/** * Displays the list of all assets from the selected album * @refresh_center determines if we need to refresh the whole page / the center * of the page or another part of the page (mainly the right side) * @global type $input * @global type $repository_path * @global type $ezplayer_url * @global type $assets_list * @global string $panel_display */ function view_album_assets($refresh_center = true) { global $input; global $repository_path; global $ezplayer_url; // used in a popup window global $user_files_path; global $assets_list; global $album; global $album_bookmarks; global $toc_bookmarks; global $error_path; // used to display an error on the main page global $login_error; // used to display error when anonymous user login global $default_bookmarks_order; global $default_toc_order; global $cache_limit; // if reloaded is set, the whole page has to be refreshed if ($_SESSION['reloaded']) { unset($input['click']); unset($_SESSION['reloaded']); $refresh_center = true; } $error_path = ''; if (isset($input['album'])) { $album = $input['album']; } else { $album = $_SESSION['album']; } if (isset($input['token'])) { $token = $input['token']; } else { $token = $_SESSION['token']; } ezmam_repository_path($repository_path); user_prefs_repository_path($user_files_path); // 0) Sanity checks if (!ezmam_album_exists($album)) { if ($input['click']) { // refresh a part of the page include_once template_getpath('error_album_not_found.php'); } else { // refresh the whole page $error_path = template_getpath('error_album_not_found.php'); include_once template_getpath('main.php'); } log_append('warning', 'view_album_assets: tried to access non-existant album ' . $input['album']); exit; } // Authorization check if (!ezmam_album_token_check($album, $token)) { if ($input['click']) { include_once template_getpath('error_permission_denied.php'); } else { $error_path = template_getpath('error_permission_denied.php'); include_once template_getpath('main.php'); } log_append('warning', 'view_album_assets: tried to access album ' . $input['album'] . ' with invalid token ' . $input['token']); die; } // 1) Retrieving all assets' metadata $assets_list = ezmam_asset_list_metadata($album); $count = count($assets_list); // add the asset token to the metadata for ($index = 0; $index < $count; $index++) { $assets_list[$index]['token'] = ezmam_asset_token_get($album, $assets_list[$index]['name']); } // 2) Save current album log_append('view_album_assets: ' . $album); $_SESSION['ezplayer_mode'] = 'view_album_assets'; // used in 'div_assets_center.php' $_SESSION['album'] = $album; // used in search $_SESSION['asset'] = ''; $_SESSION['token'] = $token; // 3) Add current album to the album list // and load album bookmarks // $album_name = get_album_title($album); $album_token = array('title' => $album_name, 'album' => $album, 'token' => $token); if (!token_array_contains($_SESSION['acl_album_tokens'], $album_token)) { if (acl_user_is_logged()) { // logged user : consulted albums are stored in file user_prefs_token_add($_SESSION['user_login'], $album, $album_name, $token); log_append('view_album_assets: album token added - ' . $album); trace_append(array('2', 'album_token_add', $album)); // lvl, action, album } else { // anonymous user : consulted albums are stored in session var $_SESSION['acl_album_tokens'][] = $album_token; } acl_update_permissions_list(); } if (acl_user_is_logged()) { // bookmarks to display in 'div_side_assets.php' $album_bookmarks = user_prefs_album_bookmarks_list_get($_SESSION['user_login'], $album); // sorts the bookmarks following user's prefs $order = acl_value_get("bookmarks_order"); if (isset($order) && $order != '' && $order != $default_bookmarks_order) { $album_bookmarks = array_reverse($album_bookmarks); } } // 4) table of contents to display in 'div_side_assets.php' $toc_bookmarks = toc_album_bookmarks_list_get($album); // sorts the bookmarks following user's prefs $order = acl_value_get("toc_order"); if (isset($order) && $order != '' && $order != $default_toc_order) { $toc_bookmarks = array_reverse($toc_bookmarks); } if ($refresh_center) { if (acl_display_threads()) { $threads = threads_select_by_album($album, $cache_limit); foreach ($threads as &$thread) { if (!thread_is_archive($thread['albumName'], $thread['assetName'])) { $threads_list[] = $thread; } } } if ($input['click']) { // called by a local link // lvl, action, album, origin trace_append(array('2', 'view_album_assets', $album, 'from_ezplayer')); include_once template_getpath('div_assets_center.php'); } else { // accessed by the UV or shared link // lvl, action, album, origin trace_append(array('2', 'view_album_assets', $album, 'from_external')); include_once template_getpath('main.php'); } } else { // refresh only the side panel (after import / export / deletion / ...) include_once template_getpath('div_side_assets.php'); } }
/** * Adds album tokens in the album tokens file * @param type $user the owner of the file * @param type $tokens_array the list of tokens to be added * @return true if all tokens of the array have been added to the file; false otherwise */ function user_prefs_tokens_add($user, $tokens_array) { // Sanity check if (!isset($user) || $user == '') { return false; } if (count($tokens_array) == 0) { return false; } // 1) set the repository path $user_files_path = user_prefs_repository_path(); if ($user_files_path === false) { return false; } // set user's file path $user_path = $user_files_path . '/' . $user; // if the user's directory doesn't exist yet, we create it if (!file_exists($user_path)) { mkdir($user_path, 0755, true); } // Get the albums list $token_list = acl_album_tokens_get(); foreach ($tokens_array as &$token) { if (ezmam_album_exists($token['album']) && !token_array_contains($token_list, $token)) { array_unshift($token_list, $token); } } if (count($token_list) == 0) { return false; } // converts the array in xml file return assoc_array2xml_file($token_list, $user_path . "/_album_tokens.xml", "album_tokens", "album_token"); }