profile.php 30 KB

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