Example #1
0
 /**
  * @param  array $dependencies
  * @return array
  */
 private function checkDependencies(array $dependencies)
 {
     $this->getDrupalHelper()->loadLegacyFile('/core/modules/system/system.module');
     $client = $this->getHttpClient();
     $localModules = array();
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         array_push($localModules, basename($module->subpath));
     }
     $checkDependencies = ['local_modules' => [], 'drupal_modules' => [], 'no_modules' => []];
     foreach ($dependencies as $module) {
         if (in_array($module, $localModules)) {
             $checkDependencies['local_modules'][] = $module;
         } else {
             $response = $client->head('https://www.drupal.org/project/' . $module);
             $header_link = explode(';', $response->getHeader('link'));
             if (empty($header_link[0])) {
                 $checkDependencies['no_modules'][] = $module;
             } else {
                 $checkDependencies['drupal_modules'][] = $module;
             }
         }
     }
     return $checkDependencies;
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Install all core themes.
     sort($this->allThemes);
     $this->container->get('theme_installer')->install($this->allThemes);
     // Enable all core modules.
     $all_modules = system_rebuild_module_data();
     $all_modules = array_filter($all_modules, function ($module) {
         // Filter contrib, hidden, already enabled modules and modules in the
         // Testing package.
         if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
             return FALSE;
         }
         return TRUE;
     });
     $this->allModules = array_keys($all_modules);
     $this->allModules[] = 'system';
     sort($this->allModules);
     $this->container->get('module_installer')->install($this->allModules);
     $this->themeHandler = $this->container->get('theme_handler');
     $this->themeInitialization = $this->container->get('theme.initialization');
     $this->themeManager = $this->container->get('theme.manager');
     $this->libraryDiscovery = $this->container->get('library.discovery');
 }
 /**
  * Provides a formatted list of available help topics.
  *
  * @return string
  *   A string containing the formatted list.
  */
 protected function helpLinksAsList()
 {
     $module_info = system_rebuild_module_data();
     $modules = array();
     foreach ($this->moduleHandler()->getImplementations('help') as $module) {
         if ($this->moduleHandler()->invoke($module, 'help', array("help.page.{$module}", $this->routeMatch))) {
             $modules[$module] = $module_info[$module]->info['name'];
         }
     }
     asort($modules);
     // Output pretty four-column list.
     $count = count($modules);
     $break = ceil($count / 4);
     $column = array('#type' => 'container', 'links' => array('#theme' => 'item_list'), '#attributes' => array('class' => array('layout-column', 'quarter')));
     $output = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', 0 => $column);
     $i = 0;
     $current_column = 0;
     foreach ($modules as $module => $name) {
         $output[$current_column]['links']['#items'][] = $this->l($name, new Url('help.page', array('name' => $module)));
         if (($i + 1) % $break == 0 && $i + 1 != $count) {
             $current_column++;
             $output[$current_column] = $column;
         }
         $i++;
     }
     return $output;
 }
Example #4
0
 /**
  * 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');
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Get a list of all available modules.
     $modules = system_rebuild_module_data();
     $uninstallable = array_filter($modules, function ($module) use($modules) {
         return empty($modules[$module->getName()]->info['required']) && drupal_get_installed_schema_version($module->getName()) > SCHEMA_UNINSTALLED && $module->getName() !== 'devel';
     });
     $form['filters'] = array('#type' => 'container', '#attributes' => array('class' => array('table-filter', 'js-show')));
     $form['filters']['text'] = array('#type' => 'search', '#title' => $this->t('Search'), '#size' => 30, '#placeholder' => $this->t('Enter module name'), '#attributes' => array('class' => array('table-filter-text'), 'data-table' => '#devel-reinstall-form', 'autocomplete' => 'off', 'title' => $this->t('Enter a part of the module name or description to filter by.')));
     // Only build the rest of the form if there are any modules available to
     // uninstall;
     if (empty($uninstallable)) {
         return $form;
     }
     $header = array('name' => $this->t('Name'), 'description' => $this->t('Description'));
     $rows = array();
     foreach ($uninstallable as $module) {
         $name = $module->info['name'] ?: $module->getName();
         $rows[$module->getName()] = array('name' => array('data' => array('#type' => 'inline_template', '#template' => '<label class="module-name table-filter-text-source">{{ module_name }}</label>', '#context' => array('module_name' => $name))), 'description' => array('data' => $module->info['description'], 'class' => array('description')));
     }
     $form['reinstall'] = array('#type' => 'tableselect', '#header' => $header, '#options' => $rows, '#js_select' => FALSE, '#empty' => $this->t('No modules are available to uninstall.'));
     $form['#attached']['library'][] = 'system/drupal.system.modules';
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Reinstall'));
     return $form;
 }
Example #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $status = $input->getOption('status');
     $type = $input->getOption('type');
     if (strtolower($status) == 'enabled') {
         $status = 1;
     } elseif (strtolower($status) == 'disabled') {
         $status = 0;
     } else {
         $status = -1;
     }
     if (strtolower($type) == 'core') {
         $type = 'core';
     } elseif (strtolower($type) == 'no-core') {
         $type = '';
     } else {
         $type = null;
     }
     $tableHeader = [$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.origin')];
     $tableRows = [];
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         if ($status >= 0 && $status != $module->status) {
             continue;
         }
         if ($type !== null && $type !== $module->origin) {
             continue;
         }
         $module_status = $module->status ? $this->trans('commands.module.debug.messages.enabled') : $this->trans('commands.module.debug.messages.disabled');
         $schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
         $tableRows[] = [$module_id, $module->info['name'], $module_status, $module->info['package'], $schema_version, $module->origin];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
 /**
  * Provides a formatted list of available help topics.
  *
  * @return string
  *   A string containing the formatted list.
  */
 protected function helpLinksAsList()
 {
     $module_info = system_rebuild_module_data();
     $modules = array();
     foreach ($this->moduleHandler()->getImplementations('help') as $module) {
         if ($this->moduleHandler()->invoke($module, 'help', array("help.page.{$module}", $this->routeMatch))) {
             $modules[$module] = $module_info[$module]->info['name'];
         }
     }
     asort($modules);
     // Output pretty four-column list.
     $count = count($modules);
     $break = ceil($count / 4);
     $output = '<div class="clearfix"><div class="help-items"><ul>';
     $i = 0;
     foreach ($modules as $module => $name) {
         $output .= '<li>' . $this->l($name, new Url('help.page', array('name' => $module))) . '</li>';
         if (($i + 1) % $break == 0 && $i + 1 != $count) {
             $output .= '</ul></div><div class="help-items' . ($i + 1 == $break * 3 ? ' help-items-last' : '') . '"><ul>';
         }
         $i++;
     }
     $output .= '</ul></div></div>';
     return $output;
 }
