profile.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  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 __DIR__.'/../inc/global.inc.php';
  13. if (api_get_setting('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. } elseif (!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. } elseif (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. } elseif (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. $userIsOnline = user_is_online($user_id);
  138. $libpath = api_get_path(LIBRARY_PATH);
  139. $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
  140. $socialAjaxUrl = api_get_path(WEB_AJAX_PATH).'social.ajax.php';
  141. $javascriptDir = api_get_path(LIBRARY_PATH).'javascript/';
  142. api_block_anonymous_users();
  143. $locale = api_get_language_isocode();
  144. // Add Jquery scroll pagination plugin
  145. $htmlHeadXtra[] = api_get_js('jscroll/jquery.jscroll.js');
  146. // Add Jquery Time ago plugin
  147. $htmlHeadXtra[] = api_get_asset('jquery-timeago/jquery.timeago.js');
  148. $timeAgoLocaleDir = $javascriptDir.'jquery-timeago/locales/jquery.timeago.'.$locale.'.js';
  149. if (file_exists($timeAgoLocaleDir)) {
  150. $htmlHeadXtra[] = api_get_js('jquery-timeago/locales/jquery.timeago.'.$locale.'.js');
  151. }
  152. $htmlHeadXtra[] = '<script>
  153. $(document).ready(function (){
  154. var container = $("#wallMessages");
  155. container.jscroll({
  156. loadingHtml: "<div class=\"well_border\">' . get_lang('Loading').' </div>",
  157. nextSelector: "a.nextPage:last",
  158. contentSelector: "",
  159. callback: timeAgo
  160. });
  161. timeAgo();
  162. });
  163. function timeAgo() {
  164. $(".timeago").timeago();
  165. }
  166. </script>';
  167. $link_shared = '';
  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(
  177. 'url' => 'home.php',
  178. 'name' => get_lang('SocialNetwork'),
  179. );
  180. if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) {
  181. $info_user = api_get_user_info($_GET['u']);
  182. $interbreadcrumb[] = array(
  183. 'url' => '#',
  184. 'name' => $info_user['complete_name']
  185. );
  186. $nametool = '';
  187. }
  188. if (isset($_GET['u'])) {
  189. $param_user = 'u='.Security::remove_XSS($_GET['u']);
  190. } else {
  191. $info_user = api_get_user_info(api_get_user_id());
  192. $param_user = '';
  193. }
  194. Session::write('social_user_id', (int) $user_id);
  195. // Setting some course info
  196. $my_user_id = isset($_GET['u']) ? intval($_GET['u']) : api_get_user_id();
  197. $personal_course_list = UserManager::get_personal_session_course_list($my_user_id, 50);
  198. $course_list_code = array();
  199. $i = 1;
  200. $list = [];
  201. if (is_array($personal_course_list)) {
  202. foreach ($personal_course_list as $my_course) {
  203. if ($i <= 10) {
  204. $list[] = SocialManager::get_logged_user_course_html($my_course, $i);
  205. $course_list_code[] = array('code' => $my_course['code']);
  206. } else {
  207. break;
  208. }
  209. $i++;
  210. }
  211. //to avoid repeted courses
  212. $course_list_code = array_unique_dimensional($course_list_code);
  213. }
  214. //Social Block Menu
  215. $social_menu_block = SocialManager::show_social_menu(
  216. 'shared_profile',
  217. null,
  218. $user_id,
  219. $show_full_profile
  220. );
  221. //Setting some session info
  222. $user_info = api_get_user_info($my_user_id);
  223. $sessionList = SessionManager::getSessionsFollowedByUser(
  224. $my_user_id,
  225. $user_info['status']
  226. );
  227. // My friends
  228. $friend_html = SocialManager::listMyFriendsBlock(
  229. $user_id,
  230. $link_shared,
  231. $show_full_profile
  232. );
  233. $wallSocialAddPost = SocialManager::getWallForm($show_full_profile);
  234. $social_wall_block = $wallSocialAddPost;
  235. // Social Post Wall
  236. $posts = SocialManager::getWallMessagesByUser($my_user_id, $friendId);
  237. $social_post_wall_block = empty($posts) ? '<p>'.get_lang("NoPosts").'</p>' : $posts;
  238. $socialAutoExtendLink = Display::url(
  239. get_lang('SeeMore'),
  240. $socialAjaxUrl.'?u='.$my_user_id.'&a=list_wall_message&start=10&length=5',
  241. array(
  242. 'class' => 'nextPage next',
  243. )
  244. );
  245. // Added a Jquery Function to return the Preview of OpenGraph URL Content
  246. $htmlHeadXtra[] = '<script>
  247. $(document).ready(function() {
  248. var getUrl = $("[name=\'social_wall_new_msg_main\']");
  249. var matchUrl = /https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/ ;
  250. getUrl.on("paste", function(e) {
  251. $.ajax({
  252. contentType: "application/x-www-form-urlencoded",
  253. beforeSend: function() {
  254. $("[name=\'wall_post_button\']").prop( "disabled", true );
  255. $(".panel-preview").hide();
  256. $(".spinner").html("'.
  257. '<div class=\'text-center\'>'.
  258. '<em class=\'fa fa-spinner fa-pulse fa-1x\'></em>'.
  259. '<p>'.get_lang('Loading').' '.get_lang('Preview').'</p>'.
  260. '</div>'.
  261. '");
  262. },
  263. type: "POST",
  264. url: "'. api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=read_url_with_open_graph",
  265. data: "social_wall_new_msg_main=" + e.originalEvent.clipboardData.getData("text"),
  266. success: function(response) {
  267. $("[name=\'wall_post_button\']").prop( "disabled", false );
  268. if (!response == false) {
  269. $(".spinner").html("");
  270. $(".panel-preview").show();
  271. $(".url_preview").html(response);
  272. $("[name=\'url_content\']").val(response);
  273. $(".url_preview img").addClass("img-responsive");
  274. } else {
  275. $(".spinner").html("");
  276. }
  277. }
  278. });
  279. });
  280. });
  281. </script>';
  282. $socialRightInformation = '';
  283. $social_right_content = '';
  284. $listInvitations = '';
  285. if ($show_full_profile) {
  286. $t_ufo = Database::get_main_table(TABLE_EXTRA_FIELD_OPTIONS);
  287. $extra_user_data = UserManager::get_extra_user_data($user_id, false, true);
  288. $extra_information = '';
  289. if (is_array($extra_user_data) && count($extra_user_data) > 0) {
  290. $extra_information_value = '';
  291. $extraField = new ExtraField('user');
  292. foreach ($extra_user_data as $key => $data) {
  293. if (empty($data)) {
  294. continue;
  295. }
  296. // Avoiding parameters
  297. if (in_array(
  298. $key,
  299. array(
  300. 'mail_notify_invitation',
  301. 'mail_notify_message',
  302. 'mail_notify_group_message',
  303. )
  304. )) {
  305. continue;
  306. }
  307. // get display text, visibility and type from user_field table
  308. $field_variable = str_replace('extra_', '', $key);
  309. $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
  310. $field_variable
  311. );
  312. if (in_array($extraFieldInfo['variable'], ['skype', 'linkedin_url'])) {
  313. continue;
  314. }
  315. // if is not visible skip
  316. if ($extraFieldInfo['visible_to_self'] != 1) {
  317. continue;
  318. }
  319. // if is not visible to others skip also
  320. if ($extraFieldInfo['visible_to_others'] != 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. $extra_information_value .= '<li class="list-group-item">'.ucfirst($extraFieldInfo['display_text']).': '.$data.'</li>';
  375. break;
  376. }
  377. }
  378. }
  379. // if there are information to show
  380. if (!empty($extra_information_value)) {
  381. $extra_information_value = '<ul class="list-group">'.$extra_information_value.'</ul>';
  382. $extra_information .= Display::panelCollapse(
  383. get_lang('ExtraInformation'),
  384. $extra_information_value,
  385. 'sn-extra-information',
  386. null,
  387. 'sn-extra-accordion',
  388. 'sn-extra-collapse'
  389. );
  390. }
  391. }
  392. // If there are information to show Block Extra Information
  393. if (!empty($extra_information_value)) {
  394. $social_extra_info_block = $extra_information;
  395. }
  396. // MY GROUPS
  397. $results = $userGroup->get_groups_by_user($my_user_id, 0);
  398. $grid_my_groups = array();
  399. $max_numbers_of_group = 4;
  400. if (is_array($results) && count($results) > 0) {
  401. $i = 1;
  402. foreach ($results as $result) {
  403. if ($i > $max_numbers_of_group) {
  404. break;
  405. }
  406. $id = $result['id'];
  407. $url_open = '<a href="group_view.php?id='.$id.'">';
  408. $url_close = '</a>';
  409. $icon = '';
  410. $name = cut($result['name'], CUT_GROUP_NAME, true);
  411. if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  412. $icon = Display::return_icon(
  413. 'social_group_admin.png',
  414. get_lang('Admin'),
  415. array('style'=>'vertical-align:middle;width:16px;height:16px;')
  416. );
  417. } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  418. $icon = Display::return_icon(
  419. 'social_group_moderator.png',
  420. get_lang('Moderator'),
  421. array('style'=>'vertical-align:middle;width:16px;height:16px;')
  422. );
  423. }
  424. $count_users_group = count($userGroup->get_all_users_by_group($id));
  425. if ($count_users_group == 1) {
  426. $count_users_group = $count_users_group.' '.get_lang('Member');
  427. } else {
  428. $count_users_group = $count_users_group.' '.get_lang('Members');
  429. }
  430. $item_name = $url_open.$name.$icon.$url_close;
  431. $item_actions = '';
  432. $grid_my_groups[] = array(
  433. $item_name,
  434. $url_open.$result['picture'].$url_close,
  435. $item_actions,
  436. );
  437. $i++;
  438. }
  439. }
  440. // Block My Groups
  441. if (count($grid_my_groups) > 0) {
  442. $my_groups = '';
  443. $count_groups = 0;
  444. if (count($results) == 1) {
  445. $count_groups = count($results);
  446. } else {
  447. $count_groups = count($results);
  448. }
  449. $my_groups .= '<div class="panel panel-default">';
  450. $my_groups .= '<div class="panel-heading">'.get_lang('MyGroups').' ('.$count_groups.') </div>';
  451. if ($i > $max_numbers_of_group) {
  452. if (api_get_user_id() == $user_id) {
  453. $my_groups .= '<div class="box_shared_profile_group_actions">'
  454. .'<a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
  455. } else {
  456. $my_groups .= '<div class="box_shared_profile_group_actions">'
  457. .'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
  458. .'?view=mygroups&height=390&width=610&user_id='.$user_id.'"'
  459. .' class="ajax" title="'.get_lang('SeeAll').'" >'
  460. .get_lang('SeeAllMyGroups')
  461. .'</a></div>';
  462. }
  463. }
  464. $total = count($grid_my_groups);
  465. $i = 1;
  466. foreach ($grid_my_groups as $group) {
  467. $my_groups .= '<div class="panel-body">';
  468. $my_groups .= $group[0];
  469. $my_groups .= '</div>';
  470. $i++;
  471. }
  472. $my_groups .= '</div>';
  473. $social_group_info_block = $my_groups;
  474. }
  475. // Block Social Course
  476. $my_courses = null;
  477. // COURSES LIST
  478. if (is_array($list)) {
  479. // Courses without sessions
  480. $my_course = '';
  481. $i = 1;
  482. foreach ($list as $key => $value) {
  483. if (empty($value[2])) { //if out of any session
  484. $my_courses .= $value[1];
  485. $i++;
  486. }
  487. }
  488. $social_course_block .= $my_courses;
  489. }
  490. // Block Social Sessions
  491. if (count($sessionList) > 0) {
  492. //$social_session_block = $htmlSessionList;
  493. $social_session_block = $sessionList;
  494. }
  495. // Block Social User Feeds
  496. $user_feeds = SocialManager::get_user_feeds($user_id);
  497. if (!empty($user_feeds)) {
  498. $social_rss_block = Display::panel($user_feeds, get_lang('RSSFeeds'));
  499. }
  500. // Productions
  501. $production_list = UserManager::build_production_list($user_id);
  502. // Images uploaded by course
  503. $file_list = '';
  504. if (is_array($course_list_code) && count($course_list_code) > 0) {
  505. foreach ($course_list_code as $course) {
  506. $file_list .= UserManager::get_user_upload_files_by_course(
  507. $user_id,
  508. $course['code'],
  509. $resourcetype = 'images'
  510. );
  511. }
  512. }
  513. $count_pending_invitations = 0;
  514. if (!isset($_GET['u']) ||
  515. (isset($_GET['u']) && $_GET['u'] == api_get_user_id())
  516. ) {
  517. $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
  518. $list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
  519. $count_pending_invitations = count($pending_invitations);
  520. }
  521. if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) {
  522. // Pending invitations
  523. if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u'] == api_get_user_id())) {
  524. if ($count_pending_invitations > 0) {
  525. $invitations = '<ul class="list-group">';
  526. for ($i = 0; $i < $count_pending_invitations; $i++) {
  527. $user_invitation_id = $pending_invitations[$i]['user_sender_id'];
  528. $invitations .= '<li id="dpending_'.$user_invitation_id.'" class="list-group-item">';
  529. $invitations .= '<img class="img-rounded" '
  530. .' src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'"'
  531. .' width="40px">';
  532. $userInfo = api_get_user_info($user_invitation_id);
  533. $invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">'
  534. .api_get_person_name($userInfo['firstname'], $userInfo['lastname']).'</a>';
  535. $invitations .= '<div class="pull-right">';
  536. $invitations .= Display::toolbarButton(
  537. get_lang('SocialAddToFriends'),
  538. api_get_path(WEB_AJAX_PATH).'social.ajax.php?'.http_build_query([
  539. 'a' => 'add_friend',
  540. 'friend_id' => $user_invitation_id,
  541. 'is_my_friend' => 'friend'
  542. ]),
  543. 'plus',
  544. 'default',
  545. ['class' => 'btn-sm'],
  546. false
  547. );
  548. $invitations .= '</div>';
  549. $invitations .= '<div id="id_response"></div>';
  550. $invitations .= '</li>';
  551. }
  552. $invitations .= '</ul>';
  553. $listInvitations = Display::panelCollapse(
  554. get_lang('PendingInvitations'),
  555. $invitations,
  556. 'invitations',
  557. null,
  558. 'invitations-acordion',
  559. 'invitations-collapse'
  560. );
  561. }
  562. }
  563. // Productions
  564. $production_list = UserManager::build_production_list($user_id);
  565. $product_content = '';
  566. if (!empty($production_list)) {
  567. $product_content .= '<div><h3>'.get_lang('MyProductions').'</h3></div>';
  568. $product_content .= $production_list;
  569. $socialRightInformation .= SocialManager::social_wrapper_div($product_content, 4);
  570. }
  571. $images_uploaded = null;
  572. // Images uploaded by course
  573. if (!empty($file_list)) {
  574. $images_uploaded .= '<div><h3>'.get_lang('ImagesUploaded').'</h3></div>';
  575. $images_uploaded .= '<div class="social-content-information">';
  576. $images_uploaded .= $file_list;
  577. $images_uploaded .= '</div>';
  578. $socialRightInformation .= SocialManager::social_wrapper_div($images_uploaded, 4);
  579. }
  580. }
  581. if (!empty($user_info['competences']) || !empty($user_info['diplomas'])
  582. || !empty($user_info['openarea']) || !empty($user_info['teach'])) {
  583. $more_info .= '<div><h3>'.get_lang('MoreInformation').'</h3></div>';
  584. if (!empty($user_info['competences'])) {
  585. $more_info .= '<br />';
  586. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
  587. $more_info .= '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
  588. $more_info .= '<br />';
  589. }
  590. if (!empty($user_info['diplomas'])) {
  591. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
  592. $more_info .= '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
  593. $more_info .= '<br />';
  594. }
  595. if (!empty($user_info['openarea'])) {
  596. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
  597. $more_info .= '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
  598. $more_info .= '<br />';
  599. }
  600. if (!empty($user_info['teach'])) {
  601. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
  602. $more_info .= '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
  603. $more_info .= '<br />';
  604. }
  605. $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4);
  606. }
  607. }
  608. $tpl = new Template(get_lang('Social'));
  609. // Block Avatar Social
  610. SocialManager::setSocialUserBlock(
  611. $tpl,
  612. $friendId,
  613. 'shared_profile',
  614. 0,
  615. $show_full_profile
  616. );
  617. $tpl->assign('social_friend_block', $friend_html);
  618. $tpl->assign('social_menu_block', $social_menu_block);
  619. $tpl->assign('social_wall_block', $social_wall_block);
  620. $tpl->assign('social_post_wall_block', $social_post_wall_block);
  621. $tpl->assign('social_extra_info_block', $social_extra_info_block);
  622. $tpl->assign('social_course_block', $social_course_block);
  623. $tpl->assign('social_group_info_block', $social_group_info_block);
  624. $tpl->assign('social_rss_block', $social_rss_block);
  625. $tpl->assign('social_skill_block', SocialManager::getSkillBlock($my_user_id));
  626. $tpl->assign('session_list', $social_session_block);
  627. $tpl->assign('invitations', $listInvitations);
  628. $tpl->assign('social_right_information', $socialRightInformation);
  629. $tpl->assign('social_auto_extend_link', $socialAutoExtendLink);
  630. $formModalTpl = new Template();
  631. $formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form('send_invitation'));
  632. $template = $formModalTpl->get_template('social/form_modals.tpl');
  633. $formModals = $formModalTpl->fetch($template);
  634. $tpl->assign('form_modals', $formModals);
  635. $social_layout = $tpl->get_template('social/profile.tpl');
  636. $tpl->display($social_layout);