本文整理汇总了PHP中Chamilo\CoreBundle\Framework\Container::getAuthorizationChecker方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getAuthorizationChecker方法的具体用法?PHP Container::getAuthorizationChecker怎么用?PHP Container::getAuthorizationChecker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chamilo\CoreBundle\Framework\Container
的用法示例。
在下文中一共展示了Container::getAuthorizationChecker方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_is_platform_admin
/**
* Checks whether current user is a platform administrator
* @param boolean Whether session admins should be considered admins or not
* @param boolean Whether HR directors should be considered admins or not
* @return boolean True if the user has platform admin rights,
* false otherwise.
* @see usermanager::is_admin(user_id) for a user-id specific function
*/
function api_is_platform_admin($allow_sessions_admins = false, $allow_drh = false)
{
$checker = Container::getAuthorizationChecker();
if ($checker) {
if ($checker->isGranted('ROLE_ADMIN')) {
return true;
}
if ($allow_sessions_admins) {
if ($checker->isGranted('ROLE_SESSION_MANAGER')) {
return true;
}
}
}
return false;
$isPlatformAdmin = Session::read('is_platformAdmin');
if ($isPlatformAdmin) {
return true;
}
$_user = api_get_user_info();
return isset($_user['status']) && ($allow_sessions_admins && $_user['status'] == SESSIONADMIN || $allow_drh && $_user['status'] == DRH);
}
示例2: save_item
//.........这里部分代码省略.........
if ($debug > 1) {
error_log("Time is INT");
}
$real_time = time() - $time;
if ($debug > 1) {
error_log('Calling $real_time ' . $real_time . ' ', 0);
}
$myLPI->set_time($real_time, 'int');
} else {
if ($debug > 1) {
error_log("Time is in SCORM format");
}
if ($debug > 1) {
error_log('Calling $time ' . $time . ' ', 0);
}
$myLPI->set_time($time, 'scorm');
}
}
if (isset($suspend) && $suspend != '' && $suspend != 'undefined') {
$myLPI->current_data = $suspend;
}
if (isset($location) && $location != '' && $location != 'undefined') {
$myLPI->set_lesson_location($location);
}
// Deal with interactions provided in arrays in the following format:
// id(0), type(1), time(2), weighting(3), correct_responses(4), student_response(5), result(6), latency(7)
if (is_array($interactions) && count($interactions) > 0) {
foreach ($interactions as $index => $interaction) {
//$mylpi->add_interaction($index,$interactions[$index]);
//fix DT#4444
$clean_interaction = str_replace('@.|@', ',', $interactions[$index]);
$myLPI->add_interaction($index, $clean_interaction);
}
}
if ($core_exit != 'undefined') {
$myLPI->set_core_exit($core_exit);
}
$myLP->save_item($item_id, false);
}
$myStatusInDB = $myLPI->get_status(true);
if ($debug) {
error_log("Status in DB: {$myStatusInDB}");
}
if ($myStatusInDB != 'completed' && $myStatusInDB != 'passed' && $myStatusInDB != 'browsed' && $myStatusInDB != 'failed') {
$myStatusInMemory = $myLPI->get_status(false);
if ($myStatusInMemory != $myStatusInDB) {
$myStatus = $myStatusInMemory;
} else {
$myStatus = $myStatusInDB;
}
} else {
$myStatus = $myStatusInDB;
}
$myTotal = $myLP->get_total_items_count_without_chapters();
$myComplete = $myLP->get_complete_items_count();
$myProgressMode = $myLP->get_progress_bar_mode();
$myProgressMode = $myProgressMode == '' ? '%' : $myProgressMode;
if ($debug > 1) {
error_log("mystatus: {$myStatus}", 0);
error_log("myprogress_mode: {$myProgressMode}", 0);
error_log("progress: {$myComplete} / {$myTotal}", 0);
}
if ($myLPI->get_type() != 'sco') {
// If this object's JS status has not been updated by the SCORM API, update now.
$return .= "olms.lesson_status='" . $myStatus . "';";
}
$return .= "update_toc('" . $myStatus . "','" . $item_id . "');";
$update_list = $myLP->get_update_queue();
foreach ($update_list as $my_upd_id => $my_upd_status) {
if ($my_upd_id != $item_id) {
/* Only update the status from other items (i.e. parents and brothers),
do not update current as we just did it already. */
$return .= "update_toc('" . $my_upd_status . "','" . $my_upd_id . "');";
}
}
$return .= "update_progress_bar('{$myComplete}', '{$myTotal}', '{$myProgressMode}');";
$isLoginAs = Container::getAuthorizationChecker()->isGranted('ROLE_PREVIOUS_ADMIN');
if (!$isLoginAs) {
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = "SELECT login_id, login_date\n FROM {$tbl_track_login}\n WHERE login_user_id= " . api_get_user_id() . "\n ORDER BY login_date DESC\n LIMIT 0,1";
$q_last_connection = Database::query($sql);
if (Database::num_rows($q_last_connection) > 0) {
$current_time = api_get_utc_datetime();
$row = Database::fetch_array($q_last_connection);
$i_id_last_connection = $row['login_id'];
$sql = "UPDATE {$tbl_track_login}\n SET logout_date='" . $current_time . "'\n WHERE login_id = {$i_id_last_connection}";
Database::query($sql);
}
}
if ($myLP->get_type() == 2) {
$return .= "update_stats();";
}
// To be sure progress is updated.
$myLP->save_last();
Session::write('lpobject', serialize($myLP));
if ($debug > 0) {
error_log('---------------- lp_ajax_save_item.php : save_item end ----- ');
}
return $return;
}