Example #8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->get('site')->loadLegacyFile('/core/modules/system/system.module');
     $status = strtolower($input->getOption('status'));
     $type = strtolower($input->getOption('type'));
     $modules = strtolower($input->getArgument('module'));
     if ($modules) {
         $config = $this->getApplication()->getConfig();
         $repo = $config->get('application.composer.repositories.default');
         foreach ($modules as $module) {
             $url = sprintf('%s/packages/drupal/%s.json', $config->get('application.composer.packages.default'), $module);
             try {
                 $data = $this->getApplication()->getHttpClientHelper()->getUrlAsJson($repo . $url);
             } catch (\Exception $e) {
                 $io->error(sprintf($this->trans('commands.module.debug.messages.no-results'), $module));
                 return 1;
             }
             $tableHeader = ['<info>' . $data->package->name . '</info>'];
             $tableRows = [];
             $tableRows[] = [$data->package->description];
             $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-downloads') . '</comment>', $data->package->downloads->total];
             $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-monthly') . '</comment>', $data->package->downloads->monthly];
             $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-daily') . '</comment>', $data->package->downloads->daily];
             $io->table($tableHeader, $tableRows, 'compact');
         }
         return 0;
     }
     if ($status == 'installed') {
         $status = 1;
     } elseif ($status == 'uninstalled') {
         $status = 0;
     } else {
         $status = -1;
     }
     if ($type == 'core') {
         $type = 'core';
     } elseif ($type == 'no-core') {
         $type = '';
     } else {
         $type = null;
     }
     $tableHeader = [$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.version'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.origin')];
     $tableRows = [];
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         if ($status >= 0 && $status != $module->status) {
             continue;
         }
         if ($type !== null && $type !== $module->origin) {
             continue;
         }
         $module_status = $module->status ? $this->trans('commands.module.debug.messages.installed') : $this->trans('commands.module.debug.messages.uninstalled');
         $module_origin = $module->origin ? $module->origin : 'no core';
         $schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
         $tableRows[] = [$module_id, $module->info['name'], $module->info['package'], $module->info['version'], $schema_version, $module_status, $module_origin];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     $role_names = array();
     $role_permissions = array();
     foreach ($this->getRoles() as $role_name => $role) {
         // Retrieve role names for columns.
         $role_names[$role_name] = String::checkPlain($role->label());
         // Fetch permissions for the roles.
         $role_permissions[$role_name] = $role->getPermissions();
     }
     // Store $role_names for use when saving the data.
     $form['role_names'] = array('#type' => 'value', '#value' => $role_names);
     // Render role/permission overview:
     $options = array();
     $module_info = system_rebuild_module_data();
     $hide_descriptions = system_admin_compact_mode();
     // Get a list of all the modules implementing a hook_permission() and sort by
     // display name.
     $modules = array();
     foreach ($this->moduleHandler->getImplementations('permission') as $module) {
         $modules[$module] = $module_info[$module]->info['name'];
     }
     asort($modules);
     $form['system_compact_link'] = array('#theme' => 'system_compact_link');
     $form['permissions'] = array('#type' => 'table', '#header' => array($this->t('Permission')), '#id' => 'permissions', '#sticky' => TRUE);
     foreach ($role_names as $name) {
         $form['permissions']['#header'][] = array('data' => $name, 'class' => array('checkbox'));
     }
     foreach ($modules as $module => $display_name) {
         if ($permissions = $this->moduleHandler->invoke($module, 'permission')) {
             // Module name.
             $form['permissions'][$module] = array(array('#wrapper_attributes' => array('colspan' => count($role_names) + 1, 'class' => array('module'), 'id' => 'module-' . $module), '#markup' => $module_info[$module]->info['name']));
             foreach ($permissions as $perm => $perm_item) {
                 // Fill in default values for the permission.
                 $perm_item += array('description' => '', 'restrict access' => FALSE, 'warning' => !empty($perm_item['restrict access']) ? $this->t('Warning: Give to trusted roles only; this permission has security implications.') : '');
                 $options[$perm] = $perm_item['title'];
                 // Show the permission description.
                 if (!$hide_descriptions) {
                     $user_permission_description = $perm_item['description'];
                     // Append warning message.
                     if (!empty($perm_item['warning'])) {
                         $user_permission_description .= ' <em class="permission-warning">' . $perm_item['warning'] . '</em>';
                     }
                 }
                 $form['permissions'][$perm]['description'] = array('#wrapper_attributes' => array('class' => array('permission')), '#type' => 'item', '#markup' => $perm_item['title'], '#description' => $user_permission_description);
                 $options[$perm] = '';
                 foreach ($role_names as $rid => $name) {
                     $form['permissions'][$perm][$rid] = array('#title' => $name . ': ' . $perm_item['title'], '#title_display' => 'invisible', '#wrapper_attributes' => array('class' => array('checkbox')), '#type' => 'checkbox', '#default_value' => in_array($perm, $role_permissions[$rid]) ? 1 : 0, '#attributes' => array('class' => array('rid-' . $rid)), '#parents' => array($rid, $perm));
                 }
             }
         }
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save permissions'));
     $form['#attached']['library'][] = 'user/drupal.user.permissions';
     return $form;
 }
 protected function calculateDependencies($modules)
 {
     $this->site->loadLegacyFile('/core/modules/system/system.module');
     $moduleList = system_rebuild_module_data();
     $dependencies = [];
     foreach ($modules as $moduleName) {
         $module = $moduleList[$moduleName];
         $dependencies = array_unique(array_merge($dependencies, $this->validator->getUninstalledModules(array_keys($module->requires) ?: [])));
     }
     return array_diff($dependencies, $modules);
 }
