/**
	 * Constructor
	 */
    public function __construct($user_id)
    {
    	$this->path = 'block_evaluation_graph';
    	$this->user_id 	= $user_id;
    	$this->bg_width = 450;
    	$this->bg_height = 350;
    	if ($this->is_block_visible_for_user($user_id)) {
            if (!api_is_session_admin()) {
                $this->courses  = CourseManager::get_courses_followed_by_drh($user_id);
            }
            $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
    	}
    }
 public static function redirect()
 {
     global $param;
     $param = isset($param) ? $param : '';
     $redirect_url = '';
     /*
      //If session request url is setted, we go there
      if (!empty($_SESSION['request_uri'])) {
      $req = $_SESSION['request_uri'];
      unset($_SESSION['request_uri']);
      header('location: '.$req);
      exit();
      }
     */
     if (api_is_student() && !api_get_setting('student_page_after_login') == '') {
         $redirect_url = html_entity_decode(api_get_setting('student_page_after_login'));
         if ($redirect_url[0] == "/") {
             $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
         }
     }
     if (api_is_teacher() && !api_get_setting('teacher_page_after_login') == '') {
         $redirect_url = html_entity_decode(api_get_setting('teacher_page_after_login'));
         if ($redirect_url[0] == "/") {
             $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
         }
     }
     if (api_is_drh() && !api_get_setting('drh_page_after_login') == '') {
         $redirect_url = html_entity_decode(api_get_setting('drh_page_after_login'));
         if ($redirect_url[0] == "/") {
             $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
         }
     }
     if (api_is_session_admin() && !api_get_setting('sessionadmin_page_after_login') == '') {
         $redirect_url = html_entity_decode(api_get_setting('sessionadmin_page_after_login'));
         if ($redirect_url[0] == "/") {
             $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
         }
     }
     if (!empty($redirect_url)) {
         header('Location: ' . $redirect_url . $param);
         exit;
     }
     // Custom pages
     if (CustomPages::enabled()) {
         CustomPages::display(CustomPages::INDEX_LOGGED);
     }
     header('location: ' . api_get_path(WEB_PATH) . api_get_setting('page_after_login') . $param);
     exit;
 }
示例#3
0
/**
 * Get course data to display
 * @param int $from
 * @param int $number_of_items
 * @param int $column
 * @param string $direction
 *
 * @return array
 */
function get_course_data($from, $number_of_items, $column, $direction)
{
    $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
    $sql = "SELECT  code AS col0,\n                    title AS col1,\n                    code AS col2,\n                    course_language AS col3,\n                    category_code AS col4,\n                    subscribe AS col5,\n                    unsubscribe AS col6,\n                    code AS col7,\n                    visibility AS col8,\n                    directory as col9,\n                    visual_code\n    \t\tFROM {$course_table}";
    if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
        $access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
        $sql .= " INNER JOIN {$access_url_rel_course_table} url_rel_course ON (id = url_rel_course.c_id)";
    }
    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string("%" . trim($_GET['keyword']) . "%");
        $sql .= " WHERE (\n            title LIKE '" . $keyword . "' OR\n            code LIKE '" . $keyword . "' OR\n            visual_code LIKE '" . $keyword . "'\n        )\n        ";
    } elseif (isset($_GET['keyword_code'])) {
        $keyword_code = Database::escape_string("%" . $_GET['keyword_code'] . "%");
        $keyword_title = Database::escape_string("%" . $_GET['keyword_title'] . "%");
        $keyword_category = Database::escape_string("%" . $_GET['keyword_category'] . "%");
        $keyword_language = Database::escape_string("%" . $_GET['keyword_language'] . "%");
        $keyword_visibility = Database::escape_string("%" . $_GET['keyword_visibility'] . "%");
        $keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
        $keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
        $sql .= " WHERE\n                (code LIKE '" . $keyword_code . "' OR visual_code LIKE '" . $keyword_code . "') AND\n                title LIKE '" . $keyword_title . "' AND\n                category_code LIKE '" . $keyword_category . "' AND\n                course_language LIKE '" . $keyword_language . "' AND\n                visibility LIKE '" . $keyword_visibility . "' AND\n                subscribe LIKE '" . $keyword_subscribe . "' AND\n                unsubscribe LIKE '" . $keyword_unsubscribe . "'";
    }
    // Adding the filter to see the user's only of the current access_url.
    if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) {
        $sql .= " AND url_rel_course.access_url_id=" . api_get_current_access_url_id();
    }
    $sql .= " ORDER BY col{$column} {$direction} ";
    $sql .= " LIMIT {$from}, {$number_of_items}";
    $res = Database::query($sql);
    $courses = array();
    $languages = api_get_languages_to_array();
    while ($course = Database::fetch_array($res)) {
        // Place colour icons in front of courses.
        $show_visual_code = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
        $course[1] = get_course_visibility_icon($course[8]) . '<a href="' . api_get_path(WEB_COURSE_PATH) . $course[9] . '/index.php">' . $course[1] . '</a> ' . $show_visual_code;
        $course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
        $course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
        $language = isset($languages[$course[3]]) ? $languages[$course[3]] : $course[3];
        $course_rem = array($course[0], $course[1], $course[2], $language, $course[4], $course[5], $course[6], $course[7]);
        $courses[] = $course_rem;
    }
    return $courses;
}
示例#4
0
 /**
  * Add a "Videocast" entry to the main menu under conditions
  *
  * @param string $content
  *
  * @return string|false String if the content has been altered, FALSE otherwise
  */
 protected function injectMainMenuEntry($content)
 {
     global $this_section;
     // The user must be authenticated
     if (!api_get_user_id()) {
         return false;
     }
     // The user must be able to create courses to access its briefcase
     if (!api_is_allowed_to_create_course() and !api_is_session_admin()) {
         return false;
     }
     return preg_replace('/(<ul id="dokeostabs">.+)<\\/ul>/m', sprintf('${1}<a href="%s" target="_top"><li class="tab_libcast%s"><div><span>Videocast</span></div></li></a></ul>', $this->getHomeUrl() . '/briefcase.php', $this_section == 'libcast' ? '_current' : ''), $content);
 }
示例#5
0
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);

if ($from == 'myspace') {
    $from_myspace = true;
    $this_section = "session_my_space";
} else {
    $this_section = SECTION_COURSES;
}

// Access restrictions.
$is_allowedToTrack =
    api_is_platform_admin() ||
    api_is_allowed_to_create_course() ||
    api_is_session_admin() ||
    api_is_drh() ||
    api_is_course_tutor() ||
    api_is_course_admin();

if (!$is_allowedToTrack) {
    api_not_allowed(true);
    exit;
}

