Esempio n. 1
0
/**
 * Create Cleaner settings form.
 *
 * @return array
 *   Form of the cleaner settings page.
 */
function hook_cleaner_settings()
{
    // Add CSS to the admin settings page.
    drupal_add_css(drupal_get_path('module', 'cleaner') . '/cleaner.css');
    $form = array();
    $yes_no = array(t('No'), t('Yes'));
    $inline = array('class' => array('container-inline'));
    $interval = array(0 => t('Every time')) + Cleaner::$intervals;
    $form['cleaner_cron'] = array('#type' => 'radios', '#title' => t('Run interval'), '#options' => $interval, '#default_value' => variable_get('cleaner_cron', 3600), '#description' => t('This is how often the options below will occur. The actions will occur on the next Cron run after this interval expires. "Every time" means on every Cron run.'), '#attributes' => $inline);
    $form['cleaner_clear_cache'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up cache'), '#default_value' => variable_get('cleaner_clear_cache', 0), '#description' => Cleaner::cleanerGetCacheTablesTable(), '#attributes' => $inline);
    $form['cleaner_empty_watchdog'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up Watchdog'), '#default_value' => variable_get('cleaner_empty_watchdog', 0), '#description' => t('There is a standard setting for controlling Watchdog contents. This is more useful for test sites.'), '#attributes' => $inline);
    $cookie = session_get_cookie_params();
    $select = db_select('sessions', 's')->fields('s', array('timestamp'))->condition('timestamp', REQUEST_TIME - $cookie['lifetime'], '<');
    $count = $select->execute()->rowCount();
    $form['cleaner_clean_sessions'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up Sessions table'), '#default_value' => variable_get('cleaner_clean_sessions', 0), '#description' => t('The sessions table can quickly become full with old, abandoned sessions. This will delete all sessions older than @interval (as set by your site administrator). There are currently @count such sessions.', array('@interval' => format_interval($cookie['lifetime']), '@count' => $count)), '#attributes' => $inline);
    $form['cleaner_clean_cssdir'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up CSS files'), '#default_value' => variable_get('cleaner_clean_cssdir', 0), '#description' => t('The CSS directory can become full with stale and outdated cache files.  This will delete all CSS cache files but the latest.'), '#attributes' => $inline);
    $form['cleaner_clean_jsdir'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up JS files'), '#default_value' => variable_get('cleaner_clean_jsdir', 0), '#description' => t('The JS directory can become full with stale and outdated cache files.  This will delete all JS cache files but the latest.'), '#attributes' => $inline);
    // We can only offer OPTIMIZE to MySQL users.
    if (db_driver() == 'mysql') {
        $form['cleaner_optimize_db'] = array('#type' => 'radios', '#options' => $yes_no + array('2' => 'Local only'), '#title' => t('Optimize tables with "overhead" space'), '#default_value' => variable_get('cleaner_optimize_db', 0), '#description' => t('The module will compress (optimize) all database tables with unused space. <strong>NOTE</strong>: During an optimization, the table will locked against any other activity; on a high vloume site, this may be undesirable. "Local only" means do not replicate the optimization (if it is being done).'), '#attributes' => $inline);
    } else {
        // If not MySQL, delete(reset) the variable.
        variable_del('cleaner_optimize_db');
    }
    return array('cleaner' => $form);
}
Esempio n. 2
0
 /**
  * Cleans up variables by template.
  */
 public static function doVariablesCleanupByTemplate($template)
 {
     $result = db_query("\n    SELECT name FROM {variable}\n    WHERE name LIKE '" . $template . "'");
     foreach ($result as $row) {
         variable_del($row->name);
     }
 }
Esempio n. 3
0
 /**
  * Resets module settings
  */
 public function reset_settings()
 {
     variable_del('mylivechat_id');
     variable_del('mylivechat_displaytype');
     variable_del('mylivechat_membership');
     variable_del('mylivechat_encrymode');
     variable_del('mylivechat_encrykey');
 }
 /**
  * Tear down REST test.
  *
  * Call this from tearDown() method of your test class.
  */
 protected function restTearDown()
 {
     // Delete storage.
     unset($this->responseStorage);
     // Unset response file variable.
     variable_del('site_test_rest_response_file');
     $this->refreshVariablesRunner();
 }
Esempio n. 5
0
function variable_move($old, $new)
{
    $val = variable_get($old, NULL);
    if (!is_null($value)) {
        variable_set($new, $val);
        variable_del($old);
    }
}
 /**
  * Method for deleting a key and its value from the caching mechanism.
  *
  * @param string $key
  *   The key that will be deleted, along with its value.
  *
  * @return NULL
  *   Returns after corresponding delete functionality finishes.
  */
 public function vdel($key)
 {
     if ($this->memcacheExists) {
         $this->mem->clear($key);
         return;
     }
     variable_del($key);
 }
Esempio n. 7
0
function marketplace_reset_settings()
{
    global $theme_key;
    variable_del('theme_' . $theme_key . '_settings');
    variable_del('theme_settings');
    $cache =& drupal_static('theme_get_setting', array());
    $cache[$theme_key] = NULL;
}
Esempio n. 8
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);
 }
Esempio n. 9
0
 /**
  * Restores the initial values of the Drupal variables.
  *
  * @AfterScenario
  */
 public function restoreVariables()
 {
     foreach ($this->initialVariables as $variable => $value) {
         if ($value === NULL) {
             variable_del($variable);
         } else {
             variable_set($variable, $value);
         }
     }
 }
Esempio n. 10
0
 /**
  * Sets up modules for API tests, and saves the default branch for teardown.
  */
 function baseSetUp()
 {
     // This is restored in the tearDown() function.
     $this->default_branch = variable_get('api_default_branch', NULL);
     variable_del('api_default_branch');
     DrupalWebTestCase::setUp('drupal_queue', 'grammar_parser', 'ctools', 'api');
     include_once drupal_get_path('module', 'api') . '/api.admin.inc';
     include_once drupal_get_path('module', 'api') . '/parser.inc';
     drupal_queue_include();
     // Set up a super-user.
     $this->super_user = $this->drupalCreateUser(array('access API reference', 'administer API reference', 'access content', 'access administration pages', 'administer blocks', 'administer nodes'));
     $this->drupalLogin($this->super_user);
 }
function gd_cache_admin_settings_submit($form, &$form_state) {
    $text = StringHelper::trim($form_state['values']['resources']);

    $resourceIds = isset($text) ? gd_cache_parse_resources($text): NULL;

    $storageValue = isset($resourceIds) ? implode("\n", $resourceIds) : NULL;
    if (isset($storageValue)) {
        variable_set(VARIABLE_NAME__CACHE_URL, $storageValue);
        $message = t('@count URLs saved', array('@count' => count($resourceIds)));
    }
    else {
        variable_del(VARIABLE_NAME__CACHE_URL);
        $message = t('List of URLs is cleared');
    }
    drupal_set_message($message);
}
 /**
  * Implements AcsfEventHandler::handle().
  */
 public function handle()
 {
     drush_print(dt('Entered @class', array('@class' => get_class($this))));
     if (!$this->isComplete()) {
         $site = acsf_get_acsf_site();
         $site->clean();
         variable_del('acsf_duplication_scrub_status');
         variable_set('site_name', $this->event->context['site_name']);
         variable_set('install_time', time());
         // As a preparatory step, remove any corrupt file entries that may prevent
         // duplication from succeeding. Specifically, remove any file with an
         // empty URI string.
         db_delete('file_managed')->condition('uri', '')->execute();
         $this->setComplete();
     }
 }
function brafton_admin_form_submit($form, &$form_state)
{
    //reset the error report
    if ($form_state['values']['brafton_clear_report']) {
        variable_set('brafton_e_log', '');
        //variable_set('brafton_clear_report', 0);
    }
    //runs importer if archive is loaded
    //Handles background image for videos
    if ($form_state['values']['brafton_video_end_cta_background'] != '') {
        $file = file_load($form_state['values']['brafton_video_end_cta_background']);
        // Change status to permanent.
        $file->status = FILE_STATUS_PERMANENT;
        // Save.
        $newfile = file_save($file);
        $name = basename('brafton.module', '.module');
        file_usage_add($newfile, $name, $name, $newfile->fid);
        variable_set('brafton_video_end_cta_background_url', $newfile->uri);
        variable_set('brafton_video_end_cta_background_id', $newfile->fid);
    } else {
        if (!$form_state['values']['brafton_video_end_cta_background']['fid']) {
            variable_set('brafton_video_end_cta_background_url', '');
            variable_del('brafton_video_end_cta_background_id');
        }
    }
    //Handles Button Image for videos
    if ($form_state['values']['brafton_video_end_cta_button_image'] != '') {
        $file = file_load($form_state['values']['brafton_video_end_cta_button_image']);
        // Change status to permanent.
        $file->status = FILE_STATUS_PERMANENT;
        // Save.
        $newfile = file_save($file);
        $name = basename('brafton.module', '.module');
        file_usage_add($newfile, $name, $name, $newfile->fid);
        variable_set('brafton_video_end_cta_button_image_url', $newfile->uri);
        variable_set('brafton_video_end_cta_button_image_id', $newfile->fid);
    } else {
        if (!$form_state['values']['brafton_video_end_cta_button_image']['fid']) {
            variable_set('brafton_video_end_cta_button_image_url', '');
            variable_del('brafton_video_end_cta_button_image_id');
        }
    }
    //Ensure that the run manual imports
    $form_state['values']['brafton_clear_report'] = 0;
}
Esempio n. 14
0
function tac_admin_submit($form, &$form_state)
{
    db_delete('tac_map')->execute();
    $vocabulary = $form_state['values']['vocabulary'];
    if ($vocabulary > 0 && $vocabulary != variable_get('tac_vocabulary')) {
        variable_set('tac_vocabulary', $vocabulary);
        node_access_needs_rebuild(TRUE);
        return;
    } elseif ($vocabulary <= 0) {
        variable_del('tac_vocabulary');
        node_access_needs_rebuild(TRUE);
        return;
    }
    $insert = db_insert('tac_map')->fields(array('rid', 'tid', 'grant_list', 'grant_create', 'grant_update', 'grant_delete'));
    foreach ($form_state['values']['edit'] as $rid => $terms) {
        foreach ($terms as $tid => $grants) {
            $insert->values(array($rid, $tid, $grants['list'], $grants['create'], $grants['update'], $grants['delete']));
        }
    }
    $insert->execute();
}
 /**
  * Implements AcsfEventHandler::handle().
  */
 public function handle()
 {
     drush_print(dt('Entered @class', array('@class' => get_class($this))));
     $options = $this->event->context['scrub_options'];
     variable_del('cron_last');
     variable_del('cron_semaphore');
     variable_del('node_cron_last');
     variable_del('drupal_private_key');
     variable_set('cron_key', drupal_hash_base64(drupal_random_bytes(55)));
     // Ensure Drupal filesystem related configuration variables are correct for
     // the new site. Consider the following variables:
     // - file_directory_path
     // - file_directory_temp
     // - file_private_path
     // - file_temporary_path
     // Given the AH environment for Gardens, we want to leave the temp paths
     // alone, and we want to delete the other variables, to ensure they reset to
     // their defaults (because of scarecrow, these shouldn't exist in the
     // variable table anyway).
     $file_path_variables = array('file_directory_path', 'file_private_path');
     foreach ($file_path_variables as $variable) {
         variable_del($variable);
     }
 }
Esempio n. 16
0
 *
 * @author: David L. Heskett (contractor: Adaptive Solutions Group)
 * @date Created: 01/13/2011
 *
 */
// using Drush, attempt to simulate the "cron" process that should occur, because oaiharvester cron is totally busted and unreliable, so workaround ...
// drush php-script <filename less the .php>
// drush php-script manualOaiHarvesterCron
$harvestId = 9;
$includePath = dirname(__FILE__) . '/';
//require_once($includePath . 'manualOaiHarvester.php');
//return;
require_once $includePath . 'manualOaiHarvesterModel.php';
// prevent crons colliding, there can be only one highlander
$nameHarvestRunning = 'harvest_running_' . $harvestId;
$flagHarvestRunning = variable_get($nameHarvestRunning, false);
if ($flagHarvestRunning) {
    return;
}
variable_set($nameHarvestRunning, 1);
$x = new manualOaiHarvesterModel();
$msg = 'harvest id:' . $harvestId;
$x->myOaiLogMsg($msg);
$msg = 'Start:' . date('YmdHis');
$x->myOaiLogMsg($msg);
// get started
$x->manualOaiHarvesterCron($harvestId);
$msg = 'End:' . date('YmdHis');
$x->myOaiLogMsg($msg);
variable_del($nameHarvestRunning);
// **************************************************
Esempio n. 17
0
/**
 * Act on node type deletion.
 *
 * This hook allows modules to take action when a node type is deleted.
 *
 * @param $info
 *   The node type object which is being deleted.
 */
function hook_node_type_delete($info)
{
    variable_del('comment_' . $info->type);
}
Esempio n. 18
0
/**
 * Tasks performed after the database is initialized.
 */
function install_tasks($profile, $task)
{
    global $base_url, $install_locale;
    // Bootstrap newly installed Drupal, while preserving existing messages.
    $messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    $_SESSION['messages'] = $messages;
    // URL used to direct page requests.
    $url = $base_url . '/install.php?locale=' . $install_locale . '&profile=' . $profile;
    // Build a page for final tasks.
    if (empty($task)) {
        variable_set('install_task', 'profile-install');
        $task = 'profile-install';
    }
    // We are using a list of if constructs here to allow for
    // passing from one task to the other in the same request.
    // Install profile modules.
    if ($task == 'profile-install') {
        $modules = variable_get('install_profile_modules', array());
        $files = module_rebuild_cache();
        variable_del('install_profile_modules');
        $operations = array();
        foreach ($modules as $module) {
            $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
        }
        $batch = array('operations' => $operations, 'finished' => '_install_profile_batch_finished', 'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_name())), 'error_message' => st('The installation has encountered an error.'));
        // Start a batch, switch to 'profile-install-batch' task. We need to
        // set the variable here, because batch_process() redirects.
        variable_set('install_task', 'profile-install-batch');
        batch_set($batch);
        batch_process($url, $url);
    }
    // We are running a batch install of the profile's modules.
    // This might run in multiple HTTP requests, constantly redirecting
    // to the same address, until the batch finished callback is invoked
    // and the task advances to 'locale-initial-import'.
    if ($task == 'profile-install-batch') {
        include_once 'includes/batch.inc';
        $output = _batch_page();
    }
    // Import interface translations for the enabled modules.
    if ($task == 'locale-initial-import') {
        if (!empty($install_locale) && $install_locale != 'en') {
            include_once 'includes/locale.inc';
            // Enable installation language as default site language.
            locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE);
            // Collect files to import for this language.
            $batch = locale_batch_by_language($install_locale, '_install_locale_initial_batch_finished');
            if (!empty($batch)) {
                // Remember components we cover in this batch set.
                variable_set('install_locale_batch_components', $batch['#components']);
                // Start a batch, switch to 'locale-batch' task. We need to
                // set the variable here, because batch_process() redirects.
                variable_set('install_task', 'locale-initial-batch');
                batch_set($batch);
                batch_process($url, $url);
            }
        }
        // Found nothing to import or not foreign language, go to next task.
        $task = 'configure';
    }
    if ($task == 'locale-initial-batch') {
        include_once 'includes/batch.inc';
        include_once 'includes/locale.inc';
        $output = _batch_page();
    }
    if ($task == 'configure') {
        if (variable_get('site_name', FALSE) || variable_get('site_mail', FALSE)) {
            // Site already configured: This should never happen, means re-running
            // the installer, possibly by an attacker after the 'install_task' variable
            // got accidentally blown somewhere. Stop it now.
            install_already_done_error();
        }
        $form = drupal_get_form('install_configure_form', $url);
        if (!variable_get('site_name', FALSE) && !variable_get('site_mail', FALSE)) {
            // Not submitted yet: Prepare to display the form.
            $output = $form;
            drupal_set_title(st('Configure site'));
            // Warn about settings.php permissions risk
            $settings_dir = './' . conf_path();
            $settings_file = $settings_dir . '/settings.php';
            if (!drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($settings_dir, FILE_NOT_WRITABLE, 'dir')) {
                drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, please consult the <a href="@handbook_url">on-line handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/getting-started')), 'error');
            } else {
                drupal_set_message(st('All necessary changes to %dir and %file have been made. They have been set to read-only for security.', array('%dir' => $settings_dir, '%file' => $settings_file)));
            }
            // Add JavaScript validation.
            _user_password_dynamic_validation();
            drupal_add_js(drupal_get_path('module', 'system') . '/system.js', 'module');
            // We add these strings as settings because JavaScript translation does not
            // work on install time.
            drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail')), 'cleanURL' => array('success' => st('Your server has been successfully tested to support this feature.'), 'failure' => st('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.'), 'testing' => st('Testing clean URLs...'))), 'setting');
            drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
  $(document).ready(function() {
    Drupal.cleanURLsInstallCheck();
    Drupal.setDefaultTimezone();
  });
}', 'inline');
            // Build menu to allow clean URL check.
            menu_rebuild();
        } else {
            $task = 'profile';
        }
    }
    // If found an unknown task or the 'profile' task, which is
    // reserved for profiles, hand over the control to the profile,
    // so it can run any number of custom tasks it defines.
    if (!in_array($task, install_reserved_tasks())) {
        $function = $profile . '_profile_tasks';
        if (function_exists($function)) {
            // The profile needs to run more code, maybe even more tasks.
            // $task is sent through as a reference and may be changed!
            $output = $function($task, $url);
        }
        // If the profile doesn't move on to a new task we assume
        // that it is done.
        if ($task == 'profile') {
            $task = 'profile-finished';
        }
    }
    // Profile custom tasks are done, so let the installer regain
    // control and proceed with importing the remaining translations.
    if ($task == 'profile-finished') {
        if (!empty($install_locale) && $install_locale != 'en') {
            include_once 'includes/locale.inc';
            // Collect files to import for this language. Skip components
            // already covered in the initial batch set.
            $batch = locale_batch_by_language($install_locale, '_install_locale_remaining_batch_finished', variable_get('install_locale_batch_components', array()));
            // Remove temporary variable.
            variable_del('install_locale_batch_components');
            if (!empty($batch)) {
                // Start a batch, switch to 'locale-remaining-batch' task. We need to
                // set the variable here, because batch_process() redirects.
                variable_set('install_task', 'locale-remaining-batch');
                batch_set($batch);
                batch_process($url, $url);
            }
        }
        // Found nothing to import or not foreign language, go to next task.
        $task = 'finished';
    }
    if ($task == 'locale-remaining-batch') {
        include_once 'includes/batch.inc';
        include_once 'includes/locale.inc';
        $output = _batch_page();
    }
    // Display a 'finished' page to user.
    if ($task == 'finished') {
        drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name())));
        $messages = drupal_set_message();
        $output = '<p>' . st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) . '</p>';
        $output .= '<p>' . (isset($messages['error']) ? st('Please review the messages above before continuing on to <a href="@url">your new site</a>.', array('@url' => url(''))) : st('You may now visit <a href="@url">your new site</a>.', array('@url' => url('')))) . '</p>';
        $task = 'done';
    }
    // The end of the install process. Remember profile used.
    if ($task == 'done') {
        // Rebuild menu to get content type links registered by the profile,
        // and possibly any other menu items created through the tasks.
        menu_rebuild();
        // Register actions declared by any modules.
        actions_synchronize();
        // Randomize query-strings on css/js files, to hide the fact that
        // this is a new install, not upgraded yet.
        _drupal_flush_css_js();
        variable_set('install_profile', $profile);
    }
    // Set task for user, and remember the task in the database.
    install_task_list($task);
    variable_set('install_task', $task);
    // Output page, if some output was required. Otherwise it is possible
    // that we are printing a JSON page and theme output should not be there.
    if (isset($output)) {
        print theme('maintenance_page', $output);
    }
}
 /**
  * Submit callback for the bundle edit form.
  */
 public function add_bundle_setting_form_submit($form, &$form_state, $bundle, $type_location)
 {
     // Some types do not support changing bundles, so we don't check if it's
     // not possible to change.
     if ($type_location) {
         $new_bundle = drupal_array_get_nested_value($form_state['values'], $type_location);
     } else {
         $new_bundle = $bundle;
     }
     // Check to see if the bundle has changed. If so, we need to move stuff
     // around.
     if ($bundle && $new_bundle != $bundle) {
         // Remove old settings.
         variable_del('panelizer_defaults_' . $this->entity_type . '_' . $bundle);
         $allowed_layouts = variable_get('panelizer_' . $this->entity_type . ':' . $bundle . '_allowed_layouts', NULL);
         if ($allowed_layouts) {
             variable_del('panelizer_' . $this->entity_type . ':' . $bundle . '_allowed_layouts');
             variable_set('panelizer_' . $this->entity_type . ':' . $new_bundle . '_allowed_layouts', $allowed_layouts);
         }
         $default = variable_get('panelizer_' . $this->entity_type . ':' . $bundle . '_default', NULL);
         if ($default) {
             variable_del('panelizer_' . $this->entity_type . ':' . $bundle . '_default');
             variable_set('panelizer_' . $this->entity_type . ':' . $new_bundle . '_default', $default);
         }
         // Load up all panelizer defaults for the old bundle and resave them
         // for the new bundle.
         $panelizer_defaults = $this->get_default_panelizer_objects($bundle);
         if (!empty($panelizer_defaults)) {
             foreach ($panelizer_defaults as $panelizer) {
                 list($entity_type, $old_bundle, $name) = explode(':', $panelizer->name);
                 $panelizer->name = implode(':', array($entity_type, $new_bundle, $name));
                 if ($panelizer->view_mode != 'page_manager') {
                     $panelizer->name .= ':' . $panelizer->view_mode;
                 }
                 // The default display selection.
                 $old_variable_name = 'panelizer_' . $this->entity_type . ':' . $bundle . ':' . $panelizer->view_mode . '_selection';
                 $new_variable_name = 'panelizer_' . $this->entity_type . ':' . $new_bundle . ':' . $panelizer->view_mode . '_selection';
                 $default_layout = variable_get($old_variable_name, NULL);
                 if (!is_null($default_layout)) {
                     variable_set($new_variable_name, $default_layout);
                     variable_del($old_variable_name);
                 }
                 $panelizer->panelizer_key = $new_bundle;
                 // If there's a pnid this should change the name and retain the pnid.
                 // If there is no pnid this will create a new one in the database
                 // because exported panelizer defaults attached to a bundle will have
                 // to be moved to the database in order to follow along and then be
                 // re-exported.
                 // @todo Should we warn the user about this?
                 ctools_export_crud_save('panelizer_defaults', $panelizer);
             }
         }
     }
     // Fix the configuration.
     // If the main configuration is disabled then everything gets disabled.
     if (empty($form_state['values']['panelizer']['status'])) {
         $form_state['values']['panelizer']['view modes'] = array();
     } elseif (!empty($form_state['values']['panelizer']['view modes'])) {
         // Make sure each setting is disabled if the view mode is disabled.
         foreach ($form_state['values']['panelizer']['view modes'] as $view_mode => &$config) {
             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.
     foreach ($this->get_default_panelizer_objects($new_bundle) as $panelizer) {
         if (isset($form_state['values']['panelizer']['view modes'][$panelizer->view_mode]['selection'])) {
             $variable_name = 'panelizer_' . $this->entity_type . ':' . $new_bundle . ':' . $panelizer->view_mode . '_selection';
             $old_value = variable_get($variable_name, NULL);
             $new_value = $form_state['values']['panelizer']['view modes'][$panelizer->view_mode]['selection'];
             // Save the variable.
             variable_set($variable_name, $new_value);
             // 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($form_state['values']['panelizer']['view modes'][$panelizer->view_mode]['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' => $panelizer->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);
                     }
                 }
             }
         }
     }
     // Remove some settings that shouldn't be saved with the others.
     if (!empty($form_state['values']['panelizer']['view modes'])) {
         foreach ($form_state['values']['panelizer']['view modes'] as $view_mode => $settings) {
             unset($form_state['values']['panelizer']['view modes'][$view_mode]['selection']);
             unset($form_state['values']['panelizer']['view modes'][$view_mode]['default revert']);
         }
     }
     variable_set('panelizer_defaults_' . $this->entity_type . '_' . $new_bundle, $form_state['values']['panelizer']);
     // Verify the necessary Page Manager prerequisites are ready.
     if (!empty($form_state['values']['panelizer']['status']) && !empty($form_state['values']['panelizer']['view modes']['page_manager']['status']) && $this->is_page_manager_enabled()) {
         $this->check_page_manager_status();
     }
     // Unset this so that the type save forms don't try to save it to variables.
     unset($form_state['values']['panelizer']);
 }
 public static function uninstall()
 {
     variable_del('ldap_authentication_conf');
 }