Example #11
0
 /**
  * Tests that theme .info.yml data is rebuild after enabling a module.
  *
  * Tests that info data is rebuilt after a module that implements
  * hook_system_info_alter() is enabled. Also tests if core *_list() functions
  * return freshly altered info.
  */
 function testSystemInfoAlter()
 {
     \Drupal::state()->set('module_test.hook_system_info_alter', TRUE);
     $info = system_rebuild_module_data();
     $this->assertFalse(isset($info['node']->info['required']), 'Before the module_test is installed the node module is not required.');
     // Enable the test module.
     \Drupal::service('module_installer')->install(array('module_test'), FALSE);
     $this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
     $info = system_rebuild_module_data();
     $this->assertTrue($info['node']->info['required'], 'After the module_test is installed the node module is required.');
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // @todo ModuleInstaller calls system_rebuild_module_data which is part of
     //   system.module, see https://www.drupal.org/node/2208429.
     include_once $this->root . '/core/modules/system/system.module';
     // Set up the state values so we know where to find the files when running
     // drupal_get_filename().
     // @todo Remove as part of https://www.drupal.org/node/2186491
     system_rebuild_module_data();
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $composer = $input->getOption('composer');
     $module = $input->getArgument('module');
     $this->get('site')->loadLegacyFile('/core/modules/system/system.module');
     $coreExtension = $this->getDrupalService('config.factory')->getEditable('core.extension');
     $moduleInstaller = $this->getDrupalService('module_installer');
     // Get info about modules available
     $moduleData = system_rebuild_module_data();
     $moduleList = array_combine($module, $module);
     if ($composer) {
         //@TODO: check with Composer if the module is previously required in composer.json!
         foreach ($module as $moduleItem) {
             $command = sprintf('composer remove drupal/%s ', $moduleItem);
             $shellProcess = $this->get('shell_process');
             if ($shellProcess->exec($command)) {
                 $io->success(sprintf($this->trans('commands.module.uninstall.messages.composer-success'), $moduleItem));
             }
         }
     }
     if ($missingModules = array_diff_key($moduleList, $moduleData)) {
         $io->error(sprintf($this->trans('commands.module.uninstall.messages.missing'), implode(', ', $module), implode(', ', $missingModules)));
         return 1;
     }
     $installedModules = $coreExtension->get('module') ?: array();
     if (!($moduleList = array_intersect_key($moduleList, $installedModules))) {
         $io->info($this->trans('commands.module.uninstall.messages.nothing'));
         return 0;
     }
     if (!($force = $input->getOption('force'))) {
         $dependencies = [];
         while (list($module) = each($moduleList)) {
             foreach (array_keys($moduleData[$module]->required_by) as $dependency) {
                 if (isset($installedModules[$dependency]) && !isset($moduleList[$dependency]) && $dependency != $profile) {
                     $dependencies[] = $dependency;
                 }
             }
         }
         if (!empty($dependencies)) {
             $io->error(sprintf($this->trans('commands.module.uninstall.messages.dependents'), implode(', ', $module), implode(', ', $dependencies)));
             return 1;
         }
     }
     try {
         $moduleInstaller->uninstall($moduleList);
         $io->info(sprintf($this->trans('commands.module.uninstall.messages.success'), implode(', ', $moduleList)));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $this->get('chain_queue')->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
Example #14
0
 /**
  * @param string $type
  * @return \Drupal\Core\Extension\Extension[]
  */
 public function discoverExtensions($type = 'module')
 {
     $this->getDrupalHelper()->loadLegacyFile('/core/modules/system/system.module');
     system_rebuild_module_data();
     /*
      * @see Remove DrupalExtensionDiscovery subclass once
      * https://www.drupal.org/node/2503927 is fixed.
      */
     $discovery = new DrupalExtensionDiscovery(\Drupal::root());
     $discovery->reset();
     return $discovery->scan($type);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->getDrupalHelper()->loadLegacyFile('/core/modules/system/system.module');
     $extension_config = $this->getConfigFactory()->getEditable('core.extension');
     $moduleInstaller = $this->getModuleInstaller();
     // Get info about modules available
     $module_data = system_rebuild_module_data();
     $module = $input->getArgument('module');
     $modules = array_filter(array_map('trim', explode(',', $module)));
     $module_list = array_combine($modules, $modules);
     // Determine if some module request is missing
     if ($missing_modules = array_diff_key($module_list, $module_data)) {
         $io->error(sprintf($this->trans('commands.module.uninstall.messages.missing'), implode(', ', $modules), implode(', ', $missing_modules)));
         return true;
     }
     // Only process currently installed modules.
     $installed_modules = $extension_config->get('module') ?: array();
     if (!($module_list = array_intersect_key($module_list, $installed_modules))) {
         $io->info($this->trans('commands.module.uninstall.messages.nothing'));
         return true;
     }
     $force = $input->getOption('force');
     if (!$force) {
         // Calculate $dependents
         $dependents = array();
         while (list($module) = each($module_list)) {
             foreach (array_keys($module_data[$module]->required_by) as $dependent) {
                 // Skip already uninstalled modules.
                 if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) {
                     $dependents[] = $dependent;
                 }
             }
         }
         // Error if there are missing dependencies
         if (!empty($dependents)) {
             $io->error(sprintf($this->trans('commands.module.uninstall.messages.dependents'), implode(', ', $modules), implode(', ', $dependents)));
             return true;
         }
     }
     // Installing modules
     try {
         // Uninstall the modules.
         $moduleInstaller->uninstall($module_list);
         $io->info(sprintf($this->trans('commands.module.uninstall.messages.success'), implode(', ', $modules)));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return;
     }
     // Run cache rebuild to see changes in Web UI
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'discovery']);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Make sure the install API is available.
     include_once DRUPAL_ROOT . '/core/includes/install.inc';
     // Get a list of all available modules.
     $modules = system_rebuild_module_data();
     $uninstallable = array_filter($modules, function ($module) use($modules) {
         return empty($modules[$module->getName()]->info['required']) && $module->status;
     });
     // Include system.admin.inc so we can use the sort callbacks.
     $this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
     $form['filters'] = array('#type' => 'container', '#attributes' => array('class' => array('table-filter', 'js-show')));
     $form['filters']['text'] = array('#type' => 'search', '#title' => $this->t('Search'), '#size' => 30, '#placeholder' => $this->t('Enter module name'), '#attributes' => array('class' => array('table-filter-text'), 'data-table' => '#system-modules-uninstall', 'autocomplete' => 'off', 'title' => $this->t('Enter a part of the module name or description to filter by.')));
     $form['modules'] = array();
     // Only build the rest of the form if there are any modules available to
     // uninstall;
     if (empty($uninstallable)) {
         return $form;
     }
     $profile = drupal_get_profile();
     // Sort all modules by their name.
     uasort($uninstallable, 'system_sort_modules_by_info_name');
     $validation_reasons = $this->moduleInstaller->validateUninstall(array_keys($uninstallable));
     $form['uninstall'] = array('#tree' => TRUE);
     foreach ($uninstallable as $module_key => $module) {
         $name = $module->info['name'] ?: $module->getName();
         $form['modules'][$module->getName()]['#module_name'] = $name;
         $form['modules'][$module->getName()]['name']['#markup'] = $name;
         $form['modules'][$module->getName()]['description']['#markup'] = $this->t($module->info['description']);
         $form['uninstall'][$module->getName()] = array('#type' => 'checkbox', '#title' => $this->t('Uninstall @module module', array('@module' => $name)), '#title_display' => 'invisible');
         // If a validator returns reasons not to uninstall a module,
         // list the reasons and disable the check box.
         if (isset($validation_reasons[$module_key])) {
             $form['modules'][$module->getName()]['#validation_reasons'] = $validation_reasons[$module_key];
             $form['uninstall'][$module->getName()]['#disabled'] = TRUE;
         }
         // All modules which depend on this one must be uninstalled first, before
         // we can allow this module to be uninstalled. (The installation profile
         // is excluded from this list.)
         foreach (array_keys($module->required_by) as $dependent) {
             if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) {
                 $name = isset($modules[$dependent]->info['name']) ? $modules[$dependent]->info['name'] : $dependent;
                 $form['modules'][$module->getName()]['#required_by'][] = $name;
                 $form['uninstall'][$module->getName()]['#disabled'] = TRUE;
             }
         }
     }
     $form['#attached']['library'][] = 'system/drupal.system.modules';
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Uninstall'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $role_names = array();
     $role_permissions = array();
     foreach ($this->getRoles() as $role_name => $role) {
         // Retrieve role names for columns.
         $role_names[$role_name] = String::checkPlain($role->label());
         // Fetch permissions for the roles.
         $role_permissions[$role_name] = $role->getPermissions();
     }
     // Store $role_names for use when saving the data.
     $form['role_names'] = array('#type' => 'value', '#value' => $role_names);
     // Render role/permission overview:
     $options = array();
     $module_info = system_rebuild_module_data();
     $hide_descriptions = system_admin_compact_mode();
     $form['system_compact_link'] = array('#theme' => 'system_compact_link');
     $form['permissions'] = array('#type' => 'table', '#header' => array($this->t('Permission')), '#id' => 'permissions', '#sticky' => TRUE);
     foreach ($role_names as $name) {
         $form['permissions']['#header'][] = array('data' => $name, 'class' => array('checkbox'));
     }
     $permissions = $this->permissionHandler->getPermissions();
     $permissions_by_provider = array();
     foreach ($permissions as $permission_name => $permission) {
         $permissions_by_provider[$permission['provider']][$permission_name] = $permission;
     }
     foreach ($permissions_by_provider as $provider => $permissions) {
         // Module name.
         $form['permissions'][$provider] = array(array('#wrapper_attributes' => array('colspan' => count($role_names) + 1, 'class' => array('module'), 'id' => 'module-' . $provider), '#markup' => $module_info[$provider]->info['name']));
         foreach ($permissions as $perm => $perm_item) {
             // Fill in default values for the permission.
             $perm_item += array('description' => '', 'restrict access' => FALSE, 'warning' => !empty($perm_item['restrict access']) ? $this->t('Warning: Give to trusted roles only; this permission has security implications.') : '');
             $options[$perm] = $perm_item['title'];
             $form['permissions'][$perm]['description'] = array('#type' => 'inline_template', '#template' => '<div class="permission"><span class="title">{{ title }}</span>{% if description or warning %}<div class="description">{% if warning %}<em class="permission-warning">{{ warning }}</em> {% endif %}{{ description }}</div>{% endif %}</div>', '#context' => array('title' => $perm_item['title']));
             // Show the permission description.
             if (!$hide_descriptions) {
                 $form['permissions'][$perm]['description']['#context']['description'] = $perm_item['description'];
                 $form['permissions'][$perm]['description']['#context']['warning'] = $perm_item['warning'];
             }
             $options[$perm] = '';
             foreach ($role_names as $rid => $name) {
                 $form['permissions'][$perm][$rid] = array('#title' => $name . ': ' . $perm_item['title'], '#title_display' => 'invisible', '#wrapper_attributes' => array('class' => array('checkbox')), '#type' => 'checkbox', '#default_value' => in_array($perm, $role_permissions[$rid]) ? 1 : 0, '#attributes' => array('class' => array('rid-' . $rid)), '#parents' => array($rid, $perm));
             }
         }
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save permissions'));
     $form['#attached']['library'][] = 'user/drupal.user.permissions';
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Enable all core modules that provide field plugins.
     $modules = system_rebuild_module_data();
     $modules = array_filter($modules, function (Extension $module) {
         // Filter contrib, hidden, already enabled modules and modules in the
         // Testing package.
         if ($module->origin === 'core' && empty($module->info['hidden']) && $module->status == FALSE && $module->info['package'] !== 'Testing' && is_readable($module->getPath() . '/src/Plugin/Field')) {
             return TRUE;
         }
         return FALSE;
     });
     $this->enableModules(array_keys($modules));
 }
