/** * Delete the user id from the session */ public function forget() { // is this user acting as another user? if (isset($_SESSION['sudo'])) { // if so, remove the sudo token, but don't log out // the user unset($_SESSION['sudo']); Utils::redirect(Site::get_url('admin')); } ACL::clear_caches(); Plugins::act('user_forget', $this); Session::clear_userid($_SESSION['user_id']); unset($_SESSION['user_id']); $home = Options::get('base_url'); Utils::redirect(Site::get_url('habari')); }
public function activate_plugins() { // extract checked plugin IDs from $_POST $plugin_ids = array(); foreach ( $_POST as $id => $activate ) { if ( preg_match( '/plugin_\w+/u', $id ) && $activate ) { $id = substr( $id, 7 ); $plugin_ids[] = $id; } } // set the user_id in the session in case plugin activation methods need it if ( ! $u = User::get_by_name( $this->handler_vars['admin_username'] ) ) { // @todo die gracefully die( _t( 'No admin user found' ) ); } $u->remember(); // loop through all plugins to find matching plugin files $plugin_files = Plugins::list_all(); foreach ( $plugin_files as $file ) { $id = Plugins::id_from_file( $file ); if ( in_array( $id, $plugin_ids ) ) { Plugins::activate_plugin( $file ); } } // unset the user_id session variable Session::clear_userid( $_SESSION['user_id'] ); unset( $_SESSION['user_id'] ); }
public function activate_plugins() { // extract checked plugin IDs from $_POST $plugin_ids = array(); foreach ($this->handler_vars as $id => $activate) { if (preg_match('/plugin_([a-f0-9]{8})/u', $id, $matches) && $activate) { $plugin_ids[] = $matches[1]; } elseif (preg_match('/plugin_(.+)/u', $id, $matches) && $activate) { $plugin_ids[] = $matches[1]; } } if (count($plugin_ids) == 0) { return; } // set the user_id in the session in case plugin activation methods need it if (!($u = User::get_by_name($this->handler_vars['admin_username']))) { // @todo die gracefully die(_t('No admin user found')); } $u->remember(); // loop through all plugins to find matching plugin files $plugin_files = Plugins::list_all(); foreach ($plugin_files as $file) { if (in_array(basename($file), $plugin_ids)) { Plugins::activate_plugin($file); continue; } $id = Plugins::id_from_file($file); if (in_array($id, $plugin_ids)) { Plugins::activate_plugin($file); } } // unset the user_id session variable Session::clear_userid($_SESSION['user_id']); unset($_SESSION['user_id']); }
/** * Delete the user id from the session * @param boolean $redirect Redirect the user to base_url after destroying session? */ public function forget($redirect = true) { // if the user is not actually logged in, just return so we don't throw any errors later if ($this->loggedin != true) { return; } // is this user acting as another user? if (isset($_SESSION['sudo'])) { // if so, remove the sudo token, but don't log out // the user unset($_SESSION['sudo']); if ($redirect) { Utils::redirect(Site::get_url('admin')); } else { // we want to return, not continue processing, or we'd log out the user too return; } } ACL::clear_caches(); Plugins::act('user_forget', $this); Session::clear_userid($_SESSION['user_id']); // then destroy the entire session Session::destroy(); if ($redirect) { Utils::redirect(Site::get_url('site')); } }