profile.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  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. * @package chamilo.social
  8. */
  9. $cidReset = true;
  10. require_once '../inc/global.inc.php';
  11. // Include OpenGraph NOT AVAILABLE
  12. require_once api_get_path(LIBRARY_PATH).'opengraph/OpenGraph.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. $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_skill_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. $idMessage = SocialManager::sendWallMessage(api_get_user_id(), $friendId, $_POST['social_wall_new_msg_main'], $messageId, MESSAGE_STATUS_WALL_POST);
  34. if (!empty($_FILES['picture']['tmp_name']) && $idMessage > 0) {
  35. $error = SocialManager::sendWallMessageAttachmentFile(api_get_user_id(), $_FILES['picture'], $idMessage, $fileComment = '');
  36. }
  37. $url = api_get_path(WEB_CODE_PATH) . 'social/profile.php';
  38. $url .= empty($_SERVER['QUERY_STRING']) ? '' : '?'.Security::remove_XSS($_SERVER['QUERY_STRING']);
  39. header('Location: ' . $url);
  40. exit;
  41. } else if (!empty($_POST['social_wall_new_msg']) && !empty($_POST['messageId'])) {
  42. $messageId = intval($_POST['messageId']);
  43. $res = SocialManager::sendWallMessage(api_get_user_id(), $friendId, $_POST['social_wall_new_msg'], $messageId , MESSAGE_STATUS_WALL);
  44. $url = api_get_path(WEB_CODE_PATH) . 'social/profile.php';
  45. $url .= empty($_SERVER['QUERY_STRING']) ? '' : '?'.Security::remove_XSS($_SERVER['QUERY_STRING']);
  46. header('Location: ' . $url);
  47. exit;
  48. } else if (isset($_GET['messageId'])) {
  49. $messageId = Security::remove_XSS($_GET['messageId']);
  50. $status = SocialManager::deleteMessage($messageId);
  51. header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/profile.php');
  52. exit;
  53. } else if (isset($_GET['u'])) { //I'm your friend? I can see your profile?
  54. $user_id = intval($_GET['u']);
  55. if (api_is_anonymous($user_id, true)) {
  56. api_not_allowed(true);
  57. }
  58. // It's me!
  59. if (api_get_user_id() != $user_id) {
  60. $user_info = UserManager::get_user_info_by_id($user_id);
  61. $show_full_profile = false;
  62. if (!$user_info) {
  63. // user does no exist !!
  64. api_not_allowed(true);
  65. } else {
  66. //checking the relationship between me and my friend
  67. $my_status= SocialManager::get_relation_between_contacts(api_get_user_id(), $user_id);
  68. if (in_array($my_status, array(
  69. USER_RELATION_TYPE_PARENT,
  70. USER_RELATION_TYPE_FRIEND,
  71. USER_RELATION_TYPE_GOODFRIEND
  72. ))) {
  73. $show_full_profile = true;
  74. }
  75. //checking the relationship between my friend and me
  76. $my_friend_status = SocialManager::get_relation_between_contacts($user_id, api_get_user_id());
  77. if (in_array($my_friend_status, array(
  78. USER_RELATION_TYPE_PARENT,
  79. USER_RELATION_TYPE_FRIEND,
  80. USER_RELATION_TYPE_GOODFRIEND
  81. ))) {
  82. $show_full_profile = true;
  83. } else {
  84. // im probably not a good friend
  85. $show_full_profile = false;
  86. }
  87. }
  88. } else {
  89. $user_info = UserManager::get_user_info_by_id($user_id);
  90. }
  91. } else {
  92. $user_info = UserManager::get_user_info_by_id($user_id);
  93. }
  94. if ($user_info['user_id'] == api_get_user_id()) {
  95. $isSelfUser = true;
  96. } else {
  97. $isSelfUser = false;
  98. }
  99. $userIsOnline = user_is_online($user_id);
  100. $libpath = api_get_path(LIBRARY_PATH);
  101. require_once $libpath.'magpierss/rss_fetch.inc';
  102. $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
  103. $socialAjaxUrl = api_get_path(WEB_AJAX_PATH).'social.ajax.php';
  104. $javascriptDir = api_get_path(LIBRARY_PATH) . 'javascript/';
  105. api_block_anonymous_users();
  106. $locale = _api_get_locale_from_language();
  107. // Add Jquery scroll pagination plugin
  108. $htmlHeadXtra[] = api_get_js('jscroll/jquery.jscroll.js');
  109. // Add Jquery Time ago plugin
  110. $htmlHeadXtra[] = api_get_js('jquery-timeago/jquery.timeago.js');
  111. $timeAgoLocaleDir = $javascriptDir . 'jquery-timeago/locales/jquery.timeago.' . $locale . '.js';
  112. if (file_exists($timeAgoLocaleDir)) {
  113. $htmlHeadXtra[] = api_get_js('jquery-timeago/locales/jquery.timeago.' . $locale . '.js');
  114. }
  115. $htmlHeadXtra[] = '<script>
  116. $(document).ready(function (){
  117. var container = $("#wallMessages");
  118. container.jscroll({
  119. loadingHtml: "<div class=\"well_border\">' . get_lang('Loading') . ' </div>",
  120. nextSelector: "a.nextPage:last",
  121. contentSelector: "",
  122. callback: timeAgo
  123. });
  124. timeAgo()
  125. });
  126. function timeAgo() {
  127. $(".timeago").timeago();
  128. }
  129. function register_friend(element_input) {
  130. if(confirm("'.get_lang('AddToFriends').'")) {
  131. name_button=$(element_input).attr("id");
  132. name_div_id="id_"+name_button.substring(13);
  133. user_id=name_div_id.split("_");
  134. user_friend_id=user_id[1];
  135. $.ajax({
  136. contentType: "application/x-www-form-urlencoded",
  137. beforeSend: function(objeto) {
  138. $("div#dpending_"+user_friend_id).html("<img src=\'../inc/lib/javascript/indicator.gif\' />");
  139. },
  140. type: "POST",
  141. url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=add_friend",
  142. data: "friend_id="+user_friend_id+"&is_my_friend="+"friend",
  143. success: function(datos) {
  144. $("#dpending_" + user_friend_id).html(datos);
  145. }
  146. });
  147. }
  148. }
  149. </script>';
  150. $nametool = get_lang('ViewMySharedProfile');
  151. if (isset($_GET['shared'])) {
  152. $my_link='../social/profile.php';
  153. $link_shared='shared='.Security::remove_XSS($_GET['shared']);
  154. } else {
  155. $my_link='../social/profile.php';
  156. $link_shared='';
  157. }
  158. $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('SocialNetwork') );
  159. if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) {
  160. $info_user = api_get_user_info($_GET['u']);
  161. $interbreadcrumb[]= array (
  162. 'url' => '#',
  163. 'name' => api_get_person_name($info_user['firstName'], $info_user['lastName']));
  164. $nametool = '';
  165. }
  166. if (isset($_GET['u'])) {
  167. $param_user='u='.Security::remove_XSS($_GET['u']);
  168. }else {
  169. $info_user = api_get_user_info(api_get_user_id());
  170. $param_user = '';
  171. }
  172. $_SESSION['social_user_id'] = intval($user_id);
  173. /**
  174. * Display
  175. */
  176. //Setting some course info
  177. $my_user_id = isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
  178. $personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
  179. $course_list_code = array();
  180. $i=1;
  181. if (is_array($personal_course_list)) {
  182. foreach ($personal_course_list as $my_course) {
  183. if ($i<=10) {
  184. $list[] = SocialManager::get_logged_user_course_html($my_course, $i);
  185. $course_list_code[] = array('code'=> $my_course['code']);
  186. } else {
  187. break;
  188. }
  189. $i++;
  190. }
  191. //to avoid repeted courses
  192. $course_list_code = array_unique_dimensional($course_list_code);
  193. }
  194. //Social Block Menu
  195. $social_menu_block = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
  196. //Setting some session info
  197. $user_info = api_get_user_info($my_user_id);
  198. $sessionList = SessionManager::getSessionsFollowedByUser($my_user_id, $user_info['status']);
  199. $htmlSessionList = null;
  200. foreach ($sessionList as $session) {
  201. $htmlSessionList .= '<div>';
  202. $htmlSessionList .= Display::return_icon('session.png', get_lang('Session'));
  203. $htmlSessionList .= $session['name'];
  204. $htmlSessionList .= '</div>';
  205. }
  206. // My friends
  207. $friend_html = SocialManager::listMyFriends($user_id, $link_shared ,$show_full_profile);
  208. $social_left_content = '<div class="well sidebar-nav">' .$friend_html . '</div>';
  209. /*
  210. $personal_info = null;
  211. if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
  212. $personal_info .= '<div><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
  213. } else {
  214. //--- Basic Information
  215. $personal_info .= '<div><h3>'.get_lang('Profile').'</h3></div>';
  216. }
  217. if ($show_full_profile) {
  218. $personal_info .= '<dl class="dl-horizontal">';
  219. if ($isAdmin || $isSelfUser) {
  220. $personal_info .= '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].' </dd>';
  221. }
  222. if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
  223. $personal_info .= '<dt>'.get_lang('Name')
  224. .'</dt><dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';
  225. }
  226. if (($isAdmin || $isSelfUser) && !empty($user_info['official_code'])) {
  227. $personal_info .= '<dt>'.get_lang('OfficialCode').'</dt><dd>'.$user_info['official_code'].'</dd>';
  228. }
  229. if (!empty($user_info['email'])) {
  230. if (api_get_setting('show_email_addresses')=='true') {
  231. $personal_info .= '<dt>'.get_lang('Email').'</dt><dd>'.$user_info['email'].'</dd>';
  232. }
  233. if (!empty($user_info['phone'])) {
  234. $personal_info .= '<dt>'.get_lang('Phone').'</dt><dd>'. $user_info['phone'].'</dd>';
  235. }
  236. $personal_info .= '</dl>';
  237. }
  238. } else {
  239. $personal_info .= '<dl class="dl-horizontal">';
  240. if (!empty($user_info['username'])) {
  241. if ($isAdmin || $isSelfUser) {
  242. $personal_info .= '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].'</dd>';
  243. }
  244. }
  245. $personal_info .= '</dl>';
  246. }
  247. */
  248. //Social Block Wall
  249. $wallSocialAddPost = SocialManager::getWallForm();
  250. $social_wall_block = $wallSocialAddPost;
  251. //Social Post Wall
  252. $post_wall = SocialManager::getWallMessagesByUser($my_user_id, $friendId) ;
  253. $social_post_wall_block = '<div class="panel panel-default social-post">';
  254. $social_post_wall_block .= '<div class="panel-heading">Mis publicaciones</div>';
  255. $social_post_wall_block .='<div class="panel-body">';
  256. if(empty($post_wall)){
  257. $social_post_wall_block .= '<p>'.get_lang("NoPosts").'</p>';
  258. }else{
  259. $social_post_wall_block .= $post_wall;
  260. }
  261. $social_post_wall_block .= '</div></div>';
  262. $socialAutoExtendLink = Display::url(
  263. get_lang('SeeMore'),
  264. $socialAjaxUrl . '?u='. $my_user_id . '&a=listWallMessage&start=10&length=5',
  265. array(
  266. 'class' => 'nextPage next',
  267. )
  268. );
  269. /* $socialRightInformation = SocialManager::social_wrapper_div($personal_info, 4); */
  270. $socialRightInformation = null;
  271. //$social_right_content .= SocialManager::social_wrapper_div($wallSocial, 5);
  272. $social_right_content = null;
  273. if ($show_full_profile) {
  274. // Block Extra information
  275. $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
  276. $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
  277. $extra_user_data = UserManager::get_extra_user_data($user_id);
  278. $extra_information = '';
  279. if (is_array($extra_user_data) && count($extra_user_data)>0 ) {
  280. $extra_information .= '<div class="panel panel-default">';
  281. $extra_information .= '<div class="panel-heading">'.get_lang('ExtraInformation').'</div>';
  282. $extra_information .='<div class="panel-body">';
  283. $extra_information_value = '';
  284. foreach($extra_user_data as $key=>$data) {
  285. //Avoding parameters
  286. if (in_array($key, array('mail_notify_invitation','mail_notify_message', 'mail_notify_group_message' ))) {
  287. continue;
  288. }
  289. // get display text, visibility and type from user_field table
  290. $field_variable = str_replace('extra_','',$key);
  291. $sql = "SELECT field_display_text,field_visible,field_type,id "
  292. ." FROM $t_uf WHERE field_variable ='$field_variable'";
  293. $res_field = Database::query($sql);
  294. $row_field = Database::fetch_row($res_field);
  295. $field_display_text = $row_field[0];
  296. $field_visible = $row_field[1];
  297. $field_type = $row_field[2];
  298. $field_id = $row_field[3];
  299. if ($field_visible == 1) {
  300. if (is_array($data)) {
  301. $extra_information_value .= '<dt>'.ucfirst($field_display_text).'</dt>'
  302. .'<dd> '.implode(',',$data).'</dd>';
  303. } else {
  304. if ($field_type == UserManager::USER_FIELD_TYPE_DOUBLE_SELECT) {
  305. $id_options = explode(';',$data);
  306. $value_options = array();
  307. // get option display text from user_field_options table
  308. foreach ($id_options as $id_option) {
  309. $sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'";
  310. $res_options = Database::query($sql);
  311. $row_options = Database::fetch_row($res_options);
  312. $value_options[] = $row_options[0];
  313. }
  314. $extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt>'
  315. .'<dd>'.implode(' ',$value_options).'</dd>';
  316. } elseif ($field_type == UserManager::USER_FIELD_TYPE_TAG ) {
  317. $user_tags = UserManager::get_user_tags($user_id, $field_id);
  318. $tag_tmp = array();
  319. foreach ($user_tags as $tags) {
  320. $tag_tmp[] = '<a class="label label_tag"'
  321. .' href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tags['tag'].'">'
  322. .$tags['tag']
  323. .'</a>';
  324. }
  325. if (is_array($user_tags) && count($user_tags)>0) {
  326. $extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt>'
  327. .'<dd>'.implode('', $tag_tmp).'</dd>';
  328. }
  329. } elseif ($field_type == UserManager::USER_FIELD_TYPE_SOCIAL_PROFILE) {
  330. $icon_path = UserManager::get_favicon_from_url($data);
  331. $bottom = '0.2';
  332. //quick hack for hi5
  333. $domain = parse_url($icon_path, PHP_URL_HOST);
  334. if ($domain == 'www.hi5.com' or $domain == 'hi5.com') {
  335. $bottom = '-0.8';
  336. }
  337. $data = '<a href="'.$data.'">'
  338. .'<img src="'.$icon_path.'" alt="icon"'
  339. .' style="margin-right:0.5em;margin-bottom:'.$bottom.'em;" />'
  340. .$field_display_text
  341. .'</a>';
  342. $extra_information_value .= '<dd>'.$data.'</dd>';
  343. } else {
  344. if (!empty($data)) {
  345. $extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt><dd>'.$data.'</dd>';
  346. }
  347. }
  348. }
  349. }
  350. }
  351. // if there are information to show
  352. if (!empty($extra_information_value)) {
  353. $extra_information .= $extra_information_value;
  354. }
  355. $extra_information .= '</div></div>'; //social-profile-info
  356. }
  357. //If there are information to show Block Extra Information
  358. if (!empty($extra_information_value)) {
  359. $social_extra_info_block = $extra_information;
  360. }
  361. // MY GROUPS
  362. $results = GroupPortalManager::get_groups_by_user($my_user_id, 0);
  363. $grid_my_groups = array();
  364. $max_numbers_of_group = 4;
  365. if (is_array($results) && count($results) > 0) {
  366. $i = 1;
  367. foreach ($results as $result) {
  368. if ($i > $max_numbers_of_group) break;
  369. $id = $result['id'];
  370. $url_open = '<a href="groups.php?id='.$id.'">';
  371. $url_close = '</a>';
  372. $icon = '';
  373. $name = cut($result['name'],CUT_GROUP_NAME,true);
  374. if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
  375. $icon = Display::return_icon(
  376. 'social_group_admin.png',
  377. get_lang('Admin'),
  378. array('style'=>'vertical-align:middle;width:16px;height:16px;')
  379. );
  380. } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
  381. $icon = Display::return_icon(
  382. 'social_group_moderator.png',
  383. get_lang('Moderator'),
  384. array('style'=>'vertical-align:middle;width:16px;height:16px;')
  385. );
  386. }
  387. $count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
  388. if ($count_users_group == 1 ) {
  389. $count_users_group = $count_users_group.' '.get_lang('Member');
  390. } else {
  391. $count_users_group = $count_users_group.' '.get_lang('Members');
  392. }
  393. //$picture = GroupPortalManager::get_picture_group($result['id'], $result['picture_uri'],80);
  394. $item_name = $url_open.$name.$icon.$url_close;
  395. if ($result['description'] != '') {
  396. //$item_description = '<div class="box_shared_profile_group_description">'
  397. //.'<p class="social-groups-text4">'.cut($result['description'],100,true).'</p></div>';
  398. } else {
  399. //$item_description = '<div class="box_shared_profile_group_description">'
  400. //.'<span class="social-groups-text2"></span><p class="social-groups-text4"></p></div>';
  401. }
  402. //$result['picture_uri'] = '<div class="box_shared_profile_group_image">'
  403. //.'<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50"'
  404. //.' border="2" align="left" width="50" /></div>';
  405. $item_actions = '';
  406. //if (api_get_user_id() == $user_id) {
  407. //$item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id='.$id.'">'
  408. //.get_lang('SeeMore').$url_close.'</div>';
  409. //}
  410. $grid_my_groups[]= array($item_name,$url_open.$result['picture_uri'].$url_close, $item_actions);
  411. $i++;
  412. }
  413. }
  414. //Block My Groups
  415. if (count($grid_my_groups) > 0) {
  416. $my_groups = '';
  417. $count_groups = 0;
  418. if (count($results) == 1 ) {
  419. $count_groups = count($results);
  420. } else {
  421. $count_groups = count($results);
  422. }
  423. $my_groups .= '<div class="panel panel-default">';
  424. $my_groups .= '<div class="panel-heading">'.get_lang('MyGroups').' ('.$count_groups.') </div>';
  425. if ($i > $max_numbers_of_group) {
  426. if (api_get_user_id() == $user_id) {
  427. $my_groups .= '<div class="box_shared_profile_group_actions">'
  428. .'<a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
  429. } else {
  430. $my_groups .= '<div class="box_shared_profile_group_actions">'
  431. .'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
  432. .'?view=mygroups&height=390&width=610&user_id='.$user_id.'"'
  433. .' class="ajax" title="'.get_lang('SeeAll').'" >'
  434. .get_lang('SeeAllMyGroups')
  435. .'</a></div>';
  436. }
  437. }
  438. $total = count($grid_my_groups);
  439. $i = 1;
  440. foreach($grid_my_groups as $group) {
  441. $my_groups .= '<div class="panel-body">';
  442. $my_groups .= $group[0];
  443. $my_groups .= '</div>';
  444. if ($i < $total) {
  445. $my_groups .= ', ';
  446. }
  447. $i++;
  448. }
  449. $my_groups .= '</div>';
  450. $social_group_info_block = $my_groups;
  451. }
  452. //Block Social Course
  453. $my_courses = null;
  454. // COURSES LIST
  455. if ( is_array($list) ) {
  456. $my_courses .= '<div class="panel panel-default">';
  457. $my_courses .= '<div class="panel-heading">'.api_ucfirst(get_lang('MyCourses')).'</div>';
  458. $my_courses .= '<div class="panel-body">';
  459. //Courses without sessions
  460. $i=1;
  461. foreach ($list as $key => $value) {
  462. if ( empty($value[2]) ) { //if out of any session
  463. $my_courses .= $value[1];
  464. $my_courses .= '<div id="social_content'.$i.'"'
  465. .' class="course_social_content" style="display:none" >s</div>';
  466. $i++;
  467. }
  468. }
  469. $my_courses .= '</div></div>';
  470. $social_course_block .= $my_courses;
  471. }
  472. //Block Social Sessions
  473. if (count($sessionList) > 0) {
  474. $sessions = '<div class="panel panel-default">';
  475. $sessions .= '<div class="panel-heading">'.api_ucfirst(get_lang('MySessions')).'</div>';
  476. $sessions .= '<div class="panel-body">'.$htmlSessionList.'</div>';
  477. $sessions .= '</div>';
  478. $social_session_block = $sessions;
  479. }
  480. // Block Social User Feeds
  481. $user_feeds = SocialManager::get_user_feeds($user_id);
  482. if (!empty($user_feeds)) {
  483. $rss = '<div class="panel panel-default social-rss">';
  484. $rss .= '<div class="panel-heading">'.get_lang('RSSFeeds').'</div>';
  485. $rss .= '<div class="panel-body">'.$user_feeds.'</div></div>';
  486. $social_rss_block = $rss;
  487. }
  488. //BLock Social Skill
  489. if (api_get_setting('allow_skills_tool') == 'true') {
  490. $skill = new Skill();
  491. $ranking = $skill->get_user_skill_ranking($my_user_id);
  492. $skills = $skill->get_user_skills($my_user_id, true);
  493. $social_skill_block = '<div class="panel panel-default social-skill">';
  494. $social_skill_block .= '<div class="panel-heading">' . get_lang('Skills');
  495. $social_skill_block .= '<div class="btn-group pull-right"> <a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#">
  496. <span class="caret"></span></a>
  497. <ul class="dropdown-menu">';
  498. if (api_is_student() || api_is_student_boss() || api_is_drh()) {
  499. $social_skill_block .= '<li>' . Display::url(
  500. get_lang('SkillsReport'),
  501. api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
  502. ) . '</li>';
  503. }
  504. $social_skill_block .= '<li>' . Display::url(
  505. get_lang('SkillsWheel'),
  506. api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
  507. ) . '</li>';
  508. $social_skill_block .= '<li>' . Display::url(
  509. sprintf(get_lang('YourSkillRankingX'), $ranking),
  510. api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
  511. ) . '</li>';
  512. $social_skill_block .= '</ul></div></div>';
  513. $lis = '';
  514. if (!empty($skills)) {
  515. foreach ($skills as $skill) {
  516. $badgeImage = null;
  517. if (!empty($skill['icon'])) {
  518. $badgeImage = Display::img(
  519. api_get_path(WEB_DATA_PATH) . $skill['icon'],
  520. $skill['name']
  521. );
  522. } else {
  523. $badgeImage = Display::return_icon(
  524. 'badges-default.png',
  525. $skill['name'],
  526. array('title' => $skill['name']),ICON_SIZE_BIG
  527. );
  528. }
  529. $lis .= Display::tag(
  530. 'li',
  531. $badgeImage .
  532. '<div class="badges-name">' . $skill['name'] . '</div>'
  533. );
  534. }
  535. $social_skill_block .= '<div class="panel-body">';
  536. $social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges'));
  537. $social_skill_block .= '</div>';
  538. }else{
  539. $social_skill_block .= '<div class="panel-body">';
  540. $social_skill_block .= '<p>'. get_lang("WithoutAchievedSkills") . '</p>';
  541. $social_skill_block .= '<p>' . Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'</p>';
  542. $social_skill_block .= '</div>';
  543. }
  544. $social_skill_block.='</div>';
  545. }
  546. //--Productions
  547. $production_list = UserManager::build_production_list($user_id);
  548. // Images uploaded by course
  549. $file_list = '';
  550. if (is_array($course_list_code) && count($course_list_code)>0) {
  551. foreach ($course_list_code as $course) {
  552. $file_list.= UserManager::get_user_upload_files_by_course($user_id,$course['code'],$resourcetype='images');
  553. }
  554. }
  555. $count_pending_invitations = 0;
  556. if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
  557. $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
  558. $list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
  559. $count_pending_invitations = count($pending_invitations);
  560. }
  561. if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) {
  562. //Pending invitations
  563. if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
  564. if ($count_pending_invitations > 0) {
  565. $invitations = '<div><h3>'.get_lang('PendingInvitations').'</h3></div>';
  566. for ($i=0;$i<$count_pending_invitations;$i++) {
  567. $user_invitation_id = $pending_invitations[$i]['user_sender_id'];
  568. $invitations .= '<div id="dpending_'.$user_invitation_id.'" class="friend_invitations">';
  569. $invitations .= '<div style="float:left;width:60px;" >';
  570. $invitations .= '<img style="margin-bottom:5px;"'
  571. .' src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'"'
  572. .' width="60px">';
  573. $invitations .= '</div>';
  574. $invitations .= '<div style="padding-left:70px;">';
  575. $user_invitation_info = api_get_user_info($user_invitation_id);
  576. $invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php'
  577. .'?u='.$user_invitation_id.'">'
  578. .api_get_person_name(
  579. $user_invitation_info['firstname'],
  580. $user_invitation_info['lastname'])
  581. .'</a>';
  582. $invitations .= '<br />';
  583. $invitations .= Security::remove_XSS(
  584. cut($pending_invitations[$i]['content'], 50),
  585. STUDENT,
  586. true
  587. );
  588. $invitations .= '<br />';
  589. $invitations .= '<a id="btn_accepted_'.$user_invitation_id.'"'
  590. .' class="btn" onclick="register_friend(this)" href="javascript:void(0)">'
  591. .get_lang('SocialAddToFriends')
  592. .'</a>';
  593. $invitations .= '<div id="id_response"></div>';
  594. $invitations .= '</div>';
  595. $invitations .= '</div>';
  596. }
  597. $socialRightInformation .= SocialManager::social_wrapper_div($invitations, 4);
  598. }
  599. }
  600. //--Productions
  601. $production_list = UserManager::build_production_list($user_id);
  602. $product_content = '';
  603. if (!empty($production_list)) {
  604. $product_content .= '<div><h3>'.get_lang('MyProductions').'</h3></div>';
  605. $product_content .= $production_list;
  606. $socialRightInformation .= SocialManager::social_wrapper_div($product_content, 4);
  607. }
  608. $images_uploaded = null;
  609. // Images uploaded by course
  610. if (!empty($file_list)) {
  611. $images_uploaded .= '<div><h3>'.get_lang('ImagesUploaded').'</h3></div>';
  612. $images_uploaded .= '<div class="social-content-information">';
  613. $images_uploaded .= $file_list;
  614. $images_uploaded .= '</div>';
  615. $socialRightInformation .= SocialManager::social_wrapper_div($images_uploaded, 4);
  616. }
  617. }
  618. if (!empty($user_info['competences']) || !empty($user_info['diplomas'])
  619. || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
  620. $more_info .= '<div><h3>'.get_lang('MoreInformation').'</h3></div>';
  621. if (!empty($user_info['competences'])) {
  622. $more_info .= '<br />';
  623. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
  624. $more_info .= '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
  625. $more_info .= '<br />';
  626. }
  627. if (!empty($user_info['diplomas'])) {
  628. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
  629. $more_info .= '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
  630. $more_info .= '<br />';
  631. }
  632. if (!empty($user_info['openarea'])) {
  633. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
  634. $more_info .= '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
  635. $more_info .= '<br />';
  636. }
  637. if (!empty($user_info['teach'])) {
  638. $more_info .= '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
  639. $more_info .= '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
  640. $more_info .= '<br />';
  641. }
  642. $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4);
  643. }
  644. }
  645. $tpl = new Template(get_lang('Social'));
  646. // Block Avatar Social
  647. SocialManager::setSocialUserBlock($tpl, $user_id, 'shared_profile');
  648. $tpl->assign('social_menu_block', $social_menu_block);
  649. $tpl->assign('social_wall_block', $social_wall_block);
  650. $tpl->assign('social_post_wall_block', $social_post_wall_block);
  651. $tpl->assign('social_extra_info_block', $social_extra_info_block);
  652. $tpl->assign('social_course_block', $social_course_block);
  653. $tpl->assign('social_group_info_block', $social_group_info_block);
  654. $tpl->assign('social_rss_block', $social_rss_block);
  655. $tpl->assign('social_skill_block', $social_skill_block);
  656. $tpl->assign('social_session_block', $social_session_block);
  657. $tpl->assign('social_right_information', $socialRightInformation);
  658. $tpl->assign('social_auto_extend_link', $socialAutoExtendLink);
  659. $formModalTpl = new Template();
  660. $formModalTpl->assign('messageForm', MessageManager::generate_message_form('send_message'));
  661. $formModalTpl->assign('invitationForm', MessageManager::generate_invitation_form('send_invitation'));
  662. $formModals = $formModalTpl->fetch('default/social/form_modals.tpl');
  663. $tpl->assign('formModals', $formModals);
  664. $social_layout = $tpl->get_template('social/profile.tpl');
  665. $tpl->display($social_layout);