social.lib.php 47 KB

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