コード例 #1
0
ファイル: lib_toc.php プロジェクト: jingyexu/ezcast
/**
 * 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");
}
コード例 #2
0
ファイル: lib_user_prefs.php プロジェクト: jingyexu/ezcast
/**
 * 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");
}