Example #1
0
 static function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, $fnSuffix)
 {
     $result = array();
     // copied from user_module_invoke
     if (function_exists('module_list')) {
         foreach (module_list() as $module) {
             $fnName = "{$module}_{$fnSuffix}";
             if (function_exists($fnName)) {
                 if ($numParams == 1) {
                     $fResult = $fnName($arg1);
                 } else {
                     if ($numParams == 2) {
                         $fResult = $fnName($arg1, $arg2);
                     } else {
                         if ($numParams == 3) {
                             $fResult = $fnName($arg1, $arg2, $arg3);
                         } else {
                             if ($numParams == 4) {
                                 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
                             } else {
                                 if ($numParams == 5) {
                                     $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
                                 }
                             }
                         }
                     }
                 }
                 if (is_array($fResult)) {
                     $result = array_merge($result, $fResult);
                 }
             }
         }
     }
     return empty($result) ? true : $result;
 }
Example #2
0
 /**
  * @param string $folder_name
  */
 private static function includeLibClassFilesWithPattern($folder_name)
 {
     $enabled_modules = module_list();
     foreach ($enabled_modules as $module_name) {
         $module_path = drupal_get_path('module', $module_name);
         // PSR-0 compliant search
         $path = $module_path . '/lib/Drupal/' . $module_name;
         if (is_dir($path)) {
             $folders = self::listFoldersWithPattern($path, $folder_name);
             if (!empty($folders)) {
                 foreach ($folders as $folder) {
                     foreach (self::listClassesWithinFolder($folder) as $class_name) {
                         include_once $class_name;
                     }
                 }
             }
         }
         // PSR-4 compliant search
         $path = $module_path . '/src';
         if (is_dir($path)) {
             $folders = self::listFoldersWithPattern($path, $folder_name);
             if (!empty($folders)) {
                 foreach ($folders as $folder) {
                     foreach (self::listClassesWithinFolder($folder) as $class_name) {
                         include_once $class_name;
                     }
                 }
             }
         }
     }
 }
Example #3
0
 public function index($context = null)
 {
     // Get a list of modules with a controller matching
     // $context ('content', 'appearance', 'settings', 'statistics', or 'developer')
     foreach (module_list() as $module) {
         if (module_controller_exists($context, $module)) {
             $this->actions[] = $module;
         }
     }
     // Do we have any actions?
     if (!count($this->actions)) {
         return '<ul class="nav-sub clearfix"></ul>';
     }
     // Grab our module permissions so we know who can see what on the sidebar
     $permissions = config_item('module_permissions');
     // Build up our menu array
     foreach ($this->actions as $module) {
         // Make sure the user has permission to view this page.
         if (isset($permissions[$context][$module]) && has_permission($permissions[$context][$module]) || !array_key_exists($module, $permissions[$context])) {
             // Grab our module config array, if any.
             $mod_config = module_config($module);
             $display_name = isset($mod_config['name']) ? $mod_config['name'] : $module;
             $title = isset($mod_config['description']) ? $mod_config['description'] : $module;
             $menu_topic = isset($mod_config['menu_topic'][$context]) ? $mod_config['menu_topic'][$context] : $display_name;
             // Drop-down menus?
             if (isset($mod_config['menus']) && isset($mod_config['menus'][$context])) {
                 $menu_view = $mod_config['menus'][$context];
             } else {
                 $menu_view = '';
             }
             $this->menu[$menu_topic][$module] = array('title' => $title, 'display_name' => $display_name, 'menu_view' => $menu_view, 'menu_topic' => $menu_topic);
         }
     }
     return $this->build_menu($context);
 }
Example #4
0
/**
 * Get an array of data structures from the database, and allow all modules
 * to extend them.  This function will call hook_data() to get the data and
 * hook_data_alter() to allow modules to alter the data.
 * @param $type The type of data.
 * @param $opts An associative array of options.
 * @return An array of data structures.
 */
