profile.php 32 KB

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