本文整理汇总了PHP中group_user_del函数的典型用法代码示例。如果您正苦于以下问题:PHP group_user_del函数的具体用法?PHP group_user_del怎么用?PHP group_user_del使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了group_user_del函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
}
示例2: remove_user_group
protected function remove_user_group($group_name, $usernames)
{
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 = new phpbb_mock_container_builder();
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
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_del($group_id, false, $usernames, $group_name);
}
示例3: main
//.........这里部分代码省略.........
do {
$mark_ary[] = $row['user_id'];
} while ($row = $db->sql_fetchrow($result));
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
$start = sizeof($mark_ary) < 200 ? 0 : $start + 200;
} else {
$start = 0;
}
$db->sql_freeresult($result);
} while ($start);
} else {
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
}
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action));
} 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 'deleteusers':
case 'delete':
if (confirm_box(true)) {
if (!$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action));
}
$error = '';
switch ($action) {
case 'delete':
if (!$auth->acl_get('a_groupdel')) {
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action));
}
$error = group_delete($group_id, $group_row['group_name']);
break;
case 'deleteusers':
$error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']);
break;
}
if ($error) {
trigger_error($user->lang[$error] . adm_back_link($this->u_action));
}
$message = $action == 'delete' ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE';
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
} 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));
}
if (!$name_ary) {
trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action));
}
$name_ary = array_unique(explode("\n", $name_ary));
// Add user/s to group
if ($error = group_user_add($group_id, false, $name_ary, $group_row['group_name'], $default, $leader, 0, $group_row)) {
trigger_error($user->lang[$error] . adm_back_link($this->u_action));
}
$message = $action == 'addleaders' ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED';
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
break;
case 'edit':
case 'add':
$data = $submit_ary = array();
if ($action == 'edit' && !$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action));
}
示例4: eveapi_setForumGroups
/**
* Sets character's Forum permissions
*/
function eveapi_setForumGroups($userId, $forumGroupsNew, $characterName = "---")
{
global $db, $config, $user;
if (!is_array($forumGroupsNew)) {
$forumGroupsNew = array();
}
$forumGroups = array();
$sql = "SELECT group_id\n FROM " . USER_GROUP_TABLE . "\n WHERE user_id = " . $userId;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$forumGroups[] = $row['group_id'];
}
$db->sql_freeresult($result);
// 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_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_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']];
}
}
$db->sql_freeresult($result);
// 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();
// 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 group special? Hhmmm...
if (!isset($forumGroupsNew[$currentForumGroup])) {
// Check if group is the default Registered Users group and ignore if it is.
// TODO: Needs better check
if ($currentForumGroup == 2) {
continue;
}
// Check if group is set as immune (special group), if not, remove user from group
if (!$forumGroupInfo[$currentForumGroup]['group_eveapi_special']) {
group_user_del($currentForumGroup, $userId);
cronlog("Removing user from Forum group -> " . $forumGroupInfo[$currentForumGroup]['group_name'], $characterName);
} else {
// Group is immune, so don't remove it. Add TeamSpeak groupId to the list if the groupId >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'];
}
}
} 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'];
}
}
}
if (!empty($forumGroupsNew)) {
// Maybe we need to add groups
foreach ($forumGroupsNew as $currentForumGroup => $defaultGroup) {
if (!in_array($currentForumGroup, $forumGroups)) {
$tempDefault = $defaultGroup ? true : false;
group_user_add($currentForumGroup, $userId, false, false, $tempDefault);
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
//.........这里部分代码省略.........
示例5: delUserToGroup
/** 50l3r
* Remove user to group.
*/
public function delUserToGroup($userId, $groupId)
{
return group_user_del($userId, $groupId);
}
示例6: 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;
}
示例7: main
//.........这里部分代码省略.........
AND a.in_message = 0)
LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id
AND a.in_message = 1)
WHERE a.poster_id = ' . $user_id . "\n\t\t\t\t\tORDER BY {$order_by}";
$result = $db->sql_query_limit($sql, $config['posts_per_page'], $start);
while ($row = $db->sql_fetchrow($result)) {
if ($row['in_message']) {
$view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&p={$row['post_msg_id']}");
} else {
$view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&p={$row['post_msg_id']}#{$row['post_msg_id']}");
}
$template->assign_block_vars('attach', array('REAL_FILENAME' => $row['real_filename'], 'COMMENT' => nl2br($row['comment']), 'EXTENSION' => $row['extension'], 'SIZE' => $row['filesize'] >= 1048576 ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : ($row['filesize'] >= 1024 ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download.{$phpEx}", 'id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic));
}
$db->sql_freeresult($result);
$template->assign_vars(array('S_ATTACHMENTS' => true, 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start), 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'PAGINATION' => generate_pagination($this->u_action . "&sk={$sort_key}&sd={$sort_dir}", $num_attachments, $config['topics_per_page'], $start, true)));
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++;
}
示例8: main
function main($id, $mode)
{
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $cache, $template;
$user->add_lang('groups');
$return_page = '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '">', '</a>');
$mark_ary = request_var('mark', array(0));
$submit = !empty($_POST['submit']) ? true : false;
$delete = !empty($_POST['delete']) ? true : false;
$error = $data = array();
switch ($mode) {
case 'membership':
$this->page_title = 'UCP_USERGROUPS_MEMBER';
if ($submit || isset($_POST['change_default'])) {
$action = isset($_POST['change_default']) ? 'change_default' : request_var('action', '');
$group_id = $action == 'change_default' ? request_var('default', 0) : request_var('selected', 0);
if (!$group_id) {
trigger_error('NO_GROUP_SELECTED');
}
$sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . "\n\t\t\t\t\t\tWHERE group_id IN ({$group_id}, {$user->data['group_id']})";
$result = $db->sql_query($sql);
$group_row = array();
while ($row = $db->sql_fetchrow($result)) {
$row['group_name'] = $row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
$group_row[$row['group_id']] = $row;
}
$db->sql_freeresult($result);
if (!sizeof($group_row)) {
trigger_error('GROUP_NOT_EXIST');
}
switch ($action) {
case 'change_default':
// User already having this group set as default?
if ($group_id == $user->data['group_id']) {
trigger_error($user->lang['ALREADY_DEFAULT_GROUP'] . $return_page);
}
if (!$auth->acl_get('u_chggrp')) {
trigger_error($user->lang['NOT_AUTHORISED'] . $return_page);
}
// User needs to be member of the group in order to make it default
if (!group_memberships($group_id, $user->data['user_id'], true)) {
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
}
if (confirm_box(true)) {
group_user_attributes('default', $group_id, $user->data['user_id']);
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_CHANGE', sprintf($user->lang['USER_GROUP_CHANGE'], $group_row[$user->data['group_id']]['group_name'], $group_row[$group_id]['group_name']));
meta_refresh(3, $this->u_action);
trigger_error($user->lang['CHANGED_DEFAULT_GROUP'] . $return_page);
} else {
$s_hidden_fields = array('default' => $group_id, 'change_default' => true);
confirm_box(false, sprintf($user->lang['GROUP_CHANGE_DEFAULT'], $group_row[$group_id]['group_name']), build_hidden_fields($s_hidden_fields));
}
break;
case 'resign':
// User tries to resign from default group but is not allowed to change it?
if ($group_id == $user->data['group_id'] && !$auth->acl_get('u_chggrp')) {
trigger_error($user->lang['NOT_RESIGN_FROM_DEFAULT_GROUP'] . $return_page);
}
if (!($row = group_memberships($group_id, $user->data['user_id']))) {
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
}
list(, $row) = each($row);
$sql = 'SELECT group_type
FROM ' . GROUPS_TABLE . '
WHERE group_id = ' . $group_id;
$result = $db->sql_query($sql);
$group_type = (int) $db->sql_fetchfield('group_type');
$db->sql_freeresult($result);
if ($group_type != GROUP_OPEN && $group_type != GROUP_FREE) {
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);
//.........这里部分代码省略.........
示例9: 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']);
}
}
}
}
}
示例10: main
//.........这里部分代码省略.........
} else {
$start = 0;
}
$db->sql_freeresult($result);
} while ($start);
} else {
group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
}
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&action=list&g=' . $group_id));
} 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 'deleteusers':
case 'delete':
if (!$group_id) {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
} else {
if ($action === 'delete' && $group_row['group_type'] == GROUP_SPECIAL) {
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
if (confirm_box(true)) {
$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();
示例11: remove_users_from_group
/**
* {@inheritdoc}
*/
public function remove_users_from_group($user_id_ary, $group_rule_data)
{
// Return if the user_id_array is empty
if (!sizeof($user_id_ary)) {
return;
}
// Set this variable for readability in the code below
$group_id = $group_rule_data['autogroups_group_id'];
// Delete user(s) from the group
group_user_del($group_id, $user_id_ary);
// Send notification
if ($group_rule_data['autogroups_notify']) {
$this->helper->send_notifications('group_removed', $user_id_ary, $group_id);
}
}
示例12: main
//.........这里部分代码省略.........
$db->sql_freeresult($result);
if (!$user_row) {
$error[] = $user->lang['NO_USER'];
} else {
$ad_owner_id = $user_row['user_id'];
}
}
}
if ($submit && !sizeof($error)) {
$sql_ary = array('ad_name' => $ad_name, 'ad_code' => $ad_code, 'ad_note' => $ad_note, 'ad_time' => $action == 'edit' ? $ad_data['ad_time'] : time(), 'ad_time_end' => $ad_time_end !== false && $ad_time_end > 0 ? $ad_time_end : 0, 'ad_views' => $request->variable('ad_views', 0), 'ad_view_limit' => $request->variable('ad_view_limit', 0), 'ad_clicks' => $request->variable('ad_clicks', 0), 'ad_click_limit' => $request->variable('ad_click_limit', 0), 'ad_priority' => $request->variable('ad_priority', 5), 'ad_enabled' => isset($_POST['ad_enabled']) ? true : false, 'all_forums' => isset($_POST['all_forums']) || !$config['ads_rules_forums'] ? true : false, 'ad_owner' => $ad_owner_id);
// Set them as able to see the ads page (stored as 1 for ad_user) and add them to the ads group if required
if ($ad_owner_id && ($action != 'edit' || $ad_owner_id != $ad_data['ad_owner'])) {
$sql = 'UPDATE ' . USERS_TABLE . ' SET ad_owner = 1
WHERE user_id = ' . (int) $ad_owner_id;
$db->sql_query($sql);
if ($config['ads_group']) {
group_user_add($config['ads_group'], array($ad_owner_id));
}
}
if ($action == 'edit') {
$db->sql_query('UPDATE ' . ADS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE ad_id = ' . $ad_id);
// Does the old owner have any ads anymore if the owner was changed?
if ($ad_owner_id != $ad_data['ad_owner']) {
$sql = 'SELECT COUNT(ad_id) AS count FROM ' . ADS_TABLE . '
WHERE ad_owner = ' . $ad_data['ad_owner'];
$db->sql_query($sql);
$count = $db->sql_fetchfield('count');
$db->sql_freeresult();
if (!$count) {
$sql = 'UPDATE ' . USERS_TABLE . ' SET ad_owner = 0
WHERE user_id = ' . (int) $ad_data['ad_owner'];
$db->sql_query($sql);
if ($config['ads_group']) {
group_user_del($config['ads_group'], array($ad_data['ad_owner']));
}
}
}
// This is the simplest way to update the groups/forums/positions list
if ($config['ads_rules_groups']) {
$db->sql_query('DELETE FROM ' . ADS_GROUPS_TABLE . ' WHERE ad_id = ' . $ad_id);
}
if ($config['ads_rules_forums']) {
$db->sql_query('DELETE FROM ' . ADS_FORUMS_TABLE . ' WHERE ad_id = ' . $ad_id);
}
$db->sql_query('DELETE FROM ' . ADS_IN_POSITIONS_TABLE . ' WHERE ad_id = ' . $ad_id);
} else {
$db->sql_query('INSERT INTO ' . ADS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
$ad_id = $db->sql_nextid();
}
if ($config['ads_rules_groups']) {
foreach ($ad_groups as $group_id) {
$db->sql_query('INSERT INTO ' . ADS_GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', array('ad_id' => $ad_id, 'group_id' => $group_id)));
}
$cache->destroy('sql', ADS_GROUPS_TABLE);
}
if ($config['ads_rules_forums']) {
foreach ($ad_forums as $forum_id) {
$db->sql_query('INSERT INTO ' . ADS_FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', array('ad_id' => $ad_id, 'forum_id' => $forum_id)));
}
$cache->destroy('sql', ADS_FORUMS_TABLE);
}
foreach ($ad_positions as $position_id) {
$sql_ary = array('ad_id' => $ad_id, 'position_id' => $position_id, 'ad_priority' => $request->variable('ad_priority', 5), 'ad_enabled' => isset($_POST['ad_enabled']) ? true : false, 'all_forums' => isset($_POST['all_forums']) || !$config['ads_rules_forums'] ? true : false);
$db->sql_query('INSERT INTO ' . ADS_IN_POSITIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
}
trigger_error(($action == 'edit' ? $user->lang['AD_EDIT_SUCCESS'] : $user->lang['AD_ADD_SUCCESS']) . adm_back_link($this->u_action));
示例13: group_delete
/**
* Group Delete
*/
function group_delete($group_id, $group_name = false)
{
global $db;
if (!$group_name) {
$group_name = get_group_name($group_id);
}
$start = 0;
do {
$user_id_ary = $username_ary = array();
// Batch query for group members, call group_user_del
$sql = 'SELECT u.user_id, u.username
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . " u\n\t\t\tWHERE ug.group_id = {$group_id}\n\t\t\t\tAND u.user_id = ug.user_id";
$result = $db->sql_query_limit($sql, 200, $start);
if ($row = $db->sql_fetchrow($result)) {
do {
$user_id_ary[] = $row['user_id'];
$username_ary[] = $row['username'];
$start++;
} while ($row = $db->sql_fetchrow($result));
group_user_del($group_id, $user_id_ary, $username_ary, $group_name);
} else {
$start = 0;
}
$db->sql_freeresult($result);
} while ($start);
// Delete group
$sql = 'DELETE FROM ' . GROUPS_TABLE . "\n\t\tWHERE group_id = {$group_id}";
$db->sql_query($sql);
// Delete auth entries from the groups table
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "\n\t\tWHERE group_id = {$group_id}";
$db->sql_query($sql);
add_log('admin', 'LOG_GROUP_DELETE', $group_name);
return 'GROUP_DELETED';
}
示例14: remove_newly_registered
/**
* Funtion to make a user leave the NEWLY_REGISTERED system group.
* @access public
* @param $user_id The id of the user to remove from the group
*/
function remove_newly_registered($user_id, $user_data = false)
{
global $db;
if ($user_data === false) {
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
return false;
} else {
$user_data = $user_row;
}
}
if (empty($user_data['user_new'])) {
return false;
}
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "\n\t\tWHERE group_name = 'NEWLY_REGISTERED'\n\t\t\tAND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql);
$group_id = (int) $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);
if (!$group_id) {
return false;
}
// We need to call group_user_del here, because this function makes sure everything is correctly changed.
// A downside for a call within the session handler is that the language is not set up yet - so no log entry
group_user_del($group_id, $user_id);
// Set user_new to 0 to let this not be triggered again
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_new = 0
WHERE user_id = ' . $user_id;
$db->sql_query($sql);
// The new users group was the users default group?
if ($user_data['group_id'] == $group_id) {
// Which group is now the users default one?
$sql = 'SELECT group_id
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$user_data['group_id'] = $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);
}
return $user_data['group_id'];
}
示例15: _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']);
}
}