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

Source for file _ajax_admin.php

Documentation is available at _ajax_admin.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(themePath('../comment/display.php'));
  17.  
  18. //////////// Check Droits utilisateur ////////////
  19. if (!IsSuperAdmin()) ReloadIndex('admin');
  20. ////////////
  21.  
  22. $a = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
  23. parse_str($a, $output);
  24. $page = $output['rub'];
  25.  
  26. $id = $_GET['id'];
  27. $todo = $_GET['todo'];
  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.  
  40. $comm = new comment;
  41.  
  42. if($todo == 'disapprove') {
  43.   $r = $comm->disapprove($id, $GLOBALS['sql_object']);
  44.   $msg = _t('comment', 'disapproved');
  45. }
  46. if($todo == 'approve') {
  47.   $isnew = $comm->isnew($id, $GLOBALS['sql_object']);
  48.   if($isnew === true) {
  49.     $comment = $comm->get(array('given_id' => $id, 'status' => array('P', 'D', 'E')), $GLOBALS['sql_object']);
  50.     $arr = array();
  51.     $arr['module'] = $comment[0]['comment_module'];
  52.     $arr['module_id'] = $comment[0]['comment_module_id'];
  53.     $arr['user_id'] = $comment[0]['comment_user_id'];
  54.     $arr['name'] = $comment[0]['comment_name'];
  55.     $arr['email'] = $comment[0]['comment_email'];
  56.     $arr['body'] = $comment[0]['comment_body'];
  57.   }
  58.   $r = $comm->approve($id, $GLOBALS['sql_object']);
  59.   $msg = _t('comment', 'approved');
  60. }
  61. if($todo == 'del') {
  62.   $r = $comm->delete($id, $GLOBALS['sql_object']);
  63.   $msg = '';
  64. }
  65. if($r == true) {
  66.   // new validated comments notified to users, if needed
  67.  
  68.   if(isset($arr) && $arr['module'] != 'contribute') {
  69.     notifyusers($arr,$id, $comm, true);
  70.   }
  71.   echo '{"status":1,"el": "#com-'.$id.'", "action": "'.$todo.'", "page": "'.$page.'", "msg": "'.$msg.'"}';
  72. } else {
  73.   echo '{"status":0,"el": "#com-'.$id.'", "action": "'.$todo.'", "page": "'.$page.'", "msg": "'.$msg.'"}';
  74. }
  75.  
  76. ?>

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