当前位置: 首页>>代码示例>>PHP>>正文


PHP RoleModel::GetArray方法代码示例

本文整理汇总了PHP中RoleModel::GetArray方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::GetArray方法的具体用法?PHP RoleModel::GetArray怎么用?PHP RoleModel::GetArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RoleModel的用法示例。


在下文中一共展示了RoleModel::GetArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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:edward-tsai,项目名称:vanilla4china,代码行数:27,代码来源:class.conditionmodule.php

示例2: 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

示例3: EditCategory

 /**
  * Editing a category.
  * 
  * @since 2.0.0
  * @access public
  *
  * @param int $CategoryID Unique ID of the category to be updated.
  */
 public function EditCategory($CategoryID = '')
 {
     // Check permission
     $this->Permission('Vanilla.Categories.Manage');
     // Set up models
     $RoleModel = new RoleModel();
     $PermissionModel = Gdn::PermissionModel();
     $this->Form->SetModel($this->CategoryModel);
     // Get category data
     $this->Category = $this->CategoryModel->GetID($CategoryID);
     $this->Category->CustomPermissions = $this->Category->CategoryID == $this->Category->PermissionCategoryID;
     // Set up head
     $this->AddJsFile('jquery.alphanumeric.js');
     $this->AddJsFile('categories.js');
     $this->AddJsFile('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();
     $this->FireEvent('AddEditCategory');
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         $this->Form->SetData($this->Category);
     } else {
         if ($this->Form->Save()) {
             Redirect('vanilla/settings/managecategories');
         }
     }
     // Get all of the currently selected role/permission combinations for this junction.
     $Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => $CategoryID), 'Category', '', array('AddDefaults' => !$this->Category->CustomPermissions));
     $Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
     $this->SetData('PermissionData', $Permissions, TRUE);
     // Render default view
     $this->Render();
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:44,代码来源:class.settingscontroller.php

示例4: Edit

 /**
  * Edit user account.
  *
  * @since 2.0.0
  * @access public
  * @param mixed $UserReference Username or User ID.
  */
 public function Edit($UserReference = '', $Username = '', $UserID = '')
 {
     $this->Permission('Garden.SignIn.Allow');
     $this->GetUserInfo($UserReference, $Username, $UserID, TRUE);
     $UserID = GetValueR('User.UserID', $this);
     $Settings = array();
     // Set up form
     $User = Gdn::UserModel()->GetID($UserID, DATASET_TYPE_ARRAY);
     $this->Form->SetModel(Gdn::UserModel());
     $this->Form->SetData($User);
     $this->SetData('User', $User);
     // Decide if they have ability to edit the username
     $CanEditUsername = (bool) C("Garden.Profile.EditUsernames") || Gdn::Session()->CheckPermission('Garden.Users.Edit');
     $this->SetData('_CanEditUsername', $CanEditUsername);
     // Decide if they have ability to edit the email
     $EmailEnabled = (bool) C('Garden.Profile.EditEmails', TRUE) && !UserModel::NoEmail();
     $CanEditEmail = $EmailEnabled && $UserID == Gdn::Session()->UserID || CheckPermission('Garden.Users.Edit');
     $this->SetData('_CanEditEmail', $CanEditEmail);
     // Decide if they have ability to confirm users
     $Confirmed = (bool) GetValueR('User.Confirmed', $this);
     $CanConfirmEmail = UserModel::RequireConfirmEmail() && CheckPermission('Garden.Users.Edit');
     $this->SetData('_CanConfirmEmail', $CanConfirmEmail);
     $this->SetData('_EmailConfirmed', $Confirmed);
     $this->Form->SetValue('ConfirmEmail', (int) $Confirmed);
     // Decide if we can *see* email
     $this->SetData('_CanViewPersonalInfo', Gdn::Session()->UserID == GetValue('UserID', $User) || CheckPermission('Garden.PersonalInfo.View') || CheckPermission('Garden.Users.Edit'));
     // Define gender dropdown options
     $this->GenderOptions = array('u' => T('Unspecified'), 'm' => T('Male'), 'f' => T('Female'));
     $this->FireEvent('BeforeEdit');
     // If seeing the form for the first time...
     if ($this->Form->IsPostBack()) {
         $this->Form->SetFormValue('UserID', $UserID);
         if (!$CanEditUsername) {
             $this->Form->SetFormValue("Name", $User['Name']);
         } else {
             $UsernameError = T('UsernameError', 'Username can only contain letters, numbers, underscores, and must be between 3 and 20 characters long.');
             Gdn::UserModel()->Validation->ApplyRule('Name', 'Username', $UsernameError);
         }
         // API
         // These options become available when POSTing as a user with Garden.Settings.Manage permissions
         if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) {
             // Role change
             $RequestedRoles = $this->Form->GetFormValue('RoleID', NULL);
             if (!is_null($RequestedRoles)) {
                 $RoleModel = new RoleModel();
                 $AllRoles = $RoleModel->GetArray();
                 if (!is_array($RequestedRoles)) {
                     $RequestedRoles = is_numeric($RequestedRoles) ? array($RequestedRoles) : array();
                 }
                 $RequestedRoles = array_flip($RequestedRoles);
                 $UserNewRoles = array_intersect_key($AllRoles, $RequestedRoles);
                 // Put the data back into the forum object as if the user had submitted
                 // this themselves
                 $this->Form->SetFormValue('RoleID', array_keys($UserNewRoles));
                 // Allow saving roles
                 $Settings['SaveRoles'] = TRUE;
             }
             // Password change
             $NewPassword = $this->Form->GetFormValue('Password', NULL);
             if (!is_null($NewPassword)) {
             }
         }
         // Allow mods to confirm emails
         $this->Form->RemoveFormValue('Confirmed');
         $Confirmation = $this->Form->GetFormValue('ConfirmEmail', null);
         $Confirmation = !is_null($Confirmation) ? (bool) $Confirmation : null;
         if ($CanConfirmEmail && is_bool($Confirmation)) {
             $this->Form->SetFormValue('Confirmed', (int) $Confirmation);
         }
         if ($this->Form->Save($Settings) !== FALSE) {
             $User = Gdn::UserModel()->GetID($UserID, DATASET_TYPE_ARRAY);
             $this->SetData('Profile', $User);
             $this->InformMessage(Sprite('Check', 'InformSprite') . T('Your changes have been saved.'), 'Dismissable AutoDismiss HasSprite');
         }
         if (!$CanEditEmail) {
             $this->Form->SetFormValue("Email", $User['Email']);
         }
     }
     $this->Title(T('Edit Profile'));
     $this->_SetBreadcrumbs(T('Edit Profile'), '/profile/edit');
     $this->Render();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:89,代码来源:class.profilecontroller.php

