Phundament App Class Reference
  • Package
  • Class
  • Tree

Packages

  • bootstrap
    • widgets
      • input
  • Image
  • None
  • p3admin
  • p3extensions
    • behaviors
    • commands
    • components
    • helpers
    • widgets
  • p3media
    • actions
    • controllers
    • models
  • p3pages
    • models
  • p3widgets
    • components
    • models
  • PHP
  • system
    • db
      • ar
    • gii
    • web
      • auth
      • helpers
      • widgets
  • yiiext
    • widgets
      • fancybox
      • lipsum
  • zii
    • widgets
      • grid

Classes

  • ActivationController
  • AdminController
  • AssignmentController
  • AssignmentForm
  • AuthChildForm
  • AuthItemController
  • AuthItemForm
  • BaseP3Widget
  • BaseP3WidgetMeta
  • BaseP3WidgetTranslation
  • Bootstrap
  • CImageComponent
  • CKEditor
  • CodeProvider
  • DefaultController
  • EChosen
  • EDbMigration
  • EditableField
  • EditableSaver
  • EMigrateCommand
  • ESelect2
  • EUserFlash
  • FullCrudFieldProvider
  • GenerateForm
  • IdentificationColumnValidator
  • InstallController
  • JSONEditorView
  • JuiJSONEditorInput
  • LoginController
  • LogoutController
  • Metadata
  • P3CrudFieldProvider
  • P3MediaController
  • P3MediaMetaController
  • P3MediaSelect
  • P3PageController
  • P3PageMetaController
  • P3PageTranslationController
  • P3Widget
  • P3WidgetController
  • P3WidgetMetaController
  • P3WidgetTranslation
  • P3WidgetTranslationController
  • ProfileController
  • ProfileFieldController
  • RAuthItemBehavior
  • RAuthItemChildDataProvider
  • RAuthItemDataProvider
  • RAuthItemParentDataProvider
  • RAuthorizer
  • RController
  • RDbAuthManager
  • RecoveryController
  • RegistrationController
  • RegistrationForm
  • RGenerator
  • Rights
  • RightsFilter
  • RightsModule
  • RInstaller
  • RPermissionDataProvider
  • RUserBehavior
  • RWebUser
  • UActiveForm
  • UploadHandler
  • UserChangePassword
  • UserController
  • UserIdentity
  • UserLogin
  • UserModule
  • UserRecoveryForm
  • UWdropDownDep
  • UWfile
  • UWjuiAutoComplete
  • UWjuidate
  • UWrelBelongsTo
  • WebUserBehavior
  1 <?php
  2 /**
  3 * Rights module class file.
  4 *
  5 * @author Christoffer Niska <cniska@live.com>
  6 * @copyright Copyright &copy; 2010 Christoffer Niska
  7 * @version 1.3.0
  8 * 
  9 * DO NOT CHANGE THE DEFAULT CONFIGURATION VALUES!
 10 * 
 11 * You may overload the module configuration values in your rights-module 
 12 * configuration like so:
 13 * 
 14 * 'modules'=>array(
 15 *     'rights'=>array(
 16 *         'userNameColumn'=>'name',
 17 *         'flashSuccessKey'=>'success',
 18 *         'flashErrorKey'=>'error',
 19 *     ),
 20 * ),
 21 */
 22 class RightsModule extends CWebModule
 23 {
 24     /**
 25     * @property string the name of the role with superuser privileges.
 26     */
 27     public $superuserName = 'Admin';
 28     /**
 29     * @property string the name of the guest role.
 30     */
 31     public $authenticatedName = 'Authenticated';
 32     /**
 33     * @property string the name of the user model class.
 34     */
 35     public $userClass = 'User';
 36     /**
 37     * @property string the name of the id column in the user table.
 38     */
 39     public $userIdColumn = 'id';
 40     /**
 41     * @property string the name of the username column in the user table.
 42     */
 43     public $userNameColumn = 'username';
 44     /**
 45     * @property boolean whether to enable business rules.
 46     */
 47     public $enableBizRule = true;
 48     /**
 49     * @property boolean whether to enable data for business rules.
 50     */
 51     public $enableBizRuleData = false;
 52     /**
 53     * @property boolean whether to display authorization items description 
 54     * instead of name it is set.
 55     */
 56     public $displayDescription = true;
 57     /**
 58     * @property string the flash message key to use for success messages.
 59     */
 60     public $flashSuccessKey = 'RightsSuccess';
 61     /**
 62     * @property string the flash message key to use for error messages.
 63     */
 64     public $flashErrorKey = 'RightsError';
 65     /**
 66     * @property boolean whether to install rights when accessed.
 67     */
 68     public $install = false;
 69     /**
 70     * @property string the base url to Rights. Override when module is nested.
 71     */
 72     public $baseUrl = '/rights';
 73     /**
 74     * @property string the path to the layout file to use for displaying Rights.
 75     */
 76     public $layout = 'rights.views.layouts.main';
 77     /**
 78     * @property string the path to the application layout file.
 79     */
 80     public $appLayout = 'application.views.layouts.main';
 81     /**
 82     * @property string the style sheet file to use for Rights.
 83     */
 84     public $cssFile;
 85     /**
 86     * @property boolean whether to enable debug mode.
 87     */
 88     public $debug = false;
 89 
 90     private $_assetsUrl;
 91 
 92     /**
 93     * Initializes the "rights" module.
 94     */
 95     public function init()
 96     {
 97         // Set required classes for import.
 98         $this->setImport(array(
 99             'rights.components.*',
100             'rights.components.behaviors.*',
101             'rights.components.dataproviders.*',
102             'rights.controllers.*',
103             'rights.models.*',
104         ));
105 
106         // Set the required components.
107         $this->setComponents(array(
108             'authorizer'=>array(
109                 'class'=>'RAuthorizer',
110                 'superuserName'=>$this->superuserName,
111             ),
112             'generator'=>array(
113                 'class'=>'RGenerator',
114             ),
115         ));
116 
117         // Normally the default controller is Assignment.
118         $this->defaultController = 'assignment';
119 
120         // Set the installer if necessary.
121         if( $this->install===true )
122         {
123             $this->setComponents(array(
124                 'installer'=>array(
125                     'class'=>'RInstaller',
126                     'superuserName'=>$this->superuserName,
127                     'authenticatedName'=>$this->authenticatedName,
128                     'guestName'=>Yii::app()->user->guestName,
129                     'defaultRoles'=>Yii::app()->authManager->defaultRoles,
130                 ),
131             ));
132 
133             // When installing we need to set the default controller to Install.
134             $this->defaultController = 'install';
135         }
136     }
137 
138     /**
139     * Registers the necessary scripts.
140     */
141     public function registerScripts()
142     {
143         // Get the url to the module assets
144         $assetsUrl = $this->getAssetsUrl();
145 
146         // Register the necessary scripts
147         $cs = Yii::app()->getClientScript();
148         $cs->registerCoreScript('jquery');
149         $cs->registerCoreScript('jquery.ui');
150         $cs->registerScriptFile($assetsUrl.'/js/rights.js');
151         $cs->registerCssFile($assetsUrl.'/css/core.css');
152 
153         // Make sure we want to register a style sheet.
154         if( $this->cssFile!==false )
155         {
156             // Default style sheet is used unless one is provided.
157             if( $this->cssFile===null )
158                 $this->cssFile = $assetsUrl.'/css/default.css';
159             else
160                 $this->cssFile = Yii::app()->request->baseUrl.$this->cssFile;
161 
162             // Register the style sheet
163             $cs->registerCssFile($this->cssFile);
164         }
165     }
166 
167     /**
168     * Publishes the module assets path.
169     * @return string the base URL that contains all published asset files of Rights.
170     */
171     public function getAssetsUrl()
172     {
173         if( $this->_assetsUrl===null )
174         {
175             $assetsPath = Yii::getPathOfAlias('rights.assets');
176 
177             // We need to republish the assets if debug mode is enabled.
178             if( $this->debug===true )
179                 $this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath, false, -1, true);
180             else
181                 $this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath);
182         }
183 
184         return $this->_assetsUrl;
185     }
186 
187     /**
188     * @return RightsAuthorizer the authorizer component.
189     */
190     public function getAuthorizer()
191     {
192         return $this->getComponent('authorizer');
193     }
194 
195     /**
196     * @return RightsInstaller the installer component.
197     */
198     public function getInstaller()
199     {
200         return $this->getComponent('installer');
201     }
202 
203     /**
204     * @return RightsGenerator the generator component.
205     */
206     public function getGenerator()
207     {
208         return $this->getComponent('generator');
209     }
210 
211     /**
212     * @return the current version.
213     */
214     public function getVersion()
215     {
216         return '1.3.0';
217     }
218 }
219 
Phundament App Class Reference API documentation generated by ApiGen 2.8.0