social.lib.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. <?php //$id: $
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /**
  4. ==============================================================================
  5. * This class provides methods for the social network management.
  6. * Include/require it in your code to use its features.
  7. *
  8. * @package dokeos.library
  9. ==============================================================================
  10. */
  11. // Relation type between users
  12. define('USERUNKNOW', 0);
  13. define('SOCIALUNKNOW', 1);
  14. define('SOCIALPARENT', 2);
  15. define('SOCIALFRIEND', 3);
  16. define('SOCIALGOODFRIEND', 4);
  17. define('SOCIALENEMY', 5);
  18. define('SOCIALDELETED', 6);
  19. //PLUGIN PLACES
  20. define('SOCIAL_LEFT_PLUGIN', 1);
  21. define('SOCIAL_CENTER_PLUGIN', 2);
  22. define('SOCIAL_RIGHT_PLUGIN', 3);
  23. define('MESSAGE_STATUS_INVITATION_PENDING', '5');
  24. define('MESSAGE_STATUS_INVITATION_ACCEPTED','6');
  25. define('MESSAGE_STATUS_INVITATION_DENIED', '7');
  26. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  27. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  28. class SocialManager extends UserManager {
  29. private function __construct() {
  30. }
  31. /**
  32. * Allow to register contact to social network
  33. * @param int user friend id
  34. * @param int user id
  35. * @param int relation between users see constants definition
  36. */
  37. public static function register_friend ($friend_id,$my_user_id,$relation_type) {
  38. $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND);
  39. $friend_id = intval($friend_id);
  40. $my_user_id = intval($my_user_id);
  41. $relation_type = intval($relation_type);
  42. $sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE friend_user_id=' .$friend_id.' AND user_id='.$my_user_id;
  43. $result = Database::query($sql, __FILE__, __LINE__);
  44. $row = Database :: fetch_array($result, 'ASSOC');
  45. if ($row['count'] == 0) {
  46. $current_date=date('Y-m-d H:i:s');
  47. $sql_i = 'INSERT INTO ' . $tbl_my_friend . '(friend_user_id,user_id,relation_type,last_edit)values(' . $friend_id . ','.$my_user_id.','.$relation_type.',"'.$current_date.'");';
  48. Database::query($sql_i, __FILE__, __LINE__);
  49. return true;
  50. } else {
  51. $sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE friend_user_id=' . $friend_id . ' AND user_id='.$my_user_id;
  52. $result = Database::query($sql, __FILE__, __LINE__);
  53. $row = Database :: fetch_array($result, 'ASSOC');
  54. if ($row['count'] == 1) {
  55. $sql_i = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.$relation_type.' WHERE friend_user_id=' . $friend_id.' AND user_id='.$my_user_id;
  56. Database::query($sql_i, __FILE__, __LINE__);
  57. return true;
  58. } else {
  59. return false;
  60. }
  61. }
  62. }
  63. /**
  64. * Deletes a contact
  65. * @param int user friend id
  66. * @param bool true will delete ALL friends relationship from $friend_id
  67. * @author isaac flores paz <isaac.flores@dokeos.com>
  68. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  69. */
  70. public static function removed_friend ($friend_id, $real_removed = false) {
  71. $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND);
  72. $tbl_my_message = Database :: get_main_table(TABLE_MAIN_MESSAGE);
  73. $friend_id = intval($friend_id);
  74. if ($real_removed == true) {
  75. //Delete user friend
  76. $sql_delete_relationship1 = 'UPDATE ' . $tbl_my_friend .' SET relation_type='.SOCIALDELETED.' WHERE friend_user_id='.$friend_id;
  77. $sql_delete_relationship2 = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.SOCIALDELETED.' WHERE user_id=' . $friend_id;
  78. // $sql_delete_relationship1 = 'DELETE FROM ' . $tbl_my_friend .' WHERE friend_user_id='.$friend_id;
  79. //$sql_delete_relationship2 = 'DELETE FROM ' . $tbl_my_friend . ' WHERE user_id=' . $friend_id;
  80. Database::query($sql_delete_relationship1, __FILE__, __LINE__);
  81. Database::query($sql_delete_relationship2, __FILE__, __LINE__);
  82. } else {
  83. $user_id=api_get_user_id();
  84. $sql = 'SELECT COUNT(*) as count FROM ' . $tbl_my_friend . ' WHERE user_id=' . $user_id . ' AND relation_type<>6 AND friend_user_id='.$friend_id;
  85. $result = Database::query($sql, __FILE__, __LINE__);
  86. $row = Database :: fetch_array($result, 'ASSOC');
  87. if ($row['count'] == 1) {
  88. //Delete user friend
  89. $sql_i = 'UPDATE ' . $tbl_my_friend .' SET relation_type='.SOCIALDELETED.' WHERE user_id=' . $user_id.' AND friend_user_id='.$friend_id;
  90. $sql_j = 'UPDATE ' . $tbl_my_message.' SET msg_status=7 WHERE user_receiver_id=' . $user_id.' AND user_sender_id='.$friend_id;
  91. //Delete user
  92. $sql_ij = 'UPDATE ' . $tbl_my_friend . ' SET relation_type='.SOCIALDELETED.' WHERE user_id=' . $friend_id.' AND friend_user_id='.$user_id;
  93. $sql_ji = 'UPDATE ' . $tbl_my_message . ' SET msg_status=7 WHERE user_receiver_id=' . $friend_id.' AND user_sender_id='.$user_id;
  94. Database::query($sql_i, __FILE__, __LINE__);
  95. Database::query($sql_j, __FILE__, __LINE__);
  96. Database::query($sql_ij, __FILE__, __LINE__);
  97. Database::query($sql_ji, __FILE__, __LINE__);
  98. }
  99. }
  100. }
  101. /**
  102. * Allow to see contacts list
  103. * @author isaac flores paz <florespaz@bidsoftperu.com>
  104. * @return array
  105. */
  106. public static function show_list_type_friends () {
  107. $friend_relation_list=array();
  108. $count_list=0;
  109. $tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
  110. $sql='SELECT id,title FROM '.$tbl_my_friend_relation_type.' WHERE id<>6 ORDER BY id ASC';
  111. $result=Database::query($sql,__FILE__,__LINE__);
  112. while ($row=Database::fetch_array($result,'ASSOC')) {
  113. $friend_relation_list[]=$row;
  114. }
  115. $count_list=count($friend_relation_list);
  116. if ($count_list==0) {
  117. $friend_relation_list[]=get_lang('UnkNow');
  118. } else {
  119. return $friend_relation_list;
  120. }
  121. }
  122. /**
  123. * Get relation type contact by name
  124. * @param string names of the kind of relation
  125. * @return int
  126. * @author isaac flores paz <florespaz@bidsoftperu.com>
  127. */
  128. public static function get_relation_type_by_name ($relation_type_name) {
  129. $list_type_friend=array();
  130. $list_type_friend=self::show_list_type_friends();
  131. foreach ($list_type_friend as $value_type_friend) {
  132. if (strtolower($value_type_friend['title'])==$relation_type_name) {
  133. return $value_type_friend['id'];
  134. }
  135. }
  136. }
  137. /**
  138. * Get the kind of relation between contacts
  139. * @param int user id
  140. * @param int user friend id
  141. * @param string
  142. * @author isaac flores paz <florespaz@bidsoftperu.com>
  143. */
  144. public static function get_relation_between_contacts ($user_id,$user_friend) {
  145. $tbl_my_friend_relation_type = Database :: get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE);
  146. $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND);
  147. $sql= 'SELECT rt.id as id FROM '.$tbl_my_friend_relation_type.' rt ' .
  148. '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).')';
  149. $res=Database::query($sql,__FILE__,__LINE__);
  150. $row=Database::fetch_array($res,'ASSOC');
  151. if (Database::num_rows($res)>0) {
  152. return $row['id'];
  153. } else {
  154. return USERUNKNOW;
  155. }
  156. }
  157. /**
  158. * Gets friends id list
  159. * @param int user id
  160. * @param int group id
  161. * @param string name to search
  162. * @param bool true will load firstname, lastname, and image name
  163. * @return array
  164. * @author Julio Montoya <gugli100@gmail.com> Cleaning code, function renamed, $load_extra_info option added
  165. * @author isaac flores paz <florespaz@bidsoftperu.com>
  166. */
  167. public static function get_friends($user_id, $id_group=null, $search_name=null, $load_extra_info = true) {
  168. $list_ids_friends=array();
  169. $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND);
  170. $tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER);
  171. $sql='SELECT friend_user_id FROM '.$tbl_my_friend.' WHERE relation_type<>6 AND friend_user_id<>'.((int)$user_id).' AND user_id='.((int)$user_id);
  172. if (isset($id_group) && $id_group>0) {
  173. $sql.=' AND relation_type='.$id_group;
  174. }
  175. if (isset($search_name) && is_string($search_name)===true) {
  176. $sql.=' AND friend_user_id IN (SELECT user_id FROM '.$tbl_my_user.' WHERE '.(api_is_western_name_order() ? 'concat(firstName, lastName)' : 'concat(lastName, firstName)').' like concat("%","'.Database::escape_string($search_name).'","%"));';
  177. }
  178. $res=Database::query($sql,__FILE__,__LINE__);
  179. while ($row=Database::fetch_array($res,'ASSOC')) {
  180. if ($load_extra_info == true) {
  181. $path = UserManager::get_user_picture_path_by_id($row['friend_user_id'],'web',false,true);
  182. $my_user_info=api_get_user_info($row['friend_user_id']);
  183. $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']);
  184. } else {
  185. $list_ids_friends[]=$row;
  186. }
  187. }
  188. return $list_ids_friends;
  189. }
  190. /**
  191. * get list web path of contacts by user id
  192. * @param int user id
  193. * @param int group id
  194. * @param string name to search
  195. * @param array
  196. * @author isaac flores paz <florespaz@bidsoftperu.com>
  197. */
  198. public static function get_list_path_web_by_user_id ($user_id,$id_group=null,$search_name=null) {
  199. $list_paths=array();
  200. $list_path_friend=array();
  201. $array_path_user=array();
  202. $combine_friend = array();
  203. $list_ids = self::get_friends($user_id,$id_group,$search_name);
  204. if (is_array($list_ids)) {
  205. foreach ($list_ids as $values_ids) {
  206. $list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'],'web',false,true);
  207. $combine_friend=array('id_friend'=>$list_ids,'path_friend'=>$list_path_image_friend);
  208. }
  209. }
  210. return $combine_friend;
  211. }
  212. /**
  213. * get web path of user invitate
  214. * @author isaac flores paz <florespaz@bidsoftperu.com>
  215. * @param int user id
  216. * @return array
  217. */
  218. public static function get_list_web_path_user_invitation_by_user_id ($user_id) {
  219. $list_paths=array();
  220. $list_path_friend=array();
  221. $list_ids = self::get_list_invitation_of_friends_by_user_id((int)$user_id);
  222. foreach ($list_ids as $values_ids) {
  223. $list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['user_sender_id'],'web',false,true);
  224. }
  225. return $list_path_image_friend;
  226. }
  227. /**
  228. * Sends an invitation to contacts
  229. * @param int user id
  230. * @param int user friend id
  231. * @param string title of the message
  232. * @param string content of the message
  233. * @return boolean
  234. * @author isaac flores paz <florespaz@bidsoftperu.com>
  235. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  236. */
  237. public static function send_invitation_friend ($user_id,$friend_id,$message_title,$message_content) {
  238. $tbl_message = Database::get_main_table(TABLE_MAIN_MESSAGE);
  239. $user_id = intval($user_id);
  240. $friend_id = intval($friend_id);
  241. $message_title = Database::escape_string($message_title);
  242. $message_content = Database::escape_string($message_content);
  243. $current_date = date('Y-m-d H:i:s',time());
  244. $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);';
  245. $res_exist=Database::query($sql_exist,__FILE__,__LINE__);
  246. $row_exist=Database::fetch_array($res_exist,'ASSOC');
  247. if ($row_exist['count']==0) {
  248. $sql='INSERT INTO '.$tbl_message.'(user_sender_id,user_receiver_id,msg_status,send_date,title,content) VALUES('.$user_id.','.$friend_id.','.MESSAGE_STATUS_INVITATION_PENDING.',"'.$current_date.'","'.$message_title.'","'.$message_content.'")';
  249. Database::query($sql,__FILE__,__LINE__);
  250. return true;
  251. } else {
  252. //invitation already exist
  253. $sql_if_exist='SELECT COUNT(*) AS count FROM '.$tbl_message.' WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.' AND msg_status=7';
  254. $res_if_exist=Database::query($sql_if_exist,__FILE__,__LINE__);
  255. $row_if_exist=Database::fetch_array($res_if_exist,'ASSOC');
  256. if ($row_if_exist['count']==1) {
  257. $sql_if_exist_up='UPDATE '.$tbl_message.'SET msg_status=5 WHERE user_sender_id='.$user_id.' AND user_receiver_id='.$friend_id.';';
  258. Database::query($sql_if_exist_up,__FILE__,__LINE__);
  259. return true;
  260. } else {
  261. return false;
  262. }
  263. }
  264. }
  265. /**
  266. * Get number messages of the inbox
  267. * @author isaac flores paz <florespaz@bidsoftperu.com>
  268. * @param int user receiver id
  269. * @return int
  270. */
  271. public static function get_message_number_invitation_by_user_id ($user_receiver_id) {
  272. $tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
  273. $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;
  274. $res=Database::query($sql,__FILE__,__LINE__);
  275. $row=Database::fetch_array($res,'ASSOC');
  276. return $row['count_message_in_box'];
  277. }
  278. /**
  279. * Get invitation list received by user
  280. * @author isaac flores paz <florespaz@bidsoftperu.com>
  281. * @param int user id
  282. * @return array()
  283. */
  284. public static function get_list_invitation_of_friends_by_user_id ($user_id) {
  285. $list_friend_invitation=array();
  286. $tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
  287. $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;
  288. $res=Database::query($sql,__FILE__,__LINE__);
  289. while ($row=Database::fetch_array($res,'ASSOC')) {
  290. $list_friend_invitation[]=$row;
  291. }
  292. return $list_friend_invitation;
  293. }
  294. /**
  295. * Get invitation list sent by user
  296. * @author Julio Montoya <gugli100@gmail.com>
  297. * @param int user id
  298. * @return array()
  299. */
  300. public static function get_list_invitation_sent_by_user_id ($user_id) {
  301. $list_friend_invitation=array();
  302. $tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
  303. $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;
  304. $res=Database::query($sql,__FILE__,__LINE__);
  305. while ($row=Database::fetch_array($res,'ASSOC')) {
  306. $list_friend_invitation[$row['user_receiver_id']]=$row;
  307. }
  308. return $list_friend_invitation;
  309. }
  310. /**
  311. * Accepts invitation
  312. * @param int user sender id
  313. * @param int user receiver id
  314. * @author isaac flores paz <florespaz@bidsoftperu.com>
  315. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  316. */
  317. public static function invitation_accepted ($user_send_id,$user_receiver_id) {
  318. $tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
  319. echo $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).';';
  320. Database::query($sql,__FILE__,__LINE__);
  321. }
  322. /**
  323. * Denies invitation
  324. * @param int user sender id
  325. * @param int user receiver id
  326. * @author isaac flores paz <florespaz@bidsoftperu.com>
  327. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  328. */
  329. public static function invitation_denied ($user_send_id,$user_receiver_id) {
  330. $tbl_message=Database::get_main_table(TABLE_MAIN_MESSAGE);
  331. //$msg_status=7;
  332. //$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).';';
  333. $sql='DELETE FROM '.$tbl_message.' WHERE user_sender_id='.((int)$user_send_id).' AND user_receiver_id='.((int)$user_receiver_id).';';
  334. Database::query($sql,__FILE__,__LINE__);
  335. }
  336. /**
  337. * allow attach to group
  338. * @author isaac flores paz <florespaz@bidsoftperu.com>
  339. * @param int user to qualify
  340. * @param int kind of rating
  341. * @return void()
  342. */
  343. public static function qualify_friend ($id_friend_qualify,$type_qualify) {
  344. $tbl_user_friend=Database::get_main_table(TABLE_MAIN_USER_FRIEND);
  345. $user_id=api_get_user_id();
  346. $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).';';
  347. Database::query($sql,__FILE__,__LINE__);
  348. }
  349. /**
  350. * Sends invitations to friends
  351. * @author Isaac Flores Paz <isaac.flores.paz@gmail.com>
  352. * @author Julio Montoya <gugli100@gmail.com> Cleaning code
  353. * @param void
  354. * @return string message invitation
  355. */
  356. public static function send_invitation_friend_user ($userfriend_id,$subject_message='',$content_message='') {
  357. global $charset;
  358. //$id_user_friend=array();
  359. $user_info = array();
  360. $user_info = api_get_user_info($userfriend_id);
  361. $succes = get_lang('MessageSentTo');
  362. $succes.= ' : '.api_get_person_name($user_info['firstName'], $user_info['lastName']);
  363. if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
  364. $send_message = MessageManager::send_message($userfriend_id, $subject_message, $content_message);
  365. if ($send_message) {
  366. echo Display::display_confirmation_message($succes,true);
  367. } else {
  368. echo Display::display_error_message($succes,true);
  369. }
  370. exit;
  371. } elseif (isset($userfriend_id) && !isset($subject_message)) {
  372. $count_is_true=false;
  373. $count_number_is_true=0;
  374. if (isset($userfriend_id) && $userfriend_id>0) {
  375. $message_title = get_lang('Invitation');
  376. $count_is_true = self::send_invitation_friend(api_get_user_id(),$userfriend_id, $message_title, $content_message);
  377. if ($count_is_true) {
  378. echo Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES,$charset),false);
  379. }else {
  380. echo Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES,$charset),false);
  381. }
  382. }
  383. }
  384. }
  385. /**
  386. * Get user's feeds
  387. * @param int User ID
  388. * @param int Limit of posts per feed
  389. * @return string HTML section with all feeds included
  390. * @author Yannick Warnier
  391. * @since Dokeos 1.8.6.1
  392. */
  393. function get_user_feeds($user, $limit=5) {
  394. if (!function_exists('fetch_rss')) { return '';}
  395. $fields = UserManager::get_extra_fields();
  396. $feed_fields = array();
  397. $feeds = array();
  398. $feed = UserManager::get_extra_user_data_by_field($user,'rssfeeds');
  399. if(empty($feed)) { return ''; }
  400. $feeds = split(';',$feed['rssfeeds']);
  401. if (count($feeds)==0) { return ''; }
  402. foreach ($feeds as $url) {
  403. if (empty($url)) { continue; }
  404. $rss = @fetch_rss($url);
  405. $res .= '<h2>'.$rss->channel['title'].'</h2>';
  406. $res .= '<div class="social-rss-channel-items">';
  407. $i = 1;
  408. if (is_array($rss->items)) {
  409. foreach ($rss->items as $item) {
  410. if ($limit>=0 and $i>$limit) {break;}
  411. $res .= '<h3><a href="'.$item['link'].'">'.$item['title'].'</a></h3>';
  412. $res .= '<div class="social-rss-item-date">'.api_get_datetime($item['date_timestamp']).'</div>';
  413. $res .= '<div class="social-rss-item-content">'.$item['description'].'</div><br />';
  414. $i++;
  415. }
  416. }
  417. $res .= '</div>';
  418. }
  419. return $res;
  420. }
  421. /**
  422. * Helper functions definition
  423. */
  424. function get_logged_user_course_html($my_course, $count) {
  425. global $nosession;
  426. if (api_get_setting('use_session_mode')=='true' && !$nosession) {
  427. global $now, $date_start, $date_end;
  428. }
  429. //initialise
  430. $result = '';
  431. // Table definitions
  432. $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
  433. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  434. $course_database = $my_course['db'];
  435. $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
  436. $tool_edit_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database);
  437. $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database);
  438. $user_id = api_get_user_id();
  439. $course_system_code = $my_course['k'];
  440. $course_visual_code = $my_course['c'];
  441. $course_title = $my_course['i'];
  442. $course_directory = $my_course['d'];
  443. $course_teacher = $my_course['t'];
  444. $course_teacher_email = isset($my_course['email'])?$my_course['email']:'';
  445. $course_info = Database :: get_course_info($course_system_code);
  446. $course_access_settings = CourseManager :: get_access_settings($course_system_code);
  447. $course_visibility = $course_access_settings['visibility'];
  448. $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code);
  449. //function logic - act on the data
  450. $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']);
  451. if ($is_virtual_course) {
  452. // If the current user is also subscribed in the real course to which this
  453. // virtual course is linked, we don't need to display the virtual course entry in
  454. // the course list - it is combined with the real course entry.
  455. $target_course_code = CourseManager :: get_target_of_linked_course($course_system_code);
  456. $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code);
  457. if ($is_subscribed_in_target_course) {
  458. return; //do not display this course entry
  459. }
  460. }
  461. $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id());
  462. if ($has_virtual_courses) {
  463. $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info);
  464. $course_display_title = $return_result['title'];
  465. $course_display_code = $return_result['code'];
  466. } else {
  467. $course_display_title = $course_title;
  468. $course_display_code = $course_visual_code;
  469. }
  470. $s_course_status=$my_course['s'];
  471. $s_htlm_status_icon="";
  472. if ($s_course_status==1) {
  473. $s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher'));
  474. }
  475. if ($s_course_status==2) {
  476. $s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach'));
  477. }
  478. if ($s_course_status==5) {
  479. $s_htlm_status_icon=Display::return_icon('students.gif', get_lang('Student'));
  480. }
  481. //display course entry
  482. $result .= '<div id="div_'.$count.'">';
  483. //$result .= '<a id="btn_'.$count.'" href="#" onclick="toogle_course(this,\''.$course_database.'\')">';
  484. $result .= '<h2><img src="../img/nolines_plus.gif" id="btn_'.$count.'" onclick="toogle_course(this,\''.$course_database.'\' )">';
  485. $result .= $s_htlm_status_icon;
  486. //show a hyperlink to the course, unless the course is closed and user is not course admin
  487. if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
  488. $result .= '<a href="javascript:void(0)" id="ln_'.$count.'" onclick=toogle_course(this,\''.$course_database.'\');>&nbsp;'.$course_title.'</a></h2>';
  489. /*
  490. if(api_get_setting('use_session_mode')=='true' && !$nosession) {
  491. if(empty($my_course['id_session'])) {
  492. $my_course['id_session'] = 0;
  493. }
  494. if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') {
  495. //$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
  496. $result .= '<a href="#">'.$course_display_title.'</a>';
  497. }
  498. } else {
  499. //$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
  500. $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
  501. }*/
  502. } else {
  503. $result .= $course_display_title." "." ".get_lang('CourseClosed')."";
  504. }
  505. // show the course_code and teacher if chosen to display this
  506. // we dont need this!
  507. /*
  508. if (api_get_setting('display_coursecode_in_courselist') == 'true' OR api_get_setting('display_teacher_in_courselist') == 'true') {
  509. $result .= '<br />';
  510. }
  511. if (api_get_setting('display_coursecode_in_courselist') == 'true') {
  512. $result .= $course_display_code;
  513. }
  514. if (api_get_setting('display_coursecode_in_courselist') == 'true' AND api_get_setting('display_teacher_in_courselist') == 'true') {
  515. $result .= ' &ndash; ';
  516. }
  517. if (api_get_setting('display_teacher_in_courselist') == 'true') {
  518. $result .= $course_teacher;
  519. if(!empty($course_teacher_email)) {
  520. $result .= ' ('.$course_teacher_email.')';
  521. }
  522. }
  523. */
  524. $current_course_settings = CourseManager :: get_access_settings($my_course['k']);
  525. // display the what's new icons
  526. // $result .= show_notification($my_course);
  527. if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) {
  528. reset($digest);
  529. $result .= '<ul>';
  530. while (list ($key2) = each($digest[$thisCourseSysCode])) {
  531. $result .= '<li>';
  532. if ($orderKey[1] == 'keyTools') {
  533. $result .= "<a href=\"$toolsList[$key2] [\"path\"] $thisCourseSysCode \">";
  534. $result .= "$toolsList[$key2][\"name\"]</a>";
  535. } else {
  536. $result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2));
  537. }
  538. $result .= '</li>';
  539. $result .= '<ul>';
  540. reset($digest[$thisCourseSysCode][$key2]);
  541. while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2])) {
  542. $result .= '<li>';
  543. if ($orderKey[2] == 'keyTools') {
  544. $result .= "<a href=\"$toolsList[$key3] [\"path\"] $thisCourseSysCode \">";
  545. $result .= "$toolsList[$key3][\"name\"]</a>";
  546. } else {
  547. $result .= format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3));
  548. }
  549. $result .= '<ul compact="compact">';
  550. reset($digest[$thisCourseSysCode][$key2][$key3]);
  551. while (list ($key4, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2][$key3])) {
  552. $result .= '<li>';
  553. $result .= htmlspecialchars(substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
  554. $result .= '</li>';
  555. }
  556. $result .= '</ul>';
  557. $result .= '</li>';
  558. }
  559. $result .= '</ul>';
  560. $result .= '</li>';
  561. }
  562. $result .= '</ul>';
  563. }
  564. $result .= '</li>';
  565. $result .= '</div>';
  566. if (api_get_setting('use_session_mode')=='true' && !$nosession) {
  567. $session = '';
  568. $active = false;
  569. if (!empty($my_course['session_name'])) {
  570. // Request for the name of the general coach
  571. $sql = 'SELECT lastname, firstname
  572. FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table .' tu
  573. ON ts.id_coach = tu.user_id
  574. WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1';
  575. $rs = Database::query($sql, __FILE__, __LINE__);
  576. $sessioncoach = Database::store_result($rs);
  577. $sessioncoach = $sessioncoach[0];
  578. $session = array();
  579. $session['title'] = $my_course['session_name'];
  580. if ( $my_course['date_start']=='0000-00-00' ) {
  581. $session['dates'] = get_lang('WithoutTimeLimits');
  582. if ( api_get_setting('show_session_coach') === 'true' ) {
  583. $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
  584. }
  585. $active = true;
  586. } else {
  587. $session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
  588. if ( api_get_setting('show_session_coach') === 'true' ) {
  589. $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
  590. }
  591. $active = ($date_start <= $now && $date_end >= $now)?true:false;
  592. }
  593. }
  594. $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
  595. } else {
  596. $output = array ($my_course['user_course_cat'], $result);
  597. }
  598. //$my_course['creation_date'];
  599. return $output;
  600. }
  601. public static function show_social_menu($show = '',$group_id = 0) {
  602. // Everybody can create groups
  603. if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
  604. $create_group_item = '<li class="socialMenuSubLevel"><a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('edit.gif',get_lang('CreateAgroup'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('CreateAgroup').'</span></a></li>';
  605. } else {
  606. // Only admins and teachers can create groups
  607. if (api_is_allowed_to_edit(null,true)) {
  608. $create_group_item = '<li class="socialMenuSubLevel"><a href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.Display::return_icon('edit.gif',get_lang('CreateAgroup'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('CreateAgroup').'</span></a></li>';
  609. }
  610. }
  611. echo '<div class="socialMenu" >
  612. <div>
  613. <ul>
  614. <li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.gif',get_lang('Home'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('Home').'</span></a></li>
  615. <li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('inbox.png',get_lang('Messages'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('Messages').'</span></a></li>';
  616. if ($show == 'messages') {
  617. echo '<ul class="social_menu_messages">';
  618. echo '<li class="socialMenuSubLevel"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('inbox.png', get_lang('Inbox'), array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('Inbox').'</span></a></li>';
  619. echo '<li class="socialMenuSubLevel"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('message_new.png', get_lang('ComposeMessage'), array('hspace'=>'6','style'=>'float:left')).'<span class="menuTex4" >'.get_lang('ComposeMessage').'</span></a></li>';
  620. echo '<li class="socialMenuSubLevel"><a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('outbox.png', get_lang('Outbox'), array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('Outbox').'</span></a></li>';
  621. echo '</ul>';
  622. }
  623. echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png',get_lang('ViewMySharedProfile'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('ViewMySharedProfile').'</span></a></li>
  624. <li><a href="'.api_get_path(WEB_PATH).'main/social/friends.php">'.Display::return_icon('lp_users.png',get_lang('Friends'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('Friends').'</span></a></li>
  625. <li><a href="'.api_get_path(WEB_PATH).'main/social/groups.php">'.Display::return_icon('group.gif',get_lang('Groups'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('Groups').'</span></a></li>';
  626. if ($show == 'groups') {
  627. echo '<ul class="social_menu_groups">';
  628. echo $create_group_item;
  629. echo '<li class="socialMenuSubLevel"><a href="'.api_get_path(WEB_PATH).'main/social/groups.php?view=mygroups">'.Display::return_icon('group.gif',get_lang('MyGroups'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('MyGroups').'</span></a></li>';
  630. echo '</ul>';
  631. }
  632. echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('search.gif',get_lang('Search'),array('hspace'=>'6')).'<span class="menuTex4" >'.get_lang('Search').'</span></a></li>
  633. </ul>
  634. </div>';
  635. if ($show == 'group_messages' && !empty($group_id)) {
  636. echo GroupPortalManager::show_group_column_information($group_id, api_get_user_id());
  637. }
  638. echo '</div>';
  639. }
  640. /**
  641. * Displays a sortable table with the list of online users.
  642. * @param array $user_list
  643. */
  644. function display_user_list($user_list) {
  645. global $charset;
  646. if ($_GET['id'] == '') {
  647. $extra_params = array();
  648. $course_url = '';
  649. if (strlen($_GET['cidReq']) > 0) {
  650. $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
  651. $course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
  652. }
  653. foreach ($user_list as $user) {
  654. $uid = $user[0];
  655. $user_info = api_get_user_info($uid);
  656. $table_row = array();
  657. if (api_get_setting('allow_social_tool')=='true') {
  658. $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$uid.$course_url;
  659. } else {
  660. $url = '?id='.$uid.$course_url;
  661. }
  662. $image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
  663. $friends_profile = SocialManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL );
  664. // reduce image
  665. $name = api_get_person_name($user_info['firstName'], $user_info['lastName']);
  666. $table_row[] = '<a href="'.$url.'"><img title = "'.$name.'" class="inicioUserOnline" alt="'.$name.'" src="'.$friends_profile['file'].'" width="60px" height="60px"></a>';
  667. $table_row[] = '<a href="'.$url.'" style="font-size:10px;">'.api_get_person_name(cut($user_info['firstName'],15), cut($user_info['lastName'],15)).'</a>';
  668. if (api_get_setting('show_email_addresses') == 'true') {
  669. $table_row[] = Display::encrypted_mailto_link($user_info['mail']);
  670. }
  671. $user_anonymous = api_get_anonymous_id();
  672. $table_data[] = $table_row;
  673. }
  674. $table_header[] = array(get_lang('UserPicture'), false, 'width="90"');
  675. ///$table_header[] = array(get_lang('Name'), true);
  676. //$table_header[] = array(get_lang('LastName'), true);
  677. if (api_get_setting('show_email_addresses') == 'true') {
  678. $table_header[] = array(get_lang('Email'), true);
  679. }
  680. Display::display_sortable_table($table_header, $table_data, array(), array('per_page' => 6), $extra_params, array(),'grid');
  681. }
  682. }
  683. /**
  684. * Displays the information of an individual user
  685. * @param int $user_id
  686. */
  687. function display_individual_user($user_id) {
  688. global $interbreadcrumb;
  689. $safe_user_id = Database::escape_string($user_id);
  690. // to prevent a hacking attempt: http://www.dokeos.com/forum/viewtopic.php?t=5363
  691. $user_table = Database::get_main_table(TABLE_MAIN_USER);
  692. $sql = "SELECT * FROM $user_table WHERE user_id='".$safe_user_id."'";
  693. $result = Database::query($sql, __FILE__, __LINE__);
  694. if (Database::num_rows($result) == 1) {
  695. $user_object = Database::fetch_object($result);
  696. $name = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;<strong>('.get_lang('Me').')</strong>' : '' );
  697. $alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;('.get_lang('Me').')' : '');
  698. $status = ($user_object->status == COURSEMANAGER ? get_lang('Teacher') : get_lang('Student'));
  699. $interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
  700. Display::display_header($alt);
  701. echo '<div class="actions-title">';
  702. echo $alt;
  703. echo '</div><br />';
  704. echo '<div style="text-align: center">';
  705. if (strlen(trim($user_object->picture_uri)) > 0) {
  706. $sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
  707. $sysdir = $sysdir_array['dir'];
  708. $webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
  709. $webdir = $webdir_array['dir'];
  710. $fullurl = $webdir.$user_object->picture_uri;
  711. $system_image_path = $sysdir.$user_object->picture_uri;
  712. list($width, $height, $type, $attr) = @getimagesize($system_image_path);
  713. $resizing = (($height > 200) ? 'height="200"' : '');
  714. $height += 30;
  715. $width += 30;
  716. $window_name = 'window'.uniqid('');
  717. // get the path,width and height from original picture
  718. $big_image = $webdir.'big_'.$user_object->picture_uri;
  719. $big_image_size = api_getimagesize($big_image);
  720. $big_image_width = $big_image_size[0];
  721. $big_image_height = $big_image_size[1];
  722. $url_big_image = $big_image.'?rnd='.time();
  723. echo '<input type="image" src="'.$fullurl.'" alt="'.$alt.'" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/><br />';
  724. } else {
  725. echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
  726. echo '<br />';
  727. }
  728. echo '<br />'.$status.'<br />';
  729. global $user_anonymous;
  730. if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
  731. echo '<br />';
  732. echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$safe_user_id.'">'.get_lang('ViewSharedProfile').'</a>';
  733. echo '<br />';
  734. $user_anonymous = api_get_anonymous_id();
  735. if ($safe_user_id != api_get_user_id() && !api_is_anonymous($safe_user_id)) {
  736. $user_relation = SocialManager::get_relation_between_contacts(api_get_user_id(), $safe_user_id);
  737. if ($user_relation == 0 || $user_relation == 6) {
  738. echo '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=300&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a><br />
  739. <a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>';
  740. } else {
  741. echo '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=310&width=610&user_friend='.$safe_user_id.'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>';
  742. }
  743. }
  744. }
  745. if (api_get_setting('show_email_addresses') == 'true') {
  746. echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />';
  747. }
  748. echo '</div>';
  749. if ($user_object->competences) {
  750. echo '<dt><div class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div></dt>';
  751. echo '<dd>'.$user_object->competences.'</dd>';
  752. }
  753. if ($user_object->diplomas) {
  754. echo '<dt><div class="actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div></dt>';
  755. echo '<dd>'.$user_object->diplomas.'</dd>';
  756. }
  757. if ($user_object->teach) {
  758. echo '<dt><div class="actions-message"><strong>'.get_lang('MyTeach').'</strong></div></dt>';
  759. echo '<dd>'.$user_object->teach.'</dd>';;
  760. }
  761. SocialManager::display_productions($user_object->user_id);
  762. if ($user_object->openarea) {
  763. echo '<dt><div class="actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div></dt>';
  764. echo '<dd>'.$user_object->openarea.'</dd>';
  765. }
  766. }
  767. else
  768. {
  769. Display::display_header(get_lang('UsersOnLineList'));
  770. echo '<div class="actions-title">';
  771. echo get_lang('UsersOnLineList');
  772. echo '</div>';
  773. }
  774. }
  775. /**
  776. * Display productions in whoisonline
  777. * @param int $user_id User id
  778. * @todo use the correct api_get_path instead of $clarolineRepositoryWeb
  779. */
  780. function display_productions($user_id) {
  781. $sysdir_array = UserManager::get_user_picture_path_by_id($user_id, 'system', true);
  782. $sysdir = $sysdir_array['dir'].$user_id.'/';
  783. $webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true);
  784. $webdir = $webdir_array['dir'].$user_id.'/';
  785. if (!is_dir($sysdir)) {
  786. mkpath($sysdir);
  787. }
  788. /*
  789. $handle = opendir($sysdir);
  790. $productions = array();
  791. while ($file = readdir($handle)) {
  792. if ($file == '.' || $file == '..' || $file == '.htaccess') {
  793. continue; // Skip current and parent directories
  794. }
  795. if (preg_match('/('.$user_id.'|[0-9a-f]{13}|saved)_.+\.(png|jpg|jpeg|gif)$/i', $file)) {
  796. // User's photos should not be listed as productions.
  797. continue;
  798. }
  799. $productions[] = $file;
  800. }
  801. */
  802. $productions = UserManager::get_user_productions($user_id);
  803. if (count($productions) > 0) {
  804. echo '<dt><strong>'.get_lang('Productions').'</strong></dt>';
  805. echo '<dd><ul>';
  806. foreach ($productions as $index => $file) {
  807. // Only display direct file links to avoid browsing an empty directory
  808. if (is_file($sysdir.$file) && $file != $webdir_array['file']) {
  809. echo '<li><a href="'.$webdir.urlencode($file).'" target=_blank>'.$file.'</a></li>';
  810. }
  811. // Real productions are under a subdirectory by the User's id
  812. if (is_dir($sysdir.$file)) {
  813. $subs = scandir($sysdir.$file);
  814. foreach ($subs as $my => $sub) {
  815. if (substr($sub, 0, 1) != '.' && is_file($sysdir.$file.'/'.$sub)) {
  816. echo '<li><a href="'.$webdir.urlencode($file).'/'.urlencode($sub).'" target=_blank>'.$sub.'</a></li>';
  817. }
  818. }
  819. }
  820. }
  821. echo '</ul></dd>';
  822. }
  823. }
  824. /**
  825. * Dummy function
  826. *
  827. */
  828. public static function get_plugins($place = SOCIAL_CENTER_PLUGIN) {
  829. $content = '';
  830. switch ($place) {
  831. case SOCIAL_CENTER_PLUGIN:
  832. $social_plugins = array(1, 2);
  833. if (is_array($social_plugins) && count($social_plugins)>0) {
  834. $content.= '<div id="social-plugins">';
  835. foreach($social_plugins as $plugin ) {
  836. $content.= '<div class="social-plugin-item">';
  837. $content.= $plugin;
  838. $content.= '</div>';
  839. }
  840. $content.= '</div>';
  841. }
  842. break;
  843. case SOCIAL_LEFT_PLUGIN:
  844. break;
  845. case SOCIAL_RIGHT_PLUGIN:
  846. break;
  847. }
  848. return $content;
  849. }
  850. }