本文整理汇总了PHP中RoleModel类的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel类的具体用法?PHP RoleModel怎么用?PHP RoleModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RoleModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: filterCheckAdmin
/**
*
* 过滤器
* @param unknown_type $filterChain
*/
public function filterCheckAdmin($filterChain)
{
//未登录,跳转
if (!($uid = $this->isAdmin())) {
$this->redirect(Yii::app()->baseUrl . "/");
}
//获取用户详细资料
$adminModel = new AdminModel();
$this->_userInfo = $adminModel->getInfoByUid($uid);
$this->username = $this->_userInfo['username'];
$this->hospital = $this->_userInfo['hospital'];
$this->role = $this->_userInfo['role'];
//账号错误
if (!$this->_userInfo) {
$this->_output("302", 'access deny', 'text');
}
$roleModel = new RoleModel();
$role = $roleModel->getInfoByCode($this->_userInfo['role']);
if ($role && $role['permission']) {
$permission = explode(',', $role['permission']);
//生成菜单
$menuModel = new MenuModel();
$this->menus = $menuModel->getInfoByGroup($permission);
foreach ($this->menus as $key => $value) {
$this->menuGroup[$value['group']] = $value['group'];
}
} else {
header("HTTP/1.1 401");
exit;
}
$filterChain->run();
}
开发者ID:FlynnFang,项目名称:cyfyy,代码行数:37,代码来源:Admin.php
示例2: dadosAction
public function dadosAction()
{
$this->_helper->layout->disableLayout();
$page = $this->_request->getParam("page", 1);
$limit = $this->_request->getParam("rows");
$sidx = $this->_request->getParam("sidx", 1);
$sord = $this->_request->getParam("sord");
$roleModel = new RoleModel();
$role = $roleModel->fetchAll();
$count = count($role);
if ($count > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) {
$page = $total_pages;
}
//$role = $roleModel->fetchAll(null, "$sidx $sord", $limit, ($page*$limit-$limit));
$responce = new stdClass();
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i = 0;
foreach ($role as $row) {
$responce->rows[$i]['cell'] = array($row->cdrole, $row->nmrole);
$i++;
}
$this->view->dados = $responce;
}
开发者ID:robertsonmello,项目名称:projetos,代码行数:30,代码来源:RoleController.php
示例3: toString
public function toString()
{
$Form = $this->_Sender->Form;
$this->_Sender->addJsFile('condition.js');
if ($Form->authenticatedPostBack()) {
// Grab the conditions from the form and convert them to the conditions array.
$this->Conditions($this->_FromForm());
} else {
}
$this->Types = array_merge(array('' => '(' . sprintf(t('Select a %s'), t('Condition Type', 'Type')) . ')'), Gdn_Condition::AllTypes());
//die(print_r($this->Types));
// Get all of the permissions that are valid for the permissions dropdown.
$PermissionModel = new PermissionModel();
$Permissions = $PermissionModel->GetGlobalPermissions(0);
$Permissions = array_keys($Permissions);
sort($Permissions);
$Permissions = array_combine($Permissions, $Permissions);
$Permissions = array_merge(array('' => '(' . sprintf(t('Select a %s'), t('Permission')) . ')'), $Permissions);
$this->Permissions = $Permissions;
// Get all of the roles.
$RoleModel = new RoleModel();
$Roles = $RoleModel->getArray();
$Roles = array_merge(array('-' => '(' . sprintf(t('Select a %s'), t('Role')) . ')'), $Roles);
$this->Roles = $Roles;
$this->Form = $Form;
return parent::ToString();
}
开发者ID:sitexa,项目名称:vanilla,代码行数:27,代码来源:class.conditionmodule.php
示例4: _add
/**
* 添加规则
* @param string $resName
* @param string $privName
*/
protected function _add($resName, $privName)
{
$data = array('res_name' => $resName, 'priv_name' => $privName);
$this->db->insert('acl_rule', $data);
$ruleId = $this->db->lastInsertId();
$roleModel = new RoleModel($this->_modName);
$roleList = $roleModel->getAll();
$data = array();
foreach ($roleList as $role) {
$data = array('rule_id' => $ruleId, 'role_id' => $role['role_id'], 'permit' => 0);
$this->db->insert('acl', $data);
}
}
开发者ID:BGCX261,项目名称:zhongyycode-svn-to-git,代码行数:18,代码来源:RuleModel.php
示例5: updatePermissions
/**
* @param array $input
*
* @return bool
*/
public function updatePermissions(array $input)
{
$roles = $this->getRoles();
$model = new RoleModel($this->db);
foreach ($roles as $role) {
if (isset($input[$role->getId()])) {
$permissions = array_keys($input[$role->getId()]);
$model->updatePermissions($role->getId(), $permissions);
} else {
$model->updatePermissions($role->getId(), array());
}
}
return true;
}
开发者ID:arkuuu,项目名称:publin,代码行数:19,代码来源:ManageModel.php
示例6: SelectByRole
/**
* Select content based on author RoleID
*
* @param array $Parameters
* @return boolean
*/
protected function SelectByRole($Parameters)
{
if (!is_array($Parameters)) {
$RoleID = $Parameters;
} else {
$RoleID = GetValue('RoleID', $Parameters, NULL);
}
// Lookup role name -> roleID
if (is_string($RoleID)) {
$RoleModel = new RoleModel();
$Roles = explode(',', $RoleID);
$RoleID = array();
foreach ($Roles as $TestRoleID) {
$TestRoleID = trim($TestRoleID);
$Role = $RoleModel->GetByName($TestRoleID);
if (!$Role) {
continue;
} else {
$Role = array_shift($Role);
$RoleID[] = GetValue('RoleID', $Role);
}
}
}
if (empty($RoleID) || !sizeof($RoleID)) {
return FALSE;
}
// Check cache
$SelectorRoleCacheKey = "modules.promotedcontent.role.{$RoleID}";
$Content = Gdn::Cache()->Get($SelectorRoleCacheKey);
if ($Content == Gdn_Cache::CACHEOP_FAILURE) {
// Get everyone with this Role
$UserIDs = Gdn::SQL()->Select('ur.UserID')->From('UserRole ur')->Where('ur.RoleID', $RoleID)->GroupBy('UserID')->Get()->Result(DATASET_TYPE_ARRAY);
$UserIDs = ConsolidateArrayValuesByKey($UserIDs, 'UserID');
// Get matching Discussions
$Discussions = Gdn::SQL()->Select('d.*')->From('Discussion d')->WhereIn('d.InsertUserID', $UserIDs)->OrderBy('DateInserted', 'DESC')->Limit($this->Limit)->Get()->Result(DATASET_TYPE_ARRAY);
// Get matching Comments
$Comments = Gdn::SQL()->Select('c.*')->From('Comment c')->WhereIn('InsertUserID', $UserIDs)->OrderBy('DateInserted', 'DESC')->Limit($this->Limit)->Get()->Result(DATASET_TYPE_ARRAY);
$this->JoinCategory($Comments);
// Interleave
$Content = $this->Union('DateInserted', array('Discussion' => $Discussions, 'Comment' => $Comments));
$this->Prepare($Content);
// Add result to cache
Gdn::Cache()->Store($SelectorRoleCacheKey, $Content, array(Gdn_Cache::FEATURE_EXPIRY => $this->Expiry));
}
$this->Security($Content);
$this->Condense($Content, $this->Limit);
return $Content;
}
开发者ID:bishopb,项目名称:vanilla,代码行数:54,代码来源:class.promotedcontentmodule.php
示例7: GetMembersListEnh
public function GetMembersListEnh($Limit = 5, $Offset = 0, $SortOrder, $UserField)
{
$RoleAction = $RoleActionID = "";
$RemoveRoleArray = C('Plugins.MembersListEnh.RoleID');
if (isset($RemoveRoleArray)) {
$RoleAction = $RemoveRoleArray[0];
$RoleActionID = $RemoveRoleArray[1];
}
$MembersListEnhModel = new Gdn_Model('User');
$SQL = $MembersListEnhModel->SQL->Select('*')->From('User u')->LeftJoin('UserRole ur', 'u.UserID = ur.UserID');
if (C('EnabledPlugins.KarmaBank') == TRUE) {
$SQL->LeftJoin('KarmaBankBalance kb', 'u.UserID = kb.UserID');
}
if ($UserField != "Balance") {
$SQL->OrderBy("u.{$UserField}", $SortOrder);
}
if (C('EnabledPlugins.KarmaBank') == TRUE && $UserField == "Balance") {
$SQL->OrderBy("kb.Balance", $SortOrder);
}
$SQL->Where('Deleted', false);
if ($RoleAction == "Exclude") {
$SQL->Where('ur.RoleID<>', $RoleActionID);
}
if ($RoleAction == "Include") {
$SQL->Where('ur.RoleID', $RoleActionID);
}
// Only show user once if in more than one role.
$SQL->GroupBy('ur.UserID');
$Sender->UserData = $SQL->Limit($Limit, $Offset)->Get();
RoleModel::SetUserRoles($Sender->UserData->Result());
return $Sender->UserData;
}
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:32,代码来源:class.memberslistenhmodel.php
示例8: down
public function down()
{
$role = RoleModel::findBy('first', 'roleDescription', 'Administrators');
if ($role !== null) {
$role->deny('compare');
$role->save();
}
}
开发者ID:humansky,项目名称:qframe,代码行数:8,代码来源:20080827133717_AddCompareRoleToAdminIfUserExists.php
示例9: getFormCadastre
public function getFormCadastre()
{
$departmentModel = new DepartmentModel();
$departmentData = $departmentModel->fetchAll($departmentModel->getAllActiveDepartment());
$roleModel = new RoleModel();
$roleData = $roleModel->fetchAll($roleModel->select());
$departmentSupervisorModel = new DepartmentsupervisorModel();
$departmentSupervisorData = $departmentSupervisorModel->fetchAll($departmentSupervisorModel->getAllSupervisor());
$companyModel = new CompanyModel();
$companyData = $companyModel->fetchAll();
$Arraycompany = array();
$Arraycompany['0'] = 'Selecione';
foreach ($companyData as $company) {
$Arraycompany[$company->cdcompany] = $company->nmfantasyname;
}
$this->_nmagenda = new Zend_Form_Element_Text('nmagenda');
$this->_nmagenda->setLabel("Nome da Agenda");
$this->_nmagenda->setRequired(true);
$this->_nmagenda->setDecorators($this->_decoratorsRequired);
$this->_nmagenda->setAttrib("id", "agenda_nmagendas");
$this->_nmagenda->setAttrib("class", "alpha nameagenda");
$this->_nmagenda->setRequired(true);
$this->_cdcompany = new Zend_Form_Element_Select('cdcompany');
$this->_cdcompany->setRegisterInArrayValidator(false);
$this->_cdcompany->addMultiOptions($Arraycompany);
$this->_cdcompany->setLabel("Empresa");
$this->_cdcompany->setDecorators($this->_decoratorsRequired);
$this->_cdcompany->setAttrib("id", "user_cdcompany");
$this->_cdcompany->setAttrib("class", "alpha");
$this->_cdcompany->setRequired(true);
$this->_cdphysicallocation = new Zend_Form_Element_Select('cdphysicallocation');
$this->_cdphysicallocation->setRegisterInArrayValidator(false);
$this->_cdphysicallocation->setLabel("Localização Física");
$this->_cdphysicallocation->addMultiOptions(array('0' => 'Selecione'));
$this->_cdphysicallocation->setDecorators($this->_decoratorsRequired);
$this->_cdphysicallocation->setAttrib("id", "company_physicallocation");
$this->_cdphysicallocation->setAttrib("class", "alpha");
$this->_cdphysicallocation->setRequired(true);
$this->_gridhours = new Zend_Form_Element_Select('gridhours');
$this->_gridhours->setRegisterInArrayValidator(false);
$this->_gridhours->addMultiOptions(array('1' => 'Sim', '2' => 'Não'));
$this->_gridhours->setLabel("Grade de Horário");
$this->_gridhours->setDecorators($this->_decoratorsDefault);
$this->_gridhours->setAttrib("id", "user_gridhours");
$this->_gridhours->setRequired(false);
}
开发者ID:robertsonmello,项目名称:projetos,代码行数:46,代码来源:AgendaForm.php
示例10: _permission
/**
* Do permission check.
*
* @since 2.0.0
* @access protected
*/
protected function _permission($RoleID = null)
{
$this->permission(array('Garden.Settings.Manage', 'Garden.Roles.Manage'), false);
if ($RoleID && !checkPermission('Garden.Settings.Manage')) {
// Make sure the user can assign this role.
$Assignable = $this->RoleModel->getAssignable();
if (!isset($Assignable[$RoleID])) {
throw permissionException('@' . t("You don't have permission to modify this role."));
}
}
return true;
}
开发者ID:R-J,项目名称:vanilla,代码行数:18,代码来源:class.rolecontroller.php
示例11: Index
public function Index($Keywords = '', $Page = '') {
$this->Permission(
array(
'Garden.Users.Add',
'Garden.Users.Edit',
'Garden.Users.Delete'
),
'',
FALSE
);
$this->AddJsFile('jquery.gardenmorepager.js');
$this->AddJsFile('user.js');
$this->Title(T('Users'));
$this->AddSideMenu('dashboard/user');
$this->Form->Method = 'get';
// Input Validation.
list($Offset, $Limit) = OffsetLimit($Page, PagerModule::$DefaultPageSize);
if (!$Keywords) {
$Keywords = $this->Form->GetFormValue('Keywords');
if ($Keywords)
$Offset = 0;
}
// Put the Keyword back in the form
if ($Keywords)
$this->Form->SetFormValue('Keywords', $Keywords);
$UserModel = new UserModel();
//$Like = trim($Keywords) == '' ? FALSE : array('u.Name' => $Keywords, 'u.Email' => $Keywords);
list($Offset, $Limit) = OffsetLimit($Page, 30);
$Filter = $this->_GetFilter();
if ($Filter)
$Filter['Keywords'] = $Keywords;
else
$Filter = $Keywords;
$this->SetData('RecordCount', $UserModel->SearchCount($Filter));
$this->UserData = $UserModel->Search($Filter, 'u.Name', 'asc', $Limit, $Offset);
RoleModel::SetUserRoles($this->UserData->Result());
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
$this->View = 'users';
}
$this->Render();
}
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:53,代码来源:class.usercontroller.php
示例12: up
public function up()
{
$this->createTable('role', array('primary' => 'roleID'), array(array('roleID', 'integer'), array('roleDescription', 'string', array('limit' => 128, 'null' => true)), array('ACLstring', 'text', array('null' => true, 'limit' => '1M'))));
$this->createTable('assignment', array('primary' => 'assignmentID'), array(array('dbUserID', 'integer'), array('roleID', 'integer'), array('assignmentID', 'integer'), array('comments', 'text', array('null' => true))));
$this->createIndex('assignment', array('dbUserID', 'roleID'));
// reset db metadata cache
QFrame_Db_Table::scanDb();
// give the admin user full global rights
$adminRole = RoleModel::create(array('roleDescription' => 'Administrators'));
$adminRole->grant('view');
$adminRole->grant('edit');
$adminRole->grant('approve');
$adminRole->grant('administer');
$adminRole->save();
DbUserModel::findByUsername('admin')->addRole($adminRole)->save();
}
开发者ID:humansky,项目名称:qframe,代码行数:16,代码来源:20080731155158_CreateTableRole.php
示例13: assignRole
/**
* Assign the given role to the user.
*
* @param string $role
*
* @return mixed
*/
public function assignRole($role, $save = true)
{
// if we passed a role name, find it
if (is_string($role)) {
$role = RoleModel::whereName($role)->first();
}
// if user already has the role, return true.
if ($save and $this->roles()->find([$role->id])->count()) {
return $role;
}
// assign role
if ($save) {
return $this->roles()->save($role);
} else {
return $this->roles()->detach($role);
}
}
开发者ID:NablusTechMeetups,项目名称:web,代码行数:24,代码来源:HasRole.php
示例14: auth
private function auth()
{
// perform mock authentication
$auth_adapter = new QFrame_Auth_Adapter('sample1', 'password');
$auth = Zend_Auth::getInstance();
$auth->authenticate($auth_adapter);
// authorize the sample1 user with the admin role and give the admin role
// all possible global rights
$adminRole = RoleModel::find(4);
$adminRole->grant('view');
$adminRole->grant('edit');
$adminRole->grant('approve');
$adminRole->grant('administer');
$adminRole->save();
$user = new DbUserModel(array('dbUserID' => 1));
$user->addRole($adminRole);
}
开发者ID:humansky,项目名称:qframe,代码行数:17,代码来源:ModelModelTest.php
示例15: Registration
/**
* Configuration of registration settings.
*/
public function Registration($RedirectUrl = '')
{
$this->Permission('Garden.Registration.Manage');
if (!C('Garden.Registration.Manage', TRUE)) {
return Gdn::Dispatcher()->Dispatch('Default404');
}
$this->AddSideMenu('dashboard/settings/registration');
$this->AddJsFile('registration.js');
$this->Title(T('Registration'));
// Create a model to save configuration settings
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array('Garden.Registration.Method' => 'Captcha', 'Garden.Registration.CaptchaPrivateKey', 'Garden.Registration.CaptchaPublicKey', 'Garden.Registration.InviteExpiration'));
// Set the model on the forms.
$this->Form->SetModel($ConfigurationModel);
// Load roles with sign-in permission
$RoleModel = new RoleModel();
$this->RoleData = $RoleModel->GetByPermission('Garden.SignIn.Allow');
// Get the currently selected default roles
// $this->ExistingRoleData = Gdn::Config('Garden.Registration.DefaultRoles');
// if (is_array($this->ExistingRoleData) === FALSE)
// $this->ExistingRoleData = array();
// Get currently selected InvitationOptions
$this->ExistingRoleInvitations = Gdn::Config('Garden.Registration.InviteRoles');
if (is_array($this->ExistingRoleInvitations) === FALSE) {
$this->ExistingRoleInvitations = array();
}
// Get the currently selected Expiration Length
$this->InviteExpiration = Gdn::Config('Garden.Registration.InviteExpiration', '');
// Registration methods.
$this->RegistrationMethods = array('Captcha' => "New users fill out a simple form and are granted access immediately.", 'Approval' => "New users are reviewed and approved by an administrator (that's you!).", 'Invitation' => "Existing members send invitations to new members.");
// Options for how many invitations a role can send out per month.
$this->InvitationOptions = array('0' => T('None'), '1' => '1', '2' => '2', '5' => '5', '-1' => T('Unlimited'));
// Options for when invitations should expire.
$this->InviteExpirationOptions = array('-1 week' => T('1 week after being sent'), '-2 weeks' => T('2 weeks after being sent'), '-1 month' => T('1 month after being sent'), 'FALSE' => T('never'));
if ($this->Form->AuthenticatedPostBack() === FALSE) {
$this->Form->SetData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->ApplyRule('Garden.Registration.Method', 'Required');
// if($this->Form->GetValue('Garden.Registration.Method') != 'Closed')
// $ConfigurationModel->Validation->ApplyRule('Garden.Registration.DefaultRoles', 'RequiredArray');
// Define the Garden.Registration.RoleInvitations setting based on the postback values
$InvitationRoleIDs = $this->Form->GetValue('InvitationRoleID');
$InvitationCounts = $this->Form->GetValue('InvitationCount');
$this->ExistingRoleInvitations = ArrayCombine($InvitationRoleIDs, $InvitationCounts);
$ConfigurationModel->ForceSetting('Garden.Registration.InviteRoles', $this->ExistingRoleInvitations);
// Save!
if ($this->Form->Save() !== FALSE) {
$this->StatusMessage = T("Your settings have been saved.");
if ($RedirectUrl != '') {
$this->RedirectUrl = $RedirectUrl;
}
}
}
$this->Render();
}
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:60,代码来源:class.settingscontroller.php
示例16: save
/**
*
*
* @throws Exception
* @throws Gdn_UserException
*/
public function save()
{
$this->permission('Garden.Users.Edit');
if (!Gdn::request()->isAuthenticatedPostBack()) {
throw new Exception('Requires POST', 405);
}
$Form = new Gdn_Form();
if ($SSOString = $Form->getFormValue('SSOString')) {
$Parts = explode(' ', $SSOString);
$String = $Parts[0];
$Data = json_decode(base64_decode($String), true);
$User = arrayTranslate($Data, array('name' => 'Name', 'email' => 'Email', 'photourl' => 'Photo', 'client_id' => 'ClientID', 'uniqueid' => 'UniqueID'));
} else {
$User = $Form->formValues();
}
if (!isset($User['UserID']) && isset($User['UniqueID'])) {
// Try and find the user based on SSO.
$Auth = Gdn::userModel()->getAuthentication($User['UniqueID'], $User['ClientID']);
if ($Auth) {
$User['UserID'] = $Auth['UserID'];
}
}
if (!isset($User['UserID'])) {
// Add some default values to make saving easier.
if (!isset($User['RoleID'])) {
$DefaultRoles = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
$User['RoleID'] = $DefaultRoles;
} elseif (is_numeric($User['RoleID'])) {
// UserModel->save() demands an array for RoleID.
$User['RoleID'] = array($User['RoleID']);
}
if (!isset($User['Password'])) {
$User['Password'] = md5(microtime());
$User['HashMethod'] = 'Random';
}
}
$UserID = Gdn::userModel()->save($User, array('SaveRoles' => isset($User['RoleID']), 'NoConfirmEmail' => true));
if ($UserID) {
if (!isset($User['UserID'])) {
$User['UserID'] = $UserID;
}
if (isset($User['ClientID']) && isset($User['UniqueID'])) {
Gdn::userModel()->saveAuthentication(array('UserID' => $User['UserID'], 'Provider' => $User['ClientID'], 'UniqueID' => $User['UniqueID']));
}
$this->setData('User', $User);
} else {
throw new Gdn_UserException(Gdn::userModel()->Validation->resultsText());
}
$this->render('Blank', 'Utility');
}
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:56,代码来源:class.usercontroller.php
示例17: Connect
/**
* Connect the user with an external source.
*
* This controller method is meant to be used with plugins that set its data array to work.
* Events: ConnectData
*
* @since 2.0.0
* @access public
*
* @param string $Method Used to register multiple providers on ConnectData event.
*/
public function Connect($Method)
{
$this->AddJsFile('entry.js');
$this->View = 'connect';
$IsPostBack = $this->Form->IsPostBack() && $this->Form->GetFormValue('Connect', NULL) !== NULL;
if (!$IsPostBack) {
// Here are the initial data array values. that can be set by a plugin.
$Data = array('Provider' => '', 'ProviderName' => '', 'UniqueID' => '', 'FullName' => '', 'Name' => '', 'Email' => '', 'Photo' => '', 'Target' => $this->Target());
$this->Form->SetData($Data);
$this->Form->AddHidden('Target', $this->Request->Get('Target', '/'));
}
// The different providers can check to see if they are being used and modify the data array accordingly.
$this->EventArguments = array($Method);
// Fire ConnectData event & error handling.
$CurrentData = $this->Form->FormValues();
try {
$this->FireEvent('ConnectData');
} catch (Gdn_UserException $Ex) {
$this->Form->AddError($Ex);
return $this->Render('ConnectError');
} catch (Exception $Ex) {
if (Debug()) {
$this->Form->AddError($Ex);
} else {
$this->Form->AddError('There was an error fetching the connection data.');
}
return $this->Render('ConnectError');
}
if (!UserModel::NoEmail()) {
if (!$this->Form->GetFormValue('Email') || $this->Form->GetFormValue('EmailVisible')) {
$this->Form->SetFormValue('EmailVisible', TRUE);
$this->Form->AddHidden('EmailVisible', TRUE);
if ($IsPostBack) {
$this->Form->SetFormValue('Email', GetValue('Email', $CurrentData));
}
}
}
$FormData = $this->Form->FormValues();
// debug
// Make sure the minimum required data has been provided to the connect.
if (!$this->Form->GetFormValue('Provider')) {
$this->Form->AddError('ValidateRequired', T('Provider'));
}
if (!$this->Form->GetFormValue('UniqueID')) {
$this->Form->AddError('ValidateRequired', T('UniqueID'));
}
if (!$this->Data('Verified')) {
// Whatever event handler catches this must Set the data 'Verified' to true to prevent a random site from connecting without credentials.
// This must be done EVERY postback and is VERY important.
$this->Form->AddError('The connection data has not been verified.');
}
if ($this->Form->ErrorCount() > 0) {
return $this->Render();
}
$UserModel = Gdn::UserModel();
// Check to see if there is an existing user associated with the information above.
$Auth = $UserModel->GetAuthentication($this->Form->GetFormValue('UniqueID'), $this->Form->GetFormValue('Provider'));
$UserID = GetValue('UserID', $Auth);
// Check to synchronise roles upon connecting.
if (($this->Data('Trusted') || C('Garden.SSO.SynchRoles')) && $this->Form->GetFormValue('Roles', NULL) !== NULL) {
$SaveRoles = TRUE;
// Translate the role names to IDs.
$Roles = $this->Form->GetFormValue('Roles', NULL);
$Roles = RoleModel::GetByName($Roles);
$RoleIDs = array_keys($Roles);
if (empty($RoleIDs)) {
// The user must have at least one role. This protects that.
$RoleIDs = $this->UserModel->NewUserRoleIDs();
}
$this->Form->SetFormValue('RoleID', $RoleIDs);
} else {
$SaveRoles = FALSE;
}
if ($UserID) {
// The user is already connected.
$this->Form->SetFormValue('UserID', $UserID);
if (C('Garden.Registration.ConnectSynchronize', TRUE)) {
$User = Gdn::UserModel()->GetID($UserID, DATASET_TYPE_ARRAY);
$Data = $this->Form->FormValues();
// Don't overwrite the user photo if the user uploaded a new one.
$Photo = GetValue('Photo', $User);
if (!GetValue('Photo', $Data) || $Photo && !StringBeginsWith($Photo, 'http')) {
unset($Data['Photo']);
}
// Synchronize the user's data.
$UserModel->Save($Data, array('NoConfirmEmail' => TRUE, 'FixUnique' => TRUE, 'SaveRoles' => $SaveRoles));
}
// Always save the attributes because they may contain authorization information.
if ($Attributes = $this->Form->GetFormValue('Attributes')) {
//.........这里部分代码省略.........
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:101,代码来源:class.entrycontroller.php
示例18: lookupRoleIDs
/**
*
*
* @param array $Roles
* @return array
*/
protected function lookupRoleIDs($Roles)
{
if (is_string($Roles)) {
$Roles = explode(',', $Roles);
} elseif (!is_array($Roles)) {
$Roles = [];
}
$Roles = array_map('trim', $Roles);
$Roles = array_map('strtolower', $Roles);
$AllRoles = RoleModel::roles();
$RoleIDs = [];
foreach ($AllRoles as $RoleID => $Role) {
$Name = strtolower($Role['Name']);
if (in_array($Name, $Roles) || in_array($RoleID, $Roles)) {
$RoleIDs[] = $RoleID;
}
}
return $RoleIDs;
}
开发者ID:vanilla,项目名称:vanilla,代码行数:25,代码来源:class.usermodel.php
示例19: LogModel
$User = $Session->User;
$CssClass = '';
if ($this->CssClass) {
$CssClass .= ' ' . $this->CssClass;
}
$DashboardCount = 0;
// Spam & Moderation Queue
if ($Session->CheckPermission('Garden.Settings.Manage') || $Session->CheckPermission('Garden.Moderation.Manage')) {
$LogModel = new LogModel();
$SpamCount = $LogModel->GetOperationCount('spam');
$ModerationCount = $LogModel->GetOperationCount('moderate');
$DashboardCount += $SpamCount + $ModerationCount;
}
// Applicant Count
if ($Session->CheckPermission('Garden.Applicants.Manage')) {
$RoleModel = new RoleModel();
$ApplicantCount = $RoleModel->GetApplicantCount();
$DashboardCount += $ApplicantCount;
}
if ($Session->IsValid()) {
echo '<div class="MeBox' . $CssClass . '">';
echo UserPhoto($User);
echo '<div class="WhoIs">';
echo UserAnchor($User, 'Username');
echo '<div class="MeMenu">';
// Notifications
$CountNotifications = $User->CountNotifications;
$CNotifications = is_numeric($CountNotifications) && $CountNotifications > 0 ? '<span class="Alert">' . $CountNotifications . '</span>' : '';
echo '<span class="ToggleFlyout" rel="/profile/notificationspopin">';
echo Anchor(Sprite('SpNotifications', 'Sprite Sprite16') . Wrap(T('Notifications'), 'em') . $CNotifications, UserUrl($User), 'MeButton FlyoutButton', array('title' => T('Notifications')));
echo Sprite('SpFlyoutHandle', 'Arrow');
开发者ID:robhazkes,项目名称:Garden,代码行数:31,代码来源:me.php
示例20: EditCategory
public function EditCategory($CategoryID = '')
{
$this->Permission('Vanilla.Categories.Manage');
$RoleModel = new RoleModel();
$PermissionModel = Gdn::PermissionModel();
$this->Form->SetModel($this->CategoryModel);
$this->Category = $this->CategoryModel->GetID($CategoryID);
$this->AddJsFile('/js/library/jquery.gardencheckboxgrid.js');
$this->Title(T('Edit Category'));
$this->AddSideMenu('vanilla/settings/managecategories');
// Make sure the form knows which item we are editing.
$this->Form->AddHidden('CategoryID', $CategoryID);
// Load all roles with editable permissions
$this->RoleArray = $RoleModel->GetArray();
if ($this->Form->AuthenticatedPostBack() === FALSE) {
$this->Form->SetData($this->Category);
} else {
if ($this->Form->Save()) {
// Report success
$this->StatusMessage = T('The category was saved successfully.');
$this->RedirectUrl = Url('vanilla/settings/managecategories');
}
}
// Get all of the currently selected role/permission combinations for this junction
$Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => $CategoryID), 'Category');
$Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
$this->SetData('PermissionData', $Permissions, TRUE);
$this->Render();
}
开发者ID:sipp11,项目名称:Garden,代码行数:29,代码来源:class.settingscontroller.php
注:本文中的RoleModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论