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


PHP UserData::entries方法代码示例

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


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

示例1: SetMembers

 /**
  * Sets the Members of a group
  */
 public function SetMembers()
 {
     $db =& $this->db;
     $response = new ResponseManager();
     $groupObject = new UserGroup($db);
     $groupId = Kit::GetParam('GroupID', _REQUEST, _INT);
     $users = Kit::GetParam('UserID', _POST, _ARRAY, array());
     // We will receive a list of users from the UI which are in the "assign column" at the time the form is
     // submitted.
     // We want to go through and unlink any users that are NOT in that list, but that the current user has access
     // to edit.
     // We want to add any users that are in that list (but aren't already assigned)
     // All users that this session has access to
     if (!($allUsers = $this->user->userList())) {
         trigger_error(__('Error getting all users'), E_USER_ERROR);
     }
     // Convert to an array of ID's for convenience
     $allUserIds = array_map(function ($array) {
         return $array['userid'];
     }, $allUsers);
     // Users in group
     $usersAssigned = UserData::entries(null, array('groupIds' => array($groupId)));
     Debug::Audit('All userIds we want to assign: ' . var_export($users, true));
     Debug::Audit('All userIds we have access to: ' . var_export($allUserIds, true));
     foreach ($usersAssigned as $user) {
         /* @var Userdata $user */
         // Did this session have permission to do anything to this user?
         // If not, move on
         if (!in_array($user->userId, $allUserIds)) {
             continue;
         }
         Debug::Audit('Logged in user has permission to make changes to this assigned user ' . $user->userId);
         // Is this user in the provided list of users?
         if (in_array($user->userId, $users)) {
             // This user is already assigned, so we remove it from the $users array
             Debug::Audit('This user is already assigned ' . $user->userId);
             if (($key = array_search($user->userId, $users)) !== false) {
                 unset($users[$key]);
             }
         } else {
             Debug::Audit('This user is assigned, but not in the list of assignments ' . $user->userId);
             // It isn't therefore needs to be removed
             if (!$groupObject->Unlink($groupId, $user->userId)) {
                 trigger_error($groupObject->GetErrorMessage(), E_USER_ERROR);
             }
         }
     }
     Debug::Audit('All userIds we want to assign after sorting: ' . var_export($users, true));
     // Add any users that are still missing after tha assignment process
     foreach ($users as $userId) {
         Debug::Audit('User was missing, linking them: ' . $userId);
         // Add any that are missing
         if (!$groupObject->Link($groupId, $userId)) {
             trigger_error($groupObject->GetErrorMessage(), E_USER_ERROR);
         }
     }
     $response->SetFormSubmitResponse(__('Group membership set'), false);
     $response->Respond();
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:62,代码来源:group.class.php


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