pearweb_manual
[ class tree: pearweb_manual ] [ index: pearweb_manual ] [ all elements ]

Source for file trans.php

Documentation is available at trans.php

  1. <?php
  2. auth_require('pear.dev');
  3.  
  4. require_once 'notes/ManualNotes.class.php';
  5. $manualNotes = new Manual_Notes;
  6.  
  7. $action '';
  8.  
  9. if (isset($_REQUEST['action'])) {
  10.     $action strtolower($_REQUEST['action']);
  11. }
  12.  
  13. switch ($action{
  14.     case 'makedocbug':
  15.         if (isset($_GET['noteId'])) {
  16.             $noteId = (int)$_GET['noteId'];
  17.  
  18.             $note $manualNotes->getSingleCommentById($noteId);
  19.  
  20.             $registered      = 1;
  21.             $package         getPackageNameForId($note['page_url']);
  22.             $package_name    is_null($package'Documentation' $package;
  23.             $bug_type        'Documentation Problem';
  24.             $email           $auth_user->email;
  25.             $handle          $auth_user->handle;
  26.             $sdesc           'User note that is a documentation problem';
  27.             $ldesc           'Manual page: ' $note['page_url'"\n" .
  28.                                'Note submitter:' "\n";
  29.             if (!empty($note['user_handle'])) {
  30.                 $ldesc .= user_link($note['user_handle']true);
  31.             else {
  32.                 include_once 'bugs/pear-bugs-utils.php';
  33.                 $ldesc .= PEAR_Bugs_Utils::spamProtect($note['user_name']'text');
  34.             }
  35.             $ldesc          .=  "\n\n" str_replace('<br />'''$dbh->escapeSimple(html_entity_decode($note['note_text'])));
  36.             $package_version = null;
  37.             $php_version     'Irrelevant';
  38.             $php_os          'Irrelevant';
  39.             $status          'Open';
  40.             $passwd          = null;
  41.             $reporter_name   $auth_user->name;
  42.  
  43.             $sql "
  44.                 INSERT INTO bugdb (
  45.                     registered,
  46.                     package_name,
  47.                     bug_type,
  48.                     email,
  49.                     handle,
  50.                     sdesc,
  51.                     ldesc,
  52.                     package_version,
  53.                     php_version,
  54.                     php_os,
  55.                     status,
  56.                     ts1,
  57.                     passwd,
  58.                     reporter_name
  59.                 ) VALUES (
  60.                     ?, ?, ?, ?, ?,
  61.                     ?, ?, null, ?, ?,
  62.                     ?, NOW(), null, ?
  63.                 )
  64.             ";
  65.  
  66.             $args = array($registered$package_name$bug_type,
  67.                           $email$handle$sdesc$ldesc$php_version$php_os$status$reporter_name);
  68.  
  69.             $dbh->query($sql$args);
  70.             // TODO: add error handling
  71.  
  72.             $id mysqli_insert_id($dbh->connection);
  73.  
  74.             $manualNotes->deleteSingleComment($noteId);
  75.             // TODO: add error handling
  76.  
  77.             $emailInfos = array(
  78.                 'reporter_name'   => $reporter_name,
  79.                 'email'           => $auth_user->email,
  80.                 'id'              => $id,
  81.                 'php_os'          => $php_os,
  82.                 'package_version' => $package_version,
  83.                 'php_version'     => $php_version,
  84.                 'package_name'    => $package_name,
  85.                 'bug_type'        => $bug_type,
  86.                 'ldesc'           => $ldesc,
  87.                 'sdesc'           => $sdesc,
  88.             );
  89.  
  90.             require 'bugs/pear-bug-accountrequest.php';
  91.             $pba = new PEAR_Bug_AccountRequest;
  92.             $pba->sendBugEmail($emailInfos);
  93.  
  94.             include dirname(__FILE__'/index.php';
  95.             exit;
  96.         }
  97.         break;
  98.     case 'updateapproved':
  99.  
  100.         if (isset($_POST['noteIds']&& is_array($_POST['noteIds'])) {
  101.             if (isset($_POST['pending'])) {
  102.                 $notes $manualNotes->updateCommentList($_POST['noteIds']'pending');
  103.             elseif (isset($_POST['delete'])) {
  104.                 $notes $manualNotes->updateCommentList($_POST['noteIds']'no');
  105.             else {
  106.                 $notes = PEAR::raiseError('Neither delete nor approve was selected');
  107.             }
  108.  
  109.             if (PEAR::isError($notes)) {
  110.                 $error 'Error while making the note pending, contact webmaster';
  111.             else {
  112.                 $message 'Comment(s) successfully ';
  113.                 $message .= isset($_POST['pending']'made pending' 'deleted';
  114.             }
  115.             $_GET $_POST;
  116.             $_GET['status''approved';
  117.  
  118.             include dirname(__FILE__'/index.php';
  119.             exit;
  120.         else {
  121.             $error 'Neither pending nor delete was selected';
  122.             $_GET $_POST;
  123.             $_GET['status''approved';
  124.  
  125.             include dirname(__FILE__'/index.php';
  126.             exit;
  127.         }
  128.  
  129.         if (isset($_POST['url']&& !empty($_POST['url'])) {
  130.             $pendingComments $manualNotes->getPageComments($_POST['url']'yes');
  131.         else {
  132.             $pendingComments $manualNotes->getPageComments('''yes'true);
  133.         }
  134.  
  135.         $url = isset($_POST['url']strip_tags($_POST['url']'';
  136.         $error '';
  137.         require PEARWEB_TEMPLATEDIR . '/notes/note-manage-admin.tpl.php';
  138.         break;
  139.     case 'approvemass':
  140.  
  141.         if (isset($_POST['noteIds']&& is_array($_POST['noteIds'])) {
  142.             if (isset($_POST['approve']|| isset($_POST['undelete'])) {
  143.                 $notes $manualNotes->updateCommentList($_POST['noteIds']'yes');
  144.             elseif (isset($_POST['delete'])) {
  145.                 $notes $manualNotes->updateCommentList($_POST['noteIds']'no');
  146.             else {
  147.                 $notes = PEAR::raiseError('Neither delete nor un-delete nor approve was selected');
  148.             }
  149.  
  150.             if (PEAR::isError($notes)) {
  151.                 $error 'Error approving the comments, contact webmaster';
  152.             else {
  153.                 $message 'Comment(s) successfully ';
  154.                 $message .= isset($_POST['approve']'approved' 'deleted';
  155.             }
  156.             $_GET $_POST;
  157.             if (isset($_POST['undelete'])) {
  158.                 $_GET['status''deleted';
  159.             }
  160.  
  161.             include dirname(__FILE__'/index.php';
  162.             exit;
  163.         else {
  164.             $error 'Neither delete nor un-delete nor approve was selected';
  165.             $_GET $_POST;
  166.             if (isset($_POST['undelete'])) {
  167.                 $_GET['status''deleted';
  168.             }
  169.  
  170.             include dirname(__FILE__'/index.php';
  171.             exit;
  172.         }
  173.  
  174.         if (isset($_POST['url']&& !empty($_POST['url'])) {
  175.             $pendingComments $manualNotes->getPageComments($_POST['url']'pending');
  176.         else {
  177.             $pendingComments $manualNotes->getPageComments('''pending'true);
  178.         }
  179.  
  180.         $url = isset($_POST['url']strip_tags($_POST['url']'';
  181.         $error '';
  182.         require PEARWEB_TEMPLATEDIR . '/notes/note-manage-admin.tpl.php';
  183.         break;
  184.     case 'updatesingle':
  185.         break;
  186.     default:
  187.        response_header('Note Administration'nullnull);
  188.        report_error('Missing action');
  189.        response_footer();
  190.        exit;
  191. }
  192.  
  193. function getPackageNameForId($id)
  194. {
  195.     global $dbh;
  196.     $res preg_match('/^package\.[\w-]+\.([\w-]+).*\.php$/'$id$matches);
  197.     if ($res === 0{
  198.         return null;
  199.     }
  200.     $package str_replace('-''_'$matches[1]);
  201.     $query 'SELECT name FROM packages WHERE LCASE(name) = LCASE(?)';
  202.     return $dbh->getOne($query$package);
  203. }

Documentation generated on Mon, 11 Mar 2019 16:04:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.