profile.php 33 KB

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