[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/image/contrib/image_gallery/ -> image_gallery.install (source)

   1  <?php
   2  // $Id: image_gallery.install,v 1.20.2.1 2010/08/03 17:43:00 sun Exp $
   3  
   4  /**
   5   * Implementation of hook_install().
   6   */
   7  function image_gallery_install() {
   8    // Notify the user of the existence of the suggested menu item.
   9    $t = get_t();
  10    drupal_set_message($t('Image gallery has been installed. You may want to enable the <a href="@navigation-menu-url">Image galleries menu item</a>.', array('@navigation-menu-url' => url('admin/build/menu-customize/navigation'))));
  11  }
  12  
  13  /**
  14   * Implementation of hook_enable().
  15   */
  16  function image_gallery_enable() {
  17    if ($vocabulary = taxonomy_vocabulary_load(variable_get('image_gallery_nav_vocabulary', 0))) {
  18      // Existing install. Add back image node type, if the image
  19      // vocabulary still exists. Keep all other node types intact there.
  20      $vocabulary = (array) $vocabulary;
  21      $vocabulary['nodes']['image'] = 1;
  22      taxonomy_save_vocabulary($vocabulary);
  23    }
  24    else {
  25      // Create the image gallery vocabulary if it does not exist.
  26      $vocabulary = array(
  27        'name' => t('Image Galleries'),
  28        'multiple' => 0,
  29        'required' => 0,
  30        'hierarchy' => 1,
  31        'relations' => 0,
  32        'module' => 'image_gallery',
  33        'nodes' => array('image' => 1),
  34      );
  35      taxonomy_save_vocabulary($vocabulary);
  36  
  37      variable_set('image_gallery_nav_vocabulary', $vocabulary['vid']);
  38    }
  39  }
  40  
  41  /**
  42   * Implementation of hook_uninstall().
  43   */
  44  function image_gallery_uninstall() {
  45    if ($vid = variable_get('image_gallery_nav_vocabulary', FALSE)) {
  46      module_invoke('taxonomy', 'del_vocabulary', $vid);
  47    }
  48    variable_del('image_images_per_page');
  49    variable_del('image_gallery_nav_vocabulary');
  50    variable_del('image_gallery_node_info');
  51    variable_del('image_gallery_sort_order');
  52  }
  53  
  54  /**
  55   * Re-assign image vocabularies to image_gallery module.
  56   */
  57  function image_gallery_update_1() {
  58    $ret = array();
  59    if ($vid = variable_get('image_nav_vocabulary', '')) {
  60      $args = array($vid);
  61      $query = "UPDATE {vocabulary} SET module = 'image_gallery' WHERE vid = %d";
  62      _db_query_callback($args, TRUE);
  63      $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
  64      $ret[] = update_sql($query);
  65    }
  66    else {
  67      $ret[] = update_sql("UPDATE {vocabulary} SET module = 'image_gallery' WHERE module = 'image'");
  68    }
  69    return $ret;
  70  }
  71  
  72  /**
  73   * Rename permission "administer images" to "administer image galleries".
  74   */
  75  function image_gallery_update_6100() {
  76    $ret = array();
  77    $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
  78    while ($role = db_fetch_object($result)) {
  79      $renamed_permission = strtr($role->perm, array('administer images' => 'administer image galleries'));
  80      if ($renamed_permission != $role->perm) {
  81        $args = array($renamed_permission, $role->rid);
  82        $query = "UPDATE {permission} SET perm = '%s' WHERE rid = %d";
  83        _db_query_callback($args, TRUE);
  84        $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
  85        $ret[] = update_sql($query);
  86      }
  87    }
  88    return $ret;
  89  }
  90  
  91  /**
  92   * Clear the Views cache so our new default views are picked up.
  93   */
  94  function image_gallery_update_6101() {
  95    $ret = array();
  96    if (drupal_load('module', 'views')) {
  97      views_invalidate_cache();
  98    }
  99    return $ret;
 100  }
 101  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7