Ejemplo n.º 1
0
/**
 * Tasks performed after the database is initialized.
 */
function install_tasks($profile, $task)
{
    global $base_url, $install_locale;
    // Bootstrap newly installed Drupal, while preserving existing messages.
    $messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    $_SESSION['messages'] = $messages;
    // URL used to direct page requests.
    $url = $base_url . '/install.php?locale=' . $install_locale . '&profile=' . $profile;
    // Build a page for final tasks.
    if (empty($task)) {
        variable_set('install_task', 'profile-install');
        $task = 'profile-install';
    }
    // We are using a list of if constructs here to allow for
    // passing from one task to the other in the same request.
    // Install profile modules.
    if ($task == 'profile-install') {
        $modules = variable_get('install_profile_modules', array());
        $files = module_rebuild_cache();
        variable_del('install_profile_modules');
        $operations = array();
        foreach ($modules as $module) {
            $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
        }
        $batch = array('operations' => $operations, 'finished' => '_install_profile_batch_finished', 'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_name())), 'error_message' => st('The installation has encountered an error.'));
        // Start a batch, switch to 'profile-install-batch' task. We need to
        // set the variable here, because batch_process() redirects.
        variable_set('install_task', 'profile-install-batch');
        batch_set($batch);
        batch_process($url, $url);
    }
    // We are running a batch install of the profile's modules.
    // This might run in multiple HTTP requests, constantly redirecting
    // to the same address, until the batch finished callback is invoked
    // and the task advances to 'locale-initial-import'.
    if ($task == 'profile-install-batch') {
        include_once 'includes/batch.inc';
        $output = _batch_page();
    }
    // Import interface translations for the enabled modules.
    if ($task == 'locale-initial-import') {
        if (!empty($install_locale) && $install_locale != 'en') {
            include_once 'includes/locale.inc';
            // Enable installation language as default site language.
            locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE);
            // Collect files to import for this language.
            $batch = locale_batch_by_language($install_locale, '_install_locale_initial_batch_finished');
            if (!empty($batch)) {
                // Remember components we cover in this batch set.
                variable_set('install_locale_batch_components', $batch['#components']);
                // Start a batch, switch to 'locale-batch' task. We need to
                // set the variable here, because batch_process() redirects.
                variable_set('install_task', 'locale-initial-batch');
                batch_set($batch);
                batch_process($url, $url);
            }
        }
        // Found nothing to import or not foreign language, go to next task.
        $task = 'configure';
    }
    if ($task == 'locale-initial-batch') {
        include_once 'includes/batch.inc';
        include_once 'includes/locale.inc';
        $output = _batch_page();
    }
    if ($task == 'configure') {
        if (variable_get('site_name', FALSE) || variable_get('site_mail', FALSE)) {
            // Site already configured: This should never happen, means re-running
            // the installer, possibly by an attacker after the 'install_task' variable
            // got accidentally blown somewhere. Stop it now.
            install_already_done_error();
        }
        $form = drupal_get_form('install_configure_form', $url);
        if (!variable_get('site_name', FALSE) && !variable_get('site_mail', FALSE)) {
            // Not submitted yet: Prepare to display the form.
            $output = $form;
            drupal_set_title(st('Configure site'));
            // Warn about settings.php permissions risk
            $settings_dir = './' . conf_path();
            $settings_file = $settings_dir . '/settings.php';
            if (!drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($settings_dir, FILE_NOT_WRITABLE, 'dir')) {
                drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, please consult the <a href="@handbook_url">on-line handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/getting-started')), 'error');
            } else {
                drupal_set_message(st('All necessary changes to %dir and %file have been made. They have been set to read-only for security.', array('%dir' => $settings_dir, '%file' => $settings_file)));
            }
            // Add JavaScript validation.
            _user_password_dynamic_validation();
            drupal_add_js(drupal_get_path('module', 'system') . '/system.js', 'module');
            // We add these strings as settings because JavaScript translation does not
            // work on install time.
            drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail')), 'cleanURL' => array('success' => st('Your server has been successfully tested to support this feature.'), 'failure' => st('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.'), 'testing' => st('Testing clean URLs...'))), 'setting');
            drupal_add_js('
// Global Killswitch
if (Drupal.jsEnabled) {
  $(document).ready(function() {
    Drupal.cleanURLsInstallCheck();
    Drupal.setDefaultTimezone();
  });
}', 'inline');
            // Build menu to allow clean URL check.
            menu_rebuild();
        } else {
            $task = 'profile';
        }
    }
    // If found an unknown task or the 'profile' task, which is
    // reserved for profiles, hand over the control to the profile,
    // so it can run any number of custom tasks it defines.
    if (!in_array($task, install_reserved_tasks())) {
        $function = $profile . '_profile_tasks';
        if (function_exists($function)) {
            // The profile needs to run more code, maybe even more tasks.
            // $task is sent through as a reference and may be changed!
            $output = $function($task, $url);
        }
        // If the profile doesn't move on to a new task we assume
        // that it is done.
        if ($task == 'profile') {
            $task = 'profile-finished';
        }
    }
    // Profile custom tasks are done, so let the installer regain
    // control and proceed with importing the remaining translations.
    if ($task == 'profile-finished') {
        if (!empty($install_locale) && $install_locale != 'en') {
            include_once 'includes/locale.inc';
            // Collect files to import for this language. Skip components
            // already covered in the initial batch set.
            $batch = locale_batch_by_language($install_locale, '_install_locale_remaining_batch_finished', variable_get('install_locale_batch_components', array()));
            // Remove temporary variable.
            variable_del('install_locale_batch_components');
            if (!empty($batch)) {
                // Start a batch, switch to 'locale-remaining-batch' task. We need to
                // set the variable here, because batch_process() redirects.
                variable_set('install_task', 'locale-remaining-batch');
                batch_set($batch);
                batch_process($url, $url);
            }
        }
        // Found nothing to import or not foreign language, go to next task.
        $task = 'finished';
    }
    if ($task == 'locale-remaining-batch') {
        include_once 'includes/batch.inc';
        include_once 'includes/locale.inc';
        $output = _batch_page();
    }
    // Display a 'finished' page to user.
    if ($task == 'finished') {
        drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name())));
        $messages = drupal_set_message();
        $output = '<p>' . st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) . '</p>';
        $output .= '<p>' . (isset($messages['error']) ? st('Please review the messages above before continuing on to <a href="@url">your new site</a>.', array('@url' => url(''))) : st('You may now visit <a href="@url">your new site</a>.', array('@url' => url('')))) . '</p>';
        $task = 'done';
    }
    // The end of the install process. Remember profile used.
    if ($task == 'done') {
        // Rebuild menu to get content type links registered by the profile,
        // and possibly any other menu items created through the tasks.
        menu_rebuild();
        // Register actions declared by any modules.
        actions_synchronize();
        // Randomize query-strings on css/js files, to hide the fact that
        // this is a new install, not upgraded yet.
        _drupal_flush_css_js();
        variable_set('install_profile', $profile);
    }
    // Set task for user, and remember the task in the database.
    install_task_list($task);
    variable_set('install_task', $task);
    // Output page, if some output was required. Otherwise it is possible
    // that we are printing a JSON page and theme output should not be there.
    if (isset($output)) {
        print theme('maintenance_page', $output);
    }
}
Ejemplo n.º 2
0
/**
 * Registry Rebuild needs to aggressively clear all caches,
 * not just some bins (at least to attempt it) also *before*
 * attempting to rebuild registry, or it may not be able
 * to fix the problem at all, if it relies on some cached
 * and no longer valid data/paths etc. This problem has been
 * confirmed and reproduced many times with option --fire-bazooka
 * which is available only in the Drush variant, but it confirms
 * the importance of starting with real, raw and not cached
 * in any way site state. While the --no-cache-clear option
 * still disables this procedure, --fire-bazooka takes precedence
 * and forces all caches clear action. All caches are cleared
 * by default in the PHP script variant.
 */
