profile.php 27 KB

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