profile.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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. * @todo use Display::panel()
  8. * @package chamilo.social
  9. */
  10. $cidReset = true;
  11. require_once '../inc/global.inc.php';
  12. if (api_get_setting('allow_social_tool') !='true') {
  13. $url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']);
  14. header('Location: '.$url);
  15. exit;
  16. }
  17. $user_id = api_get_user_id();
  18. $friendId = isset($_GET['u']) ? intval($_GET['u']) : api_get_user_id();
  19. $isAdmin = api_is_platform_admin($user_id);
  20. $userGroup = new UserGroup();
  21. $show_full_profile = true;
  22. //social tab
  23. $this_section = SECTION_SOCIAL;
  24. //Initialize blocks
  25. $social_extra_info_block = null;
  26. $social_course_block = null;
  27. $social_group_info_block = null;
  28. $social_rss_block = null;
  29. $social_session_block = null;
  30. if (!empty($_POST['social_wall_new_msg_main']) || !empty($_FILES['picture']['tmp_name'])) {
  31. $messageId = 0;
  32. $messageContent = $_POST['social_wall_new_msg_main'];
  33. if (!empty($_POST['url_content'])) {
  34. $messageContent = $_POST['social_wall_new_msg_main'].'<br><br>'.$_POST['url_content'];
  35. }
  36. $idMessage = SocialManager::sendWallMessage(
  37. api_get_user_id(),
  38. $friendId,
  39. $messageContent,
  40. $messageId,
  41. MESSAGE_STATUS_WALL_POST
  42. );
  43. if (!empty($_FILES['picture']['tmp_name']) && $idMessage > 0) {
  44. $error = SocialManager::sendWallMessageAttachmentFile(
  45. api_get_user_id(),
  46. $_FILES['picture'],
  47. $idMessage,
  48. $fileComment = ''
  49. );
  50. }
  51. Display::addFlash(Display::return_message(get_lang('MessageSent')));
  52. $url = api_get_path(WEB_CODE_PATH) . 'social/profile.php';
  53. $url .= empty($_SERVER['QUERY_STRING']) ? '' : '?'.Security::remove_XSS($_SERVER['QUERY_STRING']);
  54. header('Location: ' . $url);
  55. exit;
  56. } else if (!empty($_POST['social_wall_new_msg']) && !empty($_POST['messageId'])) {
  57. $messageId = intval($_POST['messageId']);
  58. $messageContent = $_POST['social_wall_new_msg'];
  59. $res = SocialManager::sendWallMessage(
  60. api_get_user_id(),
  61. $friendId,
  62. $messageContent,
  63. $messageId,
  64. MESSAGE_STATUS_WALL
  65. );
  66. Display::addFlash(Display::return_message(get_lang('MessageSent')));
  67. $url = api_get_path(WEB_CODE_PATH) . 'social/profile.php';
  68. $url .= empty($_SERVER['QUERY_STRING']) ? '' : '?'.Security::remove_XSS($_SERVER['QUERY_STRING']);
  69. header('Location: ' . $url);
  70. exit;
  71. } else if (isset($_GET['messageId'])) {
  72. $messageId = Security::remove_XSS($_GET['messageId']);
  73. $status = SocialManager::deleteMessage($messageId);
  74. Display::addFlash(Display::return_message(get_lang('MessageDeleted')));
  75. header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/profile.php');
  76. exit;
  77. } else if (isset($_GET['u'])) { //I'm your friend? I can see your profile?
  78. $user_id = intval($_GET['u']);
  79. if (api_is_anonymous($user_id, true)) {
  80. api_not_allowed(true);
  81. }
  82. // It's me!
  83. if (api_get_user_id() != $user_id) {
  84. $user_info = api_get_user_info($user_id);
  85. $show_full_profile = false;
  86. if (!$user_info) {
  87. // user does no exist !!
  88. api_not_allowed(true);
  89. } else {
  90. //checking the relationship between me and my friend
  91. $my_status = SocialManager::get_relation_between_contacts(
  92. api_get_user_id(),
  93. $user_id
  94. );
  95. if (in_array($my_status, array(
  96. USER_RELATION_TYPE_PARENT,
  97. USER_RELATION_TYPE_FRIEND,
  98. USER_RELATION_TYPE_GOODFRIEND
  99. ))) {
  100. $show_full_profile = true;
  101. }
  102. //checking the relationship between my friend and me
  103. $my_friend_status = SocialManager::get_relation_between_contacts(
  104. $user_id,
  105. api_get_user_id()
  106. );
  107. if (in_array($my_friend_status, array(
  108. USER_RELATION_TYPE_PARENT,
  109. USER_RELATION_TYPE_FRIEND,
  110. USER_RELATION_TYPE_GOODFRIEND
  111. ))) {
  112. $show_full_profile = true;
  113. } else {
  114. // im probably not a good friend
  115. $show_full_profile = false;
  116. }
  117. }
  118. } else {
  119. $user_info = api_get_user_info($user_id);
  120. }
  121. } else {
  122. $user_info = api_get_user_info($user_id);
  123. }
  124. if ($user_info['user_id'] == api_get_user_id()) {
  125. $isSelfUser = true;
  126. } else {
  127. $isSelfUser = false;
  128. }
  129. $userIsOnline = user_is_online($user_id);
  130. $libpath = api_get_path(LIBRARY_PATH);
  131. require_once $libpath.'magpierss/rss_fetch.inc';
  132. $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
  133. $socialAjaxUrl = api_get_path(WEB_AJAX_PATH).'social.ajax.php';
  134. $javascriptDir = api_get_path(LIBRARY_PATH) . 'javascript/';
  135. api_block_anonymous_users();
  136. $locale = api_get_language_isocode();
  137. // Add Jquery scroll pagination plugin
  138. $htmlHeadXtra[] = api_get_js('jscroll/jquery.jscroll.js');
  139. // Add Jquery Time ago plugin
  140. $htmlHeadXtra[] = api_get_asset('jquery-timeago/jquery.timeago.js');
  141. $timeAgoLocaleDir = $javascriptDir . 'jquery-timeago/locales/jquery.timeago.' . $locale . '.js';
  142. if (file_exists($timeAgoLocaleDir)) {
  143. $htmlHeadXtra[] = api_get_js('jquery-timeago/locales/jquery.timeago.' . $locale . '.js');
  144. }
  145. $htmlHeadXtra[] = '<script>
  146. $(document).ready(function (){
  147. var container = $("#wallMessages");
  148. container.jscroll({
  149. loadingHtml: "<div class=\"well_border\">' . get_lang('Loading') . ' </div>",
  150. nextSelector: "a.nextPage:last",
  151. contentSelector: "",
  152. callback: timeAgo
  153. });
  154. timeAgo()
  155. });
  156. function timeAgo() {
  157. $(".timeago").timeago();
  158. }
  159. function register_friend(element_input) {
  160. if (confirm("'.get_lang('AddToFriends').'")) {
  161. name_button=$(element_input).attr("id");
  162. name_div_id="id_"+name_button.substring(13);
  163. user_id=name_div_id.split("_");
  164. user_friend_id=user_id[1];
  165. $.ajax({
  166. contentType: "application/x-www-form-urlencoded",
  167. beforeSend: function(objeto) {
  168. $("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />");
  169. },
  170. type: "POST",
  171. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=add_friend",
  172. data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
  173. success: function(datos) {
  174. $("#dpending_" + user_friend_id).html(datos);
  175. }
  176. });
  177. }
  178. }
  179. </script>';
  180. $link_shared = '';
  181. $nametool = get_lang('ViewMySharedProfile');
  182. if (isset($_GET['shared'])) {
  183. $my_link = '../social/profile.php';
  184. $link_shared = 'shared='.Security::remove_XSS($_GET['shared']);
  185. } else {
  186. $my_link = '../social/profile.php';
  187. $link_shared = '';
  188. }
  189. $interbreadcrumb[] = array(
  190. 'url' => 'home.php',
  191. 'name' => get_lang('SocialNetwork'),
  192. );
  193. if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) {
  194. $info_user = api_get_user_info($_GET['u']);
  195. $interbreadcrumb[]= array(
  196. 'url' => '#',
  197. 'name' => $info_user['complete_name']
  198. );
  199. $nametool = '';
  200. }
  201. if (isset($_GET['u'])) {
  202. $param_user = 'u='.Security::remove_XSS($_GET['u']);
  203. } else {
  204. $info_user = api_get_user_info(api_get_user_id());
  205. $param_user = '';
  206. }
  207. $_SESSION['social_user_id'] = intval($user_id);
  208. // Setting some course info
  209. $my_user_id = isset($_GET['u']) ? intval($_GET['u']) : api_get_user_id();
  210. $personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
  211. $course_list_code = array();
  212. $i = 1;
  213. $list = [];
  214. if (is_array($personal_course_list)) {
  215. foreach ($personal_course_list as $my_course) {
  216. if ($i<=10) {
  217. $list[] = SocialManager::get_logged_user_course_html($my_course, $i);
  218. $course_list_code[] = array('code' => $my_course['code']);
  219. } else {
  220. break;
  221. }
  222. $i++;
  223. }
  224. //to avoid repeted courses
  225. $course_list_code = array_unique_dimensional($course_list_code);
  226. }
  227. //Social Block Menu
  228. $social_menu_block = SocialManager::show_social_menu(
  229. 'shared_profile',
  230. null,
  231. $user_id,
  232. $show_full_profile
  233. );
  234. //Setting some session info
  235. $user_info = api_get_user_info($my_user_id);
  236. $sessionList = SessionManager::getSessionsFollowedByUser(
  237. $my_user_id,
  238. $user_info['status']
  239. );
  240. // My friends
  241. $friend_html = SocialManager::listMyFriendsBlock(
  242. $user_id,
  243. $link_shared,
  244. $show_full_profile
  245. );
  246. $wallSocialAddPost = SocialManager::getWallForm($show_full_profile);
  247. $social_wall_block = $wallSocialAddPost;
  248. // Social Post Wall
  249. $posts = SocialManager::getWallMessagesByUser($my_user_id, $friendId) ;
  250. $posts = empty($posts) ? '<p>'.get_lang("NoPosts").'</p>' : $posts;
  251. $social_post_wall_block = Display::panel($posts, get_lang('Posts'));
  252. $socialAutoExtendLink = Display::url(
  253. get_lang('SeeMore'),
  254. $socialAjaxUrl . '?u='. $my_user_id . '&a=listWallMessage&start=10&length=5',
  255. array(
  256. 'class' => 'nextPage next',
  257. )
  258. );
  259. // Added a Jquery Function to return the Preview of OpenGraph URL Content
  260. $htmlHeadXtra[] = '<script>
  261. $(document).ready(function() {
  262. $("[name=\'social_wall_new_msg_main\']").on("paste", function(e) {
  263. $.ajax({
  264. contentType: "application/x-www-form-urlencoded",
  265. beforeSend: function() {
  266. $("[name=\'wall_post_button\']").prop( "disabled", true );
  267. $(".panel-preview").hide();
  268. $(".spinner").html("'.
  269. '<div class=\'text-center\'>'.
  270. '<em class=\'fa fa-spinner fa-pulse fa-1x\'></em>'.
  271. '<p>'. get_lang('Loading') . ' ' . get_lang('Preview') .'</p>'.
  272. '</div>'.
  273. '");
  274. },
  275. type: "POST",
  276. url: "'. api_get_path(WEB_AJAX_PATH) .'social.ajax.php?a=readUrlWithOpenGraph",
  277. data: "social_wall_new_msg_main=" + e.originalEvent.clipboardData.getData("text"),
  278. success: function(response) {
  279. $("[name=\'wall_post_button\']").prop( "disabled", false );
  280. if (!response == false) {
  281. $(".spinner").html("");
  282. $(".panel-preview").show();
  283. $(".url_preview").html(response);
  284. $("[name=\'url_content\']").val(response);
  285. $(".url_preview img").addClass("img-responsive");
  286. } else {
  287. $(".spinner").html("");
  288. }
  289. }
  290. });
  291. });
  292. });
  293. </script>';
  294. $socialRightInformation = null;
  295. $social_right_content = null;
  296. if ($show_full_profile) {
  297. $t_ufo = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
  298. $extra_user_data = UserManager::get_extra_user_data($user_id, false, true);
  299. $extra_information = '';
  300. if (is_array($extra_user_data) && count($extra_user_data)>0 ) {
  301. $extra_information_value = '<ul class="list-group">';
  302. $extraField = new ExtraField('user');
  303. foreach ($extra_user_data as $key => $data) {
  304. // Avoiding parameters
  305. if (in_array(
  306. $key,
  307. array(
  308. 'mail_notify_invitation',
  309. 'mail_notify_message',
  310. 'mail_notify_group_message',
  311. )
  312. )) {
  313. continue;
  314. }
  315. // get display text, visibility and type from user_field table
  316. $field_variable = str_replace('extra_', '', $key);
  317. $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
  318. $field_variable
  319. );
  320. if ($extraFieldInfo['visible'] != 1) {
  321. continue;
  322. }
  323. if (is_array($data)) {
  324. $extra_information_value .= '<li class="list-group-item">'.ucfirst($extraFieldInfo['display_text']).' '
  325. .' '.implode(',', $data).'</li>';
  326. } else {
  327. switch ($extraFieldInfo['field_type']) {
  328. case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
  329. $id_options = explode(';', $data);
  330. $value_options = array();
  331. // get option display text from user_field_options table
  332. foreach ($id_options as $id_option) {
  333. $sql = "SELECT display_text FROM $t_ufo WHERE id = '$id_option'";
  334. $res_options = Database::query($sql);
  335. $row_options = Database::fetch_row($res_options);
  336. $value_options[] = $row_options[0];
  337. }
  338. $extra_information_value .= '<li class="list-group-item">'.ucfirst($extraFieldInfo['display_text']).': '
  339. .' '.implode(' ', $value_options).'</li>';
  340. break;
  341. case ExtraField::FIELD_TYPE_TAG:
  342. $user_tags = UserManager::get_user_tags($user_id, $extraFieldInfo['id']);
  343. $tag_tmp = array();
  344. foreach ($user_tags as $tags) {
  345. $tag_tmp[] = '<a class="label label_tag"'
  346. .' href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tags['tag'].'">'
  347. .$tags['tag']
  348. .'</a>';
  349. }
  350. if (is_array($user_tags) && count($user_tags)>0) {
  351. $extra_information_value .= '<li class="list-group-item">'.ucfirst($extraFieldInfo['display_text']).': '
  352. .' '.implode('', $tag_tmp).'</li>';
  353. }
  354. break;
  355. case ExtraField::FIELD_TYPE_SOCIAL_PROFILE:
  356. $icon_path = UserManager::get_favicon_from_url($data);
  357. if (SocialManager::verifyUrl($icon_path) == false) {
  358. break;
  359. }
  360. $bottom = '0.2';
  361. //quick hack for hi5
  362. $domain = parse_url($icon_path, PHP_URL_HOST);
  363. if ($domain == 'www.hi5.com' or $domain == 'hi5.com') {
  364. $bottom = '-0.8';
  365. }
  366. $data = '<a href="'.$data.'">'
  367. .'<img src="'.$icon_path.'" alt="icon"'
  368. .' style="margin-right:0.5em;margin-bottom:'.$bottom.'em;" />'
  369. .$extraFieldInfo['display_text']
  370. .'</a>';
  371. $extra_information_value .= '<li class="list-group-item">'.$data.'</li>';
  372. break;
  373. default:
  374. if (!empty($data)) {
  375. $extra_field_title = ucfirst($extraFieldInfo['display_text']);
  376. if ($extra_field_title == 'Skype') {
  377. $data = '<a href="skype:' . $data . '?chat">' . get_lang('Chat') . '</a>';
  378. $extra_information_value .= '<li class="list-group-item">'.Display::return_icon('skype.png', $extraFieldInfo['display_text'], null, ICON_SIZE_TINY, false) . ' ' . $data.'</li>';
  379. } else {
  380. $extra_information_value .= '<dt>'.ucfirst($extraFieldInfo['display_text']).':</dt><dd>'.$data.'</dd>';
  381. }
  382. }
  383. break;
  384. }
  385. }
  386. }
  387. $extra_information_value .= '</ul>';
  388. // if there are information to show
  389. if (!empty($extra_information_value)) {
  390. $extra_information .= Display::panelCollapse(
  391. get_lang('ExtraInformation'),
  392. $extra_information_value,
  393. 'sn-extra-information',
  394. null, 'sn-extra-accordion',
  395. 'sn-extra-collapse'
  396. );
  397. }
  398. }
  399. // If there are information to show Block Extra Information
  400. if (!empty($extra_information_value)) {
  401. $social_extra_info_block = $extra_information;
  402. }
  403. // MY GROUPS
  404. $results = $userGroup->get_groups_by_user($my_user_id, 0);
  405. $grid_my_groups = array();
  406. $max_numbers_of_group = 4;
  407. if (is_array($results) && count($results) > 0) {
  408. $i = 1;
  409. foreach ($results as $result) {
  410. if ($i > $max_numbers_of_group) {
  411. break;
  412. }
  413. $id = $result['id'];
  414. $url_open = '<a href="group_view.php?id='.$id.'">';
  415. $url_close = '</a>';
  416. $icon = '';
  417. $name = cut($result['name'], CUT_GROUP_NAME, true);
  418. if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  419. $icon = Display::return_icon(
  420. 'social_group_admin.png',
  421. get_lang('Admin'),
  422. array('style'=>'vertical-align:middle;width:16px;height:16px;')
  423. );
  424. } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  425. $icon = Display::return_icon(
  426. 'social_group_moderator.png',
  427. get_lang('Moderator'),
  428. array('style'=>'vertical-align:middle;width:16px;height:16px;')
  429. );
  430. }
  431. $count_users_group = count($userGroup->get_all_users_by_group($id));
  432. if ($count_users_group == 1 ) {
  433. $count_users_group = $count_users_group.' '.get_lang('Member');
  434. } else {
  435. $count_users_group = $count_users_group.' '.get_lang('Members');
  436. }
  437. $item_name = $url_open.$name.$icon.$url_close;
  438. $item_actions = '';
  439. $grid_my_groups[] = array(
  440. $item_name,
  441. $url_open.$result['picture'].$url_close,
  442. $item_actions,
  443. );
  444. $i++;
  445. }
  446. }
  447. // Block My Groups
  448. if (count($grid_my_groups) > 0) {
  449. $my_groups = '';
  450. $count_groups = 0;
  451. if (count($results) == 1 ) {
  452. $count_groups = count($results);
  453. } else {
  454. $count_groups = count($results);
  455. }
  456. $my_groups .= '<div class="panel panel-default">';
  457. $my_groups .= '<div class="panel-heading">'.get_lang('MyGroups').' ('.$count_groups.') </div>';
  458. if ($i > $max_numbers_of_group) {
  459. if (api_get_user_id() == $user_id) {
  460. $my_groups .= '<div class="box_shared_profile_group_actions">'
  461. .'<a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
  462. } else {
  463. $my_groups .= '<div class="box_shared_profile_group_actions">'
  464. .'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
  465. .'?view=mygroups&height=390&width=610&user_id='.$user_id.'"'
  466. .' class="ajax" title="'.get_lang('SeeAll').'" >'
  467. .get_lang('SeeAllMyGroups')
  468. .'</a></div>';
  469. }
  470. }
  471. $total = count($grid_my_groups);
  472. $i = 1;
  473. foreach ($grid_my_groups as $group) {
  474. $my_groups .= '<div class="panel-body">';
  475. $my_groups .= $group[0];
  476. $my_groups .= '</div>';
  477. $i++;
  478. }
  479. $my_groups .= '</div>';
  480. $social_group_info_block = $my_groups;
  481. }
  482. // Block Social Course
  483. $my_courses = null;
  484. // COURSES LIST
  485. if (is_array($list)) {
  486. // Courses without sessions
  487. $my_course = '';
  488. $i = 1;
  489. foreach ($list as $key => $value) {
  490. if ( empty($value[2]) ) { //if out of any session
  491. $my_courses .= $value[1];
  492. $i++;
  493. }
  494. }
  495. $social_course_block .= $my_courses;
  496. //$social_course_block = Display::panel($my_courses, get_lang('MyCourses'));
  497. }
  498. // Block Social Sessions
  499. if (count($sessionList) > 0) {
  500. //$social_session_block = $htmlSessionList;
  501. $social_session_block = $sessionList;
  502. }
  503. // Block Social User Feeds
  504. $user_feeds = SocialManager::get_user_feeds($user_id);
  505. if (!empty($user_feeds)) {
  506. $social_rss_block = Display::panel($user_feeds, get_lang('RSSFeeds'));
  507. }
  508. // Productions
  509. $production_list = UserManager::build_production_list($user_id);
  510. // Images uploaded by course
  511. $file_list = '';
  512. if (is_array($course_list_code) && count($course_list_code)>0) {
  513. foreach ($course_list_code as $course) {
  514. $file_list.= UserManager::get_user_upload_files_by_course($user_id,$course['code'],$resourcetype='images');
  515. }
  516. }
  517. $count_pending_invitations = 0;
  518. if (!isset($_GET['u']) ||
  519. (isset($_GET['u']) && $_GET['u']==api_get_user_id())
  520. ) {
  521. $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
  522. $list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
  523. $count_pending_invitations = count($pending_invitations);
  524. }
  525. if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) {
  526. //Pending invitations
  527. if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
  528. if ($count_pending_invitations > 0) {
  529. $invitations = '<div><h3>'.get_lang('PendingInvitations').'</h3></div>';
  530. for ($i=0;$i<$count_pending_invitations;$i++) {
  531. $user_invitation_id = $pending_invitations[$i]['user_sender_id'];
  532. $invitations .= '<div id="dpending_'.$user_invitation_id.'" class="friend_invitations">';
  533. $invitations .= '<div style="float:left;width:60px;" >';
  534. $invitations .= '<img style="margin-bottom:5px;"'
  535. .' src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'"'
  536. .' width="60px">';
  537. $invitations .= '</div>';
  538. $invitations .= '<div style="padding-left:70px;">';
  539. $user_invitation_info = api_get_user_info($user_invitation_id);
  540. $invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php'
  541. .'?u='.$user_invitation_id.'">'
  542. .api_get_person_name(
  543. $user_invitation_info['firstname'],
  544. $user_invitation_info['lastname'])
  545. .'</a>';
  546. $invitations .= '<br />';
  547. $invitations .= Security::remove_XSS(
  548. cut($pending_invitations[$i]['content'], 50),
  549. STUDENT,
  550. true
  551. );
  552. $invitations .= '<br />';
  553. $invitations .= '<a id="btn_accepted_'.$user_invitation_id.'"'
  554. .' class="btn btn-default" onclick="register_friend(this)" href="javascript:void(0)">'
  555. .get_lang('SocialAddToFriends')
  556. .'</a>';
  557. $invitations .= '<div id="id_response"></div>';
  558. $invitations .= '</div>';
  559. $invitations .= '</div>';
  560. }
  561. $socialRightInformation .= SocialManager::social_wrapper_div($invitations, 4);
  562. }
  563. }
  564. // Productions
  565. $production_list = UserManager::build_production_list($user_id);
  566. $product_content = '';
  567. if (!empty($production_list)) {
  568. $product_content .= '<div><h3>'.get_lang('MyProductions').'</h3></div>';
  569. $product_content .= $production_list;
  570. $socialRightInformation .= SocialManager::social_wrapper_div($product_content, 4);
  571. }
  572. $images_uploaded = null;
  573. // Images uploaded by course
  574. if (!empty($file_list)) {
  575. $images_uploaded .= '<div><h3>'.get_lang('ImagesUploaded').'</h3></div>';
  576. $images_uploaded .= '<div class="social-content-information">';
  577. $images_uploaded .= $file_list;
  578. $images_uploaded .= '</div>';
  579. $socialRightInformation .= SocialManager::social_wrapper_div($images_uploaded, 4);
  580. }
  581. }
  582. if (!empty($user_info['competences']) || !empty($user_info['diplomas'])
  583. || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
  584. $more_info .= '<div><h3>'.get_lang('MoreInformation').'</h3></div>';
  585. if (!empty($user_info['competences'])) {
  586. $more_info .= '<br />';
  587. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
  588. $more_info .= '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
  589. $more_info .= '<br />';
  590. }
  591. if (!empty($user_info['diplomas'])) {
  592. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
  593. $more_info .= '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
  594. $more_info .= '<br />';
  595. }
  596. if (!empty($user_info['openarea'])) {
  597. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
  598. $more_info .= '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
  599. $more_info .= '<br />';
  600. }
  601. if (!empty($user_info['teach'])) {
  602. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
  603. $more_info .= '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
  604. $more_info .= '<br />';
  605. }
  606. $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4);
  607. }
  608. }
  609. $tpl = new Template(get_lang('Social'));
  610. // Block Avatar Social
  611. SocialManager::setSocialUserBlock($tpl, $user_id, 'shared_profile', 0, $show_full_profile);
  612. $tpl->assign('social_friend_block', $friend_html);
  613. $tpl->assign('social_menu_block', $social_menu_block);
  614. $tpl->assign('social_wall_block', $social_wall_block);
  615. $tpl->assign('social_post_wall_block', $social_post_wall_block);
  616. $tpl->assign('social_extra_info_block', $social_extra_info_block);
  617. $tpl->assign('social_course_block', $social_course_block);
  618. $tpl->assign('social_group_info_block', $social_group_info_block);
  619. $tpl->assign('social_rss_block', $social_rss_block);
  620. $tpl->assign('social_skill_block', SocialManager::getSkillBlock($my_user_id));
  621. $tpl->assign('sessionList', $social_session_block);
  622. $tpl->assign('social_right_information', $socialRightInformation);
  623. $tpl->assign('social_auto_extend_link', $socialAutoExtendLink);
  624. $formModalTpl = new Template();
  625. //$formModalTpl->assign('messageForm', MessageManager::generate_message_form('send_message'));
  626. $formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form('send_invitation'));
  627. $formModals = $formModalTpl->fetch('default/social/form_modals.tpl');
  628. $tpl->assign('form_modals', $formModals);
  629. $social_layout = $tpl->get_template('social/profile.tpl');
  630. $tpl->display($social_layout);