本文整理汇总了PHP中Hubzero\User\Group::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::update方法的具体用法?PHP Group::update怎么用?PHP Group::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Group
的用法示例。
在下文中一共展示了Group::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
}
示例2: 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);
}
示例3: saveTask
//.........这里部分代码省略.........
if ($this->_task == 'new') {
$subject = Lang::txt('COM_GROUPS_SAVE_EMAIL_REQUESTED_SUBJECT', $g_cn);
$type = 'groups_created';
} else {
$subject = Lang::txt('COM_GROUPS_SAVE_EMAIL_UPDATED_SUBJECT', $g_cn);
$type = 'groups_changed';
}
if ($this->_task == 'new') {
$group->set('cn', $g_cn);
$group->set('type', 1);
$group->set('published', 1);
$group->set('approved', $this->config->get('auto_approve', 1));
$group->set('created', Date::toSql());
$group->set('created_by', User::get('id'));
$group->add('managers', array(User::get('id')));
$group->add('members', array(User::get('id')));
$group->create();
}
// merge incoming settings with existing params
$params = new Registry($params);
$gParams = new Registry($group->get('params'));
$gParams->merge($params);
//set group vars & Save group
$group->set('description', $g_description);
$group->set('public_desc', $g_public_desc);
$group->set('private_desc', $g_private_desc);
$group->set('join_policy', $g_join_policy);
$group->set('restrict_msg', $g_restrict_msg);
$group->set('discoverability', $g_discoverability);
$group->set('logo', $logo);
$group->set('plugins', $plugin_access);
$group->set('discussion_email_autosubscribe', $g_discussion_email_autosubscribe);
$group->set('params', $gParams->toString());
$group->update();
// Process tags
$gt = new Tags($group->get('gidNumber'));
$gt->setTags($tags, User::get('id'));
// Rename the temporary upload directory if it exist
$log_comments = '';
Event::trigger('groups.onGroupAfterSave', array($before, $group));
if ($this->_task == 'new') {
if ($lid != $group->get('gidNumber')) {
$config = $this->config;
$bp = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/groups'), DS);
if (is_dir($bp . DS . $lid)) {
rename($bp . DS . $lid, $bp . DS . $group->get('gidNumber'));
}
}
$log_action = 'group_created';
// Trigger the functions that delete associated content
// Should return logs of what was deleted
$logs = Event::trigger('groups.onGroupNew', array($group));
if (count($logs) > 0) {
$log_comments .= implode('', $logs);
}
} else {
$log_action = 'group_edited';
}
// log invites
Log::log(array('gidNumber' => $group->get('gidNumber'), 'action' => $log_action, 'comments' => $log_comments));
// Build the e-mail message
// Note: this is done *before* pushing the changes to the group so we can show, in the message, what was changed
$eview = new \Hubzero\Component\View(array('name' => 'emails', 'layout' => 'saved'));
$eview->option = $this->_option;
$eview->user = User::getRoot();
$eview->group = $group;
示例4: 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();
}