/[drupal]/contributions/modules/shazamgallery/shazamgallery.module
ViewVC logotype

Diff of /contributions/modules/shazamgallery/shazamgallery.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.22 by ber, Fri Mar 3 14:19:16 2006 UTC revision 1.23 by ber, Thu Mar 23 19:32:25 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: shazamgallery.module,v 1.21 2006/03/02 19:34:47 ber Exp $  // $Id: shazamgallery.module,v 1.22 2006/03/03 14:19:16 ber Exp $
3    
4  /**  /**
5   * Implementation of hook_help   * Implementation of hook_help
# Line 189  function shazamgallery_nodeapi(&$node, $ Line 189  function shazamgallery_nodeapi(&$node, $
189   * Implementation of hook_form_alter().   * Implementation of hook_form_alter().
190   */   */
191  function shazamgallery_form_alter($form_id, &$form) {  function shazamgallery_form_alter($form_id, &$form) {
192      // hunmonk's module dependency check: see http://drupal.org/node/54463
193      if ($form_id == 'system_modules' && !$_POST) {
194        shazamgallery_system_module_validate($form);
195      }
196    if (isset($form['type'])) {    if (isset($form['type'])) {
197      // Extend only image node form      // Extend only image node form
198      if ('image_node_form' == $form_id) {      if ('image_node_form' == $form_id) {
# Line 225  function shazamgallery_form_alter($form_ Line 229  function shazamgallery_form_alter($form_
229    }    }
230  }  }
231    
232    /**
233     * hunmonk's module dependency check: see http://drupal.org/node/54463
234     */
235    function shazamgallery_system_module_validate(&$form) {
236      $module = 'shazamgallery';
237      $dependencies = array('views', 'image');
238      foreach ($dependencies as $dependency) {
239          if (!in_array($dependency, $form['status']['#default_value'])) {
240            $missing_dependency = TRUE;
241            $missing_dependency_list[] = $dependency;
242          }
243      }
244      if (in_array($module, $form['status']['#default_value']) && isset($missing_dependency)) {
245        db_query("UPDATE {system} SET status = 0 WHERE type = 'module' AND name = '%s'", $module);
246        $key = array_search($module, $form['status']['#default_value']);
247        unset($form['status']['#default_value'][$key]);
248        drupal_set_message(t('The module %module was deactivated--it requires the following disabled/non-existant modules to function properly: %dependencies', array('%module' => $module, '%dependencies' => implode(', ', $missing_dependency_list))), 'error');
249      }
250    }
251    
252  function _shazamgallery_image_insert($node) {  function _shazamgallery_image_insert($node) {
253   //save the parents   //save the parents
254   if ($node->shazam_parents) {   if ($node->shazam_parents) {

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.3