function gd_ext () {

    ob_get_clean();

    if ( !empty($_REQUEST['datasource']) ) {
        gd_datasource_set_active($_REQUEST['datasource']);
    }

    $ext = array();
    $dashboards = gd_dashboard_findall_by_datasource(LOAD_ENTITY);
    foreach ( $dashboards as $dashboard ) {
        $ext[] = array('id'=>$dashboard->nid,'title'=>$dashboard->title);
    }

    $response = new stdClass();
    $response->status = new stdClass();
    $response->status->code = 200;
    $response->status->message = 'OK';

    if ( isset($_REQUEST['id']) ) {
        $response->data = array('id'=>$_REQUEST['id'], 'title'=>$dashboards[$_REQUEST['id']]->title);
    }
    else {
        $response->data = $ext;
    }

    module_invoke_all('gd_ext_response_alter',$response);

    echo \GD\Utility\Json::getPayload($response,$_GET['callback']);

    gd_get_session_messages();

    drupal_exit();
}
 public function overviewForm($form, &$form_state)
 {
     // Add table and pager.
     $form = parent::overviewForm($form, $form_state);
     // Allow modules to insert their own action links to the 'table', like cleanup module.
     $top_actions = module_invoke_all('workflow_operations', 'top_actions', NULL);
     // Allow modules to insert their own workflow operations.
     foreach ($form['table']['#rows'] as &$row) {
         $url = $row[0]['data']['#url'];
         $workflow = $url['options']['entity'];
         foreach ($actions = module_invoke_all('workflow_operations', 'workflow', $workflow) as $action) {
             $action['attributes'] = isset($action['attributes']) ? $action['attributes'] : array();
             $row[] = l(strtolower($action['title']), $action['href'], $action['attributes']);
         }
     }
     // @todo: add these top actions next to the core 'Add workflow' action.
     $top_actions_args = array('links' => $top_actions, 'attributes' => array('class' => array('inline', 'action-links')));
     $form['action-links'] = array('#type' => 'markup', '#markup' => theme('links', $top_actions_args), '#weight' => -1);
     if (module_exists('workflownode')) {
         // Append the type_map form, changing the form by reference.
         // The 'type_map' form is only valid for Workflow Node API.
         module_load_include('inc', 'workflow_admin_ui', 'workflow_admin_ui.page.type_map');
         workflow_admin_ui_type_map_form($form);
     }
     // Add a submit button. The submit functions are added in the sub-forms.
     $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 100);
     return $form;
 }
 /**
  * Constructor
  * @param array   $class_list  list containing the classes of tests to be processed
  *                             default: NULL - run all tests
  */
 function DrupalUnitTests($class_list = NULL)
 {
     static $classes;
     $this->DrupalTestSuite('Drupal Unit Tests');
     /* Tricky part to avoid double inclusion */
     if (!$classes) {
         $files = module_invoke_all('simpletest');
         $existing_classes = get_declared_classes();
         foreach ($files as $file) {
             include_once $file;
         }
         $classes = array_diff(get_declared_classes(), $existing_classes);
     }
     if (!is_null($class_list)) {
         $classes = $class_list;
     }
     if (count($classes) == 0) {
         $this->addTestCase(new BadGroupTest($test_file, 'No new test cases'));
         return;
     }
     $groups = array();
     foreach ($classes as $class) {
         $this->_addClassToGroups($groups, $class);
     }
     foreach ($groups as $group_name => $group) {
         $group_test =& new DrupalTestSuite($group_name);
         foreach ($group as $key => $v) {
             $group_test->addTestCase($group[$key]);
         }
         $this->addTestCase($group_test);
     }
 }
    public function clean($expression) {
        $adjustedExpression = $expression;

        if (!isset($this->cleanHandlers)) {
            $handlerConfigurations = module_invoke_all('dp_formula_expression_sql_clean');
            if (isset($handlerConfigurations)) {
                foreach ($handlerConfigurations as $handlerConfiguration) {
                    $priority = $handlerConfiguration['priority'];
                    $classname = $handlerConfiguration['classname'];

                    if (isset($this->cleanHandlers[$priority])) {
                        throw new IllegalStateException(t(
                            'Several SQL expression cleaners have the same priority: [%classname1, %classname2]',
                            array('%classname1' => $this->cleanHandlers[$priority], '%classname2' => $classname)));
                    }
                    $this->cleanHandlers[$priority] = new $classname();
                }

                if (isset($this->cleanHandlers)) {
                    ksort($this->cleanHandlers, SORT_NUMERIC);
                }
            }
        }

        if (isset($this->cleanHandlers)) {
            foreach ($this->cleanHandlers as $handler) {
                $adjustedExpression = $handler->clean($adjustedExpression);
            }
        }

        return $adjustedExpression;
    }
 /**
  * Permanently deletes the entity.
  */
 public function delete()
 {
     // Notify any interested modules before we delete, in case there's data needed.
     // @todo D8: this can be replaced by a hook_entity_delete(?)
     module_invoke_all('workflow', 'transition delete', $this->tid, NULL, NULL, FALSE);
     return parent::delete();
 }
