/** * 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'); }
/** * Unpublishes an asset, i.e. moves it from public album to private * @param type $asset_name $the asset to move * @param type $public_album public album name * @return bool error status */ function ezmam_asset_unpublish($public_album, $asset_name) { if (!ezmam_album_exists($public_album)) { ezmam_last_error("ezmam_asset_publish: private album does not exist"); return false; } if (!ezmam_asset_exists($public_album, $asset_name)) { ezmam_last_error("ezmam_asset_publish: asset does not exist"); return false; } $private_album = suffix_replace($public_album); $res = ezmam_asset_move($asset_name, $public_album, $private_album); return $res; }