linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file _ajax_submit.php

Documentation is available at _ajax_submit.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage comment
  5.  * @author Simon Georget <simon@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. include_once('../config/define.php');
  12. include_once('../class/class.comment.php');
  13. include_once('../languages/' U_L '/lang_comment.' CHARSET '.php');
  14. include_once('../languages/' U_L '/lang_common.' CHARSET '.php');
  15. include_once(override('../comment/display.php'));
  16.  
  17. $arr array();
  18.  
  19. $arr['module'$o['module'$_POST['module'];
  20. if(isset($_POST['file_id'])) {
  21.   $arr['module_id'$o['module_id'$_POST['file_id'];
  22.   $wgid $_POST['id'];
  23. else {
  24.   $arr['module_id'$o['module_id'$_POST['id'];
  25. }
  26.  
  27.  
  28. //////////// Check Droits utilisateur ////////////
  29. if ($arr['module'== 'files'{
  30.   if(!isset($_SESSION['authenticated'])) die('<p class="error">'._t('divers''noauth').'</p>');
  31.   if($wgid != 'shared' && !$l21auth->isWorkgroupUser($wgid$sql_object)) die('<p class="error">'._t('divers''noauth').'</p>');
  32. }
  33. ////////////
  34.  
  35.  
  36. isset($_SESSION['userlogin']$arr['user_id'base64_decode($_SESSION['userid']$arr['user_id''';
  37. isset($_POST['cname']$arr['name'$_POST['cname'$arr['name''';
  38. isset($_POST['cemail']$arr['email'$_POST['cemail'$arr['email''';
  39. isset($_POST['curl']$arr['url'$_POST['curl'$arr['url''';
  40. isset($_POST['cbody']$arr['body'$_POST['cbody'$arr['body''';
  41. isset($_POST['cnotification']$arr['notification''Y' $arr['notification''N';
  42.  
  43. $comm new comment;
  44.  
  45. // prevent spam if user not authenticated
  46. if(!isset($_SESSION['authenticated']&& $_SESSION['securityaction']!=md5($_POST['securitycode'])) {
  47.     $passed =_t('security','message');
  48. }
  49.  
  50. if(!isset($passed)) $passed $comm->checkDataIntegrity($arr);
  51.  
  52.  
  53. if(is_string($passed)) {
  54.   /* Outputting the error messages */
  55.   echo '{"status":0,"errors":{"msg":'.json_encode($passed).'}}';
  56.  
  57. else {
  58.   /* we add the new comment */
  59.   $r $comm->add($arr$GLOBALS['sql_object']);
  60.   if(!is_numeric($r)) system_error();
  61.  
  62.   // we send an email to default user for moderation if needed
  63.    emailModerators($arr$r$comm);
  64.    
  65.   // we notify users if needed
  66.   // no notification on 'contribute' module
  67.   if($arr['module'!= 'contribute'{
  68.     notifyUsers($arr$r$comm);
  69.   }
  70.  
  71.   $o['status'array('P''D');
  72.   $o['given_id'$r;
  73.  
  74.   /* Outputting the markup of the just-inserted comment: */
  75.   echo json_encode(array('status'=>1,'html'=> getComments($o) ));
  76. }
  77.  
  78. ?>

Documentation generated on Thu, 20 Mar 2014 16:49:45 +0100 by phpDocumentor 1.4.1