profile.php 27 KB

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