123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- <?php
- $uInfo = $_REQUEST['uInfo'];
- $view = $_REQUEST['view'];
- $language_file = 'tracking';
- require_once '../inc/global.inc.php';
- $user_id = api_get_user_id();
- $course_id = api_get_course_id();
- $courseId = api_get_course_int_id();
- $is_allowed = true;
- require_once api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
- require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
- require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php';
- if($uInfo)
- {
- $interbreadcrumb[]= array ("url"=>"../user/userInfo.php?uInfo=$uInfo", "name"=> get_lang('BredCrumpUsers'));
- }
- $nameTools = get_lang('ToolName');
- $is_allowedToTrack = api_is_course_admin();
- $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $courseId);
- $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
- $TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
- $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
- $TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
- $tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
- $tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
- $tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
- $tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
- $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
- $DaysShort = api_get_week_days_short();
- $DaysLong = api_get_week_days_long();
- $MonthsLong = api_get_months_long();
- $MonthsShort = api_get_months_short();
- $is_allowedToTrack = true;
- $is_allowedToTrackEverybodyInCourse = $is_allowedToTrack;
- $title[0]='';
- $title[1]='';
- $line='';
- $title_line='';
- if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse))
- {
- if(!$uInfo && !isset($uInfo) )
- {
-
- if( $is_allowedToTrackEverybodyInCourse )
- {
-
- $sql = "SELECT count(user_id)
- FROM $TABLECOURSUSER
- WHERE course_code = '$_cid' AND relation_type<>".COURSE_RELATION_TYPE_RRHH."";
- }
- else
- {
-
- $sql = "SELECT count(user)
- FROM $TABLECOURSE_GROUPSUSER
- WHERE group_id = '$_gid'";
- }
- $userGroupNb = getOneResult($sql);
- $step = 25;
- if ($userGroupNb > $step)
- {
- if(!isset($offset))
- {
- $offset=0;
- }
- $next = $offset + $step;
- $previous = $offset - $step;
- $navLink = "";
- if ($previous >= 0)
- {
- }
- if ($next < $userGroupNb)
- {
- }
- }
- else
- {
- $offset = 0;
- }
- echo $navLink;
- if (!settype($offset, 'integer') || !settype($step, 'integer')) die('Offset or step variables are not integers.');
- if( $is_allowedToTrackEverybodyInCourse )
- {
-
- $sql = "SELECT u.user_id, u.firstname,u.lastname
- FROM $TABLECOURSUSER cu , $TABLEUSER u
- WHERE cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
- AND cu.course_code = '$_cid'
- LIMIT $offset,$step";
- }
- else
- {
-
- $sql = "SELECT u.user_id, u.firstname,u.lastname
- FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
- WHERE gu.user_id = u.user_id
- AND gu.group_id = '$_gid'
- LIMIT $offset,$step";
- }
- $list_users = getManyResults3Col($sql);
- for($i = 0 ; $i < sizeof($list_users) ; $i++)
- {
- }
- }
- else
- {
-
-
-
- if( $is_allowedToTrackEverybodyInCourse )
- {
-
- $tracking_is_accepted = $is_course_member;
- $tracked_user_info = api_get_user_info($uInfo);
- $title[0]=$tracked_user_info[1].'_'.$tracked_user_info[2];
- }
- else
- {
-
- $sql = "SELECT u.firstname,u.lastname, u.email
- FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
- WHERE gu.user_id = u.user_id
- AND gu.group_id = '$_gid'
- AND u.user_id = '$uInfo'";
- $query = Database::query($sql);
- $tracked_user_info = @Database::fetch_assoc($query);
- if(is_array($tracked_user_info)) $tracking_is_accepted = true;
- $title[0] = $tracked_user_info['firstname'].'_'.$tracked_user_info['lastname'];
- }
- if ($tracking_is_accepted)
- {
- $tracked_user_info['email'] == '' ? $mail_link = get_lang('NoEmail') : $mail_link = Display::encrypted_mailto_link($tracked_user_info['email']);
- if(!isset($view))
- {
- $view ='0000000';
- }
-
- list($title_line1, $line1) = TrackingUserLogCSV::display_login_tracking_info($view, $uInfo, $courseId);
-
- list($title_line2, $line2) = TrackingUserLogCSV::display_exercise_tracking_info($view, $uInfo, $courseId);
-
- list($title_line3, $line3) = TrackingUserLogCSV::display_student_publications_tracking_info($view, $uInfo, $courseId);
-
- list($title_line4, $line4) = TrackingUserLogCSV::display_links_tracking_info($view, $uInfo, $courseId);
-
- list($title_line5, $line5) = TrackingUserLogCSV::display_document_tracking_info($view, $uInfo, $courseId);
- $title_line = $title_line1.$title_line2.$title_line3.$title_line4.$title_line5;
- $line= $line1.$line2.$line3.$line4.$line5;
- }
- else
- {
- echo get_lang('ErrorUserNotInGroup');
- }
-
-
-
- }
-
- $len = strlen($title_line.$line);
- header('Content-type: application/octet-stream');
-
- header('Content-length: '.$len);
- $filename = html_entity_decode(str_replace(":","",str_replace(" ","_", $title[0].'_'.$title[1].'.csv')));
- $filename = api_replace_dangerous_char($filename);
- if(preg_match("/MSIE 5.5/",$_SERVER['HTTP_USER_AGENT']))
- {
- header('Content-Disposition: filename= '.$filename);
- }
- else
- {
- header('Content-Disposition: attachment; filename= '.$filename);
- }
- if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
- {
- header('Pragma: ');
- header('Cache-Control: ');
- header('Cache-Control: public');
- }
- header('Content-Description: '.$filename);
- header('Content-transfer-encoding: binary');
- echo api_html_entity_decode($title_line, ENT_QUOTES, $charset);
- echo api_html_entity_decode($line, ENT_QUOTES, $charset);
- exit;
- }
- else
- {
- api_not_allowed();
- }
|