function registry_rebuild_cc_all()
{
    if (function_exists('cache_clear_all')) {
        cache_clear_all('*', 'cache', TRUE);
        cache_clear_all('*', 'cache_form', TRUE);
    } else {
        cache('cache')->deleteAll();
        cache('cache_form')->deleteAll();
    }
    if (function_exists('module_rebuild_cache')) {
        // D5-D6
        module_list(TRUE, FALSE);
        module_rebuild_cache();
    }
    if (function_exists('drupal_flush_all_caches')) {
        // D6+
        drupal_flush_all_caches();
    } else {
        // D5
        cache_clear_all();
        system_theme_data();
        node_types_rebuild();
        menu_rebuild();
    }
    print "All caches have been cleared with registry_rebuild_cc_all.<br/>\n";
}
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 /**
  * @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;
 }
Ejemplo n.º 5
0
/**
 * Preprocessor for theme('help_page').
 */
function rubik_preprocess_help_page(&$vars)
{
    $vars['hook'] = 'help-page';
    $vars['is_prose'] = TRUE;
    $vars['layout'] = TRUE;
    $vars['attr'] = array('class' => 'help-page clear-block');
    // Truly hackish way to navigate help pages.
    $module_info = module_rebuild_cache();
    $modules = array();
    foreach (module_implements('help', TRUE) as $module) {
        if (module_invoke($module, 'help', "admin/help#{$module}", $empty_arg)) {
            $modules[$module] = $module_info[$module]->info['name'];
        }
    }
    asort($modules);
    $links = array();
    foreach ($modules as $module => $name) {
        $links[] = array('title' => $name, 'href' => "admin/help/{$module}");
    }
    $vars['links'] = theme('links', $links);
}
Ejemplo n.º 6
0
Archivo: update.php Proyecto: c4rl/6
/**
 * Helper function to test compatibility of a module or theme.
 */