function crm_get_data($type, $opts = array())
{
    // Get the base data
    $hook = "{$type}_data";
    if (!function_exists($hook)) {
        error_register('No such data type: ' . $type);
        die;
    }
    $data = call_user_func($hook, $opts);
    if (!empty($data)) {
        // Let other modules extend the data
        foreach (module_list() as $module) {
            // Make sure module is really installed
            $rev_hook = "{$module}_revision";
            $hook = "{$module}_data_alter";
            if (function_exists($hook)) {
                if (module_get_schema_revision($module) != call_user_func($rev_hook)) {
                    error_register("Database schema needs to be upgraded for module {$module}.");
                    continue;
                }
                $data = call_user_func($hook, $type, $data, $opts);
                // Make sure the hook actually returned data
                if (is_null($data)) {
                    error_register('Hook returned null: ' . $hook);
                }
            }
        }
    }
    return $data;
}
Example #5
0
/**
 * Get a form, allowing modules to alter it.
 */
function crm_get_form()
{
    if (func_num_args() < 1) {
        return array();
    }
    $args = func_get_args();
    $form_id = array_shift($args);
    $hook = "{$form_id}_form";
    // Build initial form
    if (!function_exists($hook)) {
        error_register("No such hook: {$hook}");
        return array();
    }
    $form = call_user_func_array($hook, $args);
    if (empty($form)) {
        return $form;
    }
    // Allow modules to alter the form
    foreach (module_list() as $module) {
        $hook = $module . '_form_alter';
        if (function_exists($hook)) {
            $form = $hook($form, $form_id);
            if (empty($form)) {
                error_register('Empty form returned by ' . $hook);
            }
        }
    }
    return $form;
}
 /**
  * Generate a settings form for this handler.
  */
 public function settingsForm($field, $instance)
 {
     $field_name = $field['field_name'];
     $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via URL.'));
     $form['action_on_edit'] = array('#type' => 'checkbox', '#title' => t('Apply action on edit'), '#description' => t('Apply action when editing an existing entity.'), '#states' => array('invisible' => array(':input[name="instance[settings][behaviors][prepopulate][action]"]' => array('value' => 'none'))));
     $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via URL.'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect')));
     // Get list of permissions.
     $perms = array();
     $perms[0] = t('- None -');
     foreach (module_list(FALSE, FALSE, TRUE) as $module) {
         // By keeping them keyed by module we can use optgroups with the
         // 'select' type.
         if ($permissions = module_invoke($module, 'permission')) {
             foreach ($permissions as $id => $permission) {
                 $perms[$module][$id] = strip_tags($permission['title']);
             }
         }
     }
     $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms);
     $description = t('Determine if values that should be prepopulated should "listen" to the OG-context.');
     if ($disabled = !module_exists('og_context') || !og_is_group_audience_field($field_name)) {
         $description .= '<br / >' . t('Organic groups integration: Enable OG-context and set "Entity selection mode" to "Organic groups" to enable this selection.');
     }
     $form['og_context'] = array('#type' => 'checkbox', '#title' => t('OG context'), '#description' => $description, '#disabled' => $disabled);
     return $form;
 }
