profile.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <?php
  2. /* For licensing terms, see /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 chamilo.social
  8. */
  9. $language_file = array('userInfo', 'index');
  10. $cidReset = true;
  11. require_once '../inc/global.inc.php';
  12. if (api_get_setting('allow_social_tool') !='true') {
  13. $url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']);
  14. header('Location: '.$url);
  15. exit;
  16. }
  17. $user_id = api_get_user_id();
  18. $show_full_profile = true;
  19. //social tab
  20. $this_section = SECTION_SOCIAL;
  21. //I'm your friend? I can see your profile?
  22. if (isset($_GET['u'])) {
  23. $user_id = (int) Database::escape_string($_GET['u']);
  24. if (api_is_anonymous($user_id, true)) {
  25. api_not_allowed(true);
  26. }
  27. // It's me!
  28. if (api_get_user_id() != $user_id) {
  29. $user_info = UserManager::get_user_info_by_id($user_id);
  30. $show_full_profile = false;
  31. if (!$user_info) {
  32. // user does no exist !!
  33. api_not_allowed(true);
  34. } else {
  35. //checking the relationship between me and my friend
  36. $my_status= SocialManager::get_relation_between_contacts(api_get_user_id(), $user_id);
  37. if (in_array($my_status, array(USER_RELATION_TYPE_PARENT, USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_GOODFRIEND))) {
  38. $show_full_profile = true;
  39. }
  40. //checking the relationship between my friend and me
  41. $my_friend_status = SocialManager::get_relation_between_contacts($user_id, api_get_user_id());
  42. if (in_array($my_friend_status, array(USER_RELATION_TYPE_PARENT, USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_GOODFRIEND))) {
  43. $show_full_profile = true;
  44. } else {
  45. // im probably not a good friend
  46. $show_full_profile = false;
  47. }
  48. }
  49. } else {
  50. $user_info = UserManager::get_user_info_by_id($user_id);
  51. }
  52. } else {
  53. $user_info = UserManager::get_user_info_by_id($user_id);
  54. }
  55. $libpath = api_get_path(LIBRARY_PATH);
  56. require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
  57. require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php';
  58. require_once $libpath.'magpierss/rss_fetch.inc';
  59. $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
  60. api_block_anonymous_users();
  61. $htmlHeadXtra[] = '<script>
  62. function checkLength( o, n, min, max ) {
  63. if ( o.val().length > max || o.val().length < min ) {
  64. o.addClass( "ui-state-error" );
  65. //updateTips( "Length of " + n + " must be between " + min + " and " + max + "." );
  66. return false;
  67. } else {
  68. return true;
  69. }
  70. }
  71. function send_message_to_user(user_id) {
  72. var subject = $( "#subject_id" );
  73. var content = $( "#content_id" );
  74. $("#send_message_form").show();
  75. $("#send_message_div").dialog({
  76. modal:true,
  77. height:350,
  78. buttons: {
  79. "'. addslashes(get_lang('Sent')).'": function() {
  80. var bValid = true;
  81. bValid = bValid && checkLength( subject, "subject", 1, 255 );
  82. bValid = bValid && checkLength( content, "content", 1, 255 );
  83. if ( bValid ) {
  84. var url = "'.$ajax_url.'?a=send_message&user_id="+user_id;
  85. var params = $("#send_message_form").serialize();
  86. $.ajax({
  87. url: url+"&"+params,
  88. success:function(data) {
  89. $("#message_ajax_reponse").html(data);
  90. $("#message_ajax_reponse").show();
  91. $("#send_message_div").dialog({ buttons:{}});
  92. $("#send_message_form").hide();
  93. $("#send_message_div").dialog("close");
  94. $("#subject_id").val("");
  95. $("#content_id").val("");
  96. }
  97. });
  98. }
  99. },
  100. },
  101. close: function() {
  102. }
  103. });
  104. $("#send_message_div").dialog("open");
  105. //prevent the browser to follow the link
  106. }
  107. function send_invitation_to_user(user_id) {
  108. var content = $( "#content_invitation_id" );
  109. $("#send_invitation_form").show();
  110. $("#send_invitation_div").dialog({
  111. modal:true,
  112. buttons: {
  113. "'. addslashes(get_lang('SendInvitation')).'": function() {
  114. var bValid = true;
  115. bValid = bValid && checkLength( content, "content", 1, 255 );
  116. if (bValid) {
  117. var url = "'.$ajax_url.'?a=send_invitation&user_id="+user_id;
  118. var params = $("#send_invitation_form").serialize();
  119. $.ajax({
  120. url: url+"&"+params,
  121. success:function(data) {
  122. $("#message_ajax_reponse").html(data);
  123. $("#message_ajax_reponse").show();
  124. $("#send_invitation_div").dialog({ buttons:{}});
  125. $("#send_invitation_form").hide();
  126. $("#send_invitation_div").dialog("close");
  127. $("#content_invitation_id").val("");
  128. }
  129. });
  130. }
  131. },
  132. },
  133. close: function() {
  134. }
  135. });
  136. $("#send_invitation_div").dialog("open");
  137. //prevent the browser to follow the link
  138. }
  139. function toogle_course (element_html, course_code){
  140. elem_id=$(element_html).attr("id");
  141. id_elem=elem_id.split("_");
  142. ident="div#div_group_"+id_elem[1];
  143. id_button="#btn_"+id_elem[1];
  144. elem_src=$(id_button).attr("src");
  145. image_show=elem_src.split("/");
  146. my_image=image_show[2];
  147. var content = \'social_content\' + id_elem[1];
  148. if (my_image=="nolines_plus.gif") {
  149. $(id_button).attr("src","../img/nolines_minus.gif"); var action = "load_course";
  150. $("div#"+content).show("fast");
  151. } else {
  152. $("div#"+content).hide("fast");
  153. $(id_button).attr("src","../img/nolines_plus.gif"); var action = "unload";
  154. return false;
  155. }
  156. $.ajax({
  157. contentType: "application/x-www-form-urlencoded",
  158. beforeSend: function(objeto) {
  159. $("div#"+content).html("<img src=\'../inc/lib/javascript/indicator.gif\' />"); },
  160. type: "POST",
  161. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=toogle_course",
  162. data: "load_ajax="+id_elem+"&action="+action+"&course_code="+course_code,
  163. success: function(datos) {
  164. $("div#"+content).html(datos);
  165. }
  166. });
  167. }
  168. $(document).ready(function (){
  169. $("input#id_btn_send_invitation").bind("click", function(){
  170. if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
  171. $("#form_register_friend").submit();
  172. }
  173. });
  174. $("#send_message_div").dialog({
  175. autoOpen: false,
  176. modal : false,
  177. width : 550,
  178. height : 300
  179. });
  180. $("#send_invitation_div").dialog({
  181. autoOpen: false,
  182. modal : false,
  183. width : 550,
  184. height : 300
  185. });
  186. });
  187. function display_hide () {
  188. setTimeout("hide_display_message()",3000);
  189. }
  190. function hide_display_message () {
  191. $("div#display_response_id").html("");
  192. try {
  193. $("#txt_subject_id").val("");
  194. $("#txt_area_invite").val("");
  195. }catch(e) {
  196. $("#txt_area_invite").val("");
  197. }
  198. }
  199. function register_friend(element_input) {
  200. if(confirm("'.get_lang('AddToFriends').'")) {
  201. name_button=$(element_input).attr("id");
  202. name_div_id="id_"+name_button.substring(13);
  203. user_id=name_div_id.split("_");
  204. user_friend_id=user_id[1];
  205. $.ajax({
  206. contentType: "application/x-www-form-urlencoded",
  207. beforeSend: function(objeto) {
  208. $("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />");
  209. },
  210. type: "POST",
  211. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=add_friend",
  212. data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
  213. success: function(datos) {
  214. $("#dpending_" + user_friend_id).html(datos);
  215. }
  216. });
  217. }
  218. }
  219. </script>';
  220. $nametool = get_lang('ViewMySharedProfile');
  221. if (isset($_GET['shared'])) {
  222. $my_link='../social/profile.php';
  223. $link_shared='shared='.Security::remove_XSS($_GET['shared']);
  224. } else {
  225. $my_link='../social/profile.php';
  226. $link_shared='';
  227. }
  228. $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('SocialNetwork') );
  229. if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) {
  230. $info_user = api_get_user_info($_GET['u']);
  231. $interbreadcrumb[]= array ('url' => '#','name' => api_get_person_name($info_user['firstName'], $info_user['lastName']));
  232. $nametool = '';
  233. }
  234. if (isset($_GET['u'])) {
  235. $param_user='u='.Security::remove_XSS($_GET['u']);
  236. }else {
  237. $info_user = api_get_user_info(api_get_user_id());
  238. $param_user = '';
  239. }
  240. $_SESSION['social_user_id'] = intval($user_id);
  241. /**
  242. * Display
  243. */
  244. //Setting some course info
  245. $my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
  246. $personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
  247. $course_list_code = array();
  248. $i=1;
  249. if (is_array($personal_course_list)) {
  250. foreach ($personal_course_list as $my_course) {
  251. if ($i<=10) {
  252. $list[] = SocialManager::get_logged_user_course_html($my_course, $i);
  253. $course_list_code[] = array('code'=> $my_course['code']);
  254. } else {
  255. break;
  256. }
  257. $i++;
  258. }
  259. //to avoid repeted courses
  260. $course_list_code = array_unique_dimensional($course_list_code);
  261. }
  262. $social_left_content = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
  263. $personal_info = null;
  264. if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
  265. $personal_info .= '<div><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
  266. } else {
  267. //--- Basic Information
  268. $personal_info .= '<div><h3>'.get_lang('Profile').'</h3></div>';
  269. }
  270. if ($show_full_profile) {
  271. $personal_info .= '<dl class="dl-horizontal">';
  272. $personal_info .= '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].' </dd>';
  273. if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
  274. $personal_info .= '<dt>'.get_lang('Name').'</dt><dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';
  275. if (!empty($user_info['official_code']))
  276. $personal_info .= '<dt>'.get_lang('OfficialCode').'</dt><dd>'.$user_info['official_code'].'</dd>';
  277. if (!empty($user_info['email']))
  278. if (api_get_setting('show_email_addresses')=='true')
  279. $personal_info .= '<dt>'.get_lang('Email').'</dt><dd>'.$user_info['email'].'</dd>';
  280. if (!empty($user_info['phone']))
  281. $personal_info .= '<dt>'.get_lang('Phone').'</dt><dd>'. $user_info['phone'].'</dd>';
  282. $personal_info .= '</dl>';
  283. } else {
  284. $personal_info .= '<dl class="dl-horizontal">';
  285. if (!empty($user_info['username']))
  286. $personal_info .= '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].'</dd>';
  287. $personal_info .= '</dl>';
  288. }
  289. $social_right_content = SocialManager::social_wrapper_div($personal_info, 4);
  290. if ($show_full_profile) {
  291. //SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
  292. $friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
  293. $friend_html = '';
  294. $number_of_images = 6;
  295. $number_friends = 0;
  296. $number_friends = count($friends);
  297. if ($number_friends != 0) {
  298. $friend_html.= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
  299. $friend_html.= '<div id="friend-container" class="social-friend-container">';
  300. $friend_html.= '<div id="friend-header">';
  301. if ($number_friends == 1) {
  302. $friend_html.= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friend').'</div>';
  303. } else {
  304. $friend_html.= '<div style="float:left;width:80%">'.$number_friends.' '.get_lang('Friends').'</div>';
  305. }
  306. if ($number_friends > $number_of_images) {
  307. if (api_get_user_id() == $user_id) {
  308. $friend_html.= '<div style="float:right;width:20%"><a href="friends.php">'.get_lang('SeeAll').'</a></div>';
  309. } else {
  310. $friend_html.= '<div style="float:right;width:20%"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=friends&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></div>';
  311. }
  312. }
  313. $friend_html.= '</div>'; // close div friend-header
  314. $friend_html.='<ul class="thumbnails">';
  315. $j=1;
  316. for ($k=0;$k<$number_friends;$k++) {
  317. if ($j > $number_of_images) break;
  318. if (isset($friends[$k])) {
  319. $friend = $friends[$k];
  320. $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
  321. $user_info_friend = api_get_user_info($friend['friend_user_id'], true);
  322. if ($user_info_friend['user_is_online']) {
  323. $status_icon = Display::span('', array('class' => 'online_user_in_text'));
  324. } else {
  325. $status_icon = Display::span('', array('class' => 'offline_user_in_text'));
  326. }
  327. $friend_html.= '<li class="span2">';
  328. $friend_html.= '<div class="thumbnail">';
  329. // the height = 92 must be the sqme in the image_friend_network span style in default.css
  330. $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_ORIGINAL);
  331. $friend_html.= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
  332. $friend_html.= '<div class="caption">';
  333. $friend_html.= $status_icon.'<a href="profile.php?u='.$friend['friend_user_id'].'&amp;'.$link_shared.'">';
  334. $friend_html.= $name_user;
  335. $friend_html.= '</a></div>';
  336. $friend_html.= '</div>';
  337. $friend_html.= '</li>';
  338. }
  339. $j++;
  340. }
  341. $friend_html.='</ul>';
  342. } else {
  343. // No friends!! :(
  344. $friend_html .= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
  345. $friend_html.= '<div id="friend-container" class="social-friend-container">';
  346. $friend_html.= '<div id="friend-header">';
  347. $friend_html.= '<div>'.get_lang('NoFriendsInYourContactList').'<br /><a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'.get_lang('TryAndFindSomeFriends').'</a></div>';
  348. $friend_html.= '</div>'; // close div friend-header
  349. }
  350. $friend_html.= '</div>';
  351. $social_right_content .= SocialManager::social_wrapper_div($friend_html, 5);
  352. // Extra information
  353. $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
  354. $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
  355. $extra_user_data = UserManager::get_extra_user_data($user_id);
  356. $extra_information = '';
  357. if (is_array($extra_user_data) && count($extra_user_data)>0 ) {
  358. $extra_information .= '<div><h3>'.get_lang('ExtraInformation').'</h3></div>';
  359. $extra_information .='<div class="social-profile-info">';
  360. $extra_information_value = '';
  361. foreach($extra_user_data as $key=>$data) {
  362. //Avoding parameters
  363. if (in_array($key, array('mail_notify_invitation','mail_notify_message', 'mail_notify_group_message' ))) continue;
  364. // get display text, visibility and type from user_field table
  365. $field_variable = str_replace('extra_','',$key);
  366. $sql = "SELECT field_display_text,field_visible,field_type,id FROM $t_uf WHERE field_variable ='$field_variable'";
  367. $res_field = Database::query($sql);
  368. $row_field = Database::fetch_row($res_field);
  369. $field_display_text = $row_field[0];
  370. $field_visible = $row_field[1];
  371. $field_type = $row_field[2];
  372. $field_id = $row_field[3];
  373. if ($field_visible == 1) {
  374. if (is_array($data)) {
  375. $extra_information_value .= '<dt>'.ucfirst($field_display_text).'</dt><dd> '.implode(',',$data).'</dd>';
  376. } else {
  377. if ($field_type == USER_FIELD_TYPE_DOUBLE_SELECT) {
  378. $id_options = explode(';',$data);
  379. $value_options = array();
  380. // get option display text from user_field_options table
  381. foreach ($id_options as $id_option) {
  382. $sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'";
  383. $res_options = Database::query($sql);
  384. $row_options = Database::fetch_row($res_options);
  385. $value_options[] = $row_options[0];
  386. }
  387. $extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt><dd>'.implode(' ',$value_options).'</dd>';
  388. } elseif($field_type == USER_FIELD_TYPE_TAG ) {
  389. $user_tags = UserManager::get_user_tags($user_id, $field_id);
  390. $tag_tmp = array();
  391. foreach ($user_tags as $tags) {
  392. $tag_tmp[] = '<a class="label label_tag" href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tags['tag'].'">'.$tags['tag'].'</a>';
  393. }
  394. if (is_array($user_tags) && count($user_tags)>0) {
  395. $extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt><dd>'.implode('', $tag_tmp).'</dd>';
  396. }
  397. } elseif ($field_type == USER_FIELD_TYPE_SOCIAL_PROFILE) {
  398. $icon_path = UserManager::get_favicon_from_url($data);
  399. $bottom = '0.3';
  400. //quick hack for hi5
  401. $domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $bottom = '0.8'; }
  402. $data = '<a href="'.$data.'"><img src="'.$icon_path.'" alt="ico" style="margin-right:0.5em;margin-bottom:-'.$bottom.'em;" />'.ucfirst($field_display_text).'</a>';
  403. $extra_information_value .= '<dd>'.$data.'</dd>';
  404. } else {
  405. if (!empty($data)) {
  406. $extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt><dd>'.$data.'</dd>';
  407. }
  408. }
  409. }
  410. }
  411. }
  412. // if there are information to show
  413. if (!empty($extra_information_value)) {
  414. $extra_information .= $extra_information_value;
  415. }
  416. $extra_information .= '</div>'; //social-profile-info
  417. }
  418. // if there are information to show
  419. if (!empty($extra_information_value)) {
  420. $social_right_content .= SocialManager::social_wrapper_div($extra_information, 9);
  421. }
  422. // MY GROUPS
  423. $results = GroupPortalManager::get_groups_by_user($my_user_id, 0);
  424. $grid_my_groups = array();
  425. $max_numbers_of_group = 4;
  426. if (is_array($results) && count($results) > 0) {
  427. $i = 1;
  428. foreach ($results as $result) {
  429. if ($i > $max_numbers_of_group) break;
  430. $id = $result['id'];
  431. $url_open = '<a href="groups.php?id='.$id.'">';
  432. $url_close = '</a>';
  433. $icon = '';
  434. $name = cut($result['name'],CUT_GROUP_NAME,true);
  435. if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  436. $icon = Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle;width:16px;height:16px;'));
  437. } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  438. $icon = Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle;width:16px;height:16px;'));
  439. }
  440. $count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
  441. if ($count_users_group == 1 ) {
  442. $count_users_group = $count_users_group.' '.get_lang('Member');
  443. } else {
  444. $count_users_group = $count_users_group.' '.get_lang('Members');
  445. }
  446. //$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  447. $item_name = $url_open.$name.$icon.$url_close;
  448. if ($result['description'] != '') {
  449. //$item_description = '<div class="box_shared_profile_group_description"><p class="social-groups-text4">'.cut($result['description'],100,true).'</p></div>';
  450. } else {
  451. //$item_description = '<div class="box_shared_profile_group_description"><span class="social-groups-text2"></span><p class="social-groups-text4"></p></div>';
  452. }
  453. //$result['picture_uri'] = '<div class="box_shared_profile_group_image"><img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" /></div>';
  454. $item_actions = '';
  455. if (api_get_user_id() == $user_id) {
  456. //$item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id='.$id.'">'.get_lang('SeeMore').$url_close.'</div>';
  457. }
  458. $grid_my_groups[]= array($item_name,$url_open.$result['picture_uri'].$url_close, $item_actions);
  459. $i++;
  460. }
  461. }
  462. if (count($grid_my_groups) > 0) {
  463. $my_groups = '';
  464. $count_groups = 0;
  465. if (count($results) == 1 ) {
  466. $count_groups = count($results);
  467. } else {
  468. $count_groups = count($results);
  469. }
  470. $my_groups .= '<div><h3>'.get_lang('MyGroups').' ('.$count_groups.') </h3></div>';
  471. if ($i > $max_numbers_of_group) {
  472. if (api_get_user_id() == $user_id) {
  473. $my_groups .= '<div class="box_shared_profile_group_actions"><a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
  474. } else {
  475. $my_groups .= '<div class="box_shared_profile_group_actions"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=mygroups&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAllMyGroups').'</a></div>';
  476. }
  477. }
  478. //Display::display_sortable_grid('shared_profile_mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
  479. $total = count($grid_my_groups);
  480. $i = 1;
  481. foreach($grid_my_groups as $group) {
  482. $my_groups .= $group[0];
  483. if ($i < $total) {
  484. $my_groups .= ', ';
  485. }
  486. $i++;
  487. }
  488. $social_right_content .= SocialManager::social_wrapper_div($my_groups, 9);
  489. }
  490. // COURSES LIST
  491. if ( is_array($list) ) {
  492. $my_courses .= '<div><h3>'.api_ucfirst(get_lang('MyCourses')).'</h3></div>';
  493. $my_courses .= '<div class="social-content-training">';
  494. //Courses without sessions
  495. $i=1;
  496. foreach ($list as $key=>$value) {
  497. if ( empty($value[2]) ) { //if out of any session
  498. $my_courses .= $value[1];
  499. $my_courses .= '<div id="social_content'.$i.'" class="course_social_content" style="display:none" >s</div>';
  500. $i++;
  501. }
  502. }
  503. /*
  504. $listActives = $listInactives = array();
  505. foreach ( $list as $key=>$value ) {
  506. if ( $value['active'] ) { //if the session is still active (as told by get_logged_user_course_html())
  507. $listActives[] = $value;
  508. } elseif ( !empty($value[2]) ) { //if there is a session but it is not active
  509. $listInactives[] = $value;
  510. }
  511. }*/
  512. $my_courses .= '</div>'; //social-content-training
  513. $social_right_content .= SocialManager::social_wrapper_div($my_courses, 9);
  514. }
  515. // user feeds
  516. $user_feeds = SocialManager::get_user_feeds($user_id);
  517. if (!empty($user_feeds)) {
  518. $rss = '<div><h3>'.get_lang('RSSFeeds').'</h3></div>';
  519. $rss .= '<div class="social-content-training">'.$user_feeds.'</div>';
  520. $social_right_content .= SocialManager::social_wrapper_div($rss, 9);
  521. }
  522. //--Productions
  523. $production_list = UserManager::build_production_list($user_id);
  524. // Images uploaded by course
  525. $file_list = '';
  526. if (is_array($course_list_code) && count($course_list_code)>0) {
  527. foreach ($course_list_code as $course) {
  528. $file_list.= UserManager::get_user_upload_files_by_course($user_id, $course['code'], $resourcetype='images');
  529. }
  530. }
  531. $count_pending_invitations = 0;
  532. if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
  533. $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
  534. $list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
  535. $count_pending_invitations = count($pending_invitations);
  536. }
  537. if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) {
  538. //Pending invitations
  539. if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
  540. if ($count_pending_invitations > 0) {
  541. $invitations .= '<div><h3>'.get_lang('PendingInvitations').'</h3></div>';
  542. for ($i=0;$i<$count_pending_invitations;$i++) {
  543. $user_invitation_id = $pending_invitations[$i]['user_sender_id'];
  544. $invitations .= '<div id="dpending_'.$user_invitation_id.'" class="friend_invitations">';
  545. $invitations .= '<div style="float:left;width:60px;" >';
  546. $invitations .= '<img style="margin-bottom:5px;" src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
  547. $invitations .= '</div>';
  548. $invitations .= '<div style="padding-left:70px;">';
  549. $user_invitation_info = api_get_user_info($user_invitation_id);
  550. $invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">'.api_get_person_name($user_invitation_info['firstname'], $user_invitation_info['lastname']).'</a>';
  551. $invitations .= '<br />';
  552. $invitations .= Security::remove_XSS(cut($pending_invitations[$i]['content'], 50), STUDENT, true);
  553. $invitations .= '<br />';
  554. $invitations .= '<a id="btn_accepted_'.$user_invitation_id.'" class="btn" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
  555. $invitations .= '<div id="id_response"></div>';
  556. $invitations .= '</div>';
  557. $invitations .= '</div>';
  558. }
  559. $social_right_content .= SocialManager::social_wrapper_div($invitations, 4);
  560. }
  561. }
  562. //--Productions
  563. $production_list = UserManager::build_production_list($user_id);
  564. $product_content = '';
  565. if (!empty($production_list)) {
  566. $product_content .= '<div><h3>'.get_lang('MyProductions').'</h3></div>';
  567. $product_content .= $production_list;
  568. $social_right_content .= SocialManager::social_wrapper_div($product_content, 5);
  569. }
  570. $images_uploaded = null;
  571. // Images uploaded by course
  572. if (!empty($file_list)) {
  573. $images_uploaded .= '<div><h3>'.get_lang('ImagesUploaded').'</h3></div>';
  574. $images_uploaded .= '<div class="social-content-information">';
  575. $images_uploaded .= $file_list;
  576. $images_uploaded .= '</div>';
  577. $social_right_content .= SocialManager::social_wrapper_div($images_uploaded, 9);
  578. }
  579. }
  580. if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
  581. $more_info .= '<div><h3>'.get_lang('MoreInformation').'</h3></div>';
  582. $cut_size = 220;
  583. if (!empty($user_info['competences'])) {
  584. $more_info .= '<br />';
  585. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
  586. $more_info .= '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
  587. $more_info .= '<br />';
  588. }
  589. if (!empty($user_info['diplomas'])) {
  590. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
  591. $more_info .= '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
  592. $more_info .= '<br />';
  593. }
  594. if (!empty($user_info['openarea'])) {
  595. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
  596. $more_info .= '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
  597. $more_info .= '<br />';
  598. }
  599. if (!empty($user_info['teach'])) {
  600. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
  601. $more_info .= '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
  602. $more_info .= '<br />';
  603. }
  604. $social_right_content .= SocialManager::social_wrapper_div($more_info, 9);
  605. }
  606. }
  607. $social_right_content .= MessageManager::generate_message_form('send_message');
  608. $social_right_content .= MessageManager::generate_invitation_form('send_invitation');
  609. $tpl = new Template(get_lang('Social'));
  610. $tpl->assign('social_left_content', $social_left_content);
  611. $tpl->assign('social_left_menu', $social_left_menu);
  612. $tpl->assign('social_right_content', $social_right_content);
  613. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  614. $content = $tpl->fetch($social_layout);
  615. $tpl->assign('actions', $actions);
  616. $tpl->assign('message', $message);
  617. $tpl->assign('content', $content);
  618. $tpl->display_one_col_template();