本文整理汇总了PHP中Roles类的典型用法代码示例。如果您正苦于以下问题:PHP Roles类的具体用法?PHP Roles怎么用?PHP Roles使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Roles类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/** The constructor
* @access public
* @param array $options
* @return void
*/
public function __construct(array $options = null)
{
parent::__construct($options);
$roles = new Roles();
$role_options = $roles->getRoles();
$inst = new Institutions();
$inst_options = $inst->getInsts();
$projecttypes = new ProjectTypes();
$projectype_list = $projecttypes->getTypes();
$this->setName('emailsearch');
ZendX_JQuery::enableForm($this);
$message = new Zend_Form_Element_Textarea('messageToUser');
$message->setLabel('Message to user: ')->setRequired(true)->addFilters(array('StringTrim', 'WordChars', 'BasicHtml', 'EmptyParagraph'))->setAttribs(array('rows' => 10))->addFilter('BasicHtml')->addErrorMessage('You must enter a message to your recipient.');
$fullname = new Zend_Form_Element_Text('fullname');
$fullname->setLabel('Send this to: ')->addFilters(array('StringTrim', 'StripTags', 'Purifier'))->setAttrib('size', 30);
$email = $this->addElement('text', 'email', array('label' => 'Their email Address', 'size' => '30'))->email;
$email->addValidator('EmailAddress')->addFilters(array('StringTrim', 'StripTags', 'StringToLower'))->setRequired(true)->addErrorMessage('Please enter a valid address!');
//Submit button
$submit = new Zend_Form_Element_Submit('submit');
$hash = new Zend_Form_Element_Hash('csrf');
$hash->setValue($this->_salt)->setTimeout(60);
$this->addElement($hash);
$this->addElements(array($fullname, $submit, $message));
$this->addDisplayGroup(array('fullname', 'email', 'messageToUser'), 'details');
$this->details->setLegend('Details: ');
$this->addDisplayGroup(array('submit'), 'buttons');
parent::init();
}
示例2: __construct
function __construct($role_id, $locale_code = "en-us", $config = null, $restricted = null)
{
// TODO: finish changing this into a params array being passed in
// $this->role_id = $params['role_id'];
// $this->locale_code = $params['locale_code'];
$this->role_id = $role_id;
$this->locale_code = $locale_code;
if (is_array($this->role_id))
{
$all_roles = $this->role_id;
}
else
{
$all_roles = array($this->role_id);
}
$roles_table = new Roles();
foreach ($all_roles as $role)
{
$all_roles = array_merge($all_roles, $roles_table->getAllAncestors($role));
}
$this->all_roles = array_unique($all_roles);
return parent::__construct($config);
}
示例3: isAllowed
static function isAllowed($resource, $module = "default", $username = null)
{
$users_roles_table = new UsersRoles();
$user_roles = array();
$roles_table = new Roles();
if (!is_null($username)) {
$users_roles_db = $users_roles_table->fetchAll($users_roles_table->select()->where("username = ?", $username));
$user_roles = array();
if (count($users_roles_db) > 0) {
foreach ($users_roles_db as $role) {
$user_roles[] = $role->role_id;
}
}
} else {
$user_roles = array($roles_table->getIdByShortname("guest"));
}
$resource_name = $module . "-@@EXTRA-" . $resource;
$out = false;
if (Zend_Registry::isRegistered('acl')) {
$acl = Zend_Registry::get('acl');
if ($acl->has($resource_name)) {
foreach ($user_roles as $role) {
if ($acl->isAllowed($role, $resource_name)) {
$out = true;
}
}
}
}
return $out;
}
示例4: __construct
public function __construct($options = null)
{
parent::__construct($options);
$roles = new Roles();
$role_options = $roles->getRoles();
$inst = new Institutions();
$inst_options = $inst->getInsts();
$projecttypes = new ProjectTypes();
$projectype_list = $projecttypes->getTypes();
$this->setName('emailsearch');
ZendX_JQuery::enableForm($this);
$decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label'), array('HtmlTag', array('tag' => 'li')));
$message = new Zend_Form_Element_Textarea('messageToUser');
$message->setLabel('Message to user: ')->setRequired(true)->addFilters(array('StringTrim', 'WordChars', 'BasicHtml', 'EmptyParagraph'))->setAttribs(array('rows' => 10))->addFilter('BasicHtml')->addErrorMessage('You must enter a message to your recipient.');
$fullname = new Zend_Form_Element_Text('fullname');
$fullname->setLabel('Send this to: ')->addFilters(array('StringTrim', 'StripTags'))->addValidator('Alnum', false, array('allowWhiteSpace' => true))->setAttrib('size', 30)->setDecorators($decorators);
$email = $this->addElement('text', 'email', array('label' => 'Their email Address', 'size' => '30'))->email;
$email->addValidator('EmailAddress')->addFilters(array('StringTrim', 'StripTags', 'StringToLower'))->setRequired(true)->addErrorMessage('Please enter a valid address!');
$email->setDecorators($decorators);
//Submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submit')->setAttrib('class', 'large')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->setLabel('Send to a friend');
$hash = new Zend_Form_Element_Hash('csrf');
$hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(60);
$this->addElement($hash);
$this->addElements(array($fullname, $submit, $message));
$this->addDisplayGroup(array('fullname', 'email', 'messageToUser'), 'details')->removeDecorator('HtmlTag');
$this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul'))));
$this->details->removeDecorator('DtDdWrapper');
$this->details->removeDecorator('HtmlTag');
$this->details->setLegend('Details: ');
$this->addDisplayGroup(array('submit'), 'submit');
}
示例5: editsystemroleAction
/** Edit a system role
*/
public function editsystemroleAction()
{
$form = new SystemRoleForm();
$this->view->form = $form;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$roles = new Roles();
$updateData = array('role' => $form->getValue('role'), 'description' => $form->getValue('description'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms());
$where = array();
$where[] = $roles->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
$update = $roles->update($updateData, $where);
$this->_flashMessenger->addMessage($form->getValue('role') . '\'s details updated.');
$this->_redirect('/admin/systemroles/');
} else {
$form->populate($formData);
}
} else {
// find id is expected in $params['id']
$id = (int) $this->_request->getParam('id', 0);
if ($id > 0) {
$roles = new Roles();
$roles = $roles->fetchRow('id=' . $id);
$form->populate($roles->toArray());
}
}
}
示例6: init
/** Initialise the form
* @access public
* @return void
*/
public function init()
{
$roles = new Roles();
$role_options = $roles->getRoles();
$inst = new Institutions();
$inst_options = $inst->getInsts();
$username = $this->addElement('text', 'username', array('label' => 'Username: '))->username;
$username->addFilters(array('StripTags', 'StringTrim'))->setRequired(true);
$firstName = $this->addElement('text', 'first_name', array('label' => 'First Name', 'size' => '30'))->first_name;
$firstName->setRequired(true)->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addErrorMessage('You must enter a firstname');
$lastName = $this->addElement('text', 'last_name', array('label' => 'Last Name', 'size' => '30'))->last_name;
$lastName->setRequired(true)->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addErrorMessage('You must enter a surname');
$preferred_name = $this->addElement('text', 'preferred_name', array('label' => 'Preferred Name: ', 'size' => '30'))->preferred_name;
$preferred_name->setRequired(true)->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addErrorMessage('You must enter your preferred name');
$fullname = $this->addElement('text', 'fullname', array('label' => 'Full name: ', 'size' => '30'))->fullname;
$fullname->setRequired(true)->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addErrorMessage('You must enter your preferred name');
$email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email;
$email->addValidator('EmailAddress')->addFilters(array('StripTags', 'StringTrim', 'StringToLower'))->setRequired(true)->addErrorMessage('Please enter a valid address!');
$password = $this->addElement('password', 'password', array('label' => 'Change password: ', 'size' => '30'))->password;
$password->setRequired(false);
$institution = $this->addElement('select', 'institution', array('label' => 'Recording institution: '))->institution;
$institution->addMultiOptions(array(null => 'Choose institution', 'Available institutions' => $inst_options))->setAttrib('class', 'input-xlarge selectpicker show-menu-arrow');
$canRecord = $this->addElement('checkbox', 'canRecord', array('label' => 'Allowed to record: '))->canRecord;
$role = $this->addElement('select', 'role', array('label' => 'Site role: '))->role;
$role->addMultiOptions(array(null => 'Choose a role', 'Available roles' => $role_options))->setAttrib('class', 'input-medium selectpicker show-menu-arrow');
$person = $this->addElement('text', 'person', array('label' => 'Personal details attached: '))->person;
$peopleID = $this->addElement('hidden', 'peopleID', array())->peopleID;
$submit = new Zend_Form_Element_Submit('submit');
$this->addElement($submit);
$this->addDisplayGroup(array('username', 'first_name', 'last_name', 'fullname', 'preferred_name', 'email', 'institution', 'role', 'password', 'person', 'peopleID', 'canRecord'), 'userdetails');
$this->addDisplayGroup(array('submit'), 'buttons');
$this->setLegend('Edit account details: ');
parent::init();
}
示例7: init
public function init()
{
$required = true;
$roles = new Roles();
$role_options = $roles->getRoles();
$inst = new Institutions();
$inst_options = $inst->getInsts();
$this->setAction($this->_actionUrl)->setMethod('post')->setAttrib('id', 'accountform');
$this->clearDecorators();
$this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate');
$this->addPrefixPath('Pas_Form_Element', 'Pas/Form/Element/', 'element');
$decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'prepend', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li')));
$username = $this->addElement('text', 'username', array('label' => 'Username: '))->username;
$username->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->setRequired(true);
$firstName = $this->addElement('text', 'first_name', array('label' => 'First Name', 'size' => '30'))->first_name;
$firstName->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true))->addErrorMessage('You must enter a firstname');
$firstName->setDecorators($decorators);
$lastName = $this->addElement('text', 'last_name', array('label' => 'Last Name', 'size' => '30'))->last_name;
$lastName->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true))->addErrorMessage('You must enter a surname');
$lastName->setDecorators($decorators);
$fullname = $this->addElement('text', 'fullname', array('label' => 'Preferred Name: ', 'size' => '30'))->fullname;
$fullname->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Alnum', false, array('allowWhiteSpace' => true))->addErrorMessage('You must enter your preferred name');
$fullname->setDecorators($decorators);
$email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email;
$email->addValidator('EmailAddress')->addFilters(array('StripTags', 'StringTrim', 'StringToLower'))->setRequired(true)->addErrorMessage('Please enter a valid address!');
$email->setDecorators($decorators);
$password = $this->addElement('password', 'password', array('label' => 'Change password: ', 'size' => '30'))->password;
$password->setRequired(false);
$password->setDecorators($decorators);
$institution = $this->addElement('select', 'institution', array('label' => 'Recording institution: '))->institution;
$institution->setDecorators($decorators);
$institution->addMultiOptions(array(NULL => NULL, 'Choose institution' => $inst_options));
$role = $this->addElement('select', 'role', array('label' => 'Site role: '))->role;
$role->setDecorators($decorators);
$role->addMultiOptions(array(NULL => NULL, 'Choose role' => $role_options));
$person = $this->addElement('text', 'person', array('label' => 'Personal details attached: '))->person;
$person->setDecorators($decorators);
$peopleID = $this->addElement('hidden', 'peopleID', array())->peopleID;
$peopleID->setDecorators($decorators);
$submit = new Zend_Form_Element_Submit('submit');
$submit->clearDecorators();
$submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit'))));
$submit->setAttrib('class', 'large');
$this->addElement($submit);
$hash = new Zend_Form_Element_Hash('csrf');
$hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(60);
$this->addElement($hash);
$this->addDisplayGroup(array('username', 'first_name', 'last_name', 'fullname', 'email', 'institution', 'role', 'password', 'person', 'peopleID'), 'userdetails');
$this->addDecorator('FormElements')->addDecorator(array('ListWrapper' => 'HtmlTag'), array('tag' => 'div'))->addDecorator('FieldSet')->addDecorator('Form');
$this->userdetails->removeDecorator('DtDdWrapper');
$this->userdetails->removeDecorator('FieldSet');
$this->userdetails->addDecorator(array('DtDdWrapper' => 'HtmlTag'), array('tag' => 'ul'));
$this->addDisplayGroup(array('submit'), 'submit');
$this->setLegend('Edit account details: ');
}
示例8: __construct
public function __construct($options = null)
{
parent::__construct($options);
$roles = new Roles();
$role_options = $roles->getRoles();
$inst = new Institutions();
$inst_options = $inst->getInsts();
$projecttypes = new ProjectTypes();
$projectype_list = $projecttypes->getTypes();
$this->setName('acceptupgrades');
ZendX_JQuery::enableForm($this);
$decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label'), array('HtmlTag', array('tag' => 'li')));
$level = new Zend_Form_Element_Select('level');
$level->setLabel('Level of research: ')->setRequired(true)->addMultiOptions(array(NULL => NULL, 'Choose type of research' => $projectype_list))->setDecorators($decorators)->addFilter('StripTags')->addFilter('StringTrim')->addErrorMessage('You must set the level of research');
$title = new Zend_Form_Element_Text('title');
$title->setLabel('Project title: ')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('size', 60)->addErrorMessage('This project needs a title.')->setDecorators($decorators);
$researchOutline = new Pas_Form_Element_RTE('researchOutline');
$researchOutline->setLabel('Research outline: ')->setRequired(true)->setAttrib('rows', 10)->setAttrib('cols', 40)->setAttrib('Height', 400)->setAttrib('ToolbarSet', 'Finds')->addFilter('StringTrim')->addFilter('BasicHtml')->addFilter('EmptyParagraph')->addFilter('WordChars')->addErrorMessage('Outline must be present.');
$reference = new Zend_Form_Element_Text('reference');
$reference->setLabel('Referee\'s name: ')->setAttrib('size', 30)->addFilter('StringTrim')->addFilter('StripTags')->setDecorators($decorators);
$referenceEmail = new Zend_Form_Element_Text('referenceEmail');
$referenceEmail->setLabel('Referee\'s email address: ')->setAttrib('size', 30)->addValidator('EmailAddress')->addFilter('StringToLower')->addFilter('StringTrim')->addFilter('StripTags')->setDecorators($decorators);
$message = new Pas_Form_Element_RTE('message');
$message->setLabel('Message to user: ')->setRequired(true)->setAttrib('rows', 10)->setAttrib('cols', 40)->setAttrib('Height', 400)->setAttrib('ToolbarSet', 'Finds')->addFilter('StringTrim')->addFilter('BasicHtml')->addFilter('EmptyParagraph')->addFilter('WordChars')->addErrorMessage('You must enter a message for the user to know they have been approved.');
$fullname = new Zend_Form_Element_Text('fullname');
$fullname->setLabel('Fullname: ')->setAttrib('size', 30)->addFilter('StringTrim')->addFilter('StripTags')->setDecorators($decorators);
$institution = $this->addElement('select', 'institution', array('label' => 'Recording institution: '))->institution;
$institution->setDecorators($decorators)->addMultiOptions(array(NULL => NULL, 'Choose institution' => $inst_options));
$role = $this->addElement('select', 'role', array('label' => 'Site role: '))->role;
$role->setDecorators($decorators);
$role->addMultiOptions(array(NULL => NULL, 'Choose role' => $role_options));
$role->removeMultiOption('admin');
$startDate = new ZendX_JQuery_Form_Element_DatePicker('startDate');
$startDate->setLabel('Start date of project: ')->setAttrib('size', 12)->setJQueryParam('dateFormat', 'yy-mm-dd')->addFilter('StringTrim')->addFilter('StripTags')->addValidator('Date')->setRequired(false)->addErrorMessage('You must enter a valid start date for this project');
$endDate = new ZendX_JQuery_Form_Element_DatePicker('endDate');
$endDate->setLabel('End date of project: ')->addValidator('Date')->addFilter('StringTrim')->addFilter('StripTags')->setJQueryParam('dateFormat', 'yy-mm-dd')->setAttrib('size', 12)->setRequired(false)->addErrorMessage('You must enter a valid end date for this project');
$email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email;
$email->addValidator('emailAddress')->setRequired(true)->addFilter('StringToLower')->addErrorMessage('Please enter a valid address!')->setDecorators($decorators);
$already = new Zend_Form_Element_Radio('already');
$already->setLabel('Is your topic already listed on our research register?: ')->addMultiOptions(array(1 => 'Yes it is', 0 => 'No it isn\'t'))->setRequired(true)->setOptions(array('separator' => ''))->setDecorators($decorators);
$insert = new Zend_Form_Element_Checkbox('insert');
$insert->setLabel('Insert details into research register: ')->setCheckedValue(1)->setDecorators($decorators);
$valid = new Zend_Form_Element_Radio('higherLevel');
$valid->setLabel('Approve?: ')->addMultiOptions(array(1 => 'Unauthorised', 0 => 'Authorised'))->setRequired(true)->setOptions(array('separator' => ''))->setDecorators($decorators);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submit')->setAttrib('class', 'large')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag');
$this->addElements(array($reference, $referenceEmail, $researchOutline, $startDate, $endDate, $fullname, $valid, $level, $title, $submit, $already, $insert, $message));
$this->addDisplayGroup(array('fullname', 'username', 'email', 'institution', 'level', 'role', 'reference', 'referenceEmail', 'message', 'researchOutline', 'title', 'startDate', 'endDate', 'already', 'higherLevel', 'insert'), 'details')->removeDecorator('HtmlTag');
$this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul'))));
$this->details->removeDecorator('DtDdWrapper');
$this->details->removeDecorator('HtmlTag');
$this->details->setLegend('Details: ');
$this->addDisplayGroup(array('submit'), 'submit');
}
示例9: getRoles
public function getRoles()
{
$data = array();
$roles = new Roles();
foreach ($roles->findAll(array('select' => 'code, id')) as $value_r) {
foreach (Yii::app()->authManager->roles as $value) {
if (strtolower(trim($value->name)) == strtolower(trim($value_r->code))) {
$data[$value_r->id] = $value_r->code;
}
}
}
return $data;
}
示例10: display_value
/**
* Static function to display the data in detail view
* @param string $value
*/
public static function display_value($value)
{
if ($value != '') {
$do_roles = new Roles();
$roles_data = $do_roles->get_role_detail($value);
if (is_array($roles_data) && count($roles_data) > 0) {
return $roles_data["rolename"];
} else {
return '';
}
} else {
return $value;
}
}
示例11: authenticate
public function authenticate()
{
$exception = null;
$result = array('code' => Zend_Auth_Result::FAILURE, 'identity' => $this->Identity, 'messages' => array());
$userInfo = array();
if (empty($this->Identity)) {
$exception = 'You must provide a identity to authenticate';
throw new Zend_Auth_Adapter_Exception('Please verify your username');
} else {
if (empty($this->Credential)) {
$exception = 'You must provide a credential to authenticate';
} elseif ($this->Rows) {
if (is_array($this->Rows)) {
$this->Rows = $this->array2object($this->Rows);
}
$userInfo[0]['user_id'] = isset($this->Rows->user_id) && !empty($this->Rows->user_id) ? $this->Rows->user_id : '';
$userInfo[0]['username'] = isset($this->Rows->username) && !empty($this->Rows->username) ? $this->Rows->username : '';
$userInfo[0]['firstname'] = isset($this->Rows->firstname) && !empty($this->Rows->firstname) ? $this->Rows->firstname : '';
$userInfo[0]['lastname'] = isset($this->Rows->lastname) && !empty($this->Rows->lastname) ? $this->Rows->lastname : '';
$userInfo[0]['location'] = isset($this->Rows->location) && !empty($this->Rows->location) ? $this->Rows->location : '';
$userInfo[0]['email'] = isset($this->Rows->email) && !empty($this->Rows->email) ? $this->Rows->email : '';
$userInfo[0]['role_id'] = isset($this->Rows->role_id) && !empty($this->Rows->role_id) ? $this->Rows->role_id : '';
$userInfo[0]['active'] = isset($this->Rows->active) && !empty($this->Rows->active) ? $this->Rows->active : '';
$userInfo[0]['publisher_id'] = isset($this->Rows->publisher_id) && !empty($this->Rows->publisher_id) ? $this->Rows->publisher_id : '';
$found = true;
if (!empty($userInfo[0]['role_id'])) {
$role = new Roles();
$roleid = $role->fetchROW(" role_id='" . $userInfo[0]['role_id'] . "'");
$userInfo[0]['rolename'] = $roleid->role_name;
} else {
$userInfo[0]['rolename'] = '';
}
if (isset($userInfo) && !empty($userInfo)) {
$result['code'] = Zend_Auth_Result::SUCCESS;
$result['messages'][] = 'Authentication success';
$this->RowsIdent = $userInfo;
} else {
//$exception = 'You must provide a credential to authenticate';
$result['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
$result['messages'][] = 'Authentication failed';
}
}
}
if (null != $exception) {
throw new Zend_Auth_Adapter_Exception($exception);
}
return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages'], $userInfo);
}
示例12: __construct
function __construct($role_id, $locale_code = "en-us", $config = null, $restricted = null)
{
$this->locale_code = $locale_code;
$this->role_id = $role_id;
if (is_array($this->role_id)) {
$all_roles = $this->role_id;
} else {
$all_roles = array($this->role_id);
}
$roles_table = new Roles();
foreach ($all_roles as $role) {
$all_roles = array_merge($all_roles, $roles_table->getAllAncestors($role));
}
$this->all_roles = array_unique($all_roles);
return parent::__construct($config);
}
示例13: actionGroup
/**
* @Author: bb - recopy ANH DUNG May 12, 2014
* @Todo: phân quyền cho group
*/
public function actionGroup($id)
{
if (in_array($id, Roles::$aRoleRestrict)) {
$this->redirect(Yii::app()->createAbsoluteUrl('admin/roles'));
}
$this->pageTitle = Yii::app()->params['title'] . ' - Group Privilege';
$mGroup = Roles::model()->findByPk($id);
try {
if (isset($_POST['submit'])) {
foreach ($this->aControllers as $keyController => $aController) {
$mController = Controllers::getByName($keyController);
if ($mController) {
$mController->addGroupRoles($this->postArrayCheckBoxToAllowDenyValue($keyController), $id);
$this->setNotifyMessage(NotificationType::Success, 'Successful Update');
}
}
$this->refresh();
}
$this->render('group', array('id' => $id, 'mGroup' => $mGroup, 'actions' => $this->listActionsCanAccess));
} catch (Exception $exc) {
Yii::log("Uid: " . Yii::app()->user->id . " Exception " . $exc->getMessage(), 'error');
$code = 404;
if (isset($exc->statusCode)) {
$code = $exc->statusCode;
}
if ($exc->getCode()) {
$code = $exc->getCode();
}
throw new CHttpException($code, $exc->getMessage());
}
}
示例14: getRoles
/**
* Retrieves roles for the user
*/
public function getRoles()
{
if (!isset($this->_roles)) {
$this->_roles = Roles::getUserRoles($this->getId());
}
return $this->_roles;
}
示例15: generate_inner_html
function generate_inner_html()
{
switch ($this->mode) {
default:
$inner_template = dirname(__FILE__) . '/center_inner_private.tpl';
}
$inner_html_gen =& new Template($inner_template);
$role = new Roles();
$this->links = $role->get_multiple();
$inner_html_gen->set('links', $this->links);
$inner_html_gen->set('display', @$this->display);
$inner_html_gen->set('super_user_and_mothership', @$this->super_user_and_mothership);
$inner_html_gen->set('config_navigation_url', network_config_navigation('manage_roles'));
$inner_html = $inner_html_gen->fetch();
return $inner_html;
}