Allow session admins to copy content from one session's course to another session's course, and added flexibility to api_protect_course_script() at the same time - refs #3823

skala
Yannick Warnier 14 years ago
parent 5efbd211f2
commit 70993f066e
  1. 2
      main/coursecopy/copy_course_session.php
  2. 8
      main/inc/lib/main_api.lib.php

@ -18,7 +18,7 @@ $language_file = array('coursebackup', 'admin');
$cidReset = true; $cidReset = true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
$current_course_tool = TOOL_COURSE_MAINTENANCE; $current_course_tool = TOOL_COURSE_MAINTENANCE;
api_protect_course_script(true); api_protect_course_script(true, true);
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php'; require_once api_get_path(LIBRARY_PATH).'xajax/xajax.inc.php';

@ -769,14 +769,15 @@ function api_valid_email($address) {
* *
* This is only the first proposal, test and improve! * This is only the first proposal, test and improve!
* @param boolean Option to print headers when displaying error message. Default: false * @param boolean Option to print headers when displaying error message. Default: false
* @param boolean Whether session admins should be allowed or not.
* @return boolean True if the user has access to the current course or is out of a course context, false otherwise * @return boolean True if the user has access to the current course or is out of a course context, false otherwise
* @todo replace global variable * @todo replace global variable
* @author Roan Embrechts * @author Roan Embrechts
*/ */
function api_protect_course_script($print_headers = false) { function api_protect_course_script($print_headers = false, $allow_session_admins = false) {
global $is_allowed_in_course; global $is_allowed_in_course;
$is_visible = false; $is_visible = false;
if (api_is_platform_admin()) { if (api_is_platform_admin($allow_session_admins)) {
return true; return true;
} }
$course_info = api_get_course_info(); $course_info = api_get_course_info();
@ -2048,6 +2049,7 @@ function api_get_self() {
/** /**
* Checks whether current user is a platform administrator * Checks whether current user is a platform administrator
* @param boolean Whether session admins should be considered admins or not
* @return boolean True if the user has platform admin rights, * @return boolean True if the user has platform admin rights,
* false otherwise. * false otherwise.
* @see usermanager::is_admin(user_id) for a user-id specific function * @see usermanager::is_admin(user_id) for a user-id specific function
@ -5898,4 +5900,4 @@ function api_get_locked_settings() {
'login_is_email', 'login_is_email',
'chamilo_database_version' 'chamilo_database_version'
); );
} }

Loading…
Cancel
Save