Beispiel #1
0
/**
 * 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;
    }
}
Beispiel #2
0
/**
 * Removes all bookmarks of a given asset
 * @param type $album the album containing bookmarks
 * @param type $asset the asset we want to remove bookmarks from
 * @return an array of bookmarks if the bookmarks have been deleted; false otherwise
 */
function toc_asset_bookmarks_delete_all($album, $asset)
{
    // Sanity check
    if (!ezmam_album_exists($album)) {
        return false;
    }
    // 1) set the repository path
    $toc_path = ezmam_repository_path();
    if ($toc_path === false) {
        return false;
    }
    // set user's file path
    $toc_path = $toc_path . '/' . $album;
    $bookmarks_list = toc_album_bookmarks_list_get($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 toc_album_bookmarks_delete_all($album);
    }
    return assoc_array2xml_file($bookmarks_list, $toc_path . "/_bookmarks.xml", "bookmarks", "bookmark");
}