/** * Returns a bookmarks list to display in a popup (export_bookmarks / delete_bookmarks) * @global type $input * @global type $repository_path * @global type $user_files_path */ function bookmarks_popup() { global $input; global $repository_path; global $user_files_path; $album = $input['album']; $asset = $input['asset']; $tab = $input['tab']; $source = $input['source']; ezmam_repository_path($repository_path); user_prefs_repository_path($user_files_path); if (isset($asset) && $asset != '') { $asset_meta = ezmam_asset_metadata_get($album, $asset); if ($tab == 'custom') { $bookmarks = user_prefs_asset_bookmarks_list_get($_SESSION['user_login'], $album, $asset); } else { $bookmarks = toc_asset_bookmark_list_get($album, $asset); } } else { if ($tab == 'custom') { $bookmarks = user_prefs_album_bookmarks_list_get($_SESSION['user_login'], $album); } else { $bookmarks = toc_album_bookmarks_list_get($album); } } switch ($input['display']) { case 'delete': include_once template_getpath('popup_delete_bookmarks.php'); break; case 'export': include_once template_getpath('popup_export_bookmarks.php'); break; } }
/** * Removes all bookmarks of a specific asset from the bookmarks file * @param type $user the user * @param type $album the album * @param type $asset the asset we want to remove bookmarks from * @return boolean true if the bookmarks have been deleted; false otherwise */ function user_prefs_asset_bookmarks_delete($user, $album, $asset) { // Sanity check if (!isset($user) || $user == '') { return false; } if (!ezmam_album_exists($album)) { 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; $bookmarks_list = user_prefs_album_bookmarks_list_get($user, $album); foreach ($bookmarks_list as $index => $bookmark) { if ($bookmark['asset'] == $asset) { unset($bookmarks_list[$index]); } } // if there is no bookmark anymore, the file is deleted if (count($bookmarks_list) == 0) { return user_prefs_album_bookmarks_delete_all($user, $album); } return assoc_array2xml_file($bookmarks_list, $user_path . "/bookmarks_{$album}.xml", "bookmarks", "bookmark"); }