Exemple #6
0
function connect_node_functions_form()
{
    drupal_add_css(drupal_get_path('module', 'connect') . '/connect.css');
    $child = array();
    $options = array();
    $p_nid = arg(1);
    $parent = node_load($p_nid);
    // determine possible and enabled actions
    $requirements_OK = TRUE;
    $actions = connect_get_actions($parent->nid);
    $action_list = module_invoke_all('connect');
    unset($action_list['connect_action_basic']);
    foreach ($action_list as $function => $action) {
        $status = '';
        if (in_array($function, $actions)) {
            if (TRUE === _connect_hook_check_requirements($parent, $child, $function, 'parent')) {
                $status = ' ' . theme_image(drupal_get_path('module', 'connect') . '/images/accept.png', '(ACTIVE)', 'This function is active.');
            } else {
                $requirements_OK = FALSE;
                $status = ' ' . theme_image(drupal_get_path('module', 'connect') . '/images/exclamation.png', '(INACTIVE)', 'This function is not active. Please check the settings tab.');
            }
        }
        $options[$function] = $action['title'] . $status . '<p class="connect-comment">' . $action['desc'] . '</p>';
    }
    if (!$requirements_OK) {
        drupal_set_message('One or more of your selected functions requires additional settings to be configured.<br />Please check the settings tab for details.', 'error');
    }
    $form = array();
    $form['parent_id'] = array('#type' => 'value', '#value' => $parent->nid);
    $form['connect_actions'] = array('#type' => 'fieldset', '#title' => 'Choose functions to apply to this campaign');
    $form['connect_actions']['actions'] = array('#type' => 'checkboxes', '#title' => '', '#options' => $options, '#default_value' => $actions);
    $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
    return $form;
}
/**
 * Implements hook_flush_caches().
 *
 * Support triggering expiration in modules not declaring their cache bins,
 * either by taking them from an explicit variable, or by performing a discovery
 * assuming the cache bin names to start by 'cache_'.
 */
function mongodb_cache_flush_caches()
{
    // Recursion protection, not static caching, so no drupal_static().
    static $reentry = FALSE;
    if ($reentry) {
        return [];
    }
    // Hardcoded in drupal_flush_all_caches() or system_cron(), but not declared
    // in system_flush_caches().
    $system_bins = ['cache', 'cache_bootstrap', 'cache_filter', 'cache_form', 'cache_menu', 'cache_page', 'cache_path'];
    $reentry = TRUE;
    $owned_bins = module_invoke_all('flush_caches');
    $reentry = FALSE;
    $detected_bins = variable_get('mongodb_cache_extra_bins', NULL);
    // As with databases, NULL means unknown, so perform a discovery.
    if (!isset($detected_bins)) {
        $detected_bins = [];
        $names = mongodb()->getCollectionNames(FALSE);
        foreach ($names as $name) {
            if (strpos($name, 'cache_') === 0) {
                $detected_bins[] = $name;
            }
        }
    }
    $adopted_bins = array_diff($detected_bins, $system_bins, $owned_bins);
    return $adopted_bins;
}
 /**
  * Implementation of FeedsParser::parse().
  */
 public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result)
 {
     $fetched = $fetcher_result->getRaw();
     $mailbox = $fetched['mailbox'];
     $result = new FeedsParserResult();
     if (!empty($fetched['messages'])) {
         foreach ($fetched['messages'] as $mid => &$message) {
             $this->authenticate($message, $mailbox);
             if ($class = mailhandler_plugin_load_class('mailhandler', $mailbox->settings['retrieve'], 'retrieve', 'handler')) {
                 $class->purge_message($mailbox, $message);
             }
             if ($message['authenticated_uid'] == 0) {
                 // User was not authenticated
                 module_invoke_all('mailhandler_auth_failed', $message);
                 $source_config = $source->getConfigFor($this);
                 if ($source_config['auth_required']) {
                     mailhandler_report('warning', 'User could not be authenticated. Please check your Mailhandler authentication plugin settings.');
                     continue;
                 }
             }
             $this->commands($message, $source);
             $result->items[] = $message;
         }
     }
     return $result;
 }
