| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: features.module,v 1.1.2.79 2010/08/05 20:50:03 yhahn Exp $ 3 4 /** 5 * @file 6 * Module file for the features module, which enables the capture and 7 * management of features in Drupal. A feature is a collection of Drupal 8 * entities which taken together statisfy a certain use-case. 9 */ 10 11 define('FEATURES_MODULE_ENABLED', 1); 12 define('FEATURES_MODULE_DISABLED', 0); 13 define('FEATURES_MODULE_MISSING', -1); 14 15 define('FEATURES_REBUILDABLE', -1); 16 define('FEATURES_DEFAULT', 0); 17 define('FEATURES_OVERRIDDEN', 1); 18 define('FEATURES_NEEDS_REVIEW', 2); 19 define('FEATURES_REBUILDING', 3); 20 define('FEATURES_CONFLICT', 4); 21 define('FEATURES_DISABLED', 5); 22 23 // Duration of rebuild semaphore: 10 minutes. 24 define('FEATURES_SEMAPHORE_TIMEOUT', 10 * 60); 25 26 /** 27 * Components with this 'default_file' flag will have exports written to the 28 * common defaults file 'MODULENAME.features.inc'. This is the default 29 * behavior. 30 */ 31 define('FEATURES_DEFAULTS_INCLUDED_COMMON', 0); 32 33 /** 34 * Components with this 'default_file' flag will have exports written to a 35 * defaults based on the component name like 'MODULENAME.features.COMPONENT-NAME.inc'. 36 * Any callers to this component's defaults hook must call 37 * features_include_defaults('component') in order to include this file. 38 */ 39 define('FEATURES_DEFAULTS_INCLUDED', 1); 40 41 /** 42 * Components with this 'default_file' flag must specify a filename for their 43 * exports. Additionally a stub will NOT be written to 'MODULENAME.features.inc' 44 * allowing the file to be included directly by the implementing module. 45 */ 46 define('FEATURES_DEFAULTS_CUSTOM', 2); 47 48 /** 49 * Components with this 'duplicates' flag may not have multiple features provide the 50 * same component key in their info files. This is the default behavior. 51 */ 52 define('FEATURES_DUPLICATES_CONFLICT', 0); 53 54 /** 55 * Components with this 'duplicates' flag are allowed to have multiple features 56 * provide the same component key in their info files. 57 */ 58 define('FEATURES_DUPLICATES_ALLOWED', 1); 59 60 /** 61 * Implementation of hook_menu(). 62 */ 63 function features_menu() { 64 $items = array(); 65 $items['admin/build/features'] = array( 66 'title' => 'Features', 67 'description' => 'Manage features.', 68 'page callback' => 'drupal_get_form', 69 'page arguments' => array('features_admin_form'), 70 'type' => MENU_NORMAL_ITEM, 71 'file' => 'features.admin.inc', 72 ); 73 $items['admin/build/features/cleanup'] = array( 74 'title' => 'Cleanup', 75 'description' => 'Detect and disable any orphaned feature dependencies.', 76 'page callback' => 'drupal_get_form', 77 'page arguments' => array('features_cleanup_form', 4), 78 'type' => MENU_CALLBACK, 79 'file' => 'features.admin.inc', 80 'weight' => 1, 81 ); 82 $items['admin/build/features/manage'] = array( 83 'title' => 'Manage', 84 'description' => 'Enable and disable features.', 85 'page callback' => 'drupal_get_form', 86 'page arguments' => array('features_admin_form'), 87 'type' => MENU_DEFAULT_LOCAL_TASK, 88 'file' => 'features.admin.inc', 89 ); 90 $items['admin/build/features/create'] = array( 91 'title' => 'Create feature', 92 'description' => 'Create a new feature.', 93 'page callback' => 'drupal_get_form', 94 'page arguments' => array('features_export_form'), 95 'access callback' => 'user_access', 96 'access arguments' => array('administer features'), 97 'type' => MENU_LOCAL_TASK, 98 'file' => "features.admin.inc", 99 'weight' => 10, 100 ); 101 $items['admin/build/features/export/populate'] = array( 102 'title' => 'Populate feature', 103 'description' => 'AHAH callback to populate a feature from selected components.', 104 'page callback' => 'features_export_build_form_populate', 105 'page arguments' => array(), 106 'access callback' => 'user_access', 107 'access arguments' => array('administer features'), 108 'type' => MENU_CALLBACK, 109 'file' => "features.admin.inc", 110 ); 111 $items['admin/build/features/%feature'] = array( 112 'title callback' => 'features_get_feature_title', 113 'title arguments' => array(3), 114 'description' => 'Display components of a feature.', 115 'page callback' => 'drupal_get_form', 116 'page arguments' => array('features_admin_components', 3), 117 'access callback' => 'user_access', 118 'access arguments' => array('administer features'), 119 'type' => MENU_CALLBACK, 120 'file' => 'features.admin.inc', 121 ); 122 $items['admin/build/features/%feature/view'] = array( 123 'title' => 'View', 124 'description' => 'Display components of a feature.', 125 'access callback' => 'user_access', 126 'access arguments' => array('administer features'), 127 'type' => MENU_DEFAULT_LOCAL_TASK, 128 'weight' => -10, 129 ); 130 $items['admin/build/features/%feature/recreate'] = array( 131 'title' => 'Recreate', 132 'description' => 'Recreate an existing feature.', 133 'page callback' => 'drupal_get_form', 134 'page arguments' => array('features_export_form', 3), 135 'access callback' => 'user_access', 136 'access arguments' => array('administer features'), 137 'type' => MENU_LOCAL_TASK, 138 'file' => "features.admin.inc", 139 'weight' => 11, 140 ); 141 if (module_exists('diff')) { 142 $items['admin/build/features/%feature/diff'] = array( 143 'title' => 'Review overrides', 144 'description' => 'Compare default and current feature.', 145 'page callback' => 'features_feature_diff', 146 'page arguments' => array(3, 5), 147 'access callback' => 'features_access_override_actions', 148 'access arguments' => array(3), 149 'type' => MENU_LOCAL_TASK, 150 'file' => 'features.admin.inc', 151 ); 152 } 153 $items['admin/build/features/%feature/status'] = array( 154 'title' => 'Status', 155 'description' => 'Javascript status call back.', 156 'page callback' => 'features_feature_status', 157 'page arguments' => array(3), 158 'access callback' => 'user_access', 159 'access arguments' => array('administer features'), 160 'type' => MENU_CALLBACK, 161 'file' => 'features.admin.inc', 162 ); 163 foreach ($items as $path => $item) { 164 if (!isset($item['access callback'])) { 165 $items[$path]['access callback'] = 'user_access'; 166 $items[$path]['access arguments'] = array('manage features'); 167 } 168 } 169 return $items; 170 } 171 172 /** 173 * Implementation of hook_theme(). 174 */ 175 function features_theme() { 176 $base = array( 177 'path' => drupal_get_path('module', 'features') .'/theme', 178 'file' => 'theme.inc', 179 ); 180 181 $items = array(); 182 $items['features_components'] = 183 $items['features_component_key'] = 184 $items['features_component_list'] = 185 $items['features_form_buttons'] = 186 $items['features_form_components'] = 187 $items['features_form_export'] = 188 $items['features_form_package'] = 189 $items['features_module_status'] = 190 $items['features_storage_link'] = $base; 191 192 $items['features_admin_components'] = array( 193 'arguments' => array('form' => NULL), 194 'template' => 'features-admin-components', 195 ) + $base; 196 197 $items['features_form'] = array( 198 'arguments' => array('form' => NULL), 199 'template' => 'features-form', 200 ) + $base; 201 202 return $items; 203 } 204 205 /** 206 * Implementation of hook_flush_caches(). 207 */ 208 function features_flush_caches() { 209 features_rebuild(); 210 features_get_modules(NULL, TRUE); 211 return array(); 212 } 213 214 /** 215 * Implementation of hook_form(). 216 */ 217 function features_form($node, $form_state) { 218 return node_content_form($node, $form_state); 219 } 220 221 /** 222 * Implemenation of hook_access() 223 */ 224 function features_access($op, $node, $account) { 225 return node_content_access($op, $node, $account); 226 } 227 228 /** 229 * Implementation of hook_perm(). 230 */ 231 function features_perm() { 232 $perms = array('administer features', 'manage features'); 233 // Generate permissions for any default node types provided by features. 234 foreach (node_get_types() as $type) { 235 if ($type->module == 'features') { 236 $name = check_plain($type->type); 237 $perms[] = 'create '. $name .' content'; 238 $perms[] = 'delete own '. $name .' content'; 239 $perms[] = 'delete any '. $name .' content'; 240 $perms[] = 'edit own '. $name .' content'; 241 $perms[] = 'edit any '. $name .' content'; 242 } 243 } 244 return $perms; 245 } 246 247 /** 248 * Implementation of hook_help(). 249 */ 250 function features_help($path, $arg) { 251 switch ($path) { 252 case 'admin/help#features': 253 $output = file_get_contents(drupal_get_path('module', 'features') .'/README.txt'); 254 return module_exists('markdown') ? filter_xss_admin(module_invoke('markdown', 'filter', 'process', 0, -1, $output)) : '<pre>'. check_plain($output) .'</pre>'; 255 case 'admin/build/features': 256 return '<p>'. t('A "Feature" is a certain type of Drupal module with contains a package of configuration that, when enabled, provides a new set of functionality for your Drupal site. Enable features by selecting the checkboxes below and clicking the Save configuration button. If the configuration of the feature has been changed its "State" will be either "overridden" or "needs review", otherwise it will be "default", indicating that the configuration has not been changed. Click on the state to see more details about the feature and its components.') .'</p>'; 257 } 258 } 259 260 /** 261 * Load includes for any modules that implement the features API and 262 * load includes for those provided by features. 263 */ 264 function features_include($reset = FALSE) { 265 static $once; 266 if (!isset($once) || $reset) { 267 $once = TRUE; 268 269 // Check for implementing modules and make necessary inclusions. 270 foreach (module_implements('features_api') as $module) { 271 $info = module_invoke($module, 'features_api'); 272 foreach ($info as $component) { 273 if (isset($component['file'])) { 274 require_once $component['file']; 275 } 276 } 277 } 278 279 // Features provides integration on behalf of these modules. 280 // The features include provides handling for the feature dependencies. 281 // Note that ctools is placed last because it implements hooks "dynamically" for other modules. 282 $modules = array('features', 'block', 'content', 'context', 'fieldgroup', 'filter', 'imagecache', 'menu', 'node', 'taxonomy', 'user', 'views', 'ctools'); 283 284 foreach (array_filter($modules, 'module_exists') as $module) { 285 if (!module_hook($module, 'features_api')) { 286 module_load_include('inc', 'features', "includes/features.$module"); 287 } 288 } 289 290 // Clear static cache, since we've now included new implementers. 291 module_implements('features_api', FALSE, TRUE); 292 } 293 } 294 295 /** 296 * Load features includes for all components that require includes before 297 * collecting defaults. 298 */ 299 function features_include_defaults($components = NULL, $reset = FALSE) { 300 static $included = array(); 301 static $include_components; 302 303 // Build an array of components that require inclusion: 304 // Views, CTools components and those using FEATURES_DEFAULTS_INCLUDED. 305 if (!isset($include_components) || $reset) { 306 $include_components = features_get_components(); 307 foreach ($include_components as $component => $info) { 308 if ($component !== 'views' && !isset($info['api']) && (!isset($info['default_file']) || $info['default_file'] !== FEATURES_DEFAULTS_INCLUDED)) { 309 unset($include_components[$component]); 310 } 311 } 312 } 313 314 // If components are specified, only include for the specified components. 315 if (isset($components)) { 316 $components = is_array($components) ? $components : array($components); 317 } 318 // Use all include components if none are explicitly specified. 319 else { 320 $components = $include_components; 321 } 322 foreach ($components as $component) { 323 if (isset($include_components[$component]) && (!isset($included[$component]) || $reset)) { 324 $info = $include_components[$component]; 325 // Inclusion of defaults for Views. 326 if ($component === 'views') { 327 views_include('view'); 328 views_include_default_views(); 329 } 330 // Inclusion of defaults for CTools. 331 else if (isset($info['api'], $info['module'], $info['current_version'])) { 332 ctools_include('plugins'); 333 ctools_plugin_api_include($info['module'], $info['api'], $info['current_version'], $info['current_version']); 334 } 335 // Inclusion of defaults for components using FEATURES_DEFAULTS_INCLUDED. 336 else { 337 $features = isset($features) ? $features : features_get_features(NULL, $reset); 338 foreach ($features as $feature) { 339 module_load_include('inc', $feature->name, "{$feature->name}.features.{$component}"); 340 } 341 } 342 $included[$component] = TRUE; 343 } 344 } 345 } 346 347 /** 348 * Feature object loader. 349 */ 350 function feature_load($name, $reset = FALSE) { 351 return features_get_features($name, $reset); 352 } 353 354 /** 355 * Return a module 'object' including .info information. 356 * 357 * @param $name 358 * The name of the module to retrieve information for. If ommitted, 359 * an array of all available modules will be returned. 360 * @param $reset 361 * Whether to reset the cache. 362 * 363 * @return 364 * If a module is request (and exists) a module object is returned. If no 365 * module is requested info for all modules is returned. 366 */ 367 function features_get_modules($name = NULL, $reset = FALSE) { 368 return features_get_info('module', $name, $reset); 369 } 370 371 /** 372 * Returns the array of supported components. 373 * 374 * @param $feature_source 375 * If set to to TRUE return feature sources only. 376 * @return An array of component labels keyed by the component names. 377 */ 378 function features_get_components($feature_source = FALSE, $reset = FALSE) { 379 features_include(); 380 static $components_all; 381 static $components_source; 382 if (!isset($components_all) || $reset) { 383 $components_all = $components_source = array(); 384 foreach (module_implements('features_api') as $module) { 385 $info = module_invoke($module, 'features_api'); 386 foreach ($info as $k => $v) { 387 $components_all[$k] = $v; 388 if (!empty($v['feature_source'])) { 389 $components_source[$k] = $v; 390 } 391 } 392 } 393 } 394 return $feature_source ? $components_source : $components_all; 395 } 396 397 /** 398 * Like module_invoke() but for arbitrary callback base names. 399 */ 400 function features_invoke() { 401 $args = func_get_args(); 402 $base = $args[0]; 403 $hook = $args[1]; 404 unset($args[0], $args[1]); 405 $function = $base .'_'. $hook; 406 if (features_hook($base, $hook)) { 407 return call_user_func_array($function, $args); 408 } 409 } 410 411 /** 412 * Like module_invoke_all() but for arbitrary callback base names. 413 */ 414 function features_invoke_all() { 415 $args = func_get_args(); 416 $hook = $args[0]; 417 unset($args[0]); 418 $return = array(); 419 foreach (features_get_components() as $component => $info) { 420 $result = features_invoke($component, $hook); 421 if (isset($result) && is_array($result)) { 422 $return = array_merge_recursive($return, $result); 423 } 424 else if (isset($result)) { 425 $return[] = $result; 426 } 427 } 428 return $return; 429 } 430 431 /** 432 * Like module_hook() but for arbitrary callback base names. 433 */ 434 function features_hook($base, $hook) { 435 return function_exists($base .'_'. $hook); 436 } 437 438 /** 439 * Enables and installs an array of modules, ignoring those 440 * already enabled & installed. Consider this a helper or 441 * extension to drupal_install_modules(). 442 * 443 * @param $modules 444 * An array of modules to install. 445 * @param $reset 446 * Clear the module info cache. 447 */ 448 function features_install_modules($modules) { 449 module_load_include('inc', 'features', 'features.export'); 450 $files = module_rebuild_cache(); 451 452 // Build maximal list of dependencies. 453 $install = array(); 454 foreach ($modules as $name) { 455 if ($file = $files[$name]) { 456 $install[] = $name; 457 if (!empty($file->info['dependencies'])) { 458 $install = array_merge($install, _features_export_maximize_dependencies($file->info['dependencies'])); 459 } 460 } 461 } 462 463 // Filter out enabled modules. 464 $enabled = array_filter($install, 'module_exists'); 465 $install = array_diff($install, $enabled); 466 467 if (!empty($install)) { 468 // Make sure the install API is available. 469 $install = array_unique($install); 470 include_once './includes/install.inc'; 471 drupal_install_modules($install); 472 } 473 } 474 475 /** 476 * Wrapper around features_get_info() that returns an array 477 * of module info objects that are features. 478 */ 479 function features_get_features($name = NULL, $reset = FALSE) { 480 return features_get_info('feature', $name, $reset); 481 } 482 483 /** 484 * Helper for retrieving info from system table. 485 */ 486 function features_get_info($type = 'module', $name = NULL, $reset = FALSE) { 487 static $cache; 488 if (!isset($cache)) { 489 $cache = cache_get('features_module_info'); 490 } 491 if (empty($cache) || $reset) { 492 $data = array(); 493 $ignored = variable_get('features_ignored_orphans', array()); 494 $result = db_query("SELECT filename, name, type, status, throttle, schema_version FROM {system} WHERE type = 'module' ORDER BY name ASC"); 495 while ($row = db_fetch_object($result)) { 496 // If module is no longer enabled, remove it from the ignored orphans list. 497 if (in_array($row->name, $ignored, TRUE) && !$row->status) { 498 $key = array_search($row->name, $ignored, TRUE); 499 unset($ignored[$key]); 500 } 501 502 // Parse and allow modules to alter the info file if necessary. 503 $row->info = drupal_parse_info_file(dirname($row->filename) .'/'. $row->name .'.info'); 504 if (!empty($row->info)) { 505 drupal_alter('system_info', $row->info, $row); 506 if (!empty($row->info['features'])) { 507 $data['feature'][$row->name] = $row; 508 } 509 $data['module'][$row->name] = $row; 510 } 511 } 512 variable_set('features_ignored_orphans', $ignored); 513 cache_set("features_module_info", $data); 514 $cache = new stdClass(); 515 $cache->data = $data; 516 } 517 if (!empty($name)) { 518 return !empty($cache->data[$type][$name]) ? $cache->data[$type][$name] : FALSE; 519 } 520 return !empty($cache->data[$type]) ? $cache->data[$type] : array(); 521 } 522 523 /** 524 * Generate an array of feature dependencies that have been orphaned. 525 */ 526 function features_get_orphans($reset = FALSE) { 527 static $orphans; 528 if (!isset($orphans) || $reset) { 529 module_load_include('inc', 'features', 'features.export'); 530 $orphans = array(); 531 532 // Build a list of all dependencies for enabled and disabled features. 533 $dependencies = array('enabled' => array(), 'disabled' => array()); 534 $features = features_get_features(); 535 foreach ($features as $feature) { 536 $key = module_exists($feature->name) ? 'enabled' : 'disabled'; 537 if (!empty($feature->info['dependencies'])) { 538 $dependencies[$key] = array_merge($dependencies[$key], _features_export_maximize_dependencies($feature->info['dependencies'])); 539 } 540 } 541 $dependencies['enabled'] = array_unique($dependencies['enabled']); 542 $dependencies['disabled'] = array_unique($dependencies['disabled']); 543 544 // Find the list of orphaned modules. 545 $orphaned = array_diff($dependencies['disabled'], $dependencies['enabled']); 546 $orphaned = array_intersect($orphaned, module_list(FALSE, FALSE)); 547 $orphaned = array_diff($orphaned, drupal_required_modules()); 548 $orphaned = array_diff($orphaned, array('features')); 549 550 // Build final list of modules that can be disabled. 551 $modules = features_get_modules(NULL, TRUE); 552 $enabled = module_list(); 553 _module_build_dependencies($modules); 554 555 foreach ($orphaned as $module) { 556 if (!empty($modules[$module]->info['dependents'])) { 557 // Determine whether any dependents are actually enabled. 558 $dependents = array_intersect($modules[$module]->info['dependents'], $enabled); 559 if (empty($dependents)) { 560 $info = features_get_modules($module); 561 $orphans[$module] = $info; 562 } 563 } 564 } 565 } 566 return $orphans; 567 } 568 569 /** 570 * Detect potential conflicts between any features that provide 571 * identical components. 572 */ 573 function features_get_conflicts($reset = FALSE) { 574 $conflicts = array(); 575 $component_info = features_get_components(); 576 $map = features_get_component_map(NULL, $reset); 577 578 foreach ($map as $type => $components) { 579 foreach ($components as $component => $modules) { 580 if (isset($component_info[$type]['duplicates']) && $component_info[$type]['duplicates'] == FEATURES_DUPLICATES_ALLOWED) { 581 continue; 582 } 583 else if (count($modules) > 1) { 584 foreach ($modules as $module) { 585 if (!isset($conflicts[$module])) { 586 $conflicts[$module] = array(); 587 } 588 foreach ($modules as $m) { 589 if ($m != $module) { 590 $conflicts[$module][$m][$type][] = $component; 591 } 592 } 593 } 594 } 595 } 596 } 597 598 return $conflicts; 599 } 600 601 /** 602 * Provide a component to feature map. 603 */ 604 function features_get_component_map($key = NULL, $reset = FALSE) { 605 static $map; 606 if (!isset($map) || $reset) { 607 $map = array(); 608 $features = features_get_features(NULL, $reset); 609 foreach ($features as $feature) { 610 foreach ($feature->info['features'] as $type => $components) { 611 if (!isset($map[$type])) { 612 $map[$type] = array(); 613 } 614 foreach ($components as $component) { 615 $map[$type][$component][] = $feature->name; 616 } 617 } 618 } 619 } 620 if (isset($key)) { 621 return isset($map[$key]) ? $map[$key] : array(); 622 } 623 return $map; 624 } 625 626 /** 627 * Simple wrapper returns the status of a module. 628 */ 629 function features_get_module_status($module) { 630 if (module_exists($module)) { 631 return FEATURES_MODULE_ENABLED; 632 } 633 else if (features_get_modules($module)) { 634 return FEATURES_MODULE_DISABLED; 635 } 636 else { 637 return FEATURES_MODULE_MISSING; 638 } 639 } 640 641 /** 642 * Menu title callback. 643 */ 644 function features_get_feature_title($feature) { 645 return $feature->info['name']; 646 } 647 648 /** 649 * Menu access callback for whether a user should be able to access 650 * override actions for a given feature. 651 */ 652 function features_access_override_actions($feature) { 653 if (user_access('administer features')) { 654 static $access = array(); 655 if (!isset($access[$feature->name])) { 656 // Set a value first. We may get called again from within features_detect_overrides(). 657 $access[$feature->name] = FALSE; 658 659 features_include(); 660 module_load_include('inc', 'features', 'features.export'); 661 $access[$feature->name] = in_array(features_get_storage($feature->name), array(FEATURES_OVERRIDDEN, FEATURES_NEEDS_REVIEW)) && user_access('administer features'); 662 } 663 return $access[$feature->name]; 664 } 665 return FALSE; 666 } 667 668 /** 669 * Implementation of hook_form_alter() for system_modules form. 670 */ 671 function features_form_system_modules_alter(&$form) { 672 features_rebuild(); 673 } 674 675 /** 676 * Restore the specified modules to the default state. 677 */ 678 function _features_restore($op, $items = array()) { 679 // Since we can't ensure that users will run update.php immediately after 680 // updating the features codebase, we must check the schema version explicitly 681 // to ensure that we will not blow away any overrides. 682 module_load_install('features'); 683 if (drupal_get_installed_schema_version('features', TRUE) < 6101) { 684 return; 685 } 686 687 module_load_include('inc', 'features', 'features.export'); 688 features_include(); 689 690 switch ($op) { 691 case 'revert': 692 $restore_states = array(FEATURES_OVERRIDDEN, FEATURES_REBUILDABLE, FEATURES_NEEDS_REVIEW); 693 $restore_hook = 'features_revert'; 694 $log_action = 'Revert'; 695 break; 696 case 'rebuild': 697 $restore_states = array(FEATURES_REBUILDABLE); 698 $restore_hook = 'features_rebuild'; 699 $log_action = 'Rebuild'; 700 break; 701 } 702 703 if (empty($items)) { 704 $states = features_get_component_states(); 705 foreach ($states as $module_name => $components) { 706 foreach ($components as $component => $state) { 707 if (in_array($state, $restore_states)) { 708 $items[$module_name][] = $component; 709 } 710 } 711 } 712 } 713 714 foreach ($items as $module_name => $components) { 715 foreach ($components as $component) { 716 if (features_hook($component, $restore_hook)) { 717 // Set a semaphore to prevent other instances of the same script from running concurrently. 718 watchdog('features', '@actioning @module_name / @component.', array('@action' => $log_action, '@component' => $component, '@module_name' => $module_name)); 719 features_semaphore('set', $component); 720 features_invoke($component, $restore_hook, $module_name); 721 722 // If the script completes, remove the semaphore and set the code signature. 723 features_semaphore('del', $component); 724 features_set_signature($module_name, $component); 725 watchdog('features', '@action completed for @module_name / @component.', array('@action' => $log_action, '@component' => $component, '@module_name' => $module_name)); 726 } 727 } 728 } 729 } 730 731 /** 732 * Wrapper around _features_restore(). 733 */ 734 function features_revert($revert = array()) { 735 return _features_restore('revert', $revert); 736 } 737 738 /** 739 * Wrapper around _features_restore(). 740 */ 741 function features_rebuild($rebuild = array()) { 742 return _features_restore('rebuild', $rebuild); 743 } 744 745 /** 746 * Utility functions ================================================== 747 */ 748 749 /** 750 * Represent the current state of permissions as a role name to role/perm array. 751 */ 752 function _features_get_roles() { 753 $roles = array(); 754 $result = db_query("SELECT r.rid, r.name, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid"); 755 while ($row = db_fetch_object($result)) { 756 $roles[$row->name] = array( 757 'rid' => $row->rid, 758 'perm' => explode(', ', $row->perm), 759 ); 760 } 761 return $roles; 762 } 763 764 /** 765 * Log a message, environment agnostic. 766 * 767 * @param $message 768 * The message to log. 769 * @param $severity 770 * The severity of the message: status, warning or error. 771 */ 772 function features_log($message, $severity = 'status') { 773 if (function_exists('drush_verify_cli')) { 774 $message = strip_tags($message); 775 if ($severity == 'status') { 776 $severity = 'ok'; 777 } 778 elseif ($severity == 'error') { 779 drush_set_error($message); 780 return; 781 } 782 drush_log($message, $severity); 783 return; 784 } 785 drupal_set_message($message, $severity, FALSE); 786 } 787 788 /** 789 * Targeted form_alter for vocabulary edit pages. 790 */ 791 function features_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) { 792 module_load_include('inc', 'features', "includes/features.taxonomy"); 793 _features_form_taxonomy_form_vocabulary_alter($form, $form_state); 794 } 795
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |