userInfo.php 26 KB

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