示例#1
0
/**
 * Copyright 2001-2002 Robert E. Coyle <*****@*****.**>
 * Copyright 2001-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('whups');
$empty = '';
$beendone = 0;
$wereerrors = 0;
$vars = Horde_Variables::getDefaultVariables($empty);
$formname = $vars->get('formname');
Whups::addTopbarSearch();
$form1 = new Whups_Form_Ticket_CreateStepOne($vars);
$form2 = new Whups_Form_Ticket_CreateStepTwo($vars);
$form3 = new Whups_Form_Ticket_CreateStepThree($vars);
$form4 = new Whups_Form_Ticket_CreateStepFour($vars);
$r = new Horde_Form_Renderer(array('varrenderer_driver' => array('whups', 'whups')));
$valid4 = $form4->validate($vars) && $formname == 'whups_form_ticket_createstepfour';
$valid3 = $form3->validate($vars, true);
$valid2 = $form2->validate($vars, !$form1->isSubmitted());
$valid1 = $form1->validate($vars, true);
$doAssignForm = $GLOBALS['registry']->getAuth() && $whups_driver->isCategory('assigned', $vars->get('state'));
if ($valid1 && $valid2 && $valid3 && (!$doAssignForm || $valid4)) {
    $form1->getInfo($vars, $info);
    $form2->getInfo($vars, $info);
    $form3->getInfo($vars, $info);
    if ($doAssignForm) {
        $form4->getInfo($vars, $info);
示例#2
0
文件: Api.php 项目: raz0rsdge/horde
 /**
  * Create a new ticket.
  *
  * @param array $ticket_info An array of form variables representing all of the
  * data collected by CreateStep1Form, CreateStep2Form, CreateStep3Form, and
  * optionally CreateStep4Form.
  *
  * @return integer The new ticket id.
  */
 public function addTicket($ticket_info)
 {
     global $whups_driver;
     if (!is_array($ticket_info)) {
         throw new Whups_Exception('Invalid arguments');
     }
     $vars = new Horde_Variables($ticket_info);
     $form1 = new Whups_Form_Ticket_CreateStepOne($vars);
     $form2 = new Whups_Form_Ticket_CreateStepTwo($vars);
     $form3 = new Whups_Form_Ticket_CreateStepThree($vars);
     // FIXME: This is an almighty hack, but we can't have form
     // tokens in rpc calls.
     $form1->useToken(false);
     $form2->useToken(false);
     $form3->useToken(false);
     // Complain if we've been given bad parameters.
     if (!$form1->validate($vars, true)) {
         $f1 = var_export($form1->getErrors(), true);
         throw new Whups_Exception("Invalid arguments ({$f1})");
     }
     if (!$form2->validate($vars, true)) {
         $f2 = var_export($form2->getErrors(), true);
         throw new Whups_Exception("Invalid arguments ({$f2})");
     }
     if (!$form3->validate($vars, true)) {
         $f3 = var_export($form3->getErrors(), true);
         throw new Whups_Exception("Invalid arguments ({$f3})");
     }
     $form1->getInfo($vars, $info);
     $form2->getInfo($vars, $info);
     $form3->getInfo($vars, $info);
     // More checks if we're assigning the ticket at create-time.
     if ($GLOBALS['registry']->getAuth() && $whups_driver->isCategory('assigned', $vars->get('state'))) {
         $form4 = new Whups_Form_Ticket_CreateStepFour($vars);
         $form4->useToken(false);
         if (!$form4->validate($vars, true)) {
             throw new Whups_Exception('Invalid arguments (' . var_export($form4->getErrors(), true) . ')');
         }
         $form4->getInfo($vars, $info);
     }
     $ticket = Whups_Ticket::newTicket($info, $GLOBALS['registry']->getAuth());
     return $ticket->getId();
 }