userInfo.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script displays info about one specific user, specified through
  5. * a GET parameter, e.g. uInfo=2
  6. *
  7. * @todo clean up script in clean sections:
  8. * (1) gather information
  9. * (2) tool logic
  10. * (3) display
  11. * @author original author (unknown, probably thomas,hugues,moosh)
  12. * @author Roan Embrechts, minor modification: virtual courses support
  13. * @author Julio Montoya Armas Several fixes
  14. * @todo clean this code
  15. * @package chamilo.user
  16. */
  17. // name of the language file that needs to be included
  18. $language_file = array ('registration', 'userInfo');
  19. require_once '../inc/global.inc.php';
  20. $htmlHeadXtra[] = '<script type="text/javascript">
  21. function show_image(image,width,height) {
  22. width = parseInt(width) + 20;
  23. height = parseInt(height) + 20;
  24. window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
  25. }
  26. </script>';
  27. $editMainUserInfo = Security::remove_XSS($_REQUEST['editMainUserInfo']);
  28. $uInfo = $editMainUserInfo;
  29. $this_section = SECTION_COURSES;
  30. $nameTools = get_lang('Users');
  31. api_protect_course_script(true);
  32. $tool_info = api_get_tool_information_by_name(TOOL_USER);
  33. if (api_is_anonymous()) {
  34. api_not_allowed(true);
  35. }
  36. //prepare variables used in userInfoLib.php functions
  37. $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO);
  38. $TBL_USERINFO_CONTENT = Database :: get_course_table(TABLE_USER_INFO_CONTENT);
  39. if ($tool_info['visibility'] == 1 ) {
  40. $interbreadcrumb[] = array ('url' => 'user.php', 'name' => get_lang('Users'));
  41. }
  42. if ($origin != 'learnpath') { //so we are not in learnpath tool
  43. Display :: display_header($nameTools, "User");
  44. $origin = Security::remove_XSS($_GET['origin']);
  45. } else {
  46. ?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH);?>css/default.css" /> <?php
  47. }
  48. $currentCourse = api_get_course_id();
  49. $current_session_id = api_get_session_id();
  50. // api_display_tool_title(get_lang("Users"));
  51. /*
  52. * data found in settings are :
  53. * $uid
  54. * $isAdmin
  55. * $isAdminOfCourse
  56. * $_configuration['main_database']
  57. * $currentCourseID
  58. */
  59. //$userIdViewed = $uInfo; // Id of the user we want to view coming from the user.php
  60. //get information about one user
  61. $userIdViewed = Security::remove_XSS($_REQUEST['uInfo']);
  62. /**
  63. * Connection layer between Chamilo and the current script
  64. */
  65. $courseCode = api_get_course_id();
  66. $tbl_coursUser = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  67. $userIdViewer = api_get_user_id(); // id fo the user currently online
  68. //$userIdViewed = $_GET['userIdViewed']; // Id of the user we want to view
  69. $allowedToEditContent = ($userIdViewer == $userIdViewed) || $is_platformAdmin;
  70. $allowedToEditDef = api_is_allowed_to_edit(null, true);
  71. $is_allowedToTrack = api_is_allowed_to_edit(null, true);
  72. // Library connection
  73. require_once "userInfoLib.php";
  74. /**
  75. * FUNCTIONS
  76. */
  77. /* COMMANDS SECTION */
  78. $displayMode = "viewContentList";
  79. $removeDef = Security::remove_XSS($_GET['removeDef']);
  80. $editDef = Security::remove_XSS($_GET['editDef']);
  81. $moveUpDef = Security::remove_XSS($_GET['moveUpDef']);
  82. $moveDownDef = Security::remove_XSS($_GET['moveDownDef']);
  83. if ($allowedToEditDef) {
  84. if (!empty($_POST['submitDef'])) {
  85. if (!empty($_POST['id'])) {
  86. edit_cat_def($_POST['id'], $_POST['title'], $_POST['comment'], $_POST['nbline']);
  87. } else {
  88. create_cat_def($_POST['title'], $_POST['comment'], $_POST['nbline']);
  89. }
  90. $displayMode = "viewDefList";
  91. } elseif (!empty($_GET['removeDef'])) {
  92. remove_cat_def($_GET['removeDef'], true);
  93. $displayMode = "viewDefList";
  94. } elseif (!empty($_GET['editDef'])) {
  95. $displayMode = "viewDefEdit";
  96. } elseif (!empty ($_POST['addDef'])) {
  97. $displayMode = "viewDefEdit";
  98. } elseif (!empty($_GET['moveUpDef'])) {
  99. move_cat_rank($_GET['moveUpDef'], "up");
  100. $displayMode = "viewDefList";
  101. } elseif (!empty($_GET['moveDownDef'])) {
  102. move_cat_rank($_GET['moveDownDef'], "down");
  103. $displayMode = "viewDefList";
  104. } elseif (!empty($_POST['viewDefList'])) {
  105. $displayMode = "viewDefList";
  106. } elseif (!empty($_GET['editMainUserInfo'])) {
  107. $userIdViewed = strval(intval($_GET['editMainUserInfo']));
  108. $displayMode = "viewMainInfoEdit";
  109. } elseif (!empty($_REQUEST['submitMainUserInfo'])) {
  110. /*
  111. if (isset ($_REQUEST['submitMainUserInfo']))
  112. {
  113. */
  114. $userIdViewed = strval(intval($_REQUEST['submitMainUserInfo']));
  115. /*
  116. //is teacher
  117. $promoteCourseAdmin=$_REQUEST['promoteCourseAdmin'];
  118. $userProperties['status'] = 5;
  119. if ($promoteCourseAdmin)
  120. {
  121. $userProperties['status'] = 1;
  122. }
  123. // deprecated feature
  124. // is coach
  125. if (isset ($_REQUEST['promoteTutor']))
  126. {
  127. $promoteTutor=$_REQUEST['promoteTutor'];
  128. $userProperties['tutor'] = 0;
  129. if ($promoteTutor)
  130. {
  131. $userProperties['tutor'] = 1;
  132. }
  133. }
  134. // role is a string
  135. if (isset ($_REQUEST['role']))
  136. {
  137. $role=$_REQUEST['role'];
  138. $userProperties['role'] = $role;
  139. }
  140. */
  141. //get information about one user - task #3009
  142. if ($current_session_id) {
  143. $nocoach = isset($_POST['promoteTutor'])?false:true;
  144. $res = SessionManager::set_coach_to_course_session($userIdViewed, $current_session_id, $courseCode, $nocoach);
  145. } else {
  146. if (!empty($_POST['promoteCourseAdmin']) && $_POST['promoteCourseAdmin']){
  147. $userProperties['status'] = 1;
  148. } else{
  149. $userProperties['status'] = 5;
  150. }
  151. if (!empty($_POST['promoteTutor']) && $_POST['promoteTutor']){
  152. $userProperties['tutor'] = 1;
  153. } else{
  154. $userProperties['tutor'] = 0;
  155. }
  156. $userProperties['role'] = $_POST['role'];
  157. update_user_course_properties($userIdViewed, $courseCode, $userProperties);
  158. }
  159. $displayMode = "viewContentList";
  160. }
  161. }
  162. // COMMON COMMANDS
  163. if ($allowedToEditContent) {
  164. if (isset($_POST['submitContent'])) {
  165. if ($_POST['cntId']) {
  166. // submit a content change
  167. edit_cat_content($_POST['catId'], $userIdViewed, $_POST['content'], $_SERVER['REMOTE_ADDR']);
  168. } else {
  169. // submit a totally new content
  170. fill_new_cat_content($_POST['catId'], $userIdViewed, $_POST['content'], $_SERVER['REMOTE_ADDR']);
  171. }
  172. $displayMode = "viewContentList";
  173. } elseif (!empty($_GET['editContent'])) {
  174. $displayMode = "viewContentEdit";
  175. $userIdViewed = $userIdViewed;
  176. }
  177. }
  178. /* DISPLAY MODES */
  179. // Back button for each display mode (Top)
  180. if (api_is_allowed_to_edit(null, true)) {
  181. echo '<div class="actions">';
  182. if($origin=='users'){
  183. echo '<a href="user.php?'.api_get_cidreq().'&amp;origin='.$origin.'">'.Display::return_icon('back.png',get_lang('BackUser'),'',ICON_SIZE_MEDIUM).'</a>';
  184. }
  185. else{
  186. echo '<a href="javascript:history.back(1)">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  187. }
  188. if (!is_numeric($_GET['editMainUserInfo'])) {
  189. if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
  190. echo '<a href="userInfo.php?'.api_get_cidreq().'&amp;origin='.$origin.'&amp;editMainUserInfo='.$userIdViewed.'">'.Display::return_icon('edit.png',get_lang('EditUser'),'',ICON_SIZE_MEDIUM).'</a>';
  191. }
  192. } else {
  193. if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
  194. echo '<a href="userInfo.php?'.api_get_cidreq().'&amp;origin='.$origin.'&amp;uInfo='.$userIdViewed.'">'.Display::return_icon('user.png',get_lang('ViewUser'),'',ICON_SIZE_MEDIUM).'</a>';
  195. }
  196. }
  197. echo '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&amp;origin=user_course&amp;student='.$userIdViewed.'&amp;details=true&amp;course='.$_course['id'].'">'.Display::return_icon('stats.png',get_lang('UserStatistics'),'',ICON_SIZE_MEDIUM).'</a>';
  198. echo '</div>';
  199. } else {
  200. if ($tool_info['visibility'] == 1 ) {
  201. echo '<div class="actions">';
  202. if($origin=='users'){
  203. echo '<a href="user.php?'.api_get_cidreq().'&amp;origin='.$origin.'">'.Display::return_icon('back.png',get_lang('BackUser'),'',ICON_SIZE_MEDIUM).'</a>';
  204. }
  205. else{
  206. echo '<a href="javascript:history.back(1)">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  207. }
  208. echo '</div>';
  209. }
  210. }
  211. // get information about user id viewed
  212. $user_info_viewed = api_get_user_info($userIdViewed);
  213. $is_session_course_coach = UserManager::is_session_course_coach($userIdViewed, $_course['sysCode'], $current_session_id);
  214. if ($displayMode == "viewDefEdit") {
  215. /* CATEGORIES DEFINITIONS : EDIT */
  216. $catToEdit = get_cat_def($_GET['editDef']);
  217. $edit_heading_form = new FormValidator('edit_heading_form');
  218. $edit_heading_form->addElement('hidden', 'id');
  219. $edit_heading_form->add_textfield('title', get_lang('Title'));
  220. $edit_heading_form->addElement('textarea', 'comment', get_lang('Comment'), array ('cols' => 60, 'rows' => 4));
  221. $possible_line_nrs[1] = '1 '.get_lang('Line');
  222. $possible_line_nrs[3] = '3 '.get_lang('Lines');
  223. $possible_line_nrs[5] = '5 '.get_lang('Lines');
  224. $possible_line_nrs[10] = '10 '.get_lang('Lines');
  225. $possible_line_nrs[15] = '15 '.get_lang('Lines');
  226. $edit_heading_form->addElement('select', 'nbline', get_lang('LineNumber'), $possible_line_nrs);
  227. $edit_heading_form->addElement('submit', 'submitDef', get_lang('Ok'));
  228. $edit_heading_form->setDefaults($catToEdit);
  229. $edit_heading_form->display();
  230. } elseif ($displayMode == "viewDefList") {
  231. /*CATEGORIES DEFINITIONS : LIST */
  232. $catList = get_cat_def_list();
  233. if ($catList) {
  234. foreach ($catList as $thisCat) {
  235. // displays Title and comments
  236. echo "<p>", "<b>".htmlize($thisCat['title'])."</b><br>\n", "<i>".htmlize($thisCat['comment'])."</i>\n", "</p>";
  237. // displays lines
  238. echo "<blockquote>\n", "<font color=\"gray\">\n";
  239. for ($i = 1; $i <= $thisCat['nbline']; $i ++) {
  240. echo "<br>__________________________________________\n";
  241. }
  242. echo "</font>\n", "</blockquote>\n";
  243. // displays commands
  244. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&removeDef=", $thisCat['catId'], "\">", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"".get_lang('Remove')."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">", "</a>", "<a href=\"".api_get_self()."?".api_get_cidreq()."&editDef=", $thisCat['catId'], "\">", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"".get_lang('Edit')."\" />", "</a>", "<a href=\"".api_get_self()."?".api_get_cidreq()."&moveUpDef=", $thisCat['catId'], "\">", "<img src=\"../img/up.gif\" border=\"0\" alt=\"".get_lang('MoveUp')."\">", "</a>", "<a href=\"".api_get_self()."?".api_get_cidreq()."&moveDownDef=", $thisCat['catId'], "\">", "<img src=\"../img/down.gif\" border=\"0\" alt=\"".get_lang('MoveDown')."\">", "</a>\n";
  245. } // end for each
  246. } // end if ($catList)
  247. echo "<center>\n",
  248. "<form method=\"post\" action=\"".api_get_self()."\">",
  249. "<input type=\"submit\" name=\"addDef\" class=\"plus\" value=\"".get_lang('AddNewHeading')."\" />",
  250. "</form>\n",
  251. "<center>\n";
  252. }
  253. elseif ($displayMode == "viewContentEdit") {
  254. /* CATEGORIES CONTENTS : EDIT */
  255. $catToEdit = get_cat_content($userIdViewed, $_GET['editContent']);
  256. $content_heading_form = new FormValidator('content_heading_form');
  257. $content_heading_form->addElement('hidden', 'cntId');
  258. $content_heading_form->addElement('hidden', 'catId');
  259. $content_heading_form->addElement('hidden', 'uInfo');
  260. $content_heading_form->addElement('static', null, $catToEdit['title'], htmlize($catToEdit['comment']));
  261. if ($catToEdit['nbline'] == 1) {
  262. $content_heading_form->addElement('text', 'content', null, array ('size' => 80));
  263. } else {
  264. $content_heading_form->addElement('textarea', 'content', null, array ('cols' => 60, 'rows' => $catToEdit['nbline']));
  265. }
  266. $content_heading_form->addElement('submit', 'submitContent', get_lang('Ok'));
  267. $defaults = $catToEdit;
  268. $defaults['cntId'] = $catToEdit['contentId'];
  269. $defaults['uInfo'] = $userIdViewed;
  270. $content_heading_form->setDefaults($defaults);
  271. $content_heading_form->display();
  272. } elseif ($displayMode == "viewMainInfoEdit") {
  273. /* CATEGORIES MAIN INFO : EDIT */
  274. $mainUserInfo = get_main_user_info($userIdViewed, $courseCode);
  275. if ($mainUserInfo) {
  276. ($mainUserInfo['status'] == COURSEMANAGER) ? $courseAdminChecked = "checked" : $courseAdminChecked = "";
  277. if ($current_session_id) {
  278. ($is_session_course_coach)? $tutorChecked = "checked" : $tutorChecked = "";
  279. } else {
  280. ($mainUserInfo['tutor_id'] == 1) ? $tutorChecked = "checked" : $tutorChecked = "";
  281. }
  282. $image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true);
  283. // get the path,width and height from original picture
  284. $big_image = $image_array['dir'].'big_'.$image_array['file'];
  285. $big_image_size = api_getimagesize($big_image);
  286. $big_image_width= $big_image_size['width'];
  287. $big_image_height= $big_image_size['height'];
  288. $url_big_image = $big_image.'?rnd='.time();
  289. if ($image_array['file']=='unknown.jpg') {
  290. echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
  291. } else {
  292. echo '<input type="image" src="'.$image_array['dir'].$image_array['file'].'" onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
  293. }
  294. echo "<form action=\"".api_get_self()."\" method=\"post\">\n",
  295. "<input type=\"hidden\" name=\"submitMainUserInfo\" value=\"$userIdViewed\" />\n",
  296. "<table width=\"80%\" border=\"0\">",
  297. "<tr align=\"center\" bgcolor=\"#E6E6E6\">\n",
  298. "<td align=\"left\">", get_lang('Name'), "</td>\n",
  299. "<td width=\"100px\" align=\"left\">", get_lang('Description'), "</td>\n";
  300. if ($current_session_id) {
  301. if ($user_info_viewed['status'] == COURSEMANAGER) {
  302. echo "<td>", get_lang('Tutor'), "</td>\n";
  303. }
  304. } else {
  305. if ($user_info_viewed['status'] == STUDENT) {
  306. echo "<td>", get_lang('CourseAssistant'), "</td>\n";
  307. } else {
  308. echo "<td>", get_lang('CourseManager'), "</td>\n";
  309. }
  310. }
  311. echo "</tr>\n",
  312. "<tr align=\"center\">",
  313. "<td align=\"left\"><b>", htmlize(api_get_person_name($mainUserInfo['firstName'], $mainUserInfo['lastName'])), "</b></td>\n",
  314. "<td align=\"left\"><input type=\"text\" name =\"role\" value=\"", $mainUserInfo['role'], "\" maxlength=\"40\" /></td>";
  315. if (!($is_courseAdmin && $_user['user_id'] == $userIdViewed)) {
  316. if ($current_session_id) {
  317. if ($user_info_viewed['status'] == COURSEMANAGER) {
  318. echo "<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteTutor\" value=\"1\" ", $tutorChecked, " /></td>";
  319. }
  320. } else {
  321. if ($user_info_viewed['status'] == STUDENT) {
  322. echo "<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteTutor\" value=\"1\" ", $tutorChecked, " />" . ' ' . Display::return_icon('synthese_view.gif',get_lang('TheTutorOnlyCanKeepTrackOfStudentsRegisteredInTheCourse')),$checked,"</td>";
  323. } else {
  324. echo "<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteCourseAdmin\" value=\"1\"", $courseAdminChecked, " />" . ' ' . Display::return_icon('synthese_view.gif',get_lang('TheTeacherCanQualifyEvaluateAndKeepTrackOfAllStudentsEnrolledInTheCourse')),$checked,"</td>\n";
  325. }
  326. }
  327. } else {
  328. echo "<td>", get_lang('CourseManager'), "</td>\n";
  329. }
  330. echo "<td><button class=\"save\" type=\"submit\" name=\"submit\">".get_lang('SaveChanges')."</button></td>\n", "</tr>", "</table>", "</form>\n";
  331. if (api_get_setting('show_email_addresses') == 'true') {
  332. echo "<p>".Display :: encrypted_mailto_link($mainUserInfo['email'], $mainUserInfo['email'])."</p>";
  333. }
  334. if (api_get_setting('extended_profile') == 'true') {
  335. if (!empty($mainUserInfo['competences']))
  336. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div><div>'.$mainUserInfo['competences'].'</div>';
  337. if (!empty($mainUserInfo['diplomas']))
  338. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div><div>'.$mainUserInfo['diplomas'].'</div>';
  339. if (!empty($mainUserInfo['teach']))
  340. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyTeach').'</strong></div><div>'.$mainUserInfo['teach'].'</div>';
  341. if (!empty($mainUserInfo['openarea']))
  342. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div><div>'.$mainUserInfo['openarea'].'</div>';
  343. if (!empty($mainUserInfo['competences']))
  344. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyProductions').'</strong></div><div>'.UserManager::build_production_list($mainUserInfo['user_id']).'</div>';
  345. }
  346. } else {
  347. Display :: display_normal_message(get_lang('ThisStudentIsSubscribeThroughASession'));
  348. }
  349. } elseif ($displayMode == "viewContentList") {
  350. // default display
  351. $virtual_course_code = $_GET["virtual_course"];
  352. if (isset ($virtual_course_code)) {
  353. $courseCode = $virtual_course_code;
  354. //not supported yet: editing users of virtual courses
  355. $allowedToEditDef = false;
  356. }
  357. $mainUserInfo = get_main_user_info($userIdViewed, $courseCode);
  358. if ($mainUserInfo) {
  359. $image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true);
  360. // get the path,width and height from original picture
  361. $big_image = $image_array['dir'].'big_'.$image_array['file'];
  362. $big_image_size = api_getimagesize($big_image);
  363. $big_image_width= $big_image_size['width'];
  364. $big_image_height= $big_image_size['height'];
  365. $url_big_image = $big_image.'?rnd='.time();
  366. if ($image_array['file']=='unknown.jpg') {
  367. echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
  368. } else {
  369. echo '<input type="image" src="'.$image_array['dir'].$image_array['file'].'" onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
  370. }
  371. // is the user online?
  372. $online ='';
  373. if (user_is_online($userIdViewed)) {
  374. $online = Display::return_icon('online.gif', get_lang('OnLine'),array('style'=>'with="8"; height="8"'));
  375. }
  376. //DISPLAY TABLE HEADING
  377. if ($origin == 'learnpath') { $allowedToEditDef=false; $is_allowedToTrack=false; }
  378. //"<td>",get_lang('Tutor'),"</td>\n",
  379. echo "<table width=\"80%\" border=\"0\">",
  380. "<tr align=\"center\" bgcolor=\"#E6E6E6\">\n",
  381. "<td align=\"left\">".get_lang('Name')."</td>\n",
  382. "<td width=\"20%\" align=\"left\">".get_lang('Description')."</td>\n";
  383. if ($current_session_id) {
  384. if ($user_info_viewed['status'] == COURSEMANAGER) {
  385. echo "<td>".get_lang('Tutor')."</td>\n";
  386. }
  387. } else {
  388. if ($user_info_viewed['status'] == STUDENT) {
  389. echo "<td>".get_lang('Tutor')."</td>\n";
  390. } else {
  391. echo "<td>".get_lang('CourseManager')."</td>\n";
  392. }
  393. }
  394. //echo ($allowedToEditDef && api_get_setting('allow_user_course_subscription_by_course_admin') == 'true'?"<td>".get_lang('Edit')."</td>\n":"");
  395. //echo ($is_allowedToTrack?"<td>".get_lang('Tracking')."</td>\n":"");
  396. echo "</tr>\n",
  397. "<tr align=\"center\">\n",
  398. "<td align=\"left\"><b>".$online.' '.htmlize(api_get_person_name($mainUserInfo['firstName'], $mainUserInfo['lastName']))."</b></td>\n",
  399. "<td align=\"left\">".htmlize($mainUserInfo['role'])."</td>";
  400. //DISPLAY TABLE CONTENT
  401. if ($current_session_id) {
  402. if ($user_info_viewed['status'] == COURSEMANAGER) {
  403. if ($is_session_course_coach) {
  404. echo "<td>",get_lang('Tutor'),"</td>\n";
  405. } else {
  406. echo "<td> - </td>\n";
  407. }
  408. }
  409. } else {
  410. if ($user_info_viewed['status'] == STUDENT) {
  411. if ($mainUserInfo['tutor_id'] == 1) {
  412. echo "<td>",get_lang('Tutor'),"</td>\n";
  413. } else {
  414. echo "<td> - </td>\n";
  415. }
  416. } else {
  417. if ($mainUserInfo['status'] == 1) {
  418. echo "<td>",get_lang('CourseManager'),"</td>";
  419. } else {
  420. echo "<td> - </td>\n";
  421. }
  422. }
  423. }
  424. if ($allowedToEditDef && api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
  425. //echo "<td>";
  426. //echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&editMainUserInfo=$userIdViewed\"><img border=\"0\" alt=\"\" src=\"../img/edit.gif\" /></a>";
  427. //echo "</td>";
  428. }
  429. if ($is_allowedToTrack) {
  430. //echo "<td>";
  431. //echo "<a href=\"../mySpace/myStudents.php?".api_get_cidreq()."&origin=user_course&student=$userIdViewed&details=true&course=".$_course['id']."\"><img border=\"0\" alt=\"".get_lang('Tracking')." : $userIdViewed\" src=\"../img/statistics.gif\" /></a>";
  432. //echo "</td>";
  433. }
  434. echo "</tr></table>";
  435. if (api_get_setting("show_email_addresses") == "true") {
  436. echo "<p>". Display::encrypted_mailto_link($mainUserInfo['email'],$mainUserInfo['email']). "</p>";
  437. }
  438. if (api_get_setting('extended_profile') == 'true') {
  439. if (!empty($mainUserInfo['competences']))
  440. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div><div>'.$mainUserInfo['competences'].'</div>';
  441. if (!empty($mainUserInfo['diplomas']))
  442. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div><div>'.$mainUserInfo['diplomas'].'</div>';
  443. if (!empty($mainUserInfo['teach']))
  444. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyTeach').'</strong></div><div>'.$mainUserInfo['teach'].'</div>';
  445. if (!empty($mainUserInfo['openarea']))
  446. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div><div>'.$mainUserInfo['openarea'].'</div>';
  447. if (!empty($mainUserInfo['competences']))
  448. echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyProductions').'</strong></div><div>'.UserManager::build_production_list($mainUserInfo['user_id']).'</div>';
  449. }
  450. } else {
  451. Display :: display_normal_message(get_lang('ThisStudentIsSubscribeThroughASession'));
  452. }
  453. if (api_get_setting('allow_user_headings') == 'true' && $allowedToEditDef) // only course administrators see this line
  454. {
  455. echo "<div align=right>",
  456. "<form method=\"post\" action=\"".api_get_self()."\">",
  457. get_lang('CourseAdministratorOnly')," : ",
  458. "<input type=\"submit\" class=\"save\" name=\"viewDefList\" value=\"".get_lang('DefineHeadings')."\" />",
  459. "</form>",
  460. "<hr noshade size=\"1\" style=\"color:#99CCFF\">",
  461. "</div>\n";
  462. }
  463. $catList = get_course_user_info($userIdViewed);
  464. if ($catList)
  465. {
  466. foreach ($catList as $thisCat)
  467. {
  468. // Category title
  469. echo "<p><b>",$thisCat['title'],"</b></p>\n";
  470. // Category content
  471. echo "<blockquote>\n";
  472. if ($thisCat['content'])
  473. {
  474. echo htmlize($thisCat['content'])."\n";
  475. }
  476. else
  477. {
  478. echo "....";
  479. }
  480. // Edit command
  481. if ($allowedToEditContent)
  482. {
  483. echo "<br><br>\n",
  484. "<a href=\"".api_get_self()."?".api_get_cidreq()."&editContent=",$thisCat['catId'],"&uInfo=",$userIdViewed,"\">",
  485. "<img src=\"../img/edit.gif\" border=\"0\" alt=\"edit\">",
  486. "</a>\n";
  487. }
  488. echo "</blockquote>\n";
  489. }
  490. }
  491. }
  492. // Back button for each display mode (bottom)
  493. //echo "<div class=\"actions\"><a href=\"user.php?".api_get_cidreq()."&amp;origin=".$origin."\">".get_lang('BackUser')."</a></div>\n";
  494. /* FOOTER */
  495. Display :: display_footer();