/** * * * * @param string $message * @param integer $level * @return boolean */ protected function _log($message, $level = QUICKBOOKS_LOG_NORMAL) { if ($this->_masking) { // Mask credit card numbers, session tickets, and connection tickets $message = QuickBooks_Utilities::mask($message); } if ($this->_debug) { print $message . QUICKBOOKS_CRLF; } if ($this->_driver) { $this->_driver->log($message, $this->_ticket_session, $level); } return true; }
/** * * * The stdClass object passed as a parameter will have the following members: * - ticket * * @param stdClass $obj * @return QuickBooks_Result_InteractiveDone */ public function interactiveDone($obj) { $this->_driver->log('interactiveDone()', $obj->ticket, QUICKBOOKS_LOG_VERBOSE); if ($this->_driver->authCheck($obj->ticket)) { $user = $this->_driver->authResolve($obj->ticket); $hookdata = array('username' => $user, 'ticket' => $obj->ticket); $hookerr = ''; $this->_callHook($obj->ticket, QUICKBOOKS_HANDLERS_HOOK_INTERACTIVEDONE, null, null, null, null, $hookerr, null, array(), $hookdata); return new QuickBooks_Result_InteractiveDone('Done'); } return new QuickBooks_Result_InteractiveDone(''); }
/** * Call a hook function / object method / static method * * @param QuickBooks_Driver $Driver QuickBooks_Driver instance for logging * @param array $hooks An array of arrays of hooks * @param string $hook The hook to call * @param string $requestID The requestID of the request which caused this hook to be called * @param string $user The username of the QuickBooks user * @param string $ticket The ticket for the session * @param string $err Any errors that occur will be passed back here * @param array $hook_data An array of additional data to be passed to the hook * @param array $callback_config An array of additional callback data * @return boolean */ public static function callHook($Driver, &$hooks, $hook, $requestID, $user, $ticket, &$err, $hook_data, $callback_config = array()) { // There's a bug somewhere that passes a null value to this function... ? if (!is_array($hooks)) { $hooks = array(); } // First, clean up the hooks array foreach ($hooks as $key => $value) { if (!is_array($value)) { $hooks[$key] = array($value); } } // Clean up the hook data foreach (array('requestID' => $requestID, 'user' => $user, 'ticket' => $ticket) as $key => $value) { if (empty($hook_data[$key])) { $hook_data[$key] = $value; } } // Check if the hook is set, if so, call it! if (isset($hooks[$hook])) { // Drop a message in the log if ($Driver) { $Driver->log('Calling hooks for: ' . $hook, $ticket, QUICKBOOKS_LOG_VERBOSE); } // Loop through the hooks foreach ($hooks[$hook] as $callback) { // Determine the type of hook $type = QuickBooks_Callbacks::_type($callback, $Driver, $ticket); if ($Driver) { // Log the callback for debugging // $Driver->log('Calling callback [' . $type . ']: ' . print_r($callback, true), $ticket, QUICKBOOKS_LOG_DEVELOP); } $vars = array($requestID, $user, $hook, &$err, $hook_data, $callback_config); if ($type == QUICKBOOKS_CALLBACKS_TYPE_OBJECT_METHOD) { $object = $callback[0]; $method = $callback[1]; if ($Driver) { $Driver->log('Calling hook instance method: ' . get_class($callback[0]) . '->' . $callback[1], $ticket, QUICKBOOKS_LOG_VERBOSE); } $ret = QuickBooks_Callbacks::_callObjectMethod(array($object, $method), $vars, $err); //$ret = call_user_func_array( array( $object, $method ), array( $requestID, $user, $hook, &$err, $hook_data, $callback_config) ); } else { if ($type == QUICKBOOKS_CALLBACKS_TYPE_FUNCTION) { if ($Driver) { $Driver->log('Calling hook function: ' . $callback, $ticket, QUICKBOOKS_LOG_VERBOSE); } $ret = QuickBooks_Callbacks::_callFunction($callback, $vars, $err); //$ret = $callback($requestID, $user, $hook, $err, $hook_data, $callback_config); // $requestID, $user, $action, $ident, $extra, $err, $xml, $qb_identifier } else { if ($type == QUICKBOOKS_CALLBACKS_TYPE_STATIC_METHOD) { if ($Driver) { $Driver->log('Calling hook static method: ' . $callback, $ticket, QUICKBOOKS_LOG_VERBOSE); } //$tmp = explode('::', $callback); //$class = trim(current($tmp)); //$method = trim(end($tmp)); $ret = QuickBooks_Callbacks::_callStaticMethod($callback, $vars, $err); //$ret = call_user_func_array( array( $class, $method ), array( $requestID, $user, $hook, &$err, $hook_data, $callback_config) ); } else { if ($type == QUICKBOOKS_CALLBACKS_TYPE_HOOK_INSTANCE) { // Just call the ->hook() method if ($Driver) { $Driver->log('Calling hook instance: ' . get_class($callback), $ticket, QUICKBOOKS_LOG_VERBOSE); } $ret = QuickBooks_Callbacks::_callObjectMethod(array($callback, 'hook'), $vars, $err); } else { return false; } } } } // If the hook returns FALSE, then *do not* run all of the other hooks, just return FALSE here if ($ret == false) { return false; } } } return true; }
protected function _log($msg, $lvl = null) { if ($this->_masking) { // Mask credit card numbers, session tickets, and connection tickets $msg = QuickBooks_Utilities::mask($msg); } return $this->_driver->log($msg, $lvl); }