Example #19
0
 /**
  * Ensures that no URL generator is called on a page without hook_help().
  */
 public function testEmptyHookHelp()
 {
     $all_modules = system_rebuild_module_data();
     $all_modules = array_filter($all_modules, function ($module) {
         // Filter contrib, hidden, already enabled modules and modules in the
         // Testing package.
         if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
             return FALSE;
         }
         return TRUE;
     });
     \Drupal::service('module_installer')->install(array_keys($all_modules));
     $route = \Drupal::service('router.route_provider')->getRouteByName('<front>');
     \Drupal::service('module_handler')->invokeAll('help', ['<front>', new RouteMatch('<front>', $route)]);
 }
 protected function getAllModules($status, $type, $output, $table)
 {
     $table->setHeaders([$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.origin')]);
     $table->setlayout($table::LAYOUT_COMPACT);
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         if ($status >= 0 && $status != $module->status) {
             continue;
         }
         if ($type !== null && $type !== $module->origin) {
             continue;
         }
         $module_status = $module->status ? $this->trans('commands.module.debug.messages.enabled') : $this->trans('commands.module.debug.messages.disabled');
         $table->addRow([$module_id, $module->info['name'], $module_status, $module->info['package'], $module->origin]);
     }
     $table->render($output);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $extension_config = $this->getConfigFactory()->getEditable('core.extension');
     $moduleInstaller = $this->getModuleInstaller();
     // Get info about modules available
     $module_data = system_rebuild_module_data();
     $module = $input->getArgument('module');
     $modules = array_filter(array_map('trim', explode(',', $module)));
     $module_list = array_combine($modules, $modules);
     // Determine if some module request is missing
     if ($missing_modules = array_diff_key($module_list, $module_data)) {
         $output->writeln('[+] <error>' . sprintf($this->trans('commands.module.uninstall.messages.missing'), implode(', ', $modules), implode(', ', $missing_modules)) . '</error>');
         return true;
     }
     // Only process currently installed modules.
     $installed_modules = $extension_config->get('module') ?: array();
     if (!($module_list = array_intersect_key($module_list, $installed_modules))) {
         $output->writeln('[+] <info>' . $this->trans('commands.module.uninstall.messages.nothing') . '</info>');
         return true;
     }
     // Calculate $dependents
     $dependents = array();
     while (list($module) = each($module_list)) {
         foreach (array_keys($module_data[$module]->required_by) as $dependent) {
             // Skip already uninstalled modules.
             if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) {
                 $dependents[] = $dependent;
             }
         }
     }
     // Error if there are missing dependencies
     if (!empty($dependents)) {
         $output->writeln('[+] <error>' . sprintf($this->trans('commands.module.uninstall.messages.dependents'), implode(', ', $modules), implode(', ', $dependents)) . '</error>');
         return true;
     }
     // Installing modules
     try {
         // Install the modules.
         $moduleInstaller->uninstall($module_list);
         $output->writeln('[+] <info>' . sprintf($this->trans('commands.module.uninstall.messages.success'), implode(', ', $modules)) . '</info>');
     } catch (\Exception $e) {
         $output->writeln('[+] <error>' . $e->getMessage() . '</error>');
         return;
     }
 }