function update_check_incompatibility($name, $type = 'module')
{
    static $themes, $modules;
    // Store values of expensive functions for future use.
    if (empty($themes) || empty($modules)) {
        $themes = _system_theme_data();
        $modules = module_rebuild_cache();
    }
    if ($type == 'module' && isset($modules[$name])) {
        $file = $modules[$name];
    } else {
        if ($type == 'theme' && isset($themes[$name])) {
            $file = $themes[$name];
        }
    }
    if (!isset($file) || !isset($file->info['core']) || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY || version_compare(phpversion(), $file->info['php']) < 0) {
        return TRUE;
    }
    return FALSE;
}
Ejemplo n.º 7
0
 /**
  * Disables a drupal module in the test database.
  *
  * @param string $name Name of the module.
  * @return boolean Success.
  * @see drupalModuleEnable()
  */
 function drupalModuleDisable($name)
 {
     if (!module_exists($name)) {
         $this->pass(" [module] {$name} already disabled");
         return TRUE;
     }
     unset($this->_modules[$key]);
     $form_state['values'] = array('status' => $this->_modules, 'op' => t('Save configuration'));
     drupal_execute('system_modules', $form_state);
     //rebuilding all caches
     drupal_rebuild_theme_registry();
     node_types_rebuild();
     menu_rebuild();
     cache_clear_all('schema', 'cache');
     module_rebuild_cache();
 }
Ejemplo n.º 8
0
 function install($config)
 {
     echo '<link rel="stylesheet" type="text/css" href="template.css" />';
     echo '<div style="padding: 1em;"><h1>Installing CiviCRM...</h1>
           <p>I am now running through the installation steps (this should take a few minutes)<p/>
           <p>If you receive a fatal error, refresh this page to continue the installation</p>';
     flush();
     // Load the sapphire runtime
     echo '<br/>Building database schema and setup files...</div>';
     flush();
     // create database if does not exists
     $this->createDatabaseIfNotExists($config['mysql']['server'], $config['mysql']['username'], $config['mysql']['password'], $config['mysql']['database']);
     // Build database
     require_once 'civicrm.php';
     civicrm_main($config);
     // clean output
     @ob_clean();
     if (!$this->errors) {
         global $installType;
         echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
         echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
         echo '<head>';
         echo '<title>CiviCRM Installed</title>';
         echo '<link rel="stylesheet" type="text/css" href="template.css" />';
         echo '</head>';
         echo '<body>';
         echo '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
         echo '<ul>';
         $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', false, 'here');
         if (!function_exists('ts')) {
             $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
         }
         if ($installType == 'drupal') {
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/user/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             echo "<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>";
             // 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 listings and forms, register for events, view event info, view event participants\') WHERE rid IN (1, 2)');
         } elseif ($installType == 'standalone') {
             $standaloneURL = civicrm_cms_base() . 'standalone/index.php';
             $checkListURL = $standaloneURL . "?q=civicrm/admin/configtask&reset=1";
             echo "<li>Click <a target=\"_blank\" href=\"{$standaloneURL}\">here</a> to go to your CiviCRM Standalone home page.</li>";
         }
         echo '</ul>';
         echo '</div>';
         echo '</body>';
         echo '</html>';
     }
     return $this->errors;
 }
