|
|
@ -2102,6 +2102,22 @@ function api_is_platform_admin_by_id($user_id = null) { |
|
|
|
return Database::num_rows($res) === 1; |
|
|
|
return Database::num_rows($res) === 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function api_get_user_status($user_id = null) { |
|
|
|
|
|
|
|
$user_id = intval($user_id); |
|
|
|
|
|
|
|
if (empty($user_id)) { |
|
|
|
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_USER); |
|
|
|
|
|
|
|
$sql = "SELECT status FROM $table WHERE user_id = $user_id "; |
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
$status = null; |
|
|
|
|
|
|
|
if (Database::num_rows($result)) { |
|
|
|
|
|
|
|
$row = Database::fetch_array($result); |
|
|
|
|
|
|
|
$status = $row['status']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $status; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Checks whether current user is allowed to create courses |
|
|
|
* Checks whether current user is allowed to create courses |
|
|
|
* @return boolean True if the user has course creation rights, |
|
|
|
* @return boolean True if the user has course creation rights, |
|
|
@ -2153,7 +2169,6 @@ function api_get_user_platform_status($user_id = false) { |
|
|
|
//Group (in course) |
|
|
|
//Group (in course) |
|
|
|
if ($group_id && $course_id) { |
|
|
|
if ($group_id && $course_id) { |
|
|
|
$group_status = array(); |
|
|
|
$group_status = array(); |
|
|
|
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; |
|
|
|
|
|
|
|
$is_subscribed = GroupManager::is_subscribed($user_id, $group_id); |
|
|
|
$is_subscribed = GroupManager::is_subscribed($user_id, $group_id); |
|
|
|
if ($is_subscribed) { |
|
|
|
if ($is_subscribed) { |
|
|
|
$group_status = array('id'=> $group_id , 'status' => 'student'); |
|
|
|
$group_status = array('id'=> $group_id , 'status' => 'student'); |
|
|
@ -5404,10 +5419,11 @@ function api_is_global_platform_admin($user_id = null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function api_global_admin_can_edit_admin($admin_id_to_check, $my_user_id = null) { |
|
|
|
function api_global_admin_can_edit_admin($admin_id_to_check, $my_user_id = null, $allow_session_admin = false) { |
|
|
|
if (empty($my_user_id)) { |
|
|
|
if (empty($my_user_id)) { |
|
|
|
$my_user_id = api_get_user_id(); |
|
|
|
$my_user_id = api_get_user_id(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$iam_a_global_admin = api_is_global_platform_admin($my_user_id); |
|
|
|
$iam_a_global_admin = api_is_global_platform_admin($my_user_id); |
|
|
|
$user_is_global_admin = api_is_global_platform_admin($admin_id_to_check); |
|
|
|
$user_is_global_admin = api_is_global_platform_admin($admin_id_to_check); |
|
|
|
|
|
|
|
|
|
|
@ -5416,7 +5432,13 @@ function api_global_admin_can_edit_admin($admin_id_to_check, $my_user_id = null) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//If i'm a simple admin |
|
|
|
//If i'm a simple admin |
|
|
|
if (api_is_platform_admin_by_id($my_user_id)) { |
|
|
|
$is_platform_admin = api_is_platform_admin_by_id($my_user_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($allow_session_admin) { |
|
|
|
|
|
|
|
$is_platform_admin = api_is_platform_admin_by_id($my_user_id) || (api_get_user_status($my_user_id) == SESSIONADMIN); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($is_platform_admin) { |
|
|
|
if ($user_is_global_admin) { |
|
|
|
if ($user_is_global_admin) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -5428,8 +5450,8 @@ function api_global_admin_can_edit_admin($admin_id_to_check, $my_user_id = null) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function api_protect_super_admin($admin_id_to_check, $my_user_id = null) { |
|
|
|
function api_protect_super_admin($admin_id_to_check, $my_user_id = null, $allow_session_admin = false) { |
|
|
|
if (api_global_admin_can_edit_admin($admin_id_to_check, $my_user_id)) { |
|
|
|
if (api_global_admin_can_edit_admin($admin_id_to_check, $my_user_id, $allow_session_admin)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
api_not_allowed(); |
|
|
|
api_not_allowed(); |
|
|
@ -5497,66 +5519,52 @@ function api_browser_support($format="") { |
|
|
|
if ($format=='svg'){ |
|
|
|
if ($format=='svg'){ |
|
|
|
if (($current_browser == 'Internet Explorer' && $current_majorver >= 9) || ($current_browser == 'Firefox' && $current_majorver > 1) || ($current_browser == 'Safari' && $current_majorver >= 4) || ($current_browser == 'Chrome' && $current_majorver >= 1) || ($current_browser == 'Opera' && $current_majorver >= 9)) { |
|
|
|
if (($current_browser == 'Internet Explorer' && $current_majorver >= 9) || ($current_browser == 'Firefox' && $current_majorver > 1) || ($current_browser == 'Safari' && $current_majorver >= 4) || ($current_browser == 'Chrome' && $current_majorver >= 1) || ($current_browser == 'Opera' && $current_majorver >= 9)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='pdf') { |
|
|
|
elseif($format=='pdf'){ |
|
|
|
|
|
|
|
//native pdf support |
|
|
|
//native pdf support |
|
|
|
if($current_browser == 'Chrome' && $current_majorver >= 6){ |
|
|
|
if($current_browser == 'Chrome' && $current_majorver >= 6){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='tif' || $format=='tiff'){ |
|
|
|
elseif($format=='tif' || $format=='tiff'){ |
|
|
|
|
|
|
|
//native tif support |
|
|
|
//native tif support |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5){ |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='ogg' || $format=='ogx'|| $format=='ogv' || $format=='oga'){ |
|
|
|
elseif($format=='ogg' || $format=='ogx'|| $format=='ogv' || $format=='oga'){ |
|
|
|
|
|
|
|
//native ogg, ogv,oga support |
|
|
|
//native ogg, ogv,oga support |
|
|
|
if (($current_browser == 'Firefox' && $current_majorver >= 3) || ($current_browser == 'Chrome' && $current_majorver >= 3) || ($current_browser == 'Opera' && $current_majorver >= 9)) { |
|
|
|
if (($current_browser == 'Firefox' && $current_majorver >= 3) || ($current_browser == 'Chrome' && $current_majorver >= 3) || ($current_browser == 'Opera' && $current_majorver >= 9)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='mpg' || $format=='mpeg'){ |
|
|
|
elseif($format=='mpg' || $format=='mpeg'){ |
|
|
|
|
|
|
|
//native mpg support |
|
|
|
//native mpg support |
|
|
|
if(($current_browser == 'Safari' && $current_majorver >= 5)){ |
|
|
|
if(($current_browser == 'Safari' && $current_majorver >= 5)){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='mp4') { |
|
|
|
elseif($format=='mp4'){ |
|
|
|
|
|
|
|
//native mp4 support (TODO: Android, iPhone) |
|
|
|
//native mp4 support (TODO: Android, iPhone) |
|
|
|
if($current_browser == 'Android' || $current_browser == 'iPhone') { |
|
|
|
if($current_browser == 'Android' || $current_browser == 'iPhone') { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='mov') { |
|
|
|
elseif($format=='mov'){ |
|
|
|
|
|
|
|
//native mov support( TODO:check iPhone) |
|
|
|
//native mov support( TODO:check iPhone) |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5 || $current_browser == 'iPhone'){ |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5 || $current_browser == 'iPhone'){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='avi') { |
|
|
|
elseif($format=='avi'){ |
|
|
|
|
|
|
|
//native avi support |
|
|
|
//native avi support |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5){ |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -5564,17 +5572,14 @@ function api_browser_support($format="") { |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='wmv') { |
|
|
|
elseif($format=='wmv'){ |
|
|
|
|
|
|
|
//native wmv support |
|
|
|
//native wmv support |
|
|
|
if($current_browser == 'Firefox' && $current_majorver >= 4){ |
|
|
|
if ($current_browser == 'Firefox' && $current_majorver >= 4){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='webm') { |
|
|
|
elseif($format=='webm'){ |
|
|
|
|
|
|
|
//native webm support (TODO:check IE9, Chrome9, Android) |
|
|
|
//native webm support (TODO:check IE9, Chrome9, Android) |
|
|
|
if(($current_browser == 'Firefox' && $current_majorver >= 4) || ($current_browser == 'Opera' && $current_majorver >= 9) || ($current_browser == 'Internet Explorer' && $current_majorver >= 9)|| ($current_browser == 'Chrome' && $current_majorver >=9)|| $current_browser == 'Android'){ |
|
|
|
if(($current_browser == 'Firefox' && $current_majorver >= 4) || ($current_browser == 'Opera' && $current_majorver >= 9) || ($current_browser == 'Internet Explorer' && $current_majorver >= 9)|| ($current_browser == 'Chrome' && $current_majorver >=9)|| $current_browser == 'Android'){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -5582,26 +5587,22 @@ function api_browser_support($format="") { |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='wav') { |
|
|
|
elseif($format=='wav'){ |
|
|
|
|
|
|
|
//native wav support (only some codecs !) |
|
|
|
//native wav support (only some codecs !) |
|
|
|
if(($current_browser == 'Firefox' && $current_majorver >= 4) || ($current_browser == 'Safari' && $current_majorver >= 5) || ($current_browser == 'Opera' && $current_majorver >= 9) || ($current_browser == 'Internet Explorer' && $current_majorver >= 9)|| ($current_browser == 'Chrome' && $current_majorver > 9)|| $current_browser == 'Android' || $current_browser == 'iPhone'){ |
|
|
|
if (($current_browser == 'Firefox' && $current_majorver >= 4) || ($current_browser == 'Safari' && $current_majorver >= 5) || ($current_browser == 'Opera' && $current_majorver >= 9) || ($current_browser == 'Internet Explorer' && $current_majorver >= 9)|| ($current_browser == 'Chrome' && $current_majorver > 9)|| $current_browser == 'Android' || $current_browser == 'iPhone'){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='mid' || $format=='kar') { |
|
|
|
elseif($format=='mid' || $format=='kar'){ |
|
|
|
|
|
|
|
//native midi support (TODO:check Android) |
|
|
|
//native midi support (TODO:check Android) |
|
|
|
if($current_browser == 'Opera'&& $current_majorver >= 9 || $current_browser == 'Android'){ |
|
|
|
if($current_browser == 'Opera'&& $current_majorver >= 9 || $current_browser == 'Android'){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='wma') { |
|
|
|
elseif($format=='wma'){ |
|
|
|
|
|
|
|
//native wma support |
|
|
|
//native wma support |
|
|
|
if($current_browser == 'Firefox' && $current_majorver >= 4){ |
|
|
|
if($current_browser == 'Firefox' && $current_majorver >= 4){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -5609,8 +5610,7 @@ function api_browser_support($format="") { |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='au') { |
|
|
|
elseif($format=='au'){ |
|
|
|
|
|
|
|
//native au support |
|
|
|
//native au support |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5){ |
|
|
|
if($current_browser == 'Safari' && $current_majorver >= 5){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -5618,21 +5618,17 @@ function api_browser_support($format="") { |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=='mp3') { |
|
|
|
elseif($format=='mp3'){ |
|
|
|
|
|
|
|
//native mp3 support (TODO:check Android, iPhone) |
|
|
|
//native mp3 support (TODO:check Android, iPhone) |
|
|
|
if(($current_browser == 'Safari' && $current_majorver >= 5) || ($current_browser == 'Chrome' && $current_majorver >=6)|| ($current_browser == 'Internet Explorer' && $current_majorver >= 9)|| $current_browser == 'Android' || $current_browser == 'iPhone'){ |
|
|
|
if(($current_browser == 'Safari' && $current_majorver >= 5) || ($current_browser == 'Chrome' && $current_majorver >=6)|| ($current_browser == 'Internet Explorer' && $current_majorver >= 9)|| $current_browser == 'Android' || $current_browser == 'iPhone'){ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif($format=="check_browser") { |
|
|
|
elseif($format=="check_browser"){ |
|
|
|
|
|
|
|
$array_check_browser=array($current_browser, $current_majorver); |
|
|
|
$array_check_browser=array($current_browser, $current_majorver); |
|
|
|
return $array_check_browser; |
|
|
|
return $array_check_browser; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|