function album_get_auth_keys($cur_cat_id = ALBUM_ROOT_CATEGORY, $auth_key = ALBUM_AUTH_VIEW, $all = false, $level = -1, $max = -1) { global $album_data; $keys = array(); $last_i = -1; // add the level if ($max < ALBUM_ROOT_CATEGORY + 1 || $level < $max || $level == $max && $album_data['parent'][$album_data['keys'][$cur_cat_id]] == ALBUM_ROOT_CATEGORY) { if ($cur_cat_id == ALBUM_ROOT_CATEGORY || album_check_permission($album_data['auth'][$cur_cat_id], $auth_key) || $all) { // if child of cat, align the level on the parent one $orig_level = $level; // store this level $last_i++; $keys['keys'][$cur_cat_id] = $last_i; $keys['id'][$last_i] = $cur_cat_id; $keys['real_level'][$last_i] = $orig_level; $keys['level'][$last_i] = $level; $keys['idx'][$last_i] = isset($album_data['keys'][$cur_cat_id]) ? $album_data['keys'][$cur_cat_id] : ALBUM_ROOT_CATEGORY; // get sub-levels for ($i = 0; $i < sizeof($album_data['sub'][$cur_cat_id]); $i++) { $subkeys = array(); $subkeys = album_get_auth_keys($album_data['sub'][$cur_cat_id][$i], $auth_key, $all, $orig_level + 1, $max); // add sub-levels for ($j = 0; $j < sizeof($subkeys['id']); $j++) { $last_i++; $keys['keys'][$subkeys['id'][$j]] = $last_i; $keys['id'][$last_i] = $subkeys['id'][$j]; $keys['real_level'][$last_i] = $subkeys['real_level'][$j]; $keys['level'][$last_i] = $subkeys['level'][$j]; $keys['idx'][$last_i] = $subkeys['idx'][$j]; } // for( $j = 0..... } // for($i = 0..... } // if ($cur_cat_id == ALBUM_ROOT.... } // if (($max < 0 ..... if ($level <= ALBUM_ROOT_CATEGORY && ALBUM_HIERARCHY_DEBUG_ENABLED == true) { album_debug('album_get_auth_keys = %s', $keys); } return $keys; }
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; }