本文整理汇总了PHP中Hubzero\User\Group::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::read方法的具体用法?PHP Group::read怎么用?PHP Group::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Group
的用法示例。
在下文中一共展示了Group::read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayTask
/**
* Displays a list of groups
*
* @return void
*/
public function displayTask()
{
// Incoming
$this->view->filters = array('gid' => Request::getState($this->_option . '.' . $this->_controller . '.gid', 'gid', ''));
// Ensure we have a group ID
if (!$this->view->filters['gid']) {
App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_GROUPS_MISSING_ID'), 'error');
return;
}
// Load the group page
$group = new Group();
$group->read($this->view->filters['gid']);
$this->view->filters['gidNumber'] = $group->get('gidNumber');
$this->view->filters['search'] = urldecode(trim(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')));
$this->view->filters['status'] = trim(Request::getState($this->_option . '.' . $this->_controller . '.status', 'status', ''));
// Sorting options
$this->view->filters['sort'] = trim(Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'name'));
$this->view->filters['sort_Dir'] = trim(Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'));
// Filters for returning results
$this->view->filters['limit'] = Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int');
$this->view->filters['start'] = Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int');
// In case limit has been changed, adjust limitstart accordingly
$this->view->filters['start'] = $this->view->filters['limit'] != 0 ? floor($this->view->filters['start'] / $this->view->filters['limit']) * $this->view->filters['limit'] : 0;
$tbl = new Tables\Group($this->database);
$this->view->total = $tbl->countMembers($this->view->filters);
$this->view->rows = $tbl->findMembers($this->view->filters);
//add invite emails to list
if ($this->view->filters['status'] == '' || $this->view->filters['status'] == 'invitee') {
//get group invite emails
$hubzeroGroupInviteEmail = new \Hubzero\User\Group\InviteEmail($this->database);
$inviteemails = $hubzeroGroupInviteEmail->getInviteEmails($group->get('gidNumber'));
//add invite emails to list
foreach ($inviteemails as $inviteemail) {
$this->view->rows[$inviteemail['email']] = new \stdClass();
$this->view->rows[$inviteemail['email']]->name = $inviteemail['email'];
$this->view->rows[$inviteemail['email']]->username = null;
$this->view->rows[$inviteemail['email']]->email = $inviteemail['email'];
$this->view->rows[$inviteemail['email']]->uidNumber = null;
$this->view->rows[$inviteemail['email']]->role = 'inviteemail';
}
}
$this->view->group = $group;
// Set any errors
foreach ($this->getErrors() as $error) {
$this->view->setError($error);
}
// Output the HTML
$this->view->display();
}
示例2: approveTask
/**
* Approve a group
*
* @return void
*/
public function approveTask()
{
// Incoming
$ids = Request::getVar('id', array());
// Get the single ID we're working with
if (!is_array($ids)) {
$ids = array($ids);
}
// Do we have any IDs?
if (!empty($ids)) {
// foreach group id passed in
foreach ($ids as $id) {
// Load the group page
$group = new Group();
$group->read($id);
// Ensure we found the group info
if (!$group) {
continue;
}
//set the group to be published and update
$group->set('approved', 1);
$group->update();
// log publishing
Log::log(array('gidNumber' => $group->get('gidNumber'), 'action' => 'group_approved', 'comments' => 'approved by administrator'));
}
// Output messsage and redirect
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_GROUPS_APPROVED'));
}
}
示例3: delegateTask
/**
* Assign members to a role
*
* @return void
*/
public function delegateTask()
{
Request::setVar('hidemainmenu', 1);
$ids = Request::getVar('id', array());
$ids = !is_array($ids) ? array($ids) : $ids;
$gid = Request::getVar('gid', '');
$roleid = Request::getInt('roleid', 0);
if (!$gid) {
App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_GROUPS_MISSING_ID'), 'error');
}
$group = new Group();
$group->read($gid);
foreach ($ids as $id) {
$model = \Components\Groups\Models\Member\Role::oneByUserAndRole((int) $id, $roleid);
if (!$model->get('id')) {
$model->set('roleid', $roleid);
$model->set('uidNumber', (int) $id);
$model->save();
}
}
$this->cancelTask();
}
示例4: removeTask
/**
* Remove member(s) from a group
* Disallows removal of last manager (group must have at least one)
*
* @return void
*/
public function removeTask()
{
// Check for request forgeries
Request::checkToken(['get', 'post']);
$gid = Request::getVar('gid', '');
// Load the group page
$group = new Group();
$group->read($gid);
// Get all the group's managers
$managers = $group->get('managers');
// Get all the group's members
$members = $group->get('members');
$users_mem = array();
$users_man = array();
// Incoming array of users to remove
$id = Request::getInt('id', 0);
// Ensure we found an account
if (!$id) {
\App::abort(404, Lang::txt('COM_MEMBERS_NOT_FOUND'));
}
if (in_array($id, $members)) {
$users_mem[] = $id;
}
if (in_array($id, $managers)) {
$users_man[] = $id;
}
// Remove users from members list
$group->remove('members', $users_mem);
// Remove users from managers list
$group->remove('managers', $users_man);
// Save changes
$group->update();
// Push through to the groups view
$this->displayTask($id);
}
示例5: unapproveTask
/**
* Unapprove a group
*
* @return void
*/
public function unapproveTask()
{
// Check for request forgeries
//Request::checkToken();
if (!User::authorise('core.manage', $this->_option) && !User::authorise('core.admin', $this->_option) && !User::authorise('core.edit', $this->_option) && !User::authorise('core.edit.state', $this->_option)) {
App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
}
// Incoming
$ids = Request::getVar('id', array());
// Get the single ID we're working with
if (!is_array($ids)) {
$ids = array($ids);
}
$i = 0;
// foreach group id passed in
foreach ($ids as $id) {
// Load the group page
$group = new Group();
$group->read($id);
// Ensure we found the group info
if (!$group) {
continue;
}
// Set the group to be published and update
$group->set('approved', 0);
$group->update();
$i++;
// log publishing
Log::log(array('gidNumber' => $group->get('gidNumber'), 'action' => 'group_unapproved', 'comments' => 'unapproved by administrator'));
}
if ($i) {
Notify::success(Lang::txt('COM_GROUPS_UNAPPROVED'));
}
// Output messsage and redirect
$this->cancelTask();
}