_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q255900 | Analytics.getUrl | test | public function getUrl()
{
$prepareUrl = new PrepareUrl;
return $prepareUrl->build(
$this->getEndpoint(),
$this->singleParameters,
$this->compoundParametersCollections
);
} | php | {
"resource": ""
} |
q255901 | Analytics.hasMinimumRequiredParameters | test | protected function hasMinimumRequiredParameters()
{
$minimumRequiredParameters = [
'v' => false,
'tid' => false,
'cid' => false,
'uid' => false,
't' => false,
];
foreach ($minimumRequiredParameters as $parameterName => $isParamPresent) {
if (array_key_exists($parameterName, $this->singleParameters)) {
$minimumRequiredParameters[$parameterName] = true;
}
}
if (!$minimumRequiredParameters['cid'] && $minimumRequiredParameters['uid']) {
$minimumRequiredParameters['cid'] = true;
}
if (!$minimumRequiredParameters['uid'] && $minimumRequiredParameters['cid']) {
$minimumRequiredParameters['uid'] = true;
}
return !in_array(false, $minimumRequiredParameters, true);
} | php | {
"resource": ""
} |
q255902 | Analytics.setParameterActionTo | test | protected function setParameterActionTo($parameter, $action)
{
$actionConstant = $this->getParameterClassConstant(
'TheIconic\Tracking\GoogleAnalytics\Parameters\EnhancedEcommerce\\'
. $parameter . 'Action::ACTION_' . strtoupper($action),
$parameter . ' action ' . $action . ' does not exist, check spelling'
);
$function = 'set' . $parameter . 'Action';
$this->$function($actionConstant);
return $this;
} | php | {
"resource": ""
} |
q255903 | Analytics.setParameter | test | protected function setParameter($methodName, array $methodArguments)
{
$parameterClass = substr($methodName, 3);
$fullParameterClass = $this->getFullParameterClass($parameterClass, $methodName);
$parameterIndex = $this->getIndexFromArguments($methodArguments);
/** @var SingleParameter $parameterObject */
$parameterObject = new $fullParameterClass($parameterIndex);
if (!isset($methodArguments[0])) {
throw new \InvalidArgumentException(
'For Analytics object, you must specify a value to be set for ' . $methodName
);
} else {
$parameterObject->setValue($methodArguments[0]);
}
$this->singleParameters[$parameterObject->getName()] = $parameterObject;
return $this;
} | php | {
"resource": ""
} |
q255904 | Analytics.addItem | test | protected function addItem($methodName, array $methodArguments)
{
$parameterClass = substr($methodName, 3);
$fullParameterClass = $this->getFullParameterClass($parameterClass, $methodName);
if (!isset($methodArguments[0])) {
throw new \InvalidArgumentException(
'You must specify a ' . $parameterClass . ' to be add for ' . $methodName
);
} else {
$parameterObject = new $fullParameterClass($methodArguments[0]);
}
$collectionIndex = $this->getIndexFromArguments($methodArguments);
if (isset($this->compoundParametersCollections[$parameterClass . $collectionIndex])) {
$this->compoundParametersCollections[$parameterClass . $collectionIndex]->add($parameterObject);
} else {
$fullParameterCollectionClass = $fullParameterClass . 'Collection';
/** @var CompoundParameterCollection $parameterObjectCollection */
$parameterObjectCollection = new $fullParameterCollectionClass($collectionIndex);
$parameterObjectCollection->add($parameterObject);
$this->compoundParametersCollections[$parameterClass . $collectionIndex] = $parameterObjectCollection;
}
return $this;
} | php | {
"resource": ""
} |
q255905 | Analytics.getParameter | test | protected function getParameter($methodName, array $methodArguments)
{
$parameterClass = substr($methodName, 3);
$fullParameterClass = $this->getFullParameterClass($parameterClass, $methodName);
// Handle index arguments
$parameterIndex = '';
if (isset($methodArguments[0]) && is_numeric($methodArguments[0])) {
$parameterIndex = $methodArguments[0];
}
// Handle compoundParametersCollections
if (isset($this->compoundParametersCollections[$parameterClass . $parameterIndex])) {
// If compoundParametersCollections contains our Objects, return them well-formatted
return $this->compoundParametersCollections[$parameterClass . $parameterIndex]->getReadableItems();
} else {
$fullParameterCollectionClass = $fullParameterClass . 'Collection';
// Test if the class Collection exist
if (class_exists($fullParameterCollectionClass, false)) {
return null;
}
// If not, it's a SingleParameter Object, continue the magic
}
/** @var SingleParameter $parameterObject */
$parameterObject = new $fullParameterClass($parameterIndex);
if (!array_key_exists($parameterObject->getName(), $this->singleParameters)) {
return null;
}
$currentParameterObject = $this->singleParameters[$parameterObject->getName()];
return $currentParameterObject->getValue();
} | php | {
"resource": ""
} |
q255906 | Analytics.getIndexFromArguments | test | protected function getIndexFromArguments($methodArguments)
{
$index = '';
if (isset($methodArguments[1]) && is_numeric($methodArguments[1])) {
$index = $methodArguments[1];
}
return $index;
} | php | {
"resource": ""
} |
q255907 | Analytics.getFullParameterClass | test | protected function getFullParameterClass($parameterClass, $methodName)
{
if (empty($this->availableParameters[$parameterClass])) {
throw new \BadMethodCallException('Method ' . $methodName . ' not defined for Analytics class');
} else {
return '\\TheIconic\\Tracking\\GoogleAnalytics\\Parameters\\' . $this->availableParameters[$parameterClass];
}
} | php | {
"resource": ""
} |
q255908 | HttpClient.post | test | public function post($url, array $options = [])
{
$request = new Request(
'GET',
$url,
['User-Agent' => self::PHP_GA_MEASUREMENT_PROTOCOL_USER_AGENT]
);
$opts = $this->parseOptions($options);
$response = $this->getClient()->sendAsync($request, [
'synchronous' => !$opts['async'],
'timeout' => $opts['timeout'],
'connect_timeout' => $opts['timeout'],
]);
if ($opts['async']) {
self::$promises[] = $response;
} else {
$response = $response->wait();
}
return $this->getAnalyticsResponse($request, $response);
} | php | {
"resource": ""
} |
q255909 | HttpClient.parseOptions | test | private function parseOptions(array $options)
{
$defaultOptions = [
'timeout' => static::REQUEST_TIMEOUT_SECONDS,
'async' => false,
];
$opts = [];
foreach ($defaultOptions as $option => $value) {
$opts[$option] = isset($options[$option]) ? $options[$option] : $defaultOptions[$option];
}
if (!is_int($opts['timeout']) || $opts['timeout'] <= 0) {
throw new \UnexpectedValueException('The timeout must be an integer with a value greater than 0');
}
if (!is_bool($opts['async'])) {
throw new \UnexpectedValueException('The async option must be boolean');
}
return $opts;
} | php | {
"resource": ""
} |
q255910 | CompoundParameterCollection.getReadableItems | test | public function getReadableItems()
{
$readablesItems = [];
foreach ($this->items as $key => $item) {
array_push($readablesItems, $item->getReadableParameters());
}
return $readablesItems;
} | php | {
"resource": ""
} |
q255911 | CreditCard.addSupportedBrand | test | public function addSupportedBrand($name, $expression)
{
$known_brands = array_keys($this->supported_cards);
if (in_array($name, $known_brands)) {
return false;
}
$this->supported_cards[$name] = $expression;
return true;
} | php | {
"resource": ""
} |
q255912 | CreditCard.setYearParameter | test | protected function setYearParameter($key, $value)
{
// normalize year to four digits
if (null === $value || '' === $value) {
$value = null;
} else {
$value = (int) gmdate('Y', gmmktime(0, 0, 0, 1, 1, (int) $value));
}
return $this->setParameter($key, $value);
} | php | {
"resource": ""
} |
q255913 | CreditCard.validate | test | public function validate()
{
$requiredParameters = array(
'number' => 'credit card number',
'expiryMonth' => 'expiration month',
'expiryYear' => 'expiration year'
);
foreach ($requiredParameters as $key => $val) {
if (!$this->getParameter($key)) {
throw new InvalidCreditCardException("The $val is required");
}
}
if ($this->getExpiryDate('Ym') < gmdate('Ym')) {
throw new InvalidCreditCardException('Card has expired');
}
if (!Helper::validateLuhn($this->getNumber())) {
throw new InvalidCreditCardException('Card number is invalid');
}
if (!is_null($this->getNumber()) && !preg_match('/^\d{12,19}$/i', $this->getNumber())) {
throw new InvalidCreditCardException('Card number should have 12 to 19 digits');
}
} | php | {
"resource": ""
} |
q255914 | CreditCard.getNumberMasked | test | public function getNumberMasked($mask = 'X')
{
$maskLength = strlen($this->getNumber()) - 4;
return str_repeat($mask, $maskLength) . $this->getNumberLastFour();
} | php | {
"resource": ""
} |
q255915 | CreditCard.getBrand | test | public function getBrand()
{
foreach ($this->getSupportedBrands() as $brand => $val) {
if (preg_match($val, $this->getNumber())) {
return $brand;
}
}
} | php | {
"resource": ""
} |
q255916 | CreditCard.getTrackByPattern | test | protected function getTrackByPattern($pattern)
{
if ($tracks = $this->getTracks()) {
if (preg_match($pattern, $tracks, $matches) === 1) {
return $matches[0];
}
}
} | php | {
"resource": ""
} |
q255917 | CreditCard.listFirstLastName | test | protected function listFirstLastName($fullName)
{
$names = explode(' ', $fullName, 2);
return [$names[0], isset($names[1]) ? $names[1] : null];
} | php | {
"resource": ""
} |
q255918 | CreditCard.setBillingName | test | public function setBillingName($value)
{
$names = $this->listFirstLastName($value);
$this->setBillingFirstName($names[0]);
$this->setBillingLastName($names[1]);
return $this;
} | php | {
"resource": ""
} |
q255919 | CreditCard.setShippingName | test | public function setShippingName($value)
{
$names = $this->listFirstLastName($value);
$this->setShippingFirstName($names[0]);
$this->setShippingLastName($names[1]);
return $this;
} | php | {
"resource": ""
} |
q255920 | CreditCard.getBirthday | test | public function getBirthday($format = 'Y-m-d')
{
$value = $this->getParameter('birthday');
return $value ? $value->format($format) : null;
} | php | {
"resource": ""
} |
q255921 | CreditCard.setBirthday | test | public function setBirthday($value)
{
if ($value) {
$value = new DateTime($value, new DateTimeZone('UTC'));
} else {
$value = null;
}
return $this->setParameter('birthday', $value);
} | php | {
"resource": ""
} |
q255922 | AbstractRequest.initialize | test | public function initialize(array $parameters = array())
{
if (null !== $this->response) {
throw new RuntimeException('Request cannot be modified after it has been sent!');
}
$this->parameters = new ParameterBag;
Helper::initialize($this, $parameters);
return $this;
} | php | {
"resource": ""
} |
q255923 | AbstractRequest.setParameter | test | protected function setParameter($key, $value)
{
if (null !== $this->response) {
throw new RuntimeException('Request cannot be modified after it has been sent!');
}
return $this->traitSetParameter($key, $value);
} | php | {
"resource": ""
} |
q255924 | AbstractRequest.setCard | test | public function setCard($value)
{
if ($value && !$value instanceof CreditCard) {
$value = new CreditCard($value);
}
return $this->setParameter('card', $value);
} | php | {
"resource": ""
} |
q255925 | AbstractRequest.getAmount | test | public function getAmount()
{
$money = $this->getMoney();
if ($money !== null) {
$moneyFormatter = new DecimalMoneyFormatter($this->getCurrencies());
return $moneyFormatter->format($money);
}
} | php | {
"resource": ""
} |
q255926 | AbstractRequest.setMoney | test | public function setMoney(Money $value)
{
$currency = $value->getCurrency()->getCode();
$this->setCurrency($currency);
return $this->setParameter('amount', $value);
} | php | {
"resource": ""
} |
q255927 | AbstractRequest.setCurrency | test | public function setCurrency($value)
{
if ($value !== null) {
$value = strtoupper($value);
}
return $this->setParameter('currency', $value);
} | php | {
"resource": ""
} |
q255928 | AbstractRequest.getCurrencyNumeric | test | public function getCurrencyNumeric()
{
if (! $this->getCurrency()) {
return null;
}
$currency = new Currency($this->getCurrency());
if ($this->getCurrencies()->contains($currency)) {
return (string) $this->getCurrencies()->numericCodeFor($currency);
}
} | php | {
"resource": ""
} |
q255929 | AbstractRequest.getCurrencyDecimalPlaces | test | public function getCurrencyDecimalPlaces()
{
if ($this->getCurrency()) {
$currency = new Currency($this->getCurrency());
if ($this->getCurrencies()->contains($currency)) {
return $this->getCurrencies()->subunitFor($currency);
}
}
return 2;
} | php | {
"resource": ""
} |
q255930 | AbstractRequest.formatCurrency | test | public function formatCurrency($amount)
{
$money = $this->getMoney((string) $amount);
$formatter = new DecimalMoneyFormatter($this->getCurrencies());
return $formatter->format($money);
} | php | {
"resource": ""
} |
q255931 | ItemBag.replace | test | public function replace(array $items = array())
{
$this->items = array();
foreach ($items as $item) {
$this->add($item);
}
} | php | {
"resource": ""
} |
q255932 | AbstractResponse.validateRedirect | test | protected function validateRedirect()
{
if (!$this instanceof RedirectResponseInterface || !$this->isRedirect()) {
throw new RuntimeException('This response does not support redirection.');
}
if (empty($this->getRedirectUrl())) {
throw new RuntimeException('The given redirectUrl cannot be empty.');
}
if (!in_array($this->getRedirectMethod(), ['GET', 'POST'])) {
throw new RuntimeException('Invalid redirect method "'.$this->getRedirectMethod().'".');
}
} | php | {
"resource": ""
} |
q255933 | Helper.camelCase | test | public static function camelCase($str)
{
$str = self::convertToLowercase($str);
return preg_replace_callback(
'/_([a-z])/',
function ($match) {
return strtoupper($match[1]);
},
$str
);
} | php | {
"resource": ""
} |
q255934 | Helper.validateLuhn | test | public static function validateLuhn($number)
{
$str = '';
foreach (array_reverse(str_split($number)) as $i => $c) {
$str .= $i % 2 ? $c * 2 : $c;
}
return array_sum(str_split($str)) % 10 === 0;
} | php | {
"resource": ""
} |
q255935 | Helper.getGatewayShortName | test | public static function getGatewayShortName($className)
{
if (0 === strpos($className, '\\')) {
$className = substr($className, 1);
}
if (0 === strpos($className, 'Omnipay\\')) {
return trim(str_replace('\\', '_', substr($className, 8, -7)), '_');
}
return '\\'.$className;
} | php | {
"resource": ""
} |
q255936 | Helper.getGatewayClassName | test | public static function getGatewayClassName($shortName)
{
if (0 === strpos($shortName, '\\')) {
return $shortName;
}
// replace underscores with namespace marker, PSR-0 style
$shortName = str_replace('_', '\\', $shortName);
if (false === strpos($shortName, '\\')) {
$shortName .= '\\';
}
return '\\Omnipay\\'.$shortName.'Gateway';
} | php | {
"resource": ""
} |
q255937 | ProxyQuery.getFixedQueryBuilder | test | protected function getFixedQueryBuilder(QueryBuilder $queryBuilder)
{
$queryBuilderId = clone $queryBuilder;
$rootAlias = current($queryBuilderId->getRootAliases());
// step 1 : retrieve the targeted class
$from = $queryBuilderId->getDQLPart('from');
$class = $from[0]->getFrom();
$metadata = $queryBuilderId->getEntityManager()->getMetadataFactory()->getMetadataFor($class);
// step 2 : retrieve identifier columns
$idNames = $metadata->getIdentifierFieldNames();
// step 3 : retrieve the different subjects ids
$selects = [];
$idxSelect = '';
foreach ($idNames as $idName) {
$select = sprintf('%s.%s', $rootAlias, $idName);
// Put the ID select on this array to use it on results QB
$selects[$idName] = $select;
// Use IDENTITY if id is a relation too.
// See: http://doctrine-orm.readthedocs.org/en/latest/reference/dql-doctrine-query-language.html
// Should work only with doctrine/orm: ~2.2
$idSelect = $select;
if ($metadata->hasAssociation($idName)) {
$idSelect = sprintf('IDENTITY(%s) as %s', $idSelect, $idName);
}
$idxSelect .= ('' !== $idxSelect ? ', ' : '').$idSelect;
}
$queryBuilderId->select($idxSelect);
$queryBuilderId->distinct($this->isDistinct());
// for SELECT DISTINCT, ORDER BY expressions must appear in idxSelect list
/* Consider
SELECT DISTINCT x FROM tab ORDER BY y;
For any particular x-value in the table there might be many different y
values. Which one will you use to sort that x-value in the output?
*/
$queryId = $queryBuilderId->getQuery();
$queryId->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [OrderByToSelectWalker::class]);
$results = $queryId->execute([], Query::HYDRATE_ARRAY);
$platform = $queryBuilderId->getEntityManager()->getConnection()->getDatabasePlatform();
$idxMatrix = [];
foreach ($results as $id) {
foreach ($idNames as $idName) {
// Convert ids to database value in case of custom type, if provided.
$fieldType = $metadata->getTypeOfField($idName);
$idxMatrix[$idName][] = $fieldType && Type::hasType($fieldType)
? Type::getType($fieldType)->convertToDatabaseValue($id[$idName], $platform)
: $id[$idName];
}
}
// step 4 : alter the query to match the targeted ids
foreach ($idxMatrix as $idName => $idx) {
if (\count($idx) > 0) {
$idxParamName = sprintf('%s_idx', $idName);
$idxParamName = preg_replace('/[^\w]+/', '_', $idxParamName);
$queryBuilder->andWhere(sprintf('%s IN (:%s)', $selects[$idName], $idxParamName));
$queryBuilder->setParameter($idxParamName, $idx);
$queryBuilder->setMaxResults(null);
$queryBuilder->setFirstResult(null);
}
}
return $queryBuilder;
} | php | {
"resource": ""
} |
q255938 | ModelManager.getParentMetadataForProperty | test | public function getParentMetadataForProperty($baseClass, $propertyFullName)
{
$nameElements = explode('.', $propertyFullName);
$lastPropertyName = array_pop($nameElements);
$class = $baseClass;
$parentAssociationMappings = [];
foreach ($nameElements as $nameElement) {
$metadata = $this->getMetadata($class);
if (isset($metadata->associationMappings[$nameElement])) {
$parentAssociationMappings[] = $metadata->associationMappings[$nameElement];
$class = $metadata->getAssociationTargetClass($nameElement);
continue;
}
break;
}
$properties = \array_slice($nameElements, \count($parentAssociationMappings));
$properties[] = $lastPropertyName;
return [$this->getMetadata($class), implode('.', $properties), $parentAssociationMappings];
} | php | {
"resource": ""
} |
q255939 | DatagridBuilder.getPager | test | protected function getPager($pagerType)
{
switch ($pagerType) {
case Pager::TYPE_DEFAULT:
return new Pager();
case Pager::TYPE_SIMPLE:
return new SimplePager();
default:
throw new \RuntimeException(sprintf('Unknown pager type "%s".', $pagerType));
}
} | php | {
"resource": ""
} |
q255940 | ModelFilter.getParentAlias | test | private function getParentAlias(ProxyQueryInterface $queryBuilder, $alias)
{
$parentAlias = $rootAlias = current($queryBuilder->getRootAliases());
$joins = $queryBuilder->getDQLPart('join');
if (isset($joins[$rootAlias])) {
foreach ($joins[$rootAlias] as $join) {
if ($join->getAlias() === $alias) {
$parts = explode('.', $join->getJoin());
$parentAlias = $parts[0];
break;
}
}
}
return $parentAlias;
} | php | {
"resource": ""
} |
q255941 | QuickBooks_IPP_Service._add | test | protected function _add($Context, $realmID, $resource, $Object)
{
$IPP = $Context->IPP();
switch ($IPP->version())
{
case QuickBooks_IPP_IDS::VERSION_2:
return $this->_add_v2($Context, $realmID, $resource, $Object);
case QuickBooks_IPP_IDS::VERSION_3:
return $this->_add_v3($Context, $realmID, $resource, $Object);
}
} | php | {
"resource": ""
} |
q255942 | QuickBooks_IPP_Service._findById | test | protected function _findById($Context, $realmID, $resource, $IDType, $xml_or_IDType = '', $query = null)
{
$IPP = $Context->IPP();
$flavor = $IPP->flavor();
if (!$xml_or_IDType)
{
if ($flavor == QuickBooks_IPP_IDS::FLAVOR_DESKTOP)
{
$parse = QuickBooks_IPP_IDS::parseIDType($IDType);
$xml_or_IDType = '';
$xml_or_IDType .= '<?xml version="1.0" encoding="UTF-8"?>' . QUICKBOOKS_CRLF;
$xml_or_IDType .= '<' . $resource . 'Query xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.intuit.com/sb/cdm/' . $IPP->version() . '">' . QUICKBOOKS_CRLF;
if ($resource == QuickBooks_IPP_IDS::RESOURCE_CUSTOMER)
{
$xml_or_IDType .= '<CustomFieldEnable>true</CustomFieldEnable>';
}
if ($query)
{
$xml_or_IDType .= $query;
}
$xml_or_IDType .= ' <' . QuickBooks_IPP_IDS::resourceToKeyType($resource) . 'Set>' . QUICKBOOKS_CRLF;
$xml_or_IDType .= ' <Id idDomain="' . $parse['domain'] . '">' . $parse['ID'] . '</Id>' . QUICKBOOKS_CRLF;
$xml_or_IDType .= ' </' . QuickBooks_IPP_IDS::resourceToKeyType($resource) . 'Set>' . QUICKBOOKS_CRLF;
$xml_or_IDType .= '</' . $resource . 'Query>';
}
else if ($flavor == QuickBooks_IPP_IDS::FLAVOR_ONLINE)
{
$xml_or_IDType = $IDType;
}
}
$return = $IPP->IDS($Context, $realmID, $resource, QuickBooks_IPP_IDS::OPTYPE_FINDBYID, $xml_or_IDType);
$this->_setLastRequestResponse($Context->lastRequest(), $Context->lastResponse());
$this->_setLastDebug($Context->lastDebug());
if (count($return))
{
return $return[0];
}
return null;
} | php | {
"resource": ""
} |
q255943 | QuickBooks_Adapter_Client_Php.authenticate | test | public function authenticate($user, $pass)
{
$req = new QuickBooks_Request_Authenticate($user, $pass);
$resp = parent::__soapCall('authenticate', array( $req ));
$tmp = current($resp);
return current($tmp);
} | php | {
"resource": ""
} |
q255944 | QuickBooks_QBXML_Object_Customer.setParentApplicationID | test | public function setParentApplicationID($id)
{
return $this->set('ParentRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_CUSTOMER, QUICKBOOKS_LISTID, $id));
} | php | {
"resource": ""
} |
q255945 | QuickBooks_QBXML_Object_Customer.setCreditCardInfo | test | public function setCreditCardInfo($cardno, $expmonth, $expyear, $name, $address, $postalcode)
{
// should probably do better checking here for failed sets.
$b = FALSE;
$b = $this->set('CreditCardInfo CreditCardNumber', $cardno);
$b = $this->set('CreditCardInfo ExpirationMonth', $expmonth);
$b = $this->set('CreditCardInfo ExpirationYear', $expyear);
$b = $this->set('CreditCardInfo NameOnCard', $name);
$b = $this->set('CreditCardInfo CreditCardAddress', $address);
$b = $this->set('CreditCardInfo CreditCardPostalCode', $postalcode);
return $b;
} | php | {
"resource": ""
} |
q255946 | QuickBooks_QBXML_Object_Customer.getCreditCardInfo | test | public function getCreditCardInfo($part = null, $defaults = array())
{
if (!is_null($part))
{
return $this->get('CreditCardInfo ' . $part);
}
return $this->getArray('CreditCardInfo *', $defaults);
} | php | {
"resource": ""
} |
q255947 | QuickBooks_IPP_Service_Class.add | test | public function add($Context, $realmID, $Object)
{
return parent::_add($Context, $realmID, QuickBooks_IPP_IDS::RESOURCE_CLASS, $Object);
} | php | {
"resource": ""
} |
q255948 | QuickBooks_IPP_Service_Employee.findById | test | public function findById($Context, $realmID, $ID)
{
$xml = null;
return parent::_findById($Context, $realmID, QuickBooks_IPP_IDS::RESOURCE_EMPLOYEE, $ID, null, $xml);
} | php | {
"resource": ""
} |
q255949 | QuickBooks_IPP_OAuth.signature | test | public function signature($method, $keyfile = null)
{
$this->_signature = $method;
$this->_keyfile = $keyfile;
} | php | {
"resource": ""
} |
q255950 | My_Class_Name.handleError500 | test | public function handleError500($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
{
mail('[email protected]',
'QuickBooks error occured!',
'The following error occured: ' . $errnum . ': ' . $errmsg);
// return true; // If you return TRUE, it will continue to process requests
return false; // If you return FALSE, it will stop processing requests
} | php | {
"resource": ""
} |
q255951 | My_Class_Name.hookLoginSuccess | test | public function hookLoginSuccess($requestID, $user, $hook, &$err, $hook_data, $callback_config)
{
if ($this->_dsn)
{
QuickBooks_Utilities::log($this->_dsn, 'This user logged in and the user login hook was called: ' . $user . ', params: ' . print_r($hook_data, true));
return true;
}
return false;
} | php | {
"resource": ""
} |
q255952 | QuickBooks_QBXML_Schema_Object.isRepeatable | test | public function isRepeatable($path)
{
/*
static $paths = array(
'FirstName' => false,
'LastName' => false,
);
*/
$paths = $this->_isRepeatablePaths();
if (isset($paths[$path]))
{
return $paths[$path];
}
return false;
} | php | {
"resource": ""
} |
q255953 | QuickBooks_QBXML_Schema_Object.exists | test | public function exists($path, $case_doesnt_matter = true, $is_end_element = false)
{
$ordered_paths = $this->_reorderPathsPaths();
if (in_array($path, $ordered_paths))
{
return true;
}
else if ($case_doesnt_matter)
{
foreach ($ordered_paths as $ordered_path)
{
if (strtolower($path) == strtolower($ordered_path))
{
return true;
}
}
}
return false;
} | php | {
"resource": ""
} |
q255954 | QuickBooks_QBXML_Schema_Object.reorderPaths | test | public function reorderPaths($unordered_paths, $allow_application_id = true, $allow_application_editsequence = true)
{
/*
static $ordered_paths = array(
0 => 'Name',
1 => 'FirstName',
2 => 'LastName',
);
*/
$ordered_paths = $this->_reorderPathsPaths();
$tmp = array();
foreach ($ordered_paths as $key => $path)
{
if (in_array($path, $unordered_paths))
{
$tmp[$key] = $path;
}
/*else if (substr($path, -6) == 'ListID' and $allow_application_id)
{
// Modify and add: (so that application IDs are supported and in the correct place)
// CustomerRef ListID tags
// modified to:
// CustomerRef APIApplicationID tags
$parent = trim(substr($path, 0, -7));
$apppath = trim($parent . ' ' . QUICKBOOKS_API_APPLICATIONID);
if (in_array($apppath, $unordered_paths))
{
$tmp[$key] = $apppath;
}
}
else if (substr($path, -5) == 'TxnID' and $allow_application_id)
{
$parent = trim(substr($path, 0, -6));
$apppath = $parent . ' ' . QUICKBOOKS_API_APPLICATIONID;
if (in_array($apppath, $unordered_paths))
{
$tmp[$key] = $apppath;
}
}
else if ($path == 'EditSequence' and $allow_application_editsequence)
{
$apppath = QUICKBOOKS_API_APPLICATIONEDITSEQUENCE;
if (in_array($apppath, $unordered_paths))
{
$tmp[$key] = $apppath;
}
}*/
/*else if ($path == QUICKBOOKS_API_APPLICATIONID)
{
print('HERE!');
}*/
}
return array_merge($tmp);
} | php | {
"resource": ""
} |
q255955 | QuickBooks_Callbacks._callFunction | test | static protected function _callFunction($function, &$vars, &$err, $which = null)
{
if (!function_exists($function))
{
$err = 'Callback does not exist: [function] ' . $function . '(...)';
return false;
}
$ret = call_user_func_array($function, $vars);
if (!is_null($which))
{
$err = $vars[$which];
}
return $ret;
} | php | {
"resource": ""
} |
q255956 | QuickBooks_Callbacks._callStaticMethod | test | static protected function _callStaticMethod($class_and_method, &$vars, &$err, $which = null)
{
$tmp = explode('::', $class_and_method);
$class = current($tmp);
$method = next($tmp);
if (is_callable(array( $class, $method)))
{
$ret = call_user_func_array(array( $class, $method ), $vars);
if (!is_null($which))
{
// *** WARNING *** This is a hack for just this _callStaticMethod routine, because the offset doesn't seem to be working correctly for static methods...
//$which = $which - 1;
$err = $vars[$which];
}
return $ret;
}
$err = 'Static method does not exist: ' . $class . '::' . $method . '(...)';
return false;
} | php | {
"resource": ""
} |
q255957 | QuickBooks_IPP_Service_Customer.findByName | test | public function findByName($Context, $realm, $name)
{
$xml = null;
return parent::_findByName($Context, $realm, QuickBooks_IPP_IDS::RESOURCE_CUSTOMER, $name, $xml);
} | php | {
"resource": ""
} |
q255958 | QuickBooks_QBXML_Object_Invoice.setClassApplicationID | test | public function setClassApplicationID($value)
{
return $this->set('ClassRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_CLASS, QUICKBOOKS_LISTID, $value));
} | php | {
"resource": ""
} |
q255959 | QuickBooks_QBXML_Object_Invoice.getBillAddress | test | public function getBillAddress($part = null, $defaults = array())
{
if (!is_null($part))
{
return $this->get('BillAddress ' . $part);
}
return $this->getArray('BillAddress *', $defaults);
} | php | {
"resource": ""
} |
q255960 | QuickBooks_QBXML_Object_Invoice.setShipMethodApplicationID | test | public function setShipMethodApplicationID($value)
{
return $this->set('ShipMethodRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_SHIPMETHOD, QUICKBOOKS_LISTID, $value));
} | php | {
"resource": ""
} |
q255961 | QuickBooks_QBXML_Object_Invoice.setPaymentMethodApplicationID | test | public function setPaymentMethodApplicationID($value)
{
return $this->set('PaymentMethodRef ' . QUICKBOOKS_API_APPLICATIONID, $this->encodeApplicationID(QUICKBOOKS_OBJECT_PAYMENTMETHOD, QUICKBOOKS_LISTID, $value));
} | php | {
"resource": ""
} |
q255962 | QuickBooks_Driver_Sql_Sqlite._generateFieldSchema | test | protected function _generateFieldSchema($name, $def)
{
switch ($def[0])
{
case QUICKBOOKS_DRIVER_SQL_SERIAL:
$sql = $name . ' INTEGER PRIMARY KEY '; // AUTO_INCREMENT
return $sql;
case QUICKBOOKS_DRIVER_SQL_TIMESTAMP:
case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_INSERT_OR_UPDATE:
$sql = $name . ' TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ';
return $sql;
case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_UPDATE:
$sql = $name . ' TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP ';
return $sql;
case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_INSERT:
$sql = $name . ' TIMESTAMP DEFAULT CURRENT_TIMESTAMP ';
return $sql;
case QUICKBOOKS_DRIVER_SQL_BOOLEAN:
$sql = $name . ' tinyint(1) ';
if (isset($def[2]))
{
if (strtolower($def[2]) == 'null')
{
$sql .= ' DEFAULT NULL ';
}
else if ($def[2])
{
$sql .= ' DEFAULT 1 ';
}
else
{
$sql .= ' DEFAULT 0 ';
}
}
return $sql;
case QUICKBOOKS_DRIVER_SQL_INTEGER:
$sql = $name . ' int(10) ';
if (isset($def[2]))
{
if (strtolower($def[2]) == 'null')
{
$sql .= ' DEFAULT NULL ';
}
else
{
$sql .= ' DEFAULT ' . (int) $def[2];
}
}
else
{
$sql .= ' NOT NULL ';
}
return $sql;
default:
return parent::_generateFieldSchema($name, $def);
}
} | php | {
"resource": ""
} |
q255963 | QuickBooks_XML_Node._getChildAtHelper | test | protected function _getChildAtHelper($root, $path)
{
if (false !== strpos($path, ' ') and false === strpos($path, '/'))
{
$path = str_replace(' ', '/', $path);
}
$explode = explode('/', $path);
//$explode = explode(' ', $path);
$current = array_shift($explode);
$next = current($explode);
if ($path == $root->name())
{
return $root;
}
else if ($current == $root->name())
{
$path = implode('/', $explode);
foreach ($root->children() as $child)
{
if ($child->name() == $next)
{
return $this->_getChildAtHelper($child, $path);
}
}
}
return false;
} | php | {
"resource": ""
} |
q255964 | QuickBooks_XML_Node.addChildAt | test | public function addChildAt($path, $node, $create = false)
{
return $this->_addChildAtHelper($this, $path, $node, $create);
} | php | {
"resource": ""
} |
q255965 | QuickBooks_XML_Node.children | test | public function children($pattern = null)
{
if (!is_null($pattern))
{
$list = array();
foreach ($this->_children as $Child)
{
if ($this->_fnmatch($pattern, $Child->name()))
{
$list[] = $Child;
}
}
return $list;
}
return $this->_children;
} | php | {
"resource": ""
} |
q255966 | QuickBooks_XML_Node.removeAttribute | test | public function removeAttribute($attr)
{
if ($this->attributeExists($attr))
{
unset($this->_attributes[$attr]);
return true;
}
return false;
} | php | {
"resource": ""
} |
q255967 | QuickBooks_XML_Node._asXMLHelper | test | public function _asXMLHelper($node, $tabs, $empty, $indent)
{
$xml = '';
if ($node->childCount())
{
$xml .= str_repeat($indent, $tabs) . '<' . $node->name();
foreach ($node->attributes() as $key => $value)
{
// Make sure double-encode is *off*
//$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value, true, false) . '"';
$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value) . '"';
}
$xml .= '>' . "\n";
foreach ($node->children() as $child)
{
$xml .= $this->_asXMLHelper($child, $tabs + 1, $empty, $indent);
}
$xml .= str_repeat($indent, $tabs) . '</' . $node->name() . '>' . "\n";
}
else
{
if ($node->hasAttributes()) // if the node has attributes, we'll build the whole thing no matter what
{
$xml .= str_repeat($indent, $tabs) . '<' . $node->name();
foreach ($node->attributes() as $key => $value)
{
// Double-encode is *off*
//$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value, true, false) . '"';
$xml .= ' ' . $key . '="' . QuickBooks_XML::encode($value) . '"';
}
// Double-encode is *off*
//$xml .= '>' . QuickBooks_XML::encode($node->data(), true, false) . '</' . $node->name() . '>' . "\n";
$xml .= '>' . QuickBooks_XML::encode($node->data()) . '</' . $node->name() . '>' . "\n";
}
else
{
if ($node->data() == '__EMPTY__') // ick, bad hack
{
$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '></' . $node->name() . '>' . "\n";
}
else if ($node->hasData() or $empty == QuickBooks_XML::XML_PRESERVE)
{
// Double-encode is *off*
//$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '>' . QuickBooks_XML::encode($node->data(), true, false) . '</' . $node->name() . '>' . "\n";
$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . '>' . QuickBooks_XML::encode($node->data()) . '</' . $node->name() . '>' . "\n";
}
else if ($empty == QuickBooks_XML::XML_COMPRESS)
{
$xml .= str_repeat($indent, $tabs) . '<' . $node->name() . ' />' . "\n";
}
else if ($empty == QuickBooks_XML::XML_DROP)
{
; // do nothing, drop the empty element
}
}
}
return $xml;
} | php | {
"resource": ""
} |
q255968 | QuickBooks_XML_Node.asArray | test | public function asArray($mode = QuickBooks_XML::ARRAY_NOATTRIBUTES)
{
switch ($mode)
{
case QuickBooks_XML::ARRAY_EXPANDATTRIBUTES:
return $this->_asArrayExpandAttributesHelper($this);
case QuickBooks_XML::ARRAY_BRANCHED:
return $this->_asArrayBranchedHelper($this);
case QuickBooks_XML::ARRAY_PATHS:
$current = '';
$paths = array();
$this->_asArrayPathsHelper($this, $current, $paths);
return $paths;
case QuickBooks_XML::ARRAY_NOATTRIBUTES:
default:
return $this->_asArrayNoAttributesHelper($this);
}
} | php | {
"resource": ""
} |
q255969 | QuickBooks_XML_Node._asArrayPathsHelper | test | protected function _asArrayPathsHelper($node, $current, &$paths)
{
if ($node->hasChildNodes())
{
foreach ($node->children() as $child)
{
$this->_asArrayPathsHelper($child, $current . ' ' . $node->name(), $paths);
}
}
else if ($node->hasData())
{
$paths[trim($current . ' ' . $node->name())] = $node->data();
}
} | php | {
"resource": ""
} |
q255970 | QuickBooks_XML_Node.saveXML | test | public function saveXML($path_or_resource, $mode = 'wb', $todo_for_empty_elements = QuickBooks_XML::XML_COMPRESS)
{
$xml = $this->asXML($todo_for_empty_elements);
if (is_resource($path_or_resource))
{
return fwrite($path_or_resource, $xml);
}
$fp = fopen($path_or_resource, $mode);
$bytes = fwrite($fp, $xml);
fclose($fp);
return $bytes;
} | php | {
"resource": ""
} |
q255971 | QuickBooks_XML_Node.saveJSON | test | public function saveJSON($path_or_resource, $mode = 'wb')
{
$json = $this->_root->asJSON();
if (is_resource($path_or_resource))
{
return fwrite($path_or_resource, $json);
}
$fp = fopen($path_or_resource, $mode);
$bytes = fwrite($fp, $json);
fclose($fp);
return $bytes;
} | php | {
"resource": ""
} |
q255972 | QuickBooks_Cast._castTruncate | test | static protected function _castTruncate($value, $length, $with_abbrevs = true)
{
//$value = QuickBooks_Cast::_castCharset($value);
if (strlen($value) > $length)
{
if ($with_abbrevs)
{
$value = QuickBooks_Cast::_castAbbreviations($value);
}
if (strlen($value) > $length)
{
$value = substr($value, 0, $length);
}
}
// This breaks the UTF8 encoding
//return utf8_encode($value);
// Just return the data
return $value;
} | php | {
"resource": ""
} |
q255973 | QuickBooks_Cast._decodeUTF8 | test | static protected function _decodeUTF8($string)
{
// don't do decoding when there are no 8bit symbols
if (!QuickBooks_Cast::_is8Bit($string, 'utf-8'))
{
return $string;
}
// decode four byte unicode characters
$string = preg_replace_callback("/([\360-\367])([\200-\277])([\200-\277])([\200-\277])/",
function($arr)
{
$val = ((ord($arr[1])-240)*262144+(ord($arr[2])-128)*4096+(ord($arr[3])-128)*64+(ord($arr[4])-128));
return "&#" . $val . ";";
}, $string);
// decode three byte unicode characters
$string = preg_replace_callback("/([\340-\357])([\200-\277])([\200-\277])/",
function($arr)
{
$val = ((ord($arr[1])-224)*4096+(ord($arr[2])-128)*64+(ord($arr[3])-128));
return "&#" . $val . ";";
}, $string);
// decode two byte unicode characters
$string = preg_replace_callback("/([\300-\337])([\200-\277])/",
function($arr)
{
$val = ((ord($arr[1])-192)*64+(ord($arr[2])-128));
return "&#" . $val . ";";
}, $string);
// remove broken unicode
$string = preg_replace("/[\200-\237]|\240|[\241-\377]/", '?', $string);
return $string;
} | php | {
"resource": ""
} |
q255974 | QuickBooks_Utilities.parseDSN | test | static public function parseDSN($dsn, $defaults = array(), $part = null)
{
// Some DSN strings look like this: filesystem:///path/to/file
// parse_url() will not parse this *unless* we provide some sort of hostname (in this case, null)
$dsn = str_replace(':///', '://null/', $dsn);
$defaults = array_merge(array(
'scheme' => '',
'host' => '',
'port' => 0,
'user' => '',
'pass' => '',
'path' => '',
'query' => '',
'fragment' => '',
), $defaults);
$parse = array_merge($defaults, parse_url($dsn));
$parse['user'] = urldecode($parse['user']);
$parse['pass'] = urldecode($parse['pass']);
if (is_null($part))
{
return $parse;
}
else if (isset($parse[$part]))
{
return $parse[$part];
}
return null;
} | php | {
"resource": ""
} |
q255975 | QuickBooks_Utilities.extractRequestID | test | static public function extractRequestID($xml)
{
$look = array(
);
if (false !== ($start = strpos($xml, ' requestID="')) and
false !== ($end = strpos($xml, '"', $start + 12)))
{
return substr($xml, $start + 12, $end - $start - 12);
}
return false;
} | php | {
"resource": ""
} |
q255976 | QuickBooks_Utilities.parseRequestID | test | static public function parseRequestID($requestID, &$action, &$ident)
{
$tmp = explode('|', base64_decode($requestID));
if (count($tmp) == 2)
{
$action = $tmp[0];
$ident = $tmp[1];
return true;
}
$action = null;
$ident = null;
return false;
} | php | {
"resource": ""
} |
q255977 | QuickBooks_Utilities._checkCIDR | test | static protected function _checkCIDR($remoteaddr, $CIDR)
{
$remoteaddr_long = ip2long($remoteaddr);
list ($net, $mask) = split('/', $CIDR);
$ip_net = ip2long($net);
$ip_mask = ~((1 << (32 - $mask)) - 1);
$remoteaddr_net = $remoteaddr_long & $ip_mask;
return $remoteaddr_net == $ip_net;
} | php | {
"resource": ""
} |
q255978 | QuickBooks_Utilities.createUser | test | static public function createUser($dsn, $username, $password, $company_file = null, $wait_before_next_update = null, $min_run_every_n_seconds = null)
{
$driver = QuickBooks_Utilities::driverFactory($dsn);
return $driver->authCreate($username, $password, $company_file, $wait_before_next_update, $min_run_every_n_seconds);
} | php | {
"resource": ""
} |
q255979 | QuickBooks_Utilities.disableUser | test | static public function disableUser($dsn, $username)
{
$driver = QuickBooks_Utilities::driverFactory($dsn);
return $driver->authDisable($username);
} | php | {
"resource": ""
} |
q255980 | QuickBooks_Utilities.generateUniqueHash | test | static public function generateUniqueHash($mixed1, $mixed2 = null, $mixed3 = null, $mixed4 = null, $mixed5 = null)
{
return md5(serialize($mixed1) . serialize($mixed2) . serialize($mixed3) . serialize($mixed4) . serialize($mixed5));
} | php | {
"resource": ""
} |
q255981 | QuickBooks_Utilities.hasQuickBooksID | test | public static function hasQuickBooksID($dsn, $user, $object_type, $app_ID)
{
if (QuickBooks_Utilities::fetchQuickBooksID($dsn, $user, $object_type, $app_ID))
{
return true;
}
return false;
} | php | {
"resource": ""
} |
q255982 | QuickBooks_Utilities.initialize | test | static public function initialize($dsn, $driver_options = array(), $init_options = array())
{
$Driver = QuickBooks_Utilities::driverFactory($dsn, $driver_options);
return $Driver->initialize($init_options);
} | php | {
"resource": ""
} |
q255983 | QuickBooks_Utilities.initialized | test | static public function initialized($dsn, $driver_options = array())
{
$Driver = QuickBooks_Utilities::driverFactory($dsn, $driver_options);
return $Driver->initialized();
} | php | {
"resource": ""
} |
q255984 | QuickBooks_Utilities.listObjects | test | static public function listObjects($filter = null, $return_keys = false, $order_for_mapping = false)
{
static $cache = array();
$crunch = $filter . '[' . $return_keys . '[' . $order_for_mapping;
if (isset($cache[$crunch]))
{
return $cache[$crunch];
}
$constants = array();
foreach (get_defined_constants() as $constant => $value)
{
if (substr($constant, 0, strlen('QUICKBOOKS_OBJECT_')) == 'QUICKBOOKS_OBJECT_' and
substr_count($constant, '_') == 2)
{
if (!$return_keys)
{
$constant = $value;
}
if ($filter)
{
if (QuickBooks_Utilities::fnmatch($filter, $constant))
{
$constants[] = $constant;
}
}
else
{
$constants[] = $constant;
}
}
}
if ($order_for_mapping)
{
// Sort with the very longest values first, to the shortest values last
usort($constants, function($a, $b){ return strlen($a) > strlen($b) ? -1 : 1; });
}
else
{
sort($constants);
}
$cache[$crunch] = $constants;
return $constants;
} | php | {
"resource": ""
} |
q255985 | QuickBooks_Utilities.listActions | test | static public function listActions($filter = null, $return_keys = false)
{
$startswith = array(
'QUICKBOOKS_IMPORT_',
'QUICKBOOKS_QUERY_',
'QUICKBOOKS_ADD_',
'QUICKBOOKS_MOD_',
'QUICKBOOKS_DEL_',
'QUICKBOOKS_VOID_',
);
$constants = array();
//$inter_key = 'QUICKBOOKS_INTERACTIVE_MODE';
//$inter_val = QUICKBOOKS_INTERACTIVE_MODE;
/*
if (is_null($filter))
{
if ($return_keys)
{
$constants[] = $inter_key;
}
else
{
$constants[] = $inter_val;
}
}
*/
/*
else if ($return_keys and QuickBooks_Utilities::fnmatch($filter, $inter_key))
{
$constants[] = $inter_key;
}
else if (!$return_keys and QuickBooks_Utilities::fnmatch($filter, $inter_val))
{
$constants[] = $inter_val;
}
*/
foreach (get_defined_constants() as $constant => $value)
{
foreach ($startswith as $start)
{
if (substr($constant, 0, strlen($start)) == $start)
{
if (!$return_keys)
{
$constant = $value;
}
if (!is_null($filter))
{
if (QuickBooks_Utilities::fnmatch($filter, $constant))
{
$constants[] = $constant;
}
}
else
{
$constants[] = $constant;
}
}
}
}
sort($constants);
return $constants;
} | php | {
"resource": ""
} |
q255986 | QuickBooks_Driver_Sql_Mysqli._escape | test | protected function _escape($str)
{
if (is_array($str))
{
error_log('Param passed to _escape($str) was an array: ' . print_r($str, true));
$str = '';
}
return $this->_conn->real_escape_string($str);
} | php | {
"resource": ""
} |
q255987 | QuickBooks.config | test | public function config()
{
$name = 'CodeIgniter QuickBooks Demo'; // A name for your server (make it whatever you want)
$descrip = 'CodeIgniter QuickBooks Demo'; // A description of your server
$appurl = 'https://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/qbwc'; // This *must* be httpS:// (path to your QuickBooks SOAP server)
$appsupport = $appurl; // This *must* be httpS:// and the domain name must match the domain name above
$username = $this->config->item('quickbooks_user'); // This is the username you stored in the 'quickbooks_user' table by using QuickBooks_Utilities::createUser()
$fileid = QuickBooks_WebConnector_QWC::fileID(); // Just make this up, but make sure it keeps that format
$ownerid = QuickBooks_WebConnector_QWC::ownerID(); // Just make this up, but make sure it keeps that format
$qbtype = QUICKBOOKS_TYPE_QBFS; // You can leave this as-is unless you're using QuickBooks POS
$readonly = false; // No, we want to write data to QuickBooks
$run_every_n_seconds = 600; // Run every 600 seconds (10 minutes)
// Generate the XML file
$QWC = new QuickBooks_WebConnector_QWC($name, $descrip, $appurl, $appsupport, $username, $fileid, $ownerid, $qbtype, $readonly, $run_every_n_seconds);
$xml = $QWC->generate();
// Send as a file download
header('Content-type: text/xml');
//header('Content-Disposition: attachment; filename="my-quickbooks-wc-file.qwc"');
print($xml);
exit;
} | php | {
"resource": ""
} |
q255988 | QuickBooks.qbwc | test | public function qbwc()
{
$user = $this->config->item('quickbooks_user');
$pass = $this->config->item('quickbooks_pass');
// Memory limit
ini_set('memory_limit', $this->config->item('quickbooks_memorylimit'));
// We need to make sure the correct timezone is set, or some PHP installations will complain
if (function_exists('date_default_timezone_set'))
{
// * MAKE SURE YOU SET THIS TO THE CORRECT TIMEZONE! *
// List of valid timezones is here: http://us3.php.net/manual/en/timezones.php
date_default_timezone_set($this->config->item('quickbooks_tz'));
}
// Map QuickBooks actions to handler functions
$map = array(
QUICKBOOKS_ADD_CUSTOMER => array( array( $this, '_addCustomerRequest' ), array( $this, '_addCustomerResponse' ) ),
);
// Catch all errors that QuickBooks throws with this function
$errmap = array(
'*' => array( $this, '_catchallErrors' ),
);
// Call this method whenever the Web Connector connects
$hooks = array(
//QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => array( array( $this, '_loginSuccess' ) ), // Run this function whenever a successful login occurs
);
// An array of callback options
$callback_options = array();
// Logging level
$log_level = $this->config->item('quickbooks_loglevel');
// What SOAP server you're using
//$soapserver = QUICKBOOKS_SOAPSERVER_PHP; // The PHP SOAP extension, see: www.php.net/soap
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN; // A pure-PHP SOAP server (no PHP ext/soap extension required, also makes debugging easier)
$soap_options = array( // See http://www.php.net/soap
);
$handler_options = array(
'deny_concurrent_logins' => false,
'deny_reallyfast_logins' => false,
); // See the comments in the QuickBooks/Server/Handlers.php file
$driver_options = array( // See the comments in the QuickBooks/Driver/<YOUR DRIVER HERE>.php file ( i.e. 'Mysql.php', etc. )
'max_log_history' => 32000, // Limit the number of quickbooks_log entries to 1024
'max_queue_history' => 1024, // Limit the number of *successfully processed* quickbooks_queue entries to 64
);
// Build the database connection string
$dsn = 'mysql://' . $this->db->username . ':' . $this->db->password . '@' . $this->db->hostname . '/' . $this->db->database;
// Check to make sure our database is set up
if (!QuickBooks_Utilities::initialized($dsn))
{
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
// This creates a username and password which is used by the Web Connector to authenticate
QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
// Set up our queue singleton
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);
// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);
} | php | {
"resource": ""
} |
q255989 | QuickBooks._addCustomerRequest | test | public function _addCustomerRequest($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Do something here to load data using your model
//$data = $this->yourmodel->getCustomerData($ID);
// Build the qbXML request from $data
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>ConsoliBYTE, LLC (' . mt_rand() . ')</Name>
<CompanyName>ConsoliBYTE, LLC</CompanyName>
<FirstName>Keith</FirstName>
<LastName>Palmer</LastName>
<BillAddress>
<Addr1>ConsoliBYTE, LLC</Addr1>
<Addr2>134 Stonemill Road</Addr2>
<City>Mansfield</City>
<State>CT</State>
<PostalCode>06268</PostalCode>
<Country>United States</Country>
</BillAddress>
<Phone>860-634-1602</Phone>
<AltPhone>860-429-0021</AltPhone>
<Fax>860-429-5183</Fax>
<Email>[email protected]</Email>
<Contact>Keith Palmer</Contact>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
} | php | {
"resource": ""
} |
q255990 | QuickBooks._addCustomerResponse | test | public function _addCustomerResponse($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
// Do something here to record that the data was added to QuickBooks successfully
return true;
} | php | {
"resource": ""
} |
q255991 | QuickBooks._catchallErrors | test | public function _catchallErrors($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
{
return false;
} | php | {
"resource": ""
} |
q255992 | QuickBooks_Driver.queueProcessing | test | final public function queueProcessing($user)
{
$hookdata = array(
'username' => $user,
);
$hookerr = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_QUEUEPROCESSING, null, $hookerr, $hookdata);
return $this->_queueProcessing($user);
} | php | {
"resource": ""
} |
q255993 | QuickBooks_Driver.recurEnqueue | test | final public function recurEnqueue($user, $run_every, $action, $ident, $replace = true, $priority = 0, $extra = null, $qbxml = null)
{
$hookdata = array(
'username' => $user,
'interval' => $run_every,
'action' => $action,
'ident' => $ident,
'replace' => $replace,
'priority' => $priority,
'extra' => $extra,
'qbxml' => $qbxml,
);
$hookerr = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHRESOLVE, null, $hookerr, $hookdata);
return $this->_recurEnqueue($user, $run_every, $action, $ident, $replace, $priority, $extra, $qbxml);
} | php | {
"resource": ""
} |
q255994 | QuickBooks_Driver.recurDequeue | test | final public function recurDequeue($user, $by_priority = false)
{
$hookdata = array(
'username' => $user,
);
$hookerr = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHRESOLVE, null, $hookerr, $hookdata);
return $this->_recurDequeue($user, $by_priority);
} | php | {
"resource": ""
} |
q255995 | QuickBooks_Driver.queueLeft | test | final public function queueLeft($user, $queued = true)
{
$hookdata = array(
'username' => $user,
'queued' => $queued,
);
$hookerr = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_QUEUELEFT, null, $hookerr, $hookdata);
return $this->_queueLeft($user, $queued);
} | php | {
"resource": ""
} |
q255996 | QuickBooks_Driver.queueReport | test | final public function queueReport($user, $date_from, $date_to, $offset = 0, $limit = null)
{
$offset = max(0, (int) $offset);
$limit = min(999999999, (int) $limit);
$hookdata = array(
'offset' => $offset,
'limit' => $limit,
'from' => $date_from,
'to' => $date_to,
);
$hookerr = '';
$this->_callHook(QuickBooks_Driver::HOOK_QUEUEREPORT, null, $hookerr, $hookdata);
return $this->_queueReport($user, $date_from, $date_to, $offset, $limit);
} | php | {
"resource": ""
} |
q255997 | QuickBooks_Driver.queueProcessed | test | final public function queueProcessed($ticket)
{
$hookdata = array();
$hookerr = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_QUEUEPROCESSED, $ticket, $hookerr, $hookdata);
return $this->_queueProcessed($ticket);
} | php | {
"resource": ""
} |
q255998 | QuickBooks_Driver.errorLog | test | final public function errorLog($ticket, $errno, $errstr)
{
$hookdata = array(
'errno' => $errno,
'errstr' => $errstr,
);
$hookerr = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHRESOLVE, $ticket, $hookerr, array());
return $this->_errorLog($ticket, $errno, $errstr);
} | php | {
"resource": ""
} |
q255999 | QuickBooks_Driver.errorLast | test | final public function errorLast($ticket)
{
$hookerr = '';
$this->_callHook(QUICKBOOKS_DRIVER_HOOK_AUTHRESOLVE, $ticket, $hookerr, array());
return $this->_errorLast($ticket);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.