Skip to content
Snippets Groups Projects
Select Git revision
  • aa72efb204287848a56a74e90dd30553277c2abf
  • master default
  • shib-cas
3 results

Authorize.php

Blame
  • Authorize.php 1.14 KiB
    <?php
    /**
     * Plugin to check a user's authorization
     *
     * @copyright  2006 New Media Center - University of Nebraska Lincoln
     * @license    http://www.gnu.org/gpl.txt GPL
     * @version    Release: 0.0.1
     * @link       http://nmc.unl.edu/
     * @since      Class available since Release 0.0.1
     */
    
    class Nmc_Controller_Action_Plugin_Authorize implements Nmc_Controller_Action_Plugin_Interface
    {
    
        public function preAction(Nmc_Controller_Action $controller,
                                  Zend_Controller_Dispatcher_Token $action)
        {
            $authorized = false;
            if(!$controller->authorize()) {
                $action->setActionName('unauthorized');
            }
        }
    
        public function postAction(Nmc_Controller_Action $controller,
                                   Zend_Controller_Dispatcher_Token $action)
        {
            //do nothing
        }
    
        public function authorize()
        {
            return Nmc_User::getInstance()->isLoggedIn();
        }
    
        public function unauthorizedAction()
        {
            header('HTTP/1.0 403 Forbidden');
            $out = new Nmc_View();
            $out->page = '403';
            $out->title = '403 Access Denied';
            echo $out->render();
        }
    
    }