PATH:
home
/
letacommog
/
letaweb
/
protected
/
modules
/
admin
/
modules
/
store
<?php class StoreModule extends CWebModule { public $initialise; public $showMenu = false; /** * @property bool Set TRUE to enable development mode. * In development mode assets (e.g. JavaScript and CSS files) are published on * each access and options to initialise (if RbamModule::initialise is not * empty) and generate authorisation data are shown. */ public $development = false; public $defaultController = 'dashboard'; private $_cs; private $_defaultRoles; /** * Initialises the module. */ public function init() { } /** * Attach the RBAMxAuthManagerBehavior and pass the auth manager to the controller. * * @param CController controller being run * @param CAction action being run * * @return bool whether the action should be executed */ public function beforeControllerAction($controller, $action) { $authManager = Yii::app()->getAuthManager(); $authManager->defaultRoles = array_merge($authManager->defaultRoles, array( $this->authenticatedRole, $this->guestRole, )); if ($authManager instanceof CAuthManager) { $authManager->attachBehavior('authManager', array( 'class' => ($authManager instanceof CDbAuthManager ? 'RbamDbAuthManagerBehavior' : 'RbamPhpAuthManagerBehavior' ), 'module' => $this, )); } else { throw new CException(Yii::t('RbamModule.rbam', 'AuthManager component is not an instance of CAuthManager')); } $controller->authManager = $authManager; return true; } /** * Returns the default roles. * * @return array default roles */ public function getDefaultRoles() { return $this->_defaultRoles; } /** * Determine the base url from parent module(s). */ private function _setBaseUrl() { if (empty($this->baseUrl)) { $this->baseUrl = ''; $m = $this; do { $this->baseUrl = '/'.$m->getId().$this->baseUrl; $m = $m->getParentModule(); } while (!is_null($m)); } if (substr($this->baseUrl, -1) === '/') { $this->baseUrl = substr($this->baseUrl, 0, -1); } } /** * Publish jquery and JUI JavaScript files and the theme CSS file. */ private function _publishCoreAssets() { if (is_null($this->_cs)) { $this->_cs = Yii::app()->getClientScript(); } /* * Determine the JUI package installation path. * This method will identify the JavaScript root URL and theme root URL. * If they are not explicitly specified, it will publish the included JUI package * and use that to resolve the needed paths. */ if ($this->juiScriptFile === null || $this->juiThemeUrl === null) { if ($this->juiScriptUrl === null) { $this->juiScriptUrl = $this->_cs->getCoreScriptUrl().'/jui/js'; } if ($this->juiThemeUrl === null) { $this->juiThemeUrl = $this->_cs->getCoreScriptUrl().'/jui/css'; } } /* * Register jquery and JUI JavaScript files and the theme CSS file. */ if (is_string($this->juiCssFile)) { $this->_cs->registerCssFile($this->juiThemeUrl.'/'.$this->juiTheme.'/'.$this->juiCssFile); } elseif (is_array($this->juiCssFile)) { foreach ($this->juiCssFile as $cssFile) { $this->_cs->registerCssFile($this->juiThemeUrl.'/'.$this->juiTheme.'/'.$cssFile); } } $this->_cs->registerCoreScript('jquery'); $this->_cs->registerCoreScript('bbq'); if (is_string($this->juiScriptFile)) { $this->_registerScriptFile($this->juiScriptFile); } elseif (is_array($this->juiScriptFile)) { foreach ($this->juiScriptFile as $scriptFile) { $this->_cs->registerScriptFile($scriptFile); } } } /** * Publish module JavaScript and CSS files. */ private function _publishModuleAssets() { if (is_null($this->_cs)) { $this->_cs = Yii::app()->getClientScript(); } if (!is_string($this->baseScriptUrl)) { // Republish if in development mode $this->baseScriptUrl = ($this->development ? Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('rbam.assets'), false, -1, true) : Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('rbam.assets')) ); } $this->_cs->registerScriptFile($this->baseScriptUrl.'/js/jquery.rbam.js'); if ($this->cssFile !== false) { if ($this->cssFile === null) { $this->cssFile = $this->baseScriptUrl.'/css/styles.css'; } $this->_cs->registerCssFile($this->cssFile); } } /** * Registers a JavaScript file under {@link scriptUrl}. * Note that by default, the script file will be rendered at the end of a page to improve page loading speed. * * @param string $fileName JavaScript file name * @param int $position the position of the JavaScript file. Valid values include the following: * <ul> * <li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li> * <li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li> * <li>CClientScript::POS_END : the script is inserted at the end of the body section.</li> * </ul> */ private function _registerScriptFile($fileName, $position = CClientScript::POS_END) { $this->_cs->registerScriptFile($this->juiScriptUrl.'/'.$fileName, $position); } /** * Returns the version of this module. * * @return string the version of this module. */ public function getVersion() { return '1.6.1'; } /** * Returns the user with the specified id. * To handle the case of a user logged in to the Yii default application as * admin/admin or demo/demo or a similar scenario where the user is not in the * db, we use a dummy user to provide the RBAM user name. * * @param mixed the user id */ public function getUser($id) { $user = CActiveRecord::model($this->userClass)->findByPk($id); if (is_null($user) && !Yii::app()->getUser()->isGuest) { $user = CActiveRecord::model($this->userClass); $user->{$this->userNameAttribute} = Yii::app()->getUser()->id; } $user->attachBehavior('RbamUserBehavior', 'RbamUserBehavior'); return $user; } /** * Returns a CMenu item property for the module. * Call this function as an item in a list of CMenu items. * * @param array CMenu item property. Options set here override the defaults. * * @return array CMenu item(s). */ public function getMenuItem($item = array()) { $items = $this->getMenuItems(isset($item['items']) ? $item['items'] : array()); unset($item['items']); $linkOptions = array_merge( array('title' => Yii::t('RbamModule.rbam', 'Manage Roles & Assignments')), (isset($item['linkOptions']) ? $item['linkOptions'] : array()) ); unset($item['linkOptions']); return array_merge(array( 'label' => Yii::t('RbamModule.rbam', 'RBAM'), 'url' => array("{$this->baseUrl}/rbam"), 'linkOptions' => $linkOptions, 'items' => $items, ), $item); } /** * Returns an array CMenu items for the module. * * @param array CMenu items. Options set here override the defaults. * * @return array CMenu items. */ public function getMenuItems($items = array()) { $user = Yii::app()->getUser(); // return Yii::app()->getModule('admin')->getMenuItems($items); return array_merge(array( array( 'label' => Yii::t('RbamModule.rbam', 'Back'), 'url' => array('/admin/'), ), array( 'label' => Yii::t('RbamModule.rbam', 'Auth Assignments'), 'url' => array('authAssignments/index'), 'active' => $this->id === 'authAssignments', 'visible' => $user->checkAccess($this->authAssignmentsManagerRole), ), array( 'label' => Yii::t('RbamModule.rbam', 'Auth Items'), 'url' => array('authItems/index'), 'active' => $this->id === 'authItems' && $this->action->id !== 'generate', 'visible' => $user->checkAccess($this->authItemsManagerRole), 'items' => array( array( 'label' => Yii::t('RbamModule.rbam', 'Create {type}', array('{type}' => Yii::t('RbamModule.rbam', 'Role'))), 'url' => array('authItems/create', 'type' => CAuthItem::TYPE_ROLE), 'active' => $this->id === 'authItems' && $this->action->id === 'create' && strpos(Yii::app()->getRequest()->queryString, 'type='.CAuthItem::TYPE_ROLE) !== false, ), array( 'label' => Yii::t('RbamModule.rbam', 'Create {type}', array('{type}' => Yii::t('RbamModule.rbam', 'Task'))), 'url' => array('authItems/create', 'type' => CAuthItem::TYPE_TASK), 'active' => $this->id === 'authItems' && $this->action->id === 'create' && strpos(Yii::app()->getRequest()->queryString, 'type='.CAuthItem::TYPE_TASK) !== false, ), array( 'label' => Yii::t('RbamModule.rbam', 'Create {type}', array('{type}' => Yii::t('RbamModule.rbam', 'Operation'))), 'url' => array('authItems/create', 'type' => CAuthItem::TYPE_OPERATION), 'active' => $this->id === 'authItems' && $this->action->id === 'create' && strpos(Yii::app()->getRequest()->queryString, 'type='.CAuthItem::TYPE_OPERATION) !== false, ), ), ), array( 'label' => Yii::t('RbamModule.rbam', 'Generate Auth Data'), 'url' => array('authItems/generate'), 'active' => $this->id === 'authItems' && $this->action->id === 'generate', 'visible' => $this->development && $user->checkAccess($this->rbacManagerRole), ), array( 'label' => Yii::t('RbamModule.initialisation', 'Re-Initialise RBAC'), 'url' => array('rbamInitialise/initialise'), 'active' => $this->id === 'rbaminitialise', 'visible' => $this->development && !empty($this->initialise) && $user->checkAccess($this->rbacManagerRole), ), ), $items); } }
[+]
..
[+]
controllers
[+]
messages
[+]
components
[+]
views
[-] StoreModule.php
[edit]
[+]
extensions
[+]
validators
[+]
models
[+]
assets