social.lib.php 49 KB

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