profile.php 36 KB

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