Esempio n. 21
0
 /**
  * Delete variable.
  *
  * @param string $name
  *    Variable name.
  */
 public function deleteVariable($name)
 {
     variable_del($name);
 }
function elysia_cron_check_version_update()
{
    $ver = variable_get('elysia_cron_version', 0);
    if ($ver < 20111012) {
        $ver = _ec_variable_get('elysia_cron_version', 0);
    }
    if (!$ver || $ver < 20090218) {
        $unchanged = array('elysia_cron_last_context', 'elysia_cron_last_run', 'elysia_cron_disabled', 'elysia_cron_semaphore', 'elysia_cron_key', 'elysia_cron_allowed_hosts', 'elysia_cron_default_rule', 'elysia_cron_script', 'elysia_cron_runtime_replacement', 'elysia_cron_version');
        $rs = db_query('select * from {variable} where name like "elysia_cron_%%"');
        while ($v = db_fetch_object($rs)) {
            if (!in_array($v->name, $unchanged)) {
                $vn = false;
                if (preg_match('/^elysia_cron_ctx_(.*)_(running|disabled|last_run|last_aborted|abort_count|execution_count|last_execution_time|avg_execution_time|max_execution_time|last_shutdown_time|last_abort_function)/', $v->name, $r)) {
                    switch ($r[2]) {
                        case 'running':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_r';
                            break;
                        case 'disabled':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_d';
                            break;
                        case 'last_run':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_lr';
                            break;
                        case 'last_aborted':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_la';
                            break;
                        case 'abort_count':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_ac';
                            break;
                        case 'execution_count':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_ec';
                            break;
                        case 'last_execution_time':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_let';
                            break;
                        case 'avg_execution_time':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_aet';
                            break;
                        case 'max_execution_time':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_met';
                            break;
                        case 'last_shutdown_time':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_lst';
                            break;
                        case 'last_abort_function':
                            $vn = 'ecc_' . _ec_get_name($r[1]) . '_laf';
                            break;
                    }
                } elseif (preg_match('/^elysia_cron_(.*)_(rule|disabled|context|running|last_run|last_execution_time|execution_count|avg_execution_time|max_execution_time)/', $v->name, $r)) {
                    switch ($r[2]) {
                        case 'rule':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_rul';
                            break;
                        case 'disabled':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_d';
                            break;
                        case 'context':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_c';
                            break;
                        case 'running':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_r';
                            break;
                        case 'last_run':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_lr';
                            break;
                        case 'last_execution_time':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_let';
                            break;
                        case 'execution_count':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_ec';
                            break;
                        case 'avg_execution_time':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_aet';
                            break;
                        case 'max_execution_time':
                            $vn = 'ec_' . _ec_get_name($r[1]) . '_met';
                            break;
                    }
                }
                if ($vn) {
                    variable_set($vn, unserialize($v->value));
                } else {
                    _dco_watchdog('cron', 'Error in update, cant convert %name (value: %value)', array('%name' => $v->name, '%value' => $v->value), WATCHDOG_ERROR);
                }
                variable_del($v->name);
            }
        }
        variable_set('elysia_cron_version', 20090218);
    }
    if ($ver < 20090920) {
        variable_set('elysia_cron_version', 20090920);
    }
    if ($ver < 20100507) {
        if (EC_DRUPAL_VERSION >= 6) {
            // D6
            drupal_install_schema('elysia_cron');
            // In ver 20111020 disabled has been renamed to disable, revert it now
            if (EC_DRUPAL_VERSION >= 7) {
                // D7
                // Must use "$v" for PHP5.3 running D6 version (detect the error even if it doesn't pass here)
                db_change_field($v = 'elysia_cron', 'disable', 'disabled', array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE));
            } elseif (EC_DRUPAL_VERSION >= 6) {
                // D6
                $ret = array();
                db_change_field($ret, 'elysia_cron', 'disable', 'disabled', array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE));
            }
        } else {
            // D5
            switch ($GLOBALS['db_type']) {
                case 'mysqli':
                case 'mysql':
                    db_query("create table if not exists {elysia_cron} (\r\n            name varchar(120) not null,\r\n            disabled tinyint(1) not null default '0',\r\n            rule varchar(32),\r\n            weight int(11) not null default '0',\r\n            context varchar(32),\r\n            running int(11) not null default '0',\r\n            last_run int(11) not null default '0',\r\n            last_aborted tinyint(1) not null default '0',\r\n            abort_count int(11) not null default '0',\r\n            last_abort_function varchar(32),\r\n            last_execution_time int(11) not null default '0',\r\n            execution_count int(11) not null default '0',\r\n            avg_execution_time float(5,2) not null default '0',\r\n            max_execution_time int(11) not null default '0',\r\n            last_shutdown_time int(11) not null default '0',\r\n            primary key (name)\r\n          )");
                    break;
                case 'pgsql':
                    db_query("create table {elysia_cron} (\r\n            name varchar(120) not null,\r\n            disabled smallint not null default '0',\r\n            rule varchar(32),\r\n            weight integer not null default '0',\r\n            context varchar(32),\r\n            running int not null default '0',\r\n            last_run integer not null default '0',\r\n            last_aborted smallint not null default '0',\r\n            abort_count integer not null default '0',\r\n            last_abort_function varchar(32),\r\n            last_execution_time integer not null default '0',\r\n            execution_count integer not null default '0',\r\n            avg_execution_time float not null default '0',\r\n            max_execution_time integer not null default '0',\r\n            last_shutdown_time integer not null default '0',\r\n            primary key (name)\r\n          )");
            }
        }
        $rs = db_query('select * from {variable} where name like "ec_%%" or name like "ecc_%%"');
        $data = array();
        $todelete = array();
        while ($v = db_fetch_object($rs)) {
            $name = false;
            if (preg_match('/^ecc_(.+)_(r|d|lr|la|ac|ec|let|aet|met|lst|laf)/', $v->name, $r)) {
                $name = ':' . $r[1];
            } elseif (preg_match('/^ec_(.+)_(rul|d|c|w|r|lr|let|ec|aet|met)/', $v->name, $r)) {
                $name = $r[1];
            }
            if ($name) {
                if (!isset($data[$name])) {
                    $data[$name] = array('name' => $name);
                }
                switch ($r[2]) {
                    case 'r':
                        $f = 'running';
                        break;
                    case 'd':
                        $f = 'disabled';
                        break;
                    case 'rul':
                        $f = 'rule';
                        break;
                    case 'w':
                        $f = 'weight';
                        break;
                    case 'c':
                        $f = 'context';
                        break;
                    case 'lr':
                        $f = 'last_run';
                        break;
                    case 'la':
                        $f = 'last_aborted';
                        break;
                    case 'ac':
                        $f = 'abort_count';
                        break;
                    case 'laf':
                        $f = 'last_abort_function';
                        break;
                    case 'let':
                        $f = 'last_execution_time';
                        break;
                    case 'ec':
                        $f = 'execution_count';
                        break;
                    case 'aet':
                        $f = 'avg_execution_time';
                        break;
                    case 'met':
                        $f = 'max_execution_time';
                        break;
                    case 'lst':
                        $f = 'last_shutdown_time';
                        break;
                }
                $data[$name][$f] = unserialize($v->value);
                $todelete[] = $v->name;
            }
        }
        $ifields = array('disabled', 'weight', 'running', 'last_run', 'last_aborted', 'abort_count', 'last_execution_time', 'execution_count', 'avg_execution_time', 'max_execution_time', 'last_shutdown_time');
        foreach ($data as $v) {
            foreach ($ifields as $f) {
                if (empty($v[$f])) {
                    $v[$f] = 0;
                }
            }
            db_query("insert into {elysia_cron} (name, disabled, rule, weight, context, running, last_run, last_aborted, abort_count, last_abort_function, last_execution_time, execution_count, avg_execution_time, max_execution_time, last_shutdown_time)\r\n        values ('%s', %d, '%s', %d, '%s', %d, %d, %d, %d, '%s', %d, %d, %f, %d, %d)", $v['name'], $v['disabled'], $v['rule'], $v['weight'], $v['context'], $v['running'], $v['last_run'], $v['last_aborted'], $v['abort_count'], $v['last_abort_function'], $v['last_execution_time'], $v['execution_count'], $v['avg_execution_time'], $v['max_execution_time'], $v['last_shutdown_time']);
        }
        db_query("update {elysia_cron} set context = null where context = ''");
        db_query("update {elysia_cron} set rule = null where rule = ''");
        foreach ($todelete as $v) {
            variable_del($v);
            db_query("DELETE FROM {variable} WHERE name = '%s'", $v);
        }
        variable_set('elysia_cron_version', 20100507);
        unset($GLOBALS['_ec_variables']);
    }
    // D7 VERSION FROM NOW ON...
    if ($ver < 20110323) {
        if (EC_DRUPAL_VERSION >= 7) {
            // D7
            // Must use "$v" for PHP5.3 running D6 version (detect the error even if it doesn't pass here)
            db_change_field($v = 'elysia_cron', 'weight', 'weight', array('type' => 'int', 'not null' => FALSE));
        } elseif (EC_DRUPAL_VERSION >= 6) {
            // D6
            $ret = array();
            db_change_field($ret, 'elysia_cron', 'weight', 'weight', array('type' => 'int', 'not null' => FALSE));
        } else {
            // D5
            db_query("alter table {elysia_cron} change weight weight int(11)");
        }
        variable_set('elysia_cron_version', 20110323);
    }
    if ($ver < 20111007) {
        $default_rules = variable_get('elysia_cron_default_rules', $GLOBALS['elysia_cron_default_rules']);
        if (!empty($default_rules['*/6 * * * *']) && $default_rules['*/6 * * * *'] == 'Every 6 hours') {
            unset($default_rules['*/6 * * * *']);
            $default_rules['0 */6 * * *'] = 'Every 6 hours';
            variable_set('elysia_cron_default_rules', $default_rules);
        }
        variable_set('elysia_cron_version', 20111007);
    }
    if ($ver < 20111012) {
        // I only need to rebuild variable cache, so i just set the new version
        variable_set('elysia_cron_version', 20111012);
    }
    if ($ver < 20111020) {
        if (EC_DRUPAL_VERSION >= 7) {
            // D7
            // Must use "$v" for PHP5.3 running D6 version (detect the error even if it doesn't pass here)
            db_change_field($v = 'elysia_cron', 'disabled', 'disable', array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE));
        } elseif (EC_DRUPAL_VERSION >= 6) {
            // D6
            $ret = array();
            db_change_field($ret, 'elysia_cron', 'disabled', 'disable', array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE));
        } else {
            // D5
            db_query("alter table {elysia_cron} change disabled disable tinyint(1)");
        }
        db_query("update {elysia_cron} set disable = NULL where disable = 0");
        variable_set('elysia_cron_version', 20111020);
    }
}
Esempio n. 23
0
 /**
  * This function will run post install tasks
  * when a shareaholic flag is set
  */
 public static function post_install()
 {
     if (variable_get('Installed_Module_Shareaholic', '') == 'shareaholic') {
         // delete this so we do not check again
         variable_del('Installed_Module_Shareaholic');
         // Do share counts check
         ShareaholicUtilities::share_counts_api_connectivity_check();
     }
 }
