Example #1
0
/**
 * Updates the (locally stored) list of consulted albums and moderated albums 
 */
function acl_update_permissions_list()
{
    global $repository_path;
    ezmam_repository_path($repository_path);
    $courses_list_for_author = array();
    $consulted_albums = array();
    if (acl_user_is_logged()) {
        $courses_list_for_author = courses_list($_SESSION['user_login']);
        foreach ($courses_list_for_author as $key => $title) {
            if (!ezmam_album_exists("{$key}-pub")) {
                unset($courses_list_for_author[$key]);
            }
        }
        $album_tokens_list = user_prefs_tokens_get($_SESSION['user_login']);
        foreach ($album_tokens_list as $album_token) {
            $consulted_albums[] = $album_token['album'];
        }
        $_SESSION['acl_album_tokens'] = $album_tokens_list;
    } else {
        // anonymous user : every consulted album is directly stored in $_SESSION['acl_album_tokens']
        // tokens stored during action "view_album_assets" in web_index.php
        foreach ($_SESSION['acl_album_tokens'] as $album_token) {
            $consulted_albums[] = $album_token['album'];
        }
    }
    if (acl_show_notifications()) {
        acl_update_watched_assets();
    }
    $_SESSION['acl_consulted_albums'] = $consulted_albums;
    $_SESSION['acl_moderated_albums'] = $courses_list_for_author;
}
Example #2
0
/**
 * Updates the (locally stored) list of albums created/not created
 */
function acl_update_permissions_list()
{
    // Checking which courses the user can manage, which have been created, which have not
    $courses_list_for_author = courses_list($_SESSION['user_login']);
    $existing_albums = ezmam_album_list();
    // By comparing $courses_list_for_autor and $existing_albums, we're able
    // to infer which album has already been created and which hasn't
    // So we store this information in various arrays
    $albums_created_array = array();
    // Albums already created (name only)
    $albums_created_array_descriptions = array();
    // Album created (name as a key and description as a value)
    $albums_not_created_array = array();
    $albums_not_created_array_descriptions = array();
    // For each course an author can manage, we check whether or not albums exist
    foreach ($courses_list_for_author as $course) {
        $course_infos = explode('|', $course, 2);
        // lib_podcastcours gives us the information as name|description, so we need to change that
        $course_code = $course_infos[0];
        $course_description = $course_infos[1];
        if (in_array($course_code . '-pub', $existing_albums) || in_array($course_code . '-priv', $existing_albums)) {
            $albums_created_array[] = $course_code;
            $albums_created_array_descriptions[$course_code] = $course_description;
        } else {
            $albums_not_created_array[] = $course_code;
            $albums_not_created_array_descriptions[$course_code] = $course_description;
        }
    }
    // Finally, we save the information in session vars
    $_SESSION['acl_created_albums'] = $albums_created_array;
    // Array of all created albums, by album name
    $_SESSION['acl_created_albums_descriptions'] = $albums_created_array_descriptions;
    // Associative array listing all album names (key) and description (value)
    $_SESSION['acl_not_created_albums'] = $albums_not_created_array;
    // Array of all albums the user could create bus has not, by album name
    $_SESSION['acl_not_created_albums_descriptions'] = $albums_not_created_array_descriptions;
    // Associative array listing all album names (key) and description (value)
    $_SESSION['acl_permitted_albums'] = array_merge($albums_created_array, $albums_not_created_array);
    $_SESSION['acl_permitted_albums_descriptions'] = array_merge($albums_created_array_descriptions, $albums_not_created_array_descriptions);
}
    }
    foreach ($visibilities as $visibility) {
        if (!in_array($visibility, array_keys($vis))) {
            return array('error_msg' => 'Security check failed');
        }
        $courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
        foreach ($courses_list_tmp as $index => $course) {
            $course_info = CourseManager::get_course_information($course['code']);
            $courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
        }
    }
    return $courses_list;
}
header('Content-Type: text/xml; charset=utf-8');
echo '<?xml version="1.0"?>';
echo '<courseslist>';
if (empty($_POST['security-key']) || empty($_POST['visibility'])) {
    echo '<errormsg>Invalid parameters, this script expects a security-key and a visibility parameters</errormsg>';
} else {
    $courses_list = courses_list($_POST['security-key'], $_POST['visibility']);
    foreach ($courses_list as $code => $cd) {
        echo '<course>';
        echo '<code>', $code, '</code>';
        echo '<title>', $cd['title'], '</title>';
        echo '<url>', $cd['url'], '</url>';
        echo '<teacher>', $cd['teacher'], '</teacher>';
        echo '<language>', $cd['language'], '</language>';
        echo '</course>';
    }
}
echo '</courseslist>';