function asu_webspark_bootstrap_settings_submit($form, &$form_state) { // Set the variables, need to use this instead of theme_get_settings // because the scop of the vars is more global. if ($form_state['values']['asu_brand_header_selector'] != 'custom') { variable_set('asu_brand_header_template', $form_state['values']['asu_brand_header_selector']); } else { variable_set('asu_brand_header_template', $form_state['values']['asu_brand_header_template']); } variable_set('asu_brand_is_student', $form_state['values']['asu_brand_is_student']); variable_set('asu_brand_student_color', $form_state['values']['asu_brand_student_color']); variable_set('asu_brand_header_selector', $form_state['values']['asu_brand_header_selector']); if ($file = $form_state['values']['picture_upload']) { unset($form_state['values']['picture_upload']); $filename = file_unmanaged_copy($file->uri); $form_state['values']['default_picture'] = 1; $form_state['values']['picture_path'] = $filename; } // If the user entered a path relative to the system files directory for // a logo or favicon, store a public:// URI so the theme system can handle it. if (!empty($form_state['values']['picture_path'])) { $form_state['values']['picture_path'] = _system_theme_settings_validate_path($form_state['values']['picture_path']); } // ASU header needs a cache_clear if (module_exists('asu_brand')) { asu_brand_cache_clear(); } }
/** * Initialize theme settings if needed */ function fusion_core_initialize_theme_settings($theme_name) { $theme_settings = theme_get_settings($theme_name); if (is_null($theme_settings['theme_font_size']) || $theme_settings['rebuild_registry'] == 1) { // Rebuild theme registry & notify user if ($theme_settings['rebuild_registry'] == 1) { drupal_rebuild_theme_registry(); drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning'); } // Retrieve saved or site-wide theme settings $theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings'); $settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings(); // Skip toggle_node_info_ settings if (module_exists('node')) { foreach (node_get_types() as $type => $name) { unset($settings['toggle_node_info_' . $type]); } } // Retrieve default theme settings $defaults = fusion_core_default_theme_settings(); // Set combined default & saved theme settings variable_set($theme_setting_name, array_merge($defaults, $settings)); // Force theme settings refresh theme_get_setting('', TRUE); } }
public function submit($form, &$form_state) { variable_set('publisher_enabled', $form_state['values']['enabled']); variable_set('publisher_api_key', $form_state['values']['api_key']); variable_set('publisher_debug_mode', $form_state['values']['debug']); drupal_set_message('Publisher settings saved successfully!'); }
public static function setUpBeforeClass() { static::$cacheDir = DRUPONY_TEST_DIR . DIRECTORY_SEPARATOR . 'cacheDir'; variable_set('drupony_cachedir', static::$cacheDir); require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'drupony.module'; require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'drupony.hooks.inc'; }
public function save() { foreach ($this->saveable as $property) { $save[$property] = $this->{$property}; } variable_set('ldap_profile_conf', $save); }
/** * Verify that date fields are imported correctly. When no timezone is * explicitly provided with the source data, we want the displayed time on the * Drupal site to match that in the source data. To validate that, we make * sure we have set a consistent timezone at the PHP and Drupal levels, and * that the format used on the page is not locale-dependent (no day or month * names). Then, we can just look for the desired date/time strings in the * node page. */ function testDateImport() { date_default_timezone_set('America/Los_Angeles'); variable_set('date_default_timezone', 'America/Los_Angeles'); variable_set('date_format_medium', 'Y-m-d H:i'); $migration = Migration::getInstance('DateExample'); $result = $migration->processImport(); $this->assertEqual($result, Migration::RESULT_COMPLETED, t('Variety term import returned RESULT_COMPLETED')); $rawnodes = node_load_multiple(FALSE, array('type' => 'date_migrate_example'), TRUE); $this->assertEqual(count($rawnodes), 2, t('Two sample nodes created')); $node = reset($rawnodes); $this->drupalGet('/node/' . $node->nid); $this->assertText('2011-05-12 19:43', t('Simple date field found')); $this->assertText('2011-06-13 18:32 to 2011-07-23 10:32', t('Date range field found')); $this->assertText('2011-07-22 12:13', t('Datestamp field found')); $this->assertText('2011-08-01 00:00 to 2011-09-01 00:00', t('Datestamp range field found')); $this->assertText('2011-11-18 15:00', t('Datetime field with +9 timezone found')); $this->assertText('2011-10-30 14:43 to 2011-12-31 17:59', t('Datetime range field with -5 timezone found')); $this->assertText('2011-11-25 09:01', t('First date repeat instance found')); $this->assertText('2011-12-09 09:01', t('Second date repeat instance found')); $this->assertNoText('2011-12-23 09:01', t('Skipped date repeat instance not found')); $this->assertText('2012-05-11 09:01', t('Last date repeat instance found')); $node = next($rawnodes); $this->drupalGet('/node/' . $node->nid); $this->assertText('2012-06-21 15:32', t('First date value found')); $this->assertText('2012-12-02 11:08', t('Second date value found')); $this->assertText('2004-02-03 01:15', t('Start for first date range found')); $this->assertText('2005-03-04 22:11', t('End for first date range found')); $this->assertText('2014-09-01 17:21', t('Start for second date range found')); $this->assertText('2015-12-23 00:01', t('End for first second range found')); }
function _scratchpadify_install_configure_form_submit($form, &$form_state) { global $user; variable_set('site_name', $form_state['values']['site_name']); variable_set('site_mail', $form_state['values']['site_mail']); variable_set('date_default_timezone', $form_state['values']['date_default_timezone']); // Enable update.module if this option was selected. if ($form_state['values']['update_status_module'][1]) { // Stop enabling the update module, it's a right royal pain in the arse. //drupal_install_modules(array('update')); } // Turn this off temporarily so that we can pass a password through. variable_set('user_email_verification', FALSE); $form_state['old_values'] = $form_state['values']; $form_state['values'] = $form_state['values']['account']; // We precreated user 1 with placeholder values. Let's save the real values. $account = user_load(1); $merge_data = array('init' => $form_state['values']['mail'], 'roles' => array(), 'status' => 0); user_save($account, array_merge($form_state['values'], $merge_data)); // Log in the first user. user_authenticate($form_state['values']); $form_state['values'] = $form_state['old_values']; unset($form_state['old_values']); variable_set('user_email_verification', TRUE); if (isset($form_state['values']['clean_url'])) { variable_set('clean_url', $form_state['values']['clean_url']); } // The user is now logged in, but has no session ID yet, which // would be required later in the request, so remember it. $user->sid = session_id(); // Record when this install ran. variable_set('install_time', time()); }
/** * Test enumeration of anonymous and authenticated keys. */ public function testKeyEnumKeys() { global $base_root; variable_set('authcache_roles', array()); $expect = array($base_root); $result = authcache_enum_keys(); $this->assertEqual($expect, $result); drupal_static_reset(); // Test anonymous and authenticated roles. variable_set('authcache_roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID)); $result = authcache_enum_keys(); $anonymous_key = array_pop($result); $this->assertEqual($base_root, $anonymous_key); // Expect 1 additional key for authenticated users. $this->assertEqual(1, count($result)); drupal_static_reset(); // Test additional roles. $rid1 = $this->drupalCreateRole(array()); $rid2 = $this->drupalCreateRole(array()); variable_set('authcache_roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID, $rid1 => $rid1, $rid2 => $rid2)); $result = authcache_enum_keys(); $anonymous_key = array_pop($result); $this->assertEqual($base_root, $anonymous_key); // Expect 4 keys for authenticated users: // * Only authenticated rid // * Only rid1 // * Only rid2 // * rid1 and rid2 $this->assertEqual(4, count($result)); }
function drupalexp_form_system_theme_settings_submit(&$form, &$form_state) { unset($_SESSION['drupalexp_default_preset']); unset($_SESSION['drupalexp_default_direction']); unset($_SESSION['drupalexp_layout']); variable_set('drupalexp_settings_updated', REQUEST_TIME); }
function csa_base_get_default_settings($theme) { // Get node types $node_types = node_get_types('names'); // The default values for the theme variables. Make sure $defaults exactly // matches the $defaults in the theme-settings.php file. $defaults = array('csa_base_move_sidebar' => 1, 'breadcrumb_display' => 0, 'breadcrumb_display_admin' => 1, 'breadcrumb_with_title' => 1, 'primary_links_display_style' => 'tabbed-menu', 'primary_links_allow_tree' => 0, 'secondary_links_display_style' => 'menu', 'secondary_links_allow_tree' => 0, 'search_snippet' => 1, 'search_info_type' => 1, 'search_info_user' => 1, 'search_info_date' => 1, 'search_info_comment' => 1, 'search_info_upload' => 1, 'mission_statement_pages' => 'home', 'hide_front_page_title' => 1, 'front_page_title_display' => 'title_slogan', 'page_title_display_custom' => '', 'other_page_title_display' => 'ptitle_slogan', 'other_page_title_display_custom' => '', 'configurable_separator' => ' | ', 'meta_keywords' => '', 'meta_description' => '', 'taxonomy_display_default' => 'only', 'taxonomy_display_vocab_name' => 1, 'taxonomy_format_default' => 'vocab', 'taxonomy_format_links' => 0, 'taxonomy_format_delimiter' => ', ', 'taxonomy_enable_content_type' => 0, 'submitted_by_author_default' => 0, 'submitted_by_date_default' => 0, 'submitted_by_enable_content_type' => 0); // Make the default content-type settings the same as the default theme settings, // so we can tell if content-type-specific settings have been altered. $defaults = array_merge($defaults, theme_get_settings()); // Set the default values for content-type-specific settings foreach ($node_types as $type => $name) { $defaults["taxonomy_display_{$type}"] = $defaults['taxonomy_display_default']; $defaults["taxonomy_format_{$type}"] = $defaults['taxonomy_format_default']; $defaults["submitted_by_author_{$type}"] = $defaults['submitted_by_author_default']; $defaults["submitted_by_date_{$type}"] = $defaults['submitted_by_date_default']; } // Get default theme settings. $settings = theme_get_settings($theme); // Don't save the toggle_node_info_ variables if (module_exists('node')) { foreach (node_get_types() as $type => $name) { unset($settings['toggle_node_info_' . $type]); } } // Save default theme settings variable_set(str_replace('/', '_', 'theme_' . $theme . '_settings'), array_merge($defaults, $settings)); // Force refresh of Drupal internals theme_get_setting('', TRUE); return $defaults; }
/** * Check the enabled Garland blocks are correctly copied over. */ function testNewDefaultThemeBlocks() { // Create administrative user. $adminuser = $this->drupalCreateUser(array('administer themes')); $this->drupalLogin($adminuser); // Ensure no other theme's blocks are in the block table yet. $count = db_query_range("SELECT 1 FROM {block} WHERE theme NOT IN ('garland', 'seven')", 0, 1)->fetchField(); $this->assertFalse($count, t('Only Garland and Seven have blocks.')); // Populate list of all blocks for matching against new theme. $blocks = array(); $result = db_query("SELECT * FROM {block} WHERE theme = 'garland'"); foreach ($result as $block) { // $block->theme and $block->bid will not match, so remove them. unset($block->theme, $block->bid); $blocks[$block->module][$block->delta] = $block; } // Turn on the Stark theme and ensure that it contains all of the blocks // that Garland did. theme_enable(array('stark')); variable_set('theme_default', 'stark'); $result = db_query("SELECT * FROM {block} WHERE theme='stark'"); foreach ($result as $block) { unset($block->theme, $block->bid); $this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block %name matched', array('%name' => $block->module . '-' . $block->delta))); } }
/** * Apply default NextEuropa configuration to a specific content type. * * This method is usually called into hook_install(). * * @param string $type * Content type machine name. * * @see nexteuropa_pages_install() */ public function applyDefaultConfigurationToContentType($type) { // Replace title field. multisite_config_service('title')->replaceTitleField('node', $type, 'title'); multisite_config_service('entity_translation')->enableEntityTranslation($type); // Add Organic Group fields. multisite_config_service('og')->createOgGroupAudienceField('node', $type); multisite_config_service('og')->createOgContentAccessField('node', $type); // Enable Workbench Moderation. multisite_config_service('workbench_moderation')->enableWorkbenchModeration($type); // Grant OG permissions if NextEuropa Editorial feature is enabled. if (module_exists('nexteuropa_editorial')) { $og_permissions = array(); $og_permissions['contributor'] = array('create ' . $type . ' content', 'update own ' . $type . ' content', 'delete own ' . $type . ' content'); $og_permissions['validator'] = $og_permissions['publisher'] = $og_permissions['administrator member'] = array('create ' . $type . ' content', 'update own ' . $type . ' content', 'delete own ' . $type . ' content', 'update any ' . $type . ' content', 'delete any ' . $type . ' content'); foreach ($og_permissions as $role => $permissions) { multisite_config_service('og')->grantOgPermissions($role, $permissions, 'node', 'editorial_team', 'og'); } } // Enable Linkchecker control for "Page" content type. multisite_config_service('linkchecker')->enableLinkcheckerForContentType($type); // Enable default scheduling options for a specific content type. multisite_config_service('scheduler')->enableSchedulerForContentType($type); // Set unpublish moderation state to "expired". // This call cannot be included in the API method above since it is // a configuration specific to NextEuropa . variable_set('scheduler_unpublish_moderation_state_' . $type, 'expired'); }
/** * Act on taxonomy vocabularies when updated. * * Modules implementing this hook can act on the vocabulary object when updated. * * @param $vocabulary * A taxonomy vocabulary object. */ function hook_taxonomy_vocabulary_update($vocabulary) { $status = $vocabulary->synonyms ? TRUE : FALSE; if ($vocabulary->synonyms) { variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', $status); } }
/** * Respond to a custom menu deletion. * * This hook is used to notify modules that a custom menu along with all links * contained in it (if any) has been deleted. Contributed modules may use the * information to perform actions based on the information entered into the menu * system. * * @param $menu * An array representing a custom menu: * - menu_name: The unique name of the custom menu. * - title: The human readable menu title. * - description: The custom menu description. * * @see hook_menu_insert() * @see hook_menu_update() */ function hook_menu_delete($menu) { // Delete the record from our variable. $my_menus = variable_get('my_module_menus', array()); unset($my_menus[$menu['menu_name']]); variable_set('my_module_menus', $my_menus); }
function _validate_page_width($width) { global $theme_key; /* * The default values for the theme variables. Make sure $defaults exactly * matches the $defaults in the theme-settings.php file. */ $defaults = array('pixture_width' => '85%'); // check if it is liquid (%) or fixed width (px) if (preg_match("/(\\d+)\\s*%/", $width, $match)) { $liquid = 1; $num = intval($match[0]); if (50 <= $num && $num <= 100) { return $num . "%"; // OK! } } else { if (preg_match("/(\\d+)\\s*px/", $width, $match)) { $fixed = 1; $num = intval($match[0]); if (800 <= $num && $num < 1600) { return $num . "px"; // OK } } } // reset to default value variable_set(str_replace('/', '_', 'theme_' . $theme_key . '_settings'), array_merge($defaults, theme_get_settings($theme_key))); // Force refresh of Drupal internals theme_get_setting('', TRUE); return $defaults['pixture_width']; }
/** * Initialize theme settings if needed */ function fusion_core_initialize_theme_settings($theme_name) { $theme_settings = theme_get_settings($theme_name); if (!isset($theme_settings['primary_menu_dropdown']) || $theme_settings['rebuild_registry'] == 1) { static $registry_rebuilt = false; // avoid multiple rebuilds per page // Rebuild theme registry & notify user if (isset($theme_settings['rebuild_registry']) && $theme_settings['rebuild_registry'] == 1 && !$registry_rebuilt) { drupal_rebuild_theme_registry(); drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning'); $registry_rebuilt = true; } // Retrieve saved or site-wide theme settings $theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings'); $settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings(); // Skip toggle_node_info_ settings if (module_exists('node')) { foreach (node_get_types() as $type => $name) { unset($settings['toggle_node_info_' . $type]); } } // Combine default theme settings from .info file & theme-settings.php $theme_data = list_themes(); // get theme data for all themes $info_theme_settings = $theme_name ? $theme_data[$theme_name]->info['settings'] : array(); $defaults = array_merge(fusion_core_default_theme_settings(), $info_theme_settings); // Set combined default & saved theme settings variable_set($theme_setting_name, array_merge($defaults, $settings)); // Force theme settings refresh theme_get_setting('', TRUE); } }
/** * Preprocess Page */ function superhero_preprocess_page(&$vars) { $theme = superhero_get_theme(); $theme->page =& $vars; $vars['attributes_array']['class'] = array('body'); // Primary nav $vars['primary_nav'] = FALSE; if ($vars['main_menu']) { // Build links $vars['primary_nav'] = menu_tree(variable_get('menu_main_links_source', 'main-menu')); // Provide default theme wrapper function $vars['primary_nav']['#theme_wrappers'] = array('menu_tree__primary'); } $default_preset = $theme->settings['default_preset']; $force = false; $superhero_base_url = variable_get('superhero_base_url', ''); global $base_url; if ($superhero_base_url != $base_url) { $force = true; } variable_set('superhero_base_url', $base_url); require_once dirname(__FILE__) . '/includes/superhero_scss.php'; $scss = new Superhero_scss($theme); if (!file_exists('public://css')) { drupal_mkdir('public://css'); } $file = $scss->outputFile('public://css/' . $theme->theme . '-theme-preset' . ($default_preset + 1) . '.css', $force); drupal_add_css($file, array('type' => 'file', 'group' => CSS_THEME)); }
/** * Sets up a project and a files branch using API function calls. * * @param $prefix * Directory prefix to prepend on the data directories. * @param $default * TRUE to set this as the default branch; FALSE to not set it as default. * @param $info * Array of information to override the defaults (see function code to see * what they are). Note that $prefix is applied after this information is * read, and that only one directory and one excluded are supported in this * function. * * @return * Array of information (defaults with overrides) used to create the * branch and project. */ function setUpBranchAPICall($prefix = '', $default = TRUE, $info = array()) { // Set up defaults. $info += array('project' => 'test', 'project_title' => 'Project 6', 'project_type' => 'module', 'branch_name' => '6', 'title' => 'Testing 6', 'core_compatibility' => '7.x', 'update_frequency' => 1, 'directory' => drupal_get_path('module', 'api') . '/tests/sample', 'excluded' => drupal_get_path('module', 'api') . '/tests/sample/to_exclude', 'regexps' => ''); $info['preferred'] = $default ? 1 : 0; // Create the project. $project = new stdClass(); $project->project_type = $info['project_type']; $project->project_name = $info['project']; $project->project_title = $info['project_title']; api_save_project($project); if ($default) { // Make this the default project/compatibility. variable_set('api_default_project', $info['project']); variable_set('api_default_core_compatibility', $info['core_compatibility']); } // Create the branch. $branch = new stdClass(); $branch->project = $info['project']; $branch->branch_name = $info['branch_name']; $branch->title = $info['title']; $branch->preferred = $info['preferred']; $branch->core_compatibility = $info['core_compatibility']; $branch->update_frequency = $info['update_frequency']; $branch->data = array('directories' => $prefix . $info['directory'], 'excluded_directories' => $prefix . $info['excluded'], 'exclude_files_regexp' => $info['regexps']); api_save_branch($branch); if ($default) { $this->assertEqual(variable_get('api_default_branch', 99), $branch->branch_id, 'Variable for default branch is set correctly'); } return $info; }
/** * Method for defining a key's value in the caching mechanism. * * @param string $key * The unique name of the value to be stored. If not unique, the existing * value will be replaced. * @param mixed $value * The serializable value to be stored under the $key provided. * * @return NULL * Returns after corresponding set functionality finishes. */ public function vset($key, $value) { if ($this->memcacheExists) { $this->mem->set($key, $value); return; } variable_set($key, $value); }
/** * Respond to image style deletion. * * This hook enables modules to update settings when a image style is being * deleted. If a style is deleted, a replacement name may be specified in * $style['name'] and the style being deleted will be specified in * $style['old_name']. * * @param $style * The image style array that being deleted. */ function hook_image_style_delete($style) { // Administrators can choose an optional replacement style when deleting. // Update the modules style variable accordingly. if (isset($style['old_name']) && $style['old_name'] == variable_get('mymodule_image_style', '')) { variable_set('mymodule_image_style', $style['name']); } }
/** * Returns the next available member id. */ public function next($membership) { $settings = $this->settings; $length = !empty($settings['length']) ? $settings['length'] : 5; $member_id = variable_get('membership_entity_next_member_id', 0); variable_set('membership_entity_next_member_id', ++$member_id); return str_pad($member_id, $length, '0', STR_PAD_LEFT); }
public function save() { foreach ($this->saveable as $property) { $save[$property] = $this->{$property}; } variable_set('ldap_user_conf', $save); ldap_user_conf_cache_clear(); }
/** * Form submission handler for ec_resp_form_system_theme_settings_alter(). */ function ec_resp_theme_settings_submit($form, &$form_state) { // The 'easy_breadcrumb-segments_separator' variable is used by // easy-breadcrumb module, to construct link separators. // For interinstituional template, we replace it by an image. $separator = $form_state['values']['enable_interinstitutional_theme'] == 0 ? '>' : ' '; variable_set('easy_breadcrumb-segments_separator', $separator); }
function acquia_prosper_preprocess(&$vars) { if (!function_exists('fusion_core_add_block')) { drupal_set_message(t('Error! <a href="!link">Fusion Core</a> base theme not found. Please install and enable Fusion Core first.', array('!link' => 'http://drupal.org/project/fusion')), 'error', false); variable_set('theme_default', 'garland'); $vars['is_admin'] ? drupal_goto('admin/build/themes') : drupal_goto(''); } }
/** * @todo. */ public function setUp() { parent::setUp(); // Create and log in our privileged user. $this->privileged_user = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'bypass node access', 'administer date tools')); $this->drupalLogin($this->privileged_user); variable_set('date_format_long', 'D, m/d/Y - H:i'); }
function variable_move($old, $new) { $val = variable_get($old, NULL); if (!is_null($value)) { variable_set($new, $val); variable_del($old); } }
public function flushMailSystem() { if ($this->maillog) { db_query("TRUNCATE {maillog}"); } else { variable_set('drupal_test_email_collector', array()); } }
/** * Renew the cache prefix, save it, and notify all observers. */ function renewCachePrefix() { $this->prefix = Util::randomString(); variable_set('xautoload_cache_prefix', $this->prefix); foreach ($this->observers as $observer) { $observer->setCachePrefix($this->prefix); } }
function configure_chosen() { drush_log('Configuring chosen', 'ok'); variable_set('chosen_minimum_multiple', '26'); variable_set('chosen_minimum_single', '99'); variable_set('chosen_disable_search_threshold', '32'); variable_set('chosen_minimum_width', '300'); }
public function setPlanType($type = 'unknown') { variable_set('lingotek_account_plan_type', $type); $standard_types = array('cosmopolitan_monthly', 'cosmopolitan_yearly'); // if in this list, then set to 'standard' $type = in_array($type, $standard_types) ? 'standard' : $type; $this->planType = $type; }