Exemple #9
0
 /**
  * {@inheritdoc}
  */
 public function getQueues()
 {
     if (!isset(static::$queues)) {
         static::$queues = module_invoke_all('cron_queue_info');
         drupal_alter('cron_queue_info', static::$queues);
     }
     return static::$queues;
 }
 public function delete($options = array())
 {
     // Append default options.
     $options += $this->defaultCrudOptions['delete'];
     db_delete('versioncontrol_operation_labels')->condition('label_id', $this->label_id)->execute();
     db_delete('versioncontrol_labels')->condition('label_id', $this->label_id)->execute();
     $this->backendDelete($options);
     module_invoke_all('versioncontrol_entity_tag_delete', $this);
 }
 public function __construct()
 {
     parent::__construct();
     $this->handlerConfigurations = module_invoke_all('dc_cache');
     // preparing default value for cache entry expiration time
     $cacheConfigurationSection = Environment::getInstance()->getConfigurationSection('Cache');
     if (isset($cacheConfigurationSection['Entry Expiration']['Default'])) {
         AbstractCacheHandler::$DEFAULT__ENTRY_EXPIRATION = $cacheConfigurationSection['Entry Expiration']['Default'];
     }
 }
/**
 * Implements hook_wysiwyg_fields_wysiwyg_plugins().
 */
function hook_wysiwyg_fields_wysiwyg_plugins($content_type)
{
    $plugins = array();
    foreach (content_fields() as $field) {
        if (!in_array(TRUE, module_invoke_all('wysiwyg_fields_field_bypass', $field)) && !is_null(content_fields($field['field_name'], $content_type)) && isset($field['widget']['wysiwyg_fields_status']) && $field['widget']['wysiwyg_fields_status']) {
            $plugins[$field['field_name']] = array('label' => $field['widget']['label'], 'icon' => $field['widget']['wysiwyg_fields_icon']);
        }
    }
    return $plugins;
}
Exemple #13
0
function connect_get_lookup_types($select = FALSE)
{
    static $return = array();
    $empty = array();
    if (empty($return)) {
        $return = module_invoke_all('connect_lookup');
        $return[0] = '';
        asort($return);
    }
    return $return;
}
/**
 * Execute operations before oauth2_server_authorize() main logic.
 *
 * Allow modules to perform additional operations at the very beginning of
 * the OAuth2 authorize callback.
 */
