social.lib.php 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This class provides methods for the social network management.
  5. * Include/require it in your code to use its features.
  6. *
  7. * @package chamilo.social
  8. */
  9. /**
  10. * Code
  11. */
  12. //PLUGIN PLACES
  13. define('SOCIAL_LEFT_PLUGIN', 1);
  14. define('SOCIAL_CENTER_PLUGIN', 2);
  15. define('SOCIAL_RIGHT_PLUGIN', 3);
  16. define('CUT_GROUP_NAME', 50);
  17. //This require is necessary because we use constants that need to be loaded before the SocialManager class
  18. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  19. /**
  20. *
  21. * @package chamilo.social
  22. */
  23. class SocialManager extends UserManager
  24. {
  25. public function __construct()
  26. {
  27. }
  28. /**
  29. * Allow to see contacts list
  30. * @author isaac flores paz
  31. * @return array
  32. */
  33. public static function show_list_type_friends()
  34. {
  35. $friend_relation_list = array();
  36. $count_list = 0;
  37. $tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
  38. $sql = 'SELECT id,title FROM '.$tbl_my_friend_relation_type.' WHERE id<>6 ORDER BY id ASC';
  39. $result = Database::query($sql);
  40. while ($row = Database::fetch_array($result, 'ASSOC')) {
  41. $friend_relation_list[] = $row;
  42. }
  43. $count_list = count($friend_relation_list);
  44. if ($count_list == 0) {
  45. $friend_relation_list[] = get_lang('Unknown');
  46. } else {
  47. return $friend_relation_list;
  48. }
  49. }
  50. /**
  51. * Get relation type contact by name
  52. * @param string names of the kind of relation
  53. * @return int
  54. * @author isaac flores paz
  55. */
  56. public static function get_relation_type_by_name($relation_type_name)
  57. {
  58. $list_type_friend = self::show_list_type_friends();
  59. foreach ($list_type_friend as $value_type_friend) {
  60. if (strtolower($value_type_friend['title']) == $relation_type_name) {
  61. return $value_type_friend['id'];
  62. }
  63. }
  64. }
  65. /**
  66. * Get the kind of relation between contacts
  67. * @param int user id
  68. * @param int user friend id
  69. * @param string
  70. * @author isaac flores paz
  71. */
  72. public static function get_relation_between_contacts($user_id, $user_friend)
  73. {
  74. $tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
  75. $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_REL_USER);
  76. $sql = 'SELECT rt.id as id FROM '.$tbl_my_friend_relation_type.' rt '.
  77. 'WHERE rt.id=(SELECT uf.relation_type FROM '.$tbl_my_friend.' uf WHERE user_id='.((int) $user_id).' AND friend_user_id='.((int) $user_friend).' AND uf.relation_type <> '.USER_RELATION_TYPE_RRHH.' )';
  78. $res = Database::query($sql);
  79. if (Database::num_rows($res) > 0) {
  80. $row = Database::fetch_array($res, 'ASSOC');
  81. return $row['id'];
  82. } else {
  83. return USER_UNKNOW;
  84. }
  85. }
  86. /**
  87. * Gets friends id list
  88. * @param int user id
  89. * @param int group id
  90. * @param string name to search
  91. * @param bool true will load firstname, lastname, and image name
  92. * @return array
  93. * @author Julio Montoya <gugli100@gmail.com> Cleaning code, function renamed, $load_extra_info option added
  94. * @author isaac flores paz
  95. */
  96. public static function get_friends($user_id, $id_group = null, $search_name = null, $load_extra_info = true)
  97. {
  98. $list_ids_friends = array();
  99. $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_REL_USER);
  100. $tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER);
  101. $sql = 'SELECT friend_user_id FROM '.$tbl_my_friend.' WHERE relation_type NOT IN ('.USER_RELATION_TYPE_DELETED.', '.USER_RELATION_TYPE_RRHH.') AND friend_user_id<>'.((int) $user_id).' AND user_id='.((int) $user_id);
  102. if (isset($id_group) && $id_group > 0) {
  103. $sql.=' AND relation_type='.$id_group;
  104. }
  105. if (isset($search_name)) {
  106. $search_name = trim($search_name);
  107. $search_name = str_replace(' ', '', $search_name);
  108. $sql.=' AND friend_user_id IN (SELECT user_id FROM '.$tbl_my_user.' WHERE firstName LIKE "%'.Database::escape_string($search_name).'%" OR lastName LIKE "%'.Database::escape_string($search_name).'%" OR '.(api_is_western_name_order() ? 'concat(firstName, lastName)' : 'concat(lastName, firstName)').' like concat("%","'.Database::escape_string($search_name).'","%") ) ';
  109. }
  110. $res = Database::query($sql);
  111. while ($row = Database::fetch_array($res, 'ASSOC')) {
  112. if ($load_extra_info) {
  113. $path = UserManager::get_user_picture_path_by_id($row['friend_user_id'], 'web', false, true);
  114. $my_user_info = api_get_user_info($row['friend_user_id']);
  115. $list_ids_friends[] = array('friend_user_id' => $row['friend_user_id'], 'firstName' => $my_user_info['firstName'], 'lastName' => $my_user_info['lastName'], 'username' => $my_user_info['username'], 'image' => $path['file']);
  116. } else {
  117. $list_ids_friends[] = $row;
  118. }
  119. }
  120. return $list_ids_friends;
  121. }
  122. /**
  123. * get list web path of contacts by user id
  124. * @param int user id
  125. * @param int group id
  126. * @param string name to search
  127. * @param array
  128. * @author isaac flores paz
  129. */
  130. public static function get_list_path_web_by_user_id($user_id, $id_group = null, $search_name = null)
  131. {
  132. $combine_friend = array();
  133. $list_ids = self::get_friends($user_id, $id_group, $search_name);
  134. if (is_array($list_ids)) {
  135. foreach ($list_ids as $values_ids) {
  136. $list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'], 'web', false, true);
  137. $combine_friend = array('id_friend' => $list_ids, 'path_friend' => $list_path_image_friend);
  138. }
  139. }
  140. return $combine_friend;
  141. }
  142. /**
  143. * get web path of user invitate
  144. * @author isaac flores paz
  145. * @author Julio Montoya setting variable array
  146. * @param int user id
  147. * @return array
  148. */
  149. public static function get_list_web_path_user_invitation_by_user_id($user_id)
  150. {
  151. $list_ids = self::get_list_invitation_of_friends_by_user_id((int) $user_id);
  152. $list_path_image_friend = array();
  153. foreach ($list_ids as $values_ids) {
  154. $list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['user_sender_id'], 'web', false, true);
  155. }
  156. return $list_path_image_friend;
  157. }
  158. /**
  159. * Sends an invitation to contacts
  160. * @param int user id
  161. * @param int user friend id
  162. * @param string title of the message
  163. * @param string content of the message
  164. * @return boolean
  165. * @author isaac flores paz
  166. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  167. */
  168. public static function send_invitation_friend($user_id, $friend_id, $message_title, $message_content)
  169. {
  170. $tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
  171. $user_id = intval($user_id);
  172. $friend_id = intval($friend_id);
  173. //Just in case we replace the and \n and \n\r while saving in the DB
  174. $message_content = str_replace(array("\n", "\n\r"), '<br />', $message_content);
  175. $clean_message_title = Database::escape_string($message_title);
  176. $clean_message_content = Database::escape_string($message_content);
  177. $now = api_get_utc_datetime();
  178. $sql_exist = 'SELECT COUNT(*) AS count FROM '.$tbl_message.' WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status IN(5,6,7);';
  179. $res_exist = Database::query($sql_exist);
  180. $row_exist = Database::fetch_array($res_exist, 'ASSOC');
  181. if ($row_exist['count'] == 0) {
  182. $sql = ' INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content)
  183. VALUES('.$user_id.','.$friend_id.','.MESSAGE_STATUS_INVITATION_PENDING.',"'.$now.'","'.$clean_message_title.'","'.$clean_message_content.'") ';
  184. Database::query($sql);
  185. $sender_info = api_get_user_info($user_id);
  186. $notification = new Notification();
  187. $notification->save_notification(Notification::NOTIFICATION_TYPE_INVITATION, array($friend_id), $message_title, $message_content, $sender_info);
  188. return true;
  189. } else {
  190. //invitation already exist
  191. $sql_if_exist = 'SELECT COUNT(*) AS count, id FROM '.$tbl_message.' WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status = 7';
  192. $res_if_exist = Database::query($sql_if_exist);
  193. $row_if_exist = Database::fetch_array($res_if_exist, 'ASSOC');
  194. if ($row_if_exist['count'] == 1) {
  195. $sql_if_exist_up = 'UPDATE '.$tbl_message.'SET msg_status=5, content = "'.$clean_message_content.'" WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status = 7 ';
  196. Database::query($sql_if_exist_up);
  197. return true;
  198. } else {
  199. return false;
  200. }
  201. }
  202. }
  203. /**
  204. * Get number messages of the inbox
  205. * @author isaac flores paz
  206. * @param int user receiver id
  207. * @return int
  208. */
  209. public static function get_message_number_invitation_by_user_id($user_receiver_id)
  210. {
  211. $tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
  212. $sql = 'SELECT COUNT(*) as count_message_in_box FROM '.$tbl_message.' WHERE user_receiver_id='.intval($user_receiver_id).' AND msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
  213. $res = Database::query($sql);
  214. $row = Database::fetch_array($res, 'ASSOC');
  215. return $row['count_message_in_box'];
  216. }
  217. /**
  218. * Get invitation list received by user
  219. * @author isaac flores paz
  220. * @param int user id
  221. * @return array()
  222. */
  223. public static function get_list_invitation_of_friends_by_user_id($user_id)
  224. {
  225. $list_friend_invitation = array();
  226. $tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
  227. $sql = 'SELECT user_sender_id,send_date,title,content FROM '.$tbl_message.' WHERE user_receiver_id='.intval($user_id).' AND msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
  228. $res = Database::query($sql);
  229. while ($row = Database::fetch_array($res, 'ASSOC')) {
  230. $list_friend_invitation[] = $row;
  231. }
  232. return $list_friend_invitation;
  233. }
  234. /**
  235. * Get invitation list sent by user
  236. * @author Julio Montoya <gugli100@gmail.com>
  237. * @param int user id
  238. * @return array()
  239. */
  240. public static function get_list_invitation_sent_by_user_id($user_id)
  241. {
  242. $list_friend_invitation = array();
  243. $tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
  244. $sql = 'SELECT user_receiver_id, send_date,title,content FROM '.$tbl_message.' WHERE user_sender_id = '.intval($user_id).' AND msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
  245. $res = Database::query($sql);
  246. while ($row = Database::fetch_array($res, 'ASSOC')) {
  247. $list_friend_invitation[$row['user_receiver_id']] = $row;
  248. }
  249. return $list_friend_invitation;
  250. }
  251. /**
  252. * Accepts invitation
  253. * @param int user sender id
  254. * @param int user receiver id
  255. * @author isaac flores paz
  256. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  257. */
  258. public static function invitation_accepted($user_send_id, $user_receiver_id)
  259. {
  260. $tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
  261. $sql = 'UPDATE '.$tbl_message.' SET msg_status='.MESSAGE_STATUS_INVITATION_ACCEPTED.' WHERE user_sender_id='.((int) $user_send_id).' AND user_receiver_id='.((int) $user_receiver_id).';';
  262. Database::query($sql);
  263. }
  264. /**
  265. * Denies invitation
  266. * @param int user sender id
  267. * @param int user receiver id
  268. * @author isaac flores paz
  269. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  270. */
  271. public static function invitation_denied($user_send_id, $user_receiver_id)
  272. {
  273. $tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
  274. //$msg_status=7;
  275. //$sql='UPDATE '.$tbl_message.' SET msg_status='.$msg_status.' WHERE user_sender_id='.((int)$user_send_id).' AND user_receiver_id='.((int)$user_receiver_id).';';
  276. $sql = 'DELETE FROM '.$tbl_message.' WHERE user_sender_id='.((int) $user_send_id).' AND user_receiver_id='.((int) $user_receiver_id).';';
  277. Database::query($sql);
  278. }
  279. /**
  280. * allow attach to group
  281. * @author isaac flores paz
  282. * @param int user to qualify
  283. * @param int kind of rating
  284. * @return void()
  285. */
  286. public static function qualify_friend($id_friend_qualify, $type_qualify)
  287. {
  288. $tbl_user_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
  289. $user_id = api_get_user_id();
  290. $sql = 'UPDATE '.$tbl_user_friend.' SET relation_type='.((int) $type_qualify).' WHERE user_id='.((int) $user_id).' AND friend_user_id='.((int) $id_friend_qualify).';';
  291. Database::query($sql);
  292. }
  293. /**
  294. * Sends invitations to friends
  295. * @author Isaac Flores Paz <isaac.flores.paz@gmail.com>
  296. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  297. * @param void
  298. * @return string message invitation
  299. */
  300. public static function send_invitation_friend_user($userfriend_id, $subject_message = '', $content_message = '')
  301. {
  302. global $charset;
  303. $user_info = array();
  304. $user_info = api_get_user_info($userfriend_id);
  305. $succes = get_lang('MessageSentTo');
  306. $succes.= ' : '.api_get_person_name($user_info['firstName'], $user_info['lastName']);
  307. if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
  308. $send_message = MessageManager::send_message($userfriend_id, $subject_message, $content_message);
  309. if ($send_message) {
  310. echo Display::display_confirmation_message($succes, true);
  311. } else {
  312. echo Display::display_error_message(get_lang('ErrorSendingMessage'), true);
  313. }
  314. return false;
  315. } elseif (isset($userfriend_id) && !isset($subject_message)) {
  316. $count_is_true = false;
  317. if (isset($userfriend_id) && $userfriend_id > 0) {
  318. $message_title = get_lang('Invitation');
  319. $count_is_true = self::send_invitation_friend(api_get_user_id(), $userfriend_id, $message_title, $content_message);
  320. if ($count_is_true) {
  321. echo Display::display_confirmation_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false);
  322. } else {
  323. echo Display::display_warning_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false);
  324. }
  325. }
  326. }
  327. }
  328. /**
  329. * Get user's feeds
  330. * @param int User ID
  331. * @param int Limit of posts per feed
  332. * @return string HTML section with all feeds included
  333. * @author Yannick Warnier
  334. * @since Dokeos 1.8.6.1
  335. */
  336. public static function get_user_feeds($user, $limit = 5)
  337. {
  338. if (!function_exists('fetch_rss')) {
  339. return '';
  340. }
  341. $feeds = array();
  342. $feed = UserManager::get_extra_user_data_by_field($user, 'rssfeeds');
  343. if (empty($feed)) {
  344. return '';
  345. }
  346. $feeds = explode(';', $feed['rssfeeds']);
  347. if (count($feeds) == 0) {
  348. return '';
  349. }
  350. $res = '';
  351. foreach ($feeds as $url) {
  352. if (empty($url)) {
  353. continue;
  354. }
  355. $rss = @fetch_rss($url);
  356. $i = 1;
  357. if (!empty($rss->items)) {
  358. $icon_rss = '';
  359. if (!empty($feed)) {
  360. $icon_rss = Display::url(Display::return_icon('rss.png', '', array(), 32), Security::remove_XSS($feed['rssfeeds']), array('target' => '_blank'));
  361. }
  362. $res .= '<h2>'.$rss->channel['title'].''.$icon_rss.'</h2>';
  363. $res .= '<div class="social-rss-channel-items">';
  364. foreach ($rss->items as $item) {
  365. if ($limit >= 0 and $i > $limit) {
  366. break;
  367. }
  368. $res .= '<h3><a href="'.$item['link'].'">'.$item['title'].'</a></h3>';
  369. $res .= '<div class="social-rss-item-date">'.api_get_datetime($item['date_timestamp']).'</div>';
  370. $res .= '<div class="social-rss-item-content">'.$item['description'].'</div><br />';
  371. $i++;
  372. }
  373. $res .= '</div>';
  374. }
  375. }
  376. return $res;
  377. }
  378. /**
  379. * Helper functions definition
  380. */
  381. public static function get_logged_user_course_html($my_course, $count)
  382. {
  383. global $nosession, $nbDigestEntries, $orderKey, $digest, $thisCourseSysCode;
  384. if (!$nosession) {
  385. global $now, $date_start, $date_end;
  386. }
  387. //initialise
  388. $result = '';
  389. // Table definitions
  390. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  391. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  392. $course_code = $my_course['code'];
  393. $course_visual_code = $my_course['course_info']['official_code'];
  394. $course_title = $my_course['course_info']['title'];
  395. $course_info = Database :: get_course_info($course_code);
  396. $course_id = $course_info['real_id'];
  397. $course_access_settings = CourseManager :: get_access_settings($course_code);
  398. $course_visibility = $course_access_settings['visibility'];
  399. $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_code);
  400. //function logic - act on the data
  401. $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($course_code);
  402. if ($is_virtual_course) {
  403. // If the current user is also subscribed in the real course to which this
  404. // virtual course is linked, we don't need to display the virtual course entry in
  405. // the course list - it is combined with the real course entry.
  406. $target_course_code = CourseManager :: get_target_of_linked_course($course_code);
  407. $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code);
  408. if ($is_subscribed_in_target_course) {
  409. return; //do not display this course entry
  410. }
  411. }
  412. $s_htlm_status_icon = Display::return_icon('course.gif', get_lang('Course'));
  413. //display course entry
  414. $result .= '<div id="div_'.$count.'">';
  415. $result .= '<h3><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_course(this,\''.$course_id.'\' )">';
  416. $result .= $s_htlm_status_icon;
  417. //show a hyperlink to the course, unless the course is closed and user is not course admin
  418. if ($course_visibility != COURSE_VISIBILITY_HIDDEN && ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER)) {
  419. $result .= '<a href="javascript:void(0)" id="ln_'.$count.'" onclick=toogle_course(this,\''.$course_id.'\');>&nbsp;'.$course_title.'</a>';
  420. } else {
  421. $result .= $course_title." "." ".get_lang('CourseClosed')."";
  422. }
  423. $result .= '</h3>';
  424. //$current_course_settings = CourseManager :: get_access_settings($my_course['k']);
  425. // display the what's new icons
  426. if ($nbDigestEntries > 0) {
  427. reset($digest);
  428. $result .= '<ul>';
  429. while (list ($key2) = each($digest[$thisCourseSysCode])) {
  430. $result .= '<li>';
  431. if ($orderKey[1] == 'keyTools') {
  432. $result .= "<a href=\"$toolsList[$key2] [\"path\"] $thisCourseSysCode \">";
  433. $result .= "$toolsList[$key2][\"name\"]</a>";
  434. } else {
  435. $result .= api_convert_and_format_date($key2, DATE_FORMAT_LONG, date_default_timezone_get());
  436. }
  437. $result .= '</li>';
  438. $result .= '<ul>';
  439. reset($digest[$thisCourseSysCode][$key2]);
  440. while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2])) {
  441. $result .= '<li>';
  442. if ($orderKey[2] == 'keyTools') {
  443. $result .= "<a href=\"$toolsList[$key3] [\"path\"] $thisCourseSysCode \">";
  444. $result .= "$toolsList[$key3][\"name\"]</a>";
  445. } else {
  446. $result .= api_convert_and_format_date($key3, DATE_FORMAT_LONG, date_default_timezone_get());
  447. }
  448. $result .= '<ul compact="compact">';
  449. reset($digest[$thisCourseSysCode][$key2][$key3]);
  450. while (list ($key4, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2][$key3])) {
  451. $result .= '<li>';
  452. $result .= htmlspecialchars(substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
  453. $result .= '</li>';
  454. }
  455. $result .= '</ul>';
  456. $result .= '</li>';
  457. }
  458. $result .= '</ul>';
  459. $result .= '</li>';
  460. }
  461. $result .= '</ul>';
  462. }
  463. $result .= '</li>';
  464. $result .= '</div>';
  465. if (!$nosession) {
  466. $session = '';
  467. $active = false;
  468. if (!empty($my_course['session_name'])) {
  469. // Request for the name of the general coach
  470. $sql = 'SELECT lastname, firstname
  471. FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table.' tu
  472. ON ts.id_coach = tu.user_id
  473. WHERE ts.id='.(int) $my_course['id_session'].' LIMIT 1';
  474. $rs = Database::query($sql);
  475. $sessioncoach = Database::store_result($rs);
  476. $sessioncoach = $sessioncoach[0];
  477. $session = array();
  478. $session['title'] = $my_course['session_name'];
  479. if ($my_course['date_start'] == '0000-00-00') {
  480. $session['dates'] = get_lang('WithoutTimeLimits');
  481. if (api_get_setting('show_session_coach') === 'true') {
  482. $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
  483. }
  484. $active = true;
  485. } else {
  486. $session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
  487. if (api_get_setting('show_session_coach') === 'true') {
  488. $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
  489. }
  490. $active = ($date_start <= $now && $date_end >= $now) ? true : false;
  491. }
  492. }
  493. $my_course['id_session'] = isset($my_course['id_session']) ? $my_course['id_session'] : 0;
  494. $output = array($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active' => $active);
  495. } else {
  496. $output = array($my_course['user_course_cat'], $result);
  497. }
  498. //$my_course['creation_date'];
  499. return $output;
  500. }
  501. /**
  502. * Shows the right menu of the Social Network tool
  503. *
  504. * @param string highlight link possible values: group_add, home, messages, messages_inbox, messages_compose ,messages_outbox ,invitations, shared_profile, friends, groups search
  505. * @param int group id
  506. * @param int user id
  507. * @param bool show profile or not (show or hide the user image/information)
  508. *
  509. */
  510. public static function show_social_menu($show = '', $group_id = 0, $user_id = 0, $show_full_profile = false, $show_delete_account_button = false)
  511. {
  512. if (empty($user_id)) {
  513. $user_id = api_get_user_id();
  514. }
  515. $user_info = api_get_user_info($user_id, true);
  516. $current_user_id = api_get_user_id();
  517. $current_user_info = api_get_user_info($current_user_id, true);
  518. if ($current_user_id == $user_id) {
  519. $user_friend_relation = null;
  520. } else {
  521. $user_friend_relation = SocialManager::get_relation_between_contacts($current_user_id, $user_id);
  522. }
  523. $show_groups = array('groups', 'group_messages', 'messages_list', 'group_add', 'mygroups', 'group_edit', 'member_list', 'invite_friends', 'waiting_list', 'browse_groups');
  524. // get count unread message and total invitations
  525. $count_unread_message = MessageManager::get_number_of_messages(true);
  526. $count_unread_message = !empty($count_unread_message) ? Display::badge($count_unread_message) : null;
  527. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
  528. $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
  529. $group_pending_invitations = count($group_pending_invitations);
  530. $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
  531. $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : '');
  532. $html = '<div class="social-menu">';
  533. if (in_array($show, $show_groups) && !empty($group_id)) {
  534. //--- Group image
  535. $group_info = GroupPortalManager::get_group_data($group_id);
  536. $big = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'], 160, GROUP_IMAGE_SIZE_BIG);
  537. $html .= '<div class="social-content-image">';
  538. $html .= '<div class="well social-background-content">';
  539. $html .= Display::url('<img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />', api_get_path(WEB_PATH).'main/social/groups.php?id='.$group_id);
  540. if (GroupPortalManager::is_group_admin($group_id, api_get_user_id())) {
  541. $html .= '<div id="edit_image" class="hidden_message" style="display:none">
  542. <a href="'.api_get_path(WEB_PATH).'main/social/group_edit.php?id='.$group_id.'">'.
  543. get_lang('EditGroup').'</a></div>';
  544. }
  545. $html .= '</div>';
  546. $html .= '</div>';
  547. } else {
  548. $img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
  549. $big_image = UserManager::get_picture_user($user_id, $img_array['file'], '', USER_IMAGE_SIZE_BIG);
  550. $big_image = $big_image['file'].'?'.uniqid();
  551. $normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();
  552. //--- User image
  553. $html .= '<div class="well social-background-content">';
  554. if ($img_array['file'] != 'unknown.jpg') {
  555. $html .= '<a class="thumbnail thickbox" href="'.$big_image.'"><img src='.$normal_image.' /> </a>';
  556. } else {
  557. $html .= '<img src='.$normal_image.' width="110px" />';
  558. }
  559. if (api_get_user_id() == $user_id) {
  560. $html .= '<div id="edit_image" class="hidden_message" style="display:none">';
  561. $html .= '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.get_lang('EditProfile').'</a></div>';
  562. }
  563. $html .= '</div>';
  564. }
  565. if (!in_array($show, array('shared_profile', 'groups', 'group_edit', 'member_list', 'waiting_list', 'invite_friends'))) {
  566. $html .= '<div class="well sidebar-nav"><ul class="nav nav-list">';
  567. $active = $show == 'home' ? 'active' : null;
  568. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png', get_lang('Home'), array()).get_lang('Home').'</a></li>';
  569. $active = $show == 'messages' ? 'active' : null;
  570. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('instant_message.png', get_lang('Messages'), array()).get_lang('Messages').$count_unread_message.'</a></li>';
  571. //Invitations
  572. $active = $show == 'invitations' ? 'active' : null;
  573. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png', get_lang('Invitations'), array()).get_lang('Invitations').$total_invitations.'</a></li>';
  574. //Shared profile and groups
  575. $active = $show == 'shared_profile' ? 'active' : null;
  576. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png', get_lang('ViewMySharedProfile'), array()).get_lang('ViewMySharedProfile').'</a></li>';
  577. $active = $show == 'friends' ? 'active' : null;
  578. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/friends.php">'.Display::return_icon('friend.png', get_lang('Friends'), array()).get_lang('Friends').'</a></li>';
  579. $active = $show == 'browse_groups' ? 'active' : null;
  580. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/groups.php">'.Display::return_icon('group_s.png', get_lang('SocialGroups'), array()).get_lang('SocialGroups').'</a></li>';
  581. //Search users
  582. $active = $show == 'search' ? 'active' : null;
  583. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png', get_lang('Search'), array()).get_lang('Search').'</a></li>';
  584. //My files
  585. $active = $show == 'myfiles' ? 'active' : null;
  586. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png', get_lang('MyFiles'), array(), 16).get_lang('MyFiles').'</span></a></li>';
  587. $html .='</ul>
  588. </div>';
  589. }
  590. if (in_array($show, $show_groups) && !empty($group_id)) {
  591. $html .= GroupPortalManager::show_group_column_information($group_id, api_get_user_id(), $show);
  592. }
  593. if ($show == 'shared_profile') {
  594. $html .= '<div class="well sidebar-nav">
  595. <ul class="nav nav-list">';
  596. // My own profile
  597. if ($show_full_profile && $user_id == intval(api_get_user_id())) {
  598. $html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png', get_lang('Home'), array()).get_lang('Home').'</a></li>
  599. <li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('instant_message.png', get_lang('Messages'), array()).get_lang('Messages').$count_unread_message.'</a></li>';
  600. $active = $show == 'invitations' ? 'active' : null;
  601. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png', get_lang('Invitations'), array()).get_lang('Invitations').$total_invitations.'</a></li>';
  602. $html .= '<li class="active"><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png', get_lang('ViewMySharedProfile'), array('style' => 'float:left')).''.get_lang('ViewMySharedProfile').'</a></li>
  603. <li><a href="'.api_get_path(WEB_PATH).'main/social/friends.php">'.Display::return_icon('friend.png', get_lang('Friends'), array()).get_lang('Friends').'</a></li>
  604. <li><a href="'.api_get_path(WEB_PATH).'main/social/groups.php">'.Display::return_icon('group_s.png', get_lang('SocialGroups'), array()).get_lang('SocialGroups').'</a></li>';
  605. $active = $show == 'search' ? 'active' : null;
  606. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png', get_lang('Search'), array()).get_lang('Search').'</a></li>';
  607. $active = $show == 'myfiles' ? 'active' : null;
  608. $html .= '<li class="'.$active.'"><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png', get_lang('MyFiles'), array(), 16).get_lang('MyFiles').'</a></li>';
  609. }
  610. // My friend profile
  611. if ($user_id != api_get_user_id()) {
  612. $html .= '<li><a href="javascript:void(0);" onclick="javascript:send_message_to_user(\''.$user_id.'\');" title="'.get_lang('SendMessage').'">';
  613. $html .= Display::return_icon('compose_message.png', get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';
  614. }
  615. //check if I already sent an invitation message
  616. $invitation_sent_list = SocialManager::get_list_invitation_sent_by_user_id(api_get_user_id());
  617. if (isset($invitation_sent_list[$user_id]) && is_array($invitation_sent_list[$user_id]) && count($invitation_sent_list[$user_id]) > 0) {
  618. $html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png', get_lang('YouAlreadySentAnInvitation')).'&nbsp;&nbsp;'.get_lang('YouAlreadySentAnInvitation').'</a></li>';
  619. } else {
  620. if (!$show_full_profile) {
  621. $html .= '<li><a href="javascript:void(0);" onclick="javascript:send_invitation_to_user(\''.$user_id.'\');" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('invitation.png', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a></li>';
  622. }
  623. }
  624. //Chat
  625. //@todo check if user is online and if it's a friend to show the chat link
  626. if (api_is_global_chat_enabled()) {
  627. $user_name = $user_info['complete_name'];
  628. if ($user_friend_relation == USER_RELATION_TYPE_FRIEND) {
  629. if ($user_id != api_get_user_id()) {
  630. //Only show chat if I'm available to talk
  631. if ($current_user_info['user_is_online_in_chat'] == 1) {
  632. $options = array('onclick' => "javascript:chatWith('".$user_id."', '".Security::remove_XSS($user_name)."', '".$user_info['user_is_online_in_chat']."')");
  633. $chat_icon = $user_info['user_is_online_in_chat'] ? Display::return_icon('online.png', get_lang('Online')) : Display::return_icon('offline.png', get_lang('Offline'));
  634. $html .= Display::tag('li', Display::url($chat_icon.'&nbsp;&nbsp;'.get_lang('Chat'), 'javascript:void(0);', $options));
  635. }
  636. }
  637. } else {
  638. if ($user_id != api_get_user_id()) {
  639. if ($current_user_info['user_is_online_in_chat'] == 1) {
  640. $message = Security::remove_XSS(sprintf(get_lang("YouHaveToAddXAsAFriendFirst"), $user_name));
  641. $options = array('onclick' => "javascript:chatNotYetWith('".$message."')");
  642. $chat_icon = $user_info['user_is_online_in_chat'] ? Display::return_icon('online.png', get_lang('Online')) : Display::return_icon('offline.png', get_lang('Offline'));
  643. $html .= Display::tag('li', Display::url($chat_icon.'&nbsp;&nbsp;'.get_lang('Chat'), 'javascript:void(0);', $options));
  644. }
  645. }
  646. }
  647. }
  648. $html .= '</ul></div>';
  649. if ($show_full_profile && $user_id == intval(api_get_user_id())) {
  650. $personal_course_list = UserManager::get_personal_session_course_list($user_id);
  651. $course_list_code = array();
  652. $i = 1;
  653. if (is_array($personal_course_list)) {
  654. foreach ($personal_course_list as $my_course) {
  655. if ($i <= 10) {
  656. $course_list_code[] = array('code' => $my_course['code']);
  657. } else {
  658. break;
  659. }
  660. $i++;
  661. }
  662. //to avoid repeted courses
  663. $course_list_code = array_unique_dimensional($course_list_code);
  664. }
  665. //-----Announcements
  666. $my_announcement_by_user_id = intval($user_id);
  667. $announcements = array();
  668. foreach ($course_list_code as $course) {
  669. $course_info = api_get_course_info($course['code']);
  670. if (!empty($course_info)) {
  671. $content = AnnouncementManager::get_all_annoucement_by_user_course($course_info['code'], $my_announcement_by_user_id);
  672. if (!empty($content)) {
  673. $url = Display::url(Display::return_icon('announcement.png', get_lang('Announcements')).$course_info['name'].' ('.$content['count'].')', api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$course['code']);
  674. $announcements[] = Display::tag('li', $url);
  675. }
  676. }
  677. }
  678. if (!empty($announcements)) {
  679. $html .= '<div class="social_menu_items">';
  680. $html .= '<ul>';
  681. foreach ($announcements as $announcement) {
  682. $html .= $announcement;
  683. }
  684. $html .= '</ul>';
  685. $html .= '</div>';
  686. }
  687. }
  688. }
  689. if ($show_delete_account_button) {
  690. $html .= '<div class="sidebar-nav"><ul><li>';
  691. $url = api_get_path(WEB_CODE_PATH).'auth/unsubscribe_account.php';
  692. $html .= Display::url(Display::return_icon('delete.png', get_lang('Unsubscribe'), array(), ICON_SIZE_TINY).get_lang('Unsubscribe'), $url);
  693. $html .= '</li></ul></div>';
  694. }
  695. $html .= '</div>';
  696. return $html;
  697. }
  698. /**
  699. * Displays a sortable table with the list of online users.
  700. * @param array $user_list
  701. */
  702. public static function display_user_list($user_list)
  703. {
  704. if ($_GET['id'] == '') {
  705. $column_size = '9';
  706. $add_row = false;
  707. if (api_is_anonymous()) {
  708. $column_size = '12';
  709. $add_row = true;
  710. }
  711. $extra_params = array();
  712. $course_url = '';
  713. if (strlen($_GET['cidReq']) > 0) {
  714. $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
  715. $course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
  716. }
  717. if ($add_row) {
  718. $html .='<div class="row">';
  719. }
  720. $html .= '<div class="span'.$column_size.'">';
  721. $html .= '<ul id="online_grid_container" class="thumbnails">';
  722. foreach ($user_list as $uid) {
  723. $user_info = api_get_user_info($uid);
  724. //Anonymous users can't have access to the profile
  725. if (!api_is_anonymous()) {
  726. if (api_get_setting('allow_social_tool') == 'true') {
  727. $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$uid.$course_url;
  728. } else {
  729. $url = '?id='.$uid.$course_url;
  730. }
  731. } else {
  732. $url = '#';
  733. }
  734. $image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
  735. // reduce image
  736. $name = $user_info['complete_name'];
  737. $status_icon = Display::span('', array('class' => 'online_user_in_text'));
  738. $user_status = $user_info['status'] == 1 ? Display::span('', array('class' => 'teacher_online')) : Display::span('', array('class' => 'student_online'));
  739. if ($image_array['file'] == 'unknown.jpg' || !file_exists($image_array['dir'].$image_array['file'])) {
  740. $friends_profile['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
  741. $img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
  742. } else {
  743. $friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
  744. $img = '<img title = "'.$name.'" alt="'.$name.'" src="'.$friends_profile['file'].'">';
  745. }
  746. $name = '<a href="'.$url.'">'.$status_icon.$user_status.$name.'</a><br>';
  747. $html .= '<li class="span'.($column_size / 3).'"><div class="thumbnail">'.$img.'<div class="caption">'.$name.'</div</div></li>';
  748. }
  749. $counter = $_SESSION['who_is_online_counter'];
  750. $html .= '</ul></div>';
  751. if (count($user_list) >= 9) {
  752. $html .= '<div class="span'.$column_size.'"><a class="btn btn-large" id="link_load_more_items" data_link="'.$counter.'" >'.get_lang('More').'</a></div>';
  753. }
  754. if ($add_row) {
  755. $html .= '</div>';
  756. }
  757. }
  758. return $html;
  759. }
  760. /**
  761. * Displays the information of an individual user
  762. * @param int $user_id
  763. */
  764. public static function display_individual_user($user_id)
  765. {
  766. global $interbreadcrumb;
  767. $safe_user_id = intval($user_id);
  768. $user_table = Database::get_main_table(TABLE_MAIN_USER);
  769. $sql = "SELECT * FROM $user_table WHERE user_id = ".$safe_user_id;
  770. $result = Database::query($sql);
  771. if (Database::num_rows($result) == 1) {
  772. $user_object = Database::fetch_object($result);
  773. $alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;('.get_lang('Me').')' : '');
  774. $status = get_status_from_code($user_object->status);
  775. $interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
  776. Display::display_header($alt, null, $alt);
  777. echo '<div class ="thumbnail">';
  778. if (strlen(trim($user_object->picture_uri)) > 0) {
  779. $sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
  780. $sysdir = $sysdir_array['dir'];
  781. $webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
  782. $webdir = $webdir_array['dir'];
  783. $fullurl = $webdir.$user_object->picture_uri;
  784. $system_image_path = $sysdir.$user_object->picture_uri;
  785. list($width, $height, $type, $attr) = @getimagesize($system_image_path);
  786. $height += 30;
  787. $width += 30;
  788. // get the path,width and height from original picture
  789. $big_image = $webdir.'big_'.$user_object->picture_uri;
  790. $big_image_size = api_getimagesize($big_image);
  791. $big_image_width = $big_image_size['width'];
  792. $big_image_height = $big_image_size['height'];
  793. $url_big_image = $big_image.'?rnd='.time();
  794. //echo '<a href="javascript:void()" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');" >';
  795. echo '<img src="'.$fullurl.'" alt="'.$alt.'" />';
  796. } else {
  797. echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
  798. }
  799. if (!empty($status)) {
  800. echo '<div class="caption">'.$status.'</div>';
  801. }
  802. echo '</div>';
  803. if (api_get_setting('show_email_addresses') == 'true') {
  804. echo Display::encrypted_mailto_link($user_object->email, $user_object->email).'<br />';
  805. }
  806. if ($user_object->competences) {
  807. echo Display::page_subheader(get_lang('MyCompetences'));
  808. echo '<p>'.$user_object->competences.'</p>';
  809. }
  810. if ($user_object->diplomas) {
  811. echo Display::page_subheader(get_lang('MyDiplomas'));
  812. echo '<p>'.$user_object->diplomas.'</p>';
  813. }
  814. if ($user_object->teach) {
  815. echo Display::page_subheader(get_lang('MyTeach'));
  816. echo '<p>'.$user_object->teach.'</p>';
  817. }
  818. SocialManager::display_productions($user_object->user_id);
  819. if ($user_object->openarea) {
  820. echo Display::page_subheader(get_lang('MyPersonalOpenArea'));
  821. echo '<p>'.$user_object->openarea.'</p>';
  822. }
  823. } else {
  824. Display::display_header(get_lang('UsersOnLineList'));
  825. echo '<div class="actions-title">';
  826. echo get_lang('UsersOnLineList');
  827. echo '</div>';
  828. }
  829. }
  830. /**
  831. * Display productions in whoisonline
  832. * @param int $user_id User id
  833. */
  834. public static function display_productions($user_id)
  835. {
  836. $sysdir_array = UserManager::get_user_picture_path_by_id($user_id, 'system', true);
  837. $sysdir = $sysdir_array['dir'].$user_id.'/';
  838. $webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true);
  839. $webdir = $webdir_array['dir'].$user_id.'/';
  840. if (!is_dir($sysdir)) {
  841. mkdir($sysdir, api_get_permissions_for_new_directories(), true);
  842. }
  843. /*
  844. $handle = opendir($sysdir);
  845. $productions = array();
  846. while ($file = readdir($handle)) {
  847. if ($file == '.' || $file == '..' || $file == '.htaccess') {
  848. continue; // Skip current and parent directories
  849. }
  850. if (preg_match('/('.$user_id.'|[0-9a-f]{13}|saved)_.+\.(png|jpg|jpeg|gif)$/i', $file)) {
  851. // User's photos should not be listed as productions.
  852. continue;
  853. }
  854. $productions[] = $file;
  855. }
  856. */
  857. $productions = UserManager::get_user_productions($user_id);
  858. if (count($productions) > 0) {
  859. echo '<dt><strong>'.get_lang('Productions').'</strong></dt>';
  860. echo '<dd><ul>';
  861. foreach ($productions as $file) {
  862. // Only display direct file links to avoid browsing an empty directory
  863. if (is_file($sysdir.$file) && $file != $webdir_array['file']) {
  864. echo '<li><a href="'.$webdir.urlencode($file).'" target=_blank>'.$file.'</a></li>';
  865. }
  866. // Real productions are under a subdirectory by the User's id
  867. if (is_dir($sysdir.$file)) {
  868. $subs = scandir($sysdir.$file);
  869. foreach ($subs as $my => $sub) {
  870. if (substr($sub, 0, 1) != '.' && is_file($sysdir.$file.'/'.$sub)) {
  871. echo '<li><a href="'.$webdir.urlencode($file).'/'.urlencode($sub).'" target=_blank>'.$sub.'</a></li>';
  872. }
  873. }
  874. }
  875. }
  876. echo '</ul></dd>';
  877. }
  878. }
  879. public static function social_wrapper_div($content, $span_count)
  880. {
  881. $span_count = intval($span_count);
  882. $html = '<div class="span'.$span_count.'">';
  883. $html .= '<div class="well_border">';
  884. $html .= $content;
  885. $html .= '</div></div>';
  886. return $html;
  887. }
  888. /**
  889. * Dummy function
  890. *
  891. */
  892. public static function get_plugins($place = SOCIAL_CENTER_PLUGIN)
  893. {
  894. $content = '';
  895. switch ($place) {
  896. case SOCIAL_CENTER_PLUGIN:
  897. $social_plugins = array(1, 2);
  898. if (is_array($social_plugins) && count($social_plugins) > 0) {
  899. $content.= '<div id="social-plugins">';
  900. foreach ($social_plugins as $plugin) {
  901. $content.= '<div class="social-plugin-item">';
  902. $content.= $plugin;
  903. $content.= '</div>';
  904. }
  905. $content.= '</div>';
  906. }
  907. break;
  908. case SOCIAL_LEFT_PLUGIN:
  909. break;
  910. case SOCIAL_RIGHT_PLUGIN:
  911. break;
  912. }
  913. return $content;
  914. }
  915. }