Ejemplo n.º 9
0
 /**
  * tearDown implementation, setting back switched modules etc
  */
 function tearDown()
 {
     if ($this->_modules != $this->_originalModules) {
         $form_state['values'] = array('status' => $this->_originalModules, 'op' => t('Save configuration'));
         drupal_execute('system_modules', $form_state);
         //rebuilding all caches
         drupal_rebuild_theme_registry();
         node_types_rebuild();
         menu_rebuild();
         cache_clear_all('schema', 'cache');
         module_rebuild_cache();
         $this->_modules = $this->_originalModules;
     }
     foreach ($this->_cleanupVariables as $name => $value) {
         if (is_null($value)) {
             variable_del($name);
         } else {
             variable_set($name, $value);
         }
     }
     $this->_cleanupVariables = array();
     //delete nodes
     foreach ($this->_cleanupNodes as $nid) {
         node_delete($nid);
     }
     $this->_cleanupNodes = array();
     //delete roles
     while (sizeof($this->_cleanupRoles) > 0) {
         $rid = array_pop($this->_cleanupRoles);
         db_query("DELETE FROM {role} WHERE rid = %d", $rid);
         db_query("DELETE FROM {permission} WHERE rid = %d", $rid);
     }
     //delete users and their content
     while (sizeof($this->_cleanupUsers) > 0) {
         $uid = array_pop($this->_cleanupUsers);
         // cleanup nodes this user created
         $result = db_query("SELECT nid FROM {node} WHERE uid = %d", $uid);
         while ($node = db_fetch_array($result)) {
             node_delete($node['nid']);
         }
         user_delete(array(), $uid);
     }
     //delete content types
     foreach ($this->_cleanupContentTypes as $type) {
         node_type_delete($type);
     }
     $this->_cleanupContentTypes = array();
     //Output drupal warnings and messages into assert messages
     $drupal_msgs = drupal_get_messages();
     foreach ($drupal_msgs as $type => $msgs) {
         foreach ($msgs as $msg) {
             $this->assertTrue(TRUE, "{$type}: {$msg}");
         }
     }
     parent::tearDown();
 }
Ejemplo n.º 10
0
 /**
  * Enables a drupal module
  * @param string $name name of the module
  * @return boolean success
  */
 function drupalModuleEnable($name)
 {
     if (module_exists($name)) {
         return TRUE;
     }
     include_once './includes/install.inc';
     module_rebuild_cache();
     // Rebuild the module cache
     if (drupal_get_installed_schema_version($name, TRUE) == SCHEMA_UNINSTALLED) {
         drupal_install_modules(array($name));
     } else {
         $try = module_enable(array($name));
     }
     if (module_exists($name)) {
         if (!isset($this->_cleanupModules[$name])) {
             $this->_cleanupModules[$name] = 0;
             return TRUE;
         }
     } else {
         die("required module {$name} could not be enabled (probably file does not exist)");
     }
 }
Ejemplo n.º 11
0
 /**
  * Enables a drupal module
  * @param string $name name of the module
  * @return boolean success
  */
 function drupalModuleEnable($name)
 {
     if (module_exists($name)) {
         $this->pass(" [module] {$name} already enabled");
         return TRUE;
     }
     include_once './includes/install.inc';
     module_rebuild_cache();
     // Rebuild the module cache
     if (drupal_get_installed_schema_version($name, TRUE) == SCHEMA_UNINSTALLED) {
         drupal_install_modules(array($name));
     } else {
         $try = module_enable(array($name));
     }
     if (module_exists($name)) {
         if (!isset($this->_cleanupModules[$name])) {
             $this->_cleanupModules[$name] = 0;
         }
         $this->pass(" [module] {$name} enabled");
         return TRUE;
     } else {
         $this->fail(" [module] {$name} could not be enbled, probably file not exists");
         return FALSE;
     }
 }