public function getCachedSecurityToken($service, &$securityToken) { if ($this->client->isCacheEnabled()) { $cacheKey = $this->getSecurityTokenCacheKey($service); $isDefined = $this->client->cache->exists($cacheKey); if ($isDefined) { $securityToken = $this->client->cache->get($cacheKey); } return $isDefined; } return false; }
/** * Get all the Operations & corresponding SoapActions for the OrganizationService */ private function getAllOrganizationSoapActions() { /* If it is not cached, update the cache */ if ($this->organizationSoapActions == null) { $this->organizationSoapActions = self::getAllSoapActions($this->client->getOrganizationDOM(), 'OrganizationService'); $this->setCachedSoapActions('organization', $this->organizationSoapActions); } /* Return the cached value */ return $this->organizationSoapActions; }
/** * Send a Delete request to the Dynamics CRM server, and return delete response status * * @return boolean TRUE on successful delete, false on failure */ public function delete() { return $this->client->delete($this); }
/** * Generate a Retrieve Multiple Request * * @ignore */ public static function generateRetrieveMultipleRequest($queryXML, $pagingCookie = null, $limitCount = null, $pageNumber = null) { /* Turn the queryXML into a DOMDocument so we can manipulate it */ $queryDOM = new DOMDocument(); $queryDOM->loadXML($queryXML); $newPage = 1; if ($queryDOM->documentElement->hasAttribute('page')) { $newPage = (int) $queryDOM->documentElement->getAttribute('page'); } if ($pagingCookie !== null) { $newPage = Client::getPageNo($pagingCookie) + 1; $queryDOM->documentElement->setAttribute('paging-cookie', $pagingCookie); } elseif ($pageNumber !== null) { $newPage = $pageNumber; } /* Modify the query that we send: Add the Page number */ $queryDOM->documentElement->setAttribute('page', $newPage); /* Find the current limit, if there is one */ $currentLimit = Client::getMaximumRecords() + 1; if ($queryDOM->documentElement->hasAttribute('count')) { $currentLimit = $queryDOM->documentElement->getAttribute('count'); } /* Determine the preferred limit (passed by argument, or 5000 if not set) */ $preferredLimit = $limitCount == null ? $currentLimit : $limitCount; if ($preferredLimit > Client::getMaximumRecords()) { $preferredLimit = Client::getMaximumRecords(); } /* If the current limit is not set, or is greater than the preferred limit, override it */ if ($currentLimit > $preferredLimit) { /* Modify the query that we send: Change the Count */ $queryDOM->documentElement->setAttribute('count', $preferredLimit); /* Update the Query XML with the new structure */ } $queryXML = $queryDOM->saveXML($queryDOM->documentElement); /* Generate the RetrieveMultipleRequest message */ $retrieveMultipleRequestDOM = new DOMDocument(); $retrieveMultipleNode = $retrieveMultipleRequestDOM->appendChild($retrieveMultipleRequestDOM->createElementNS('http://schemas.microsoft.com/xrm/2011/Contracts/Services', 'RetrieveMultiple')); $queryNode = $retrieveMultipleNode->appendChild($retrieveMultipleRequestDOM->createElement('query')); $queryNode->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'i:type', 'b:FetchExpression'); $queryNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:b', 'http://schemas.microsoft.com/xrm/2011/Contracts'); $queryNode->appendChild($retrieveMultipleRequestDOM->createElement('b:Query', trim(htmlentities($queryXML)))); /* Return the DOMNode */ return $retrieveMultipleNode; }
*/ require_once '../init.php'; /* * Specify whether we retrieve the contact record by its e-mail (emailaddress1) or ID * * NOTICE. For retrieval by e-mail to work, you should first create an entity key for Contact entity * where [emailaddress1] would be a key attribute. * * It is possible to get all entity keys for given entity from its metadata ($entity->metadata()->keys) */ $isRetrievedByEmail = false; if ($argc > 1) { $contactKeyValue = $argv[1]; if (filter_var($contactKeyValue, FILTER_VALIDATE_EMAIL)) { $isRetrievedByEmail = true; } elseif (Client::isGuid($contactKeyValue)) { $isRetrievedByEmail = false; } else { die('Error: invalid Contact ID or e-mail specified.' . PHP_EOL); } } else { die('Error: Contact ID or e-mail not specified.' . PHP_EOL); } $clientOptions = (include 'config.php'); $clientSettings = new Settings($clientOptions); $client = new Client($clientSettings); $metadata = MetadataCollection::instance($client); echo 'Retrieving contact information for ' . ($isRetrievedByEmail ? 'e-mail' : 'ID') . ' ' . $contactKeyValue . PHP_EOL; $contactKey = null; if ($isRetrievedByEmail) { $contactKey = new \AlexaCRM\CRMToolkit\KeyAttributes();