Example #1
0
/**
 * 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);
}
Example #2
0
/**
 * Imports all selected bookmarks to the selected album
 * @global type $input
 * @global type $user_files_path
 * @global type $repository_path
 */
function bookmarks_import()
{
    global $input;
    global $user_files_path;
    global $repository_path;
    $album = $_SESSION['album'];
    $selection = $input['import_selection'];
    $imported_bookmarks = json_decode($input['imported_bookmarks'], true);
    $target = $input['target'];
    $selected_bookmarks = array();
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    // keeps only the selected bookmarks
    foreach ($selection as $index) {
        array_push($selected_bookmarks, $imported_bookmarks[$index]);
    }
    if ($target == 'official') {
        if (acl_has_album_moderation($album)) {
            // authorization check
            toc_album_bookmarks_add($selected_bookmarks);
        }
    } else {
        user_prefs_album_bookmarks_add($_SESSION['user_login'], $selected_bookmarks);
    }
    log_append('import_bookmarks: bookmarks added to the album ' . $album);
    // lvl, action, album, asset, target (in official|personal), number of selected bookmarks, number of uploaded bookmarks
    trace_append(array($input['source'] == 'assets' ? '2' : '3', 'bookmarks_import', $album, $_SESSION['asset'] != '' ? $_SESSION['asset'] : '-', $target, count($selection), count($imported_bookmarks)));
    // determines the page to display
    if ($input['source'] == 'assets') {
        // the token is needed to display the album assets
        $input['token'] = ezmam_album_token_get($album);
        view_album_assets(false);
    } else {
        view_asset_details(false);
    }
}
Example #3
0
/**
 * 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&amp;from=SOURCE&amp;to=DESTINATION&amp;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');
}