Example #7
0
 /**
  * Build the list of modules to be processed for hooks.
  */
 function buildModuleList()
 {
     if ($this->isBuilt === FALSE) {
         if ($this->drupalModules === NULL) {
             if (function_exists('module_list')) {
                 // copied from user_module_invoke
                 $this->drupalModules = module_list();
             }
         }
         if ($this->civiModules === NULL) {
             $this->civiModules = array();
             $this->requireCiviModules($this->civiModules);
         }
         // we should add civicrm's module's just after main civicrm drupal module
         // Note: Assume that drupalModules and civiModules may each be array() or NULL
         if ($this->drupalModules !== NULL) {
             foreach ($this->drupalModules as $moduleName) {
                 $this->allModules[$moduleName] = $moduleName;
                 if ($moduleName == 'civicrm') {
                     if (!empty($this->civiModules)) {
                         foreach ($this->civiModules as $civiModuleName) {
                             $this->allModules[$civiModuleName] = $civiModuleName;
                         }
                     }
                 }
             }
         } else {
             $this->allModules = (array) $this->civiModules;
         }
         if ($this->drupalModules !== NULL && $this->civiModules !== NULL) {
             // both CRM and CMS have bootstrapped, so this is the final list
             $this->isBuilt = TRUE;
         }
     }
 }
 /**
  * Finds a list of all language files for a specific language by
  * searching the application/languages folder as well as all core_module
  * folders for folders matching the language name.
  *
  * @param string $language The language
  *
  * @return array An array of files.
  */
 function list_lang_files($language = 'english')
 {
     $ci =& get_instance();
     $ci->load->helper('file');
     $lang_files = array();
     // Base language files.
     $lang_files['core'] = find_lang_files(APPPATH . 'language/' . $language . '/');
     // Module lang files
     $modules = module_list();
     $custom_modules = module_list(TRUE);
     foreach ($modules as $module) {
         $module_langs = module_files($module, 'language');
         $type = 'core';
         if (isset($module_langs[$module]['language'][$language])) {
             $path = implode('/', array($module, 'language', $language));
             if (in_array($module, $custom_modules)) {
                 $files = find_lang_files(realpath(APPPATH . '../modules/' . $path) . '/');
                 $type = 'custom';
             } else {
                 $files = find_lang_files(APPPATH . 'core_modules/' . $path . '/');
             }
             foreach ($files as $file) {
                 $lang_files[$type][] = $file;
             }
         }
         //end if
     }
     //end foreach
     return $lang_files;
 }
Example #9
0
	public function index($type=null) 
	{	
		// Get a list of modules with a controller matching
		// $type ('content', 'appearance', 'settings', 'statistics', or 'developer')
		foreach (module_list() as $module)
		{
			if (module_controller_exists($type, $module))
			{
				$this->actions[] = $module;
			}
		}
		
		// Do we have any actions? 
		if (!count($this->actions))
		{
			return '<ul class="nav-sub clearfix"></ul>';
		}
		
		// Grab our module permissions so we know who can see what on the sidebar
		$permissions = config_item('module_permissions');
		
		// Build a ul to return
		$list = "<ul class='nav-sub clearfix'>\n";
		
		foreach ($this->actions as $module)
		{
			// Make sure the user has permission to view this page.
			if ((isset($permissions[$type][$module]) && has_permission($permissions[$type][$module])) || !array_key_exists($module, $permissions[$type]))
			{
				// Is this the current module? 
				if ($module == $this->uri->segment(3))
				{
					$class = 'class="current"';
				}
				else
				{
					$class = '';
				}
				
				// Build our list item.
				$list .= '<li><a href="'. site_url('admin/'. $type .'/'. $module) .'" '. $class;
				// Icon
				/*
				if ($icon = module_icon($module))
				{
					$list .= ' style="background: url('. $icon .')"';
				}
				*/
				$list .= '>'. ucwords(str_replace('_', '', $module)) ."</a></li>\n";
			}
		}
		
		$list .= "</ul>\n";
		
		return $list;
	}
Example #10
0
 /**
  * Displays a list of installed modules with the option to create
  * a new one.
  *
  * @access public
  *
  * @return void
  */
 public function index()
 {
     $modules = module_list(true);
     $configs = array();
     // check that the modules folder is writeable
     Template::set('writeable', $this->_check_writeable());
     // Get a list of available generators
     Template::set('generators', $this->get_generators());
     Template::render();
 }
Example #11
0
 /** 
  * This hook will be called on any operation on some core CiviCRM 
  * objects. We will extend the functionality over a period of time 
  * to make it similar to Drupal's user hook, where the external module 
  * can inject and collect form elements and form information into a 
  * Drupal form (specifically the registration page and the account 
  * information page) 
  * 
  * @param string $op         the type of operation being performed 
  * @param string $objectName the BAO class name of the object 
  * @param int    $objectId   the unique identifier for the object 
  * @param object $objectRef  the reference to the object if available 
  *  
  * @return mixed             based on op. pre-hooks return a boolean and/or
  *                           an error message which aborts the operation
  * @access public 
  */
 function post($op, $objectName, $objectId, &$objectRef)
 {
     // copied from user_module_invoke
     foreach (module_list() as $module) {
         $function = $module . '_civicrm_post';
         if (function_exists($function)) {
             $function($op, $objectName, $objectId, $objectRef);
         }
     }
 }
