profile.php 29 KB

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