示例5: EditCategory

 /**
  * Editing a category.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $CategoryID Unique ID of the category to be updated.
  */
 public function EditCategory($CategoryID = '')
 {
     // Check permission
     $this->Permission('Garden.Settings.Manage');
     // Set up models
     $RoleModel = new RoleModel();
     $PermissionModel = Gdn::PermissionModel();
     $this->Form->SetModel($this->CategoryModel);
     if (!$CategoryID && $this->Form->IsPostBack()) {
         if ($ID = $this->Form->GetFormValue('CategoryID')) {
             $CategoryID = $ID;
         }
     }
     // Get category data
     $this->Category = $this->CategoryModel->GetID($CategoryID);
     $this->Category->CustomPermissions = $this->Category->CategoryID == $this->Category->PermissionCategoryID;
     // Set up head
     $this->AddJsFile('jquery.alphanumeric.js');
     $this->AddJsFile('categories.js');
     $this->AddJsFile('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);
     $this->SetData('CategoryID', $CategoryID);
     // Load all roles with editable permissions
     $this->RoleArray = $RoleModel->GetArray();
     $this->FireEvent('AddEditCategory');
     if ($this->Form->IsPostBack() == FALSE) {
         $this->Form->SetData($this->Category);
         $this->SetupDiscussionTypes($this->Category);
         $this->Form->SetValue('CustomPoints', $this->Category->PointsCategoryID == $this->Category->CategoryID);
     } else {
         $this->SetupDiscussionTypes($this->Category);
         $Upload = new Gdn_Upload();
         $TmpImage = $Upload->ValidateUpload('PhotoUpload', FALSE);
         if ($TmpImage) {
             // Generate the target image name
             $TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS);
             $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
             // Save the uploaded image
             $Parts = $Upload->SaveAs($TmpImage, $ImageBaseName);
             $this->Form->SetFormValue('Photo', $Parts['SaveName']);
         }
         $this->Form->SetFormValue('CustomPoints', (bool) $this->Form->GetFormValue('CustomPoints'));
         if ($this->Form->Save()) {
             $Category = CategoryModel::Categories($CategoryID);
             $this->SetData('Category', $Category);
             if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
                 Redirect('vanilla/settings/managecategories');
             }
         }
     }
     // Get all of the currently selected role/permission combinations for this junction.
     $Permissions = $PermissionModel->GetJunctionPermissions(array('JunctionID' => $CategoryID), 'Category', '', array('AddDefaults' => !$this->Category->CustomPermissions));
     $Permissions = $PermissionModel->UnpivotPermissions($Permissions, TRUE);
     if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
         $this->SetData('PermissionData', $Permissions, TRUE);
     }
     // Render default view
     $this->Render();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:70,代码来源:class.settingscontroller.php

