profile.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2009 Dokeos SPRL
  6. Copyright (c) Julio Montoya Armas
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  15. Mail: info@dokeos.com
  16. ==============================================================================
  17. */
  18. /**
  19. ==============================================================================
  20. * This is the profile social main page
  21. * @author Julio Montoya <gugli100@gmail.com>
  22. =============================================================================
  23. */
  24. $language_file = array('registration','messages','userInfo','admin');
  25. $cidReset = true;
  26. require '../inc/global.inc.php';
  27. require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  28. require_once (api_get_path(LIBRARY_PATH).'social.lib.php');
  29. /*
  30. define(SOCIALUNKNOW,1);
  31. define(SOCIALPARENT,2);
  32. define(SOCIALFRIEND,3);
  33. define(SOCIALGOODFRIEND,4);
  34. define(SOCIALENEMY,5);
  35. define(SOCIALDELETED,6);
  36. */
  37. $user_id = api_get_user_id();
  38. $show_full_profile = true;
  39. //I'm your friend? I can see your profile?
  40. if (isset($_GET['u'])) {
  41. $user_id = (int) Database::escape_string($_GET['u']);
  42. // It's me!
  43. if (api_get_user_id() != $user_id) {
  44. $user_info = UserManager::get_user_info_by_id($user_id);
  45. $show_full_profile = false;
  46. if ($user_info==false) {
  47. // user does no exist !!
  48. api_not_allowed();
  49. } else {
  50. //checking the relationship between me and my friend
  51. $my_status= UserFriend::get_relation_between_contacts(api_get_user_id(), $user_id);
  52. if (in_array($my_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {
  53. $show_full_profile = true;
  54. }
  55. //checking the relationship between my friend and me
  56. $my_friend_status = UserFriend::get_relation_between_contacts($user_id, api_get_user_id());
  57. if (in_array($my_friend_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {
  58. $show_full_profile = true;
  59. } else {
  60. // im probably not a good friend
  61. $show_full_profile = false;
  62. }
  63. }
  64. } else {
  65. $user_info = UserManager::get_user_info_by_id($user_id);
  66. }
  67. } else {
  68. $user_info = UserManager::get_user_info_by_id($user_id);
  69. }
  70. require_once (api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php');
  71. require_once (api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php');
  72. require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
  73. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  74. api_block_anonymous_users();
  75. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  76. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.corners.min.js" type="text/javascript" language="javascript"></script>'; //jQuery corner
  77. $htmlHeadXtra[] = '<script type="text/javascript" src="../inc/lib/javascript/thickbox.js"></script>';
  78. $htmlHeadXtra[] = '<link rel="stylesheet" href="../inc/lib/javascript/thickbox.css" type="text/css" media="projection, screen">';
  79. $htmlHeadXtra[] = '
  80. <script type="text/javascript">
  81. function toogle_function (element_html, course_code){
  82. elem_id=$(element_html).attr("id");
  83. id_elem=elem_id.split("_");
  84. ident="div#div_group_"+id_elem[1];
  85. id_button="#btn_"+id_elem[1];
  86. elem_src=$(id_button).attr("src");
  87. image_show=elem_src.split("/");
  88. my_image=image_show[2];
  89. if (my_image=="nolines_plus.gif") {
  90. $(ident).hide("slow");
  91. $(id_button).attr("src","../img/nolines_minus.gif"); var action = "load_course";
  92. } else {
  93. $(ident).show("slow");
  94. $(id_button).attr("src","../img/nolines_plus.gif"); var action = "unload";
  95. }
  96. var content = \'social_content\' + id_elem[1];
  97. $.ajax({
  98. contentType: "application/x-www-form-urlencoded",
  99. beforeSend: function(objeto) {
  100. $("#id_response").html("'.get_lang('Loading').'"); },
  101. type: "POST",
  102. url: "../social/data_personal.inc.php",
  103. data: "load_ajax="+id_elem+"&action="+action+"&course_code="+course_code,
  104. success: function(datos) {
  105. //$("div#"+name_div_id).hide("slow");
  106. $("div#"+content).html(datos);
  107. }
  108. });
  109. }
  110. </script>';
  111. $htmlHeadXtra[] = '<script type="text/javascript">
  112. $(document).ready(function (){
  113. $("input#id_btn_send_invitation").bind("click", function(){
  114. if (confirm("'.get_lang('SendMessageInvitation').'")) {
  115. $("#form_register_friend").submit();
  116. }
  117. });
  118. });
  119. function change_panel (mypanel_id,myuser_id) {
  120. $.ajax({
  121. contentType: "application/x-www-form-urlencoded",
  122. beforeSend: function(objeto) {
  123. $("#id_content_panel").html("'.get_lang('Loading').'"); },
  124. type: "POST",
  125. url: "../messages/send_message.php",
  126. data: "panel_id="+mypanel_id+"&user_id="+myuser_id,
  127. success: function(datos) {
  128. $("div#id_content_panel_init").html(datos);
  129. $("div#display_response_id").html("");
  130. }
  131. });
  132. }
  133. function action_database_panel(option_id,myuser_id) {
  134. if (option_id==5) {
  135. my_txt_subject=$("#txt_subject_id").val();
  136. } else {
  137. my_txt_subject="clear";
  138. }
  139. my_txt_content=$("#txt_area_invite").val();
  140. if (my_txt_content.length==0 || my_txt_subject.length==0) {
  141. $("#display_response_id").html("&nbsp;&nbsp;&nbsp;'.get_lang('MessageInformationBySendMessage').'");
  142. setTimeout("message_information_display()",3000);
  143. return false;
  144. }
  145. $.ajax({
  146. contentType: "application/x-www-form-urlencoded",
  147. beforeSend: function(objeto) {
  148. $("#display_response_id").html("'.get_lang('Loading').'"); },
  149. type: "POST",
  150. url: "../messages/send_message.php",
  151. data: "panel_id="+option_id+"&user_id="+myuser_id+"&txt_subject="+my_txt_subject+"&txt_content="+my_txt_content,
  152. success: function(datos) {
  153. $("#display_response_id").html(datos);
  154. }
  155. });
  156. }
  157. function display_hide () {
  158. setTimeout("hide_display_message()",3000);
  159. }
  160. function message_information_display() {
  161. $("#display_response_id").html("");
  162. }
  163. function hide_display_message () {
  164. $("div#display_response_id").html("");
  165. try {
  166. $("#txt_subject_id").val("");
  167. $("#txt_area_invite").val("");
  168. }catch(e) {
  169. $("#txt_area_invite").val("");
  170. }
  171. }
  172. function register_friend(element_input) {
  173. if(confirm("'.get_lang('AddToContacts').'")) {
  174. name_button=$(element_input).attr("id");
  175. name_div_id="id_"+name_button.substring(13);
  176. user_id=name_div_id.split("_");
  177. user_friend_id=user_id[1];
  178. $.ajax({
  179. contentType: "application/x-www-form-urlencoded",
  180. beforeSend: function(objeto) {
  181. $("#id_response").html("'.get_lang('Loading').'"); },
  182. type: "POST",
  183. url: "../social/register_friend.php",
  184. data: "friend_id="+user_friend_id,
  185. success: function(datos) {
  186. $("div#id_response").html(datos);
  187. }
  188. });
  189. }
  190. }
  191. </script>';
  192. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('ModifyProfile') );
  193. $interbreadcrumb[]= array (
  194. 'url' => '../social/index.php?#remote-tab-1',
  195. 'name' => get_lang('ViewSharedProfile')
  196. );
  197. if (isset($_GET['u'])) {
  198. $info_user=api_get_user_info(api_get_user_id());
  199. $interbreadcrumb[]= array (
  200. 'url' => '../social/profile.php'.$param_user,
  201. 'name' => $info_user['firstName'].' '.$info_user['lastName']
  202. );
  203. }
  204. if (isset($_GET['u'])) {
  205. $info_user=api_get_user_info(Security::remove_XSS($_GET['u']));
  206. $param_user='?u='.Security::remove_XSS($_GET['u']);
  207. }else {
  208. $info_user=api_get_user_info(api_get_user_id());
  209. $param_user='';
  210. }
  211. $interbreadcrumb[]= array (
  212. 'url' => '../social/profile.php'.$param_user,
  213. 'name' => $info_user['firstName'].' '.$info_user['lastName']
  214. );
  215. $_SESSION['social_user_id'] = $user_id;
  216. function get_logged_user_course_html($my_course, $count) {
  217. global $nosession;
  218. if (api_get_setting('use_session_mode')=='true' && !$nosession) {
  219. global $now, $date_start, $date_end;
  220. }
  221. //initialise
  222. $result = '';
  223. // Table definitions
  224. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  225. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  226. $course_database = $my_course['db'];
  227. $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
  228. $tool_edit_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database);
  229. $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database);
  230. $user_id = api_get_user_id();
  231. $course_system_code = $my_course['k'];
  232. $course_visual_code = $my_course['c'];
  233. $course_title = $my_course['i'];
  234. $course_directory = $my_course['d'];
  235. $course_teacher = $my_course['t'];
  236. $course_teacher_email = isset($my_course['email'])?$my_course['email']:'';
  237. $course_info = Database :: get_course_info($course_system_code);
  238. $course_access_settings = CourseManager :: get_access_settings($course_system_code);
  239. $course_visibility = $course_access_settings['visibility'];
  240. $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code);
  241. //function logic - act on the data
  242. $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']);
  243. if ($is_virtual_course) {
  244. // If the current user is also subscribed in the real course to which this
  245. // virtual course is linked, we don't need to display the virtual course entry in
  246. // the course list - it is combined with the real course entry.
  247. $target_course_code = CourseManager :: get_target_of_linked_course($course_system_code);
  248. $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code);
  249. if ($is_subscribed_in_target_course) {
  250. return; //do not display this course entry
  251. }
  252. }
  253. $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id());
  254. if ($has_virtual_courses) {
  255. $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info);
  256. $course_display_title = $return_result['title'];
  257. $course_display_code = $return_result['code'];
  258. } else {
  259. $course_display_title = $course_title;
  260. $course_display_code = $course_visual_code;
  261. }
  262. $s_course_status=$my_course['s'];
  263. $s_htlm_status_icon="";
  264. if ($s_course_status==1) {
  265. $s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher'));
  266. }
  267. if ($s_course_status==2) {
  268. $s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach'));
  269. }
  270. if ($s_course_status==5) {
  271. $s_htlm_status_icon=Display::return_icon('students.gif', get_lang('Student'));
  272. }
  273. //display course entry
  274. $result .= '<div id="div_'.$count.'">';
  275. //$result .= '<a id="btn_'.$count.'" href="#" onclick="toogle_function(this,\''.$course_database.'\')">';
  276. $result .= '<h2><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_function(this,\''.$course_database.'\' )">';
  277. $result .= $s_htlm_status_icon;
  278. //show a hyperlink to the course, unless the course is closed and user is not course admin
  279. if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
  280. $result .= '<a href="#" id="ln_'.$count.'" onclick=toogle_function(this,\''.$course_database.'\');>&nbsp;'.$course_title.'</a></h2>';
  281. /*
  282. if(api_get_setting('use_session_mode')=='true' && !$nosession) {
  283. if(empty($my_course['id_session'])) {
  284. $my_course['id_session'] = 0;
  285. }
  286. if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') {
  287. //$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
  288. $result .= '<a href="#">'.$course_display_title.'</a>';
  289. }
  290. } else {
  291. //$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
  292. $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
  293. }*/
  294. } else {
  295. $result .= $course_display_title." "." ".get_lang('CourseClosed')."";
  296. }
  297. // show the course_code and teacher if chosen to display this
  298. // we dont need this!
  299. /*
  300. if (get_setting('display_coursecode_in_courselist') == 'true' OR get_setting('display_teacher_in_courselist') == 'true') {
  301. $result .= '<br />';
  302. }
  303. if (get_setting('display_coursecode_in_courselist') == 'true') {
  304. $result .= $course_display_code;
  305. }
  306. if (get_setting('display_coursecode_in_courselist') == 'true' AND get_setting('display_teacher_in_courselist') == 'true') {
  307. $result .= ' &ndash; ';
  308. }
  309. if (get_setting('display_teacher_in_courselist') == 'true') {
  310. $result .= $course_teacher;
  311. if(!empty($course_teacher_email)) {
  312. $result .= ' ('.$course_teacher_email.')';
  313. }
  314. }
  315. */
  316. $current_course_settings = CourseManager :: get_access_settings($my_course['k']);
  317. // display the what's new icons
  318. // $result .= show_notification($my_course);
  319. if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) {
  320. reset($digest);
  321. $result .= '<ul>';
  322. while (list ($key2) = each($digest[$thisCourseSysCode])) {
  323. $result .= '<li>';
  324. if ($orderKey[1] == 'keyTools') {
  325. $result .= "<a href=\"$toolsList[$key2] [\"path\"] $thisCourseSysCode \">";
  326. $result .= "$toolsList[$key2][\"name\"]</a>";
  327. } else {
  328. $result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2));
  329. }
  330. $result .= '</li>';
  331. $result .= '<ul>';
  332. reset($digest[$thisCourseSysCode][$key2]);
  333. while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2])) {
  334. $result .= '<li>';
  335. if ($orderKey[2] == 'keyTools') {
  336. $result .= "<a href=\"$toolsList[$key3] [\"path\"] $thisCourseSysCode \">";
  337. $result .= "$toolsList[$key3][\"name\"]</a>";
  338. } else {
  339. $result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3));
  340. }
  341. $result .= '<ul compact="compact">';
  342. reset($digest[$thisCourseSysCode][$key2][$key3]);
  343. while (list ($key4, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2][$key3])) {
  344. $result .= '<li>';
  345. $result .= htmlspecialchars(substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
  346. $result .= '</li>';
  347. }
  348. $result .= '</ul>';
  349. $result .= '</li>';
  350. }
  351. $result .= '</ul>';
  352. $result .= '</li>';
  353. }
  354. $result .= '</ul>';
  355. }
  356. $result .= '</li>';
  357. $result .= '</div>';
  358. if (api_get_setting('use_session_mode')=='true' && !$nosession) {
  359. $session = '';
  360. $active = false;
  361. if (!empty($my_course['session_name'])) {
  362. // Request for the name of the general coach
  363. $sql = 'SELECT lastname, firstname
  364. FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table .' tu
  365. ON ts.id_coach = tu.user_id
  366. WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1';
  367. $rs = api_sql_query($sql, __FILE__, __LINE__);
  368. $sessioncoach = api_store_result($rs);
  369. $sessioncoach = $sessioncoach[0];
  370. $session = array();
  371. $session['title'] = $my_course['session_name'];
  372. if ( $my_course['date_start']=='0000-00-00' ) {
  373. $session['dates'] = get_lang('WithoutTimeLimits');
  374. if ( api_get_setting('show_session_coach') === 'true' ) {
  375. $session['coach'] = get_lang('GeneralCoach').': '.$sessioncoach['lastname'].' '.$sessioncoach['firstname'];
  376. }
  377. $active = true;
  378. } else {
  379. $session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
  380. if ( api_get_setting('show_session_coach') === 'true' ) {
  381. $session['coach'] = get_lang('GeneralCoach').': '.$sessioncoach['lastname'].' '.$sessioncoach['firstname'];
  382. }
  383. $active = ($date_start <= $now && $date_end >= $now)?true:false;
  384. }
  385. }
  386. $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
  387. } else {
  388. $output = array ($my_course['user_course_cat'], $result);
  389. }
  390. return $output;
  391. }
  392. Display :: display_header(null);
  393. // @todo here we must show the user information as read only
  394. //User picture size is calculated from SYSTEM path
  395. $img_array= UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
  396. //print_r($user_info);
  397. echo $s="<script>$(document).ready( function(){
  398. $('.rounded').corners();
  399. });</script>";
  400. //echo '<div id="actions">';
  401. //echo '<a href="../auth/profile.php?show=1"">'.Display::return_icon('edit.gif').'&nbsp;'.mb_convert_encoding(get_lang('EditInformation'),'UTF-8',$charset).'</a>';
  402. //echo '</div>';
  403. //Setting some course info
  404. $personal_course_list = UserManager::get_personal_session_course_list($_user['user_id']);
  405. $course_list_code = array();
  406. $i=1;
  407. //print_r($personal_course_list);
  408. foreach ($personal_course_list as $my_course) {
  409. $list[] = get_logged_user_course_html($my_course,$i);
  410. $course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db'], 'title'=>$my_course['i']);
  411. $i++;
  412. }
  413. echo '<div id="social-profile-wrapper">';
  414. // RIGHT COLUMN
  415. echo '<div id="social-profile-right">';
  416. //---- FRIENDS
  417. if ($show_full_profile) {
  418. $list_path_friends= $list_path_normal_friends = $list_path_parents = array();
  419. $list_path_good_friends = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALGOODFRIEND);
  420. $list_path_normal_friends = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALFRIEND);
  421. $list_path_parents = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALPARENT);
  422. $list_path_friends = array_merge_recursive($list_path_good_friends, $list_path_normal_friends, $list_path_parents);
  423. $friend_html='';
  424. $number_of_images=3;
  425. $number_friends=0;
  426. $list_friends_id=array();
  427. $list_friends_dir=array();
  428. $list_friends_file=array();
  429. if (count($list_path_friends)!=0) {
  430. $friends_count = count($list_path_friends['id_friend']);
  431. for ($z=0;$z< $friends_count ;$z++) {
  432. $list_friends_id[] = $list_path_friends['id_friend'][$z]['friend_user_id'];
  433. $list_friends_dir[] = $list_path_friends['path_friend'][$z]['dir'];
  434. $list_friends_file[]= $list_path_friends['path_friend'][$z]['file'];
  435. }
  436. $number_friends= count($list_friends_dir);
  437. $number_loop = ($number_friends/$number_of_images);
  438. $loop_friends = ceil($number_loop);
  439. $j=0;
  440. $friend_html.= '<div id="friend-container">';
  441. //$friend_html .= api_display_tool_title(get_lang('Friends'));
  442. $friend_html.= '<div id="friend-header">';
  443. //$friend_html.= $friends_count.' '.get_lang('Friends');
  444. if ($friends_count == 1)
  445. $friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friend').'</div>';
  446. else
  447. $friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friends').'</div>';
  448. $friend_html.= '<div style="float:right;">'.get_lang('SeeAll').'</div>';
  449. $friend_html.= '</div><br/>'; // close div friend-header
  450. for ($k=0;$k<$loop_friends;$k++) {
  451. if ($j==$number_of_images) {
  452. $number_of_images=$number_of_images*2;
  453. }
  454. while ($j<$number_of_images) {
  455. if ($list_friends_file[$j]<>"") {
  456. $my_user_info=api_get_user_info($list_friends_id[$j]);
  457. $name_user=$my_user_info['firstName'].' '.$my_user_info['lastName'];
  458. //class="image-social-content"
  459. $friend_html.='&nbsp;<div id=div_'.$list_friends_id[$j].' style="float:left;" >';
  460. $margin_top = 10;
  461. if ($k==0) $margin_top = 0;
  462. $friend_html.='<a href="profile.php?u='.$list_friends_id[$j].'">';
  463. $friend_html.='<img src="'.$list_friends_dir[$j]."/".$list_friends_file[$j].'" width="90px" height="110px" style="margin-left:3px;margin-right:3px;margin-top:'.$margin_top.'px;margin-bottom:3px;" id="imgfriend_'.$list_friends_id[$j].'" title="'.$name_user.'" />';
  464. $friend_html.= '<br />'.$my_user_info['firstName'].'<br />'.$my_user_info['lastName'];
  465. $friend_html.= '</a>';
  466. $friend_html.= '</div>&nbsp;';
  467. }
  468. $j++;
  469. }
  470. }
  471. //$friend_html.='</div>'; // close the div friend-container
  472. }
  473. $friend_html.= '</div>';
  474. echo $friend_html;
  475. //Pending invitations
  476. $pending_invitations = UserFriend::get_list_invitation_of_friends_by_user_id($user_id);
  477. $list_get_path_web=UserFriend::get_list_web_path_user_invitation_by_user_id($user_id);
  478. $count_pending_invitations = count($pending_invitations);
  479. echo '<div class="clear"></div><br />';
  480. //javascript:register_friend(this)
  481. /*echo '<div id="social-profile-invitations" style="width:240px;" >';
  482. if ($count_pending_invitations > 0) {
  483. api_display_tool_title(get_lang('PendingInvitations'));
  484. for ($i=0;$i<$count_pending_invitations;$i++) {
  485. //var_dump($invitations);
  486. echo '<div style="width:240px;">';
  487. echo '<div style="float:left;width:60px;" >';
  488. echo '<img src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
  489. echo '</div>';
  490. echo '<div style="padding-left:70px;">';
  491. echo ' '.substr($pending_invitations[$i]['content'],19);
  492. echo '<br />';
  493. echo '<a id="btn_accepted_'.$pending_invitations[$i]['user_sender_id'].'" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('AddToFriends').'</a>';
  494. echo '<div id="id_response">&nbsp;</div>';
  495. echo '</div>';
  496. echo '</div>';
  497. echo '<div class="clear"></div>';
  498. }
  499. }
  500. echo '</div>'; */
  501. echo '<div class="clear"></div><br />';
  502. //--Productions
  503. $production_list = UserManager::build_production_list($user_id);
  504. if (!empty($production_list )) {
  505. api_display_tool_title(get_lang('Productions'));
  506. echo '<div class="rounded1">';
  507. echo $production_list;
  508. echo '</div>';
  509. }
  510. // Images uploaded by course
  511. $file_list = '';
  512. foreach ($course_list_code as $course) {
  513. $file_list.= UserManager::get_user_upload_files_by_course($user_id,$course['code']);
  514. }
  515. if (!empty($file_list)) {
  516. api_display_tool_title(get_lang('ImagesUploaded'));
  517. echo '<div class="rounded2">';
  518. echo $file_list;
  519. echo '</div>';
  520. }
  521. }
  522. echo '</div>'; // end of content section
  523. // echo '</div>';
  524. echo '<div id="social-profile-container">';
  525. // LEFT COLUMN
  526. echo '<div id="social-profile-left">';
  527. //--- User image
  528. echo '<img src='.$img_array['dir'].$img_array['file'].' /> <br /><br />';
  529. if (api_get_user_id() == $user_id) {
  530. // if i'm me
  531. echo Display::return_icon('email.gif');
  532. echo '&nbsp;&nbsp;<a href="../social/index.php#remote-tab-2">'.get_lang('MyInbox').'</a><br />';
  533. echo Display::return_icon('edit.gif');
  534. echo '&nbsp;&nbsp;<a href="../auth/profile.php?show=1">'.get_lang('EditInformation').'</a>';
  535. } else {
  536. echo '&nbsp;&nbsp;<a href="../messages/send_message_to_userfriend.inc.php?height=365&width=610&user_friend='.$user_id.'&view=profile" class="thickbox" title="'.get_lang('SendMessage').'">'.Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />';
  537. //echo '&nbsp;&nbsp;<a href="#">'.get_lang('SendMessage').'</a>';
  538. }
  539. echo '<br /><br />';
  540. // Send message or Add to friend links
  541. /*if (!$show_full_profile) {
  542. echo '&nbsp;&nbsp;<a href="../messages/send_message_to_userfriend.inc.php?height=365&width=610&user_friend='.$user_id.'&view=profile" class="thickbox" title="'.get_lang('SendMessage').'">'.Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />';
  543. }*/
  544. if ($show_full_profile) {
  545. //-- Extra Data
  546. api_display_tool_title(get_lang('ExtraInformation'));
  547. $extra_user_data = UserManager::get_extra_user_data($user_id);
  548. echo '<div class="rounded left-side">';
  549. foreach($extra_user_data as $key=>$data) {
  550. echo ucfirst($key).': '.$data;
  551. echo '<br />';
  552. }
  553. echo '</div>';
  554. echo '<br /><br />';
  555. // ---- My Agenda Items
  556. api_display_tool_title(get_lang('MyAgenda'));
  557. $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
  558. echo '<div class="rounded left-side">';
  559. echo show_simple_personal_agenda($user_id);
  560. echo '</div>';
  561. echo '<br /><br />';
  562. //-----Announcements
  563. api_display_tool_title(get_lang('Announcements'));
  564. foreach ($course_list_code as $course) {
  565. echo '<h2>'.$course['title'].'</h2>';
  566. echo '<div class="rounded left-side">';
  567. get_all_annoucement_by_user_course($course['dbName'],$user_id);
  568. echo '</div>';
  569. echo '<br/>';
  570. }
  571. }
  572. echo '</div>';
  573. // CENTER COLUMN
  574. echo '<div id="social-profile-content">';
  575. //--- Basic Information
  576. api_display_tool_title(get_lang('Information')); //class="social-profile-info"
  577. if ($show_full_profile) {
  578. echo '<div class="social-profile-info" >';
  579. echo '<dl>';
  580. echo '<dt>'.mb_convert_encoding(get_lang('UserName'),'UTF-8',$charset).'</dt> <dd>'. mb_convert_encoding($user_info['username'],'UTF-8',$charset).' </dd>';
  581. if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
  582. echo '<dt>'.mb_convert_encoding(get_lang('Name'),'UTF-8',$charset).'</dt> <dd>'. mb_convert_encoding($user_info['firstname'].' '.$user_info['lastname'],'UTF-8',$charset).'</dd>';
  583. if (!empty($user_info['official_code']))
  584. echo '<dt>'.mb_convert_encoding(get_lang('OfficialCode'),'UTF-8',$charset).'</dt> <dd>'. mb_convert_encoding($user_info['official_code'],'UTF-8',$charset).'</dd>';
  585. if (!empty($user_info['email']))
  586. if (api_get_setting('show_email_addresses')=='true')
  587. echo '<dt>'.mb_convert_encoding(get_lang('Email'),'UTF-8',$charset).'</dt> <dd>'. mb_convert_encoding($user_info['email'],'UTF-8',$charset).'</dd>';
  588. if (!empty($user_info['phone']))
  589. echo '<dt>'.mb_convert_encoding(get_lang('Phone'),'UTF-8',$charset).'</dt> <dd>'. mb_convert_encoding($user_info['phone'],'UTF-8',$charset).'</dd>';
  590. echo '</dl>';
  591. echo '</div>';
  592. } else {
  593. echo '<div class="social-profile-info" >';
  594. echo '<dl>';
  595. if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
  596. echo '<dt>'.mb_convert_encoding(get_lang('Name'),'UTF-8',$charset).'</dt> <dd>'. mb_convert_encoding($user_info['firstname'].' '.$user_info['lastname'],'UTF-8',$charset).'</dd>';
  597. echo '</dl>';
  598. echo '</div>';
  599. }
  600. echo '<div class="clear"></div><br />';
  601. // COURSES LIST
  602. if ($show_full_profile) {
  603. api_display_tool_title(ucfirst(get_lang('Courses')));
  604. //print_r($personal_course_list);
  605. //echo '<pre>';
  606. if ( is_array($list) ) {
  607. //Courses whithout sessions
  608. $old_user_category = 0;
  609. $i=1;
  610. foreach($list as $key=>$value) {
  611. if ( empty($value[2]) ) { //if out of any session
  612. echo $value[1];
  613. echo '<div id="loading'.$i.'"></div>';
  614. //class="social-profile-rounded maincourse"
  615. echo '<div id="social_content'.$i.'" class="rounded maincourse" style="background : #EFEFEF; padding:0px; ">';
  616. echo '</div>';
  617. $i++;
  618. }
  619. }
  620. $listActives = $listInactives = $listCourses = array();
  621. foreach ( $list as $key=>$value ) {
  622. if ( $value['active'] ) { //if the session is still active (as told by get_logged_user_course_html())
  623. $listActives[] = $value;
  624. } elseif ( !empty($value[2]) ) { //if there is a session but it is not active
  625. $listInactives[] = $value;
  626. }
  627. }
  628. /*
  629. // --- Session registered
  630. api_display_tool_title(get_lang('Sessions'));
  631. if(count($listActives)>0) {
  632. echo "<ul class=\"courseslist\">\n";
  633. foreach ($listActives as $key => $value) {
  634. if (!empty($value[2])) {
  635. if ((isset($old_session) && $old_session != $value[2]) or ((!isset($old_session)) && isset($value[2]))) {
  636. $old_session = $value[2];
  637. if ($key != 0) {
  638. echo '</ul>';
  639. }
  640. //echo '<ul class="session_box"><li class="session_box_title">'.$value[3]['title'].' '.$value[3]['dates'].'</li>';
  641. echo '<ul>';
  642. if ( !empty($value[3]['coach']) ) {
  643. echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>';
  644. }
  645. echo '</ul>';
  646. echo '<ul class="session_course_item">';
  647. }
  648. }
  649. echo $value[1];
  650. }
  651. echo '</ul>';
  652. }
  653. */
  654. }
  655. echo '</ul>';
  656. //echo '<pre>';
  657. foreach ($course_list_code as $course) {
  658. // course name
  659. //echo ucfirst(get_lang('InCourse')).' '.$course['code'].'<br /><br />';
  660. /*
  661. //------Blog posts
  662. api_display_tool_title(get_lang('BlogPosts'));
  663. echo '<div class="rounded social-profile-post">';
  664. get_blog_post_from_user($course['dbName'], $user_id);
  665. echo '</div>';
  666. echo '<br />';
  667. //------Blog comments
  668. api_display_tool_title(get_lang('BlogComments'));
  669. echo '<div class="rounded" social-profile-post >';
  670. get_blog_comment_from_user($course['dbName'], $user_id);
  671. echo '</div>';
  672. echo '<br />';
  673. //------Forum messages
  674. api_display_tool_title(get_lang('Forum'));
  675. //print_r($course);
  676. $table_forums = Database :: get_course_table(TABLE_FORUM,$course['dbName']);
  677. $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD,$course['dbName']);
  678. $table_posts = Database :: get_course_table(TABLE_FORUM_POST,$course['dbName']);
  679. $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course['dbName']);
  680. $table_users = Database :: get_main_table(TABLE_MAIN_USER);
  681. echo '<div class="rounded social-profile-post">';
  682. get_all_post_from_user($user_id);
  683. echo '</div>';
  684. echo '<br />';
  685. */
  686. }
  687. echo '<br />';
  688. /* this should be somewhere
  689. //-- Competences
  690. api_display_tool_title(get_lang('MoreInfo'));
  691. echo '<br />';
  692. echo get_lang('Competences');
  693. echo '<div class="rounded social-profile-post">';
  694. echo $user_info['competences']; echo '<br />';
  695. echo '</div>';
  696. echo get_lang('Diplomas');
  697. echo '<div class="rounded social-profile-post">';
  698. echo $user_info['diplomas']; echo '<br />';
  699. echo '</div>';
  700. echo get_lang('OpenArea');
  701. echo '<div class="rounded social-profile-post">';
  702. echo $user_info['openarea']; echo '<br />';
  703. echo '</div>';
  704. echo get_lang('Teach');
  705. echo '<div class="rounded social-profile-post">';
  706. echo $user_info['teach']; echo '<br />';
  707. echo '</div>';
  708. */
  709. echo '</div>';
  710. }
  711. echo '</div>';
  712. echo '</div>';
  713. echo '</div>'; //from the main
  714. Display :: display_footer();
  715. ?>