function edit_user($user_id) { global $db, $CONFIG, $lang_usermgr_php, $lang_yes, $lang_no; $sql = "SELECT username, user_active_cp, user_group_cp, user_group_list_cp FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '{$user_id}'"; $result = $db->sql_query($sql); if (!$db->sql_numrows($result)) { cpg_die(_CRITICAL_ERROR, ERR_UNKNOWN_USER, __FILE__, __LINE__); } $user_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); starttable(500, MODIFY_USER, 2); $chset = _CHARSET; echo '<form method="post" action="' . URL::index("&file=usermgr&opp=update&user_id={$user_id}") . "\" enctype=\"multipart/form-data\" accept-charset=\"{$chset}\">"; echo ' <tr> <td width="40%" class="tableb">' . U_NAME . '</td> <td width="60%" class="tableb">' . $user_data['username'] . '</td> </tr>'; $yes_selected = $user_data['user_active_cp'] ? 'selected' : ''; $no_selected = !$user_data['user_active_cp'] ? 'selected' : ''; echo ' <tr> <td class="tableb">' . USER_ACTIVE_CP . '</td> <td class="tableb"> <select name="user_active_cp" class="listbox"> <option value="1" ' . $yes_selected . '>' . YES . '</option> <option value="0" ' . $no_selected . '>' . NO . '</option> </select> </td> </tr>'; $result = $db->sql_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} ORDER BY group_name"); $group_list = $db->sql_fetchrowset($result); $db->sql_freeresult($result); $sel_group = $user_data['user_group_cp']; $user_group_list = explode(',', $user_data['user_group_list_cp']); echo ' <tr> <td class="tableb">' . USER_GROUP_CP . '</td> <td class="tableb" valign="top"> <select name="user_group_cp" class="listbox">'; $group_cb = ''; foreach ($group_list as $group) { echo ' <option value="' . $group['group_id'] . '"' . ($group['group_id'] == $sel_group ? ' selected' : '') . '>' . $group['group_name'] . "</option>\n"; $checked = user_ingroup($group['group_id'], $user_group_list) ? 'checked' : ''; $group_cb .= '<input name="group_list[]" type="checkbox" value="' . $group['group_id'] . '" ' . $checked . '>' . $group['group_name'] . "<br />\n"; } echo ' </select><br /> ' . $group_cb . ' </td> </tr> <tr> <td colspan="2" align="center" class="tablef"><input type="submit" value="' . MODIFY_USER . '" class="button"></td> </form> </tr>'; endtable(); }
function list_cat_albums($cat = 0, $buffer = true) { global $db, $CONFIG, $USER, $PAGE, $USER_DATA, $CPG_M_DIR; if ($cat == 0 && $buffer) { return ''; } $cat = intval($cat); $alb_per_page = $CONFIG['albums_per_page']; $maxTab = $CONFIG['max_tabs']; $visible = ''; if (!USER_IS_ADMIN && !$CONFIG['show_private']) { $visible = "AND " . VIS_GROUPS; // NEW gtroll $tmpvis = explode(',', USER_IN_GROUPS); $vis[0] = 0; foreach ($tmpvis as $dummy => $group) { $vis[$group] = $group; } unset($tmpvis); } /* $result = $db->sql_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = $cat $visible",false,__FILE__,__LINE__); $nbEnr = $db->sql_fetchrow($result); $nbAlb = $nbEnr[0]; $db->sql_freeresult($result); */ //$nbAlb = cpg_tablecount($CONFIG['TABLE_ALBUMS']." WHERE category = $cat $visible", 'count(*)',__FILE__, __LINE__); $nbAlb = 0; foreach (get_albums_data() as $row) { if ($row['category'] != $cat) { continue; } if (isset($vis) && !isset($vis[$row['visibility']])) { continue; } $nbAlb++; } if (!$nbAlb) { return ''; } $totalPages = ceil($nbAlb / $alb_per_page); if (isset($_GET['page'])) { $PAGE = max(intval($_GET['page']), 1); } //if ($PAGE > $totalPages || $cat != $_GET['cat']) $PAGE = 1; if ($PAGE > $totalPages) { $PAGE = 1; } $lower_limit = ($PAGE - 1) * $alb_per_page; $upper_limit = min($nbAlb, $PAGE * $alb_per_page); $sql = "SELECT a.aid, a.title, a.description, visibility, filepath, " . "filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_ALBUMS']} as a " . "LEFT JOIN {$CONFIG['TABLE_PICTURES']} as p ON thumb=pid " . "WHERE category = '{$cat}' {$visible} ORDER BY pos " . "LIMIT " . ($upper_limit - $lower_limit) . " OFFSET " . $lower_limit; $alb_thumbs = $db->sql_ufetchrowset($sql, SQL_BOTH, __FILE__, __LINE__); $disp_album_count = count($alb_thumbs); $album_set = ''; foreach ($alb_thumbs as $value) { $album_set .= $value['aid'] . ', '; } $album_set = '(' . substr($album_set, 0, -2) . ')'; $sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE aid IN {$album_set} AND approved = '1' " . "GROUP BY aid"; if ($alb_stats = $db->sql_ufetchrowset($sql, SQL_BOTH)) { foreach ($alb_stats as $key => $value) { $cross_ref[$value['aid']] =& $alb_stats[$key]; } } for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) { $alb_thumb =& $alb_thumbs[$alb_idx]; $aid = $alb_thumb['aid']; if (isset($cross_ref[$aid])) { $alb_stat = $cross_ref[$aid]; $count = $alb_stat['pic_count']; } else { $alb_stat = array(); $count = 0; } // Inserts a thumbnail if the album contains 1 or more images $visibility = $alb_thumb['visibility']; if ($visibility == '0' || $visibility == FIRST_USER_CAT + USER_ID || $visibility == $USER_DATA['group_id'] || USER_IS_ADMIN || user_ingroup($visibility, $USER_DATA['user_group_list_cp'])) { if ($count > 0) { // Inserts a thumbnail if the album contains 1 or more images if ($alb_thumb['filename']) { $picture =& $alb_thumb; } else { $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='{$alb_stat['last_pid']}'"; $result = $db->sql_query($sql, false, __FILE__, __LINE__); $picture = $db->sql_fetchrow($result); $db->sql_freeresult($result); } $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . get_pic_url($picture, 'thumb') . "\" {$image_size['geom']} title=\"" . $alb_thumb['title'] . "\" alt=\"" . $alb_thumb['title'] . "\" border=\"0\" class=\"image\" />"; } else { // Inserts an empty thumbnail if the album contains 0 images $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"{$CPG_M_DIR}/images/nopic.jpg\" {$image_size['geom']} alt=\"" . NO_IMG_TO_DISPLAY . "\" title=\"" . NO_IMG_TO_DISPLAY . "\" border=\"0\" class=\"image\" />"; } } elseif ($CONFIG['show_private']) { $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']); $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"{$CPG_M_DIR}/images/private.jpg\" {$image_size['geom']} alt=\"" . MEMBERS_ONLY . "\" title=\"" . MEMBERS_ONLY . "\" border=\"0\" class=\"image\" />"; } // Prepare everything $last_upload_date = $count ? localised_date($alb_stat['last_upload'], LASTUP_DATE_FMT) : ''; $alb_list[$alb_idx]['aid'] = $alb_thumb['aid']; $alb_list[$alb_idx]['album_title'] = $alb_thumb['title']; $alb_list[$alb_idx]['album_desc'] = decode_bbcode($alb_thumb['description']); $alb_list[$alb_idx]['pic_count'] = $count; $alb_list[$alb_idx]['last_upl'] = $last_upload_date; $alb_list[$alb_idx]['album_info'] = sprintf(N_PICTURES, $count) . ($count ? sprintf(LAST_ADDED, $last_upload_date) : ""); $alb_list[$alb_idx]['album_adm_menu'] = GALLERY_ADMIN_MODE || USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT ? html_albummenu($alb_thumb['aid']) : ''; } if ($buffer) { ob_start(); theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages); $cat_albums = ob_get_contents(); ob_end_clean(); return $cat_albums; } else { theme_display_album_list($alb_list, $nbAlb, $cat, $PAGE, $totalPages); } }