/** * Implements setUp(). */ function setUp($modules = array()) { if (!isset($this->time)) { $this->time = time(); } $this->timeLimit = 1000; parent::setUp(); if (!module_exists('forum_access')) { module_enable(array('acl', 'chain_menu_access', 'forum_access'), FALSE); } $this->assertTrue(module_exists('acl'), t('Module %module enabled!', array('%module' => 'acl')), 'Setup'); $this->assertTrue(module_exists('chain_menu_access'), t('Module %module enabled!', array('%module' => 'chain_menu_access')), 'Setup'); $this->assertTrue(module_exists('forum_access'), t('Module %module enabled!', array('%module' => 'forum_access')), 'Setup'); $modules = array('devel', 'devel_node_access') + $modules; $files = system_rebuild_module_data(); $available_modules = array(); foreach ($modules as $module) { if (!empty($files[$module]) && !module_exists($module)) { $available_modules[] = $module; } } if (!empty($available_modules)) { module_enable($available_modules); } parent::resetAll(); $this->accesses = array('view', 'create', 'update', 'delete'); }
/** * Test that the links are added to the page (no JS testing). */ function testPermissions() { module_enable(array('contact')); $this->resetAll(); // Anonymous users should not see the menu. $this->drupalGet(''); $this->assertNoElementByXPath('//div[@id="admin-menu"]', array(), t('Administration menu not found.')); // Create a user who // - can access content overview // - cannot access drupal.org links // - cannot administer Contact module $permissions = $this->basePermissions + array('access content overview'); $admin_user = $this->drupalCreateUser($permissions); $this->drupalLogin($admin_user); // Check that the user can see the admin links, but not the drupal links. $this->assertElementByXPath('//div[@id="admin-menu"]', array(), 'Administration menu found.'); $this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/content'), 'Content link found.'); $this->assertNoElementByXPath('//div[@id="admin-menu"]//a[@href=:path]', array(':path' => 'http://drupal.org'), 'Icon » Drupal.org link not found.'); $this->assertNoElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/contact'), 'Structure » Contact link not found.'); // Create a user "reversed" to the above; i.e., who // - cannot access content overview // - can access drupal.org links // - can administer Contact module $permissions = $this->basePermissions + array('display drupal links', 'administer contact forms'); $admin_user2 = $this->drupalCreateUser($permissions); $this->drupalLogin($admin_user2); $this->assertElementByXPath('//div[@id="admin-menu"]', array(), 'Administration menu found.'); $this->assertNoElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/content'), 'Content link not found.'); $this->assertElementByXPath('//div[@id="admin-menu"]//a[@href=:path]', array(':path' => 'http://drupal.org'), 'Icon » Drupal.org link found.'); $this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/contact'), 'Structure » Contact link found.'); }
/** * @BeforeFeature */ public static function setupFeature(BeforeFeatureScope $scope) { $feature = $scope->getFeature(); if ($feature->getTitle() == 'Dkan Harvest') { module_enable(array('dkan_harvest_test')); } }
/** * @param array $cache_types * The autoloader modes that are enabled, e.g. * array('apc' => 'apc', 'xcache' => 'xcache') * @param bool $cache_lazy * Whether the "lazy" mode is enabled. */ protected function xautoloadTestWithCacheTypes($cache_types, $cache_lazy) { // @FIXME // // @FIXME // // The correct configuration object could not be determined. You'll need to // // rewrite this call manually. // variable_set(XAUTOLOAD_VARNAME_CACHE_TYPES, $cache_types); $this->pass("Set cache types: " . var_export($cache_types, TRUE)); // @FIXME // // @FIXME // // The correct configuration object could not be determined. You'll need to // // rewrite this call manually. // variable_set(XAUTOLOAD_VARNAME_CACHE_LAZY, $cache_lazy); $this->pass("Set cache lazy mode: " . var_export($cache_lazy, TRUE)); // Enable xautoload. module_enable(array('xautoload'), FALSE); // At this time the xautoload_cache_mode setting is not in effect yet, // so we have to clear old cached values from APC cache. xautoload()->cacheManager->renewCachePrefix(); module_enable(array('xautoload_test_1', 'xautoload_test_2', 'xautoload_test_3', 'xautoload_test_4', 'xautoload_test_5'), FALSE); menu_rebuild(); foreach (array('xautoload_test_1' => array('Drupal\\xautoload_test_1\\ExampleClass'), 'xautoload_test_2' => array('xautoload_test_2_ExampleClass'), 'xautoload_test_3' => array('Drupal\\xautoload_test_3\\ExampleClass')) as $module => $classes) { $classes_on_include = in_array($module, array('xautoload_test_2', 'xautoload_test_3')); $this->xautoloadModuleEnabled($module, $classes, $classes_on_include); $this->xautoloadModuleCheckJson($module, $cache_types, $cache_lazy, $classes); } }
/** * Test successful execution of hook_requirements() during install/enable. * * Function module_enable() does not check requirements, unlike normal * enabling, so we need to invoke the hook manually to simulate it. */ public function testEnable() { module_load_install(static::MODULE); module_invoke(static::MODULE, 'requirements', 'install'); module_enable([static::MODULE], FALSE); $this->pass('Successfully enabled mongodb.module.'); }
/** * implements hook_sanmateo_is_master_set * * PARAM is_master: a bool that states if this is the master site * * THis is called when ever this site is set as master or not master * It can be used when other items need to be udpated */ function hook_sanmateo_is_master_set($is_master) { if ($is_master) { module_enable(array('openid_provider')); } else { module_disable(array('openid_provider')); } }
function prepTestData() { $servers = array(); $variables = array(); $authentication = array(); $authorization = array(); $this->testFunctions = new LdapTestFunctions(); if ($this->useFeatureData) { module_enable(array('ctools'), TRUE); module_enable(array('strongarm'), TRUE); module_enable(array('features'), TRUE); module_enable(array($this->featureName), TRUE); // will need to set non exportables such as bind password also // also need to create fake ldap server data. use if (!(module_exists('ctools') && module_exists('strongarm') && module_exists('features') && module_exists('$this->featureName'))) { drupal_set_message(t('Features and Strongarm modules must be available to use Features as configuratio of simpletests'), 'warning'); } // with test data stored in features, need to get server properties from ldap_server properties require_once drupal_get_path('module', $this->featureName) . '/' . $this->featureName . '.ldap_servers.inc'; require_once drupal_get_path('module', $this->featureName) . '/fake_ldap_server_data.inc'; $function_name = $this->featureName . '_default_ldap_servers'; $servers = call_user_func($function_name); foreach ($servers as $sid => $server) { $this->testData['servers'][$sid]['properties'] = (array) $server; // convert to array $this->testData['servers'][$sid]['properties']['inDatabase'] = TRUE; $this->testData['servers'][$sid]['properties']['bindpw'] = 'goodpwd'; $this->testData['servers'][$sid] = array_merge($this->testData['servers'][$sid], $fake_ldap_server_data[$sid]); } // make included fake sid match feature sid $this->testFunctions->prepTestConfiguration($this->testData, TRUE); } else { include drupal_get_path('module', 'ldap_authorization') . '/tests/' . $this->authorizationData; $this->testData['authorization'] = $authorization; include drupal_get_path('module', 'ldap_authorization') . '/tests/' . $this->authenticationData; $this->testData['authentication'] = $authentication; include drupal_get_path('module', 'ldap_authorization') . '/tests/' . $this->serversData; $this->testData['servers'] = $servers; $this->testData['variables'] = $variables; // if only one server, set as default in authentication and authorization if (count($this->testData['servers']) == 1) { $sids = array_keys($servers); $this->sid = $sids[0]; foreach ($this->testData['authorization'] as $consumer_type => $consumer_conf) { $this->testData['authorization'][$consumer_type]['consumerType'] = $consumer_type; $this->testData['authorization'][$consumer_type]['sid'] = $this->sid; } $this->testData['authentication']['sids'] = array($this->sid => $this->sid); $this->testData['servers'][$this->sid]['sid'] = $this->sid; } $this->testFunctions->prepTestConfiguration($this->testData, FALSE); } }
/** * @BeforeFeature @enableDKAN_Workflow */ public static function enableDKAN_Workflow(BeforeFeatureScope $scope) { if (!parent::shouldEnableModule("dkan_workflow")) { return; } // This order matters through drupal_flush_all_caches. module_enable(array('link_badges', 'menu_badges', 'views_dkan_workflow_tree', 'workbench', 'workbench_moderation', 'workbench_email')); // Enable 'open_data_federal_extras' module. module_enable(array('dkan_workflow_permissions')); module_enable(array('dkan_workflow')); features_revert(array('dkan_workflow_permissions' => array('roles_permissions'))); drupal_flush_all_caches(); }
/** * React to an environment state change. * * Use this hook to specify changes to your site configuration depending on * what kind of environment the site is operating in. For example, production * environments should not have developer/site-builder oriented modules enabled, * such as administrative UI modules. * * When defining your state change actions, be careful to account for a given * state always consisting of the same behaviors and configuration, regardless * of how it returns to that state (which previous environment it was in.) Be * careful that you do not *disable* any modules in one environment that * implement a necessary instance of hook_environment_switch(). * * @param $target_env * The name of the environment being activated. * @param $current_env * The name of the environment being deactivated. * @param $workflow * The name of the environment workflow whose current state is being switched. * A "NULL" workflow is the default/generic/unspecified workflow for the site. * * @return * String summarizing changes made for drush user. */ function hook_environment_switch($target_env, $current_env, $workflow = NULL) { // Declare each optional development-related module $devel_modules = array('devel', 'devel_generate', 'devel_node_access'); switch ($target_env) { case 'production': module_disable($devel_modules); drupal_set_message('Disabled development modules'); return; case 'development': module_enable($devel_modules); drupal_set_message('Enabled development modules'); return; } }
/** * Test successful execution of hook_uninstall() with Mongodb disabled. * * This cannot be checked by API calls, because the missing functions will * still be loaded in PHP, hence the need to use the UI to trigger page * reloads. */ public function testUninstall() { module_enable([static::DRIVER, static::MODULE]); $this->pass('Successfully enabled driver and watchdog.module.'); module_disable([static::MODULE, static::DRIVER]); $admin = $this->drupalCreateUser(['administer modules']); $this->drupalLogin($admin); $modules = ['uninstall[mongodb_watchdog]' => 1]; $this->drupalPost('admin/modules/uninstall', $modules, t('Uninstall')); $this->assertResponse(200, 'Module uninstall form succeeded'); $this->drupalPost(NULL, [], t('Uninstall')); // Broken core : this should NOT be a 200, but actually is. // $this->assertResponse(200, 'Module uninstall confirmation succeeded'); $this->assertText(t('The selected modules have been uninstalled.'), 'Module uninstall confirmation succeeded.'); $this->pass('Successfully uninstalled watchdog module.'); }
/** * Enable modules if disabled. * * @param array $modules * An array of modules */ function enable_modules_if_needed($modules) { foreach ($modules as $module) { // Check if modules are disabled. $result = db_select('system', 's')->fields('s', array('status'))->condition('name', $module, '=')->condition('status', 0, '=')->execute(); if ($result->fetchAssoc()) { // Create an array of modules to enable. $to_enable[] = $module; } } if ($to_enable) { module_enable($to_enable); echo "Enabled new modules"; } else { echo "No new modules to enable"; } }
/** * @param array $cache_types * The autoloader modes that are enabled, e.g. * array('apc' => 'apc', 'xcache' => 'xcache') * @param bool $cache_lazy * Whether the "lazy" mode is enabled. */ protected function xautoloadTestWithCacheTypes($cache_types, $cache_lazy) { variable_set('xautoload_cache_types', $cache_types); $this->pass("Set cache types: " . var_export($cache_types, TRUE)); variable_set('xautoload_cache_lazy', $cache_lazy); $this->pass("Set cache lazy mode: " . var_export($cache_lazy, TRUE)); // Enable xautoload. module_enable(array('xautoload'), FALSE); // At this time the xautoload_cache_mode setting is not in effect yet, // so we have to clear old cached values from APC cache. xautoload()->cacheManager->renewCachePrefix(); module_enable(array('xautoload_test_1', 'xautoload_test_2', 'xautoload_test_3'), FALSE); menu_rebuild(); foreach (array('xautoload_test_1' => array('Drupal\\xautoload_test_1\\ExampleClass'), 'xautoload_test_2' => array('xautoload_test_2_ExampleClass'), 'xautoload_test_3' => array('Drupal\\xautoload_test_3\\ExampleClass')) as $module => $classes) { $classes_on_include = in_array($module, array('xautoload_test_2', 'xautoload_test_3')); $this->xautoloadModuleEnabled($module, $classes, $classes_on_include); $this->xautoloadModuleCheckJson($module, $cache_types, $cache_lazy, $classes); } }
/** * Enables given module(s) at given location by symlinking their contents * * @param string $loc the location the module(s) can be found * @param array|string|null $name the name(s) of the module(s). Defaults to basename($loc). * * @throws \InvalidArgumentException */ public static function enableModule($loc, $name = null) { $loc = rtrim($loc, '/'); if (!is_dir($loc) || !is_readable($loc)) { throw new \InvalidArgumentException(sprintf('Unable to read directory %s', $loc)); } $base = basename($loc); $link = DRUPAL_ROOT . "/sites/all/modules/{$base}"; if (file_exists($link) && readlink($link)) { unlink($link); } symlink($loc, $link); drupal_static('system_rebuild_module_data', null, true); $modules = (array) ($name ?: $base); $enabled = module_enable($modules); if (false === $enabled) { throw new \InvalidArgumentException(sprintf('Unable to enable module(s) "%s"', implode(',', $modules))); } module_invoke_all('boot'); module_invoke_all('init'); }
public function setUp() { // For benchmarking. $this->start = time(); // Enable any modules required for the test. parent::setUp('better_exposed_filters', 'date', 'date_views', 'list', 'number', 'taxonomy', 'text', 'views', 'views_ui'); // One of these days I'll figure out why Features is breaking all my tests. module_enable(array('bef_test_content')); // User with edit views perms $this->admin_user = $this->drupalCreateUser(); $role = user_role_load_by_name('administrator'); $this->assertTrue(!empty($role->rid), 'Found the "administrator" role.'); user_save($this->admin_user, array('roles' => array($role->rid => $role->rid))); $this->drupalLogin($this->admin_user); // Build a basic view for use in tests. $this->createView(); // $this->createDisplay('Page', array('path' => array('path' => 'bef_test_page'))); // Add field to default display // $this->addField('node.title'); // Turn of Better Exposed Filters $this->setBefExposedForm(); }
/** * Initialize auto-inc values on dev site. Run this function only once, at setup. */ function __init() { // Bring config vars into function namespace extract(__config()); // Enable profile module drush_print("Installing profile module."); if (drush_drupal_major_version() < 7) { include_once 'includes/install.inc'; drupal_install_modules(array('profile')); } else { module_enable(array('profile')); } // Set auto-increment values $tables = array('authmap', 'comments', 'files', 'node', 'node_revisions', 'profile_fields', 'role', 'term_data', 'url_alias', 'users', 'vocabulary'); foreach ($tables as $table) { $value = ${$table}; db_query("ALTER TABLE `{$table}` AUTO_INCREMENT = %d", $value); drush_print("Set auto-increment value for {$table} to {$value}"); } unset($value); drush_print("Initialization done!"); }
/** * Implements AcsfEventHandler::handle(). */ public function handle() { drush_print(dt('Entered @class', array('@class' => get_class($this)))); // Enable any modules that are currently disabled, but were once enabled, so // that their data cleanup hooks (e.g. hook_user_delete) and functions // (e.g. search_reindex) can be invoked. // // Note: These modules will all be uninstalled. Uninstalling them should // really take care of all the cleanup these modules should be doing. But // enable them here for good measure just incase there's some cleanup // depending on these hooks. require_once DRUPAL_ROOT . '/includes/install.inc'; $modules = system_rebuild_module_data(); $enable_for_scrub = array(); foreach ($modules as $module) { // Disabled modules with schema_version > -1 have not been uninstalled. if (empty($module->status) && $module->schema_version > SCHEMA_UNINSTALLED) { $enable_for_scrub[] = $module->name; } } // Get a list of disabled dependencies. These will get automatically enabled // during module_enable(), but we want to be able to disable and uninstall // them explicitly later. foreach ($enable_for_scrub as $dependent) { foreach (array_keys($modules[$dependent]->requires) as $dependency) { // Use isset() to make sure the module is still in the filesystem before // trying to enable it. (Historically there have been modules in Gardens // which were disabled but then removed from the codebase without ever // uninstalling them, and we don't want to try to enable those now, // because it will fail.) if (isset($modules[$dependency]) && empty($modules[$dependency]->status)) { $enable_for_scrub[] = $dependency; } } } module_enable($enable_for_scrub); acsf_vset('acsf_duplication_enable_for_scrub', $enable_for_scrub, 'acsf_duplication_scrub'); }
/** * @param $config * * @return mixed */ public 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; $registerSiteURL = "https://civicrm.org/register-site"; $commonOutputMessage = "<li>" . ts("Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a %1>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).", array(1 => "href='{$registerSiteURL}' target='_blank'")) . "</li>" . "<li>" . ts("We have integrated KCFinder with CKEditor and TinyMCE. This allows a user to upload images. All uploaded images are public.") . "</li>"; $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>' . ts('CiviCRM Installed') . '</title>'; $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; $output .= '<link rel="stylesheet" type="text/css" href="template.css" />'; $output .= '</head>'; $output .= '<body>'; $output .= '<div style="padding: 1em;"><p class="good">' . ts('CiviCRM has been successfully installed') . '</p>'; $output .= '<ul>'; $drupalURL = civicrm_cms_base(); $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/people/permissions"; $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1"; $output .= "<li>" . ts("Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$drupalPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>"; $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$drupalURL}'")) . "</li>"; $output .= $commonOutputMessage; // 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); // Force the re-initialisation of the config singleton on the next call // since so far, we had used the Config object without loading the DB. $c = CRM_Core_Config::singleton(FALSE); $c->free(); 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, page, theme, and hook caches drupal_flush_all_caches(); //add basic drupal permissions civicrm_install_set_drupal_perms(); // restore the user. $GLOBALS['user'] = $original_user; drupal_save_session(TRUE); //change the default language to one chosen if (isset($config['seedLanguage']) && $config['seedLanguage'] != 'en_US') { civicrm_api3('Setting', 'create', array('domain_id' => 'current_domain', 'lcMessages' => $config['seedLanguage'])); } $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>' . ts('CiviCRM Installed') . '</title>'; $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; $output .= '<link rel="stylesheet" type="text/css" href="template.css" />'; $output .= '</head>'; $output .= '<body>'; $output .= '<div style="padding: 1em;"><p class="good">' . ts("CiviCRM has been successfully installed") . '</p>'; $output .= '<ul>'; $drupalURL = civicrm_cms_base(); $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/user/permissions"; $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1"; $output .= "<li>" . ts("Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$drupalPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>"; $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$drupalURL}'")) . "</li>"; $output .= $commonOutputMessage; // 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); // Force the re-initialisation of the config singleton on the next call // since so far, we had used the Config object without loading the DB. $c = CRM_Core_Config::singleton(FALSE); $c->free(); 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, page, theme, and hook caches drupal_flush_all_caches(); //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>' . ts('CiviCRM Installed') . '</h1>'; echo '<div style="padding: 1em;"><p style="background-color: #0C0; border: 1px #070 solid; color: white;">' . ts("CiviCRM has been successfully installed") . '</p>'; echo '<ul>'; $cmsURL = civicrm_cms_base(); $cmsURL .= "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/configtask&reset=1"; $wpPermissionsURL = "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/access/wp-permissions&reset=1"; $output .= "<li>" . ts("WordPress user permissions have been automatically set - giving Anonymous and Subscribers access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$wpPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>"; $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$cmsURL}'")) . "</li>"; $output .= $commonOutputMessage; echo '</ul>'; echo '</div>'; $c = CRM_Core_Config::singleton(FALSE); $c->free(); $wpInstallRedirect = admin_url("?page=CiviCRM&q=civicrm&reset=1"); echo "<script>\n window.location = '{$wpInstallRedirect}';\n </script>"; } } return $this->errors; }
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; }
/** * Perform Drupal installation. */ protected function setUpInstall(array $modules, $public_files_directory, $private_files_directory, $temp_files_directory) { include_once DRUPAL_ROOT . '/includes/install.inc'; drupal_install_system(); $this->preloadRegistry(); // Set path variables. variable_set('file_public_path', $public_files_directory); variable_set('file_private_path', $private_files_directory); variable_set('file_temporary_path', $temp_files_directory); // Include the testing profile. variable_set('install_profile', $this->profile); $profile_details = install_profile_info($this->profile, 'en'); // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); // Install modules needed for this test. This could have been passed in as // either a single array argument or a variable number of string arguments. // @todo Remove this compatibility layer in Drupal 8, and only accept // $modules as a single array argument. if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } if ($modules) { module_enable($modules, TRUE); } // Run the profile tasks. $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField(); if ($install_profile_module_exists) { module_enable(array($this->profile), FALSE); } // Reset/rebuild all data structures after enabling the modules. $this->resetAll(); // Run cron once in that environment, as install.php does at the end of // the installation process. drupal_cron_run(); // Log in with a clean $user. $this->originalUser = $user; drupal_save_session(FALSE); $user = user_load(1); }
/** * Return the Indicia form code. * Expects there to be a sample attribute with caption 'Email' containing the email * address. * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { iform_load_helpers(array('data_entry_helper', 'map_helper', 'report_helper')); $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']); //Clear Verifier Tasks automatically when they open the screen if the option is set. if ($args['clear_verification_task_notifications'] && hostsite_get_user_field('indicia_user_id')) { self::clear_verifier_task_notifications($auth); } // set some defaults, applied when upgrading from a form configured on a previous form version. if (empty($args['email_subject_send_to_recorder'])) { $args['email_subject_send_to_recorder'] = 'Record of %taxon% requires confirmation (ID:%id%)'; } if (empty($args['email_body_send_to_recorder'])) { $args['email_body_send_to_recorder'] = 'The following record requires confirmation. Please could you reply to this email stating how confident you are that the record is correct ' . 'and any other information you have which may help to confirm this.' . "\n\n%record%"; } if (isset($_POST['enable'])) { module_enable(array('iform_ajaxproxy')); drupal_set_message(lang::get('The Indicia AJAX Proxy module has been enabled.', 'info')); } elseif (!defined('IFORM_AJAXPROXY_PATH')) { $r = '<p>' . lang::get('The Indicia AJAX Proxy module must be enabled to use this form. This lets the form save verifications to the ' . 'Indicia Warehouse without having to reload the page.') . '</p>'; $r .= '<form method="post">'; $r .= '<input type="hidden" name="enable" value="t"/>'; $r .= '<input type="submit" value="' . lang::get('Enable Indicia AJAX Proxy') . '"/>'; $r .= '</form>'; return $r; } if (function_exists('drupal_add_js')) { drupal_add_js('misc/collapse.js'); } // fancybox for popup comment forms etc data_entry_helper::add_resource('fancybox'); data_entry_helper::add_resource('validation'); global $user, $indicia_templates; $indicia_user_id = self::get_indicia_user_id($args); data_entry_helper::$js_read_tokens = $auth['read']; // Find a list of websites we are allowed verify $websiteIds = iform_get_allowed_website_ids($auth['read'], 'verification'); if (function_exists('module_exists') && module_exists('easy_login')) { if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_location') === false) { $args['param_presets'] .= "\nexpertise_location={profile_location_expertise}"; } if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_taxon_groups') === false) { $args['param_presets'] .= "\nexpertise_taxon_groups={profile_taxon_groups_expertise}"; } if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_surveys') === false) { $args['param_presets'] .= "\nexpertise_surveys={profile_surveys_expertise}"; } } $args['sharing'] = 'verification'; $opts = array_merge(iform_report_get_report_options($args, $auth['read']), array('id' => 'verification-grid', 'reportGroup' => 'verification', 'rowId' => 'occurrence_id', 'paramsFormButtonCaption' => lang::get('Filter'), 'paramPrefix' => '<div class="report-param">', 'paramSuffix' => '</div>', 'sharing' => 'verification', 'ajax' => TRUE, 'callback' => 'verificationGridLoaded', 'rowClass' => 'zero-{zero_abundance}')); $opts['columns'][] = array('display' => '', 'template' => '<div class="nowrap"><button class="default-button quick-verify tools-btn" type="button" id="quick-{occurrence_id}" title="Record tools">...</button>' . '<input type="hidden" class="row-input-form" value="{rootFolder}{input_form}"/><input type="hidden" class="row-belongs-to-site" value="{belongs_to_site}"/><ul class="verify-tools"><li><a href="#" class="quick-verify-tool">Bulk verify similar records</a></li>' . '<li><a href="#" class="trust-tool">Recorder\'s trust settings</a></li><li><a href="#" class="edit-record">Edit record</a></li></ul>' . '<input type="checkbox" class="check-row no-select" style="display: none" value="{occurrence_id}" /></div>'); $params = self::report_filter_panel($args, $auth['read']); $opts['zoomMapToOutput'] = false; $grid = report_helper::report_grid($opts); $r = str_replace(array('{grid}', '{paramsForm}'), array($grid, $params), self::get_template_with_map($args, $auth['read'], $opts['extraParams'], $opts['paramDefaults'])); $link = data_entry_helper::get_reload_link_parts(); global $user; data_entry_helper::$js_read_tokens = $auth['read']; data_entry_helper::$javascript .= 'indiciaData.nid = "' . $node->nid . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.username = "******"\";\n"; data_entry_helper::$javascript .= 'indiciaData.userId = "' . $indicia_user_id . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.rootUrl = "' . $link['path'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.website_id = ' . $args['website_id'] . ";\n"; data_entry_helper::$javascript .= 'indiciaData.ajaxFormPostUrl="' . iform_ajaxproxy_url($node, 'occurrence') . "&user_id={$indicia_user_id}&sharing=verification\";\n"; data_entry_helper::$javascript .= 'indiciaData.ajaxUrl="' . url('iform/ajax/verification_4') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.autoDiscard = ' . $args['auto_discard_rows'] . ";\n"; if (!empty($args['indicia_species_layer_feature_type']) && !empty(data_entry_helper::$geoserver_url)) { data_entry_helper::$javascript .= "indiciaData.indiciaSpeciesLayer = {\n" . ' "title":"' . lang::get('Online recording data for this species') . "\",\n" . ' "featureType":"' . $args['indicia_species_layer_feature_type'] . "\",\n" . ' "wmsUrl":"' . data_entry_helper::$geoserver_url . "wms\",\n" . ' "cqlFilter":"website_id IN (' . implode(',', $websiteIds) . ') AND ' . $args['indicia_species_layer_filter_field'] . "='{filterValue}'\",\n" . ' "filterField":"' . $args['indicia_species_layer_ds_filter_field'] . "\",\n" . ' "sld":"' . (isset($args['indicia_species_layer_sld']) ? $args['indicia_species_layer_sld'] : '') . "\"\n" . "};\n"; } if (!empty($args['additional_wms_species_layer_title'])) { data_entry_helper::$javascript .= 'indiciaData.wmsSpeciesLayers = [{"title":"' . $args['additional_wms_species_layer_title'] . '",' . '"url":"' . $args['additional_wms_species_layer_url'] . '",' . '"settings":' . $args['additional_wms_species_layer_settings'] . ',' . '"olSettings":' . $args['additional_wms_species_layer_ol_settings'] . "}];\n"; } // output some translations for JS to use data_entry_helper::$javascript .= "indiciaData.popupTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.title="' . lang::get('Add {1} comment') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.save="' . lang::get('Save and {1}') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbV="' . lang::get('verify') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbR="' . lang::get('reject') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbD="' . lang::get('query') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.V="' . lang::get('Verification') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.R="' . lang::get('Rejection') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.D="' . lang::get('Query') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailTitle="' . lang::get('Email record details for checking') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sendEmail="' . lang::get('Send Email') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailSent="' . lang::get('The email was sent successfully.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.requestManualEmail="' . lang::get('The webserver is not correctly configured to send emails. Please send the following email usual your email client:') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.multipleWarning="' . lang::get('You are about to verify multiple records. Please note that this comment will apply to all the ticked records. ' . 'If you did not intend to do this, please close this box and turn off the Select Records tool before proceeding.') . "\";\n"; data_entry_helper::$javascript .= "indiciaData.statusTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.V = "' . lang::get('Verified') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.R = "' . lang::get('Rejected') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.D = "' . lang::get('Query') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.I = "' . lang::get('In progress') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.T = "' . lang::get('Test record') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.S = "' . lang::get('Sent for verification') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.C = "' . lang::get('Awaiting verification') . "\";\n"; data_entry_helper::$javascript .= "indiciaData.commentTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.emailed = "' . lang::get('I emailed this record to {1} for checking.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.recorder = "' . lang::get('the recorder') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.expert = "' . lang::get('an expert') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.email_subject_send_to_verifier = "' . $args['email_subject_send_to_verifier'] . "\";\n"; $body = str_replace(array("\r", "\n"), array('', '\\n'), $args['email_body_send_to_verifier']); data_entry_helper::$javascript .= 'indiciaData.email_body_send_to_verifier = "' . $body . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.email_subject_send_to_recorder = "' . $args['email_subject_send_to_recorder'] . "\";\n"; $body = str_replace(array("\r", "\n"), array('', '\\n'), $args['email_body_send_to_recorder']); data_entry_helper::$javascript .= 'indiciaData.email_body_send_to_recorder = "' . $body . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.str_month = "' . lang::get('month') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_location = "' . $opts['extraParams']['expertise_location'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_surveys = "' . $opts['extraParams']['expertise_surveys'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_taxon_groups = "' . $opts['extraParams']['expertise_taxon_groups'] . "\";\n"; data_entry_helper::add_resource('jqplot'); data_entry_helper::add_resource('jqplot_bar'); return $r; }
/** * Generates a random database prefix, runs the install scripts on the * prefixed database and enable the specified modules. After installation * many caches are flushed and the internal browser is setup so that the * page requests will run on the new prefix. A temporary files directory * is created with the same name as the database prefix. * * @param ... * List of modules to enable for the duration of the test. This can be * either a single array or a variable number of string arguments. */ protected function setUp() { global $user, $language, $conf; // Generate a temporary prefixed database to ensure that tests have a clean starting point. $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000); db_update('simpletest_test_id')->fields(array('last_prefix' => $this->databasePrefix))->condition('test_id', $this->testId)->execute(); // Clone the current connection and replace the current prefix. $connection_info = Database::getConnectionInfo('default'); Database::renameConnection('default', 'simpletest_original_default'); foreach ($connection_info as $target => $value) { $connection_info[$target]['prefix'] = array('default' => $value['prefix']['default'] . $this->databasePrefix); } Database::addConnectionInfo('default', 'default', $connection_info['default']); // Store necessary current values before switching to prefixed database. $this->originalLanguage = $language; $this->originalLanguageDefault = variable_get('language_default'); $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); $this->originalProfile = drupal_get_profile(); $clean_url_original = variable_get('clean_url', 0); // Set to English to prevent exceptions from utf8_truncate() from t() // during install if the current language is not 'en'. // The following array/object conversion is copied from language_default(). $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''); // Save and clean shutdown callbacks array because it static cached and // will be changed by the test run. If we don't, then it will contain // callbacks from both environments. So testing environment will try // to call handlers from original environment. $callbacks =& drupal_register_shutdown_function(); $this->originalShutdownCallbacks = $callbacks; $callbacks = array(); // Create test directory ahead of installation so fatal errors and debug // information can be logged during installation process. // Use temporary files directory with the same prefix as the database. $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10); $private_files_directory = $public_files_directory . '/private'; $temp_files_directory = $private_files_directory . '/temp'; // Create the directories file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY); file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY); $this->generatedTestFiles = FALSE; // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $public_files_directory . '/error.log'); // Reset all statics and variables to perform tests in a clean environment. $conf = array(); drupal_static_reset(); // Set the test information for use in other parts of Drupal. $test_info =& $GLOBALS['drupal_test_info']; $test_info['test_run_id'] = $this->databasePrefix; $test_info['in_child_site'] = FALSE; include_once DRUPAL_ROOT . '/includes/install.inc'; drupal_install_system(); $this->preloadRegistry(); // Set path variables. variable_set('file_public_path', $public_files_directory); variable_set('file_private_path', $private_files_directory); variable_set('file_temporary_path', $temp_files_directory); // Include the testing profile. variable_set('install_profile', $this->profile); $profile_details = install_profile_info($this->profile, 'en'); // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); // Install modules needed for this test. This could have been passed in as // either a single array argument or a variable number of string arguments. // @todo Remove this compatibility layer in Drupal 8, and only accept // $modules as a single array argument. $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } if ($modules) { $success = module_enable($modules, TRUE); $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); } // Run the profile tasks. $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField(); if ($install_profile_module_exists) { module_enable(array($this->profile), FALSE); } // Reset/rebuild all data structures after enabling the modules. $this->resetAll(); // Run cron once in that environment, as install.php does at the end of // the installation process. drupal_cron_run(); // Log in with a clean $user. $this->originalUser = $user; drupal_save_session(FALSE); $user = user_load(1); // Restore necessary variables. variable_set('install_task', 'done'); variable_set('clean_url', $clean_url_original); variable_set('site_mail', '*****@*****.**'); variable_set('date_default_timezone', date_default_timezone_get()); // Set up English language. unset($GLOBALS['conf']['language_default']); $language = language_default(); // Use the test mail class instead of the default mail handler class. variable_set('mail_system', array('default-system' => 'TestingMailSystem')); drupal_set_time_limit($this->timeLimit); }
/** * Form API submit for the site configuration form. */ function 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']); variable_set('site_default_country', $form_state['values']['site_default_country']); // Enable update.module if this option was selected. if ($form_state['values']['update_status_module'][1]) { module_enable(array('update'), FALSE); // Add the site maintenance account's email address to the list of // addresses to be notified when updates are available, if selected. if ($form_state['values']['update_status_module'][2]) { variable_set('update_notify_emails', array($form_state['values']['account']['mail'])); } } // 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' => 1); user_save($account, array_merge($form_state['values'], $merge_data)); // Load global $user and perform final login tasks. $user = user_load(1); user_login_finalize(); $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']); } // Record when this install ran. variable_set('install_time', $_SERVER['REQUEST_TIME']); }
} } break; case 'install': if (!EXTERNAL_PACKAGE_MANAGEMENT) { if (is_array($errors = module_install($modulename))) { echo '<span class="error">' . sprintf(_("Error(s) installing %s"), $modulename) . ': '; echo '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'; echo '</span>'; } else { echo '<span class="success">' . sprintf(_("%s installed successfully"), $modulename) . '</span>'; } } break; case 'enable': if (is_array($errors = module_enable($modulename))) { echo '<span class="error">' . sprintf(_("Error(s) enabling %s"), $modulename) . ': '; echo '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'; echo '</span>'; } else { echo '<span class="success">' . sprintf(_("%s enabled successfully"), $modulename) . '</span>'; } break; case 'disable': if (is_array($errors = module_disable($modulename))) { echo '<span class="error">' . sprintf(_("Error(s) disabling %s"), $modulename) . ': '; echo '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>'; echo '</span>'; } else { echo '<span class="success">' . sprintf(_("%s disabled successfully"), $modulename) . '</span>'; }
protected static function check_prerequisites() { // check required modules installed if (isset($_POST['enable'])) { module_enable(array('iform_ajaxproxy')); drupal_set_message(lang::get('The Indicia AJAX Proxy module has been enabled.', 'info')); } $ok = true; if (!module_exists('iform_ajaxproxy')) { drupal_set_message('This form must be used in Drupal with the Indicia AJAX Proxy module enabled.'); $ok = false; } if (!function_exists('iform_ajaxproxy_url')) { drupal_set_message(lang::get('The Indicia AJAX Proxy module must be enabled to use this form. This lets the form save verifications to the ' . 'Indicia Warehouse without having to reload the page.')); $r .= '<form method="post">'; $r .= '<input type="hidden" name="enable" value="t"/>'; $r .= '<input type="submit" value="' . lang::get('Enable Indicia AJAX Proxy') . '">'; $r .= '</form>'; return $r; } return $ok; }
function _apim_profile_enable_module($module, $module_name, &$context) { module_enable(array($module), FALSE); $context['message'] = st('Installed %module module.', array('%module' => $module_name)); }
/** * @Then /^I enable pinserver$/ */ public function iEnablePinserver() { module_enable(array('pinserver', 'pinserver_authenticate', 'os_pinserver_auth')); }
/** * Sets up a Backdrop site for running functional and integration tests. * * Generates a random database prefix and installs Backdrop with the specified * installation profile in BackdropWebTestCase::$profile into the * prefixed database. Afterwards, installs any additional modules specified by * the test. * * After installation all caches are flushed and several configuration values * are reset to the values of the parent site executing the test, since the * default values may be incompatible with the environment in which tests are * being executed. * * @param ... * List of modules to enable for the duration of the test. This can be * either a single array or a variable number of string arguments. * * @see BackdropWebTestCase::prepareDatabasePrefix() * @see BackdropWebTestCase::changeDatabasePrefix() * @see BackdropWebTestCase::prepareEnvironment() */ protected function setUp() { global $user, $language, $conf; // Create the database prefix for this test. $this->prepareDatabasePrefix(); // Prepare the environment for running tests. $this->prepareEnvironment(); if (!$this->setupEnvironment) { return FALSE; } // Reset all statics and variables to perform tests in a clean environment. $conf = array(); backdrop_static_reset(); // Change the database prefix. // All static variables need to be reset before the database prefix is // changed, since BackdropCacheArray implementations attempt to // write back to persistent caches when they are destructed. $this->changeDatabasePrefix(); if (!$this->setupDatabasePrefix) { return FALSE; } // Preset the 'install_profile' system variable, so the first call into // system_rebuild_module_data() (in backdrop_install_system()) will register // the test's profile as a module. Without this, the installation profile of // the parent site (executing the test) is registered, and the test // profile's hook_install() and other hook implementations are never invoked. config_install_default_config('system'); config_set('system.core', 'install_profile', $this->profile); // Perform the actual Backdrop installation. include_once BACKDROP_ROOT . '/core/includes/install.inc'; backdrop_install_system(); // Set path variables. $core_config = config('system.core'); $core_config->set('file_default_scheme', 'public'); $core_config->set('file_public_path', $this->public_files_directory); $core_config->set('file_private_path', $this->private_files_directory); $core_config->set('file_temporary_path', $this->temp_files_directory); $core_config->save(); // Set 'parent_profile' of simpletest to add the parent profile's // search path to the child site's search paths. // @see backdrop_system_listing() // @todo This may need to be primed like 'install_profile' above. config_set('simpletest.settings', 'parent_profile', $this->originalProfile); // Ensure schema versions are recalculated. backdrop_static_reset('backdrop_get_schema_versions'); // Include the testing profile. config_set('system.core', 'install_profile', $this->profile); $profile_details = install_profile_info($this->profile, 'en'); // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); // Install modules needed for this test. This could have been passed in as // either a single array argument or a variable number of string arguments. // @todo Remove this compatibility layer and only accept a single array. $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } if ($modules) { $success = module_enable($modules, TRUE); $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); } // Run the profile tasks. $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField(); if ($install_profile_module_exists) { module_enable(array($this->profile), FALSE); } // Reset/rebuild all data structures after enabling the modules. $this->resetAll(); // Run cron once in that environment, as install.php does at the end of // the installation process. backdrop_cron_run(); // Ensure that the session is not written to the new environment and replace // the global $user session with uid 1 from the new test site. backdrop_save_session(FALSE); // Login as uid 1. $user = user_load(1); // Restore necessary variables. state_set('install_task', 'done'); config_set('system.core', 'clean_url', $this->originalCleanUrl); config_set('system.core', 'site_mail', '*****@*****.**'); config_set('system.date', 'date_default_timezone', date_default_timezone_get()); backdrop_static_reset('url'); // Set up English language. unset($conf['language_default']); $language = language_default(); // Use the test mail class instead of the default mail handler class. config_set('system.mail', 'default-system', 'TestingMailSystem'); backdrop_set_time_limit($this->timeLimit); $this->setup = TRUE; }
/** * Enables one or more modules. * * Provide modules data in the following format: * * | modules | * | blog | * | book | * * @param TableNode $modules_table * The table listing modules. * * @return bool * Always returns TRUE. * * @throws \Exception * Thrown when a module does not exist. * * @Given the/these module/modules is/are enabled */ public function enableModule(TableNode $modules_table) { $rebuild = FALSE; $message = array(); foreach ($modules_table->getHash() as $row) { if (!module_exists($row['modules'])) { if (!module_enable($row)) { $message[] = $row['modules']; } else { $this->modules[] = $row['modules']; $rebuild = TRUE; } } } if (!empty($message)) { throw new \Exception(sprintf('Modules "%s" not found', implode(', ', $message))); } else { if ($rebuild) { drupal_flush_all_caches(); } return TRUE; } }
/** * Batch callback for batch installation of modules. */ function _install_module_batch($module, $module_name, &$context) { _drupal_install_module($module); // We enable the installed module right away, so that the module will be // loaded by drupal_bootstrap in subsequent batch requests, and other // modules possibly depending on it can safely perform their installation // steps. module_enable(array($module)); $context['results'][] = $module; $context['message'] = st('Installed %module module.', array('%module' => $module_name)); }
/** * Generates a random database prefix, runs the install scripts on the * prefixed database and enable the specified modules. After installation * many caches are flushed and the internal browser is setup so that the * page requests will run on the new prefix. A temporary files directory * is created with the same name as the database prefix. * * @param ... * List of modules to enable for the duration of the test. */ protected function setUp() { global $db_prefix, $user, $language, $conf; // Store necessary current values before switching to prefixed database. $this->originalLanguage = $language; $this->originalLanguageDefault = variable_get('language_default'); $this->originalPrefix = $db_prefix; $this->originalFileDirectory = file_directory_path(); $this->originalProfile = drupal_get_profile(); $clean_url_original = variable_get('clean_url', 0); // Generate temporary prefixed database to ensure that tests have a clean starting point. $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}'); db_update('simpletest_test_id')->fields(array('last_prefix' => $db_prefix_new))->condition('test_id', $this->testId)->execute(); $db_prefix = $db_prefix_new; // Create test directory ahead of installation so fatal errors and debug // information can be logged during installation process. // Use temporary files directory with the same prefix as the database. $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10); $private_files_directory = $public_files_directory . '/private'; $temp_files_directory = $private_files_directory . '/temp'; // Create the directories file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY); file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY); $this->generatedTestFiles = FALSE; // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $public_files_directory . '/error.log'); // Reset all statics and variables so that test is performed with a clean // environment. $conf = array(); drupal_static_reset(); include_once DRUPAL_ROOT . '/includes/install.inc'; drupal_install_system(); $this->preloadRegistry(); // Include the default profile. variable_set('install_profile', 'standard'); $profile_details = install_profile_info('standard', 'en'); // Install the modules specified by the default profile. module_enable($profile_details['dependencies'], FALSE, TRUE); drupal_static_reset('_node_types_build'); if ($modules = func_get_args()) { // Install modules needed for this test. module_enable($modules, TRUE, TRUE); } // Because the schema is static cached, we need to flush // it between each run. If we don't, then it will contain // stale data for the previous run's database prefix and all // calls to it will fail. drupal_get_schema(NULL, TRUE); // Run default profile tasks. $install_state = array(); module_enable(array('standard'), FALSE, TRUE); // Rebuild caches. node_types_rebuild(); actions_synchronize(); _drupal_flush_css_js(); $this->refreshVariables(); $this->checkPermissions(array(), TRUE); // Log in with a clean $user. $this->originalUser = $user; drupal_save_session(FALSE); $user = user_load(1); // Restore necessary variables. variable_set('install_task', 'done'); variable_set('clean_url', $clean_url_original); variable_set('site_mail', '*****@*****.**'); // Set up English language. unset($GLOBALS['conf']['language_default']); $language = language_default(); // Set path variables variable_set('file_public_path', $public_files_directory); variable_set('file_private_path', $private_files_directory); variable_set('file_temporary_path', $temp_files_directory); // Use the test mail class instead of the default mail handler class. variable_set('mail_system', array('default-system' => 'TestingMailSystem')); drupal_set_time_limit($this->timeLimit); }