/** * Reset all data structures after having enabled new modules. * * This method is called by BackdropWebTestCase::setUp() after enabling * the requested modules. It must be called again when additional modules * are enabled later. */ protected function resetAll() { // Reset all static variables. backdrop_static_reset(); // Reset the list of enabled modules. module_list(TRUE); // Reset cached schema for new database prefix. This must be done before // backdrop_flush_all_caches() so rebuilds can make use of the schema of // modules enabled on the cURL side. backdrop_get_schema(NULL, TRUE); // Perform rebuilds and flush remaining caches. backdrop_flush_all_caches(); // Reload global $conf array and permissions. $this->refreshVariables(); $this->checkPermissions(array(), TRUE); }
/** * Form constructor for the list of available database module updates. */ function update_script_selection_form($form, &$form_state) { $count = 0; $incompatible_count = 0; $form['start'] = array('#tree' => TRUE, '#type' => 'fieldset', '#collapsed' => TRUE, '#collapsible' => TRUE); // Ensure system.module's updates appear first. $form['start']['system'] = array(); $updates = update_get_update_list(); $starting_updates = array(); $incompatible_updates_exist = FALSE; foreach ($updates as $module => $update) { if (!isset($update['start'])) { $form['start'][$module] = array('#type' => 'item', '#title' => $module . ' module', '#markup' => $update['warning'], '#prefix' => '<div class="messages warning">', '#suffix' => '</div>'); $incompatible_updates_exist = TRUE; continue; } if (!empty($update['pending'])) { $starting_updates[$module] = $update['start']; $form['start'][$module] = array('#type' => 'hidden', '#value' => $update['start']); $form['start'][$module . '_updates'] = array('#theme' => 'item_list', '#items' => $update['pending'], '#title' => $module . ' module'); } if (isset($update['pending'])) { $count = $count + count($update['pending']); } } // Find and label any incompatible updates. foreach (update_resolve_dependencies($starting_updates) as $function => $data) { if (!$data['allowed']) { $incompatible_updates_exist = TRUE; $incompatible_count++; $module_update_key = $data['module'] . '_updates'; if (isset($form['start'][$module_update_key]['#items'][$data['number']])) { $text = $data['missing_dependencies'] ? 'This update will been skipped due to the following missing dependencies: <em>' . implode(', ', $data['missing_dependencies']) . '</em>' : "This update will be skipped due to an error in the module's code."; $form['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>'; } // Move the module containing this update to the top of the list. $form['start'] = array($module_update_key => $form['start'][$module_update_key]) + $form['start']; } } // Warn the user if any updates were incompatible. if ($incompatible_updates_exist) { backdrop_set_message('Some of the pending updates cannot be applied because their dependencies were not met.', 'warning'); } if (empty($count)) { backdrop_set_message(t('No pending updates.')); unset($form); $form['links'] = array('#theme' => 'links', '#links' => update_helpful_links()); // No updates to run, so caches won't get flushed later. Clear them now. backdrop_flush_all_caches(); } else { $form['help'] = array('#markup' => '<p>Updates have been found that need to be applied. You may review the updates below before executing them.</p>', '#weight' => -5); if ($incompatible_count) { $form['start']['#title'] = format_plural($count, '1 pending update (@number_applied to be applied, @number_incompatible skipped)', '@count pending updates (@number_applied to be applied, @number_incompatible skipped)', array('@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count)); } else { $form['start']['#title'] = format_plural($count, '1 pending update', '@count pending updates'); } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Apply pending updates'); } return $form; }
/** * @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 == 'backdrop') { // 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>'; $backdropURL = civicrm_cms_base(); $backdropPermissionsURL = "{$backdropURL}index.php?q=admin/config/people/permissions"; $backdropURL .= "index.php?q=civicrm/admin/configtask&reset=1"; $output .= "<li>" . ts("Backdrop 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='{$backdropPermissionsURL}'", 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='{$backdropURL}'")) . "</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 "./core/includes/bootstrap.inc"; include_once "./core/includes/unicode.inc"; backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL); // prevent session information from being saved. backdrop_save_session(FALSE); // Force the current user to anonymous. $original_user = $GLOBALS['user']; $GLOBALS['user'] = backdrop_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 backdrop_flush_all_caches(); //add basic backdrop permissions civicrm_install_set_backdrop_perms(); // restore the user. $GLOBALS['user'] = $original_user; backdrop_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; }
#!/usr/bin/env php <?php ## usage: module-enable.php <module_a> <module_b> ... ini_set('display_errors', 1); $_SERVER['HTTP_HOST'] = 'default'; $_SERVER['PHP_SELF'] = '/index.php'; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $_SERVER['SERVER_SOFTWARE'] = NULL; $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['QUERY_STRING'] = ''; $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/'; $_SERVER['HTTP_USER_AGENT'] = 'console'; define('BACKDROP_ROOT', '.'); require_once 'core/includes/bootstrap.inc'; backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL); $modules = $argv; $program = array_shift($modules); if (empty($modules)) { echo "usage: {$program} <module_a> <module_b> ...\n"; exit(0); } else { printf("[[ Enable %s ]]\n", implode(', ', $modules)); module_enable($modules); backdrop_flush_all_caches(); $messages = backdrop_get_messages(); if (!empty($messages)) { print_r($messages); } }