/** * {@inheritdoc} */ protected function handle() { $plugins = elgg_get_plugins('inactive'); if (empty($plugins)) { system_message('All plugins are active'); return; } $ids = array_map(function (ElggPlugin $plugin) { return $plugin->getID(); }, $plugins); $ids = array_values($ids); if ($this->option('all')) { $activate_ids = $ids; } else { $helper = $this->getHelper('question'); $question = new ChoiceQuestion('Please select plugins you would like to activate (comma-separated list of indexes)', $ids); $question->setMultiselect(true); $activate_ids = $helper->ask($this->input, $this->output, $question); } if (empty($activate_ids)) { throw new \RuntimeException('You must select at least one plugin'); } $plugins = []; foreach ($activate_ids as $plugin_id) { $plugins[] = elgg_get_plugin_from_id($plugin_id); } do { $additional_plugins_activated = false; foreach ($plugins as $key => $plugin) { if ($plugin->isActive()) { unset($plugins[$key]); continue; } if (!$plugin->activate()) { // plugin could not be activated in this loop, maybe in the next loop continue; } $ids = array('cannot_start' . $plugin->getID(), 'invalid_and_deactivated_' . $plugin->getID()); foreach ($ids as $id) { elgg_delete_admin_notice($id); } // mark that something has changed in this loop $additional_plugins_activated = true; unset($plugins[$key]); system_message("Plugin {$plugin->getFriendlyName()} has been activated"); } if (!$additional_plugins_activated) { // no updates in this pass, break the loop break; } } while (count($plugins) > 0); if (count($plugins) > 0) { foreach ($plugins as $plugin) { $msg = $plugin->getError(); $string = $msg ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no'; register_error(elgg_echo($string, array($plugin->getFriendlyName()))); } } elgg_flush_caches(); }
function filter_settings_save($h, $t, $v, $p) { $params = get_input('params'); $modules = $params['modules']; $modules = preg_split('~\\s+~', $modules, -1, PREG_SPLIT_NO_EMPTY); $modules = array_unique($modules); foreach ($modules as $i => $module) { if (module_is_blacklisted($module)) { unset($modules[$i]); register_error("The module '{$module}' cannot be combined. It has been removed from the list."); } } $params['modules'] = implode("\n", $modules); set_input('params', $params); elgg_flush_caches(); }
/** * {@inheritdoc} */ protected function handle() { $plugins = elgg_get_plugins('active'); if (empty($plugins)) { system_message('All plugins are inactive'); return; } $ids = array_map(function (ElggPlugin $plugin) { return $plugin->getID(); }, $plugins); $ids = array_values($ids); if ($this->option('all')) { $deactivate_ids = $ids; } else { $helper = $this->getHelper('question'); $question = new ChoiceQuestion('Please select plugins you would like to deactivate (comma-separated list of indexes)', $ids); $question->setMultiselect(true); $deactivate_ids = $helper->ask($this->input, $this->output, $question); } if (empty($deactivate_ids)) { throw new RuntimeException('You must select at least one plugin'); } $plugins = []; foreach ($deactivate_ids as $plugin_id) { $plugins[] = elgg_get_plugin_from_id($plugin_id); } foreach ($plugins as $plugin) { if (!$plugin->isActive()) { continue; } if (!$plugin->deactivate()) { $msg = $plugin->getError(); $string = $msg ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no'; register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError()))); } else { system_message("Plugin {$plugin->getFriendlyName()} has been deactivated"); } } elgg_flush_caches(); }
/** * Run the upgrade process * * @return array */ public function run() { $result = array('failure' => false, 'reason' => ''); // prevent someone from running the upgrade script in parallel (see #4643) if (!$this->getUpgradeMutex()) { $result['failure'] = true; $result['reason'] = _elgg_services()->translator->translate('upgrade:locked'); return $result; } // disable the system log for upgrades to avoid exceptions when the schema changes. _elgg_services()->events->unregisterHandler('log', 'systemlog', 'system_log_default_logger'); _elgg_services()->events->unregisterHandler('all', 'all', 'system_log_listener'); // turn off time limit set_time_limit(0); if ($this->getUnprocessedUpgrades()) { $this->processUpgrades(); } _elgg_services()->events->trigger('upgrade', 'system', null); elgg_flush_caches(); $this->releaseUpgradeMutex(); return $result; }
} if ($plugin->activate()) { $activated_guids[] = $guid; $ids = array('cannot_start' . $plugin->getID(), 'invalid_and_deactivated_' . $plugin->getID()); foreach ($ids as $id) { elgg_delete_admin_notice($id); } } else { $msg = $plugin->getError(); $string = $msg ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no'; register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError()))); } } // don't regenerate the simplecache because the plugin won't be // loaded until next run. Just invalidate and let it regenerate as needed elgg_flush_caches(); if (count($activated_guids) === 1) { $url = 'admin/plugins'; $query = (string) parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY); if ($query) { $url .= "?{$query}"; } $plugin = get_entity($plugin_guids[0]); $id = $css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID()); forward("{$url}#{$id}"); } else { // forward to top of page with a failure so remove any #foo $url = $_SERVER['HTTP_REFERER']; if (strpos($url, '#')) { $url = substr(0, strpos($url, '#')); }
/** * {@inheritdoc} */ protected function handle() { elgg_flush_caches(); _elgg_services()->autoloadManager->deleteCache(); system_message(elgg_echo('admin:cache:flushed')); }