| 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 |
| 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) { |
| 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) { |