Example #22
0
 protected function getAllModules($status, $type, $output, $table)
 {
     $this->getDrupalHelper()->loadLegacyFile('/core/includes/schema.inc');
     $table->setHeaders([$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.origin')]);
     $table->setlayout($table::LAYOUT_COMPACT);
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         if ($status >= 0 && $status != $module->status) {
             continue;
         }
         if ($type !== null && $type !== $module->origin) {
             continue;
         }
         $module_status = $module->status ? $this->trans('commands.module.debug.messages.enabled') : $this->trans('commands.module.debug.messages.disabled');
         $schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
         $table->addRow([$module_id, $module->info['name'], $module_status, $module->info['package'], $schema_version, $module->origin]);
     }
     $table->render($output);
 }
 /**
  * Installs all core modules.
  */
 protected function installAllModules()
 {
     // Needed for system_rebuild_module_data().
     include_once $this->root . '/core/modules/system/system.module';
     // Enable all core modules.
     $all_modules = system_rebuild_module_data();
     $all_modules = array_filter($all_modules, function ($module) {
         // Filter contrib, hidden, already enabled modules and modules in the
         // Testing package.
         if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
             return FALSE;
         }
         return TRUE;
     });
     $this->allModules = array_keys($all_modules);
     sort($this->allModules);
     $module_installer = $this->container->get('module_installer');
     $module_installer->install($this->allModules);
     $this->installConfig(['system', 'user']);
 }
 /**
  * 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');
 }
Example #25
0
 /**
  * Tests that drupal_get_filename() works when the file is not in database.
  */
 function testDrupalGetFilename()
 {
     // drupal_get_profile() is using obtaining the profile from state if the
     // install_state global is not set.
     global $install_state;
     $install_state['parameters']['profile'] = 'testing';
     // Rebuild system.module.files state data.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     drupal_static_reset('system_rebuild_module_data');
     system_rebuild_module_data();
     // Retrieving the location of a module.
     $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml');
     // Retrieving the location of a theme.
     \Drupal::service('theme_handler')->install(array('stark'));
     $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml');
     // Retrieving the location of a theme engine.
     $this->assertIdentical(drupal_get_filename('theme_engine', 'twig'), 'core/themes/engines/twig/twig.info.yml');
     // Retrieving the location of a profile. Profiles are a special case with
     // a fixed location and naming.
     $this->assertIdentical(drupal_get_filename('profile', 'testing'), 'core/profiles/testing/testing.info.yml');
     // Generate a non-existing module name.
     $non_existing_module = uniqid("", TRUE);
     // Set a custom error handler so we can ignore the file not found error.
     set_error_handler(function ($severity, $message, $file, $line) {
         // Skip error handling if this is a "file not found" error.
         if (strstr($message, 'is missing from the file system:')) {
             \Drupal::state()->set('get_filename_test_triggered_error', TRUE);
             return;
         }
         throw new \ErrorException($message, 0, $severity, $file, $line);
     });
     $this->assertNull(drupal_get_filename('module', $non_existing_module), 'Searching for an item that does not exist returns NULL.');
     $this->assertTrue(\Drupal::state()->get('get_filename_test_triggered_error'), 'Searching for an item that does not exist triggers an error.');
     // Restore the original error handler.
     restore_error_handler();
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     // Retrieve the list of modules from the key value store.
     $account = $this->currentUser()->id();
     $this->modules = $this->keyValueExpirable->get($account);
     // Prevent this page from showing when the module list is empty.
     if (empty($this->modules)) {
         return new RedirectResponse('/admin/modules/uninstall');
     }
     $data = system_rebuild_module_data();
     $form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
     $form['modules'] = array('#theme' => 'item_list', '#items' => array_map(function ($module) use($data) {
         return $data[$module]->info['name'];
     }, $this->modules));
     $form['entities'] = array('#type' => 'details', '#title' => $this->t('Configuration deletions'), '#description' => $this->t('The listed configuration will be deleted.'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#access' => FALSE);
     // Get the dependent entities.
     $entity_types = array();
     $dependent_entities = $this->configManager->findConfigEntityDependentsAsEntities('module', $this->modules);
     foreach ($dependent_entities as $entity) {
         $entity_type_id = $entity->getEntityTypeId();
         if (!isset($form['entities'][$entity_type_id])) {
             $entity_type = $this->entityManager->getDefinition($entity_type_id);
             // Store the ID and label to sort the entity types and entities later.
             $label = $entity_type->getLabel();
             $entity_types[$entity_type_id] = $label;
             $form['entities'][$entity_type_id] = array('#theme' => 'item_list', '#title' => $label, '#items' => array());
         }
         $form['entities'][$entity_type_id]['#items'][] = $entity->label();
     }
     if (!empty($dependent_entities)) {
         $form['entities']['#access'] = TRUE;
         // Add a weight key to the entity type sections.
         asort($entity_types, SORT_FLAG_CASE);
         $weight = 0;
         foreach ($entity_types as $entity_type_id => $label) {
             $form['entities'][$entity_type_id]['#weight'] = $weight;
             // Sort the list of entity labels alphabetically.
             sort($form['entities'][$entity_type_id]['#items'], SORT_FLAG_CASE);
             $weight++;
         }
     }
     return parent::buildForm($form, $form_state);
 }
Example #27
0
 /**
  * Populates the extension change list.
  */
 protected function createExtensionChangelist()
 {
     // Read the extensions information to determine changes.
     $current_extensions = $this->storageComparer->getTargetStorage()->read('core.extension');
     $new_extensions = $this->storageComparer->getSourceStorage()->read('core.extension');
     // If there is no extension information in staging then exit. This is
     // probably due to an empty staging directory.
     if (!$new_extensions) {
         return;
     }
     // Get a list of modules with dependency weights as values.
     $module_data = system_rebuild_module_data();
     // Set the actual module weights.
     $module_list = array_combine(array_keys($module_data), array_keys($module_data));
     $module_list = array_map(function ($module) use($module_data) {
         return $module_data[$module]->sort;
     }, $module_list);
     // Determine which modules to uninstall.
     $uninstall = array_keys(array_diff_key($current_extensions['module'], $new_extensions['module']));
     // Sort the list of newly uninstalled extensions by their weights, so that
     // dependencies are uninstalled last. Extensions of the same weight are
     // sorted in reverse alphabetical order, to ensure the order is exactly
     // opposite from installation. For example, this module list:
     // array(
     //   'actions' => 0,
     //   'ban' => 0,
     //   'options' => -2,
     //   'text' => -1,
     // );
     // will result in the following sort order:
     // -2   options
     // -1   text
     //  0 0 ban
     //  0 1 actions
     // @todo Move this sorting functionality to the extension system.
     array_multisort(array_values($module_list), SORT_ASC, array_keys($module_list), SORT_DESC, $module_list);
     $uninstall = array_intersect(array_keys($module_list), $uninstall);
     // Determine which modules to install.
     $install = array_keys(array_diff_key($new_extensions['module'], $current_extensions['module']));
     // Ensure that installed modules are sorted in exactly the reverse order
     // (with dependencies installed first, and modules of the same weight sorted
     // in alphabetical order).
     $module_list = array_reverse($module_list);
     $install = array_intersect(array_keys($module_list), $install);
     // Work out what themes to install and to uninstall.
     $theme_install = array_keys(array_diff_key($new_extensions['theme'], $current_extensions['theme']));
     $theme_uninstall = array_keys(array_diff_key($current_extensions['theme'], $new_extensions['theme']));
     $this->extensionChangelist = array('module' => array('uninstall' => $uninstall, 'install' => $install), 'theme' => array('install' => $theme_install, 'uninstall' => $theme_uninstall));
 }
Example #28
0
/**
 * Before calling this we need to be bootstrapped to DRUPAL_BOOTSTRAP_SESSION.
 */
function registry_rebuild_rebuild()
{
    // This section is not functionally important. It's just using the
    // registry_get_parsed_files() so that it can report the change. Drupal 7 only.
    if (function_exists('registry_rebuild')) {
        $connection_info = Database::getConnectionInfo();
        $driver = $connection_info['default']['driver'];
        global $include_dir;
        require_once $include_dir . '/database/' . $driver . '/query.inc';
        $parsed_before = registry_get_parsed_files();
    }
    // Separate bootstrap cache exists only in Drupal 7 or newer.
    // They are cleared later again via drupal_flush_all_caches().
    if (function_exists('registry_rebuild')) {
        // D7
        cache_clear_all('lookup_cache', 'cache_bootstrap');
        cache_clear_all('variables', 'cache_bootstrap');
        cache_clear_all('module_implements', 'cache_bootstrap');
        print "Bootstrap caches have been cleared in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
    } elseif (!function_exists('cache_clear_all')) {
        // D8+
        cache('bootstrap')->deleteAll();
        print "Bootstrap caches have been cleared in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
    }
    // We later run system_rebuild_module_data() and registry_update() on Drupal 7 via
    // D7-only registry_rebuild() wrapper, which is run inside drupal_flush_all_caches().
    // It is an equivalent of module_rebuild_cache() in D5-D6 and is normally run via
    // our universal wrapper registry_rebuild_cc_all() -- see further below.
    // However, we are still on the DRUPAL_BOOTSTRAP_SESSION level here,
    // and we want to make the initial rebuild as atomic as possible, so we can't
    // run everything from registry_rebuild_cc_all() yet, so we run an absolute
    // minimum we can at this stage, core specific.
    if (function_exists('registry_rebuild')) {
        // D7 only
        print "Doing registry_rebuild() in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
        registry_rebuild();
    } elseif (!function_exists('registry_rebuild') && function_exists('system_rebuild_module_data')) {
        // D8+
        print "Doing system_rebuild_module_data() in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
        system_rebuild_module_data();
    } else {
        // D5-D6
        print "Doing module_rebuild_cache() in DRUPAL_BOOTSTRAP_SESSION<br/>\n";
        module_list(TRUE, FALSE);
        module_rebuild_cache();
    }
    print "Bootstrapping to DRUPAL_BOOTSTRAP_FULL<br/>\n";
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    // We can run our wrapper now, since we are in a full bootstrap already.
    print "Rebuilding registry via registry_rebuild_cc_all in DRUPAL_BOOTSTRAP_FULL<br/>\n";
    registry_rebuild_cc_all();
    // Extra cleanup available for D7 only.
    if (function_exists('registry_rebuild')) {
        $parsed_after = registry_get_parsed_files();
        // Remove files which don't exist anymore.
        $filenames = array();
        foreach ($parsed_after as $filename => $file) {
            if (!file_exists($filename)) {
                $filenames[] = $filename;
            }
        }
        if (!empty($filenames)) {
            db_delete('registry_file')->condition('filename', $filenames)->execute();
            db_delete('registry')->condition('filename', $filenames)->execute();
            print "Deleted " . count($filenames) . ' stale files from registry manually.';
        }
        $parsed_after = registry_get_parsed_files();
        print "There were " . count($parsed_before) . " files in the registry before and " . count($parsed_after) . " files now.<br/>\n";
        registry_rebuild_cc_all();
    }
    print "If you don't see any crazy fatal errors, your registry has been rebuilt.<br/>\n";
}
Example #29
0
 /**
  * Gets the list of enabled modules that implement hook_help().
  *
  * @return array
  *   A list of enabled modules.
  */
 protected function getModuleList()
 {
     $modules = array();
     $module_data = system_rebuild_module_data();
     foreach (\Drupal::moduleHandler()->getImplementations('help') as $module) {
         $modules[$module] = $module_data[$module]->info['name'];
     }
     return $modules;
 }
 /**
  * @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;
 }