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('../lib/functions_auth.php');
  12. include_once('../config/define.php');
  13. include_once('../lib/lib_common.php');
  14. include_once('../class/class.comment.php');
  15. include_once('../languages/' . U_L . '/lang_comment.' . CHARSET . '.php');
  16. include_once('../languages/' . U_L . '/lang_common.' . CHARSET . '.php');
  17. include_once(themePath('../comment/display.php'));
  18.  
  19. $arr = array();
  20.  
  21. $arr['module'] = $o['module'] = $_POST['module'];
  22. if(isset($_POST['file_id'])) {
  23.   $arr['module_id'] = $o['module_id'] = $_POST['file_id'];
  24.   $wgid = $_POST['id'];
  25. } else {
  26.   $arr['module_id'] = $o['module_id'] = $_POST['id'];
  27. }
  28.  
  29. ////////////////////////////////////////
  30. /// Connexion SQL
  31. ///////////////////
  32. include_once('../class/system/class.'.SQL.'.php');
  33. $sql_entity=SQL;
  34. $GLOBALS['sql_object'] = new $sql_entity;
  35. $GLOBALS['sql_object'] -> DBInitialise();
  36. $GLOBALS['sql_object'] -> DBConnexion();
  37. ///////////////////
  38.  
  39. //////////// Check Droits utilisateur ////////////
  40. if ($arr['module'] == 'files') {
  41.   if(!isset($_COOKIE['linea21']['login'])) die('<p class="error">'._t('divers', 'noauth').'</p>');
  42.   if($wgid != 'shared' && !isWorkgroupUser($wgid)) die('<p class="error">'._t('divers', 'noauth').'</p>');
  43. }
  44. ////////////
  45.  
  46.  
  47. isset($_COOKIE['linea21']['login']) ? $arr['user_id'] = $_COOKIE['linea21']['id'] : $arr['user_id'] = '';
  48. isset($_POST['cname']) ? $arr['name'] = $_POST['cname'] : $arr['name'] = '';
  49. isset($_POST['cemail']) ? $arr['email'] = $_POST['cemail'] : $arr['email'] = '';
  50. isset($_POST['curl']) ? $arr['url'] = $_POST['curl'] : $arr['url'] = '';
  51. isset($_POST['cbody']) ? $arr['body'] = $_POST['cbody'] : $arr['body'] = '';
  52. isset($_POST['cnotification']) ? $arr['notification'] = 'Y' : $arr['notification'] = 'N';
  53.  
  54.  
  55. $comm = new comment;
  56. $passed = $comm->checkDataIntegrity($arr);
  57.  
  58.  
  59. if(is_string($passed)) {
  60.   /* Outputting the error messages */
  61.   echo '{"status":0,"errors":{"msg":'.json_encode($passed).'}}';
  62.  
  63. } else {
  64.   /* we add the new comment */
  65.   $r = $comm->add($arr, $GLOBALS['sql_object']);
  66.   if(!is_numeric($r)) system_error();
  67.  
  68.   // we send an email to default user for moderation if needed
  69.    emailModerators($arr, $r, $comm);
  70.    
  71.   // we notify users if needed
  72.   // no notification on 'contribute' module
  73.   if($arr['module'] != 'contribute') {
  74.     notifyUsers($arr, $r, $comm);
  75.   }
  76.  
  77.   $o['status'] = array('P', 'D');
  78.   $o['given_id'] = $r;
  79.  
  80.   /* Outputting the markup of the just-inserted comment: */
  81.   echo json_encode(array('status'=>1,'html'=> getComments($o) ));
  82. }
  83.  
  84. ?>

Documentation generated on Thu, 03 May 2012 15:08:02 +0200 by phpDocumentor 1.4.1