function hook_oauth2_server_pre_authorize()
{
    // Make sure we're not in the middle of a running operation.
    if (empty($_SESSION['oauth2_server_authorize'])) {
        global $user;
        // Ensure that the current session is killed before authorize.
        module_invoke_all('user_logout', $user);
        // Destroy the current session, and reset $user to the anonymous user.
        session_destroy();
    }
}
 /**
  * {@inheritdoc}
  * @see user_logout()
  */
 public function logout(Request $request, Response $response, TokenInterface $token)
 {
     $user = $token->getUser();
     if (is_a($user, 'Bangpound\\Bundle\\DrupalBundle\\Security\\User\\User')) {
         /** @var \Bangpound\Bundle\DrupalBundle\Security\User\User $user */
         $user = $token->getUser()->getDrupalUser();
         watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
         module_invoke_all('user_logout', $user);
         $GLOBALS['user'] = drupal_anonymous_user();
     }
 }
 /**
  * Returns all the identifiers available for this component.
  */
 public static function getAllIdentifiers($component)
 {
     $return = array();
     $permissions = array_keys(module_invoke_all('permission'));
     foreach ($permissions as $permission) {
         $id = str_replace(' ', '_', $permission);
         $id = str_replace('/', '_', $id);
         $return[$id] = $permission;
     }
     return $return;
 }
 public function __construct()
 {
     if (count(self::$registry) <= 0) {
         // Prepare the registry.
         self::$registry[] = 'Drupal\\publisher\\Preparers\\Node';
         self::$registry[] = 'Drupal\\publisher\\Preparers\\MenuLink';
         self::$registry[] = 'Drupal\\publisher\\Preparers\\User';
         // Call the hook for other modules.
         self::$registry += module_invoke_all('publisher_preparers');
     }
 }
 public function __construct()
 {
     // Allow other modules to add stuff in there
     $this->map = module_invoke_all('usync_path_map');
     drupal_alter('usync_path_map', $this->map);
     foreach ($this->map as $pattern => $class) {
         if (!class_exists($class)) {
             unset($this->pathMap[$pattern]);
             trigger_error(sprintf("Class '%s' does not exist", $class), E_USER_ERROR);
         }
     }
 }
 function setSessionData($data)
 {
     $this->trainer_id = $data['trainer_id'];
     $this->start_time = $data['start_time'];
     $this->elapsed_time = $data['elapsed_time'];
     $this->success = $data['success'];
     $this->session_data = $data;
     // Inform any other modules that an update occurred and pass the session data.
     module_invoke_all('xlms_session_update', $this);
     // @TODO: Remove debug
     watchdog(WATCHDOG_INFO, t('XLMS Simulator Data: ') . print_r($data, 1));
     $this->save();
 }
Exemple #20
0
/**
 * Override of theme_node_form().
 */
function slate_node_form($form)
{
    $buttons = '<div class="buttons">' . drupal_render($form['buttons']) . '</div>';
    // Allow modules to insert form elements into the sidebar,
    // defaults to showing taxonomy in that location.
    if (!($sidebar_fields = module_invoke_all('node_form_sidebar', $form, $form['#node']))) {
        $sidebar_fields = array('taxonomy');
    }
    foreach ($sidebar_fields as $field) {
        $sidebar .= drupal_render($form[$field]);
    }
    $main = drupal_render($form);
    return "<div class='node-form clear-block'>\n    <div class='right'>{$buttons}{$sidebar}</div>\n    <div class='left'><div class='main'>{$main}{$buttons}</div></div>\n  </div>";
}
 public function addItemToCart($nodeID, $qty = 1, $data = array())
 {
     $node = node_load($nodeID);
     if (!is_object($node) || !uc_product_is_product($node)) {
         throw new NoProductException();
     }
     /** @todo this should come over form. or this field is populated by submit handler. **/
     $data['nid'] = $nodeID;
     if ($node->type == 'product_kit') {
         return $this->addItemKitToCart($nodeID, $qty, $data);
     }
     uc_cart_add_item($node->nid, $qty, module_invoke_all('add_to_cart_data', $data), null, true, false, true);
     return;
 }
Exemple #22
0
/**
 * Return an array of matching merge values.
 *
 * @param $mergevars
 * @param $account
 * @param $list
 *
 * @return array
 */
