/** * Removes an asset bookmark from the user's bookmarks list * @global type $input * @global type $repository_path * @global type $user_files_path */ function bookmark_delete() { global $input; global $repository_path; global $user_files_path; $bookmark_album = $input['album']; $bookmark_asset = $input['asset']; $bookmark_timecode = $input['timecode']; // init paths ezmam_repository_path($repository_path); user_prefs_repository_path($user_files_path); if ($input['tab'] == 'custom') { // remove from personal bookmarks user_prefs_asset_bookmark_delete($_SESSION['user_login'], $bookmark_album, $bookmark_asset, $bookmark_timecode); } else { // removes from table of contents if (acl_user_is_logged() && acl_has_album_moderation($bookmark_album)) { toc_asset_bookmark_delete($bookmark_album, $bookmark_asset, $bookmark_timecode); } } // lvl, action, album, asset, timecode trace_append(array($_SESSION['asset'] == '' ? '2' : '3', 'bookmark_delete', $bookmark_album, $bookmark_asset, $bookmark_timecode)); log_append('remove_asset_bookmark', 'bookmark removed : album -' . $bookmark_album . ' asset - ' . $bookmark_asset . ' timecode - ' . $bookmark_timecode); if ($input['source'] == 'assets') { $input['token'] = ezmam_album_token_get($bookmark_album); view_album_assets(false); } else { view_asset_details(false); } }
/** * Adds a bookmark in the album bookmarks file * @param type $user the user * @param type $album the album * @param type $asset the asset * @param type $timecode the timecode of the bookmark * @param type $title the title of the bookmark * @param type $description the description of the bookmark * @param type $keywords the keywords of the bookmark * @param type $level the level of the bookmark * @return boolean */ function user_prefs_asset_bookmark_add($user, $album, $asset, $timecode, $title = '', $description = '', $keywords = '', $level = '1', $type = '') { // Sanity check if (!isset($user) || $user == '') { return false; } if (!ezmam_album_exists($album)) { return false; } if (!ezmam_asset_exists($album, $asset)) { return false; } if (!isset($timecode) || $timecode == '' || $timecode < 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; // remove the previous same bookmark if it existed yet user_prefs_asset_bookmark_delete($user, $album, $asset, $timecode); // if the user's directory doesn't exist yet, we create it if (!file_exists($user_path)) { mkdir($user_path, 0755, true); } // Get the bookmarks list $bookmarks_list = user_prefs_album_bookmarks_list_get($user, $album); $count = count($bookmarks_list); $index = 0; if ($count > 0) { $index = -1; $asset_ref = $bookmarks_list[0]['asset']; $timecode_ref = $bookmarks_list[0]['timecode']; // loop while the asset is older than the reference asset while ($index < $count && $asset < $asset_ref) { ++$index; $asset_ref = $bookmarks_list[$index]['asset']; $timecode_ref = $bookmarks_list[$index]['timecode']; } // if the asset already contains bookmarks, loop while // timecode is bigger than reference timecode while ($index < $count && $asset == $asset_ref && $timecode > $timecode_ref) { ++$index; $timecode_ref = $bookmarks_list[$index]['timecode']; $asset_ref = $bookmarks_list[$index]['asset']; } if ($index < 0) { // no bookmark yet $index = 0; } if ($index > $count) { // add in last index --$index; } } // extract keywords from the description $keywords_array = get_keywords($description); // and save them as keywords foreach ($keywords_array as $keyword) { if (strlen($keywords) > 0) { $keywords .= ', '; } $keywords .= $keyword; } // surround every url by '*' for url recognition in EZplayer $description = surround_url($description); // add a bookmark at the specified index in the albums list array_splice($bookmarks_list, $index, 0, array(null)); $bookmarks_list[$index] = array('album' => $album, 'asset' => $asset, 'timecode' => $timecode, 'title' => $title, 'description' => $description, 'keywords' => $keywords, 'level' => $level, 'type' => $type); return assoc_array2xml_file($bookmarks_list, $user_path . "/bookmarks_{$album}.xml", "bookmarks", "bookmark"); }