Esempio n. 24
0
/**
 * Remove any information that the module sets.
 *
 * The information that the module should remove includes:
 * - variables that the module has set using variable_set() or system_settings_form()
 * - modifications to existing tables
 *
 * The module should not remove its entry from the {system} table. Database
 * tables defined by hook_schema() will be removed automatically.
 *
 * The uninstall hook must be implemented in the module's .install file. It
 * will fire when the module gets uninstalled but before the module's database
 * tables are removed, allowing your module to query its own tables during
 * this routine.
 *
 * When hook_uninstall() is called, your module will already be disabled, so
 * its .module file will not be automatically included. If you need to call API
 * functions from your .module file in this hook, use drupal_load() to make
 * them available. (Keep this usage to a minimum, though, especially when
 * calling API functions that invoke hooks, or API functions from modules
 * listed as dependencies, since these may not be available or work as expected
 * when the module is disabled.)
 *
 * @see hook_install()
 * @see hook_schema()
 * @see hook_disable()
 * @see hook_modules_uninstalled()
 */
function hook_uninstall()
{
    variable_del('upload_file_types');
}
Esempio n. 25
0
/**
 * Respond to the deletion of taxonomy vocabularies.
 *
 * Modules implementing this hook can respond to the deletion of taxonomy
 * vocabularies from the database.
 *
 * @param $vocabulary
 *   A taxonomy vocabulary object.
 */