Example #12
0
 public function getAllModulePerms() {
   $permissions = array();
   $module_list = module_list();
   ksort($module_list);
   foreach ($module_list as $module) {
     if ($perms = $this->getModulePerms($module)) {
       $permissions = array_merge($permissions, $perms);
     }
   }
   return $permissions;
 }
 /**
  * Constructs a new instance.
  *
  * @param string[] $plugin_manager_definition
  *   (optional) An array of namespace that may contain plugin implementations.
  *   Defaults to an empty array.
  * @param string $plugin_definition_annotation_name
  *   (optional) The name of the annotation that contains the plugin definition.
  *   Defaults to 'Drupal\Component\Annotation\Plugin'.
  */
 function __construct($plugin_manager_definition, $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin')
 {
     $namespaces = array();
     foreach (module_list() as $module_name) {
         $directory = DRUPAL_ROOT . '/' . drupal_get_path('module', $module_name) . '/src/' . trim($plugin_manager_definition['directory'], DIRECTORY_SEPARATOR);
         $namespaces['Drupal\\' . $module_name] = array($directory);
     }
     $this->pluginNamespaces = new \ArrayObject($namespaces);
     $this->pluginDefinitionAnnotationName = isset($plugin_manager_definition['class']) ? $plugin_manager_definition['class'] : $plugin_definition_annotation_name;
     $this->pluginManagerDefinition = $plugin_manager_definition;
 }
 function invoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, $fnSuffix)
 {
     if (!$this->first || empty($this->allModules)) {
         $this->first = TRUE;
         // copied from user_module_invoke
         if (function_exists('module_list')) {
             $this->allModules = module_list();
         }
         $this->requireCiviModules($this->allModules);
     }
     return $this->runHooks($this->allModules, $fnSuffix, $numParams, $arg1, $arg2, $arg3, $arg4, $arg5);
 }
Example #15
0
 /**
  * Display the list of modules in the Bonfire installation
  *
  * @access public
  *
  * @return void
  */
 public function modules()
 {
     $modules = module_list();
     $configs = array();
     foreach ($modules as $module) {
         $configs[$module] = module_config($module);
         if (!isset($configs[$module]['name'])) {
             $configs[$module]['name'] = ucwords($module);
         }
     }
     ksort($configs);
     Template::set('modules', $configs);
     Template::render();
 }
 /**
  * Generate a settings form for this handler.
  */
 public function settingsForm($field, $instance)
 {
     $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via URL.'));
     $form['action_on_edit'] = array('#type' => 'checkbox', '#title' => t('Apply action on edit'), '#description' => t('Apply action when editing an existing entity.'), '#states' => array('invisible' => array(':input[name="instance[settings][behaviors][prepopulate][action]"]' => array('value' => 'none'))));
     $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via URL.'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect')));
     // Get list of permissions.
     $perms = array();
     $perms[0] = t('- None -');
     foreach (module_list(FALSE, FALSE, TRUE) as $module) {
         // By keeping them keyed by module we can use optgroups with the
         // 'select' type.
         if ($permissions = module_invoke($module, 'permission')) {
             foreach ($permissions as $id => $permission) {
                 $perms[$module][$id] = strip_tags($permission['title']);
             }
         }
     }
     $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms);
     $form['providers'] = array('#type' => 'container', '#theme' => 'entityreference_prepopulate_providers_table', '#element_validate' => array('entityreference_prepopulate_providers_validate'));
     $providers = entityreference_prepopulate_providers_info();
     // Sort providers by weight.
     $providers_names = !empty($instance['settings']['behaviors']['prepopulate']['providers']) ? array_keys($instance['settings']['behaviors']['prepopulate']['providers']) : array();
     $providers_names = drupal_array_merge_deep($providers_names, array_keys($providers));
     $weight = 0;
     foreach ($providers_names as $name) {
         // Validate that the provider exists.
         if (!isset($providers[$name])) {
             continue;
         }
         $provider = $providers[$name];
         // Set default values.
         $provider += array('disabled' => FALSE);
         $form['providers']['title'][$name] = array('#type' => 'item', '#markup' => filter_xss($provider['title']), '#description' => filter_xss($provider['description']));
         if (!isset($instance['settings']['behaviors']['prepopulate']['providers'][$name])) {
             // backwards compatibility with version 1.4.
             if ($name == 'url') {
                 // Enable the URL provider is it is not set in the instance yet.
                 $default_value = TRUE;
             } elseif ($name == 'og_context') {
                 $default_value = !empty($instance['settings']['behaviors']['prepopulate']['og_context']);
             }
         } else {
             $default_value = !empty($instance['settings']['behaviors']['prepopulate']['providers'][$name]);
         }
         $form['providers']['enabled'][$name] = array('#type' => 'checkbox', '#disabled' => $provider['disabled'], '#default_value' => $default_value);
         $form['providers']['weight'][$name] = array('#type' => 'weight', '#default_value' => $weight, '#attributes' => array('class' => array('provider-weight')));
         ++$weight;
     }
     return $form;
 }