示例6: GetByRole

 public function GetByRole($Role)
 {
     $RoleID = $Role;
     // Optimistic
     if (is_string($Role)) {
         $RoleModel = new RoleModel();
         $Roles = $RoleModel->GetArray();
         $RolesByName = array_flip($Roles);
         $RoleID = GetValue($Role, $RolesByName, NULL);
         // No such role
         if (is_null($RoleID)) {
             return new Gdn_DataSet();
         }
     }
     return $this->SQL->Select('u.*')->From('User u')->Join('UserRole ur', 'u.UserID = ur.UserID')->Where('ur.RoleID', $RoleID, TRUE, FALSE)->OrderBy('DateInserted', 'desc')->Get();
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:16,代码来源:class.usermodel.php

示例7: Edit

 /**
  * Edit a user account.
  *
  * @since 2.0.0
  * @access public
  * @param int $UserID Unique ID.
  */
 public function Edit($UserID)
 {
     $this->Permission('Garden.Users.Edit');
     // Page setup
     $this->AddJsFile('user.js');
     $this->Title(T('Edit User'));
     $this->AddSideMenu('dashboard/user');
     // Only admins can reassign roles
     $RoleModel = new RoleModel();
     $AllRoles = $RoleModel->GetArray();
     $RoleData = CheckPermission('Garden.Settings.Manage') ? $AllRoles : array();
     $UserModel = new UserModel();
     $User = $UserModel->GetID($UserID, DATASET_TYPE_ARRAY);
     // Determine if username can be edited
     $CanEditUsername = (bool) C("Garden.Profile.EditUsernames") || Gdn::Session()->CheckPermission('Garden.Users.Edit');
     $this->SetData('_CanEditUsername', $CanEditUsername);
     // Determine if emails can be edited
     $CanEditEmail = Gdn::Session()->CheckPermission('Garden.Users.Edit');
     $this->SetData('_CanEditEmail', $CanEditEmail);
     // Decide if they have ability to confirm users
     $Confirmed = (bool) GetValueR('Confirmed', $User);
     $CanConfirmEmail = UserModel::RequireConfirmEmail() && Gdn::Session()->CheckPermission('Garden.Users.Edit');
     $this->SetData('_CanConfirmEmail', $CanConfirmEmail);
     $this->SetData('_EmailConfirmed', $Confirmed);
     $User['ConfirmEmail'] = (int) $Confirmed;
     // Determine whether user being edited is privileged (can escalate permissions)
     $UserModel = new UserModel();
     $EditingPrivilegedUser = $UserModel->CheckPermission($User, 'Garden.Settings.Manage');
     // Determine our password reset options
     // Anyone with user editing my force reset over email
     $this->ResetOptions = array(0 => T('Keep current password.'), 'Auto' => T('Force user to reset their password and send email notification.'));
     // Only admins may manually reset passwords for other admins
     if (CheckPermission('Garden.Settings.Manage') || !$EditingPrivilegedUser) {
         $this->ResetOptions['Manual'] = T('Manually set user password. No email notification.');
     }
     // Set the model on the form.
     $this->Form->SetModel($UserModel);
     // Make sure the form knows which item we are editing.
     $this->Form->AddHidden('UserID', $UserID);
     try {
         $AllowEditing = TRUE;
         $this->EventArguments['AllowEditing'] =& $AllowEditing;
         $this->EventArguments['TargetUser'] =& $User;
         // These are all the 'effective' roles for this edit action. This list can
         // be trimmed down from the real list to allow subsets of roles to be
         // edited.
         $this->EventArguments['RoleData'] =& $RoleData;
         $UserRoleData = $UserModel->GetRoles($UserID)->ResultArray();
         $RoleIDs = ConsolidateArrayValuesByKey($UserRoleData, 'RoleID');
         $RoleNames = ConsolidateArrayValuesByKey($UserRoleData, 'Name');
         $UserRoleData = ArrayCombine($RoleIDs, $RoleNames);
         $this->EventArguments['UserRoleData'] =& $UserRoleData;
         $this->FireEvent("BeforeUserEdit");
         $this->SetData('AllowEditing', $AllowEditing);
         $this->Form->SetData($User);
         if ($this->Form->AuthenticatedPostBack()) {
             if (!$CanEditUsername) {
                 $this->Form->SetFormValue("Name", $User['Name']);
             }
             // Allow mods to confirm/unconfirm emails
             $this->Form->RemoveFormValue('Confirmed');
             $Confirmation = $this->Form->GetFormValue('ConfirmEmail', null);
             $Confirmation = !is_null($Confirmation) ? (bool) $Confirmation : null;
             if ($CanConfirmEmail && is_bool($Confirmation)) {
                 $this->Form->SetFormValue('Confirmed', (int) $Confirmation);
             }
             $ResetPassword = $this->Form->GetValue('ResetPassword', FALSE);
             // If we're an admin or this isn't a privileged user, allow manual setting of password
             $AllowManualReset = CheckPermission('Garden.Settings.Manage') || !$EditingPrivilegedUser;
             if ($ResetPassword == 'Manual' && $AllowManualReset) {
                 // If a new password was specified, add it to the form's collection
                 $NewPassword = $this->Form->GetValue('NewPassword', '');
                 $this->Form->SetFormValue('Password', $NewPassword);
             }
             // Role changes
             // These are the new roles the editing user wishes to apply to the target
             // user, adjusted for his ability to affect those roles
             $RequestedRoles = $this->Form->GetFormValue('RoleID');
             if (!is_array($RequestedRoles)) {
                 $RequestedRoles = array();
             }
             $RequestedRoles = array_flip($RequestedRoles);
             $UserNewRoles = array_intersect_key($RoleData, $RequestedRoles);
             // These roles will stay turned on regardless of the form submission contents
             // because the editing user does not have permission to modify them
             $ImmutableRoles = array_diff_key($AllRoles, $RoleData);
             $UserImmutableRoles = array_intersect_key($ImmutableRoles, $UserRoleData);
             // Apply immutable roles
             foreach ($UserImmutableRoles as $IMRoleID => $IMRoleName) {
                 $UserNewRoles[$IMRoleID] = $IMRoleName;
             }
             // Put the data back into the forum object as if the user had submitted
             // this themselves
//.........这里部分代码省略.........
开发者ID:3marproof,项目名称:vanilla,代码行数:101,代码来源:class.usercontroller.php

示例8: Edit

 /**
  * Edit a user account.
  *
  * @since 2.0.0
  * @access public
  * @param int $UserID Unique ID.
  */
 public function Edit($UserID)
 {
     $this->Permission('Garden.Users.Edit');
     // Page setup
     $this->AddJsFile('user.js');
     $this->Title(T('Edit User'));
     $this->AddSideMenu('dashboard/user');
     // Determine if username can be edited
     $this->CanEditUsername = TRUE;
     $this->CanEditUsername = $this->CanEditUsername & Gdn::Config("Garden.Profile.EditUsernames");
     $this->CanEditUsername = $this->CanEditUsername | Gdn::Session()->CheckPermission('Garden.Users.Edit');
     $RoleModel = new RoleModel();
     $AllRoles = $RoleModel->GetArray();
     // By default, people with access here can freely assign all roles
     $this->RoleData = $AllRoles;
     $UserModel = new UserModel();
     $this->User = $UserModel->GetID($UserID);
     // Set the model on the form.
     $this->Form->SetModel($UserModel);
     // Make sure the form knows which item we are editing.
     $this->Form->AddHidden('UserID', $UserID);
     try {
         $AllowEditing = TRUE;
         $this->EventArguments['AllowEditing'] =& $AllowEditing;
         $this->EventArguments['TargetUser'] =& $this->User;
         // These are all the 'effective' roles for this edit action. This list can
         // be trimmed down from the real list to allow subsets of roles to be
         // edited.
         $this->EventArguments['RoleData'] =& $this->RoleData;
         $UserRoleData = $UserModel->GetRoles($UserID)->ResultArray();
         $RoleIDs = ConsolidateArrayValuesByKey($UserRoleData, 'RoleID');
         $RoleNames = ConsolidateArrayValuesByKey($UserRoleData, 'Name');
         $this->UserRoleData = ArrayCombine($RoleIDs, $RoleNames);
         $this->EventArguments['UserRoleData'] =& $this->UserRoleData;
         $this->FireEvent("BeforeUserEdit");
         $this->SetData('AllowEditing', $AllowEditing);
         if (!$this->Form->AuthenticatedPostBack()) {
             $this->Form->SetData($this->User);
         } else {
             if (!$this->CanEditUsername) {
                 $this->Form->SetFormValue("Name", $this->User->Name);
             }
             // If a new password was specified, add it to the form's collection
             $ResetPassword = $this->Form->GetValue('ResetPassword', FALSE);
             $NewPassword = $this->Form->GetValue('NewPassword', '');
             if ($ResetPassword !== FALSE) {
                 $this->Form->SetFormValue('Password', $NewPassword);
             }
             // Role changes
             // These are the new roles the editing user wishes to apply to the target
             // user, adjusted for his ability to affect those roles
             $RequestedRoles = $this->Form->GetFormValue('RoleID');
             if (!is_array($RequestedRoles)) {
                 $RequestedRoles = array();
             }
             $RequestedRoles = array_flip($RequestedRoles);
             $UserNewRoles = array_intersect_key($this->RoleData, $RequestedRoles);
             // These roles will stay turned on regardless of the form submission contents
             // because the editing user does not have permission to modify them
             $ImmutableRoles = array_diff_key($AllRoles, $this->RoleData);
             $UserImmutableRoles = array_intersect_key($ImmutableRoles, $this->UserRoleData);
             // Apply immutable roles
             foreach ($UserImmutableRoles as $IMRoleID => $IMRoleName) {
                 $UserNewRoles[$IMRoleID] = $IMRoleName;
             }
             // Put the data back into the forum object as if the user had submitted
             // this themselves
             $this->Form->SetFormValue('RoleID', array_keys($UserNewRoles));
             if ($this->Form->Save(array('SaveRoles' => TRUE)) !== FALSE) {
                 if ($this->Form->GetValue('Password', '') != '') {
                     $UserModel->SendPasswordEmail($UserID, $NewPassword);
                 }
                 $this->InformMessage(T('Your changes have been saved.'));
             }
             $this->UserRoleData = $UserNewRoles;
         }
     } catch (Exception $Ex) {
         $this->Form->AddError($Ex);
     }
     $this->Render();
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:88,代码来源:class.usercontroller.php

示例9: Edit

 /**
  * Edit an existing rank or add a new one
  *
  * @param int $RankID
  * @throws ForbiddenException if no proper rules are found
  */
 public function Edit($RankID = NULL)
 {
     $this->Permission('Yaga.Ranks.Manage');
     $this->AddSideMenu('rank/settings');
     $this->Form->SetModel($this->RankModel);
     $Edit = FALSE;
     if ($RankID) {
         $this->Title(T('Yaga.Rank.Edit'));
         $this->Rank = $this->RankModel->GetByID($RankID);
         $this->Form->AddHidden('RankID', $RankID);
         $Edit = TRUE;
     } else {
         $this->Title(T('Yaga.Rank.Add'));
     }
     // Load up all roles
     $RoleModel = new RoleModel();
     $Roles = $RoleModel->GetArray();
     $this->SetData('Roles', $Roles);
     if ($this->Form->IsPostBack() != TRUE) {
         if (property_exists($this, 'Rank')) {
             $PerkOptions = (array) unserialize($this->Rank->Perks);
             $RankArray = (array) $this->Rank;
             $Data = array_merge($RankArray, $PerkOptions);
             $this->Form->SetData($Data);
         }
     } else {
         // Find the perk options
         $FormValues = $this->Form->FormValues();
         $PerkOptions = array();
         foreach ($FormValues as $Key => $Value) {
             // Don't save default settings
             if ($Value === '') {
                 continue;
             }
             if (substr($Key, 0, 7) == '_Perks/') {
                 $RealKey = substr($Key, 7);
                 $PerkOptions[$RealKey] = $Value;
             }
         }
         // Fire event for validating perk options
         $this->EventArguments['PerkOptions'] =& $PerkOptions;
         $this->FireEvent('BeforeValidation');
         $this->Form->SetFormValue('Perks', serialize($PerkOptions));
         if ($this->Form->Save()) {
             if ($Edit) {
                 $this->InformMessage(T('Yaga.Rank.Updated'));
             } else {
                 $this->InformMessage(T('Yaga.Rank.Added'));
             }
             Redirect('/rank/settings');
         }
     }
     include_once $this->FetchViewLocation('helper_functions', 'rank');
     $this->Render('edit');
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:61,代码来源:class.rankcontroller.php


注:本文中的RoleModel::GetArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。