本文整理汇总了PHP中Hubzero\User\Group::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::set方法的具体用法?PHP Group::set怎么用?PHP Group::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hubzero\User\Group
的用法示例。
在下文中一共展示了Group::set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveTask
/**
* Save group settings
*
* @return void
*/
public function saveTask()
{
// Check if they're logged in
if (User::isGuest()) {
$this->loginTask(Lang::txt('COM_GROUPS_CREATE_MUST_BE_LOGGED_IN'));
return;
}
Request::checkToken();
// Incoming
$g_gidNumber = Request::getInt('gidNumber', 0, 'post');
$c_gidNumber = Request::getVar('gidNumber', 0, 'post');
if ((string) $g_gidNumber !== (string) $c_gidNumber) {
App::abort(404, Lang::txt('COM_GROUPS_ERROR_NO_ID'));
}
if (!$g_gidNumber && !User::authorise('core.create', $this->_option) || $g_gidNumber && !User::authorise('core.edit', $this->_option)) {
return App::redirect(Route::url('index.php?option=' . $this->_option), Lang::txt('COM_GROUPS_ERROR_NOT_AUTH'), 'warning');
}
$g_cn = trim(Request::getVar('cn', '', 'post'));
$g_description = preg_replace('/\\s+/', ' ', trim(Request::getVar('description', Lang::txt('NONE'), 'post')));
$g_discoverability = Request::getInt('discoverability', 0, 'post');
$g_public_desc = Sanitize::stripScripts(trim(Request::getVar('public_desc', '', 'post', 'none', 2)));
$g_private_desc = Sanitize::stripScripts(trim(Request::getVar('private_desc', '', 'post', 'none', 2)));
$g_restrict_msg = Sanitize::stripScripts(trim(Request::getVar('restrict_msg', '', 'post', 'none', 2)));
$g_join_policy = Request::getInt('join_policy', 0, 'post');
$tags = trim(Request::getVar('tags', ''));
$lid = Request::getInt('lid', 0, 'post');
$customization = Request::getVar('group', '', 'POST', 'none', 2);
$plugins = Request::getVar('group_plugin', '', 'POST');
$params = Request::getVar('params', array(), 'POST');
$g_discussion_email_autosubscribe = Request::getInt('discussion_email_autosubscribe', 0, 'post');
//Check authorization
if ($this->_authorize() != 'manager' && $g_gidNumber != 0 && !$this->_authorizedForTask('group.edit')) {
$this->_errorHandler(403, Lang::txt('COM_GROUPS_ERROR_NOT_AUTH'));
}
//are we editing or creating
if ($g_gidNumber) {
$group = Group::getInstance($g_gidNumber);
$this->_task = 'edit';
$before = Group::getInstance($g_gidNumber);
} else {
$this->_task = 'new';
$group = new Group();
$before = new Group();
}
// Check for any missing info
if (!$g_cn) {
$this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_MISSING_INFORMATION') . ': ' . Lang::txt('COM_GROUPS_DETAILS_FIELD_CN'), 'error');
}
if (!$g_description) {
$this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_MISSING_INFORMATION') . ': ' . Lang::txt('COM_GROUPS_DETAILS_FIELD_DESCRIPTION'), 'error');
}
// Ensure the data passed is valid
if ($g_cn == 'new' || $g_cn == 'browse') {
$this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_INVALID_ID'), 'error');
}
if (!$this->_validCn($g_cn)) {
$this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_INVALID_ID'), 'error');
}
if ($this->_task == 'new' && Group::exists($g_cn, true)) {
$this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_ID_TAKEN'), 'error');
}
// Get the logo
$logo = '';
if (isset($customization['logo'])) {
$logo_parts = explode("/", $customization['logo']);
$logo = array_pop($logo_parts);
}
// Plugin settings
$plugin_access = '';
foreach ($plugins as $plugin) {
$plugin_access .= $plugin['name'] . '=' . $plugin['access'] . ',' . "\n";
}
// Run content through validation and spam filters
if (trim($g_public_desc)) {
$results = Event::trigger('content.onContentBeforeSave', array('com_groups.group.public_desc', &$g_public_desc, $this->_task == 'new'));
foreach ($results as $result) {
if ($result === false) {
$this->setNotification(Lang::txt('COM_GROUPS_SAVE_ERROR_FAILED_VALIDATION'), 'error');
break;
}
}
}
// Push back into edit mode if any errors
if ($this->getNotifications()) {
$group->set('cn', $g_cn);
$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('discussion_email_autosubscribe', $g_discussion_email_autosubscribe);
$group->set('logo', $logo);
$group->set('plugins', $plugin_access);
$this->lid = $lid;
//.........这里部分代码省略.........
示例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: 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();
}