本文整理汇总了PHP中Roles类的典型用法代码示例。如果您正苦于以下问题:PHP Roles类的具体用法?PHP Roles怎么用?PHP Roles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Roles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:33,代码来源:EmailSearchForm.php
示例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);
}
开发者ID:richjoslin,项目名称:rivety,代码行数:25,代码来源:Navigation.php
示例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;
}
开发者ID:jaybill,项目名称:Bolts,代码行数:30,代码来源:ExtraResourceCheck.php
示例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');
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:33,代码来源:EmailSearchForm.php
示例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());
}
}
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:29,代码来源:SystemController.php
示例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();
}
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:38,代码来源:EditAccountForm.php
示例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: ');
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:55,代码来源:EditAccountForm.php
示例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');
}
开发者ID:rwebley,项目名称:Beowulf---PAS,代码行数:54,代码来源:AcceptUpgradeForm.php
示例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;
}
开发者ID:arduanov,项目名称:eco,代码行数:13,代码来源:Users.php
示例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;
}
}
开发者ID:abhikchakraborty,项目名称:sqcrm,代码行数:18,代码来源:FieldType103.class.php
示例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);
}
开发者ID:xinghao,项目名称:shs,代码行数:48,代码来源:Adapter.php
示例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);
}
开发者ID:jaybill,项目名称:Bolts,代码行数:16,代码来源:Navigation.php
示例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());
}
}
开发者ID:jasonhai,项目名称:onehome,代码行数:35,代码来源:RolesAuthController.php
示例14: getRoles
/**
* Retrieves roles for the user
*/
public function getRoles()
{
if (!isset($this->_roles)) {
$this->_roles = Roles::getUserRoles($this->getId());
}
return $this->_roles;
}
开发者ID:tymiles003,项目名称:X2CRM,代码行数:10,代码来源:X2WebUser.php
示例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;
}
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:16,代码来源:RoleManageModule.php
示例16: emailToUser
/**
* [emailToUser Send Email to user for report user status]
* @param [type] $email [user email]
* @param [type] $name [user name]
* @param [type] $status [user status]
* @return [type] [description]
*/
public function emailToUser($email, $name, $status, $group, $role)
{
if ($status == 'yes') {
$status = 'เปิดใช้งาน';
} else {
$status = 'ปิดการใช้งาน';
}
$role_obj = new Roles();
$_role = $role_obj->getRoleName($role);
$grp_obj = new Usergroup();
$_grp = $grp_obj->getGrpName($group);
//var_dump($_grp);exit;
Mail::send('userlist.email', array("name" => $name, "status" => $status, "group" => $_grp->grp_nameth, "role" => $_role->role_name), function ($message) use($email) {
$message->to($email, 'Admin@NHC')->subject('Your status @NHC');
});
}
开发者ID:nattaphat,项目名称:cuse2,代码行数:23,代码来源:UsernhcController.php
示例17: authenticate
public function authenticate()
{
$record = Usuario::model()->findByAttributes(array('nombre' => $this->username));
$conexion = Yii::app()->db;
$consulta = "SELECT nombre, clave FROM usuario ";
$consulta .= "WHERE nombre='" . $this->username . "' AND ";
$consulta .= "clave='" . $this->password . "'";
$resultado = $conexion->createCommand($consulta)->query();
$resultado->bindColumn(1, $this->username);
$resultado->bindColumn(2, $this->password);
while ($resultado->read() !== false) {
$this->errorCode = self::ERROR_NONE;
$this->_id = $record->id;
//bien
$role = Roles::model()->findByPk($record->IdRol);
//bien
$this->setState('role', $role->NOMBRE);
//bien
return !$this->errorCode;
}
/*$users=array(
// username => password
'demo'=>'demo',
'admin'=>'admin',
);
if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID;
elseif($users[$this->username]!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;*/
}
开发者ID:leydyk93,项目名称:conveniosunet,代码行数:33,代码来源:UserIdentity.php
示例18: submitAction
public function submitAction()
{
// Disable view
$this->view->disable();
// Check and get POSTED data
if ($this->request->isPost() && !empty($login_name = $this->request->getPost("username")) && !empty($password = $this->request->getPost("password"))) {
$user = Users::findFirst(array("login_name = :login_name: AND active = true", "bind" => array("login_name" => $login_name)));
if (empty($user)) {
echo json_encode(array("success" => false, "errorType" => "username", "errorMessage" => "Username tidak dikenal"));
return;
} else {
if ($user->isBanned()) {
echo json_encode(array("success" => false, "errorType" => "username", "errorMessage" => "Username ini tidak dapat digunakan kembali"));
return;
} else {
if ($user->isSuspended()) {
echo json_encode(array("success" => false, "errorType" => "username", "errorMessage" => "Untuk sementara, username ini tidak dapat digunakan"));
return;
}
}
}
if (!$this->security->checkHash($password, $user->getPassword())) {
echo json_encode(array("success" => false, "errorType" => "password", "errorMessage" => "Password yang anda masukkan salah"));
return;
}
$this->session->set("auth", array("user" => $user, "role" => Roles::findFirstByIdRole($user->getIdRole())));
echo json_encode(array("success" => true));
}
}
开发者ID:efronnyp,项目名称:seleksi-supplier,代码行数:29,代码来源:AuthController.php
示例19: UserAclRoles
function UserAclRoles($user_id = '')
{
$show_box['title'] = '获取用户全部角色';
$return_value = '';
$roles_idname = array();
$roles_id = array();
$sp_roles = Q::ini('appini/sp_role');
// 第一步:直接从中间表获得用户的全部角色ID
$user_roles = UsersHaveRoles::find('user_id = ?', intval($user_id))->asArray()->getAll();
//dump($user_roles);
// 取出有用的ID,去除deny的ID
foreach ($user_roles as $value) {
if ($value['is_include']) {
$roles_id[] = $value['role_id'];
}
}
//dump ( $roles_id);
$roles_arr = Roles::find('role_id in (?)', Q::normalize($roles_id, ","))->asArray()->getAll();
foreach ($roles_arr as $value) {
$roles_idname[$value['role_id']] = $value['rolename'];
}
//dump($roles_idname);
if (in_array($sp_roles['REPEAL'], $roles_idname)) {
$return_value = array($value['role_id'] => $sp_roles['REPEAL']);
return $return_value;
} elseif (in_array($sp_roles['FREEZE'], $roles_idname)) {
$return_value = array($value['role_id'] => $sp_roles['FREEZE']);
return $return_value;
} elseif (in_array($sp_roles['UNCHECKED'], $roles_idname)) {
$return_value = array($value['role_id'] => $sp_roles['UNCHECKED']);
return $return_value;
} else {
return $roles_idname;
}
}
开发者ID:Debenson,项目名称:openwan,代码行数:35,代码来源:acl.php
示例20: login
public function login()
{
$email = Input::get('email');
$password = Input::get('password');
$user = Users::where('email', '=', $email)->first();
if ($user != null && Hash::check($password, $user->password)) {
Session::set('logged', true);
Session::set('email', $email);
Session::set('time_zone', $user->time_zone);
Session::set('lid', $user->language_id);
Session::set('user_id', $user->id);
$userRole = Roles::getUserRole($user->role_id);
Session::set('role', $userRole);
// getting car_id if its a driver
if ($user->role_id == Roles::DRIVER_ROLE_ID) {
$driver = Driver::where('user_id', '=', $user->id)->firstOrFail();
Session::set('car_id', $driver->car_id);
}
$result = array('success' => true, 'message' => 'logged in successfully', 'payload' => array('role' => $userRole));
} else {
Session::flush();
$result = array('success' => false, 'message' => 'invalid email or password');
}
return $result;
}
开发者ID:ardyaryan,项目名称:presidential-car-api,代码行数:25,代码来源:AdminController.php
注:本文中的Roles类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论