index.php 18 KB

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