Example #1
0
/**
 * Resets the token of a specific album, and tokens of all the assets within
 * @param type $album 
 * @return bool error status
 */
function ezmam_album_token_reset($album)
{
    // Sanity checks
    $repository_path = ezmam_repository_path();
    if ($repository_path == false) {
        ezmam_last_error("Please call ezmam_repository_path() before anything else");
        return false;
    }
    if (!ezmam_album_exists($album)) {
        ezmam_last_error("ezmam_album_token_reset: Album {$album} does not exist");
        return false;
    }
    $old_token = ezmam_album_token_get($album);
    // Resetting the album token
    $res = ezmam_album_token_create($album);
    if (!$res) {
        ezmam_last_error('ezmam_album_token_reset: Unable to change token');
        return false;
    }
    $assets = ezmam_asset_list($album);
    foreach ($assets as $asset) {
        ezmam_asset_token_reset($album, $asset, false);
    }
    // Resetting the RSS feed
    ezmam_rss_generate($album, "high");
    ezmam_rss_generate($album, "low");
    // Logging the operation
    log_append('album_token_reset', 'album ' . $album . ', old token: ' . $old_token . ', new token: ' . $res);
    return true;
}
Example #2
0
/**
 * Updates the 'new assets' count
 * @param type $user the user
 * @param type $album the album to update
 * @return boolean
 */
function user_prefs_token_update_count($user, $album)
{
    // Sanity check
    if (!isset($user) || $user == '') {
        return false;
    }
    if (!ezmam_album_exists($album)) {
        return false;
    }
    // 1) set the repository path
    $user_files_path = user_prefs_repository_path();
    if ($user_files_path === false) {
        return false;
    }
    $index = user_prefs_token_index($user, $album);
    if ($index >= 0) {
        // set user's file path
        $user_path = $user_files_path . '/' . $user;
        $token_list = user_prefs_tokens_get($user);
        // updates the count
        $count = count(ezmam_asset_list($album));
        $token_list[$index]['count'] = $count;
        return assoc_array2xml_file($token_list, $user_path . "/_album_tokens.xml", "album_tokens", "album_token");
    }
    return false;
}
Example #3
0
/**
 * Returns the number of watched assets
 * @param string $album
 * @return int
 */
function acl_watched_count($album)
{
    if (!acl_user_is_logged()) {
        error_print_message('Error: acl_has_album_permissions: You are not logged in');
        return 0;
    }
    $count = 0;
    foreach ($_SESSION['acl_watched_assets'] as $watched) {
        if ($watched['album'] == $album) {
            $album_assets = ezmam_asset_list($album);
            foreach ($watched['assets'] as $asset) {
                if (in_array($asset, $album_assets)) {
                    ++$count;
                }
            }
        }
    }
    return $count;
}