Esempio n. 1
0
 /**
  * 
  * 
  * @param string $method
  * @param string $action
  * @param string $type
  * @param string $qbxml
  * @param array $callbacks
  * @param mixed $uniqueid
  * @param integer $priority
  * @param string $err
  * @param integer $recur
  * @return boolean
  */
 public function handleQBXML($method, $action, $type, $qbxml, $callbacks, $uniqueid, $priority, &$err, $recur = null)
 {
     if (strlen($uniqueid) == 0) {
         $uniqueid = md5(time() . $this->_user . mt_rand());
     }
     // The qbXML requests that get passed to this function are without the
     //	typical qbXML wrapper info, so we need to modify them to make them
     // 	into complete, valid requests.
     $qbxml = $this->_makeValidQBXML($qbxml, $this->_config['qbxml_version'], $this->_config['qbxml_onerror']);
     $extra = array('method' => $method, 'action' => $action, 'type' => $type, 'api' => true, 'uniqueid' => $uniqueid, 'callbacks' => $callbacks, 'options' => $this->_config, 'recur' => $recur);
     //print_r($qbxml);
     if ($recur) {
         return $this->_driver->recurEnqueue($this->_user, $recur, $action, $uniqueid, true, $priority, $extra, $qbxml);
     } else {
         return $this->_driver->queueEnqueue($this->_user, $action, $uniqueid, true, $priority, $extra, $qbxml);
     }
 }
Esempio n. 2
0
 /**
  * Queue up recurring events that are overdue to be run
  * 
  * @param string $ticket
  * @return boolean 
  */
 protected function _handleRecurringEvents($ticket)
 {
     if ($user = $this->_driver->authResolve($ticket)) {
         while ($next = $this->_driver->recurDequeue($user, true)) {
             $this->_driver->log('Dequeued a recurring event, enqueuing!', $ticket, QUICKBOOKS_LOG_VERBOSE);
             $extra = null;
             if ($next['extra']) {
                 $extra = unserialize($next['extra']);
             }
             $hookerr = '';
             $this->_callHook($ticket, QUICKBOOKS_HANDLERS_HOOK_RECURRING, $this->_constructRequestID($next['qb_action'], $next['ident']), $next['qb_action'], $next['ident'], $extra, $hookerr);
             // $ticket, $hook, $requestID, $action, $ident, $extra, &$err, $xml = '', $qb_identifiers = array()
             //print_r($next);
             //exit;
             // (boolean) $next['replace']
             // 							$user, $action, $ident, $replace = true, $priority = 0, $extra = null, $qbxml = null
             $this->_driver->queueEnqueue($user, $next['qb_action'], $next['ident'], true, (int) $next['priority'], $extra, $next['qbxml']);
         }
         return true;
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Accept input from the data source and queue things up 
  * 
  * @param QuickBooks_Driver $Driver
  * @return boolean
  */
 public function input($Driver)
 {
     if ($this->_mode != QUICKBOOKS_TRANSPORT_MODE_INPUT) {
         return false;
     }
     // Clean up magic quotes junk
     $this->_compat();
     $defaults = array('method' => QUICKBOOKS_TRANSPORT_METHOD_ENQUEUE, 'action' => $this->_action, 'ident' => null, 'replace' => true, 'priority' => 0, 'extra' => null, 'qbxml' => null, 'id' => null);
     $data = array_merge($defaults, $_POST);
     if (empty($data['id'])) {
         $data['id'] = QuickBooks_Utilities::generateGUID();
     }
     $data['extra'] = array('__extra' => $data['extra'], '__id' => $data['id'], '__method' => $data['method'], '__replace' => $data['replace'], '__priority' => $data['priority']);
     // They must pass *at least* a valid method *and* either an action, or a qbXML request
     $errno = QUICKBOOKS_TRANSPORT_ERROR_OK;
     $errmsg = null;
     if (!$data['action'] and !$data['qbxml']) {
         $errno = QUICKBOOKS_TRANSPORT_ERROR_MISSING;
         $errmsg = 'You must HTTP POST at least either an "action" parameter or a "qbxml" parameter.';
     } else {
         if (!is_numeric($data['priority'])) {
             $errno = QUICKBOOKS_TRANSPORT_ERROR_VALIDATE;
             $errmsg = 'The value "' . $data['priority'] . '" is invalid for the priority field.';
         }
     }
     if (!$errno) {
         $ok = false;
         switch ($data['method']) {
             case QUICKBOOKS_TRANSPORT_METHOD_ENQUEUE:
                 $ok = $Driver->queueEnqueue($this->_user, $data['action'], $data['ident'], (bool) $data['replace'], (int) $data['priority'], $data['extra'], $data['qbxml']);
                 break;
             case QUICKBOOKS_TRANSPORT_METHOD_EXISTS:
             case QUICKBOOKS_TRANSPORT_METHOD_RECUR:
             default:
                 $errmsg = 'Unimplemented method: ' . $data['method'];
                 break;
         }
     }
     $this->_ack($data, $ok, $data['id'], $errno, $errmsg);
     $this->_done = true;
     return $ok == true;
 }