diff options
Diffstat (limited to 'actions/admin')
21 files changed, 296 insertions, 250 deletions
diff --git a/actions/admin/delete_admin_notice.php b/actions/admin/delete_admin_notice.php new file mode 100644 index 000000000..a9c3b8758 --- /dev/null +++ b/actions/admin/delete_admin_notice.php @@ -0,0 +1,13 @@ +<?php +/** + * Removes an admin notice. + */ + +$guid = get_input('guid'); +$notice = get_entity($guid); + +if (!(elgg_instanceof($notice, 'object', 'admin_notice') && $notice->delete())) { + register_error(elgg_echo("admin:notices:could_not_delete")); +} + +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/menu/save.php b/actions/admin/menu/save.php index 3fdce8c45..66ce71082 100644 --- a/actions/admin/menu/save.php +++ b/actions/admin/menu/save.php @@ -9,12 +9,11 @@ // featured menu items $featured_names = get_input('featured_menu_names', array()); $featured_names = array_unique($featured_names); -if (in_array('', $featured_names)) { - unset($featured_names[array_search('', $featured_names)]); +if (in_array(' ', $featured_names)) { + unset($featured_names[array_search(' ', $featured_names)]); } elgg_save_config('site_featured_menu_names', $featured_names); - // custom menu items $custom_menu_titles = get_input('custom_menu_titles', array()); $custom_menu_urls = get_input('custom_menu_urls', array()); diff --git a/actions/admin/plugins/activate.php b/actions/admin/plugins/activate.php new file mode 100644 index 000000000..5234a4ca5 --- /dev/null +++ b/actions/admin/plugins/activate.php @@ -0,0 +1,59 @@ +<?php +/** + * Activate a plugin or plugins. + * + * Plugins to be activated are passed via $_REQUEST['plugin_guids'] as GUIDs. + * After activating the plugin(s), the views cache and simplecache are invalidated. + * + * @uses mixed $_GET['plugin_guids'] The GUIDs of the plugin to activate. Can be an array. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugin_guids = get_input('plugin_guids'); + +if (!is_array($plugin_guids)) { + $plugin_guids = array($plugin_guids); +} + +$activated_guids = array(); +foreach ($plugin_guids as $guid) { + $plugin = get_entity($guid); + + if (!($plugin instanceof ElggPlugin)) { + register_error(elgg_echo('admin:plugins:activate:no', array($guid))); + continue; + } + + if ($plugin->activate()) { + $activated_guids[] = $guid; + } 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_invalidate_simplecache(); +elgg_reset_system_cache(); + +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, '#')); + } + forward($url); +}
\ No newline at end of file diff --git a/actions/admin/plugins/activate_all.php b/actions/admin/plugins/activate_all.php new file mode 100644 index 000000000..4514ccbdf --- /dev/null +++ b/actions/admin/plugins/activate_all.php @@ -0,0 +1,33 @@ +<?php +/** + * Activates all specified installed and inactive plugins. + * + * All specified plugins in the mod/ directory are that aren't active are activated and the views + * cache and simplecache are invalidated. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$guids = get_input('guids'); +$guids = explode(',', $guids); + +foreach ($guids as $guid) { + $plugin = get_entity($guid); + if (!$plugin->isActive()) { + if ($plugin->activate()) { + //system_message(elgg_echo('admin:plugins:activate:yes', array($plugin->getManifest()->getName()))); + } 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 regnerate as needed +elgg_invalidate_simplecache(); +elgg_reset_system_cache(); + +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/deactivate.php b/actions/admin/plugins/deactivate.php new file mode 100644 index 000000000..354f4717d --- /dev/null +++ b/actions/admin/plugins/deactivate.php @@ -0,0 +1,53 @@ +<?php +/** + * Deactivate a plugin or plugins. + * + * Plugins to be deactivated are passed via $_REQUEST['plugin_guids'] as GUIDs. + * After deactivating the plugin(s), the views cache and simplecache are invalidated. + * + * @uses mixed $_GET['plugin_guids'] The GUIDs of the plugin to deactivate. Can be an array. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugin_guids = get_input('plugin_guids'); + +if (!is_array($plugin_guids)) { + $plugin_guids = array($plugin_guids); +} + +foreach ($plugin_guids as $guid) { + $plugin = get_entity($guid); + + if (!($plugin instanceof ElggPlugin)) { + register_error(elgg_echo('admin:plugins:deactivate:no', array($guid))); + continue; + } + + if ($plugin->deactivate()) { + //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->getManifest()->getName()))); + } else { + $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()))); + } +} + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_reset_system_cache(); + +if (count($plugin_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 = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID()); + forward("$url#$id"); +} else { + forward(REFERER); +} diff --git a/actions/admin/plugins/deactivate_all.php b/actions/admin/plugins/deactivate_all.php new file mode 100644 index 000000000..8b347a633 --- /dev/null +++ b/actions/admin/plugins/deactivate_all.php @@ -0,0 +1,33 @@ +<?php +/** + * Disable all specified installed plugins. + * + * Specified plugins in the mod/ directory are disabled and the views cache and simplecache + * are reset. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$guids = get_input('guids'); +$guids = explode(',', $guids); + +foreach ($guids as $guid) { + $plugin = get_entity($guid); + if ($plugin->isActive()) { + if ($plugin->deactivate()) { + //system_message(elgg_echo('admin:plugins:activate:yes', array($plugin->getManifest()->getName()))); + } else { + $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()))); + } + } +} + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_reset_system_cache(); + +forward(REFERER); diff --git a/actions/admin/plugins/disable.php b/actions/admin/plugins/disable.php deleted file mode 100644 index 64994423f..000000000 --- a/actions/admin/plugins/disable.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * Disable a plugin or plugins. - * - * Plugins to be disabled are passed via $_REQUEST['plugin'] as plugin ID (directory name). - * After disabling the plugin(s), the views cache and simplecache are both reset. - * - * @uses mixed $_GET['plugin'] The id (directory name) of the plugin to disable. Can be an array. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$plugin = get_input('plugin'); -if (!is_array($plugin)) { - $plugin = array($plugin); -} - -foreach ($plugin as $p) { - if (disable_plugin($p)) { - system_message(elgg_echo('admin:plugins:disable:yes', array($p))); - - elgg_delete_admin_notice('first_installation_plugin_reminder'); - } else { - register_error(elgg_echo('admin:plugins:disable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER); diff --git a/actions/admin/plugins/disableall.php b/actions/admin/plugins/disableall.php deleted file mode 100644 index 351ebf840..000000000 --- a/actions/admin/plugins/disableall.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Disable all installed plugins. - * - * All plugins in the mod/ directory are disabled and the views cache and simplecache - * are reset. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$plugins = get_installed_plugins(); - -foreach ($plugins as $p => $data) { - if (disable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:disable:yes', array($p))); - } else { - register_error(elgg_echo('admin:plugins:disable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER); diff --git a/actions/admin/plugins/enable.php b/actions/admin/plugins/enable.php deleted file mode 100644 index ebabe7bc8..000000000 --- a/actions/admin/plugins/enable.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * Enables a plugin or plugins. - * - * Plugins to be enabled are passed via $_REQUEST['plugin'] as plugin ID (directory name). - * After enabling the plugin(s), the views cache and simplecache are reset. - * - * @uses mixed $_GET['plugin'] The id (directory name) of the plugin to enable. Can be an array. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$plugin = get_input('plugin'); - -if (!is_array($plugin)) { - $plugin = array($plugin); -} - -foreach ($plugin as $p) { - if (enable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:enable:yes', array($p))); - } else { - register_error(elgg_echo('admin:plugins:enable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/enableall.php b/actions/admin/plugins/enableall.php deleted file mode 100644 index 04574f067..000000000 --- a/actions/admin/plugins/enableall.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Enables all installed plugins. - * - * All plugins in the mod/ directory are enabled and the views cache and simplecache - * are reset. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$plugins = get_installed_plugins(); - -foreach ($plugins as $p => $data) { - if (enable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:enable:yes', array($p))); - } else { - register_error(elgg_echo('admin:plugins:enable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/reorder.php b/actions/admin/plugins/reorder.php deleted file mode 100644 index 29c4a7268..000000000 --- a/actions/admin/plugins/reorder.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - * Changes the load order of a plugin. - * - * Plugin order affects priority for view, action, and page handler - * overriding as well as the order of view extensions. Higher numbers - * are loaded after lower numbers, and so receive higher priority. - * - * NOTE: When viewing the admin page (advanced plugin admin in >= 1.8) plugins - * LOWER on the page have HIGHER priority and will override views, etc - * from plugins above them. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$mod = get_input('plugin'); -$mod = str_replace('.', '', $mod); -$mod = str_replace('/', '', $mod); - -// Get the new order -$order = (int) get_input('order'); - -// Get the current plugin list -$plugins = get_plugin_list(); - -// Inject the plugin order back into the list -if ($key = array_search($mod, $plugins)) { - - unset($plugins[$key]); - while (isset($plugins[$order])) { - $order++; - } - - $plugins[$order] = $mod; -} - -// Disable -if (regenerate_plugin_list($plugins)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:reorder:yes', array($plugin))); -} else { - register_error(elgg_echo('admin:plugins:reorder:no', array($plugin))); -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/set_priority.php b/actions/admin/plugins/set_priority.php new file mode 100644 index 000000000..edd735371 --- /dev/null +++ b/actions/admin/plugins/set_priority.php @@ -0,0 +1,39 @@ +<?php +/** + * Changes the load priority of a plugin. + * + * Plugin priority affects view, action, and page handler + * overriding as well as the order of view extensions. Plugins with higher + * priority are loaded after and override plugins with lower priorities. + * + * NOTE: When viewing the plugin admin page, plugins LOWER on the page + * have HIGHER priority and will override views, etc from plugins above them. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugin_guid = get_input('plugin_guid'); +$priority = get_input('priority'); + +$plugin = get_entity($plugin_guid); + +if (!($plugin instanceof ElggPlugin)) { + register_error(elgg_echo('admin:plugins:set_priority:no', array($plugin_guid))); + forward(REFERER); +} + +if ($plugin->setPriority($priority)) { + //system_message(elgg_echo('admin:plugins:set_priority:yes', array($plugin->getManifest()->getName()))); +} else { + $msg = $plugin->getError(); + $string = ($msg) ? 'admin:plugins:set_priority:no_with_msg' : 'admin:plugins:set_priority: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 regnerate as needed +elgg_invalidate_simplecache(); +elgg_reset_system_cache(); + +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/simple_update_states.php b/actions/admin/plugins/simple_update_states.php deleted file mode 100644 index 7d01e4a46..000000000 --- a/actions/admin/plugins/simple_update_states.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * Bulk enable and disable for plugins appearing in the "simple" interface. - * - * Plugins marked as using the "simple" interface can be enabled and disabled - * en masse by passing the enabled plugins as an array of their plugin ids - * (directory names) through $_REQUEST['enabled_plugins']. All "simple" plugins - * not in this array will be disabled. - * - * Simplecache and views cache are reset. - * - * @uses array $_REQUEST['enabled_plugins'] An array of plugin ids (directory names) to enable. - * - * @since 1.8 - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$installed_plugins = get_installed_plugins(); -$enabled_plugins = get_input('enabled_plugins', array()); - -$success = TRUE; - -foreach ($installed_plugins as $plugin => $info) { - // this is only for simple plugins. - $interface_type = elgg_get_array_value('admin_interface', $info['manifest'], NULL); - if (!$interface_type || $interface_type != 'simple') { - continue; - } - - $plugin_enabled = is_plugin_enabled($plugin); - - // only effect changes to plugins not already in that state. - if ($plugin_enabled && !in_array($plugin, $enabled_plugins)) { - $success = $success && disable_plugin($plugin); - } elseif (!$plugin_enabled && in_array($plugin, $enabled_plugins)) { - $success = $success && enable_plugin($plugin); - } -} - -if ($success) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:simple_simple_success')); -} else { - register_error(elgg_echo('admins:plugins:simple_simple_fail')); -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/site/flush_cache.php b/actions/admin/site/flush_cache.php new file mode 100644 index 000000000..ebb8296c7 --- /dev/null +++ b/actions/admin/site/flush_cache.php @@ -0,0 +1,10 @@ +<?php +/** + * Flush all the caches + */ + +elgg_invalidate_simplecache(); +elgg_reset_system_cache(); + +system_message(elgg_echo('admin:cache:flushed')); +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/site/regenerate_secret.php b/actions/admin/site/regenerate_secret.php new file mode 100644 index 000000000..3112fb5f3 --- /dev/null +++ b/actions/admin/site/regenerate_secret.php @@ -0,0 +1,11 @@ +<?php +/** + * Generate a new site secret + */ + +init_site_secret(); +elgg_reset_system_cache(); + +system_message(elgg_echo('admin:site:secret_regenerated')); + +forward(REFERER); diff --git a/actions/admin/site/unlock_upgrade.php b/actions/admin/site/unlock_upgrade.php new file mode 100644 index 000000000..b625b1d26 --- /dev/null +++ b/actions/admin/site/unlock_upgrade.php @@ -0,0 +1,10 @@ +<?php +/** + * Unlocks the upgrade script + */ + +if (_elgg_upgrade_is_locked()) { + _elgg_upgrade_unlock(); +} +system_message(elgg_echo('upgrade:unlock:success')); +forward(REFERER); diff --git a/actions/admin/site/update_advanced.php b/actions/admin/site/update_advanced.php index 523c64e3e..4888b0a8d 100644 --- a/actions/admin/site/update_advanced.php +++ b/actions/admin/site/update_advanced.php @@ -9,27 +9,43 @@ * @subpackage Administration.Site */ -if (datalist_get('default_site')) { - $site = get_entity(datalist_get('default_site')); +if ($site = elgg_get_site_entity()) { if (!($site instanceof ElggSite)) { throw new InstallationException(elgg_echo('InvalidParameterException:NonElggSite')); } - $site->url = get_input('wwwroot'); + $site->url = rtrim(get_input('wwwroot', '', false), '/') . '/'; - datalist_set('path', sanitise_filepath(get_input('path'))); - datalist_set('dataroot', sanitise_filepath(get_input('dataroot'))); + datalist_set('path', sanitise_filepath(get_input('path', '', false))); + $dataroot = sanitise_filepath(get_input('dataroot', '', false)); + + // check for relative paths + if (stripos(PHP_OS, 'win') === 0) { + if (strpos($dataroot, ':') !== 1) { + $msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot)); + register_error($msg); + forward(REFERER); + } + } else { + if (strpos($dataroot, '/') !== 0) { + $msg = elgg_echo('admin:configuration:dataroot:relative_path', array($dataroot)); + register_error($msg); + forward(REFERER); + } + } + + datalist_set('dataroot', $dataroot); if (get_input('simplecache_enabled')) { - elgg_view_enable_simplecache(); + elgg_enable_simplecache(); } else { - elgg_view_disable_simplecache(); + elgg_disable_simplecache(); } - if (get_input('viewpath_cache_enabled')) { - elgg_enable_filepath_cache(); + if (get_input('system_cache_enabled')) { + elgg_enable_system_cache(); } else { - elgg_disable_filepath_cache(); + elgg_disable_system_cache(); } set_config('default_access', get_input('default_access', ACCESS_PRIVATE), $site->getGUID()); @@ -37,8 +53,6 @@ if (datalist_get('default_site')) { $user_default_access = (get_input('allow_user_default_access')) ? 1 : 0; set_config('allow_user_default_access', $user_default_access, $site->getGUID()); - set_config('view', get_input('view'), $site->getGUID()); - $debug = get_input('debug'); if ($debug) { set_config('debug', $debug, $site->getGUID()); diff --git a/actions/admin/site/update_basic.php b/actions/admin/site/update_basic.php index c809dc671..9765182cc 100644 --- a/actions/admin/site/update_basic.php +++ b/actions/admin/site/update_basic.php @@ -10,18 +10,18 @@ * @subpackage Administration.Site */ -if (datalist_get('default_site')) { - $site = get_entity(datalist_get('default_site')); +if ($site = elgg_get_site_entity()) { if (!($site instanceof ElggSite)) { throw new InstallationException(elgg_echo('InvalidParameterException:NonElggSite')); } $site->description = get_input('sitedescription'); - $site->name = get_input('sitename'); + $site->name = strip_tags(get_input('sitename')); $site->email = get_input('siteemail'); $site->save(); set_config('language', get_input('language'), $site->getGUID()); } +system_message(elgg_echo('admin:configuration:success')); forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/user/ban.php b/actions/admin/user/ban.php index a8fa57925..209ece2a0 100644 --- a/actions/admin/user/ban.php +++ b/actions/admin/user/ban.php @@ -12,7 +12,7 @@ $guid = get_input('guid'); $user = get_entity($guid); -if ($guid == get_loggedin_userid()) { +if ($guid == elgg_get_logged_in_user_guid()) { register_error(elgg_echo('admin:user:self:ban:no')); forward(REFERER); } diff --git a/actions/admin/user/delete.php b/actions/admin/user/delete.php index c6ed5b819..7cfbd0925 100644 --- a/actions/admin/user/delete.php +++ b/actions/admin/user/delete.php @@ -13,7 +13,7 @@ $guid = get_input('guid'); $user = get_entity($guid); -if ($guid == get_loggedin_userid()) { +if ($guid == elgg_get_logged_in_user_guid()) { register_error(elgg_echo('admin:user:self:delete:no')); forward(REFERER); } @@ -34,7 +34,7 @@ if (($user instanceof ElggUser) && ($user->canEdit())) { // forward to user administration if on a user's page as it no longer exists $forward = REFERER; if (strpos($_SERVER['HTTP_REFERER'], $username) != FALSE) { - $forward = "pg/admin/user/"; + $forward = "admin/users/newest"; } forward($forward); diff --git a/actions/admin/user/removeadmin.php b/actions/admin/user/removeadmin.php index 4466e925f..8cebc7078 100644 --- a/actions/admin/user/removeadmin.php +++ b/actions/admin/user/removeadmin.php @@ -9,7 +9,7 @@ $guid = get_input('guid'); $user = get_entity($guid); -if ($guid == get_loggedin_userid()) { +if ($guid == elgg_get_logged_in_user_guid()) { register_error(elgg_echo('admin:user:self:removeadmin:no')); forward(REFERER); } |
