fields(array( 'weight' => 20, )) ->condition('name', 'cdm_dataportal') ->execute(); } /** * Implements hook_uninstall(). */ function cdm_dataportal_uninstall() { // Delete all nodes with a cdm content type from the node table. // Comment @WA: you also may want to delete these content types from the // node_type table. db_delete('node') ->condition('type', 'cdm_%') ->execute(); } /* * update functions: * * - 1 digit for Drupal core compatibility. * - 1 digit for your module's major release version (e.g., is this the 7.x-1.* (1) or 7.x-2.* (2) series of your module?). This digit should be 0 for initial porting of your module to a new Drupal core API. * - 2 digits for sequential counting, starting with 00. * * @see http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_update_N/7 */ /** * update for RELEASE 3.1.3: * - reset edit_map_server variable to default */ function cdm_dataportal_update_7301() { // reset edit_map_server variable to default return _remove_variable('edit_map_server'); } /** * update for RELEASE 3.1.4: * - reset edit_map_server variable to default */ function cdm_dataportal_update_7302() { return _remove_variable('edit_map_server') . // once again reset edit_map_server variable to default _rename_variable('cdm_dataportal_show_media', 'cdm_images_include_children'); } /** * update for RELEASE 3.2.1: * - adding missing permissions for role CDM Admin */ function cdm_dataportal_update_7303() { $role = user_role_load_by_name('CDM admin'); if(!$role){ return "Role CDM admin not found, so the update is skipped."; } $tasks_performed = array(); // permissions for node types $node_type_names = node_type_get_names(); $types_to_update = array('page', 'story', 'article'); foreach ($types_to_update as $name){ if(in_array($name, $node_type_names)) { $node_type_permissions = array( 'create ' . $name . ' content', 'edit any ' . $name . ' content', 'edit own ' . $name . ' content', 'delete any ' . $name . ' content', 'delete own ' . $name . ' content', ); user_role_grant_permissions($role->rid, $node_type_permissions); $tasks_performed[] = "node type " . $name; } } if(module_exists('extlinks')){ $extlinks_permissions = array( 'access extlinks content', 'administer extlinks', ); user_role_grant_permissions($role->rid, $extlinks_permissions); $tasks_performed[] = 'permissions for extlinks'; } foreach (filter_formats() as $key=>$format){ if($key == 'full_html' || $format->format == "Full HTML"){ $formats_permissions = array( 'use text format full_html' ); user_role_grant_permissions($role->rid, $formats_permissions); $tasks_performed[] = 'use text format full_html'; } } // assure 'create url aliases' can be set if(!module_exists('path')){ module_enable(array('path'), TRUE); $tasks_performed[] = 'module path enabled'; } $other_permissions = array( 'create url aliases', 'delete revisions', 'revert revisions', 'view own unpublished content', 'flush caches' ); user_role_grant_permissions($role->rid, $other_permissions); $tasks_performed[] = 'and other permissions'; return "adding missing permissions for role CDM Admin: " . join(', ', $tasks_performed); } /** * update for RELEASE 3.2.2: * - migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image['show'] * - enabling required module file */ function cdm_dataportal_update_7304() { module_enable(array('file'), TRUE); $tasks_performed[] = 'module file enabled'; $cdm_taxon_profile_image_settings = unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT); $cdm_taxon_profile_image_settings['show'] = variable_get('cdm_dataportal_show_default_image', 0); variable_set(CDM_TAXON_PROFILE_IMAGE, $cdm_taxon_profile_image_settings); variable_del('cdm_dataportal_show_default_image'); $tasks_performed[] = 'migrating variable cdm_dataportal_show_default_image to cdm_taxon_profile_image[\'show\']'; return join(', ',$tasks_performed); } /** * Renames a persistent variable. * * @return * A message string of the performed operation. */ function _rename_variable($old_name, $new_name) { $success = FALSE; $value = variable_get($old_name, FALSE); variable_del($old_name); if ($value !== FALSE) { variable_set($new_name, $value); $success = variable_get($new_name, FALSE) === $value; } else { $success = TRUE; } return "Variable \'$old_name\' to \'$new_name\' renamed. "; } /** * Unsets a persistent variable. * * Calls variable_del() and returns a message string. * * @return * A message string of the performed operation. */ function _remove_variable($name) { variable_del($name); return "Variable \'$name\' removed. "; } /** * Sets a persistent variable. * * Calls variable_set() and returns a message string. * * @return * A message string of the performed operation. */ function _create_variable($name, $value) { variable_set($name, $value); return "Variable \'$name\' created with value: \'$value\'. "; } /** * Overwrites a persistent variable. * * Calls _create_variable() and returns a message string. * * @return * A message string of the performed operation. */ function _modify_variable($name, $value_override) { /* * FIXME take care for correct handling of tree variables * for example description_gallery contains the array: * Array ( [cdm_dataportal_show_thumbnail_captions] => 1 [cdm_dataportal_media_maxextend] => 120 [cdm_dataportal_media_cols] => 4 ) * -----> solutions merge arrays !!! */ return _create_variable($name, $value_override); }