profile.php 26 KB

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