/**
  * Implements AcsfEventHandler::handle().
  */
 public function handle()
 {
     drush_print(dt('Entered @class', array('@class' => get_class($this))));
     // Clear the theme field so all users will use the default theme.
     db_update('users')->fields(array('theme' => 0))->execute();
     // Clear any in-progress multistep forms that are not normally wiped during
     // cache-clear. The other caches are expected to be cleared externally from
     // this process.
     cache_clear_all('*', 'cache_form', TRUE);
     // Clean up ACSF variables.
     $acsf_variables = acsf_vget_group('acsf_duplication_scrub');
     foreach ($acsf_variables as $name => $value) {
         acsf_vdel($name);
     }
     // Begin the site without any watchdog records. This should happen right at
     // the end of the scubbing process to remove any log entries added by the
     // scrubbing process itself.
     if (db_table_exists('watchdog')) {
         db_delete('watchdog')->execute();
     }
     // Mark the entire scrubbing process as complete.
     variable_set('acsf_duplication_scrub_status', 'complete');
 }
/**
 * Implementation of THEMEHOOK_settings() function.
 *
 * @param $saved_settings
 *   array An array of saved settings for this theme.
 * @return
 *   array A form array.
 */
function phptemplate_settings($saved_settings)
{
    // Empty the cached css...
    cache_clear_all('abessive_custom_css', 'cache');
    $form = array();
    require_once path_to_theme() . '/abessive_settings.php';
    // Add Farbtastic color picker
    drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
    drupal_add_js('misc/farbtastic/farbtastic.js');
    drupal_add_js(path_to_theme() . '/theme-settings.js');
    $defaults = _abessive_default_settings();
    $settings = array_merge($defaults, $saved_settings);
    $form['abessive_picker'] = array('#type' => 'markup', '#value' => '<div id="picker"></div>');
    $form['abessive_background_color'] = array('#type' => 'textfield', '#title' => t('Background Color'), '#description' => t('What colour should the body background behind all the containers be? Default: %val', array('%val' => $defaults['abessive_background_color'])), '#default_value' => $settings['abessive_background_color'], '#size' => 7, '#maxlength' => 7, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#attributes' => array('class' => 'form-item-use-colorpicker'), '#element_validate' => array('abessive_validate_hex_field'));
    $form['abessive_border_color'] = array('#type' => 'textfield', '#title' => t('Border Color'), '#description' => t('What colour should the border around all the containers be? Default: %val', array('%val' => $defaults['abessive_border_color'])), '#default_value' => $settings['abessive_border_color'], '#size' => 7, '#maxlength' => 7, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#attributes' => array('class' => 'form-item-use-colorpicker'), '#element_validate' => array('abessive_validate_hex_field'));
    $form['abessive_content_background_color'] = array('#type' => 'textfield', '#title' => t('Content Background Color'), '#description' => t('What colour should the background of all the containers be? Default: %val', array('%val' => $defaults['abessive_content_background_color'])), '#default_value' => $settings['abessive_content_background_color'], '#size' => 7, '#maxlength' => 7, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#attributes' => array('class' => 'form-item-use-colorpicker'), '#element_validate' => array('abessive_validate_hex_field', 'abessive_calculate_gradient'));
    $form['abessive_content_background_color']['abessive_r5'] = $form['abessive_content_background_color']['abessive_r4'] = $form['abessive_content_background_color']['abessive_r3'] = $form['abessive_content_background_color']['abessive_r2'] = array('#type' => 'value', '#default_value' => 0);
    $form['abessive_text_color'] = array('#type' => 'textfield', '#title' => t('Text Color'), '#description' => t('What colour should the text be? Default: %val', array('%val' => $defaults['abessive_text_color'])), '#default_value' => $settings['abessive_text_color'], '#size' => 7, '#maxlength' => 7, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#attributes' => array('class' => 'form-item-use-colorpicker'), '#element_validate' => array('abessive_validate_hex_field'));
    $form['abessive_link_color'] = array('#type' => 'textfield', '#title' => t('Hyperlink Color'), '#description' => t('What colour should hyperlinks be? Default: %val', array('%val' => $defaults['abessive_link_color'])), '#default_value' => $settings['abessive_link_color'], '#size' => 7, '#maxlength' => 7, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#attributes' => array('class' => 'form-item-use-colorpicker'), '#element_validate' => array('abessive_validate_hex_field'));
    $form['abessive_link_hover_color'] = array('#type' => 'textfield', '#title' => t('Hyperlink Hover Color'), '#description' => t('What colour should hyperlinks be when hovered over? Default: %val', array('%val' => $defaults['abessive_link_hover_color'])), '#default_value' => $settings['abessive_link_hover_color'], '#size' => 7, '#maxlength' => 7, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#attributes' => array('class' => 'form-item-use-colorpicker'), '#element_validate' => array('abessive_validate_hex_field'));
    $form['abessive_link_active_color'] = array('#type' => 'textfield', '#title' => t('Hyperlink Active Color'), '#description' => t('What colour should active hyperlinks be? Default: %val', array('%val' => $defaults['abessive_link_active_color'])), '#default_value' => $settings['abessive_link_active_color'], '#size' => 7, '#maxlength' => 7, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#attributes' => array('class' => 'form-item-use-colorpicker'), '#element_validate' => array('abessive_validate_hex_field'));
    $form['abessive_left_width'] = array('#type' => 'textfield', '#title' => t('Left Column Width'), '#description' => t('How wide should the left column be? Default: %val', array('%val' => $defaults['abessive_left_width'])), '#default_value' => $settings['abessive_left_width'], '#size' => 3, '#maxlength' => 3, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#field_suffix' => 'px', '#element_validate' => array('abessive_validate_numeric_field'));
    $form['abessive_right_width'] = array('#type' => 'textfield', '#title' => t('Right Column Width'), '#description' => t('How wide should the right column be? Default: %val', array('%val' => $defaults['abessive_right_width'])), '#default_value' => $settings['abessive_right_width'], '#size' => 3, '#maxlength' => 3, '#prefix' => '<div class="container-inline">', '#suffix' => '</div>', '#field_suffix' => 'px', '#element_validate' => array('abessive_validate_numeric_field'));
    $form['#submit'][] = 'abessive_submit_settings';
    return $form;
}
Beispiel #3
0
 /**
  * Clear all Zeitgeist cache entries.
  */
 public static function clearAll()
 {
     $known_cids = array_keys(static::getCids());
     foreach ($known_cids as $cid) {
         $core_cid = static::prefixCid($cid);
         cache_clear_all($core_cid, Cache::BIN);
     }
     variable_del(static::VARCIDS);
 }
/**
 * Update menu links
 */
function osha_update_menu_links()
{
    db_update('menu_links')->fields(array('link_path' => 'tools-and-publications/publications', 'router_path' => 'tools-and-publications/publications'))->condition('mlid', '652')->execute();
    db_update('menu_links')->fields(array('link_path' => 'inside-eu-osha/press-room', 'router_path' => 'inside-eu-osha/press-room'))->condition('mlid', '673')->execute();
    db_update('menu_links')->fields(array('link_path' => 'inside-eu-osha/press-room', 'router_path' => 'inside-eu-osha/press-room'))->condition('mlid', '1704')->execute();
    db_update('menu_links')->fields(array('link_path' => 'tools-and-publications/events', 'router_path' => 'tools-and-publications/events'))->condition('mlid', '1513')->execute();
    db_update('block')->fields(array('pages' => 'tools-and-publications/events'))->condition('delta', '5322')->execute();
    // Flush cache.
    cache_clear_all();
}
 /**
  * Refresh the in-memory set of variables.
  *
  * Refresh the in-memory set of variables. Useful after a page request is made
  * that changes a variable in a different thread.
  *
  * This is an overridden version of the function provided by the Drupal test
  * module. It maintains any settings created in settings.php (and it's
  * corresponding global.inc) file.
  *
  * In other words calling a settings page with $this->drupalPost() with a
  * changed value would update a variable to reflect that change, but in
  * the thread that made the call (thread running the test) the changed
  * variable would not be picked up.
  *
  * This method clears the variables cache and loads a fresh copy from
  * the database to ensure that the most up-to-date set of variables is loaded.
  */
 protected function refreshVariables()
 {
     global $conf;
     cache_clear_all('variables', 'cache_bootstrap');
     $variables = variable_initialize();
     // Merge updated database variables back into $conf.
     foreach ($variables as $name => $value) {
         $conf[$name] = $value;
     }
     return $conf;
 }
 function cleanup($config)
 {
     $res = db_query("SELECT cid FROM {cache} WHERE cid LIKE '%s%%'", 'htmlpurifier:');
     while ($row = db_fetch_object($res)) {
         $key = substr($row->cid, 13);
         // 13 == strlen('htmlpurifier:')
         if ($this->isOld($key, $config)) {
             cache_clear_all($row->cid, 'cache');
         }
     }
 }
Beispiel #7
0
 private function deleteComments()
 {
     module_load_include('inc', 'comment', 'comment.admin');
     $result = db_query("SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid");
     while ($comment = db_fetch_object($result)) {
         // Delete comment and its replies.
         _comment_delete_thread($comment);
         _comment_update_node_statistics($comment->nid);
     }
     // Clear the cache so an anonymous user sees that his comment was deleted.
     cache_clear_all();
 }
Beispiel #8
0
 /**
  * (non-PHPdoc)
  * @see Yamm_Entity::_update()
  */
 protected function _update($object, $identifier)
 {
     // TODO we should check for all dependencies which are not data, such as
     // handlers and modules (this is done by views_export module).
     views_include('view');
     // Should give us the '$view' variable
     eval($object);
     $view->save();
     views_ui_cache_set($view);
     menu_rebuild();
     cache_clear_all('*', 'cache_views');
     cache_clear_all();
 }
 function cleanup($config)
 {
     // TODO: This does not work with the pluggable cache system in Drupal 7,
     // since it assumes a database cache is being used.
     $res = db_query("SELECT cid FROM {cache} WHERE cid LIKE :cid", array(':cid' => 'htmlpurifier:%'));
     foreach ($res as $row) {
         $key = substr($row->cid, 13);
         // 13 == strlen('htmlpurifier:')
         if ($this->isOld($key, $config)) {
             cache_clear_all($row->cid, 'cache');
         }
     }
 }
 /**
  * Delete a node.
  */
 function deleteNode($nid)
 {
     // Implemention taken from node_delete, with some assumptions regarding
     // function_exists removed.
     $node = node_load($nid);
     db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
     db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
     // Call the node-specific callback (if any):
     node_invoke($node, 'delete');
     node_invoke_nodeapi($node, 'delete');
     // Clear the page and block caches.
     cache_clear_all();
 }
 /**
  * Visit a node page given its type and title.
  *
  * @param string $type
  *    The node type.
  * @param string $title
  *    The node title.
  *
  * @Then I visit the :type content with title :title
  */
 public function visitContentPage($type, $title)
 {
     $nodes = node_load_multiple([], ['title' => $title, 'type' => $type], TRUE);
     if (!$nodes) {
         throw new \InvalidArgumentException("Node of type '{$type}' and title '{$title}' not found.");
     }
     // Get node path without any base path by setting 'base_url' and 'absolute'.
     $node = array_shift($nodes);
     $path = 'node/' . $node->nid;
     cache_clear_all($path, 'cache_path');
     $path = url($path, ['base_url' => '', 'absolute' => TRUE]);
     // Visit newly created node page.
     $this->visitPath($path);
 }
Beispiel #12
0
function action_results()
{
    // Get the results from the drupal cache and clear them.
    $results = cache_get('publisher_batch_results');
    $success = cache_get('publisher_batch_success');
    cache_clear_all('publisher_batch_results', 'cache');
    cache_clear_all('publisher_batch_success', 'cache');
    if (!$success && !$results) {
        drupal_set_message('There are currently no results to display.', 'error');
        return '';
    }
    if ($results && isset($results->data)) {
        $results = $results->data;
    }
    if ($success && isset($success->data)) {
        $success = $success->data;
    }
    if ($success) {
        drupal_set_message('Publisher batch operation completed successfully!');
    } else {
        drupal_set_message('There was an error during the publisher batch operation. See the table below for details.', 'error');
    }
    // Check the count of the results.
    if (!$results || !is_array($results) || count($results) <= 0) {
        return '<p>There are currently no results to display. This could mean the batch operation failed entirely
		or there were no entities to process and send over to the remote server.</p>';
    }
    // Build the table.
    $table_attributes = array('class' => array('system-status-report'));
    $table_rows = array();
    foreach ($results as $result) {
        if (!array_key_exists('type', $result) || !array_key_exists('message', $result) || !array_key_exists('entity_type', $result) || !array_key_exists('entity_id', $result)) {
            continue;
        }
        $row = array('data' => array());
        $row['class'] = $result['type'] != 'status' ? array($result['type']) : array('ok');
        $row['no_striping'] = true;
        $row['data'] = array($result['entity_type'], $result['entity_id'], $result['message']);
        $table_rows[] = $row;
    }
    $table_header = array('Entity Type', 'Entity ID', 'Message');
    return theme('table', array('header' => $table_header, 'rows' => $table_rows, 'attributes' => $table_attributes));
}
/**
 * Submit the form to add to an existing node
 */
function _nodereferrer_create_add_form_submit($form, &$form_state)
{
    if ($form_state['clicked_button']['#name'] != 'add') {
        drupal_set_message(t('The operation was cancelled'));
        drupal_goto('node/' . arg(1));
    }
    $append_node = node_load($form_state['values']['referrence']);
    // Make sure the user is allowed to do this
    if (!node_access('update', $append_node)) {
        drupal_set_message(t('You do not have rights to update this node'));
        drupal_goto('node/' . arg(1));
        return;
    }
    $current_node = node_load(arg(1));
    $field = $current_node->referrers[arg(3)]['referrence'][arg(4)][arg(5)]['field_name'];
    array_push($append_node->{$field}, array('nid' => $current_node->nid));
    // Save, and ensure the changes are noticed
    node_save($append_node);
    cache_clear_all();
    drupal_set_message(t('The node was added'));
    drupal_goto('node/' . arg(1));
}
 /**
  * Test DRUPAL_CACHE_PER_ROLE.
  */
 function testCachePerRole()
 {
     $this->setCacheMode(DRUPAL_CACHE_PER_ROLE);
     // Enable our test block. Set some content for it to display.
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
     $this->drupalLogin($this->normal_user);
     $this->drupalGet('');
     $this->assertText($current_content, t('Block content displays.'));
     // Change the content, but the cached copy should still be served.
     $old_content = $current_content;
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
     $this->drupalGet('');
     $this->assertText($old_content, t('Block is served from the cache.'));
     // Clear the cache and verify that the stale data is no longer there.
     cache_clear_all();
     $this->drupalGet('');
     $this->assertNoText($old_content, t('Block cache clear removes stale cache data.'));
     $this->assertText($current_content, t('Fresh block content is displayed after clearing the cache.'));
     // Test whether the cached data is served for the correct users.
     $old_content = $current_content;
     $current_content = $this->randomName();
     variable_set('block_test_content', $current_content);
     $this->drupalLogout();
     $this->drupalGet('');
     $this->assertNoText($old_content, t('Anonymous user does not see content cached per-role for normal user.'));
     $this->drupalLogin($this->normal_user_alt);
     $this->drupalGet('');
     $this->assertText($old_content, t('User with the same roles sees per-role cached content.'));
     $this->drupalLogin($this->admin_user);
     $this->drupalGet('');
     $this->assertNoText($old_content, t('Admin user does not see content cached per-role for normal user.'));
     $this->drupalLogin($this->normal_user);
     $this->drupalGet('');
     $this->assertText($old_content, t('Block is served from the per-role cache.'));
 }
 /**
  * @see CultureFeed_Pages::removePage()
  */
 public function removePage($id)
 {
     $result = $this->realCultureFeedPages->removePage($id);
     $this->cacheClear('page:' . $id);
     // Also flush search results.
     cache_clear_all('culturefeed:results:search/page:', 'cache_culturefeed_search', TRUE);
     return $result;
 }
/**
 * Allows modules to react after items were indexed.
 *
 * @param SearchApiIndex $index
 *   The used index.
 * @param array $item_ids
 *   An array containing the indexed items' IDs.
 */
function hook_search_api_items_indexed(SearchApiIndex $index, array $item_ids)
{
    if ($index->getEntityType() == 'node') {
        // Flush page cache of the search page.
        cache_clear_all(url('search'), 'cache_page');
    }
}
 /**
  * Clear cached Solr data.
  */
 public function clearCache()
 {
     cache_clear_all("apachesolr:luke:", 'cache', TRUE);
     $this->luke = array();
 }
 public function synchronize(NodeInterface $node, Context $context, $dirtyAllowed = false)
 {
     /* @var $node ViewNode */
     $entityType = $node->getEntityType();
     $bundle = $node->getBundle();
     $name = $node->getName();
     // First populate the variable that will be used during the
     // hook_entity_info_alter() call to populate the view modes
     $viewModes = variable_get(USYNC_VAR_VIEW_MODE, []);
     $viewModes[$entityType][$name] = $name;
     variable_set(USYNC_VAR_VIEW_MODE, $viewModes);
     // First grab a list of everything that can be displayed in view
     // modes with both extra fields and real fields
     $instances = field_info_instances($entityType, $bundle);
     $bundleSettings = field_bundle_settings($entityType, $bundle);
     $extra = $this->getExtraFieldsDisplay($entityType, $bundle);
     $weight = 0;
     $displayExtra = [];
     $displayField = [];
     // Then deal with fields and such
     foreach ($node->getValue() as $propertyName => $formatter) {
         if (isset($instances[$propertyName])) {
             $display = array();
             // We are working with a field
             if (!is_array($formatter)) {
                 if (true === $formatter || 'default' === $formatter) {
                     $formatter = array();
                 } else {
                     if (false === $formatter || null === $formatter || 'delete' === $formatter) {
                         continue;
                     } else {
                         if (!is_string($formatter)) {
                             $context->logWarning(sprintf("%s: %s invalid value for formatter", $node->getPath(), $propertyName));
                             $formatter = array();
                         } else {
                             $display['type'] = $formatter;
                         }
                     }
                 }
             } else {
                 $display = $formatter;
             }
             // Merge default and save
             $displayField[$propertyName] = drupal_array_merge_deep($this->getFieldDefault($node, $entityType, $bundle, $propertyName, $context), $display, array('weight' => $weight++));
         } else {
             if (isset($extra[$propertyName])) {
                 // We are working with and extra field
                 if (!is_array($formatter)) {
                     if (true === $formatter || 'default' === $formatter) {
                         $formatter = array();
                     } else {
                         if (false === $formatter || null === $formatter || 'delete' === $formatter) {
                             continue;
                         } else {
                             $context->logWarning(sprintf("%s: %s extra fields can only be delete or default", $node->getPath(), $propertyName));
                         }
                     }
                 }
                 // Merge default and save
                 $displayExtra[$propertyName] = ['visible' => true, 'weight' => $weight++];
             } else {
                 $context->logError(sprintf("%s: %s property is nor a field nor an extra field", $node->getPath(), $propertyName));
             }
         }
     }
     // Iterate over the fields and update each instance: we don't
     // need to do it with the $displayExtra property since it is
     // already the correctly formatted variable
     foreach ($displayField as $fieldName => $display) {
         $instances[$fieldName]['display'][$name] = $display;
     }
     // Remove non configured fields and extra fields from display
     foreach ($instances as $fieldName => $instance) {
         if (!isset($displayField[$fieldName])) {
             $instance['display'][$name] = array('type' => 'hidden');
         }
         if ($dirtyAllowed) {
             $data = $instance;
             unset($data['id'], $data['field_id'], $data['field_name'], $data['entity_type'], $data['bundle'], $data['deleted']);
             db_update('field_config_instance')->condition('id', $instance['id'])->fields(['data' => serialize($data)])->execute();
         } else {
             field_update_instance($instance);
         }
     }
     foreach (array_keys($extra) as $propertyName) {
         if (isset($displayExtra[$propertyName])) {
             $bundleSettings['extra_fields']['display'][$propertyName][$name] = $displayExtra[$propertyName];
         } else {
             $bundleSettings['extra_fields']['display'][$propertyName][$name] = ['visible' => false, 'weight' => $weight++];
         }
     }
     $bundleSettings['view_modes'][$name] = ['label' => $name, 'custom_settings' => true];
     if ($dirtyAllowed) {
         // Hopefully nothing about display is really cached into the
         // internal field cache class, except the raw display array
         // into each instance, but nothing will use that except this
         // specific view mode implementation, we are going to delay
         // a few cache clear calls at the very end of the processing.
         // From field_bundle_settings().
         variable_set('field_bundle_settings_' . $entityType . '__' . $bundle, $bundleSettings);
     } else {
         field_bundle_settings($entityType, $bundle, $bundleSettings);
     }
     if ($dirtyAllowed) {
         // From field_update_instance()
         cache_clear_all('*', 'cache_field', true);
         // From field_info_cache_clear()
         drupal_static_reset('field_view_mode_settings');
         // We need to clear cache in order for later view modes to
         // load the right instance and prevent them for overriding
         // what we actually did here
         entity_info_cache_clear();
         _field_info_field_cache()->flush();
     }
 }
Beispiel #19
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";
}
 /**
  * Submit entity specific settings on the Panelizer settings form.
  */
 public function settings_form_submit(&$form, &$form_state)
 {
     if (empty($form_state['values']['entities'][$this->entity_type])) {
         return;
     }
     foreach ($form_state['values']['entities'][$this->entity_type] as $bundle => $values) {
         // Rewrite our settings because they're not quite in the right format in
         // the form.
         $settings = array('status' => $values[0]['status'], 'view modes' => array());
         if (!empty($values[0]['status'])) {
             $settings['help'] = $values[0]['help'];
             foreach ($values as $view_mode => $config) {
                 if (!empty($view_mode) && !empty($config)) {
                     // Fix the configuration.
                     // Make sure each setting is disabled if the view mode is
                     // disabled.
                     if (empty($config['status'])) {
                         foreach ($config as $key => $val) {
                             $config[$key] = 0;
                         }
                     }
                     // Save the default display for this bundle to a variable so that it
                     // may be controlled separately.
                     if (!empty($config['selection'])) {
                         $variable_name = 'panelizer_' . $this->entity_type . ':' . $bundle . ':' . $view_mode . '_selection';
                         $old_value = variable_get($variable_name, NULL);
                         $new_value = $config['selection'];
                         variable_set($variable_name, $config['selection']);
                         // Cleanup.
                         // Additional cleanup if the default display was changed.
                         if (!is_null($old_value) && $old_value != $new_value) {
                             // The user specifically requested that existing entities are
                             // to be updated to the new display.
                             if (!empty($config['default revert'])) {
                                 $updated_count = db_update('panelizer_entity')->fields(array('name' => $new_value))->condition('name', $old_value)->execute();
                                 drupal_set_message(t('@count @entity records were updated to the new Panelizer display for the @mode view mode.', array('@count' => $updated_count, '@entity' => $this->entity_type, '@mode' => $view_mode)));
                                 // If EntityCache is enabled, clear all records of this type.
                                 // This is a little heavy-handed, but I don't believe there's
                                 // an easy way to clear only entities of certain types
                                 // without querying for them first, which could trigger an
                                 // execution timeout.
                                 if (module_exists('entitycache')) {
                                     cache_clear_all('*', 'cache_entity_' . $this->entity_type, TRUE);
                                 }
                             }
                         }
                     }
                     // Don't save some settings with the rest of the settings bundle.
                     unset($config['selection']);
                     unset($config['default revert']);
                     $settings['view modes'][$view_mode] = $config;
                 }
             }
         }
         variable_set('panelizer_defaults_' . $this->entity_type . '_' . $bundle, $settings);
     }
     // @todo if we enable caching of the plugins, which we should, this
     // needs to clear that cache so they get reloaded.
 }
Beispiel #21
0
/**
 * Allow modules to respond to the Views cache being invalidated.
 *
 * This hook should fire whenever a view is enabled, disabled, created,
 * updated, or deleted.
 *
 * @see views_invalidate_cache()
 */
function hook_views_invalidate_cache()
{
    cache_clear_all('views:*', 'cache_mymodule', TRUE);
}
 protected function _clearCache()
 {
     if ($this->env_id) {
         cache_clear_all($this->env_id . ":stats:", 'cache_apachesolr', TRUE);
         cache_clear_all($this->env_id . ":luke:", 'cache_apachesolr', TRUE);
     }
     $this->luke = array();
     $this->stats = NULL;
 }
Beispiel #23
0
 function updateCategories()
 {
     // copied this from profile.module. Seems a bit inefficient, but i dont know a better way
     // CRM-3600
     cache_clear_all();
     menu_rebuild();
 }
 function install($config)
 {
     global $installDirPath;
     // create database if does not exists
     $this->createDatabaseIfNotExists($config['mysql']['server'], $config['mysql']['username'], $config['mysql']['password'], $config['mysql']['database']);
     global $installDirPath;
     // Build database
     require_once $installDirPath . 'civicrm.php';
     civicrm_main($config);
     if (!$this->errors) {
         global $installType, $installURLPath;
         $output = NULL;
         if ($installType == 'drupal' && version_compare(VERSION, '7.0-rc1') >= 0) {
             // clean output
             @ob_clean();
             $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
             $output .= '<head>';
             $output .= '<title>CiviCRM Installed</title>';
             $output .= '<link rel="stylesheet" type="text/css" href="template.css" />';
             $output .= '</head>';
             $output .= '<body>';
             $output .= '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
             $output .= '<ul>';
             $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
             if (!function_exists('ts')) {
                 $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
             }
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/people/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
             $output .= "<li>Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a target='_blank' href={$drupalPermissionsURL}>review these permissions</a> to ensure that they are appropriate for your requirements (<a target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'>learn more...</a>)</li>\n                      <li>Use the <a target='_blank' href=\"{$drupalURL}\">Configuration Checklist</a> to review and configure settings for your new site</li>\n                      <li> Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='{$registerSiteURL}' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>\n                      <li>We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.</li>";
             // automatically enable CiviCRM module once it is installed successfully.
             // so we need to Bootstrap Drupal, so that we can call drupal hooks.
             global $cmsPath, $crmPath;
             // relative / abosolute paths are not working for drupal, hence using chdir()
             chdir($cmsPath);
             include_once "./includes/bootstrap.inc";
             include_once "./includes/unicode.inc";
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             // prevent session information from being saved.
             drupal_save_session(FALSE);
             // Force the current user to anonymous.
             $original_user = $GLOBALS['user'];
             $GLOBALS['user'] = drupal_anonymous_user();
             // explicitly setting error reporting, since we cannot handle drupal related notices
             error_reporting(1);
             // rebuild modules, so that civicrm is added
             system_rebuild_module_data();
             // now enable civicrm module.
             module_enable(array('civicrm', 'civicrmtheme'));
             // clear block and page cache, to make sure civicrm link is present in navigation block
             cache_clear_all();
             //add basic drupal permissions
             civicrm_install_set_drupal_perms();
             // restore the user.
             $GLOBALS['user'] = $original_user;
             drupal_save_session(TRUE);
             $output .= '</ul>';
             $output .= '</div>';
             $output .= '</body>';
             $output .= '</html>';
             echo $output;
         } elseif ($installType == 'drupal' && version_compare(VERSION, '6.0') >= 0) {
             // clean output
             @ob_clean();
             $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
             $output .= '<head>';
             $output .= '<title>CiviCRM Installed</title>';
             $output .= '<link rel="stylesheet" type="text/css" href="template.css" />';
             $output .= '</head>';
             $output .= '<body>';
             $output .= '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
             $output .= '<ul>';
             $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
             if (!function_exists('ts')) {
                 $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
             }
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/user/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
             $output .= "<li>Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a target='_blank' href={$drupalPermissionsURL}>review these permissions</a> to ensure that they are appropriate for your requirements (<a target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'>learn more...</a>)</li>\n                      <li>Use the <a target='_blank' href=\"{$drupalURL}\">Configuration Checklist</a> to review and configure settings for your new site</li>\n                      <li> Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='{$registerSiteURL}' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>\n                      <li>We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.</li>";
             // explicitly setting error reporting, since we cannot handle drupal related notices
             error_reporting(1);
             // automatically enable CiviCRM module once it is installed successfully.
             // so we need to Bootstrap Drupal, so that we can call drupal hooks.
             global $cmsPath, $crmPath;
             // relative / abosolute paths are not working for drupal, hence using chdir()
             chdir($cmsPath);
             include_once "./includes/bootstrap.inc";
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             // rebuild modules, so that civicrm is added
             module_rebuild_cache();
             // now enable civicrm module.
             module_enable(array('civicrm'));
             // clear block and page cache, to make sure civicrm link is present in navigation block
             cache_clear_all();
             //add basic drupal permissions
             db_query('UPDATE {permission} SET perm = CONCAT( perm, \', access CiviMail subscribe/unsubscribe pages, access all custom data, access uploaded files, make online contributions, profile create, profile edit, profile view, register for events, view event info\') WHERE rid IN (1, 2)');
             echo $output;
         } elseif ($installType == 'wordpress') {
             echo '<h1>CiviCRM Installed</h1>';
             echo '<div style="padding: 1em;"><p style="background-color: #0C0; border: 1px #070 solid; color: white;">CiviCRM has been successfully installed</p>';
             echo '<ul>';
             $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
             if (!function_exists('ts')) {
                 $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
             }
             $cmsURL = civicrm_cms_base();
             $cmsURL .= "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/configtask&reset=1";
             $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
             echo "<li>Use the <a target='_blank' href=\"{$cmsURL}\">Configuration Checklist</a> to review and configure settings for your new site</li>\n                    <li> Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='{$registerSiteURL}' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>\n                    <li>We have integrated KCFinder with CKEditor and TinyMCE, which enables user to upload images. Note that all the images uploaded using KCFinder will be public.</li>";
             echo '</ul>';
             echo '</div>';
         }
     }
     return $this->errors;
 }
 protected function _clearCache()
 {
     cache_clear_all("apachesolr:luke:", 'cache', TRUE);
     cache_clear_all("apachesolr:stats:", 'cache', TRUE);
     $this->luke = array();
     $this->stats = NULL;
 }
 /**
  * Refresh the in-memory set of variables. Useful after a page request is made
  * that changes a variable in a different thread.
  *
  * In other words calling a settings page with $this->drupalPost() with a changed
  * value would update a variable to reflect that change, but in the thread that
  * made the call (thread running the test) the changed variable would not be
  * picked up.
  *
  * This method clears the variables cache and loads a fresh copy from the database
  * to ensure that the most up-to-date set of variables is loaded.
  */
 protected function refreshVariables()
 {
     global $conf;
     cache_clear_all('variables', 'cache_bootstrap');
     $conf = variable_initialize();
 }
Beispiel #27
0
/**
 * Form submit handler for the theme settings form.
 */
function omega_theme_settings_form_submit($form, &$form_state)
{
    // Clear the theme cache.
    $theme = $form_state['build_info']['args'][0];
    cache_clear_all('omega:' . $theme . ':', 'cache', TRUE);
    // We also need to clear the static right away.
    drupal_static_reset('omega_extensions');
    // Rebuild the theme registry. This has quite a performance impact but since
    // this only happens once after we (re-)saved the theme settings this is fine.
    // Also, this is actually required because we are caching certain things in
    // the theme registry.
    drupal_theme_rebuild();
    // We really don't want to reset theme settings for disabled extensions.
    foreach ($form_state['extensions'] as $extension) {
        if (!$form_state['values']['omega_toggle_extension_' . $extension]) {
            _omega_retain_extension_settings($form, $form_state, $extension, $theme);
        }
    }
    // This is a relict from the vertical tabs and should be removed so it doesn't
    // end up in the theme settings array.
    unset($form_state['values']['omega__active_tab']);
}
Beispiel #28
0
function update_info_page()
{
    // Change query-strings on css/js files to enforce reload for all users.
    _drupal_flush_css_js();
    // Flush the cache of all data for the update status module.
    if (db_table_exists('cache_update')) {
        cache_clear_all('*', 'cache_update', TRUE);
    }
    update_task_list('info');
    drupal_set_title('Drupal database update');
    $token = drupal_get_token('update');
    $output = '<p>Use this utility to update your database whenever a new release of Drupal or a module is installed.</p><p>For more detailed information, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
    $output .= "<ol>\n";
    $output .= "<li><strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.</li>\n";
    $output .= "<li><strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.</li>\n";
    $output .= '<li>Put your site into <a href="' . base_path() . '?q=admin/settings/maintenance-mode">maintenance mode</a>.</li>' . "\n";
    $output .= "<li>Install your new files in the appropriate location, as described in the handbook.</li>\n";
    $output .= "</ol>\n";
    $output .= "<p>When you have performed the steps above, you may proceed.</p>\n";
    $output .= '<form method="post" action="update.php?op=selection&amp;token=' . $token . '"><p><input type="submit" value="Continue" /></p></form>';
    $output .= "\n";
    return $output;
}
 /**
  * Provide the actual editing form.
  */
 function edit_form(&$form, &$form_state)
 {
     parent::edit_form($form, $form_state);
     $settings = $form_state['item']->settings;
     $new = TRUE;
     $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#default_value' => isset($form_state['item']->label) ? $form_state['item']->label : array(), '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#attributes' => $new ? array() : array('readonly' => 'readonly'));
     $form['module'] = array('#type' => 'textfield', '#title' => t('Module'), '#default_value' => isset($form_state['item']->module) ? $form_state['item']->module : array(), '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#attributes' => $new ? array() : array('readonly' => 'readonly'));
     $form['settings'] = array('#type' => 'fieldset', '#title' => t('Settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, '#group' => 'general-tab');
     $plugin_name = $form_state['item']->plugin_name;
     $pluginWrapper = heartbeat_plugins_get_plugin($plugin_name);
     if ($pluginWrapper instanceof iHeartbeatPluginWrapper) {
         $plugin = $pluginWrapper->getPlugin();
         if ($plugin) {
             $plugin->pluginUIForm($form, $form_state);
         }
         $new = FALSE;
     }
     if ($new) {
         $form['settings']['attachment'] = array('#type' => 'checkbox', '#title' => t('Attachment'), '#default_value' => isset($settings['attachment']) ? $settings['attachment'] : array());
     }
     if (!element_children($form['settings'])) {
         unset($form['settings']);
     }
     // Clear the cache for heartbeat plugins.
     cache_clear_all('heartbeat_plugins', 'cache');
 }
Beispiel #30
-2
/**
 * This function is copying the same code from legal.
 */
function devis_form_legal_login_submit($form, &$form_state)
{
    // This is a copy from the legal module.
    global $user;
    $values = $form_state['values'];
    $user = user_load($values['uid']);
    $redirect = 'user/' . $user->uid;
    if (!empty($_GET['destination'])) {
        $redirect = $_GET['destination'];
    }
    $form_state['redirect'] = $redirect;
    // Update the user table timestamp noting user has logged in.
    db_update('users')->fields(array('login' => time()))->condition('uid', $user->uid)->execute();
    // User has new permissions, so we clear their menu cache.
    cache_clear_all($user->uid, 'cache_menu', TRUE);
    // Fixes login problems in Pressflow.
    drupal_session_regenerate();
    user_module_invoke('login', $edit, $user);
}