function hook_mailchimp_lists_merge_values($mergevars, $account, $list)
{
    $values = array();
    // grab the saved list merge vars and filter out unset values
    if (!empty($list->settings['mergefields'])) {
        $mergevars = array_filter($list->settings['mergefields']);
        $mergevars = array_flip($mergevars);
        // match with token values
        $values = module_invoke_all('mailchimp_lists_merge_values', $mergevars, $account, $list);
        // always add email
        $values += array('EMAIL' => $account->mail);
    }
    return $values;
}
Exemple #23
0
 protected function initializeMessageListeners()
 {
     $this->messageListeners = array();
     $listenerConfigurations = module_invoke_all('dc_log_message_listener');
     foreach ($listenerConfigurations as $listenerConfiguration) {
         $classname = $listenerConfiguration['classname'];
         // recommended priority value:
         //     -10000 ..  -501: collect info
         //       -500 ..    -1: message modification
         //          0 .. 10000: logging into storage
         $priority = isset($listenerConfiguration['priority']) ? $listenerConfiguration['priority'] : 0;
         $this->messageListeners[$priority][] = new $classname();
     }
     ksort($this->messageListeners);
 }
 function settingsForm(array $form, array &$form_state)
 {
     $element = parent::settingsForm($form, $form_state);
     $element['date_element'] = array('#type' => 'select', '#title' => t('Date element'), '#default_value' => $this->getSetting('date_element'), '#options' => array('date' => t('HTML5 Date'), 'datetime' => t('HTML5 Datetime'), 'datetime-local' => t('HTML5 Datetime-local'), 'text' => t('Text field'), 'none' => t('<Hidden>')), '#description' => t('The element to use for the date in a textfield.'), '#fieldset' => 'date_format');
     // The custom format only applies for non-HTML5 elements.
     $element['date_format'] = array('#type' => 'textfield', '#title' => t('Date text field entry format'), '#default_value' => $this->getSetting('date_format'), '#description' => t('Custom format for the text field date. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php')), '#fieldset' => 'date_format', '#states' => array('visible' => array(":input[name=\"instance[widget][settings][date_element]\"]" => array('value' => 'text'))));
     $element['time_element'] = array('#type' => 'select', '#title' => t('Time element'), '#default_value' => $this->getSetting('time_element'), '#options' => array('time' => t('HTML5 Time'), 'text' => t('Text field'), 'none' => t('<Hidden>')), '#description' => t('The element to use for the time.'), '#fieldset' => 'date_format');
     // The custom format only applies for non-HTML5 elements.
     $element['time_format'] = array('#type' => 'textfield', '#title' => t('Time text field entry format'), '#default_value' => $this->getSetting('time_format'), '#description' => t('Custom format for the text field time See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php')), '#fieldset' => 'date_format', '#states' => array('visible' => array(":input[name=\"instance[widget][settings][time_element]\"]" => array('value' => 'text'))));
     $options = module_invoke_all('date_field_date_callbacks');
     $element['date_callbacks'] = array('#type' => 'checkboxes', '#title' => t('Additional date features'), '#default_value' => $this->getSetting('date_callbacks'), '#options' => $options, '#fieldset' => 'date_format', '#states' => array('invisible' => array(":input[name=\"instance[widget][settings][date_element]\"]" => array('value' => 'none'))));
     $options = module_invoke_all('date_field_time_callbacks');
     $element['time_callbacks'] = array('#type' => 'checkboxes', '#title' => t('Additional time features'), '#default_value' => $this->getSetting('time_callbacks'), '#options' => $options, '#fieldset' => 'date_format', '#states' => array('invisible' => array(":input[name=\"instance[widget][settings][time_element]\"]" => array('value' => 'none'))));
     return $element;
 }
 /**
  * Constructor
  *
  * @param ConsumerCredentials $consumerCredentials
  */
 private function __construct(ConsumerCredentials $consumerCredentials)
 {
     $endpoint = variable_get('culturefeed_search_api_location', CULTUREFEED_SEARCH_API_LOCATION);
     $cdbXmlVersion = variable_get('culturefeed_search_cdb_version', CULTUREFEED_SEARCH_CDB_DEFAULT_VERSION);
     $service = new \CultuurNet\Search\Guzzle\Service($endpoint, $consumerCredentials, NULL, $cdbXmlVersion);
     module_invoke_all('culturefeed_search_service_created', $service);
     if (module_exists('culturefeed_devel')) {
         $service->enableLogging();
     }
     if (variable_get('culturefeed_search_cache_enabled', FALSE)) {
         $this->service = new DrupalCultureFeedSearchService_Cache($service, $consumerCredentials, DrupalCultureFeed::getLoggedInUserId());
     } else {
         $this->service = $service;
     }
 }
 function invoke_panels_ipe_access()
 {
     if (user_access('bypass access in place editing')) {
         return TRUE;
     }
     // Modules can return TRUE, FALSE or NULL, for allowed, disallowed,
     // or don't care - respectively. On the first FALSE, we deny access,
     // otherwise allow.
     foreach (module_invoke_all('panels_ipe_access', $this->display) as $result) {
         if ($result === FALSE) {
             return FALSE;
         }
     }
     return TRUE;
 }
