profile.php 26 KB

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