$group_pending = !empty($group_data['user_pending']) ? ' <i>[' . $lang['MEMBERSHIP_PENDING'] . ']</i>' : ''; $template->assign_block_vars('groups', array('GROUP_COLOR' => !empty($group_data['group_color']) ? ' style="color: ' . $group_data['group_color'] . ';"' : '', 'U_GROUP_NAME' => append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_data['group_id']), 'U_GROUP_REMOVE' => append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&' . POST_USERS_URL . '=' . $profiledata['user_id'] . '&' . POST_GROUPS_URL . '=' . $group_data['group_id'] . '&ug_rem=1'), 'L_GROUP_NAME' => $group_name . $group_pending, 'L_GROUP_DESC' => $group_data['group_description'])); } } } if (!empty($groups_display_block)) { $template->assign_var('S_DISPLAY_UCP_GROUPS', true); } if ($user->data['user_level'] == ADMIN) { $profile_groups_list = array(); if (!empty($profile_groups_data)) { foreach ($profile_groups_data as $group_data) { $profile_groups_list[] = $group_data['group_id']; } } $all_groups = get_groups_data(false, true, array()); $non_member_groups = array(); foreach ($all_groups as $group_data) { $process_group = true; if (!empty($profile_groups_list) && in_array($group_data['group_id'], $profile_groups_list)) { $process_group = false; } if ($process_group) { $non_member_groups[] = $group_data; } } if (!empty($non_member_groups)) { $template->assign_var('S_DISPLAY_NON_MEMBER_GROUPS', true); $non_member_groups_select = ''; $non_member_groups_select .= '<select name="' . POST_GROUPS_URL . '">'; foreach ($non_member_groups as $group_data) {
setup_extra_lang(array('lang_album_main', 'lang_album_admin')); require ALBUM_MOD_PATH . 'album_common.' . PHP_EXT; $album_user_id = ALBUM_PUBLIC_GALLERY; if (!isset($_POST['submit'])) { album_read_tree(); $s_album_cat_list = album_get_tree_option(ALBUM_ROOT_CATEGORY, ALBUM_AUTH_VIEW, ALBUM_SELECTBOX_INCLUDE_ALL | ALBUM_SELECTBOX_INCLUDE_ROOT); $template->set_filenames(array('body' => ADM_TPL . 'album_cat_select_body.tpl')); $template->assign_vars(array('L_ALBUM_AUTH_TITLE' => $lang['Album_Auth_Title'], 'L_ALBUM_AUTH_EXPLAIN' => $lang['Album_Auth_Explain'], 'L_SELECT_CAT' => $lang['Select_a_Category'], 'S_ALBUM_ACTION' => append_sid("admin_album_auth." . PHP_EXT), 'L_LOOK_UP_CAT' => $lang['Look_up_Category'], 'CAT_SELECT_TITLE' => $s_album_cat_list)); $template->pparse('body'); include IP_ROOT_PATH . ADM . '/page_footer_admin.' . PHP_EXT; } else { if (!isset($_GET['cat_id'])) { $cat_id = intval($_POST['cat_id']); $template->set_filenames(array('body' => ADM_TPL . 'album_auth_body.tpl')); $template->assign_vars(array('L_ALBUM_AUTH_TITLE' => $lang['Album_Auth_Title'], 'L_ALBUM_AUTH_EXPLAIN' => $lang['Album_Auth_Explain'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_GROUPS' => $lang['Usergroups'], 'L_VIEW' => $lang['View'], 'L_UPLOAD' => $lang['Upload'], 'L_RATE' => $lang['Rate'], 'L_COMMENT' => $lang['Comment'], 'L_EDIT' => $lang['Edit'], 'L_DELETE' => $lang['Delete'], 'L_IS_MODERATOR' => $lang['Is_Moderator'], 'S_ALBUM_ACTION' => append_sid('admin_album_auth.' . PHP_EXT . '?cat_id=' . $cat_id))); $groups_data = get_groups_data(false, false, array()); // Get info of this cat $sql = "SELECT cat_id, cat_title, cat_view_groups, cat_upload_groups, cat_rate_groups, cat_comment_groups, cat_edit_groups, cat_delete_groups, cat_moderator_groups\n\t\t\t\tFROM " . ALBUM_CAT_TABLE . "\n\t\t\t\tWHERE cat_id = '{$cat_id}'"; $result = $db->sql_query($sql); $thiscat = $db->sql_fetchrow($result); $view_groups = @explode(',', $thiscat['cat_view_groups']); $upload_groups = @explode(',', $thiscat['cat_upload_groups']); $rate_groups = @explode(',', $thiscat['cat_rate_groups']); $comment_groups = @explode(',', $thiscat['cat_comment_groups']); $edit_groups = @explode(',', $thiscat['cat_edit_groups']); $delete_groups = @explode(',', $thiscat['cat_delete_groups']); $moderator_groups = @explode(',', $thiscat['cat_moderator_groups']); for ($i = 0; $i < sizeof($groups_data); $i++) { $class = $i % 2 ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars('grouprow', array('CLASS' => $class, 'GROUP_ID' => $groups_data[$i]['group_id'], 'GROUP_NAME' => $groups_data[$i]['group_name'], 'VIEW_CHECKED' => in_array($groups_data[$i]['group_id'], $view_groups) ? 'checked="checked"' : '', 'UPLOAD_CHECKED' => in_array($groups_data[$i]['group_id'], $upload_groups) ? 'checked="checked"' : '', 'RATE_CHECKED' => in_array($groups_data[$i]['group_id'], $rate_groups) ? 'checked="checked"' : '', 'COMMENT_CHECKED' => in_array($groups_data[$i]['group_id'], $comment_groups) ? 'checked="checked"' : '', 'EDIT_CHECKED' => in_array($groups_data[$i]['group_id'], $edit_groups) ? 'checked="checked"' : '', 'DELETE_CHECKED' => in_array($groups_data[$i]['group_id'], $delete_groups) ? 'checked="checked"' : '', 'MODERATOR_CHECKED' => in_array($groups_data[$i]['group_id'], $moderator_groups) ? 'checked="checked"' : '')); }
} elseif ($sid !== $user->data['session_id']) { message_die(GENERAL_ERROR, $lang['Session_invalid']); } update_all_users_colors_ranks($group_id); $redirect_url = append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_id); meta_refresh(3, $redirect_url); $message = $lang['Group_members_updated'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(CMS_PAGE_FORUM) . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } elseif (isset($_POST['joingroup']) && $group_id) { // First, joining a group // If the user isn't logged in redirect them to login if (!$user->data['session_logged_in']) { redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=groupcp.' . PHP_EXT . '&' . POST_GROUPS_URL . '=' . $group_id, true)); } // Get group data $all_groups_data = get_groups_data(true, false, array($group_id)); $this_group_data = array(); if (!empty($all_groups_data)) { foreach ($all_groups_data as $group_data) { $this_group_data = $group_data; } $is_autogroup_enable = $this_group_data['group_count'] <= $user->data['user_posts'] && $this_group_data['group_count_max'] > $user->data['user_posts'] ? true : false; // Check if the group is open or we are "autojoining" if ($this_group_data['group_type'] != GROUP_OPEN && empty($is_autogroup_enable)) { $redirect_url = append_sid(CMS_PAGE_FORUM); meta_refresh(3, $redirect_url); $message = $lang['This_closed_group'] . '<br /><br />' . sprintf($lang['Click_return_group'], '<a href="' . append_sid(CMS_PAGE_GROUP_CP . '?' . POST_GROUPS_URL . '=' . $group_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid(CMS_PAGE_FORUM) . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } } else { // The group doesn't exist!
function show_blocks_settings_list_ajax() { global $db, $template, $user, $lang; if (defined('CMS_NO_AJAX')) { return $this->show_blocks_settings_list(); } //return $this->show_blocks_settings_list(); // do stuff $j_request = request_var('json', false); $action = request_var('json_action', ''); if (strlen($action)) { $result = $this->show_blocks_settings_action($action); if (is_array($result)) { return $result; } } // get list of blocks $blocks = $this->get_parent_blocks(); // get all layouts $layouts = array(); $sql = "SELECT lid, name FROM " . $this->tables['layout_table']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $layouts[$row['lid']] = array('lid' => $row['lid'], 'name' => $row['name'], 'url' => append_sid($this->root . '?mode=blocks&l_id=' . $row['lid'])); } $db->sql_freeresult($result); $layouts_special = array(); $sql = "SELECT lsid, name FROM " . $this->tables['layout_special_table']; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $layouts_special[$row['lsid']] = array('lsid' => $row['lsid'], 'name' => isset($lang['auth_view_' . $row['name']]) ? $lang['auth_view_' . $row['name']] : (isset($lang['cms_page_name_' . strtolower($row['name'])]) ? $lang['cms_page_name_' . strtolower($row['name'])] : ucfirst($row['name'])), 'url' => append_sid($this->root . '?mode=blocks&ls_id=' . $row['lsid'])); } $db->sql_freeresult($result); // get list of layouts where blocks used $list = array(); $sql = "SELECT bs_id, layout, layout_special FROM " . $this->tables['blocks_table']; $result = $db->sql_query($sql); $global_url = append_sid($this->root . '?mode=blocks&l_id=0&action=editglobal'); while ($row = $db->sql_fetchrow($result)) { $bsid = intval($row['bs_id']); $layout = intval($row['layout']); $special = intval($row['layout_special']); if (!isset($list[$bsid]) || !in_array($layout, $list[$bsid])) { if ($layout) { // layout $url = $layouts[$layout]['url']; $name = $layouts[$layout]['name']; } elseif ($special) { // special page $url = $layouts_special[$special]['url']; $name = $layouts_special[$special]['name']; } else { // global $url = $global_url; $name = $lang['CMS_GLOBAL_BLOCKS']; } // avoid adding duplicates $found = false; for ($i = 0; $i < count($list[$bsid]); $i++) { if ($list[$bsid][$i]['url'] == $url) { $found = true; } } if (!$found) { $list[$bsid][] = array('bs_id' => $bsid, 'layout' => $layout, 'special' => $special, 'name' => $name, 'url' => $url); } } } $db->sql_freeresult($result); // blocks list $blist = array(); if ($user->data['user_level'] == ADMIN) { $blocks_array = $this->get_blocks_files_list(); foreach ($blocks_array as $block_file) { $blist[BLOCKS_PREFIX . $block_file] = $block_file . (!empty($lang['cms_block_' . $block_file]) ? ' [' . $lang['cms_block_' . $block_file] . ']' : ''); } } else { $blist = false; } // groups list $groups = array(); $groups_data = get_groups_data(false, true, array()); foreach ($groups_data as $group_data) { $groups[$group_data['group_id']] = $group_data['group_name']; } // json data $json = array('rows' => $blocks, 'list' => $list, 'blist' => $blist, 'view_id' => array(0, 1, 2, 3, 4, 8), 'view' => array($lang['B_ALL'], $lang['B_GUESTS'], $lang['B_REG'], $lang['B_MOD'], $lang['B_ADMIN'], $lang['B_ALL_NO_BOTS']), 'groups' => $groups, 'remove' => append_sid($this->root . '?mode=block_settings&action=delete&bs_id={ID}'), 'edit' => append_sid($this->root . '?mode=block_settings&action=edit&bs_id={ID}', true), 'post' => array('url' => append_sid($this->root), 'mode' => $this->mode)); if ($this->action !== false) { $json['post']['action'] = $this->action; } // return stuff if (!$j_request) { // non-ajax action define('AJAX_CMS', true); // echo '<pre>', htmlspecialchars(print_r($json, true)), '</pre>'; $template->assign_vars(array('JSON_DATA' => json_encode($json))); return true; } return $json; }
function groups_select($select_name, $default, $allow_empty = true) { global $db, $cache, $lang; $groups_data = get_groups_data(true, false, array()); $groups_select = '<select name="' . $select_name . '">'; $groups_select .= !empty($allow_empty) ? '<option value="0">' . $lang['None'] . '</option>' : ''; foreach ($groups_data as $group_data) { $group_color = check_valid_color($group_data['group_color']); $group_color = !empty($group_color) ? ' style="color: ' . $group_color . '; font-weight: bold;"' : ''; $selected = $group_data['group_id'] == $default ? ' selected="selected"' : ''; $groups_select .= '<option value="' . $group_data['group_id'] . '"' . $selected . $group_color . '>' . htmlspecialchars($group_data['group_name']) . '</option>'; } $groups_select .= '</select>'; return $groups_select; }
/** * Add user(s) to group * * @return mixed false if no errors occurred */ function group_user_add($group_id, $user_id, $clear_cache = false, $is_autogroup_enable = false) { // 2 => User already member // 1 => User added // 0 => User not added global $db, $cache, $config, $lang; $this_userdata = get_userdata($user_id); $sql = "SELECT * FROM " . USER_GROUP_TABLE . " ug\n\t\t\tWHERE ug.user_id = '" . (int) $user_id . "'\n\t\t\t\tAND ug.group_id = '" . (int) $group_id . "'"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $db->sql_freeresult($result); return 2; } $groups_data = get_groups_data(false, false, array($group_id)); if (empty($groups_data)) { return 0; } $this_group_data = array(); foreach ($groups_data as $group_data) { $this_group_data = $group_data; $group_rank = $group_data['group_rank']; $group_color = $group_data['group_color']; } $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) VALUES (" . (int) $group_id . ", " . (int) $user_id . ", 0)"; $result = $db->sql_query($sql); if (!empty($group_color) && $group_color != $this_userdata['user_color']) { update_user_color($user_id, $group_color, $group_id, false, false); update_user_posts_details($user_id, $group_color, '', false, false); } if (!empty($group_rank) && empty($this_userdata['user_rank'])) { update_user_rank_simple($user_id, $group_rank, false); } if ($clear_cache) { $db->clear_cache(); } return 1; }
function get_groups_names($groups_ids) { global $db, $cache; $groups_ids_array = explode(',', str_replace(array(' ', ', '), array(' ', ','), $groups_ids)); $groups_data = get_groups_data(false, true, $groups_ids_array); $groups = ''; foreach ($groups_data as $group_data) { $groups .= ($groups != '' ? '<br />' : '') . '[ ' . $group_data['group_name'] . ' ]'; } return $groups; }