/** * Deletes an album from the repository * @return true|false error status */ function ezmam_album_delete($album_name) { $repository_path = ezmam_repository_path(); if ($repository_path === false) { return false; } if (!ezmam_album_exists($album_name)) { ezmam_last_error("Trying to delete {$album_name} which doesn't exist!"); return false; } $path = $repository_path . '/' . $album_name; // First we empty the directory $dir = opendir($path); if ($dir === false) { ezmam_last_error("Unable to open folder {$path}"); return false; } while (($file = readdir($dir)) !== false) { if ($file != "." && $file != "..") { if (is_dir($path . '/' . $file)) { ezmam_asset_delete($album_name, $file, false); } else { unlink($path . '/' . $file); } } } // Then we delete it $res = rmdir($path); if (!$res) { ezmam_last_error("Unable to delete folder {$path}"); return false; } // And finally we log the operation log_append("album_delete", "Album " . $album_name); return true; }
/** * Effectively deletes an asset from the repository, and displays a nice message to the user */ function asset_delete() { global $input; global $repository_path; // // Sanity checks // ezmam_repository_path($repository_path); if (!isset($input['album']) || !isset($input['asset'])) { echo "Usage: web_index.php?action=delete_asset&album=ALBUM&asset=ASSET"; die; } if (!acl_has_album_permissions($input['album'])) { error_print_message(template_get_message('Unauthorized', get_lang())); log_append('warning', 'delete_asset: tried to access album ' . $input['album'] . ' without permission'); die; } if (!ezmam_asset_exists($input['album'], $input['asset'])) { error_print_message(template_get_message('Non-existant_asset', get_lang())); log_append('warning', 'delete_asset: tried to access asset ' . $input['asset'] . ' of album ' . $input['album'] . ' which does not exist'); die; } // We remove the bookmarks list from the table of contents (EZcast Player) toc_asset_bookmarks_delete_all($input['album'], $input['asset']); // // Now we simply use lib_ezmam to delete the asset from the repository // ezmam_asset_delete($input['album'], $input['asset']); // // And that's all, we just have to print a confirmation message next! // //require_once template_getpath('popup_asset_successfully_deleted.php'); //view_album(); }
} if ($step_by_step) { echo 'adding asset in COURSE-MNEMO-pub'; } $metadata = array('author' => 'X', 'title' => 'Test d\'accentuation UTF-8: tètètè', 'description' => 'Ceci est un accent: à', 'record_date' => '2011_07_26_16h00', 'record_type' => 'camslide', 'language' => 'français'); ezmam_asset_new("COURSE-MNEMO-pub", "2011-07-27-14h32", $metadata); if ($step_by_step) { exec('read'); } /* echo 'deleting album COURSE-MNEMO-pub'; ezmam_album_delete('COURSE-MNEMO-pub'); echo 'Trying to delete a non-existant album'; ezmam_album_delete("FOO-I-000");*/ ezmam_asset_delete("COURSE-MNEMO-pub", "2011-07-27-14h32"); if ($step_by_step) { exec('read'); } if ($step_by_step) { echo 'adding asset in COURSE-MNEMO-pub again'; } $metadata = array('author' => 'X', 'title' => 'Test d\'accentuation UTF-8: tètètè', 'description' => 'Ceci est un accent: à', 'record_date' => '2011_07_26_16h00', 'record_type' => 'camslide', 'language' => 'français'); ezmam_asset_new("COURSE-MNEMO-pub", "2011-07-27-14h32", $metadata); /*if($step_by_step) exec('read'); if($step_by_step) echo "Unpublishing asst 2011-07-27-14h32"; $res=ezmam_asset_unpublish("COURSE-MNEMO-pub", "2011-07-27-14h32"); if(!$res)