function hook_taxonomy_vocabulary_delete($vocabulary)
{
    if (variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE)) {
        variable_del('taxonomy_' . $vocabulary->vid . '_synonyms');
    }
}
Esempio n. 26
0
 /**
  * Then /^I should see the string in the variables table$/
  */
 public function stepIShouldSeeTheStringInTheVariablesTable()
 {
     $this->assertEquals(variable_get($this->var_key, NULL), 'hello world');
     variable_del($this->var_key);
 }
 /**
  * Test path normalization checks.
  */
 function _testPathNorms()
 {
     variable_set('securepages_switch', TRUE);
     variable_set('securepages_pages', 'user');
     // Test mixed-case path.
     $this->drupalGet('UsEr');
     $this->assertUrl('UsEr', array('https' => TRUE, 'absolute' => TRUE));
     $this->assertFieldByXPath('//form[@id="user-login" and starts-with(@action, "/")]', NULL, 'The user login form action is https.');
     // Test that a trailing slash will not force a protected form's action to
     // http. A http based 'user/' path will become 'user' when doing the
     // redirect, so best to ensure that the test gets the right conditions the
     // path should be https based.
     $this->drupalGet('user/', array('https' => TRUE, 'absolute' => TRUE));
     $this->assertUrl('user/', array('https' => TRUE, 'absolute' => TRUE));
     $this->assertFieldByXPath('//form[@id="user-login" and starts-with(@action, "/")]', NULL, 'The user login form action is https.');
     // Clean up.
     variable_del('securepages_switch');
     variable_del('securepages_pages');
 }
