public function roleTreeGetChildsByIdAction() { $list = new User\Role\Listing(); $list->setCondition("parentId = ?", intval($this->getParam("node"))); $list->load(); $roles = []; if (is_array($list->getItems())) { foreach ($list->getItems() as $role) { $roles[] = $this->getRoleTreeNodeConfig($role); } } $this->_helper->json($roles); }
/** * Returns a list of users given an array of ID's * if an ID is a role, all users associated with that role * will also be returned. * @param $userIds */ private static function getNotificationUsers($userIds) { $notifyUsers = []; //get roles $roleList = new User\Role\Listing(); $roleList->setCondition('id in (?)', [implode(',', $userIds)]); foreach ($roleList->load() as $role) { $userList = new User\Listing(); $userList->setCondition('FIND_IN_SET(?, roles) > 0', [$role->getId()]); foreach ($userList->load() as $user) { if ($user->getEmail()) { $notifyUsers[] = $user; } } } unset($roleList, $user, $role); //get users $roleList = new User\Listing(); $roleList->setCondition('id in (?)', [implode(',', $userIds)]); foreach ($roleList->load() as $user) { /** * @var User $user */ if ($user->getEmail()) { $notifyUsers[] = $user; } } return $notifyUsers; }