本文整理汇总了PHP中group_user_add函数的典型用法代码示例。如果您正苦于以下问题:PHP group_user_add函数的具体用法?PHP group_user_add怎么用?PHP group_user_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了group_user_add函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_notifications
public function test_notifications()
{
global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_log;
include_once $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx;
include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
include_once $phpbb_root_path . 'includes/functions_content.' . $phpEx;
set_config(false, false, false, $this->config);
$this->container->set('groupposition.legend', new \phpbb\groupposition\legend($this->db, $this->user));
$this->container->set('groupposition.teampage', new \phpbb\groupposition\teampage($this->db, $this->user, $this->cache->get_driver()));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_log = new \phpbb\log\null();
// Now on to the actual test
$group_id = false;
group_create($group_id, GROUP_OPEN, 'test', 'test group', array());
// Add user 2 as group leader
group_user_add($group_id, 2, false, false, false, true, false);
// Add user 3 as pending
group_user_add($group_id, 3, false, false, false, false, true);
$this->assert_notifications(array(array('item_id' => 3, 'item_parent_id' => $group_id, 'user_id' => 2, 'notification_read' => 0, 'notification_data' => array('group_name' => 'test'))), array('user_id' => 2));
// Approve user 3 joining the group
group_user_attributes('approve', $group_id, array(3));
// user 3 pending notification should have been deleted
$this->assert_notifications(array(), array('user_id' => 2));
$this->assert_notifications(array(array('item_id' => $group_id, 'user_id' => 3, 'notification_read' => 0, 'notification_data' => array('group_name' => 'test'))), array('user_id' => 3));
}
示例2: update_group
/**
* Update a phpbb3 group
*
* @param int $group_id
* @param array:int $members_to_remove
* @param array:int $members_to_add
*/
function update_group($group_id, $members_to_remove, $members_to_add)
{
if (sizeof($members_to_remove)) {
$err = group_user_del($group_id, $members_to_remove);
if ($err) {
logln("[ERROR] could not remove members: {$err}");
} else {
logln("Removed " . sizeof($members_to_remove) . " members: " . implode(', ', $members_to_remove));
}
}
if (sizeof($members_to_add)) {
$err = group_user_add($group_id, $members_to_add);
if ($err) {
logln("[ERROR] could not add members: {$err}");
} else {
logln("Added " . sizeof($members_to_add) . " members: " . implode(', ', $members_to_add));
}
}
}
示例3: add_users_to_group
/**
* {@inheritdoc}
*/
public function add_users_to_group($user_id_ary, $group_rule_data)
{
// Set this variable for readability in the code below
$group_id = $group_rule_data['autogroups_group_id'];
// Add user(s) to the group
group_user_add($group_id, $user_id_ary);
// Send notification
if ($group_rule_data['autogroups_notify']) {
$this->helper->send_notifications('group_added', $user_id_ary, $group_id);
}
// Set group as default?
if ($group_rule_data['autogroups_default']) {
// Make sure user_id_ary is an array
$user_id_ary = $this->helper->prepare_users_for_query($user_id_ary);
// Get array of users exempt from default group switching
$default_exempt_users = $this->helper->get_default_exempt_users();
// Remove any exempt users from our main user array
if (sizeof($default_exempt_users)) {
$user_id_ary = array_diff($user_id_ary, $default_exempt_users);
}
// Set the current group as default for non-exempt users
group_user_attributes('default', $group_id, $user_id_ary);
}
}
示例4: eveapi_setForumGroups
/**
* Sets character's Forum permissions
*/
function eveapi_setForumGroups($userId, $forumGroupsNew, $characterName = "---")
{
global $db, $config, $user;
if (!is_array($forumGroupsNew)) {
$forumGroupsNew = array();
}
// Grab all the forumgroups and put them into an array to be able to easily request values for EVE related stuffz
$forumGroupInfo = array();
$sql = "SELECT group_id, group_type, group_name, group_eveapi_special, group_eveapi_ts3, group_eveapi_jabber, group_eveapi_openfire\n\t\t\tFROM " . GROUPS_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$forumGroupInfo[$row['group_id']]['group_name'] = $row['group_name'];
$forumGroupInfo[$row['group_id']]['group_type'] = $row['group_type'];
$forumGroupInfo[$row['group_id']]['group_eveapi_special'] = $row['group_eveapi_special'];
$forumGroupInfo[$row['group_id']]['group_eveapi_ts3'] = $row['group_eveapi_ts3'];
$forumGroupInfo[$row['group_id']]['group_eveapi_jabber'] = $row['group_eveapi_jabber'];
$forumGroupInfo[$row['group_id']]['group_eveapi_openfire'] = $row['group_eveapi_openfire'];
// Check if the group name is actually a language identifier
// If so, grab the correct language string from the language file instead
// ( group prefix is G_ )
if (isset($user->lang["G_" . $row['group_name']])) {
$forumGroupInfo[$row['group_id']]['group_name'] = $user->lang["G_" . $row['group_name']];
}
// By default the REGISTERED group_id is 2, but that may not be the case 100% of the time.
if ($row['group_name'] == 'REGISTERED') {
$registeredGroupID = (int) $row['group_id'];
}
}
$db->sql_freeresult($result);
$forumGroups = array();
$sql = "SELECT group_id\n FROM " . USER_GROUP_TABLE . "\n WHERE user_id = " . (int) $userId;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$forumGroups[] = $row['group_id'];
}
$db->sql_freeresult($result);
// All active users are part of the REGISTERED group.
$forumGroups[] = $registeredGroupID;
// Set array for TeamSpeak groups if Forum Groups are set to immune.
$returnGroups = array();
// Set jabber access to default (just in case)
$returnGroups["jabber"] = false;
$returnGroups["openfire"] = array();
$returnGroups["TS"] = array();
// Add existing Special phpBB groups to new groups to ensure they are not removed.
foreach ($forumGroups as $currentForumGroup) {
if ($forumGroupInfo[$currentForumGroup]['group_type'] == GROUP_SPECIAL) {
$forumGroupsNew = $forumGroupsNew + array($currentForumGroup => false);
}
}
// All active users are part of the REGISTERED group, so it is always "New"
$forumGroupsNew = $forumGroupsNew + array($registeredGroupID => false);
// Loop groups to determine if we need to remove some permissions
foreach ($forumGroups as $currentForumGroup) {
// User should not be in this group, or is the special group? Hhmmm...
if (!isset($forumGroupsNew[$currentForumGroup]) && !$forumGroupInfo[$currentForumGroup]['group_eveapi_special']) {
group_user_del($currentForumGroup, $userId);
cronlog("Removing user from Forum group -> " . $forumGroupInfo[$currentForumGroup]['group_name'], $characterName);
} else {
// User is part of this group, add the TeamSpeak groupId to the list if the group >0
if ($forumGroupInfo[$currentForumGroup]['group_eveapi_ts3']) {
$returnGroups["TS"][] = $forumGroupInfo[$currentForumGroup]['group_eveapi_ts3'];
}
// Add ejabberd access aswell
if ($forumGroupInfo[$currentForumGroup]['group_eveapi_jabber']) {
$returnGroups["jabber"] = true;
}
// Add OpenFire access aswell
if ($forumGroupInfo[$currentForumGroup]['group_eveapi_openfire'] != "") {
$returnGroups["openfire"][] = $forumGroupInfo[$currentForumGroup]['group_eveapi_openfire'];
}
}
}
// Maybe we need to add groups
foreach ($forumGroupsNew as $currentForumGroup => $defaultGroup) {
if (!in_array($currentForumGroup, $forumGroups)) {
group_user_add($currentForumGroup, $userId, false, false, $defaultGroup ? true : false);
cronlog("Adding user to Forum group -> " . $forumGroupInfo[$currentForumGroup]['group_name'], $characterName);
} else {
cronlog("User already part of Forum group -> " . $forumGroupInfo[$currentForumGroup]['group_name'], $characterName);
}
// User should be part of this group, add the TeamSpeak groupId to the list if the group >0
if ($forumGroupInfo[$currentForumGroup]['group_eveapi_ts3']) {
$returnGroups["TS"][] = $forumGroupInfo[$currentForumGroup]['group_eveapi_ts3'];
}
// Add ejabberd access aswell
if ($forumGroupInfo[$currentForumGroup]['group_eveapi_jabber']) {
$returnGroups["jabber"] = true;
}
// Add OpenFire access aswell
if ($forumGroupInfo[$currentForumGroup]['group_eveapi_openfire'] != "") {
$returnGroups["openfire"][] = $forumGroupInfo[$currentForumGroup]['group_eveapi_openfire'];
}
}
return $returnGroups;
}
示例5: main
//.........这里部分代码省略.........
break;
case 'groups':
$user->add_lang(array('groups', 'acp/groups'));
$group_id = request_var('g', 0);
switch ($action) {
case 'demote':
case 'promote':
case 'default':
group_user_attributes($action, $group_id, $user_id);
if ($action == 'default') {
$user_row['group_id'] = $group_id;
}
break;
case 'delete':
if (confirm_box(true)) {
if (!$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
if ($error = group_user_del($group_id, $user_id)) {
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id));
}
$error = array();
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'g' => $group_id)));
}
break;
}
// Add user to group?
if ($submit) {
if (!$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
// Add user/s to group
if ($error = group_user_add($group_id, $user_id)) {
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id));
}
$error = array();
}
$sql = 'SELECT ug.*, g.*
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\n\t\t\t\t\tWHERE ug.user_id = {$user_id}\n\t\t\t\t\t\tAND g.group_id = ug.group_id\n\t\t\t\t\tORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name";
$result = $db->sql_query($sql);
$i = 0;
$group_data = $id_ary = array();
while ($row = $db->sql_fetchrow($result)) {
$type = $row['group_type'] == GROUP_SPECIAL ? 'special' : ($row['user_pending'] ? 'pending' : 'normal');
$group_data[$type][$i]['group_id'] = $row['group_id'];
$group_data[$type][$i]['group_name'] = $row['group_name'];
$group_data[$type][$i]['group_leader'] = $row['group_leader'] ? 1 : 0;
$id_ary[] = $row['group_id'];
$i++;
}
$db->sql_freeresult($result);
// Select box for other groups
$sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . '
' . (sizeof($id_ary) ? 'WHERE group_id NOT IN (' . implode(', ', $id_ary) . ')' : '') . '
ORDER BY group_type DESC, group_name ASC';
$result = $db->sql_query($sql);
$s_group_options = '';
while ($row = $db->sql_fetchrow($result)) {
if ($config['coppa_hide_groups'] && in_array($row['group_name'], array('INACTIVE_COPPA', 'REGISTERED_COPPA'))) {
continue;
}
$s_group_options .= '<option' . ($row['group_type'] == GROUP_SPECIAL ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . ($row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
$db->sql_freeresult($result);
示例6: main
//.........这里部分代码省略.........
trigger_error($user->lang['CANNOT_RESIGN_GROUP'] . $return_page);
}
if (confirm_box(true)) {
group_user_del($group_id, $user->data['user_id']);
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_RESIGN', $group_row[$group_id]['group_name']);
meta_refresh(3, $this->u_action);
trigger_error($user->lang[$row['user_pending'] ? 'GROUP_RESIGNED_PENDING' : 'GROUP_RESIGNED_MEMBERSHIP'] . $return_page);
} else {
$s_hidden_fields = array('selected' => $group_id, 'action' => 'resign', 'submit' => true);
confirm_box(false, $row['user_pending'] ? 'GROUP_RESIGN_PENDING' : 'GROUP_RESIGN_MEMBERSHIP', build_hidden_fields($s_hidden_fields));
}
break;
case 'join':
$sql = 'SELECT ug.*, u.username, u.username_clean, u.user_email
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
WHERE ug.user_id = u.user_id
AND ug.group_id = ' . $group_id . '
AND ug.user_id = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row) {
if ($row['user_pending']) {
trigger_error($user->lang['ALREADY_IN_GROUP_PENDING'] . $return_page);
}
trigger_error($user->lang['ALREADY_IN_GROUP'] . $return_page);
}
// Check permission to join (open group or request)
if ($group_row[$group_id]['group_type'] != GROUP_OPEN && $group_row[$group_id]['group_type'] != GROUP_FREE) {
trigger_error($user->lang['CANNOT_JOIN_GROUP'] . $return_page);
}
if (confirm_box(true)) {
if ($group_row[$group_id]['group_type'] == GROUP_FREE) {
group_user_add($group_id, $user->data['user_id']);
$email_template = 'group_added';
} else {
group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1);
$email_template = 'group_request';
}
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
$sql = 'SELECT u.username, u.username_clean, u.user_email, u.user_notify_type, u.user_jabber, u.user_lang
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
WHERE ug.user_id = u.user_id
AND ' . ($group_row[$group_id]['group_type'] == GROUP_FREE ? "ug.user_id = {$user->data['user_id']}" : 'ug.group_leader = 1') . "\n\t\t\t\t\t\t\t\t\t\tAND ug.group_id = {$group_id}";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$messenger->template($email_template, $row['user_lang']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username']), 'GROUP_NAME' => htmlspecialchars_decode($group_row[$group_id]['group_name']), 'REQUEST_USERNAME' => $user->data['username'], 'U_PENDING' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=manage&action=list&g={$group_id}", 'U_GROUP' => generate_board_url() . "/memberlist.{$phpEx}?mode=group&g={$group_id}"));
$messenger->send($row['user_notify_type']);
}
$db->sql_freeresult($result);
$messenger->save_queue();
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_JOIN' . ($group_row[$group_id]['group_type'] == GROUP_FREE ? '' : '_PENDING'), $group_row[$group_id]['group_name']);
meta_refresh(3, $this->u_action);
trigger_error($user->lang[$group_row[$group_id]['group_type'] == GROUP_FREE ? 'GROUP_JOINED' : 'GROUP_JOINED_PENDING'] . $return_page);
} else {
$s_hidden_fields = array('selected' => $group_id, 'action' => 'join', 'submit' => true);
confirm_box(false, $group_row[$group_id]['group_type'] == GROUP_FREE ? 'GROUP_JOIN' : 'GROUP_JOIN_PENDING', build_hidden_fields($s_hidden_fields));
}
break;
case 'demote':
if (!($row = group_memberships($group_id, $user->data['user_id']))) {
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
示例7: create_management
/**
* Make the first two users a admin and a global moderator.
*/
private function create_management()
{
global $db, $phpbb_root_path, $phpEx, $settings;
// Don't do anything if there is not enough users.
$users_needed = 0;
$users_needed = $this->create_mod ? $users_needed + 1 : $users_needed;
$users_needed = $this->create_admin ? $users_needed + 1 : $users_needed;
if (sizeof($this->user_arr) < $users_needed) {
return;
}
$admin_group = $mod_group = 0;
// Get group id for admins and moderators.
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = 'ADMINISTRATORS'\n\t\t\t\tOR group_name = 'GLOBAL_MODERATORS'";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if ($row['group_name'] == 'ADMINISTRATORS') {
$admin_group = (int) $row['group_id'];
} else {
if ($row['group_name'] == 'GLOBAL_MODERATORS') {
$mod_group = (int) $row['group_id'];
}
}
}
$db->sql_freeresult($result);
if (file_exists("{$phpbb_root_path}language/" . $settings->get_config('default_lang') . "/common.{$phpEx}")) {
include "{$phpbb_root_path}language/" . $settings->get_config('default_lang') . "/common.{$phpEx}";
} else {
if (file_exists("{$phpbb_root_path}language/en/common.{$phpEx}")) {
include "{$phpbb_root_path}language/en/common.{$phpEx}";
} else {
$lang['G_ADMINISTRATORS'] = $lang['G_GLOBAL_MODERATORS'] = '';
}
}
if (!empty($admin_group) && $this->create_admin) {
reset($this->user_arr);
$user = current($this->user_arr);
if (!empty($user['user_id'])) {
group_user_add($admin_group, $user['user_id'], false, $lang['G_ADMINISTRATORS'], true, 0);
}
}
if (!empty($mod_group) && $this->create_mod) {
next($this->user_arr);
$user = current($this->user_arr);
if (!empty($user['user_id'])) {
group_user_add($mod_group, $user['user_id'], false, $lang['G_GLOBAL_MODERATORS'], true, 1);
}
}
}
示例8: main
//.........这里部分代码省略.........
}
$error = array();
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'u' => $user_id,
'i' => $id,
'mode' => $mode,
'action' => $action,
'g' => $group_id))
);
}
break;
}
// Add user to group?
if ($submit)
{
if (!check_form_key($form_name))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
// Add user/s to group
if ($error = group_user_add($group_id, $user_id))
{
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
$error = array();
}
$sql = 'SELECT ug.*, g.*
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug
WHERE ug.user_id = $user_id
AND g.group_id = ug.group_id
ORDER BY g.group_type DESC, ug.user_pending ASC, g.group_name";
$result = $db->sql_query($sql);
$i = 0;
$group_data = $id_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : (($row['user_pending']) ? 'pending' : 'normal');
$group_data[$type][$i]['group_id'] = $row['group_id'];
$group_data[$type][$i]['group_name'] = $row['group_name'];
$group_data[$type][$i]['group_leader'] = ($row['group_leader']) ? 1 : 0;
$id_ary[] = $row['group_id'];
$i++;
}
$db->sql_freeresult($result);
// Select box for other groups
示例9: add_user_group
protected function add_user_group($group_name, $usernames, $default = false, $leader = false)
{
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx;
$config = new \phpbb\config\config(array());
$config['coppa_enable'] = 0;
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user = $this->getMock('\\phpbb\\user', array(), array(new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\\phpbb\\datetime'));
$auth = $this->getMock('\\phpbb\\auth\\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
$cache = new phpbb_mock_null_cache();
$cache_driver = new \phpbb\cache\driver\dummy();
$phpbb_container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$phpbb_container->expects($this->any())->method('get')->with('cache.driver')->will($this->returnValue($cache_driver));
if (!function_exists('utf_clean_string')) {
require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
}
if (!function_exists('group_user_del')) {
require_once __DIR__ . '/../../phpBB/includes/functions_user.php';
}
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name = '" . $db->sql_escape($group_name) . "'";
$result = $db->sql_query($sql);
$group_id = (int) $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);
return group_user_add($group_id, false, $usernames, $group_name, $default, $leader);
}
示例10: _auth_mdc_set_admin
function _auth_mdc_set_admin($mdcuser)
{
$DEKI_ADMIN = 5;
// Dekiwiki role ID for admins
$PHPBB_ADMIN_GROUP_ID = 5;
// group ID for phpbb admins
if ($mdcuser['user_role_id'] == $DEKI_ADMIN) {
return group_user_add($PHPBB_ADMIN_GROUP_ID, $mdcuser['id']);
} else {
return group_user_del($PHPBB_ADMIN_GROUP_ID, $mdcuser['id']);
}
}
示例11: syncgroups
private function syncgroups()
{
// Si l'utilisateur est login alors voir les groups qu'il a et les ajouter s'il n'existe pas.
// En profiter pour maj l'user
//todo: code la maj du realname
// maj des groups
if (!function_exists('get_group_id')) {
include $this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext;
}
if (!function_exists('group_memberships')) {
include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
if (!function_exists('get_group_name')) {
include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$passage_groups = explode(' ', get_apache_header($this->config['passage_groups']));
$phpbb_groups = group_memberships(false, $this->user->data['user_id'], false);
// Append
if (!empty($phpbb_groups) and !empty($passage_groups)) {
foreach ($passage_groups as $p_grg) {
if (is_array($phpbb_groups)) {
if (false == in_array($p_grg, $phpbb_groups)) {
group_user_add(get_group_id($p_grg), $this->user->data['user_id']);
}
}
}
// Clean
if (is_array($phpbb_groups)) {
foreach ($phpbb_groups as $bb_grp) {
if (false == in_array(get_group_name($bb_grp['group_id']), $passage_groups)) {
group_user_del($bb_grp['group_id'], $this->user->data['user_id']);
}
}
}
}
}
示例12: main
//.........这里部分代码省略.........
$error = '';
switch ($action) {
case 'delete':
if (!$auth->acl_get('a_groupdel')) {
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$error = group_delete($group_id, $group_row['group_name']);
break;
case 'deleteusers':
$group_name = $group_row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
$error = group_user_del($group_id, $mark_ary, false, $group_name);
break;
}
$back_link = $action == 'delete' ? $this->u_action : $this->u_action . '&action=list&g=' . $group_id;
if ($error) {
trigger_error($user->lang[$error] . adm_back_link($back_link), E_USER_WARNING);
}
$message = $action == 'delete' ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE';
trigger_error($user->lang[$message] . adm_back_link($back_link));
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('mark' => $mark_ary, 'g' => $group_id, 'i' => $id, 'mode' => $mode, 'action' => $action)));
}
break;
case 'addusers':
if (!$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$name_ary) {
trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING);
}
$name_ary = array_unique(explode("\n", $name_ary));
$group_name = $group_row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
// Add user/s to group
if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, $leader, 0, $group_row)) {
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING);
}
$message = $leader ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED';
trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
break;
case 'edit':
case 'add':
include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
$data = $submit_ary = array();
if ($action == 'edit' && !$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($action == 'add' && !$auth->acl_get('a_groupadd')) {
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$error = array();
$user->add_lang('ucp');
$avatar_select = basename(request_var('avatar_select', ''));
$category = basename(request_var('category', ''));
// Did we submit?
if ($update) {
if (!check_form_key($form_key)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$group_name = utf8_normalize_nfc(request_var('group_name', '', true));
$group_desc = utf8_normalize_nfc(request_var('group_desc', '', true));
$group_type = request_var('group_type', GROUP_FREE);
$allow_desc_bbcode = request_var('desc_parse_bbcode', false);
$allow_desc_urls = request_var('desc_parse_urls', false);
$allow_desc_smilies = request_var('desc_parse_smilies', false);
$data['uploadurl'] = request_var('uploadurl', '');
$data['remotelink'] = request_var('remotelink', '');
示例13: addUserToGroup
/**
* Add user to group.
*
* @param int $userId User ID.
* @param int $groupId The user group ID to add user to.
* @param boolean $default If true, will set this group as the default group for the user being added.
* @param boolean $leader If true, user will be a leader of the group.
* @param boolean $pending If true, user needs to be approved before being shown in the group member list.
*
* @return boolean/string FALSE on success, language string for the relevant error otherwise.
*/
public function addUserToGroup($userId, $groupId, $default = FALSE, $leader = FALSE, $pending = FALSE)
{
return group_user_add($groupId, $userId, FALSE, FALSE, $default, $leader, $pending);
}
示例14: add_groups
/**
* Add groups
* Add the user to the selected gourps
*
* @param int $user_id The user id
* @param array $group_data The group data
* @param array &$error The error array
*/
function add_groups($user_id, $group_data, &$error)
{
foreach ($group_data['groups'] as $group_id) {
$default = $leader = false;
if ($group_data['default'] == $group_id) {
$default = true;
}
if (in_array($group_id, $group_data['leaders'])) {
$leader = true;
}
// Add to the group
if (($msg = group_user_add($group_id, array($user_id), false, false, $default, $leader)) !== false) {
// Something went wrong
$error[] = $msg;
return false;
}
}
}
示例15: donors_group_user_add
/**
* Add donor to the donors group
*
* @return null
* @access private
*/
private function donors_group_user_add()
{
// we add the user to the donors group
if ($this->can_use_autogroup()) {
if (!function_exists('group_user_add')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
// add the user to the donors group and set as default.
group_user_add($this->config['ppde_ipn_group_id'], array($this->payer_data['user_id']), array($this->payer_data['username']), get_group_name($this->config['ppde_ipn_group_id']), $this->config['ppde_ipn_group_as_default']);
}
}