From: <gem...@li...> - 2011-10-17 12:03:16
|
Revision: 106 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=106&view=rev Author: mennodekker Date: 2011-10-17 12:03:09 +0000 (Mon, 17 Oct 2011) Log Message: ----------- Fixed #17: Implement maintenance mode where only superadmin are allowed to login Modified Paths: -------------- trunk/library/classes/Gems/Default/ProjectInformationAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-17 11:22:46 UTC (rev 105) +++ trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-17 12:03:09 UTC (rev 106) @@ -135,6 +135,17 @@ $this->_showTable($this->_('Version information'), $data); } + public function maintenanceAction() + { + $lockFile = GEMS_ROOT_DIR . '/var/settings/lock.txt'; + if(file_exists($lockFile)) { + unlink($lockFile); + } else { + touch($lockFile); + } + $this->_forward('index'); + } + public function phpAction() { $this->html->h2($this->_('Server PHP Info')); Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-17 11:22:46 UTC (rev 105) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-17 12:03:09 UTC (rev 106) @@ -300,6 +300,7 @@ $page->addAction($this->_('PHP'), null, 'php'); $page->addAction($this->_('Project'), null, 'project'); $page->addAction($this->_('Session'), null, 'session'); + $page->addAction($this->_('Maintenance mode'), 'pr.maintenance', 'maintenance'); return $page; } Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-10-17 11:22:46 UTC (rev 105) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-10-17 12:03:09 UTC (rev 106) @@ -348,6 +348,16 @@ return null; } + /** + * Add an action to the current subMenuItem + * + * @param string $label The label to display for the menu item + * @param string $privilege The privilege for the item + * @param string $controller What controller to use + * @param string $action The name of the action + * @param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only' + * @return Gems_Menu_SubMenuItem + */ public function addAction($label, $privilege = null, $action = 'index', array $other = array()) { $other['label'] = $label; Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-10-17 11:22:46 UTC (rev 105) +++ trunk/library/classes/GemsEscort.php 2011-10-17 12:03:09 UTC (rev 106) @@ -1519,6 +1519,25 @@ $this->menu = $this->getLoader()->createMenu($this); $this->_updateVariable('menu'); + /** + * Check if we are in maintenance mode or not. This is triggeren by a file in the var/settings + * directory with the name lock.txt + */ + if(file_exists(GEMS_ROOT_DIR . '/var/settings/lock.txt')) { + if ($this->session->user_id && $this->session->user_role !== 'super') { + //Still allow logoff so we can relogin as super + if (!('index' == $request->getControllerName() && 'logoff' == $request->getActionName())) { + $this->setError( + $this->_('Please check back later.'), + 401, + $this->_('System is in maintenance mode')); + } + } else { + $this->getMessenger()->addMessage($this->_('System is in maintenance mode')); + MUtil_Echo::r($this->_('System is in maintenance mode')); + } + } + // Gems does not use index/index if (('index' == $request->getControllerName()) && ('index' == $request->getActionName())) { // Instead Gems routes to the first available menu item when this is the request target This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |