import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
20
libs/Monkeys/Controller/Action.php
Executable file → Normal file
20
libs/Monkeys/Controller/Action.php
Executable file → Normal file
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @package Monkeys Framework
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
abstract class Monkeys_Controller_Action extends Zend_Controller_Action
|
||||
{
|
||||
/**
|
||||
@ -16,6 +24,7 @@ abstract class Monkeys_Controller_Action extends Zend_Controller_Action
|
||||
|
||||
public function init()
|
||||
{
|
||||
Zend_Registry::get('logger')->log('Route used: ' . Application::$front->getRouter()->getCurrentRouteName(), Zend_Log::DEBUG);
|
||||
$this->_config = Zend_Registry::get('config');
|
||||
$this->_settings = new Model_Settings();
|
||||
|
||||
@ -43,7 +52,9 @@ abstract class Monkeys_Controller_Action extends Zend_Controller_Action
|
||||
|
||||
$this->view->addHelperPath('libs/Monkeys/View/Helper', 'Monkeys_View_Helper');
|
||||
$this->view->setUseStreamWrapper(true);
|
||||
$this->_setScriptPaths();
|
||||
$this->_addCustomTemplatePath();
|
||||
$this->view->addBasePath(APP_DIR . '/views');
|
||||
$this->_addCustomTemplatePath();
|
||||
$this->_setBase();
|
||||
$this->view->numCols = $this->_numCols;
|
||||
|
||||
@ -59,6 +70,8 @@ abstract class Monkeys_Controller_Action extends Zend_Controller_Action
|
||||
$this->view->nextAction = '';
|
||||
}
|
||||
|
||||
$this->view->messages = $this->_helper->FlashMessenger->getMessages();
|
||||
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
$slowdown = $this->_config->environment->ajax_slowdown;
|
||||
if ($slowdown > 0) {
|
||||
@ -67,7 +80,6 @@ abstract class Monkeys_Controller_Action extends Zend_Controller_Action
|
||||
$this->_helper->layout->disableLayout();
|
||||
} else {
|
||||
$this->view->version = Application::VERSION;
|
||||
$this->view->messages = $this->_helper->FlashMessenger->getMessages();
|
||||
$this->view->loaderCombine = $this->_config->environment->YDN? 'true' : 'false';
|
||||
$this->view->loaderBase = $this->_config->environment->YDN?
|
||||
'http://yui.yahooapis.com/2.7.0/build/'
|
||||
@ -82,7 +94,7 @@ abstract class Monkeys_Controller_Action extends Zend_Controller_Action
|
||||
$this->view->title = $this->_title;
|
||||
}
|
||||
|
||||
private function _setScriptPaths()
|
||||
private function _addCustomTemplatePath()
|
||||
{
|
||||
if (($template = $this->_config->environment->template) == 'default') {
|
||||
return;
|
||||
@ -149,7 +161,7 @@ abstract class Monkeys_Controller_Action extends Zend_Controller_Action
|
||||
return parent::_redirect($url, $options);
|
||||
}
|
||||
|
||||
public function getProtocol()
|
||||
public static function getProtocol()
|
||||
{
|
||||
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
|
||||
return 'https';
|
||||
|
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @package Monkeys Framework
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
abstract class Monkeys_Controller_Error extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
@ -24,11 +32,11 @@ abstract class Monkeys_Controller_Error extends Monkeys_Controller_Action
|
||||
case 'Monkeys_BadUrlException';
|
||||
$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
|
||||
|
||||
$this->view->message = 'The URL you entered is incorrect. Please correct and try again.';
|
||||
$this->view->message = $this->_getTranslationForException($exceptionClass);
|
||||
break;
|
||||
case 'Monkeys_AccessDeniedException';
|
||||
$this->getResponse()->setRawHeader('HTTP/1.1 401 Unauthorized');
|
||||
$this->view->message = 'Access Denied - Maybe your session has expired? Try logging-in again.';
|
||||
$this->view->message = $this->_getTranslationForException($exceptionClass);
|
||||
break;
|
||||
default:
|
||||
$this->view->message = get_class($errors->exception) . '<br />' . $errors->exception->getMessage();
|
||||
@ -37,7 +45,8 @@ abstract class Monkeys_Controller_Error extends Monkeys_Controller_Action
|
||||
} else if ($this->_config->email->adminemail) {
|
||||
$mail = self::getMail($errors->exception, $this->user, $errors);
|
||||
$mail->send();
|
||||
$this->view->message .= '<br />The system administrator has been notified.';
|
||||
$this->view->message .= "<br />\n";
|
||||
$this->view->message .= 'The system administrator has been notified.';
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -110,4 +119,23 @@ EOD;
|
||||
protected function _validateTargetUser()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns translation for an exception message
|
||||
*
|
||||
* Override using your translation engine.
|
||||
*/
|
||||
protected function _getTranslationForException($ex)
|
||||
{
|
||||
switch ($ex) {
|
||||
case 'Monkeys_BadUrlException':
|
||||
return 'The URL you entered is incorrect. Please correct and try again.';
|
||||
break;
|
||||
case 'Monkeys_AccessDeniedException':
|
||||
return 'Access Denied - Maybe your session has expired? Try logging-in again.';
|
||||
break;
|
||||
default:
|
||||
return $ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
libs/Monkeys/Controller/Plugin/Auth.php
Executable file → Normal file
14
libs/Monkeys/Controller/Plugin/Auth.php
Executable file → Normal file
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @package Monkeys Framework
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Monkeys_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
private $_acl;
|
||||
@ -49,18 +57,18 @@ class Monkeys_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
$resource = $request->getModuleName() . '_' . $request->getControllerName();
|
||||
|
||||
if (!$this->_acl->has($resource)) {
|
||||
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";
|
||||
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";exit;
|
||||
throw new Monkeys_BadUrlException($this->getRequest()->getRequestUri());
|
||||
}
|
||||
|
||||
// if an admin is not allowed for this action, then the action doesn't exist
|
||||
if (!$this->_acl->isAllowed(Users_Model_User::ROLE_ADMIN, $resource, $request->getActionName())) {
|
||||
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";
|
||||
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";exit;
|
||||
throw new Monkeys_BadUrlException($this->getRequest()->getRequestUri());
|
||||
}
|
||||
|
||||
if (!$this->_acl->isAllowed($user->role, $resource, $request->getActionName())) {
|
||||
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";
|
||||
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";exit;
|
||||
throw new Monkeys_AccessDeniedException();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user