Esempio n. 28
0
/**
 * Remove any information that the module sets.
 *
 * The information that the module should remove includes:
 * - variables that the module has set using variable_set() or system_settings_form()
 * - tables the module has created, using drupal_uninstall_schema()
 * - modifications to existing tables
 *
 * The module should not remove its entry from the {system} table.
 *
 * The uninstall hook will fire when the module gets uninstalled.
 */
function hook_uninstall()
{
    drupal_uninstall_schema('upload');
    variable_del('upload_file_types');
}
Esempio n. 29
0
 /**
  * @AfterScenario @variables
  */
 public function afterScenarioVariableCleanUp(\Behat\Behat\Hook\Scope\AfterScenarioScope $scope)
 {
     // Clean up variables after each scenario tagged @variable.
     variable_del('commerce_kickstart_user_breadcrumbs');
 }
Esempio n. 30
0
/**
 * Installation task; import remaining languages via a batch process.
 *
 * @param $install_state
 *   An array of information about the current installation state.
 * @return
 *   The batch definition, if there are language files to import.
 */
function install_import_locales_remaining(&$install_state)
{
    include_once DRUPAL_ROOT . '/includes/locale.inc';
    // Collect files to import for this language. Skip components already covered
    // in the initial batch set.
    $install_locale = $install_state['parameters']['locale'];
    $batch = locale_batch_by_language($install_locale, NULL, variable_get('install_locale_batch_components', array()));
    // Remove temporary variable.
    variable_del('install_locale_batch_components');
    return $batch;
}