Example #17
0
 /**
  * {@inheritDoc}
  */
 public function getExtensionPathList()
 {
     $paths = array();
     // Get enabled modules.
     $modules = \module_list();
     foreach ($modules as $module) {
         $paths[] = $this->drupalRoot . DIRECTORY_SEPARATOR . \drupal_get_path('module', $module);
     }
     // Themes.
     // @todo
     // Active profile
     // @todo
     return $paths;
 }
Example #18
0
/**
 * Construct the data structure for a specified page.
 *
 * @param $page The page to construct.
 * @param $options An associative array of options.
 *
 * @return The page data structure.
 */
function page($page, $options)
{
    // Initialize page structure
    $data = array();
    // Loop through modules
    foreach (module_list() as $module) {
        // Check if hook exists and execute
        $hook = $module . '_page';
        if (function_exists($hook)) {
            $hook($data, $page, $options);
        }
    }
    return $data;
}
Example #19
0
 public function index()
 {
     $modules = module_list();
     $configs = array();
     foreach ($modules as $module) {
         $configs[$module] = module_config($module);
         if (!isset($configs[$module]['name'])) {
             $configs[$module]['name'] = ucwords($module);
         }
     }
     ksort($configs);
     Template::set('modules', $configs);
     Template::set_view('admin/developer/index');
     Template::render();
 }
Example #20
0
/**
 * Get a table, allowing modules to alter it.
 * @param $table_id The name of the table.
 * @param $opts Associative array of options.
 */
function crm_get_table($table_id, $opts = array())
{
    // Get base table
    $table = call_user_func("{$table_id}_table", $opts);
    // Allow modules to alter the table
    foreach (module_list() as $module) {
        $hook = $module . '_table_alter';
        if (function_exists($hook)) {
            $table = call_user_func($hook, $table, $table_id, $opts);
            if (is_null($table)) {
                error_register('Null table returned by ' . $hook);
            }
        }
    }
    return $table;
}
Example #21
0
 /**
  * Displays a list of installed modules with the option to create
  * a new one.
  *
  * @access public
  *
  * @return void
  */
 public function index()
 {
     $modules = module_list(true);
     $configs = array();
     foreach ($modules as $module) {
         $configs[$module] = module_config($module);
         if (!isset($configs[$module]['name'])) {
             $configs[$module]['name'] = ucwords($module);
         }
     }
     // check that the modules folder is writeable
     Template::set('writeable', $this->_check_writeable());
     ksort($configs);
     Template::set('modules', $configs);
     Template::set('toolbar_title', 'Manage Modules');
     Template::render('two_left');
 }