Exemple #27
0
/**
 * Define additional links to add to the site map.
 *
 * This hook allows modules to add additional links to the site map. Links
 * may be associated with nodes, terms, or users, as shown in the example.
 * @param $type:
 * If set, a string specifying the type of additional links to return. You
 * can use your own type or a type from one of the included modules:
 * - node:
 *   Links associated with nodes
 * - term:
 *   Links associated with terms
 * - user:
 *   Links associated with users
 * - xml:
 *   An XML site map (for including site maps from other modules)
 * You can define additional types by adding them to the switch statement.
 * @param $excludes:
 * Depends on the type of links being requested.
 * - For "node", an array of excluded node types
 * - For "term", an array of excluded vocabularies
 * - For "user", an array of included roles
 * @return
 * If $type is xml, return an XML site map. Otherwise, return an array of
 * links or an empty array. Each link should be an array with the
 * following keys:
 * - nid, tid, uid, or custom ID type:
 *   ID to associate with this link (If you have defined your own link type,
 *   use the ID key to group related links together.)
 * - #loc:
 *   The URL of the page
 * - #lastmod:
 *   Timestamp of last modification
 * - #changefreq:
 *   Number of seconds between changes
 * - #priority:
 *   A number between 0 and 1 indicating the link's priority
 */
function hook_xmlsitemap_links($type = NULL, $excludes = array())
{
    $links = array();
    switch ($type) {
        case 'node':
            break;
        case 'term':
            break;
        case 'user':
            // Load profiles.
            $result = db_query("\n        SELECT u.uid, xu.last_changed, xu.previously_changed, xu.priority_override, SUM(xur.priority), ua.dst AS alias\n        FROM {users} u\n        LEFT JOIN {users_roles} ur ON ur.uid = u.uid\n        LEFT JOIN {xmlsitemap_user_role} xur ON xur.rid = ur.rid\n        LEFT JOIN {xmlsitemap_user} xu ON xu.uid = u.uid\n        LEFT JOIN {url_alias} ua ON ua.pid = xu.pid\n        WHERE (xu.priority_override IS NULL OR xu.priority_override >= 0) AND u.uid <> %d\n        GROUP BY u.uid, xu.last_changed, xu.previously_changed, xu.priority_override, ua.dst\n        HAVING MIN(xur.priority) <> -1\n      ", _xmlsitemap_user_frontpage());
            // Create link array for each profile.
            while ($user = db_fetch_object($result)) {
                $age = time() - $user->last_changed;
                $interval = empty($user->previously_changed) ? 0 : $user->last_changed - $user->previously_changed;
                $links[] = array('uid' => $user->uid, '#loc' => xmlsitemap_url("user/{$user->uid}", $user->alias, NULL, NULL, TRUE), '#lastmod' => $user->last_changed, '#changefreq' => max($age, $interval), '#priority' => _xmlsitemap_user_priority($user));
            }
            // Add other user links to the links array.
            $links = array_merge($links, module_invoke_all('xmlsitemap_links', 'user'));
            // Sort links by user ID and URL.
            foreach ($links as $key => $link) {
                $uid[$key] = $link['uid'];
                $loc[$key] = $link['#loc'];
            }
            array_multisort($uid, $loc, $links);
            break;
        case 'xml':
            // Retrieve an XML site map.
            $links = example_sitemap();
            break;
        default:
            // Add arbitrary additional links.
            $result = db_query("\n        SELECT xa.*, ua.dst AS alias FROM {xmlsitemap_additional} xa\n        LEFT JOIN {url_alias} ua ON xa.pid = ua.pid\n      ");
            while ($link = db_fetch_object($result)) {
                $age = time() - $link->last_changed;
                if (!empty($link->previously_changed)) {
                    $interval = $link->last_changed - $link->previously_changed;
                } else {
                    $interval = 0;
                }
                $entry = array('#loc' => xmlsitemap_url($link->path, $link->alias, NULL, NULL, TRUE), '#lastmod' => $link->last_changed, '#changefreq' => max($age, $interval), '#priority' => $link->priority);
                $additional[] = $entry;
            }
            break;
    }
    return $links;
}
    protected function initHandlers() {
        $handlers = module_invoke_all('gd_sync_entities');
        $exportHandlers = array();
        foreach ( $handlers as $h ) {
            $exportHandlers[] = $h['export'];
        }

        // sort by operation weight
        usort($exportHandlers,function($a,$b){
            if ($a['weight'] == $b['weight']) {
                return 0;
            }
            return ($a['weight'] < $b['weight']) ? -1 : 1;
        });

        $this->handlers = $exportHandlers;
    }
    protected function getCacheOptions() {
        $cacheSynchronizationOptions = &drupal_static(__CLASS__ . '::cacheSynchronizationOptions');

        if (!isset($cacheSynchronizationOptions[$this->expirationTimePolicyName])) {
            $cacheKey = 'dp_cache_sync:' . $this->expirationTimePolicyName;
            $cache = CacheFactory::getInstance()->getSharedCacheHandler(get_class($this));

            $cacheSyncOptions = $cache->getValue($cacheKey);
            if (!isset($cacheSyncOptions)) {
                $isSourceDataUpdateInProgress = FALSE;
                $sourceDataAsOfDateTime = NULL;

                $syncOptions = module_invoke_all('dp_cache_sync', $this->expirationTimePolicyName);
                if (isset($syncOptions)) {
                    foreach ($syncOptions as $sourceDataOptions) {
                        if (!$isSourceDataUpdateInProgress && isset($sourceDataOptions[CacheHandler::OPTION__DATA_UPDATE_IN_PROGRESS])) {
                            $isSourceDataUpdateInProgress = $sourceDataOptions[CacheHandler::OPTION__DATA_UPDATE_IN_PROGRESS];
                        }
                        if (isset($sourceDataOptions[CacheHandler::OPTION__DATA_RESET_DATETIME])) {
                            $dt = $sourceDataOptions[CacheHandler::OPTION__DATA_RESET_DATETIME];
                            if (!isset($sourceDataAsOfDateTime) || ($sourceDataAsOfDateTime < $dt)) {
                                $sourceDataAsOfDateTime = $dt;
                            }
                        }
                    }
                }

                if ($isSourceDataUpdateInProgress) {
                    $cacheSyncOptions[CacheHandler::OPTION__DATA_UPDATE_IN_PROGRESS] = $isSourceDataUpdateInProgress;
                }
                if (isset($sourceDataAsOfDateTime)) {
                    $cacheSyncOptions[CacheHandler::OPTION__DATA_RESET_DATETIME] = $sourceDataAsOfDateTime;
                }

                // to prevent repeatable hook invocations
                if (!isset($cacheSyncOptions)) {
                    $cacheSyncOptions = FALSE;
                }

                $cache->setValue($cacheKey, $cacheSyncOptions);
            }
            $cacheSynchronizationOptions[$this->expirationTimePolicyName] = $cacheSyncOptions;
        }

        return ($cacheSynchronizationOptions[$this->expirationTimePolicyName] === FALSE) ? NULL : $cacheSynchronizationOptions[$this->expirationTimePolicyName];
    }
Exemple #30
0
 /**
  * {@inheritdoc}
  */
 public function getQueues()
 {
     if (!isset(static::$queues)) {
         static::$queues = module_invoke_all('cron_queue_info');
         drupal_alter('cron_queue_info', static::$queues);
         // Merge in queues from modules that implement hook_queue_info.
         // Currently only defined by the queue_ui module.
         $info_queues = module_invoke_all('queue_info');
         foreach ($info_queues as $name => $queue) {
             static::$queues[$name]['worker callback'] = $queue['cron']['callback'];
             if (isset($queue['cron']['time'])) {
                 static::$queues[$name]['time'] = $queue['cron']['time'];
             }
         }
     }
     return static::$queues;
 }