index.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2009 Dokeos SPRL
  6. For a full list of contributors, see "credits.txt".
  7. The full license can be read in "license.txt".
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. See the GNU General Public License for more details.
  13. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  14. Mail: info@dokeos.com
  15. ==============================================================================
  16. */
  17. $cidReset = true;
  18. $language_file = array('registration','messages','userInfo','admin');
  19. require '../inc/global.inc.php';
  20. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  21. $this_section = SECTION_MYPROFILE;
  22. $_SESSION['this_section']=$this_section;
  23. api_block_anonymous_users();
  24. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  25. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery-1.1.3.1.pack.js" type="text/javascript"></script>';
  26. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.history_remote.pack.js" type="text/javascript"></script>';
  27. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.tabs.pack.js" type="text/javascript"></script>';
  28. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
  29. //$htmlHeadXtra[] = '<style rel="stylesheet" href="../inc/lib/javascript/thickbox.css" type="text/css" media="projection, screen">';
  30. $htmlHeadXtra[]='<style type="text/css" media="all">@import "'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css";</style>';
  31. $htmlHeadXtra[] = '<script type="text/javascript">
  32. $(function() {
  33. $("#container-9").tabs({ remote: true});
  34. });
  35. function register_friend(element_input) {
  36. name_button=$(element_input).attr("id");
  37. name_div_id="id_"+name_button.substring(13);
  38. user_id=name_div_id.split("_");
  39. user_friend_id=user_id[1];
  40. $.ajax({
  41. contentType: "application/x-www-form-urlencoded",
  42. beforeSend: function(objeto) {
  43. $("#id_response").html("'.get_lang('Loading', '').'"); },
  44. type: "POST",
  45. url: "../social/register_friend.php",
  46. data: "friend_id="+user_friend_id,
  47. success: function(datos) {
  48. $("div#"+name_div_id).hide("slow");
  49. $("#id_response").html(datos);
  50. }
  51. });
  52. }
  53. function denied_friend (element_input) {
  54. name_button=$(element_input).attr("id");
  55. name_div_id="id_"+name_button.substring(13);
  56. user_id=name_div_id.split("_");
  57. friend_user_id=user_id[1];
  58. $.ajax({
  59. contentType: "application/x-www-form-urlencoded",
  60. beforeSend: function(objeto) {
  61. $("#id_response").html("'.get_lang('Loading', '').'"); },
  62. type: "POST",
  63. url: "../social/register_friend.php",
  64. data: "denied_friend_id="+friend_user_id,
  65. success: function(datos) {
  66. $("div#"+name_div_id).hide("slow");
  67. $("#id_response").html(datos);
  68. }
  69. });
  70. }
  71. function delete_friend (element_div) {
  72. id_image=$(element_div).attr("id");
  73. user_id=id_image.split("_");
  74. if (confirm("'.get_lang('Delete', '').'")) {
  75. $.ajax({
  76. contentType: "application/x-www-form-urlencoded",
  77. beforeSend: function(objeto) {
  78. /*$("#id_response").html("Cargando...");*/ },
  79. type: "POST",
  80. url: "../social/register_friend.php",
  81. data: "delete_friend_id="+user_id[1],
  82. success: function(datos) {
  83. //alert(datos);
  84. $("div#"+"div_"+user_id[1]).hide("slow");
  85. $("div#"+"div_"+user_id[1]).html("");
  86. clear_form ();
  87. }
  88. });
  89. }
  90. }
  91. function qualify_friend(element_div) {
  92. name_user=$(element_div).attr("title");
  93. id_full=$(element_div).attr("id");
  94. $("div#div_info_user").html(name_user);
  95. user_qualify=id_full.split("_");
  96. user_qualify_id=user_qualify[1];
  97. $("#user_cod_qualify").attr("value",user_qualify_id);
  98. get_image_url=$(element_div).attr("src");
  99. img_html="<img width=100 height=120 src="+get_image_url+" />";
  100. $("div#div_qualify_image").html(img_html);
  101. }
  102. function set_qualify_friend() {
  103. user_id_friend = $("#user_cod_qualify").attr("value");
  104. type_friend = $("input[@name=list_type_friend]:checked").val();
  105. if (user_id_friend==0) {
  106. alert("'.get_lang('SelectOneContact', '').'");
  107. return false;
  108. }
  109. if (type_friend==null) {
  110. alert("'.get_lang('SelectOneGroup', '').'");
  111. return false;
  112. }
  113. if (confirm("'.get_lang('AttachContactsPersonal', '').' ?")) {
  114. $.ajax({
  115. contentType: "application/x-www-form-urlencoded",
  116. beforeSend: function(objeto) {
  117. /*$("#id_response").html("Cargando...");*/ },
  118. type: "POST",
  119. url: "../social/register_friend.php",
  120. data: "user_id_friend_q="+user_id_friend+"&type_friend_q="+type_friend,
  121. success: function(datos) {
  122. //alert(datos);
  123. tb_remove();
  124. //clear_form();
  125. }
  126. });
  127. }
  128. }
  129. function show_icon_delete(element_html) {
  130. elem_id=$(element_html).attr("id");
  131. id_elem=elem_id.split("_");
  132. ident="#img_"+id_elem[1];
  133. $(ident).attr("src","../img/delete.gif");
  134. $(ident).attr("alt","'.get_lang('Delete', '').'");
  135. $(ident).attr("title","'.get_lang('Delete', '').'");
  136. }
  137. function hide_icon_delete(element_html) {
  138. elem_id=$(element_html).attr("id");
  139. id_elem=elem_id.split("_");
  140. ident="#img_"+id_elem[1];
  141. $(ident).attr("src","../img/blank.gif");
  142. $(ident).attr("alt","");
  143. $(ident).attr("title","");
  144. }
  145. function search_image_social(element_html) {
  146. name_search=$(element_html).attr("value");
  147. $.ajax({
  148. contentType: "application/x-www-form-urlencoded",
  149. beforeSend: function(objeto) {
  150. $("#div_content_table").html("'.get_lang('Searching', '').'"); },
  151. type: "POST",
  152. url: "../social/show_search_image.inc.php",
  153. data: "search_name_q="+name_search,
  154. success: function(datos) {
  155. $("div#div_content_table").html(datos);
  156. }
  157. });
  158. }
  159. function clear_form () {
  160. $("input[@type=radio]").attr("checked", false);
  161. $("div#div_qualify_image").html("");
  162. $("div#div_info_user").html("");
  163. }
  164. function toogle_function (element_html){
  165. elem_id=$(element_html).attr("id");
  166. id_elem=elem_id.split("_");
  167. ident="div#div_group_"+id_elem[1];
  168. id_button="#btn_"+id_elem[1];
  169. elem_src=$(id_button).attr("src");
  170. image_show=elem_src.split("/");
  171. for (i=0;i<image_show.length;i++) {
  172. if (image_show[i]=="visible.gif" || image_show[i]=="invisible_na.gif") {
  173. my_image=image_show[i];
  174. }
  175. }
  176. if (my_image=="visible.gif") {
  177. $(ident).hide("slow");
  178. $(id_button).attr("src","../img/invisible_na.gif");
  179. } else {
  180. $(ident).show("slow");
  181. $(id_button).attr("src","../img/visible.gif");
  182. }
  183. }
  184. function selectall_cheks() {
  185. $("input[@type=checkbox]").attr("checked", true);
  186. }
  187. function unselectall_cheks() {
  188. $("input[@type=checkbox]").attr("checked", false);
  189. }
  190. function submit_form (path_submit) {
  191. if (path_submit=="inbox") {
  192. if (count_checkbox("inbox") > 0) {
  193. document.getElementById(\'form_send\').action="../social/index.php?inbox=true#remote-tab-2";
  194. if (confirm("'.get_lang('ConfirmYourChoice', '').'")) {
  195. $("#form_send").submit();
  196. }
  197. } else {
  198. alert("'.get_lang('SelectTheCheckbox', '').'");
  199. }
  200. } else {
  201. if (count_checkbox("outbox") > 0) {
  202. document.getElementById(\'form_send_out\').action="../social/index.php?outbox=true#remote-tab-3";
  203. if (confirm("'.get_lang('ConfirmYourChoice', '').'")) {
  204. $("#form_send_out").submit();
  205. }
  206. } else {
  207. alert("'.get_lang('SelectedMoreOptions', '').'");
  208. }
  209. }
  210. }
  211. function count_checkbox(status_type) {
  212. if (status_type=="inbox") {
  213. var checkboxes = document.getElementsByName("id[]");
  214. var cont = 0;
  215. for (var x=0; x < checkboxes.length; x++) {
  216. if (checkboxes[x].checked) {
  217. cont = cont + 1;
  218. }
  219. }
  220. return cont;
  221. } else {
  222. var checkboxes = document.getElementsByName("out[]");
  223. var cont = 0;
  224. for (var x=0; x < checkboxes.length; x++) {
  225. if (checkboxes[x].checked) {
  226. cont = cont + 1;
  227. }
  228. }
  229. return cont;
  230. }
  231. }
  232. function get_action_url_and_show_messages (name_rs,name_id) {
  233. $.ajax({
  234. contentType: "application/x-www-form-urlencoded",
  235. beforeSend: function(objeto) {
  236. $("#id_response").html("'.get_lang('Loading', '').'"); },
  237. type: "GET",
  238. url: "../messages/view_message.php",
  239. data: "rs="+name_rs+"&id="+name_id,
  240. success: function(datos) {
  241. $("div#div_content_messages").html(datos);
  242. $("div#div_content_table_data").html(" ");
  243. }
  244. });
  245. }
  246. function close_div_show (my_div) {
  247. $("div#"+my_div).html("");
  248. $.ajax({
  249. contentType: "application/x-www-form-urlencoded",
  250. beforeSend: function(objeto) {
  251. $("#id_response").html("'.get_lang('Loading', '').'"); },
  252. type: "POST",
  253. url: "../messages/inbox.php",
  254. data:"",
  255. success: function(datos) {
  256. $("div#div_content_table_data").html(datos);
  257. }
  258. });
  259. }
  260. function reply_to_messages (my_action,name_rs,name_id) {
  261. if(my_action=="show") {
  262. $("div#div_content_messages").html("");
  263. $("div#div_content_table_data").html("");
  264. $.ajax({
  265. contentType: "application/x-www-form-urlencoded",
  266. beforeSend: function(objeto) {
  267. $("#id_response").html("'.get_lang('Loading', '').'"); },
  268. type: "GET",
  269. url: "../messages/new_message.php",
  270. data:"re_id="+name_rs+"&id="+name_id,
  271. success: function(datos) {
  272. $("div#div_content_messages").html(datos);
  273. }
  274. });
  275. }
  276. }
  277. function compose_and_show_message (my_action,name_rs) {
  278. if(my_action=="show") {
  279. $("div#div_content_messages").html("");
  280. $("div#div_content_table_data").html("");
  281. $.ajax({
  282. contentType: "application/x-www-form-urlencoded",
  283. beforeSend: function(objeto) {
  284. $("#id_response").html("'.get_lang('Loading', '').'"); },
  285. type: "GET",
  286. url: "../messages/new_message.php",
  287. data:"rs="+name_rs,
  288. success: function(datos) {
  289. $("div#div_content_messages").html(datos);
  290. }
  291. });
  292. }
  293. }
  294. function send_request_and_search() {
  295. cont=0;
  296. $("#id_text_name").bind("keyup", function(){
  297. name=$("#id_text_name").get(0).value;
  298. $.ajax({
  299. contentType: "application/x-www-form-urlencoded",
  300. beforeSend: function(objeto) {
  301. /*$("#id_div_search").html("Searching...");*/ },
  302. type: "POST",
  303. url: "../social/select_options.php",
  304. data: "search="+name,
  305. success: function(datos){
  306. $("#id_div_search").html(datos)
  307. $("#id_search_name").bind("click", function() {
  308. name_option=$("select#id_search_name option:selected").text();
  309. code_option=$("select#id_search_name option:selected").val();
  310. $("#user_list").attr("value", code_option);
  311. $("#id_text_name").attr("value", name_option);
  312. $("#id_div_search").html("");
  313. cont++;
  314. });
  315. }
  316. });
  317. });
  318. }
  319. function delete_one_message (num_id) {
  320. $("div#div_content_messages").html("");
  321. $("div#div_content_table_data").html("");
  322. $.ajax({
  323. contentType: "application/x-www-form-urlencoded",
  324. beforeSend: function(objeto) {
  325. /*$("#id_div_search").html("Searching...");*/ },
  326. type: "GET",
  327. url: "../messages/inbox.php",
  328. data: "action="+"deleteone"+"&id="+num_id,
  329. success: function(datos){
  330. $("#div_content_table_data").html(datos)
  331. }
  332. });
  333. }
  334. function show_sent_message (id_sent) {
  335. $("div#div_content_messages_sent").html("");
  336. $("div#div_content_table_data_sent").html("");
  337. $.ajax({
  338. contentType: "application/x-www-form-urlencoded",
  339. beforeSend: function(objeto) {
  340. /*$("#id_div_search").html("Searching...");*/ },
  341. type: "GET",
  342. url: "../messages/view_message.php",
  343. data: "rs="+"1"+"&id_send="+id_sent,
  344. success: function(datos){
  345. $("#div_content_table_data_sent").html(datos)
  346. }
  347. });
  348. }
  349. function close_and_open_outbox() {
  350. $("div#div_content_messages_sent").html("");
  351. $("div#div_content_table_data_sent").html("");
  352. $.ajax({
  353. contentType: "application/x-www-form-urlencoded",
  354. beforeSend: function(objeto) {
  355. $("#id_response").html("'.get_lang('Loading', '').'"); },
  356. type: "POST",
  357. url: "../messages/outbox.php",
  358. data:"",
  359. success: function(datos) {
  360. $("div#div_content_table_data_sent").html(datos);
  361. }
  362. });
  363. }
  364. function delete_one_message_outbox (num_id) {
  365. $("div#div_content_messages_sent").html("");
  366. $("div#div_content_table_data_sent").html("");
  367. $.ajax({
  368. contentType: "application/x-www-form-urlencoded",
  369. beforeSend: function(objeto) {
  370. /*$("#id_div_search").html("Searching...");*/ },
  371. type: "GET",
  372. url: "../messages/outbox.php",
  373. data: "action="+"deleteone"+"&id="+num_id,
  374. success: function(datos){
  375. $("#div_content_table_data_sent").html(datos)
  376. }
  377. });
  378. }
  379. function list_search_hide () {
  380. setTimeout("hide_search_list()",1500);
  381. }
  382. function hide_search_list () {
  383. $("div#id_div_search").html("");
  384. }
  385. </script>';
  386. $htmlHeadXtra[] = '<link rel="stylesheet" href="../inc/lib/javascript/jquery.tabs.css" type="text/css" media="print, projection, screen">';
  387. $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/jquery.tabs.css" type="text/css" media="print, projection, screen">';
  388. $htmlHeadXtra[] = '
  389. <!-- Additional IE/Win specific style sheet (Conditional Comments) -->
  390. <!--[if lte IE 7]>
  391. <link rel="stylesheet" href="../inc/lib/javascript/jquery.tabs-ie.css" type="text/css" media="projection, screen">
  392. <![endif]-->
  393. ';
  394. $htmlHeadXtra[] = '<style type="text/css" media="screen, projection">
  395. /* Not required for Tabs, just to make this demo look better... */
  396. * html body {
  397. font-size: 100%; /* @ IE */
  398. }
  399. h1 {
  400. margin: 1em 0 1.5em;
  401. font-size: 18px;
  402. }
  403. h2 {
  404. margin: 2em 0 1.5em;
  405. font-size: 16px;
  406. }
  407. p {
  408. margin: 0;
  409. }
  410. pre, pre+p, p+p {
  411. margin: 1em 0 0;
  412. }
  413. code {
  414. font-family: "Courier New", Courier, monospace;
  415. }
  416. </style>';
  417. $_SESSION['social_exist']=true;
  418. $_SESSION['social_dest'] = 'index.php';
  419. $interbreadcrumb[]= array (
  420. 'url' => '#',
  421. 'name' => get_lang('ModifyProfile')
  422. );
  423. if ((api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') ||(api_get_setting('allow_social_tool')=='true') && api_get_user_id()<>2 && api_get_user_id()<>0) {
  424. $interbreadcrumb[]= array (
  425. 'url' => 'index.php?#remote-tab-1',
  426. 'name' => get_lang('SocialNetwork')
  427. );
  428. } elseif ((api_get_setting('allow_social_tool')=='false' && api_get_setting('allow_message_tool')=='true')) {
  429. $interbreadcrumb[]= array (
  430. 'url' => 'index.php?#remote-tab-1',
  431. 'name' => get_lang('MessageTool')
  432. );
  433. }
  434. Display :: display_header('');
  435. if (isset($_GET['sendform'])) {
  436. $form_reply=array();
  437. $form_reply[]=urlencode($_POST['title']);
  438. $form_reply[]=urlencode($_POST['content']);
  439. $form_reply[]=$_POST['user_list'];
  440. $form_reply[]=$_POST['re_id'];
  441. $form_reply[]=urlencode($_POST['compose']);
  442. $form_reply[]=urlencode($_POST['id_text_name']);
  443. $form_reply[]=urlencode($_POST['save_form']);
  444. $form_info=implode(',',$form_reply);
  445. $form_send_data_message='?form_reply='.$form_info;
  446. } elseif (isset($_GET['inbox'])) {
  447. $form_delete=array();
  448. $form_delete[]=$_POST['action'];
  449. for ($i=0;$i<count($_POST['id']);$i++) {
  450. $form_delete[]=$_POST['id'][$i];
  451. }
  452. $form_info=implode(',',$form_delete);
  453. $form_send_data_message='?form_delete='.($form_info);
  454. } elseif (isset($_GET['outbox'])) {
  455. $form_delete_outbox=array();
  456. $form_delete_outbox[]=$_POST['action'];
  457. for ($i=0;$i<count($_POST['out']);$i++) {
  458. $form_delete_outbox[]=$_POST['out'][$i];
  459. }
  460. $form_info_outbox=implode(',',$form_delete_outbox);
  461. $form_send_data_message='?form_delete_outbox='.($form_info_outbox);
  462. }
  463. $form_url_send=isset($form_send_data_message) ? $form_send_data_message :'';
  464. ?>
  465. <div id="container-9">
  466. <ul>
  467. <li><a href="data_personal.inc.php"><span><?php Display :: display_icon('profile.png',get_lang('PersonalData')); echo '&nbsp;&nbsp;'.get_lang('PersonalData'); ?></span></a></li>
  468. <?php
  469. if (api_get_setting('allow_message_tool')=='true') {
  470. ?>
  471. <li><a href="../messages/inbox.php<?php echo $form_url_send; ?>"><span><?php Display :: display_icon('inbox.png',get_lang('Inbox')); echo '&nbsp;&nbsp;'.get_lang('Inbox');?></span></a></li>
  472. <li><a href="../messages/outbox.php<?php echo $form_url_send; ?>"><span><?php Display :: display_icon('outbox.png',get_lang('Outbox') ); echo '&nbsp;&nbsp;'.get_lang('Outbox');?></span></a></li>
  473. <?php }
  474. if (api_get_setting('allow_social_tool')=='true') {
  475. ?>
  476. <li><a href="select_friend_response.php"><span><?php Display :: display_icon('pending_invitation.png',get_lang('PendingInvitations'), array('height'=>'22px')); echo '&nbsp;&nbsp;'.get_lang('PendingInvitations'); ?></span></a></li>
  477. <li><a href="contacts.inc.php"><span><?php Display :: display_icon('contacts.png',get_lang('Contacts')); echo '&nbsp;&nbsp;'.get_lang('Contacts'); ?></span></a></li>
  478. <li><a href="group_contact.inc.php"><span><?php Display :: display_icon('group_contact.png',get_lang('ContactsGroups')); echo '&nbsp;&nbsp;'.get_lang('ContactsGroups'); ?></span></a></li>
  479. <?php
  480. }
  481. ?>
  482. </ul>
  483. <?php echo '<div id="show">&nbsp;</div>';?>
  484. </div>
  485. <?php
  486. Display :: display_footer();
  487. ?>