Example #22
0
 /**
  * Loads the config/events.php file into memory so we can access it
  * later without the disk load.
  *
  * @access public
  *
  * @return void
  */
 public static function init()
 {
     if (!function_exists('read_config')) {
         $ci =& get_instance();
         $ci->load->helper('config_file');
     }
     self::$events = read_config('events');
     // merge other modules events
     foreach (module_list(TRUE) as $module) {
         if ($module_events = read_config('events', TRUE, $module)) {
             self::$events = array_merge_recursive(self::$events, $module_events);
         }
     }
     if (self::$events == false) {
         self::$events = array();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getContainerDefinition()
 {
     FileCacheFactory::setConfiguration(array('default' => array('class' => '\\Drupal\\Component\\FileCache\\NullFileCache')));
     $container_builder = new ContainerBuilder();
     $yaml_loader = new YamlFileLoader($container_builder);
     foreach (module_list() as $module) {
         $filename = drupal_get_filename('module', $module);
         $services = dirname($filename) . "/{$module}.services.yml";
         if (file_exists($services)) {
             $yaml_loader->load($services);
         }
     }
     // Disabled for now.
     // $container_builder->compile();
     $dumper = new PhpArrayDumper($container_builder);
     return $dumper->getArray();
 }
Example #24
0
 public function index()
 {
     Assets::add_js($this->load->view('developer/modulebuilder_js', null, true), 'inline');
     $modules = module_list(true);
     $configs = array();
     foreach ($modules as $module) {
         $configs[$module] = module_config($module);
         if (!isset($configs[$module]['name'])) {
             $configs[$module]['name'] = ucwords($module);
         }
     }
     // check that the modules folder is writeable
     Template::set('writeable', $this->_check_writeable());
     ksort($configs);
     Template::set('modules', $configs);
     Template::set('toolbar_title', 'Manage Modules');
     Template::render();
 }
 /**
  * Generate a settings form for this handler.
  */
 public function settingsForm($field, $instance)
 {
     $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via URL.'));
     $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via URL.'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect')));
     // Get list of permissions.
     $perms = array();
     $perms[0] = t('- None -');
     foreach (module_list(FALSE, FALSE, TRUE) as $module) {
         // By keeping them keyed by module we can use optgroups with the
         // 'select' type.
         if ($permissions = module_invoke($module, 'permission')) {
             foreach ($permissions as $id => $permission) {
                 $perms[$module][$id] = strip_tags($permission['title']);
             }
         }
     }
     $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms);
     return $form;
 }
Example #26
0
 /**
  * Build the list of modules to be processed for hooks.
  */
 function buildModuleList()
 {
     if ($this->isBuilt === FALSE) {
         if ($this->drupalModules === NULL) {
             if (function_exists('module_list')) {
                 // copied from user_module_invoke
                 $this->drupalModules = module_list();
             }
         }
         if ($this->civiModules === NULL) {
             $this->civiModules = array();
             $this->requireCiviModules($this->civiModules);
         }
         $this->allModules = array_merge((array) $this->drupalModules, (array) $this->civiModules);
         if ($this->drupalModules !== NULL && $this->civiModules !== NULL) {
             // both CRM and CMS have bootstrapped, so this is the final list
             $this->isBuilt = TRUE;
         }
     }
 }
Example #27
0
/**
 * Process a command and redirect.
 * @param $command The name of the command to process
 * @return The url to redirect to.
 */
