Created
August 15, 2014 18:08
-
-
Save pvhee/d4773a3f7954bbdfd3cc to your computer and use it in GitHub Desktop.
patch scald
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/includes/ScaldAtomController.inc b/includes/ScaldAtomController.inc | |
| index 3402499..cd1f898 100644 | |
| --- a/includes/ScaldAtomController.inc | |
| +++ b/includes/ScaldAtomController.inc | |
| @@ -181,12 +181,23 @@ class ScaldAtomController extends DrupalDefaultEntityController { | |
| if (!isset($atom->data)) { | |
| $atom->data = array(); | |
| } | |
| + if (!isset($atom->created)) { | |
| + $atom->created = REQUEST_TIME; | |
| + } | |
| + if (!isset($atom->changed)) { | |
| + $atom->changed = REQUEST_TIME; | |
| + } | |
| $op = empty($atom->sid) ? 'insert' : 'update'; | |
| if ($op == 'update') { | |
| $hook = 'scald_update_atom'; | |
| $atom->original = entity_load_unchanged('scald_atom', $atom->sid); | |
| + | |
| + // Nobody updated the changed date, so we do it. | |
| + if($atom->original->changed === $atom->changed) { | |
| + $atom->changed = REQUEST_TIME; | |
| + } | |
| } | |
| else { | |
| $hook = 'scald_register_atom'; | |
| diff --git a/includes/scald.views.inc b/includes/scald.views.inc | |
| index 3763325..6983dcf 100644 | |
| --- a/includes/scald.views.inc | |
| +++ b/includes/scald.views.inc | |
| @@ -152,6 +152,36 @@ function scald_views_data() { | |
| ), | |
| ); | |
| + $data['scald_atoms']['created'] = array( | |
| + 'title' => t('Creation date'), // The item it appears as on the UI, | |
| + 'help' => t('The date the Scald atom was created.'), // The help that appears on the UI, | |
| + 'field' => array( | |
| + 'handler' => 'views_handler_field_date', | |
| + 'click sortable' => TRUE, | |
| + ), | |
| + 'sort' => array( | |
| + 'handler' => 'views_handler_sort_date', | |
| + ), | |
| + 'filter' => array( | |
| + 'handler' => 'views_handler_filter_date', | |
| + ), | |
| + ); | |
| + | |
| + $data['scald_atoms']['changed'] = array( | |
| + 'title' => t('Updated date'), // The item it appears as on the UI, | |
| + 'help' => t('The date the Scald atom was last updated.'), // The help that appears on the UI, | |
| + 'field' => array( | |
| + 'handler' => 'views_handler_field_date', | |
| + 'click sortable' => TRUE, | |
| + ), | |
| + 'sort' => array( | |
| + 'handler' => 'views_handler_sort_date', | |
| + ), | |
| + 'filter' => array( | |
| + 'handler' => 'views_handler_filter_date', | |
| + ), | |
| + ); | |
| + | |
| return $data; | |
| } | |
| diff --git a/scald.install b/scald.install | |
| index c47b73e..1efe360 100644 | |
| --- a/scald.install | |
| +++ b/scald.install | |
| @@ -91,6 +91,18 @@ function scald_schema() { | |
| 'not null' => TRUE, | |
| 'serialize' => TRUE, | |
| ), | |
| + 'created' => array( | |
| + 'description' => 'The Unix timestamp when the scald was created.', | |
| + 'type' => 'int', | |
| + 'not null' => TRUE, | |
| + 'default' => 0, | |
| + ), | |
| + 'changed' => array( | |
| + 'description' => 'The Unix timestamp when the scald was most recently saved.', | |
| + 'type' => 'int', | |
| + 'not null' => TRUE, | |
| + 'default' => 0, | |
| + ), | |
| ), | |
| 'primary key' => array('sid'), | |
| 'indexes' => array( | |
| @@ -108,6 +120,8 @@ function scald_schema() { | |
| array('type', 64), | |
| array('base_id', 64), | |
| ), | |
| + 'atom_changed' => array('changed'), | |
| + 'atom_created' => array('created'), | |
| ), | |
| ); | |
| @@ -621,3 +635,27 @@ function scald_update_7011() { | |
| } | |
| } | |
| } | |
| + | |
| +/** | |
| + * Add the {scald_atoms}.created and {scald_atoms}.changed column. | |
| + * | |
| + * "The Unix timestamp when the scald was created." | |
| + * "The Unix timestamp when the scald was most recently saved." | |
| + */ | |
| +function scald_update_7012() { | |
| + $new_field = array( | |
| + 'description' => 'The Unix timestamp when the scald was created.', | |
| + 'type' => 'int', | |
| + 'not null' => TRUE, | |
| + 'default' => 0, | |
| + ); | |
| + db_add_field('scald_atoms', 'created', $new_field); | |
| + | |
| + $new_field = array( | |
| + 'description' => 'The Unix timestamp when the scald was most recently saved.', | |
| + 'type' => 'int', | |
| + 'not null' => TRUE, | |
| + 'default' => 0, | |
| + ); | |
| + db_add_field('scald_atoms', 'changed', $new_field); | |
| +} | |
| diff --git a/scald.module b/scald.module | |
| index 06cc0d6..b6ba287 100644 | |
| --- a/scald.module | |
| +++ b/scald.module | |
| @@ -1712,6 +1712,20 @@ function scald_entity_property_info() { | |
| 'required' => TRUE, | |
| 'schema field' => 'publisher', | |
| ); | |
| + $properties['created'] = array( | |
| + 'label' => t('Created'), | |
| + 'description' => t("The Unix timestamp when the scald was created."), | |
| + 'setter callback' => 'entity_property_verbatim_set', | |
| + 'required' => TRUE, | |
| + 'schema field' => 'created', | |
| + ); | |
| + $properties['changed'] = array( | |
| + 'label' => t('Changed'), | |
| + 'description' => t("The Unix timestamp when the scald was most recently saved."), | |
| + 'setter callback' => 'entity_property_verbatim_set', | |
| + 'required' => TRUE, | |
| + 'schema field' => 'changed', | |
| + ); | |
| return $info; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment