default: $album_view_mode = ''; } $cat_id = request_var('cat_id', 0); if ($cat_id <= 0) { $cat_id = ALBUM_ROOT_CATEGORY; } if ($album_user_id < 1) { if (!$user->data['session_logged_in']) { redirect(append_sid(album_append_uid(CMS_PAGE_LOGIN . '?redirect=album.' . PHP_EXT, true))); } else { $album_user_id = $user->data['user_id']; redirect(append_sid(album_append_uid('album.' . PHP_EXT, true))); } } if ($cat_id != ALBUM_ROOT_CATEGORY && $cat_id != album_get_personal_root_id($album_user_id)) { redirect(append_sid(album_append_uid('album_cat.' . PHP_EXT . album_build_url_parameters($_GET), false))); } } $catrows = array(); $options = $album_view_mode == ALBUM_VIEW_LIST ? ALBUM_READ_ALL_CATEGORIES | ALBUM_AUTH_VIEW : ALBUM_AUTH_VIEW; $catrows = album_read_tree($album_user_id, $options); // Mighty Gorgon: is this really needed? Maybe not... let's keep it commented until someone complains!!! //album_read_tree($album_user_id); $album_nav_cat_desc = album_make_nav_tree($cat_id, 'album_cat.' . PHP_EXT, 'nav', $album_user_id); if ($album_nav_cat_desc != '') { $nav_server_url = create_server_url(); $album_nav_cat_desc = ALBUM_NAV_ARROW . $album_nav_cat_desc; $breadcrumbs['address'] = ALBUM_NAV_ARROW . '<a href="' . $nav_server_url . append_sid('album.' . PHP_EXT) . '">' . $lang['Album'] . '</a>' . $album_nav_cat_desc; } // --------------------------------
break; } $pic_preview = ''; $pic_preview_hs = ''; if ($album_config['lb_preview']) { $slideshow_cat = ''; $slideshow = !empty($slideshow_cat) ? ', { slideshowGroup: \'' . $slideshow_cat . '\' } ' : ''; $pic_preview_hs = ' class="highslide" onclick="return hs.expand(this' . $slideshow . ');"'; $pic_preview = 'onmouseover="showtrail(\'' . append_sid(album_append_uid('album_picm.' . PHP_EXT . '?pic_id=' . $picrow[$j]['pic_id'])) . '\',\'' . addslashes($picrow[$j]['pic_title']) . '\', ' . $album_config['midthumb_width'] . ', ' . $album_config['midthumb_height'] . ')" onmouseout="hidetrail()"'; } $template_vars = array('PIC_PREVIEW_HS' => $pic_preview_hs, 'PIC_PREVIEW' => $pic_preview); album_build_column_vars($template_vars, $picrow[$j]); $template->assign_block_vars('picrow.piccol', $template_vars); // is a personal category that the picture belongs to AND // is it the main category in the personal gallery ? if ($picrow[$j]['cat_user_id'] != 0 && $picrow[$j]['cat_id'] == album_get_personal_root_id($picrow[$j]['cat_user_id'])) { $album_page_url = 'album.' . PHP_EXT; } else { $album_page_url = 'album_cat.' . PHP_EXT; } $image_cat_url = append_sid(album_append_uid($album_page_url . '?cat_id=' . $picrow[$j]['cat_id'] . '&user_id=' . $picrow[$j]['cat_user_id'])); $template_vars = array('PIC_PREVIEW_HS' => $pic_preview_hs, 'PIC_PREVIEW' => $pic_preview, 'CATEGORY' => $picrow[$j]['cat_title'], 'U_PIC_CAT' => $image_cat_url, 'GROUP_NAME' => 'memberlist'); album_build_detail_vars($template_vars, $picrow[$j]); // $template_vars['TITLE'] = htmlspecialchars($picrow[$j]['pic_title']); $template->assign_block_vars('picrow.pic_detail', $template_vars); } } // -------------------------------- // Pagination // -------------------------------- $template->assign_vars(array('PAGINATION' => generate_pagination(append_sid(album_append_uid('album.' . PHP_EXT . '?user_id=' . $album_user_id . '&sort_method=' . $sort_method . '&sort_order=' . $sort_order . $album_view_mode_param . $album_view_type_param)), $total_pics, $pics_per_page, $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $pics_per_page) + 1, ceil($total_pics / $pics_per_page))));
$album_view_mode = strtolower($mode); // make sure that it only contains some valid value switch ($album_view_mode) { case ALBUM_VIEW_ALL: $album_view_mode = ALBUM_VIEW_ALL; break; case ALBUM_VIEW_LIST: $album_view_mode = ALBUM_VIEW_LIST; break; default: $album_view_mode = ''; } // END check request // if requested gallery is the root category of the public categories, OR // the category is the root category of the personal gallery - then show root album instead if ($cat_id <= ALBUM_ROOT_CATEGORY + 1 || album_get_personal_root_id($album_user_id) == $cat_id) { if ($cat_id == ALBUM_JUMPBOX_PUBLIC_GALLERY) { redirect(append_sid(album_append_uid('album.' . PHP_EXT))); } if ($cat_id == ALBUM_JUMPBOX_USERS_GALLERY) { redirect(append_sid(album_append_uid('album_personal_index.' . PHP_EXT))); } redirect(append_sid(album_append_uid('album.' . PHP_EXT))); } // ------------------------------------ // Get this cat info // ------------------------------------ $thiscat = array(); // this category $catrows = array(); // all categories for jumpbox
function album_build_picture_table($user_id, $cat_ids, $AH_thiscat, $auth_data, $start, $sort_method, $sort_order, $total_pics) { global $config, $album_data, $album_config, $template, $user, $lang, $db; $viewmode = strpos($cat_ids, ',') != false ? '&mode=' . ALBUM_VIEW_ALL : ''; if (intval($cat_ids) == album_get_personal_root_id($user_id) && $user_id != ALBUM_PUBLIC_GALLERY) { $album_pagination_page_url = 'album.' . PHP_EXT; } else { $album_pagination_page_url = 'album_cat.' . PHP_EXT; } $pics_per_page = $album_config['rows_per_page'] * $album_config['cols_per_page']; $limit_sql = $start == 0 ? $pics_per_page : $start . ',' . $pics_per_page; $pic_approval_sql = 'AND p.pic_approval = 1'; //if (($AH_thiscat['cat_approval'] != ALBUM_USER) || (($album_config['personal_pics_approval'] == 1) && ($AH_thiscat['cat_user_id'] > 0))) if ($AH_thiscat['cat_approval'] != ALBUM_USER || $album_config['personal_pics_approval'] == 1 && album_get_cat_user_id($cat_ids) != false) { if ($user->data['user_level'] == ADMIN || $auth_data['moderator'] == 1 && $AH_thiscat['cat_approval'] == ALBUM_MOD) { $pic_approval_sql = ''; } } $sort_methods_array = array('pic_time', 'pic_title', 'username', 'pic_view_count', 'rating', 'comments', 'new_comment'); $sort_method = in_array($sort_method, $sort_methods_array) ? $sort_method : $album_config['sort_method']; $sort_order_array = array('ASC', 'DESC'); $sort_order = in_array($sort_order, $sort_order_array) ? $sort_order : $album_config['sort_order']; $sort_append = '&sort_method=' . $sort_method . '&sort_order=' . $sort_order; switch ($sort_method) { case 'pic_time': $sort_method_sql = 'p.pic_time'; break; case 'pic_title': $sort_method_sql = 'p.pic_title'; break; case 'username': $sort_method_sql = 'u.username'; break; case 'pic_view_count': $sort_method_sql = 'p.pic_view_count'; break; case 'rating': $sort_method_sql = 'rating'; break; case 'comments': $sort_method_sql = 'comments'; break; case 'new_comment': $sort_method_sql = 'new_comment'; break; default: $sort_method_sql = 'p.pic_id'; } $sql = "SELECT ct.cat_user_id, ct.cat_id, ct.cat_title, p.*, u.user_id, u.username, u.user_active, u.user_color, r.rate_pic_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments, MAX(c.comment_id) as new_comment\n\t\t\tFROM " . ALBUM_TABLE . " AS p\n\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON p.pic_user_id = u.user_id\n\t\t\t\tLEFT JOIN " . ALBUM_RATE_TABLE . " AS r ON p.pic_id = r.rate_pic_id\n\t\t\t\tLEFT JOIN " . ALBUM_COMMENT_TABLE . " AS c ON p.pic_id = c.comment_pic_id\n\t\t\t\tLEFT JOIN " . ALBUM_CAT_TABLE . " AS ct ON p.pic_cat_id = ct.cat_id\n\t\t\tWHERE p.pic_cat_id IN ({$cat_ids}) {$pic_approval_sql}\n\t\t\tGROUP BY p.pic_id\n\t\t\tORDER BY {$sort_method_sql} {$sort_order}\n\t\t\tLIMIT {$limit_sql}"; $result = $db->sql_query($sql); $picrow = array(); while ($row = $db->sql_fetchrow($result)) { $picrow[] = $row; } $tot_unapproved = 0; for ($i = 0; $i < sizeof($picrow); $i++) { if ($picrow[$i]['pic_approval'] == 0) { $tot_unapproved++; } } $db->sql_freeresult($result); $template->assign_block_vars('index_pics_block', array()); $template->assign_block_vars('index_pics_block.enable_gallery_title', array()); for ($i = 0; $i < sizeof($picrow); $i += $album_config['cols_per_page']) { $template->assign_block_vars('index_pics_block.picrow', array()); for ($j = $i; $j < $i + $album_config['cols_per_page']; $j++) { if ($j >= sizeof($picrow)) { $template->assign_block_vars('index_pics_block.picrow.nopiccol', array()); $template->assign_block_vars('index_pics_block.picrow.picnodetail', array()); continue; //break; } //if (($AH_thiscat['cat_approval'] != ALBUM_USER) || (($album_config['personal_pics_approval'] == 1) && ($AH_thiscat['cat_user_id'] > 0))) if ($AH_thiscat['cat_approval'] != ALBUM_USER || $album_config['personal_pics_approval'] == 1 && album_get_cat_user_id($cat_ids) != false) { if ($user->data['user_level'] == ADMIN || $auth_data['moderator'] == 1 && $AH_thiscat['cat_approval'] == ALBUM_MOD) { $approval_mode = $picrow[$j]['pic_approval'] == 0 ? 'approval' : 'unapproval'; $approval_link = '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=' . $approval_mode . '&pic_id=' . $picrow[$j]['pic_id'])) . '">'; $approval_link .= $picrow[$j]['pic_approval'] == 0 ? '<b>' . $lang['Approve'] . '</b>' : $lang['Unapprove']; $approval_link .= '</a>'; } } $pic_preview = ''; $pic_preview_hs = ''; if ($album_config['lb_preview']) { $slideshow_cat = ''; $slideshow = !empty($slideshow_cat) ? ', { slideshowGroup: \'' . $slideshow_cat . '\' } ' : ''; $pic_preview_hs = ' class="highslide" onclick="return hs.expand(this' . $slideshow . ');"'; $pic_preview = 'onmouseover="showtrail(\'' . append_sid(album_append_uid('album_picm.' . PHP_EXT . '?pic_id=' . $picrow[$j]['pic_id'])) . '\',\'' . addslashes($picrow[$j]['pic_title']) . '\', ' . $album_config['midthumb_width'] . ', ' . $album_config['midthumb_height'] . ')" onmouseout="hidetrail()"'; } $template_vars = array('PIC_PREVIEW_HS' => $pic_preview_hs, 'PIC_PREVIEW' => $pic_preview, 'APPROVAL' => $approval_link); album_build_column_vars($template_vars, $picrow[$j], $sort_append); $template->assign_block_vars('index_pics_block.picrow.piccol', $template_vars); if ($picrow[$j]['user_id'] == ALBUM_GUEST || $picrow[$j]['username'] == '') { $pic_poster = $picrow[$j]['pic_username'] == '' ? $lang['Guest'] : $picrow[$j]['pic_username']; } else { $pic_poster = colorize_username($picrow[$j]['user_id'], $picrow[$j]['username'], $picrow[$j]['user_color'], $picrow[$j]['user_active']); } $edit_rights = $auth_data['edit'] && $picrow[$j]['pic_user_id'] == $user->data['user_id'] || $auth_data['moderator'] && $AH_thiscat['cat_edit_level'] != ALBUM_ADMIN || $user->data['user_level'] == ADMIN ? true : false; $delete_rights = $auth_data['delete'] && $picrow[$j]['pic_user_id'] == $user->data['user_id'] || $auth_data['moderator'] && $AH_thiscat['cat_delete_level'] != ALBUM_ADMIN || $user->data['user_level'] == ADMIN ? true : false; $admin_rights = $auth_data['moderator']; $user_rights = array('edit' => $edit_rights, 'delete' => $delete_rights, 'admin' => $admin_rights); $template_vars = array('POSTER' => $pic_poster, 'PIC_PREVIEW_HS' => $pic_preview_hs, 'PIC_PREVIEW' => $pic_preview, 'GROUP_NAME' => 'index', 'APPROVAL' => $approval_link, 'AVATAR_PIC' => $album_config['personal_allow_avatar_gallery'] == 1 && $user->data['user_id'] == $picrow[$j]['pic_user_id'] && $picrow[$j]['cat_user_id'] != 0 ? '<br /><a href="' . append_sid('album_avatar.' . PHP_EXT . '?pic_id=' . $picrow[$j]['pic_id']) . '">' . $lang['Avatar_Set'] . '</a>' : '', 'IMG_BBCODE' => $user->data['user_level'] == ADMIN || $user->data['user_id'] == $picrow[$j]['pic_user_id'] ? '<br /><a href="javasript://" OnClick="window.clipboardData.setData(\'Text\', \'[albumimg]' . $picrow[$j]['pic_id'] . '[/albumimg]\'); return false;">' . $lang['BBCode_Copy'] . '</a>' : ''); album_build_detail_vars($template_vars, $picrow[$j], $sort_append, $user_rights); $template->assign_block_vars('index_pics_block.picrow.pic_detail', $template_vars); // Mighty Gorgon - Slideshow - BEGIN if ($album_config['show_slideshow']) { $last_pic_id = $picrow[$j]['pic_id']; $slideshow_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $last_pic_id . '&slideshow=5')); $slideshow_link_full = ' [<a href="' . $slideshow_link . '">' . $lang['Slideshow'] . '</a>] '; } else { $slideshow_link_full = ''; } // Mighty Gorgon - Slideshow - END if (is_array($cats)) { // is a personal category that the picture belongs to AND // is it the main category in the personal gallery ? if ($picrow[$j]['cat_user_id'] != 0 && $picrow[$j]['cat_id'] == album_get_personal_root_id($picrow[$j]['cat_user_id'])) { $album_page_url = 'album.' . PHP_EXT; } else { $album_page_url = 'album_cat.' . PHP_EXT; } $image_cat_url = append_sid(album_append_uid($album_page_url . '?cat_id=' . $picrow[$j]['cat_id'] . '&user_id=' . $picrow[$j]['cat_user_id'])); $template->assign_block_vars('index_pics_block.picrow.pic_detail.cats', array('CATEGORY' => $picrow[$j]['cat_title'], 'U_PIC_CAT' => $image_cat_url)); } } } $template->assign_vars(array('PAGINATION' => generate_pagination(append_sid(album_append_uid($album_pagination_page_url . '?cat_id=' . intval($cat_ids) . $sort_append . $viewmode)), $total_pics, $pics_per_page, $start), 'SLIDESHOW' => $slideshow_link_full, $waiting = $tot_unapproved == 0 ? "" : $tot_unapproved . $lang['Waiting'], 'WAITING' => $user->data['user_level'] == ADMIN ? $tot_unapproved == 0 ? ' ' : '<br /><span class="gensmall"><b>' . $tot_unapproved . $lang['Waiting'] . '</b></span>' : ' ', 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $pics_per_page) + 1, ceil($total_pics / $pics_per_page)))); }
$cat_desc = trim($_POST['cat_desc']); } $cat_wm = trim($_POST['cat_wm']); $view_level = intval($_POST['cat_view_level']); $upload_level = intval($_POST['cat_upload_level']); $rate_level = intval($_POST['cat_rate_level']); $comment_level = intval($_POST['cat_comment_level']); $edit_level = intval($_POST['cat_edit_level']); $delete_level = intval($_POST['cat_delete_level']); $cat_approval = intval($_POST['cat_approval']); $cat_parent = $_POST['cat_parent_id'] == ALBUM_ROOT_CATEGORY ? 0 : intval($_POST['cat_parent_id']); $cat_parent = $cat_parent < 0 ? 0 : $cat_parent; if ($cat_id == $cat_parent && album_get_personal_root_id($album_user_id) != $cat_id) { showResultMessage($lang['No_Self_Refering_Cat']); } if (album_get_personal_root_id($album_user_id) == $cat_id && $cat_parent != 0) { showResultMessage($lang['Can_Not_Change_Main_Parent']); } // Now we update this row $sql = "UPDATE " . ALBUM_CAT_TABLE . "\n\t\t\t\tSET cat_title = '{$cat_title}', cat_desc = '{$cat_desc}', cat_wm = '{$cat_wm}', cat_view_level = '{$view_level}', cat_upload_level = '{$upload_level}', cat_rate_level = '{$rate_level}', cat_comment_level = '{$comment_level}', cat_edit_level = '{$edit_level}', cat_delete_level = '{$delete_level}', cat_approval = '{$cat_approval}', cat_parent = '{$cat_parent}'\n\t\t\t\tWHERE cat_id = '{$cat_id}'"; $result = $db->sql_query($sql); // Return a message... showResultMessage($lang['Category_updated']); } elseif ($_POST['mode'] == 'delete') { $parent_cat_deleted = false; $parent_cat_id = 0; $parent_cat_title = ""; $cat_id = intval($_GET['cat_id']); $target = intval($_POST['target']); if ($target == ALBUM_JUMPBOX_DELETE) { // check if the selected category is a parent to another category
function album_display_index($user_id, $cur_cat_id = ALBUM_ROOT_CATEGORY, $show_header = false, $show_public_footer = false, $force_display = false) { global $lang, $config, $template, $images, $album_data, $album_config, $user; $keys = array(); // for testing ONLY if (album_is_debug_enabled() == true) { if (strcmp($cur_cat_id, 'Root') == 0) { die('WRONG ROOT VALUE'); } } $is_personal_gallery = $user_id != ALBUM_PUBLIC_GALLERY ? true : false; // if we are showing a personal gallery AND we are at the root of personal gallery // then ignore the root folder of the personal gallery, since it's 'hidden' if ($is_personal_gallery && $cur_cat_id == ALBUM_ROOT_CATEGORY) { $cur_cat_id = album_get_personal_root_id($user_id); } $template->set_filenames(array('album' => 'album_box.tpl')); $keys = album_get_auth_keys($cur_cat_id, ALBUM_AUTH_VIEW); $display = album_build_index($user_id, $keys, $cur_cat_id, ALBUM_ROOT_CATEGORY, ALBUM_ROOT_CATEGORY); if ($force_display && !$is_personal_gallery && sizeof($album_data) == 0) { $template->assign_block_vars('catmain', array()); $template->assign_block_vars('catmain.catrow', array('CAT_TITLE' => $lang['No_Public_Galleries'], 'CAT_IMG' => $images['forum_nor_locked_read'])); $display = true; } // Added so that, even if there are no public galleries, the member or user galleries can be reached if ($force_display && !$is_personal_gallery && !$display) { $display = true; } // lets do some debugging.. if (album_is_debug_enabled() == true) { album_debug('$user_id = %d<br />$cur_cat_id = %d<br />$display = %d<br />album data = %s<br />authentication keys = %s', $user_id, $cur_cat_id, intval($display), $album_data, $keys); } if ($display || album_is_debug_enabled() == true) { if ($show_header) { // create header and send it to template $template->assign_block_vars('catheader', array('L_CATEGORY' => $lang['Category'], 'L_PUBLIC_CATS' => !$is_personal_gallery ? $lang['Public_Categories'] : sprintf($lang['Personal_Gallery_Of_User'], album_get_user_name($user_id)), 'U_YOUR_PERSONAL_GALLERY' => append_sid(album_append_uid('album.' . PHP_EXT . '?user_id=' . $user->data['user_id'])), 'L_YOUR_PERSONAL_GALLERY' => $lang['Your_Personal_Gallery'], 'U_USERS_PERSONAL_GALLERIES' => append_sid(album_append_uid('album_personal_index.' . PHP_EXT)), 'L_USERS_PERSONAL_GALLERIES' => $lang['Users_Personal_Galleries'])); $cols_span = album_generate_index_columns($username); // but we need to specificly specify if we want to show the public gallery header if ($show_public_footer == true) { $template->assign_block_vars('catfooter.cat_public_footer', array('U_YOUR_PERSONAL_GALLERY' => append_sid(album_append_uid('album.' . PHP_EXT . '?user_id=' . $user->data['user_id'])), 'L_YOUR_PERSONAL_GALLERY' => $lang['Your_Personal_Gallery'], 'U_USERS_PERSONAL_GALLERIES' => append_sid(album_append_uid('album_personal_index.' . PHP_EXT)), 'L_USERS_PERSONAL_GALLERIES' => $lang['Users_Personal_Galleries'], 'FOOTER_COL_SPAN' => $cols_span)); if ($album_config['show_otf_link'] == 1) { $template->assign_block_vars('catfooter.cat_public_footer.show_otf_link', array()); } if ($album_config['show_all_pics_link'] == 1) { $template->assign_block_vars('catfooter.cat_public_footer.show_all_pics_link', array()); } if ($album_config['show_personal_galleries_link'] == 1) { $template->assign_block_vars('catfooter.cat_public_footer.show_personal_galleries_link', array()); } } } $template->assign_var_from_handle('ALBUM_BOARD_INDEX', 'album'); } return $display; }
function showResultMessage($in_message) { global $lang, $album_user_id; if (album_get_personal_root_id($album_user_id) == ALBUM_ROOT_CATEGORY && strcmp('delete', isset($_GET['action']) == 0)) { $message = $in_message . '<br /><br />' . sprintf($lang['Click_return_personal_gallery_index'], '<a href="' . append_sid(album_append_uid('album_personal_index.' . PHP_EXT)) . '">', '</a>'); } else { $message = $in_message . '<br /><br />' . sprintf($lang['Click_return_personal_gallery'], '<a href="' . append_sid(album_append_uid('album.' . PHP_EXT)) . '">', '</a>'); } message_die(GENERAL_MESSAGE, $message); }
} $cat_ids = $cat_id; $image_toggle_button = $images['all_pic_view_mode']; $view_mode_url = append_sid(album_append_uid($album_page_url . '?cat_id=' . intval($cat_id) . '&mode=' . ALBUM_VIEW_ALL)); $view_mode_text = $lang['Show_all_pic_view_mode']; } else { $album_nav_cat_desc = album_make_nav_tree(album_get_personal_root_id($album_user_id), $album_page_url, 'nav', $album_user_id); if (!empty($album_nav_cat_desc)) { $nav_server_url = create_server_url(); $album_nav_cat_desc = ALBUM_NAV_ARROW . $album_nav_cat_desc; $breadcrumbs['address'] = ALBUM_NAV_ARROW . '<a href="' . $nav_server_url . append_sid('album.' . PHP_EXT) . '">' . $lang['Album'] . '</a>' . $album_nav_cat_desc; } if (album_get_personal_root_id($album_user_id) != $cat_id) { $allowed_cat = $cat_id; $tmp_array = array(); album_get_sub_cat_ids(album_get_personal_root_id($album_user_id), $tmp_array, ALBUM_AUTH_VIEW, true); reset($tmp_array); while (list($key, $id) = each($tmp_array)) { if ($id != $cat_id) { $allowed_cat .= ',' . $id; } } } $cat_ids = $allowed_cat; $image_toggle_button = $images['normal_pic_view_mode']; $view_mode_url = append_sid(album_append_uid($album_page_url . '?cat_id=' . intval($cat_id))); $view_mode_text = $lang['Show_selected_pic_view_mode']; } // ------------------------------------------------------------------------ // Count Pics of the root category of personal gallery, // - $cat_ids is set in the above IF statement