コード例 #1
0
ファイル: ticketsatisfaction.form.php プロジェクト: btry/glpi
LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkLoginUser();
$inquest = new TicketSatisfaction();
if (isset($_POST["update"])) {
    $inquest->check($_POST["tickets_id"], UPDATE);
    $inquest->update($_POST);
    Event::log($inquest->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
    Html::back();
}
Html::displayErrorAndDie('Lost');
コード例 #2
0
 /**
  * Answer to the ticket satisfaction survey
  * for an authenticated user
  *
  * @param $params    array of options (ticket, id2name)
  * @param $protocol        the communication protocol used
  *
  * @return array of hashtable as glpi.getTicket
  **/
 static function methodsetTicketSatisfaction($params, $protocol)
 {
     global $DB, $CFG_GLPI;
     if (isset($params['help'])) {
         return array('ticket' => 'integer,mandatory', 'id2name' => 'bool,optional', 'satisfaction' => 'integer,mandatory', 'comment' => 'text,optional', 'help' => 'bool,optional');
     }
     if (!Session::getLoginUserID()) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
     }
     $ticket = new Ticket();
     if (!isset($params['ticket'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket');
     }
     if (!isset($params['satisfaction'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'satisfaction');
     }
     if (!is_numeric($params['satisfaction']) || $params['satisfaction'] < 0 || $params['satisfaction'] > 5) {
         return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'satisfaction=' . $params['satisfaction']);
     }
     if (!$ticket->can($params['ticket'], 'r')) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'ticket');
     }
     $inquest = new TicketSatisfaction();
     if (!$inquest->getFromDB($params['ticket'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'satisfaction');
     }
     $input = array('id' => $inquest->getField('id'), 'tickets_id' => $inquest->getField('tickets_id'), 'satisfaction' => $params['satisfaction']);
     if (isset($params['comment'])) {
         $input['comment'] = addslashes($params['comment']);
     }
     if (!$inquest->can($params['ticket'], 'w')) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
     }
     if ($inquest->update($input)) {
         unset($params['satisfaction'], $params['comment']);
         return self::methodGetTicket($params, $protocol);
     }
     return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError());
 }