function command($command)
{
    // Initialize url and parameters
    $url = '';
    $params = array();
    // Call legacy handler if it exists
    $handler = "command_{$command}";
    if (function_exists($handler)) {
        $res = call_user_func($handler);
        // Split result into file and params
        $parts = explode('?', $res);
        $url = $parts[0];
        if (sizeof($parts) > 0) {
            $clauses = explode('&', $parts[1]);
            foreach ($clauses as $clause) {
                $keyvalue = explode('=', $clause);
                if (sizeof($keyvalue) > 1) {
                    $params[$keyvalue[0]] = $keyvalue[1];
                }
            }
        }
    }
    // Call the handler for each module if it exists
    foreach (module_list() as $module) {
        $handler = "{$module}_command";
        if (function_exists($handler)) {
            $handler($command, $url, $params);
        }
    }
    // Error if the url is still empty
    if (empty($url)) {
        error_register('No such command: ' . $command);
        $url = crm_url();
    }
    $url .= '?';
    $parts = array();
    foreach ($params as $key => $value) {
        $parts[] = $key . '=' . $value;
    }
    return $url . implode('&', $parts);
}
 /**
  * Generate a settings form for this handler.
  */
 public function settingsForm($field, $instance)
 {
     $field_name = $field['field_name'];
     $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via Current Entity(Menu Object).'));
     $form['action_on_edit'] = array('#type' => 'checkbox', '#title' => t('Apply action on edit'), '#description' => t('Apply action when editing an existing entity.'), '#states' => array('invisible' => array(':input[name="instance[settings][behaviors][current][action]"]' => array('value' => 'none'))));
     $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via via Current Entity(Menu Object).'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect')));
     // Get list of permissions.
     $perms = array();
     $perms[0] = t('- None -');
     foreach (module_list(FALSE, FALSE, TRUE) as $module) {
         // By keeping them keyed by module we can use optgroups with the
         // 'select' type.
         if ($permissions = module_invoke($module, 'permission')) {
             foreach ($permissions as $id => $permission) {
                 $perms[$module][$id] = strip_tags($permission['title']);
             }
         }
     }
     $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms);
     $form['use_uid'] = array('#type' => 'checkbox', '#title' => t('Use the Author for an entity if target type is user.'), '#description' => t('If the target type is User but the current page is a Node select the Author as the entity.'));
     return $form;
 }
Example #29
0
 public function index()
 {
     $modules = module_list();
     $configs = array();
     foreach ($modules as $module) {
         $configs[$module] = module_config($module);
         if (!isset($configs[$module]['name'])) {
             $configs[$module]['name'] = ucwords($module);
         } else {
             if (is_array($configs[$module]['name'])) {
                 if (isset($configs[$module]['name'][$this->config->item('language')])) {
                     $configs[$module]['name'] = $configs[$module]['name'][$this->config->item('language')];
                 } else {
                     if (isset($configs[$module]['name'][$this->config->item('english')])) {
                         $configs[$module]['name'] = $configs[$module]['name'][$this->config->item('english')];
                     }
                 }
             }
         }
         if (!isset($configs[$module]['description'])) {
             $configs[$module]['description'] = '---';
         } else {
             if (is_array($configs[$module]['description'])) {
                 if (isset($configs[$module]['description'][$this->config->item('language')])) {
                     $configs[$module]['description'] = $configs[$module]['description'][$this->config->item('language')];
                 } else {
                     if (isset($configs[$module]['description'][$this->config->item('english')])) {
                         $configs[$module]['description'] = $configs[$module]['description'][$this->config->item('english')];
                     }
                 }
             }
         }
     }
     ksort($configs);
     Template::set('modules', $configs);
     Template::set_view('admin/developer/index');
     Template::render();
 }
Example #30
0
/**
 * Registry Rebuild needs to aggressively clear all caches,
 * not just some bins (at least to attempt it) also *before*
 * attempting to rebuild registry, or it may not be able
 * to fix the problem at all, if it relies on some cached
 * and no longer valid data/paths etc. This problem has been
 * confirmed and reproduced many times with option --fire-bazooka
 * which is available only in the Drush variant, but it confirms
 * the importance of starting with real, raw and not cached
 * in any way site state. While the --no-cache-clear option
 * still disables this procedure, --fire-bazooka takes precedence
 * and forces all caches clear action. All caches are cleared
 * by default in the PHP script variant.
 */
function registry_rebuild_cc_all()
{
    if (function_exists('cache_clear_all')) {
        cache_clear_all('*', 'cache', TRUE);
        cache_clear_all('*', 'cache_form', TRUE);
    } else {
        cache('cache')->deleteAll();
        cache('cache_form')->deleteAll();
    }
    if (function_exists('module_rebuild_cache')) {
        // D5-D6
        module_list(TRUE, FALSE);
        module_rebuild_cache();
    }
    if (function_exists('drupal_flush_all_caches')) {
        // D6+
        drupal_flush_all_caches();
    } else {
        // D5
        cache_clear_all();
        system_theme_data();
        node_types_rebuild();
        menu_rebuild();
    }
    print "All caches have been cleared with registry_rebuild_cc_all.<br/>\n";
}