profile.php 27 KB

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