// If the user is a HR director (drh)
if (api_is_drh()) {
    // Blocking course for drh
    if (api_drh_can_access_all_session_content()) {
        // If the drh has been configured to be allowed to see all session content, give him access to the session courses
        $coursesFromSession = SessionManager::getAllCoursesFollowedByUser(api_get_user_id(), null);
$current_user_id = api_get_user_id();
// setting the name of the tool
if (UserManager::is_admin($user_id)) {
    $tool_name = get_lang('AssignSessionsToPlatformAdministrator');
} else {
    if ($user_info['status'] == SESSIONADMIN) {
        $tool_name = get_lang('AssignSessionsToSessionsAdministrator');
    } else {
        $tool_name = get_lang('AssignSessionsToHumanResourcesManager');
    }
}
$add_type = 'multiple';
if (isset($_GET['add_type']) && $_GET['add_type'] != '') {
    $add_type = Security::remove_XSS($_REQUEST['add_type']);
}
if (!api_is_platform_admin() && !api_is_session_admin()) {
    api_not_allowed(true);
}
function search_sessions($needle, $type)
{
    global $_configuration, $tbl_session_rel_access_url, $tbl_session, $user_id;
    $xajax_response = new XajaxResponse();
    $return = '';
    if (!empty($needle) && !empty($type)) {
        // xajax send utf8 datas... datas in db can be non-utf8 datas
        $charset = api_get_system_encoding();
        $needle = api_convert_encoding($needle, $charset, 'utf-8');
        $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id);
        $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
        $without_assigned_sessions = '';
        if (count($assigned_sessions_id) > 0) {
示例#7
0
 /**
  * @param int $questionId
  * @param int $in_display_category_name
  * @return null|string
  */
 public static function returnCategoryAndTitle($questionId, $in_display_category_name = 1)
 {
     $is_student = !(api_is_allowed_to_edit(null, true) || api_is_session_admin());
     $objExercise = Session::read('objExercise');
     if (!empty($objExercise)) {
         $in_display_category_name = $objExercise->display_category_name;
     }
     $content = null;
     if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) {
         $content .= '<div class="page-header">';
         $content .= '<h4>' . get_lang('Category') . ": " . TestCategory::getCategoryNameForQuestion($questionId) . '</h4>';
         $content .= "</div>";
     }
     return $content;
 }
示例#8
0
/**
 * Get the total number of users on the platform
 * @return int  The number of users
 * @see SortableTable#get_total_number_of_items()
 */
function get_number_of_users()
{
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM {$user_table} u";
    if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) {
        $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
        $sql .= " INNER JOIN {$access_url_rel_user_table} url_rel_user ON (u.user_id=url_rel_user.user_id)";
    }
    if (isset($_GET['keyword'])) {
        $keyword = Database::escape_string(trim($_GET['keyword']));
        $sql .= " WHERE (u.firstname LIKE '%{$keyword}%' OR\n                  u.lastname LIKE '%{$keyword}%'  OR\n                  concat(u.firstname,' ',u.lastname) LIKE '%{$keyword}%'  OR\n                  concat(u.lastname,' ',u.firstname) LIKE '%{$keyword}%' OR\n                  u.username LIKE '%{$keyword}%' OR\n                  u.email LIKE '%{$keyword}%'  OR\n                  u.official_code LIKE '%{$keyword}%') ";
    }
    $res = Database::query($sql);
    $obj = Database::fetch_object($res);
    return $obj->total_number_of_items;
}
示例#9
0
/**
 * Build the modify-column of the table
 * @param   int     The user id
 * @param   string  URL params to add to table links
 * @param   array   Row of elements to alter
 * @return string Some HTML-code with modify-buttons
 */
function modify_filter($user_id, $url_params, $row)
{
    global $charset, $_admins_list;
    $is_admin = in_array($user_id, $_admins_list);
    $statusname = api_get_status_langvars();
    $user_is_anonymous = false;
    $current_user_status_label = $row['7'];
    if ($current_user_status_label == $statusname[ANONYMOUS]) {
        $user_is_anonymous = true;
    }
    $result = '';
    if (!$user_is_anonymous) {
        $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_' . $user_id . '\')'));
        $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" >
			        ' . $icon . '
					<div class="blackboard_hide" id="div_' . $user_id . '">&nbsp;&nbsp;</div>
					</a>';
        $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_' . $user_id . '\')'));
        $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_' . $user_id . '\',' . $user_id . ')" >
					' . $icon . '
					<div class="blackboard_hide" id="div_s_' . $user_id . '">&nbsp;&nbsp;</div>
					</a>';
    } else {
        $result .= Display::return_icon('course_na.png', get_lang('Courses')) . '&nbsp;&nbsp;';
        $result .= Display::return_icon('course_na.png', get_lang('Sessions')) . '&nbsp;&nbsp;';
    }
    if (api_is_platform_admin()) {
        if (!$user_is_anonymous) {
            $result .= '<a href="user_information.php?user_id=' . $user_id . '">' . Display::return_icon('synthese_view.gif', get_lang('Info')) . '</a>&nbsp;&nbsp;';
        } else {
            $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')) . '&nbsp;&nbsp;';
        }
    }
    //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
    if (api_is_platform_admin() || api_is_session_admin() && $current_user_status_label == $statusname[STUDENT]) {
        if (!$user_is_anonymous) {
            if (api_global_admin_can_edit_admin($user_id)) {
                $result .= '<a href="user_list.php?action=login_as&user_id=' . $user_id . '&sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('login_as.png', get_lang('LoginAs')) . '</a>&nbsp;&nbsp;';
            } else {
                $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . '&nbsp;&nbsp;';
            }
        } else {
            $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . '&nbsp;&nbsp;';
        }
    } else {
        $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . '&nbsp;&nbsp;';
    }
    if ($current_user_status_label != $statusname[STUDENT]) {
        $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')) . '&nbsp;&nbsp;';
    } else {
        $result .= '<a href="../mySpace/myStudents.php?student=' . $user_id . '">' . Display::return_icon('statistics.gif', get_lang('Reporting')) . '</a>&nbsp;&nbsp;';
    }
    if (api_is_platform_admin(true)) {
        $editProfileUrl = Display::getProfileEditionLink($user_id, true);
        if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) {
            $result .= '<a href="' . $editProfileUrl . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
        } else {
            $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
        }
    }
    if ($is_admin) {
        $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'), array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL));
    } else {
        $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
    }
    // actions for assigning sessions, courses or users
    if (api_is_session_admin()) {
        /*if ($row[0] == api_get_user_id()) {
        			$result .= '<a href="dashboard_add_sessions_to_user.php?user='******'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
        		}*/
    } else {
        if ($current_user_status_label == $statusname[SESSIONADMIN]) {
            $result .= Display::url(Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), "dashboard_add_sessions_to_user.php?user={$user_id}");
        } else {
            if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id) || $current_user_status_label == $statusname[STUDENT_BOSS]) {
                $result .= Display::url(Display::return_icon('user_subscribe_course.png', get_lang('AssignUsers'), '', ICON_SIZE_SMALL), "dashboard_add_users_to_user.php?user={$user_id}");
            }
            if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id)) {
                $result .= Display::url(Display::return_icon('course_add.gif', get_lang('AssignCourses')), "dashboard_add_courses_to_user.php?user={$user_id}");
                $result .= Display::url(Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), "dashboard_add_sessions_to_user.php?user={$user_id}");
            }
        }
    }
    if (api_is_platform_admin()) {
        $result .= ' <a href="' . api_get_path(WEB_AJAX_PATH) . 'agenda.ajax.php?a=get_user_agenda&user_id=' . $user_id . '&modal_size=lg" class="agenda_opener ajax">' . Display::return_icon('month.png', get_lang('FreeBusyCalendar'), array(), ICON_SIZE_SMALL) . '</a>';
        $deleteAllowed = !api_get_configuration_value('deny_delete_users');
        if ($deleteAllowed) {
            if ($user_id != api_get_user_id() && !$user_is_anonymous && api_global_admin_can_edit_admin($user_id)) {
                // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
                $result .= ' <a href="user_list.php?action=delete_user&user_id=' . $user_id . '&' . $url_params . '&sec_token=' . $_SESSION['sec_token'] . '"  onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
            } else {
                $result .= Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL);
            }
        }
    }
    return $result;
}
$formSent = 0;
$errorMsg = '';
// Database Table Definitions
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$tool_name = get_lang('EditSessionCategory');
$interbreadcrumb[] = array('url' => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => "session_category_list.php", "name" => get_lang('ListSessionCategory'));
$sql = "SELECT * FROM {$tbl_session_category} WHERE id='" . $id . "' ORDER BY name";
$result = Database::query($sql);
if (!($infos = Database::fetch_array($result))) {
    header('Location: session_list.php');
    exit;
}
list($year_start, $month_start, $day_start) = explode('-', $infos['date_start']);
list($year_end, $month_end, $day_end) = explode('-', $infos['date_end']);
if (!api_is_platform_admin() && $infos['session_admin_id'] != $_user['user_id'] && !api_is_session_admin()) {
    api_not_allowed(true);
}
if (isset($_POST['formSent']) && $_POST['formSent']) {
    $formSent = 1;
    $name = $_POST['name'];
    $year_start = $_POST['year_start'];
    $month_start = $_POST['month_start'];
    $day_start = $_POST['day_start'];
    $year_end = $_POST['year_end'];
    $month_end = $_POST['month_end'];
    $day_end = $_POST['day_end'];
    $return = SessionManager::edit_category_session($id, $name, $year_start, $month_start, $day_start, $year_end, $month_end, $day_end);
    if ($return == strval(intval($return))) {
        Display::addFlash(Display::return_message(get_lang('SessionCategoryUpdate')));
        header('Location: session_category_list.php');
示例#11
0
	</script>
';
}
$controller = new IndexManager(get_lang('MyCourses'));
// Main courses and session list
//$courseAndSessions = $controller->returnCoursesAndSessions($userId);
// Main courses and session list
if (isset($_COOKIE['defaultMyCourseView' . $userId]) && $_COOKIE['defaultMyCourseView' . $userId] == IndexManager::VIEW_BY_SESSION && $displayMyCourseViewBySessionLink) {
    $courseAndSessions = $controller->returnCoursesAndSessionsViewBySession($userId);
    IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_SESSION, $userId);
} else {
    $courseAndSessions = $controller->returnCoursesAndSessions($userId);
    IndexManager::setDefaultMyCourseView(IndexManager::VIEW_BY_DEFAULT, $userId);
}
// if teacher, session coach or admin, display the button to change te course view
if ($displayMyCourseViewBySessionLink && (api_is_drh() || api_is_course_coach() || api_is_platform_admin() || api_is_session_admin() || api_is_teacher())) {
    $courseAndSessions['html'] = "<div class='view-by-session-link'>\n\t\t<div class='btn-group pull-right'>\n\t\t<a class='btn btn-default' id='viewByDefault' href='user_portal.php' onclick='changeMyCoursesView(\"" . IndexManager::VIEW_BY_DEFAULT . "\")'>\n\t\t" . get_lang('MyCoursesDefaultView') . "\n\t\t</a>\n\t\t<a class='btn btn-default' id='viewBySession' href='user_portal.php' onclick='changeMyCoursesView(\"" . IndexManager::VIEW_BY_SESSION . "\")'>\n\t\t" . get_lang('MyCoursesSessionView') . "\n\t\t</a>\n\t\t</div>\n\t</div><br /><br />\n\t" . $courseAndSessions['html'];
}
// Check if a user is enrolled only in one course for going directly to the course after the login.
if (api_get_setting('go_to_course_after_login') == 'true') {
    $count_of_sessions = $courseAndSessions['session_count'];
    $count_of_courses_no_sessions = $courseAndSessions['course_count'];
    // User is subscribe in 1 session and 0 courses.
    if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) {
        $sessions = SessionManager::get_sessions_by_user($userId);
        if (isset($sessions[0])) {
            $sessionInfo = $sessions[0];
            // Session only has 1 course.
            if (isset($sessionInfo['courses']) && count($sessionInfo['courses']) == 1) {
                $courseCode = $sessionInfo['courses'][0]['code'];
                $courseInfo = api_get_course_info_by_id($sessionInfo['courses'][0]['real_id']);
 *
 * @author Christian Fasanando <*****@*****.**>
 * @author Julio Montoya <*****@*****.**> Lots of bug fixes/improvements
 * @package chamilo.backup
 */
$cidReset = true;
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_COURSE_MAINTENANCE;
api_protect_global_admin_script();
api_protect_limit_for_session_admin();
require_once 'classes/CourseBuilder.class.php';
require_once 'classes/CourseRestorer.class.php';
require_once 'classes/CourseSelectForm.class.php';
$xajax = new xajax();
$xajax->registerFunction('search_courses');
if (!api_is_allowed_to_edit() && !api_is_session_admin()) {
    api_not_allowed(true);
}
// Remove memory and time limits as much as possible as this might be a long process...
if (function_exists('ini_set')) {
    api_set_memory_limit('256M');
    ini_set('max_execution_time', 1800);
}
$this_section = SECTION_PLATFORM_ADMIN;
$nameTools = get_lang('CopyCourse');
$interbreadcrumb[] = array('url' => '../admin/index.php', 'name' => get_lang('PlatformAdmin'));
// Database Table Definitions
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
示例#13
0
/**
 * Build the modify-column of the table
 * @param   int     The user id
 * @param   string  URL params to add to table links
 * @param   array   Row of elements to alter
 * @return string Some HTML-code with modify-buttons
 */
function modify_filter($user_id, $url_params, $row)
{
    global $_admins_list, $delete_user_available, $app;
    $is_admin = false;
    $userId = api_get_user_id();
    if (is_array($_admins_list)) {
        $is_admin = in_array($user_id, $_admins_list);
    }
    $statusname = api_get_status_langvars();
    $user_is_anonymous = false;
    $current_user_status_label = $row['7'];
    if ($current_user_status_label == $statusname[ANONYMOUS]) {
        $user_is_anonymous = true;
    }
    $result = '';
    if (!$user_is_anonymous) {
        $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_' . $user_id . '\')'));
        $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" >
			        ' . $icon . '
					<div class="blackboard_hide" id="div_' . $user_id . '">&nbsp;&nbsp;</div>
					</a>';
        $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_' . $user_id . '\')'));
        $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_' . $user_id . '\',' . $user_id . ')" >
					' . $icon . '
					<div class="blackboard_hide" id="div_s_' . $user_id . '">&nbsp;&nbsp;</div>
					</a>';
    } else {
        $result .= Display::return_icon('course_na.png', get_lang('Courses')) . '&nbsp;&nbsp;';
        $result .= Display::return_icon('course_na.png', get_lang('Sessions')) . '&nbsp;&nbsp;';
    }
    if (api_is_platform_admin()) {
        if (!$user_is_anonymous) {
            $result .= '<a href="user_information.php?user_id=' . $user_id . '">' . Display::return_icon('synthese_view.gif', get_lang('Info')) . '</a>&nbsp;&nbsp;';
        } else {
            $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')) . '&nbsp;&nbsp;';
        }
    }
    //only allow platform admins to login_as, or session admins only for
    // students (not teachers nor other admins), and only if all options
    // match to say this user has the permission to do so
    // $_configuration['login_as_forbidden_globally'], defined in
    // configuration.php, is the master key to these conditions
    global $_configuration;
    if (empty($_configuration['login_as_forbidden_globally']) && (api_is_global_platform_admin() || api_get_setting('login_as_allowed') === 'true' && (api_is_platform_admin() || api_is_session_admin() && $current_user_status_label == $statusname[STUDENT]))) {
        if (!$user_is_anonymous) {
            if ($app['security']->isGranted('ROLE_GLOBAL_ADMIN')) {
                // everything looks good, show "login as" link
                if ($user_id != $userId) {
                    $result .= '<a href="' . api_get_path(WEB_PUBLIC_PATH) . '?_switch_user='******'">' . Display::return_icon('login_as.gif', get_lang('LoginAs')) . '</a>&nbsp;&nbsp;';
                } else {
                    $result .= Display::return_icon('login_as_na.gif', get_lang('LoginAs')) . '&nbsp;&nbsp;';
                }
            } else {
                // if this user in particular can't be edited, show disabled
                $result .= Display::return_icon('login_as_na.gif', get_lang('LoginAs')) . '&nbsp;&nbsp;';
            }
        } else {
            // if anonymous user but other users show the option, show disabled
            $result .= Display::return_icon('login_as_na.gif', get_lang('LoginAs')) . '&nbsp;&nbsp;';
        }
    }
    // Else don't show anything, because the option is not available at all
    //$result .= Display::url('<i class="icon-key icon-large"></i>', 'roles');
    if ($current_user_status_label != $statusname[STUDENT]) {
        $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')) . '&nbsp;&nbsp;';
    } else {
        $result .= '<a href="../mySpace/myStudents.php?student=' . $user_id . '">' . Display::return_icon('statistics.gif', get_lang('Reporting')) . '</a>&nbsp;&nbsp;';
    }
    if (api_is_platform_admin(true)) {
        if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) {
            $result .= '<a href="user_edit.php?user_id=' . $user_id . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
        } else {
            $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>&nbsp;';
        }
    }
    if ($is_admin) {
        $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'), array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL));
    } else {
        $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
    }
    // actions for assigning sessions, courses or users
    if (api_is_session_admin()) {
        /*if ($row[0] == api_get_user_id()) {
        			$result .= '<a href="dashboard_add_sessions_to_user.php?user='******'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
        		}*/
    } else {
        if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id)) {
            $result .= '<a href="dashboard_add_users_to_user.php?user='******'">' . Display::return_icon('user_subscribe_course.png', get_lang('AssignUsers'), '', ICON_SIZE_SMALL) . '</a>';
            $result .= '<a href="dashboard_add_courses_to_user.php?user='******'">' . Display::return_icon('course_add.gif', get_lang('AssignCourses')) . '</a>&nbsp;&nbsp;';
            $result .= '<a href="dashboard_add_sessions_to_user.php?user='******'">' . Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')) . '</a>&nbsp;&nbsp;';
        } else {
            if ($current_user_status_label == $statusname[SESSIONADMIN]) {
                $result .= '<a href="dashboard_add_sessions_to_user.php?user='******'">' . Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')) . '</a>&nbsp;&nbsp;';
            }
        }
    }
    if (api_is_platform_admin()) {
        $result .= ' <a href="' . api_get_path(WEB_AJAX_PATH) . 'agenda.ajax.php?a=get_user_agenda&amp;user_id=' . $user_id . '" class="agenda_opener">' . Display::return_icon('month.png', get_lang('FreeBusyCalendar'), array(), ICON_SIZE_SMALL) . '</a>';
        if ($delete_user_available) {
            if ($user_id != api_get_user_id() && !$user_is_anonymous && api_global_admin_can_edit_admin($user_id)) {
                // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
                $result .= ' <a href="user_list.php?action=delete_user&amp;user_id=' . $user_id . '&amp;' . $url_params . '&amp;sec_token=' . Security::getCurrentToken() . '"  onclick="javascript:if(!confirm(' . "'" . addslashes(get_lang("ConfirmYourChoice")) . "'" . ')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
            } else {
                $result .= Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL);
            }
        }
    }
    return $result;
}
示例#14
0
function return_navigation_array()
{
    $navigation = array();
    $menu_navigation = array();
    $possible_tabs = get_tabs();
    // Campus Homepage
    if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
        $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
    } else {
        $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
    }
    if (api_get_user_id() && !api_is_anonymous()) {
        // My Courses
        if (api_get_setting('show_tabs', 'my_courses') == 'true') {
            $navigation['mycourses'] = $possible_tabs['mycourses'];
        } else {
            $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
        }
        // My Profile
        if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
            $navigation['myprofile'] = $possible_tabs['myprofile'];
        } else {
            $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
        }
        // My Agenda
        if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
            $navigation['myagenda'] = $possible_tabs['myagenda'];
        } else {
            $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
        }
        // Gradebook
        if (api_get_setting('gradebook_enable') == 'true') {
            if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
                $navigation['mygradebook'] = $possible_tabs['mygradebook'];
            } else {
                $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
            }
        }
        // Reporting
        if (api_get_setting('show_tabs', 'reporting') == 'true') {
            if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
                $navigation['session_my_space'] = $possible_tabs['session_my_space'];
            } else {
                $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
            }
        } else {
            if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
                $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
            } else {
                $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
            }
        }
        // Social Networking
        if (api_get_setting('show_tabs', 'social') == 'true') {
            if (api_get_setting('allow_social_tool') == 'true') {
                $navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
            }
        } else {
            $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
        }
        // Dashboard
        if (api_get_setting('show_tabs', 'dashboard') == 'true') {
            if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
                $navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
            }
        } else {
            $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
        }
        // Administration
        if (api_is_platform_admin(true)) {
            if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
                $navigation['platform_admin'] = $possible_tabs['platform_admin'];
            } else {
                $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
            }
        }
        // Reports
        if (!empty($possible_tabs['reports'])) {
            if (api_get_setting('show_tabs', 'reports') == 'true') {
                if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
                    $navigation['reports'] = $possible_tabs['reports'];
                }
            } else {
                $menu_navigation['reports'] = $possible_tabs['reports'];
            }
        }
        // Custom tabs
        $customTabs = getCustomTabs();
        if (!empty($customTabs)) {
            foreach ($customTabs as $tab) {
                if (api_get_setting($tab['variable'], $tab['subkey']) == 'true' && isset($possible_tabs[$tab['subkey']])) {
                    $possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH) . $possible_tabs[$tab['subkey']]['url'];
                    $navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
                } else {
                    if (isset($possible_tabs[$tab['subkey']])) {
                        $possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH) . $possible_tabs[$tab['subkey']]['url'];
                        $menu_navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
                    }
                }
            }
        }
    }
    return array('menu_navigation' => $menu_navigation, 'navigation' => $navigation, 'possible_tabs' => $possible_tabs);
}
示例#15
0
$exerciseResult = Session::read('exerciseResult');
$questionList = Session::read('questionList');
$objExercise = Session::read('objExercise');
$id = intval($_REQUEST['id']);
//exe id
if (empty($id)) {
    api_not_allowed(true);
}
if (api_is_course_session_coach(api_get_user_id(), api_get_course_int_id(), api_get_session_id())) {
    if (!api_coach_can_edit_view_results(api_get_course_int_id(), api_get_session_id())) {
        api_not_allowed(true);
    }
}
$allowCoachFeedbackExercises = api_get_setting('allow_coach_feedback_exercises') === 'true';
$maxEditors = intval(api_get_setting('exercise_max_ckeditors_in_page'));
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor || api_is_session_admin() || api_is_drh() || api_is_student_boss();
$isCoachAllowedToEdit = api_is_allowed_to_edit(false, true);
$isFeedbackAllowed = false;
//Getting results from the exe_id. This variable also contain all the information about the exercise
$track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
//No track info
if (empty($track_exercise_info)) {
    api_not_allowed(true);
}
$exercise_id = $track_exercise_info['id'];
$exercise_date = $track_exercise_info['start_date'];
$student_id = $track_exercise_info['exe_user_id'];
$learnpath_id = $track_exercise_info['orig_lp_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$current_user_id = api_get_user_id();
示例#16
0
    }
    Security::clear_token();
}
// user info
$user_info = api_get_user_info($student_id);
$courses_in_session = array();
//See #4676
$drh_can_access_all_courses = false;
if (api_is_drh() || api_is_platform_admin() || api_is_student_boss()) {
    $drh_can_access_all_courses = true;
}
$courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
$courses_in_session_by_coach = array();
$sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
// RRHH or session admin
if (api_is_session_admin() || api_is_drh()) {
    $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
    $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
    if (!empty($session_by_session_admin)) {
        foreach ($session_by_session_admin as $session_coached_by_user) {
            $courses_followed_by_coach = Tracking::get_courses_list_from_session($session_coached_by_user['id']);
            $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
        }
    }
}
// Teacher or admin
if (!empty($sessions_coached_by_user)) {
    foreach ($sessions_coached_by_user as $session_coached_by_user) {
        $sid = intval($session_coached_by_user['id']);
        $courses_followed_by_coach = Tracking::get_courses_followed_by_coach(api_get_user_id(), $sid);
        $courses_in_session_by_coach[$sid] = $courses_followed_by_coach;
示例#17
0
$cidReset = true;
// including additional libraries
require_once 'myspace.lib.php';
// the section (for the tabs)
$this_section = SECTION_TRACKING;
ob_start();
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;
$csv_content = array();
$nameTools = get_lang('MySpace');
$user_id = api_get_user_id();
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
//$is_coach = api_is_coach($session_id); // This is used?
$is_platform_admin = api_is_platform_admin();
$is_drh = api_is_drh();
$is_session_admin = api_is_session_admin();
$count_sessions = 0;
$count_courses = 0;
$title = null;
// access control
api_block_anonymous_users();
$htmlHeadXtra[] = api_get_jqgrid_js();
if (!$export_csv) {
    Display::display_header($nameTools);
} else {
    if ($_GET['view'] == 'admin') {
        if ($display == 'useroverview') {
            MySpace::export_tracking_user_overview();
            exit;
        } else {
            if ($display == 'sessionoverview') {
    /**
     * Gets the admin session list callback of the admin/session_list.php page
     * @param array $options order and limit keys
     * @return array
     */
    public static function get_sessions_admin($options)
    {
        $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
        $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
        $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
        $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);

        $where = ' WHERE 1=1 ';
        $user_id = api_get_user_id();

        $extraJoin = null;

        if (api_is_session_admin() &&
            api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
        ) {
            $where .= " AND (
                            s.session_admin_id = $user_id  OR
                            sru.id_user = '******' AND
                            sru.relation_type = '" . SESSION_RELATION_TYPE_RRHH . "'
                            )
                      ";

            $extraJoin = " INNER JOIN $tbl_session_rel_user sru
                            ON sru.id_session = s.id ";
        }

        if (api_is_allowed_to_edit() && !api_is_platform_admin()) {
            $where.=" AND s.id_coach = $user_id ";
        }

        $coach_name = " CONCAT(u.lastname , ' ', u.firstname) as coach_name ";

        if (api_is_western_name_order()) {
            $coach_name = " CONCAT(u.firstname, ' ', u.lastname) as coach_name ";
        }

        $options['where'] = str_replace(
            array("AND session_active = '1'  )", " AND (  session_active = '1'  )"),
            array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 ")
            , $options['where']
        );

        $options['where'] = str_replace("(  session_active = ':'  )", '1=1', $options['where']);

        $options['where'] = str_replace(
            array("AND session_active = '0'  )", " AND (  session_active = '0'  )"),
            array(') GROUP BY s.name HAVING session_active = 0 ', " GROUP BY s.name HAVING session_active = '0' "),
            $options['where']
        );

        $today = api_get_utc_datetime();
        $today = api_strtotime($today, 'UTC');
        $today = date('Y-m-d', $today);

        $courseCondition = null;
        if (strpos($options['where'], 'c.id')) {
            $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
            $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
            $courseCondition = " INNER JOIN $table course_rel_session ON (s.id = course_rel_session.id_session)
                                 INNER JOIN $tableCourse c ON (course_rel_session.course_code = c.code)
                                ";
        }

        $select = "SELECT DISTINCT * FROM (SELECT
                IF (
					(s.date_start <= '$today' AND '$today' <= s.date_end) OR
                    (s.nb_days_access_before_beginning > 0 AND DATEDIFF(s.date_start,'" . $today . "' " . ") <= s.nb_days_access_before_beginning) OR
                    (s.nb_days_access_after_end > 0 AND DATEDIFF('" . $today . "',s.date_end) <= s.nb_days_access_after_end) OR
                    (s.date_start  = '0000-00-00' AND s.date_end  = '0000-00-00' ) OR
					(s.date_start <= '$today' AND '0000-00-00' = s.date_end) OR
					('$today' <= s.date_end AND '0000-00-00' = s.date_start)
				, 1, 0)
				as session_active,
				s.name,
                nbr_courses,
                s.nbr_users,
                s.date_start,
                s.date_end,
                $coach_name,
                sc.name as category_name,
                s.visibility,
                u.user_id,
                s.id";

        $limit = null;
        if (!empty($options['limit'])) {
            $limit = " LIMIT " . $options['limit'];
        }

        if (!empty($options['where'])) {
            $where .= ' '.$options['where'];
        }

        $order = null;
        if (!empty($options['order'])) {
            $order = " ORDER BY " . $options['order'];
        }

        $query = "$select FROM $tbl_session s
				LEFT JOIN $tbl_session_category sc ON s.session_category_id = sc.id
				LEFT JOIN $tbl_user u ON s.id_coach = u.user_id
				$courseCondition
				$extraJoin
                $where $order $limit";

        if (api_is_multiple_url_enabled()) {
            $access_url_id = api_get_current_access_url_id();
            if ($access_url_id != -1) {
                $query = " $select
                           FROM $tbl_session s
                               LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id
                               LEFT JOIN $tbl_user u ON s.id_coach = u.user_id
                               INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id AND ar.access_url_id = $access_url_id
                               $courseCondition
                               $extraJoin
				 $where $order $limit";
            }
        }

        $query .= ") AS session_table";

        $result = Database::query($query);
        $formatted_sessions = array();
        if (Database::num_rows($result)) {
            $sessions = Database::store_result($result);
            foreach ($sessions as $session) {
                $session['name'] = Display::url($session['name'], "resume_session.php?id_session=" . $session['id']);
                $session['coach_name'] = Display::url($session['coach_name'], "user_information.php?user_id=" . $session['user_id']);

                if ($session['date_start'] == '0000-00-00' && $session['date_end'] == '0000-00-00') {
                    //    $session['session_active'] = 1;
                }

                if ($session['session_active'] == 1) {
                    $session['session_active'] = Display::return_icon('accept.png', get_lang('Active'), array(), ICON_SIZE_SMALL);
                } else {
                    $session['session_active'] = Display::return_icon('error.png', get_lang('Inactive'), array(), ICON_SIZE_SMALL);
                }

                if ($session['date_start'] == '0000-00-00') {
                    $session['date_start'] = '';
                }
                if ($session['date_end'] == '0000-00-00') {
                    $session['date_end'] = '';
                }

                switch ($session['visibility']) {
                    case SESSION_VISIBLE_READ_ONLY: //1
                        $session['visibility'] = get_lang('SessionReadOnly');
                        break;
                    case SESSION_VISIBLE:           //2
                        $session['visibility'] = get_lang('SessionAccessible');
                        break;
                    case SESSION_INVISIBLE:         //3
                        $session['visibility'] = api_ucfirst(get_lang('SessionNotAccessible'));
                        break;
                }
                $formatted_sessions[] = $session;
            }
        }
        return $formatted_sessions;
    }
示例#19
0
 /**
  * Returns links to teachers tools (create course, etc) based on the user
  * in the active session
  * @return string HTML <div> block
  * @assert () == ''
  */
 public function return_teacher_link()
 {
     $user_id = api_get_user_id();
     if (!empty($user_id)) {
         // tabs that are deactivated are added here
         $show_menu = false;
         $show_create_link = false;
         $show_course_link = false;
         if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
             $show_menu = true;
             $show_course_link = true;
         } else {
             if (api_get_setting('allow_students_to_browse_courses') == 'true') {
                 $show_menu = true;
                 $show_course_link = true;
             }
         }
         if ($show_menu && ($show_create_link || $show_course_link)) {
             $show_menu = true;
         } else {
             $show_menu = false;
         }
     }
     // My Account section
     $elements = array();
     if ($show_menu) {
         if ($show_create_link) {
             $elements[] = array('href' => api_get_path(WEB_CODE_PATH) . 'create_course/add_course.php', 'title' => api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate'));
         }
         if ($show_course_link) {
             if (!api_is_drh() && !api_is_session_admin()) {
                 $elements[] = array('href' => api_get_path(WEB_CODE_PATH) . 'auth/courses.php', 'title' => get_lang('CourseCatalog'));
             } else {
                 $elements[] = array('href' => api_get_path(WEB_CODE_PATH) . 'dashboard/index.php', 'title' => get_lang('Dashboard'));
             }
         }
     }
     $this->show_right_block(get_lang('Courses'), $elements, 'teacher_block');
 }
function search_users($needle, $type)
{
    global $id_session;
    $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
    $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
    $xajax_response = new xajaxResponse();
    $return = '';
    if (!empty($needle) && !empty($type)) {
        // Normal behaviour
        if ($type == 'any_session' && $needle == 'false') {
            $type = 'multiple';
            $needle = '';
        }
        $needle = Database::escape_string($needle);
        $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
        $showOfficialCode = false;
        $orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
        if ($orderListByOfficialCode === 'true') {
            $showOfficialCode = true;
            $order_clause = ' ORDER BY official_code, firstname, lastname, username';
        }
        if (api_is_session_admin() && api_get_setting('prevent_session_admins_to_manage_all_users') === 'true') {
            $order_clause = " AND user.creator_id = " . api_get_user_id() . $order_clause;
        }
        $cond_user_id = '';
        // Only for single & multiple
        if (in_array($type, array('single', 'multiple'))) {
            if (!empty($id_session)) {
                $id_session = intval($id_session);
                // check id_user from session_rel_user table
                $sql = 'SELECT user_id FROM ' . $tbl_session_rel_user . '
                    WHERE session_id = "' . $id_session . '" AND relation_type<>' . SESSION_RELATION_TYPE_RRHH . ' ';
                $res = Database::query($sql);
                $user_ids = array();
                if (Database::num_rows($res) > 0) {
                    while ($row = Database::fetch_row($res)) {
                        $user_ids[] = (int) $row[0];
                    }
                }
                if (count($user_ids) > 0) {
                    $cond_user_id = ' AND user.id NOT IN(' . implode(",", $user_ids) . ')';
                }
            }
        }
        switch ($type) {
            case 'single':
                // search users where username or firstname or lastname begins likes $needle
                $sql = 'SELECT user.id, username, lastname, firstname, official_code
                        FROM ' . $tbl_user . ' user
                        WHERE
                            (
                                username LIKE "' . $needle . '%" OR
                                firstname LIKE "' . $needle . '%" OR
                                lastname LIKE "' . $needle . '%"
                            ) AND
                            user.status <> 6 AND
                            user.status <> ' . DRH . '' . $order_clause . '
                        LIMIT 11';
                break;
            case 'multiple':
                $sql = 'SELECT user.id, username, lastname, firstname, official_code
                        FROM ' . $tbl_user . ' user
                        WHERE
                            ' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND
                            user.status <> ' . DRH . ' AND
                            user.status <> 6 ' . $cond_user_id . $order_clause;
                break;
            case 'any_session':
                $sql = 'SELECT DISTINCT user.id, username, lastname, firstname, official_code
                        FROM ' . $tbl_user . ' user
                        LEFT OUTER JOIN ' . $tbl_session_rel_user . ' s ON (s.user_id = user.id)
                        WHERE
                            s.user_id IS NULL AND
                            user.status<>' . DRH . ' AND
                            user.status<>6 ' . $cond_user_id . $order_clause;
                break;
        }
        if (api_is_multiple_url_enabled()) {
            $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
            $access_url_id = api_get_current_access_url_id();
            if ($access_url_id != -1) {
                switch ($type) {
                    case 'single':
                        $sql = 'SELECT user.id, username, lastname, firstname, official_code
                        FROM ' . $tbl_user . ' user
                        INNER JOIN ' . $tbl_user_rel_access_url . ' url_user
                        ON (url_user.user_id = user.id)
                        WHERE
                            access_url_id = ' . $access_url_id . ' AND
                            (
                                username LIKE "' . $needle . '%" OR
                                firstname LIKE "' . $needle . '%" OR
                                lastname LIKE "' . $needle . '%"
                            ) AND user.status<>6 AND
                            user.status<>' . DRH . ' ' . $order_clause . ' LIMIT 11';
                        break;
                    case 'multiple':
                        $sql = 'SELECT user.id, username, lastname, firstname, official_code
                                FROM ' . $tbl_user . ' user
                                INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.id)
                                WHERE
                                    access_url_id = ' . $access_url_id . ' AND
                                    ' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND
                                    user.status<>' . DRH . ' AND
                                    user.status<>6 ' . $cond_user_id . $order_clause;
                        break;
                    case 'any_session':
                        $sql = 'SELECT DISTINCT user.id, username, lastname, firstname, official_code
                            FROM ' . $tbl_user . ' user
                            LEFT OUTER JOIN ' . $tbl_session_rel_user . ' s
                            ON (s.user_id = user.id)
                            INNER JOIN ' . $tbl_user_rel_access_url . ' url_user
                            ON (url_user.user_id = user.id)
                            WHERE
                                access_url_id = ' . $access_url_id . ' AND
                                s.user_id IS null AND
                                user.status <> ' . DRH . ' AND
                                user.status <> 6 ' . $cond_user_id . $order_clause;
                        break;
                }
            }
        }
        $rs = Database::query($sql);
        $i = 0;
        if ($type == 'single') {
            while ($user = Database::fetch_array($rs)) {
                $i++;
                if ($i <= 10) {
                    $person_name = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ') ' . $user['official_code'];
                    if ($showOfficialCode) {
                        $officialCode = !empty($user['official_code']) ? $user['official_code'] . ' - ' : '? - ';
                        $person_name = $officialCode . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')';
                    }
                    $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\'' . $user['id'] . '\',\'' . $person_name . ' ' . '\')">' . $person_name . ' </a><br />';
                } else {
                    $return .= '...<br />';
                }
            }
            $xajax_response->addAssign('ajax_list_users_single', 'innerHTML', api_utf8_encode($return));
        } else {
            global $nosessionUsersList;
            $return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
            while ($user = Database::fetch_array($rs)) {
                $person_name = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ') ' . $user['official_code'];
                if ($showOfficialCode) {
                    $officialCode = !empty($user['official_code']) ? $user['official_code'] . ' - ' : '? - ';
                    $person_name = $officialCode . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')';
                }
                $return .= '<option value="' . $user['id'] . '">' . $person_name . ' </option>';
            }
            $return .= '</select>';
            $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
        }
    }
    return $xajax_response;
}
示例#21
0
 /**
  * @param int $filter
  * @param string $view
  * @return string
  */
 public function displayActions($view, $filter = 0)
 {
     $courseInfo = api_get_course_info();
     $actionsLeft = '';
     $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php?type={$this->type}'>" . Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM) . "</a>";
     $courseCondition = '';
     if (!empty($courseInfo)) {
         $courseCondition = api_get_cidreq();
     }
     $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_list.php?type={$this->type}&" . $courseCondition . "'>" . Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM) . "</a>";
     $form = '';
     if (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true) || GroupManager::user_has_access(api_get_user_id(), api_get_group_id(), GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())) {
         $actionsLeft .= Display::url(Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=add&type=" . $this->type);
         $actionsLeft .= Display::url(Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=importical&type=" . $this->type);
         if ($this->type == 'course') {
             if (!isset($_GET['action'])) {
                 $form = new FormValidator('form-search', 'post', '', '', array(), FormValidator::LAYOUT_INLINE);
                 $attributes = array('multiple' => false, 'id' => 'select_form_id_search');
                 $selectedValues = $this->parseAgendaFilter($filter);
                 $this->showToForm($form, $selectedValues, $attributes);
                 $form = $form->returnForm();
             }
         }
     }
     if (api_is_platform_admin() || api_is_teacher() || api_is_student_boss() || api_is_drh() || api_is_session_admin() || api_is_coach()) {
         if ($this->type == 'personal') {
             $form = null;
             if (!isset($_GET['action'])) {
                 $form = new FormValidator('form-search', 'get', api_get_self() . '?type=personal&', '', array(), FormValidator::LAYOUT_INLINE);
                 $sessions = SessionManager::get_sessions_by_user(api_get_user_id());
                 $form->addHidden('type', 'personal');
                 $sessions = array_column($sessions, 'session_name', 'session_id');
                 $sessions = ['0' => get_lang('SelectAnOption')] + $sessions;
                 $form->addSelect('session_id', get_lang('Session'), $sessions, ['id' => 'session_id', 'onchange' => 'submit();']);
                 //$form->addButtonFilter(get_lang('Filter'));
                 //$renderer = $form->defaultRenderer();
                 //$renderer->setCustomElementTemplate('<div class="col-md-6">{element}</div>');
                 $form->addButtonReset(get_lang('Reset'));
                 $form = $form->returnForm();
             }
         }
     }
     $actionsRight = '';
     if ($view == 'calendar') {
         $actionsRight .= $form;
     }
     $toolbar = Display::toolbarAction('toolbar-agenda', array(0 => $actionsLeft, 1 => $actionsRight), 2, false);
     return $toolbar;
 }
示例#22
0
 /**
  * Gets the admin session list callback of the session/session_list.php
  * page with all user/details in the right fomat
  * @param array
  * @result array Array of rows results
  * @asset ('a') === false
  */
 public static function get_sessions_admin_complete($options = array())
 {
     if (!is_array($options)) {
         return false;
     }
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD);
     $tbl_session_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
     $tbl_session_field_options = Database::get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
     $where = 'WHERE 1 = 1 ';
     $user_id = api_get_user_id();
     if (!api_is_platform_admin()) {
         if (api_is_session_admin() && api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false') {
             $where .= " AND s.session_admin_id = {$user_id} ";
         }
     }
     $coach_name = " CONCAT(u.lastname , ' ', u.firstname) as coach_name ";
     if (api_is_western_name_order()) {
         $coach_name = " CONCAT(u.firstname, ' ', u.lastname) as coach_name ";
     }
     $today = api_get_utc_datetime();
     $inject_extra_fields = null;
     $extra_fields = array();
     $extra_fields_info = array();
     //for now only sessions
     $extra_field = new ExtraField('session');
     $double_fields = array();
     $extra_field_option = new ExtraFieldOption('session');
     if (isset($options['extra'])) {
         $extra_fields = $options['extra'];
         if (!empty($extra_fields)) {
             foreach ($extra_fields as $extra) {
                 $inject_extra_fields .= " IF (fv.field_id = {$extra['id']}, fvo.option_display_text, NULL ) as {$extra['field']} , ";
                 if (isset($extra_fields_info[$extra['id']])) {
                     $info = $extra_fields_info[$extra['id']];
                 } else {
                     $info = $extra_field->get($extra['id']);
                     $extra_fields_info[$extra['id']] = $info;
                 }
                 if ($info['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
                     $double_fields[$info['id']] = $info;
                 }
             }
         }
     }
     $options_by_double = array();
     foreach ($double_fields as $double) {
         $my_options = $extra_field_option->get_field_options_by_field($double['id'], true);
         $options_by_double['extra_' . $double['field_variable']] = $my_options;
     }
     //sc.name as category_name,
     $select = "\n                SELECT * FROM (\n                    SELECT DISTINCT\n                         IF (\n                            (s.access_start_date <= '{$today}' AND '{$today}' < s.access_end_date) OR\n                            (s.access_start_date = '0000-00-00 00:00:00' AND s.access_end_date = '0000-00-00 00:00:00' ) OR\n                            (s.access_start_date IS NULL AND s.access_end_date IS NULL) OR\n                            (s.access_start_date <= '{$today}' AND ('0000-00-00 00:00:00' = s.access_end_date OR s.access_end_date IS NULL )) OR\n                            ('{$today}' < s.access_end_date AND ('0000-00-00 00:00:00' = s.access_start_date OR s.access_start_date IS NULL) )\n                        , 1, 0) as session_active,\n                s.name,\n                s.nbr_courses,\n                s.nbr_users,\n                s.display_start_date,\n                s.display_end_date,\n                {$coach_name},\n                access_start_date,\n                access_end_date,\n                s.visibility,\n                u.user_id,\n                {$inject_extra_fields}\n                c.title as course_title,\n                s.id ";
     if (!empty($options['where'])) {
         if (!empty($options['extra'])) {
             $options['where'] = str_replace(' 1 = 1  AND', '', $options['where']);
             $options['where'] = str_replace('AND', 'OR', $options['where']);
             foreach ($options['extra'] as $extra) {
                 $options['where'] = str_replace($extra['field'], 'fv.field_id = ' . $extra['id'] . ' AND fvo.option_value', $options['where']);
             }
         }
         $options['where'] = str_replace('course_title', 'c.title', $options['where']);
         $options['where'] = str_replace("( session_active = '0' )", '1=1', $options['where']);
         $options['where'] = str_replace(array("AND session_active = '1'  )", " AND (  session_active = '1'  )"), array(') GROUP BY s.name HAVING session_active = 1 ', " GROUP BY s.name HAVING session_active = 1 "), $options['where']);
         $options['where'] = str_replace(array("AND session_active = '0'  )", " AND (  session_active = '0'  )"), array(') GROUP BY s.name HAVING session_active = 0 ', " GROUP BY s.name HAVING session_active = '0' "), $options['where']);
         $where .= ' AND ' . $options['where'];
     }
     if (!empty($options['limit'])) {
         $where .= " LIMIT " . $options['limit'];
     }
     $query = "{$select} FROM {$tbl_session} s\n                    LEFT JOIN {$tbl_session_field_values} fv\n                    ON (fv.item_id = s.id)\n                    LEFT JOIN {$extraFieldTable} f\n                    ON f.id = fv.field_id\n                    LEFT JOIN {$tbl_session_field_options} fvo\n                    ON (fv.field_id = fvo.field_id)\n                    LEFT JOIN {$tbl_session_rel_course} src\n                    ON (src.session_id = s.id)\n                    LEFT JOIN {$tbl_course} c\n                    ON (src.c_id = c.id)\n                    LEFT JOIN {$tbl_session_category} sc\n                    ON (s.session_category_id = sc.id)\n                    INNER JOIN {$tbl_user} u\n                    ON (s.id_coach = u.user_id) " . $where;
     if (api_is_multiple_url_enabled()) {
         $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $where .= " AND ar.access_url_id = {$access_url_id} ";
             $query = "{$select}\n                    FROM {$tbl_session} s\n                    LEFT JOIN {$tbl_session_field_values} fv ON (fv.session_id = s.id)\n                    LEFT JOIN {$tbl_session_field_options} fvo ON (fv.field_id = fvo.field_id)\n                    LEFT JOIN {$tbl_session_rel_course} src ON (src.id_session = s.id)\n                    LEFT JOIN {$tbl_course} c ON (src.c_id = c.id)\n                    LEFT JOIN {$tbl_session_category} sc ON (s.session_category_id = sc.id)\n                    INNER JOIN {$tbl_user} u ON (s.id_coach = u.user_id)\n                    INNER JOIN {$table_access_url_rel_session} ar ON (ar.session_id = s.id)\n                    {$where}";
         }
     }
     $query .= ") AS session_table";
     if (!empty($options['order'])) {
         $query .= " ORDER BY " . $options['order'];
     }
     //error_log($query);
     //echo $query;
     $result = Database::query($query);
     $formatted_sessions = array();
     if (Database::num_rows($result)) {
         $sessions = Database::store_result($result, 'ASSOC');
         foreach ($sessions as $session) {
             $session_id = $session['id'];
             $session['name'] = Display::url($session['name'], "resume_session.php?id_session=" . $session['id']);
             $session['coach_name'] = Display::url($session['coach_name'], "user_information.php?user_id=" . $session['user_id']);
             if ($session['session_active'] == 1) {
                 $session['session_active'] = Display::return_icon('accept.png', get_lang('Active'), array(), ICON_SIZE_SMALL);
             } else {
                 $session['session_active'] = Display::return_icon('error.png', get_lang('Inactive'), array(), ICON_SIZE_SMALL);
             }
             $session = self::convert_dates_to_local($session);
             switch ($session['visibility']) {
                 case SESSION_VISIBLE_READ_ONLY:
                     //1
                     $session['visibility'] = get_lang('ReadOnly');
                     break;
                 case SESSION_VISIBLE:
                     //2
                 //2
                 case SESSION_AVAILABLE:
                     //4
                     $session['visibility'] = get_lang('Visible');
                     break;
                 case SESSION_INVISIBLE:
                     //3
                     $session['visibility'] = api_ucfirst(get_lang('Invisible'));
                     break;
             }
             // Cleaning double selects
             foreach ($session as $key => &$value) {
                 if (isset($options_by_double[$key]) || isset($options_by_double[$key . '_second'])) {
                     $options = explode('::', $value);
                 }
                 $original_key = $key;
                 if (strpos($key, '_second') === false) {
                 } else {
                     $key = str_replace('_second', '', $key);
                 }
                 if (isset($options_by_double[$key])) {
                     if (isset($options[0])) {
                         if (isset($options_by_double[$key][$options[0]])) {
                             if (strpos($original_key, '_second') === false) {
                                 $value = $options_by_double[$key][$options[0]]['option_display_text'];
                             } else {
                                 $value = $options_by_double[$key][$options[1]]['option_display_text'];
                             }
                         }
                     }
                 }
             }
             // Magic filter
             if (isset($formatted_sessions[$session_id])) {
                 $formatted_sessions[$session_id] = self::compareArraysToMerge($formatted_sessions[$session_id], $session);
             } else {
                 $formatted_sessions[$session_id] = $session;
             }
         }
     }
     return $formatted_sessions;
 }
 /**
  * @param int $id
  * @return bool
  */
 static function protect_session_edit($id = null)
 {
     if (api_is_platform_admin()) {
         return false;
     }
     if (api_is_session_admin()) {
         return false;
     }
     $blockTeachers = !api_is_teacher() || api_is_teacher() && api_get_setting('allow_teachers_to_create_sessions') == 'false';
     if ($blockTeachers) {
         api_not_allowed(true);
     }
     if (!empty($id)) {
         $session_info = self::fetch($id);
         if (empty($session_info)) {
             api_not_allowed(true);
         }
         if ($blockTeachers && !api_is_platform_admin() && api_get_setting('allow_session_admins_to_manage_all_sessions') != 'true') {
             if ($session_info['session_admin_id'] != api_get_user_id()) {
                 api_not_allowed(true);
             }
         }
         //Blocking teachers that want to edit another session
         if ($blockTeachers == false && $session_info['id_coach'] != api_get_user_id()) {
             api_not_allowed(true);
         }
     }
 }
示例#24
0
    function return_teacher_link() {
        $html = '';
        if (!empty($this->user_id)) {
            // tabs that are deactivated are added here

            $show_menu = false;
            $show_create_link = false;
            $show_course_link = false;

            if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
                $show_menu = true;
                $show_course_link = true;
                $show_create_link = true;
            } else {
                if (api_get_setting('allow_students_to_browse_courses') == 'true') {
                    $show_menu = true;
                    $show_course_link = true;
                }
            }

            if ($show_menu && ($show_create_link || $show_course_link )) {
                $show_menu = true;
            } else {
                $show_menu = false;
            }
        }

        // My Account section

        if ($show_menu) {
            $html .= '<ul class="nav nav-list">';
            if ($show_create_link) {
                $html .= '<li class="add-course"><a href="' . api_get_path(WEB_CODE_PATH) . 'create_course/add_course.php">'.(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
            }

            if ($show_course_link) {
                if (!api_is_drh() && !api_is_session_admin()) {
                    $html .=  '<li class="list-course"><a href="' . api_get_path(WEB_CODE_PATH) . 'auth/courses.php">'.get_lang('CourseCatalog').'</a></li>';
                } else {
                    $html .= '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
                }
            }
            $html .= '</ul>';
        }

        if (!empty($html)) {
            $html = self::show_right_block(get_lang('Courses'), $html, 'teacher_block');
        }

        return $html;
    }
 */
$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
// Including the global initialization file
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$course_info = api_get_course_info();
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
if ($from == 'myspace') {
    $from_myspace = true;
    $this_section = "session_my_space";
} else {
    $this_section = SECTION_COURSES;
}
// Access restrictions.
$is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor();
if (!$is_allowedToTrack) {
    api_not_allowed();
    exit;
}
// Including additional libraries.
require_once api_get_path(SYS_CODE_PATH) . 'resourcelinker/resourcelinker.inc.php';
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);
if ($export_csv) {
    ob_start();
}
if (empty($session_id)) {
    $session_id = api_get_session_id();
}
 /**
  * Get appropriate links visible for the user
  * @param int $stud_id student id (default: all students)
  * @param boolean $recursive process subcategories (default: no recursion)
  */
 public function get_links($stud_id = null, $recursive = false, $course_code = '')
 {
     $links = array();
     if (empty($course_code)) {
         $course_code = api_get_course_id();
     }
     // no links in root or course independent categories
     if ($this->id == 0) {
     } elseif (isset($stud_id)) {
         // 1 student $stud_id
         $links = LinkFactory::load(null, null, null, null, empty($this->course_code) ? null : $course_code, $this->id, api_is_allowed_to_edit() ? null : 1);
     } elseif (api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) {
         // all students -> only for course/platform admin
         $links = LinkFactory::load(null, null, null, null, empty($this->course_code) ? null : $this->course_code, $this->id, null);
     }
     if ($recursive) {
         $subcats = $this->get_subcategories($stud_id, $course_code);
         if (!empty($subcats)) {
             foreach ($subcats as $subcat) {
                 $sublinks = $subcat->get_links($stud_id, false, $course_code);
                 $links = array_merge($links, $sublinks);
             }
         }
     }
     return $links;
 }
/**
 * Report
 * @package chamilo.tracking
 */
/**
 * Code
 */
$language_file = array('registration', 'index', 'tracking', 'exercice', 'survey');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php';
require_once api_get_path(SYS_CODE_PATH) . 'exercice/question.class.php';
require_once api_get_path(LIBRARY_PATH) . 'pear/Spreadsheet_Excel_Writer/Writer.php';
require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpath.class.php';
$this_section = "session_my_space";
$is_allowedToTrack = api_is_course_admin() || api_is_platform_admin() || api_is_course_coach() || api_is_session_admin();
if (!$is_allowedToTrack) {
    Display::display_header(null);
    api_not_allowed();
    Display::display_footer();
}
$export_to_xls = false;
if (isset($_GET['export'])) {
    $export_to_xls = true;
}
if (api_is_platform_admin()) {
    $global = true;
} else {
    $global = false;
}
$global = true;
示例#28
0
/**
 * Limit the access to Session Admins wheen the limit_session_admin_role
 * configuration variable is set to true
 */
function api_protect_limit_for_session_admin()
{
    $limitAdmin = api_get_setting('session.limit_session_admin_role');
    if (api_is_session_admin() && $limitAdmin === 'true') {
        api_not_allowed(true);
    }
}
示例#29
0
$htmlHeadXtra[] = api_get_jqgrid_js();
$interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('MySpace'));
Display::display_header(get_lang('Sessions'));
$export_csv = false;
if (isset($_GET['export']) && $_GET['export'] == 'csv') {
    $export_csv = true;
}
/*	MAIN CODE */
if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
    $id_coach = intval($_GET['id_coach']);
} else {
    $id_coach = api_get_user_id();
}
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
    $a_sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
    if (!api_is_session_admin()) {
        $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "auth/my_progress.php");
        $menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), "index.php?view=drh_students&amp;display=yourstudents");
        $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php');
        $menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php');
        $menu_items[] = Display::url(Display::return_icon('session_na.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), '#');
    }
    $actionsLeft = '';
    $nb_menu_items = count($menu_items);
    if ($nb_menu_items > 1) {
        foreach ($menu_items as $key => $item) {
            $actionsLeft .= $item;
        }
    }
    $actionsRight = '';
    if (count($a_sessions) > 0) {
            if (CourseManager::get_user_in_course_status($_GET['user_id'], $_GET['courseId']) == STUDENT) {
                CourseManager::unsubscribe_user($_GET['user_id'], $_GET['courseId']);
                Display::display_normal_message(get_lang('UserUnsubscribed'));
            } else {
                Display::display_error_message(get_lang('CannotUnsubscribeUserFromCourse'));
            }
            break;
    }
}
//only allow platform admins to login_as, or session admins only for students
// (not teachers nor other admins), and only if all options confirm it
// $_configuration['login_as_forbidden_globally'], defined in configuration.php,
// is the master key to these conditions
$statusname = api_get_status_langvars();
$login_as_icon = '';
if (empty($_configuration['login_as_forbidden_globally']) && (api_is_global_platform_admin() || api_get_setting('login_as_allowed') === 'true' && (api_is_platform_admin() || api_is_session_admin() && (api_is_session_admin() && $row['6'] == $statusname[STUDENT])))) {
    $login_as_icon = '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?action=login_as&amp;user_id=' . $user['user_id'] . '&amp;sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('login_as.gif', get_lang('LoginAs')) . '</a>';
}
echo '<div class="actions"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . intval($_GET['user_id']) . '" title="' . get_lang('Reporting') . '">' . Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM) . '</a>' . $login_as_icon . '</div>';
echo Display::page_header($tool_name);
//getting the user image
$sysdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'system', false, true);
$sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
$webdir = $webdir_array['dir'];
$fullurl = $webdir . $webdir_array['file'];
$system_image_path = $sysdir . $webdir_array['file'];
list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$resizing = $height > 200 ? 'height="200"' : '';
$height += 30;
$width += 30;