/** * Moves all bookmarks of an asset from the public to the private album and reverse. * @param type $album * @param type $asset */ function toc_album_bookmarks_swap($album, $asset) { $bookmarks = toc_asset_bookmark_list_get($album, $asset); toc_asset_bookmarks_delete_all($album, $asset); $album = suffix_replace($album); $count = count($bookmarks); for ($index = 0; $index < $count; $index++) { $bookmarks[$index]['album'] = $album; } toc_album_bookmarks_add($bookmarks); }
/** * Moves asset from $input['from'] to $input['to'] * @global type $input * @global type $repository_path */ function asset_move() { global $input; global $repository_path; ezmam_repository_path($repository_path); // // Sanity checks // if (!isset($input['asset']) || !isset($input['from']) || !isset($input['to'])) { echo 'Usage: web_index.php?action=move_asset&from=SOURCE&to=DESTINATION&asset=ASSET'; die; } if (!acl_has_album_permissions($input['from']) || !acl_has_album_permissions($input['to'])) { error_print_message(template_get_message('Unauthorized', get_lang())); log_append('warning', 'move_asset: you can\'t manage album ' . $input['from'] . ' or ' . $input['to']); die; } if (!ezmam_asset_exists($input['from'], $input['asset'])) { error_print_message(template_get_message('Non-existant_album', get_lang())); log_append('warning', 'move_asset: asset ' . $input['asset'] . ' of album ' . $input['from'] . ' does not exist'); die; } // saves the bookmarks to copy $bookmarks = toc_asset_bookmark_list_get($input['from'], $input['asset']); // deletes the bookmarks from the source album toc_asset_bookmarks_delete_all($input['from'], $input['asset']); // // Moving the asset // TODO: the moving won't work if there is a different asset with the same name in dest folder. Should be corrected in the future (new asset renamed) // $res = ezmam_asset_move($input['asset'], $input['from'], $input['to']); if (!$res) { error_print_message(ezmam_last_error()); die; } // adds the previously saved bookmarks to the new album $count = count($bookmarks); for ($index = 0; $index < $count; $index++) { $bookmarks[$index]['album'] = $input['to']; } toc_album_bookmarks_add($bookmarks); include_once template_getpath('popup_asset_successfully_moved.php'); }