profile.php 32 KB

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