From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/library/Zend/Gdata/Gapps/EmailListEntry.php | 214 +++++++++ zend/library/Zend/Gdata/Gapps/EmailListFeed.php | 53 +++ zend/library/Zend/Gdata/Gapps/EmailListQuery.php | 187 ++++++++ .../Zend/Gdata/Gapps/EmailListRecipientEntry.php | 146 +++++++ .../Zend/Gdata/Gapps/EmailListRecipientFeed.php | 53 +++ .../Zend/Gdata/Gapps/EmailListRecipientQuery.php | 153 +++++++ zend/library/Zend/Gdata/Gapps/Error.php | 233 ++++++++++ .../Zend/Gdata/Gapps/Extension/EmailList.php | 144 ++++++ zend/library/Zend/Gdata/Gapps/Extension/Login.php | 485 +++++++++++++++++++++ zend/library/Zend/Gdata/Gapps/Extension/Name.php | 181 ++++++++ .../Zend/Gdata/Gapps/Extension/Nickname.php | 142 ++++++ .../Zend/Gdata/Gapps/Extension/Property.php | 179 ++++++++ zend/library/Zend/Gdata/Gapps/Extension/Quota.php | 142 ++++++ zend/library/Zend/Gdata/Gapps/GroupEntry.php | 158 +++++++ zend/library/Zend/Gdata/Gapps/GroupFeed.php | 53 +++ zend/library/Zend/Gdata/Gapps/GroupQuery.php | 226 ++++++++++ zend/library/Zend/Gdata/Gapps/MemberEntry.php | 159 +++++++ zend/library/Zend/Gdata/Gapps/MemberFeed.php | 53 +++ zend/library/Zend/Gdata/Gapps/MemberQuery.php | 194 +++++++++ zend/library/Zend/Gdata/Gapps/NicknameEntry.php | 189 ++++++++ zend/library/Zend/Gdata/Gapps/NicknameFeed.php | 53 +++ zend/library/Zend/Gdata/Gapps/NicknameQuery.php | 186 ++++++++ zend/library/Zend/Gdata/Gapps/OwnerEntry.php | 158 +++++++ zend/library/Zend/Gdata/Gapps/OwnerFeed.php | 53 +++ zend/library/Zend/Gdata/Gapps/OwnerQuery.php | 147 +++++++ zend/library/Zend/Gdata/Gapps/Query.php | 123 ++++++ zend/library/Zend/Gdata/Gapps/ServiceException.php | 208 +++++++++ zend/library/Zend/Gdata/Gapps/UserEntry.php | 295 +++++++++++++ zend/library/Zend/Gdata/Gapps/UserFeed.php | 53 +++ zend/library/Zend/Gdata/Gapps/UserQuery.php | 147 +++++++ 30 files changed, 4767 insertions(+) create mode 100644 zend/library/Zend/Gdata/Gapps/EmailListEntry.php create mode 100644 zend/library/Zend/Gdata/Gapps/EmailListFeed.php create mode 100644 zend/library/Zend/Gdata/Gapps/EmailListQuery.php create mode 100644 zend/library/Zend/Gdata/Gapps/EmailListRecipientEntry.php create mode 100644 zend/library/Zend/Gdata/Gapps/EmailListRecipientFeed.php create mode 100644 zend/library/Zend/Gdata/Gapps/EmailListRecipientQuery.php create mode 100644 zend/library/Zend/Gdata/Gapps/Error.php create mode 100644 zend/library/Zend/Gdata/Gapps/Extension/EmailList.php create mode 100644 zend/library/Zend/Gdata/Gapps/Extension/Login.php create mode 100644 zend/library/Zend/Gdata/Gapps/Extension/Name.php create mode 100644 zend/library/Zend/Gdata/Gapps/Extension/Nickname.php create mode 100644 zend/library/Zend/Gdata/Gapps/Extension/Property.php create mode 100644 zend/library/Zend/Gdata/Gapps/Extension/Quota.php create mode 100644 zend/library/Zend/Gdata/Gapps/GroupEntry.php create mode 100644 zend/library/Zend/Gdata/Gapps/GroupFeed.php create mode 100644 zend/library/Zend/Gdata/Gapps/GroupQuery.php create mode 100644 zend/library/Zend/Gdata/Gapps/MemberEntry.php create mode 100644 zend/library/Zend/Gdata/Gapps/MemberFeed.php create mode 100644 zend/library/Zend/Gdata/Gapps/MemberQuery.php create mode 100644 zend/library/Zend/Gdata/Gapps/NicknameEntry.php create mode 100644 zend/library/Zend/Gdata/Gapps/NicknameFeed.php create mode 100644 zend/library/Zend/Gdata/Gapps/NicknameQuery.php create mode 100644 zend/library/Zend/Gdata/Gapps/OwnerEntry.php create mode 100644 zend/library/Zend/Gdata/Gapps/OwnerFeed.php create mode 100644 zend/library/Zend/Gdata/Gapps/OwnerQuery.php create mode 100644 zend/library/Zend/Gdata/Gapps/Query.php create mode 100644 zend/library/Zend/Gdata/Gapps/ServiceException.php create mode 100644 zend/library/Zend/Gdata/Gapps/UserEntry.php create mode 100644 zend/library/Zend/Gdata/Gapps/UserFeed.php create mode 100644 zend/library/Zend/Gdata/Gapps/UserQuery.php (limited to 'zend/library/Zend/Gdata/Gapps') diff --git a/zend/library/Zend/Gdata/Gapps/EmailListEntry.php b/zend/library/Zend/Gdata/Gapps/EmailListEntry.php new file mode 100644 index 0000000..b31e43f --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/EmailListEntry.php @@ -0,0 +1,214 @@ + in the Google Data protocol. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Gapps + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Gdata_Gapps_EmailListEntry extends Zend_Gdata_Entry +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_EmailListEntry'; + + /** + * child element containing general information about + * this email list. + * + * @var Zend_Gdata_Gapps_Extension_EmailList + */ + protected $_emailList = null; + + /** + * element containing information about other feeds + * relevant to this entry. + * + * @var Zend_Gdata_Extension_FeedLink + */ + protected $_feedLink = array(); + + /** + * Create a new instance. + * + * @param DOMElement $element (optional) DOMElement from which this + * object should be constructed. + */ + public function __construct($element = null) + { + $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_emailList !== null) { + $element->appendChild($this->_emailList->getDOM($element->ownerDocument)); + } + foreach ($this->_feedLink as $feedLink) { + $element->appendChild($feedLink->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them as members of this entry based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + + switch ($absoluteNodeName) { + case $this->lookupNamespace('apps') . ':' . 'emailList'; + $emailList = new Zend_Gdata_Gapps_Extension_EmailList(); + $emailList->transferFromDOM($child); + $this->_emailList = $emailList; + break; + case $this->lookupNamespace('gd') . ':' . 'feedLink'; + $feedLink = new Zend_Gdata_Extension_FeedLink(); + $feedLink->transferFromDOM($child); + $this->_feedLink[] = $feedLink; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Retrieve the email list property for this entry. + * + * @see setEmailList + * @return Zend_Gdata_Gapps_Extension_EmailList The requested object + * or null if not set. + */ + public function getEmailList() + { + return $this->_emailList; + } + + /** + * Set the email list property for this entry. This property contains + * information such as the name of this email list. + * + * This corresponds to the property in the Google Data + * protocol. + * + * @param Zend_Gdata_Gapps_Extension_EmailList $value The desired value + * this element, or null to unset. + * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface + */ + public function setEmailList($value) + { + $this->_emailList = $value; + return $this; + } + + /** + * Get the feed link property for this entry. + * + * @see setFeedLink + * @param string $rel (optional) The rel value of the link to be found. + * If null, the array of links is returned. + * @return mixed If $rel is specified, a Zend_Gdata_Extension_FeedLink + * object corresponding to the requested rel value is returned + * if found, or null if the requested value is not found. If + * $rel is null or not specified, an array of all available + * feed links for this entry is returned, or null if no feed + * links are set. + */ + public function getFeedLink($rel = null) + { + if ($rel == null) { + return $this->_feedLink; + } else { + foreach ($this->_feedLink as $feedLink) { + if ($feedLink->rel == $rel) { + return $feedLink; + } + } + return null; + } + } + + /** + * Set the feed link property for this entry. Feed links provide + * information about other feeds associated with this entry. + * + * This corresponds to the property in the Google Data + * protocol. + * + * @param array $value A collection of Zend_Gdata_Gapps_Extension_FeedLink + * instances representing all feed links for this entry, or + * null to unset. + * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface + */ + public function setFeedLink($value) + { + $this->_feedLink = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/EmailListFeed.php b/zend/library/Zend/Gdata/Gapps/EmailListFeed.php new file mode 100644 index 0000000..92fde8b --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/EmailListFeed.php @@ -0,0 +1,53 @@ +setEmailListName($emailListName); + $this->setRecipient($recipient); + $this->setStartEmailListName($startEmailListName); + } + + /** + * Set the email list name to query for. When set, only lists with a name + * matching this value will be returned in search results. Set to + * null to disable filtering by list name. + * + * @param string $value The email list name to filter search results by, + * or null to disable. + */ + public function setEmailListName($value) + { + $this->_emailListName = $value; + } + + /** + * Get the email list name to query for. If no name is set, null will be + * returned. + * + * @see setEmailListName + * @return string The email list name to filter search results by, or null + * if disabled. + */ + public function getEmailListName() + { + return $this->_emailListName; + } + + /** + * Set the recipient to query for. When set, only subscribers with an + * email address matching this value will be returned in search results. + * Set to null to disable filtering by username. + * + * @param string $value The recipient email address to filter search + * results by, or null to disable. + */ + public function setRecipient($value) + { + if ($value !== null) { + $this->_params['recipient'] = $value; + } + else { + unset($this->_params['recipient']); + } + } + + /** + * Get the recipient email address to query for. If no recipient is set, + * null will be returned. + * + * @see setRecipient + * @return string The recipient email address to filter search results by, + * or null if disabled. + */ + public function getRecipient() + { + if (array_key_exists('recipient', $this->_params)) { + return $this->_params['recipient']; + } else { + return null; + } + } + + /** + * Set the first email list which should be displayed when retrieving + * a list of email lists. + * + * @param string $value The first email list to be returned, or null to + * disable. + */ + public function setStartEmailListName($value) + { + if ($value !== null) { + $this->_params['startEmailListName'] = $value; + } else { + unset($this->_params['startEmailListName']); + } + } + + /** + * Get the first email list which should be displayed when retrieving + * a list of email lists. + * + * @return string The first email list to be returned, or null to + * disable. + */ + public function getStartEmailListName() + { + if (array_key_exists('startEmailListName', $this->_params)) { + return $this->_params['startEmailListName']; + } else { + return null; + } + } + + /** + * Returns the URL generated for this query, based on it's current + * parameters. + * + * @return string A URL generated based on the state of this query. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function getQueryUrl() + { + + $uri = $this->getBaseUrl(); + $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH; + if ($this->_emailListName !== null) { + $uri .= '/' . $this->_emailListName; + } + $uri .= $this->getQueryString(); + return $uri; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/EmailListRecipientEntry.php b/zend/library/Zend/Gdata/Gapps/EmailListRecipientEntry.php new file mode 100644 index 0000000..961afd0 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/EmailListRecipientEntry.php @@ -0,0 +1,146 @@ + in the Google Data protocol. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Gapps + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Gdata_Gapps_EmailListRecipientEntry extends Zend_Gdata_Entry +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_EmailListRecipientEntry'; + + /** + * element used to store the email address of the current + * recipient. Only the email property of this element should be + * populated. + * + * @var Zend_Gdata_Extension_Who + */ + protected $_who = null; + + /** + * Create a new instance. + * + * @param DOMElement $element (optional) DOMElement from which this + * object should be constructed. + */ + public function __construct($element = null) + { + $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_who !== null) { + $element->appendChild($this->_who->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them as members of this entry based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + + switch ($absoluteNodeName) { + case $this->lookupNamespace('gd') . ':' . 'who'; + $who = new Zend_Gdata_Extension_Who(); + $who->transferFromDOM($child); + $this->_who = $who; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Get the value of the who property for this object. + * + * @see setWho + * @return Zend_Gdata_Extension_Who The requested object. + */ + public function getWho() + { + return $this->_who; + } + + /** + * Set the value of the who property for this object. This property + * is used to store the email address of the current recipient. + * + * @param Zend_Gdata_Extension_Who $value The desired value for this + * instance's who property. + * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface. + */ + public function setWho($value) + { + $this->_who = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/EmailListRecipientFeed.php b/zend/library/Zend/Gdata/Gapps/EmailListRecipientFeed.php new file mode 100644 index 0000000..8f17984 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/EmailListRecipientFeed.php @@ -0,0 +1,53 @@ +setEmailListName($emailListName); + $this->setStartRecipient($startRecipient); + } + + /** + * Set the email list name to query for. When set, only lists with a name + * matching this value will be returned in search results. Set to + * null to disable filtering by list name. + * + * @param string $value The email list name to filter search results by, + * or null to disable. + */ + public function setEmailListName($value) + { + $this->_emailListName = $value; + } + + /** + * Get the email list name to query for. If no name is set, null will be + * returned. + * + * @param string $value The email list name to filter search results by, + * or null if disabled. + */ + public function getEmailListName() + { + return $this->_emailListName; + } + + /** + * Set the first recipient which should be displayed when retrieving + * a list of email list recipients. + * + * @param string $value The first recipient to be returned, or null to + * disable. + */ + public function setStartRecipient($value) + { + if ($value !== null) { + $this->_params['startRecipient'] = $value; + } else { + unset($this->_params['startRecipient']); + } + } + + /** + * Get the first recipient which should be displayed when retrieving + * a list of email list recipients. + * + * @return string The first recipient to be returned, or null if + * disabled. + */ + public function getStartRecipient() + { + if (array_key_exists('startRecipient', $this->_params)) { + return $this->_params['startRecipient']; + } else { + return null; + } + } + + /** + * Returns the URL generated for this query, based on it's current + * parameters. + * + * @return string A URL generated based on the state of this query. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function getQueryUrl() + { + + $uri = $this->getBaseUrl(); + $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_PATH; + if ($this->_emailListName !== null) { + $uri .= '/' . $this->_emailListName; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'EmailListName must not be null'); + } + $uri .= Zend_Gdata_Gapps::APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/'; + $uri .= $this->getQueryString(); + return $uri; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/Error.php b/zend/library/Zend/Gdata/Gapps/Error.php new file mode 100644 index 0000000..7a7a73f --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Error.php @@ -0,0 +1,233 @@ +_errorCode = $errorCode; + $this->_reason = $reason; + $this->_invalidInput = $invalidInput; + } + + /** + * Set the error code for this exception. For more information about + * error codes, see getErrorCode. + * + * @see getErrorCode + * @param integer $value The new value for the error code. + */ + public function setErrorCode($value) { + $this->_errorCode = $value; + } + + /** + * Get the error code for this exception. Currently valid values are + * available as constants within this class. These values are: + * + * UNKNOWN_ERROR (1000) + * USER_DELETED_RECENTLY (1100) + * USER_SUSPENDED (1101) + * DOMAIN_USER_LIMIT_EXCEEDED (1200) + * DOMAIN_ALIAS_LIMIT_EXCEEDED (1201) + * DOMAIN_SUSPENDED (1202) + * DOMAIN_FEATURE_UNAVAILABLE (1203) + * ENTITY_EXISTS (1300) + * ENTITY_DOES_NOT_EXIST (1301) + * ENTITY_NAME_IS_RESERVED (1302) + * ENTITY_NAME_NOT_VALID (1303) + * INVALID_GIVEN_NAME (1400) + * INVALID_FAMILY_NAME (1401) + * INVALID_PASSWORD (1402) + * INVALID_USERNAME (1403) + * INVALID_HASH_FUNCTION_NAME (1404) + * INVALID_HASH_DIGEST_LENGTH (1405) + * INVALID_EMAIL_ADDRESS (1406) + * INVALID_QUERY_PARAMETER_VALUE (1407) + * TOO_MANY_RECIPIENTS_ON_EMAIL_LIST (1500) + * + * Numbers in parenthesis indicate the actual integer value of the + * constant. This list should not be treated as exhaustive, as additional + * error codes may be added at any time. + * + * For more information about these codes and their meaning, please + * see Appendix D of the Google Apps Provisioning API Reference. + * + * @link http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_d Google Apps Provisioning API Reference: Appendix D - Gdata Error Codes + * @see setErrorCode + * @return integer The error code returned by the Google Apps server. + */ + public function getErrorCode() { + return $this->_errorCode; + } + + /** + * Set human-readable text describing the reason this exception occurred. + * + * @see getReason + * @param string $value The reason this exception occurred. + */ + public function setReason($value) { + $this->_reason = $value; + } + + /** + * Get human-readable text describing the reason this exception occurred. + * + * @see setReason + * @return string The reason this exception occurred. + */ + public function getReason() { + return $this->_reason; + } + + /** + * Set the invalid input which caused this exception. + * + * @see getInvalidInput + * @param string $value The invalid input that triggered this exception. + */ + public function setInvalidInput($value) { + $this->_invalidInput = $value; + } + + /** + * Set the invalid input which caused this exception. + * + * @see setInvalidInput + * @return string The reason this exception occurred. + */ + public function getInvalidInput() { + return $this->_invalidInput; + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_errorCode !== null) { + $element->setAttribute('errorCode', $this->_errorCode); + } + if ($this->_reason !== null) { + $element->setAttribute('reason', $this->_reason); + } + if ($this->_invalidInput !== null) { + $element->setAttribute('invalidInput', $this->_invalidInput); + } + return $element; + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + */ + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'errorCode': + $this->_errorCode = $attribute->nodeValue; + break; + case 'reason': + $this->_reason = $attribute->nodeValue; + break; + case 'invalidInput': + $this->_invalidInput = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Get a human readable version of this exception. + * + * @return string + */ + public function __toString() { + return "Error " . $this->getErrorCode() . ": " . $this->getReason() . + "\n\tInvalid Input: \"" . $this->getInvalidInput() . "\""; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/Extension/EmailList.php b/zend/library/Zend/Gdata/Gapps/Extension/EmailList.php new file mode 100644 index 0000000..0fa1bdf --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Extension/EmailList.php @@ -0,0 +1,144 @@ +registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct(); + $this->_name = $name; + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_name !== null) { + $element->setAttribute('name', $this->_name); + } + return $element; + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + */ + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'name': + $this->_name = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Get the value for this element's name attribute. + * + * @see setName + * @return string The requested attribute. + */ + public function getName() + { + return $this->_name; + } + + /** + * Set the value for this element's name attribute. This is the unique + * name which will be used to identify this email list within this + * domain, and will be used to form this email list's email address. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_EmailList The element being modified. + */ + public function setName($value) + { + $this->_name = $value; + return $this; + } + + /** + * Magic toString method allows using this directly via echo + * Works best in PHP >= 4.2.0 + * + * @return string + */ + public function __toString() + { + return $this->getName(); + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/Extension/Login.php b/zend/library/Zend/Gdata/Gapps/Extension/Login.php new file mode 100644 index 0000000..f958581 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Extension/Login.php @@ -0,0 +1,485 @@ +registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct(); + $this->_username = $username; + $this->_password = $password; + $this->_hashFunctionName = $hashFunctionName; + $this->_admin = $admin; + $this->_agreedToTerms = $agreedToTerms; + $this->_suspended = $suspended; + $this->_changePasswordAtNextLogin = $changePasswordAtNextLogin; + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_username !== null) { + $element->setAttribute('userName', $this->_username); + } + if ($this->_password !== null) { + $element->setAttribute('password', $this->_password); + } + if ($this->_hashFunctionName !== null) { + $element->setAttribute('hashFunctionName', $this->_hashFunctionName); + } + if ($this->_admin !== null) { + $element->setAttribute('admin', ($this->_admin ? "true" : "false")); + } + if ($this->_agreedToTerms !== null) { + $element->setAttribute('agreedToTerms', ($this->_agreedToTerms ? "true" : "false")); + } + if ($this->_suspended !== null) { + $element->setAttribute('suspended', ($this->_suspended ? "true" : "false")); + } + if ($this->_changePasswordAtNextLogin !== null) { + $element->setAttribute('changePasswordAtNextLogin', ($this->_changePasswordAtNextLogin ? "true" : "false")); + } + + return $element; + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + * @throws Zend_Gdata_App_InvalidArgumentException + */ + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'userName': + $this->_username = $attribute->nodeValue; + break; + case 'password': + $this->_password = $attribute->nodeValue; + break; + case 'hashFunctionName': + $this->_hashFunctionName = $attribute->nodeValue; + break; + case 'admin': + if ($attribute->nodeValue == "true") { + $this->_admin = true; + } + else if ($attribute->nodeValue == "false") { + $this->_admin = false; + } + else { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#admin."); + } + break; + case 'agreedToTerms': + if ($attribute->nodeValue == "true") { + $this->_agreedToTerms = true; + } + else if ($attribute->nodeValue == "false") { + $this->_agreedToTerms = false; + } + else { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#agreedToTerms."); + } + break; + case 'suspended': + if ($attribute->nodeValue == "true") { + $this->_suspended = true; + } + else if ($attribute->nodeValue == "false") { + $this->_suspended = false; + } + else { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#suspended."); + } + break; + case 'changePasswordAtNextLogin': + if ($attribute->nodeValue == "true") { + $this->_changePasswordAtNextLogin = true; + } + else if ($attribute->nodeValue == "false") { + $this->_changePasswordAtNextLogin = false; + } + else { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for apps:login#changePasswordAtNextLogin."); + } + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Get the value for this element's username attribute. + * + * @see setUsername + * @return string The attribute being modified. + */ + public function getUsername() + { + return $this->_username; + } + + /** + * Set the value for this element's username attribute. This string + * is used to uniquely identify the user in this domian and is used + * to form this user's email address. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. + */ + public function setUsername($value) + { + $this->_username = $value; + return $this; + } + + /** + * Get the value for this element's password attribute. + * + * @see setPassword + * @return string The requested attribute. + */ + public function getPassword() + { + return $this->_password; + } + + /** + * Set the value for this element's password attribute. As of this + * writing, this can be either be provided as plaintext or hashed using + * the SHA-1 algorithm for protection. If using a hash function, + * this must be indicated by calling setHashFunctionName(). + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. + */ + public function setPassword($value) + { + $this->_password = $value; + return $this; + } + + /** + * Get the value for this element's hashFunctionName attribute. + * + * @see setHashFunctionName + * @return string The requested attribute. + */ + public function getHashFunctionName() + { + return $this->_hashFunctionName; + } + + /** + * Set the value for this element's hashFunctionName attribute. This + * indicates whether the password supplied with setPassword() is in + * plaintext or has had a hash function applied to it. If null, + * plaintext is assumed. As of this writing, the only valid hash + * function is 'SHA-1'. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. + */ + public function setHashFunctionName($value) + { + $this->_hashFunctionName = $value; + return $this; + } + + /** + * Get the value for this element's admin attribute. + * + * @see setAdmin + * @return boolean The requested attribute. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function getAdmin() + { + if (!(is_bool($this->_admin))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for admin.'); + } + return $this->_admin; + } + + /** + * Set the value for this element's admin attribute. This indicates + * whether this user is an administrator for this domain. + * + * @param boolean $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setAdmin($value) + { + if (!(is_bool($value))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); + } + $this->_admin = $value; + return $this; + } + + /** + * Get the value for this element's agreedToTerms attribute. + * + * @see setAgreedToTerms + * @return boolean The requested attribute. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function getAgreedToTerms() + { + if (!(is_bool($this->_agreedToTerms))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for agreedToTerms.'); + } + return $this->_agreedToTerms; + } + + /** + * Set the value for this element's agreedToTerms attribute. This + * indicates whether this user has agreed to the terms of service. + * + * @param boolean $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setAgreedToTerms($value) + { + if (!(is_bool($value))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); + } + $this->_agreedToTerms = $value; + return $this; + } + + /** + * Get the value for this element's suspended attribute. + * + * @see setSuspended + * @return boolean The requested attribute. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function getSuspended() + { + if (!(is_bool($this->_suspended))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for suspended.'); + } + return $this->_suspended; + } + + /** + * Set the value for this element's suspended attribute. If true, the + * user will not be able to login to this domain until unsuspended. + * + * @param boolean $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setSuspended($value) + { + if (!(is_bool($value))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); + } + $this->_suspended = $value; + return $this; + } + + /** + * Get the value for this element's changePasswordAtNextLogin attribute. + * + * @see setChangePasswordAtNextLogin + * @return boolean The requested attribute. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function getChangePasswordAtNextLogin() + { + if (!(is_bool($this->_changePasswordAtNextLogin))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for changePasswordAtNextLogin.'); + } + return $this->_changePasswordAtNextLogin; + } + + /** + * Set the value for this element's changePasswordAtNextLogin attribute. + * If true, the user will be forced to set a new password the next + * time they login. + * + * @param boolean $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Login Provides a fluent interface. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setChangePasswordAtNextLogin($value) + { + if (!(is_bool($value))) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException('Expected boolean for $value.'); + } + $this->_changePasswordAtNextLogin = $value; + return $this; + } + + /** + * Magic toString method allows using this directly via echo + * Works best in PHP >= 4.2.0 + */ + public function __toString() + { + return "Username: " . $this->getUsername() . + "\nPassword: " . (($this->getPassword() === null) ? "NOT SET" : "SET") . + "\nPassword Hash Function: " . $this->getHashFunctionName() . + "\nAdministrator: " . ($this->getAdmin() ? "Yes" : "No") . + "\nAgreed To Terms: " . ($this->getAgreedToTerms() ? "Yes" : "No") . + "\nSuspended: " . ($this->getSuspended() ? "Yes" : "No"); + } +} diff --git a/zend/library/Zend/Gdata/Gapps/Extension/Name.php b/zend/library/Zend/Gdata/Gapps/Extension/Name.php new file mode 100644 index 0000000..54a17ff --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Extension/Name.php @@ -0,0 +1,181 @@ +registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct(); + $this->_familyName = $familyName; + $this->_givenName = $givenName; + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_familyName !== null) { + $element->setAttribute('familyName', $this->_familyName); + } + if ($this->_givenName !== null) { + $element->setAttribute('givenName', $this->_givenName); + } + return $element; + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + */ + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'familyName': + $this->_familyName = $attribute->nodeValue; + break; + case 'givenName': + $this->_givenName = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Get the value for this element's familyName attribute. + * + * @see setFamilyName + * @return string The requested attribute. + */ + public function getFamilyName() + { + return $this->_familyName; + } + + /** + * Set the value for this element's familyName attribute. This + * represents a user's family name. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface.. + */ + public function setFamilyName($value) + { + $this->_familyName = $value; + return $this; + } + + /** + * Get the value for this element's givenName attribute. + * + * @see setGivenName + * @return string The requested attribute. + */ + public function getGivenName() + { + return $this->_givenName; + } + + /** + * Set the value for this element's givenName attribute. This + * represents a user's given name. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Name Provides a fluent interface. + */ + public function setGivenName($value) + { + $this->_givenName = $value; + return $this; + } + + /** + * Magic toString method allows using this directly via echo + * Works best in PHP >= 4.2.0 + */ + public function __toString() + { + return $this->getGivenName() . ' ' . $this->getFamilyName(); + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/Extension/Nickname.php b/zend/library/Zend/Gdata/Gapps/Extension/Nickname.php new file mode 100644 index 0000000..c321074 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Extension/Nickname.php @@ -0,0 +1,142 @@ +registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct(); + $this->_name = $name; + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_name !== null) { + $element->setAttribute('name', $this->_name); + } + return $element; + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + */ + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'name': + $this->_name = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Get the value for this element's name attribute. + * + * @see setName + * @return string The requested attribute. + */ + public function getName() + { + return $this->_name; + } + + /** + * Set the value for this element's name attribute. This name uniquely + * describes this nickname within the domain. Emails addressed to this + * name will be delivered to the user who owns this nickname. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Nickname Provides a fluent + * interface. + */ + public function setName($value) + { + $this->_name = $value; + return $this; + } + + /** + * Magic toString method allows using this directly via echo + * Works best in PHP >= 4.2.0 + */ + public function __toString() + { + return $this->getName(); + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/Extension/Property.php b/zend/library/Zend/Gdata/Gapps/Extension/Property.php new file mode 100644 index 0000000..546c511 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Extension/Property.php @@ -0,0 +1,179 @@ +registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct(); + $this->_name = $name; + $this->_value = $value; + + } + + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_name !== null) { + $element->setAttribute('name', $this->_name); + } + if ($this->_value !== null) { + $element->setAttribute('value', $this->_value); + } + + return $element; + + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + */ + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'name': + $this->_name = $attribute->nodeValue; + break; + case 'value': + $this->_value = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Get the value for this element's name attribute. + * + * @see setName + * @return string The requested attribute. + */ + public function getName() + { + return $this->_name; + } + + /** + * Set the value for this element's name attribute. + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Property The element being modified. + */ + public function setName($value) + { + $this->_name = $value; + return $this; + } + + /** + * Get the value for this element's value attribute. + * + * @see setName + * @return string The requested attribute. + */ + public function getValue() + { + return $this->_value; + } + + /** + * Set the value for this element's value attribute. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Property The element being modified. + */ + public function setValue($value) + { + $this->_value = $value; + return $this; + } + + /** + * Magic toString method allows using this directly via echo + * Works best in PHP >= 4.2.0 + * + * @return string + */ + public function __toString() + { + return "Property Name: " . $this->getName() . + "\nProperty Value: " . $this->getValue(); + } +} diff --git a/zend/library/Zend/Gdata/Gapps/Extension/Quota.php b/zend/library/Zend/Gdata/Gapps/Extension/Quota.php new file mode 100644 index 0000000..95ee0bc --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Extension/Quota.php @@ -0,0 +1,142 @@ +registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct(); + $this->_limit = $limit; + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_limit !== null) { + $element->setAttribute('limit', $this->_limit); + } + return $element; + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + */ + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'limit': + $this->_limit = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * Get the value for this element's limit attribute. + * + * @see setLimit + * @return string The requested attribute. + */ + public function getLimit() + { + return $this->_limit; + } + + /** + * Set the value for this element's limit attribute. This is the amount + * of storage space, in bytes, that should be made available to + * the associated user. + * + * @param string $value The desired value for this attribute. + * @return Zend_Gdata_Gapps_Extension_Quota Provides a fluent interface. + */ + public function setLimit($value) + { + $this->_limit = $value; + return $this; + } + + /** + * Magic toString method allows using this directly via echo + * Works best in PHP >= 4.2.0 + */ + public function __toString() + { + return $this->getLimit(); + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/GroupEntry.php b/zend/library/Zend/Gdata/Gapps/GroupEntry.php new file mode 100644 index 0000000..e8e86d9 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/GroupEntry.php @@ -0,0 +1,158 @@ + in the Google Data protocol. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Gapps + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Gdata_Gapps_GroupEntry extends Zend_Gdata_Entry +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_GroupEntry'; + + /** + * element containing information about other items + * relevant to this entry. + * + * @var Zend_Gdata_Gapps_Extension_Property + */ + protected $_property = array(); + + /** + * Create a new instance. + * + * @param DOMElement $element (optional) DOMElement from which this + * object should be constructed. + */ + public function __construct($element = null) + { + $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + + foreach ($this->_property as $p) { + $element->appendChild($p->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them as members of this entry based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + + switch ($absoluteNodeName) { + + case $this->lookupNamespace('apps') . ':' . 'property'; + $property = new Zend_Gdata_Gapps_Extension_Property(); + $property->transferFromDOM($child); + $this->_property[] = $property; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Returns all property tags for this entry + * + * @param string $rel The rel value of the property to be found. If null, + * the array of properties is returned instead. + * @return mixed Either an array of Zend_Gdata_Gapps_Extension_Property + * objects if $rel is null, a single + * Zend_Gdata_Gapps_Extension_Property object if $rel is specified + * and a matching feed link is found, or null if $rel is + * specified and no matching property is found. + */ + public function getProperty($rel = null) + { + if ($rel == null) { + return $this->_property; + } else { + foreach ($this->_property as $p) { + if ($p->rel == $rel) { + return $p; + } + } + return null; + } + } + + /** + * Set the value of the property property for this object. + * + * @param array $value A collection of + * Zend_Gdata_Gapps_Extension_Property objects. + * @return Zend_Gdata_Gapps_GroupEntry Provides a fluent interface. + */ + public function setProperty($value) + { + $this->_property = $value; + return $this; + } + +} + diff --git a/zend/library/Zend/Gdata/Gapps/GroupFeed.php b/zend/library/Zend/Gdata/Gapps/GroupFeed.php new file mode 100644 index 0000000..eea9e08 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/GroupFeed.php @@ -0,0 +1,53 @@ +setGroupId($groupId); + $this->setStartGroupId($startGroupId); + } + + /** + * Set the group id to query for. When set, only groups with a group id + * matching this value will be returned in search results. Set to + * null to disable filtering by group id. + * + * @see getGroupId + * @param string $value The group id to filter search results by, or null to + * disable. + */ + public function setGroupId($value) + { + $this->_groupId = $value; + } + + /** + * Get the group id to query for. If no group id is set, null will be + * returned. + * + * @param string $value The group id to filter search results by, or + * null if disabled. + */ + public function getGroupId() + { + return $this->_groupId; + } + + /** + * Set the member to query for. When set, only subscribers with an + * email address matching this value will be returned in search results. + * Set to null to disable filtering by username. + * + * @param string $value The member email address to filter search + * results by, or null to disable. + */ + public function setMember($value) + { + if ($value !== null) { + $this->_params['member'] = $value; + } + else { + unset($this->_params['member']); + } + } + + /** + * Get the member email address to query for. If no member is set, + * null will be returned. + * + * @see setMember + * @return string The member email address to filter search + * results by, or null if disabled. + */ + public function getMember() + { + if (array_key_exists('member', $this->_params)) { + return $this->_params['member']; + } else { + return null; + } + } + + + /** + * Sets the query parameter directOnly + * @param bool $value + */ + public function setDirectOnly($value) + { + if ($value !== null) { + if($value == true) { + $this->_params['directOnly'] = 'true'; + } else { + $this->_params['directOnly'] = 'false'; + } + } else { + unset($this->_params['directOnly']); + } + } + + /** + * + * @see setDirectOnly + * @return bool + */ + public function getDirectOnly() + { + if (array_key_exists('directOnly', $this->_params)) { + + if($this->_params['directOnly'] == 'true') { + return true; + } else { + return false; + } + } else { + return null; + } + } + + /** + * Set the first group id which should be displayed when retrieving + * a list of groups. + * + * @param string $value The first group id to be returned, or null to + * disable. + */ + public function setStartGroupId($value) + { + if ($value !== null) { + $this->_params['start'] = $value; + } else { + unset($this->_params['start']); + } + } + + /** + * Get the first group id which should be displayed when retrieving + * a list of groups. + * + * @see setStartGroupId + * @return string The first group id to be returned, or null if + * disabled. + */ + public function getStartGroupId() + { + if (array_key_exists('start', $this->_params)) { + return $this->_params['start']; + } else { + return null; + } + } + + /** + * Returns the query URL generated by this query instance. + * + * @return string The query URL for this instance. + */ + public function getQueryUrl() + { + + $uri = Zend_Gdata_Gapps::APPS_BASE_FEED_URI; + $uri .= Zend_Gdata_Gapps::APPS_GROUP_PATH; + $uri .= '/' . $this->_domain; + + if ($this->_groupId !== null) { + $uri .= '/' . $this->_groupId; + } + + if(array_key_exists('member', $this->_params)) { + $uri .= '/'; + } + + $uri .= $this->getQueryString(); + return $uri; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/MemberEntry.php b/zend/library/Zend/Gdata/Gapps/MemberEntry.php new file mode 100644 index 0000000..3777d7f --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/MemberEntry.php @@ -0,0 +1,159 @@ + in the Google Data protocol. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Gapps + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Gdata_Gapps_MemberEntry extends Zend_Gdata_Entry +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_MemberEntry'; + + /** + * element containing information about other items + * relevant to this entry. + * + * @var Zend_Gdata_Gapps_Extension_Property + */ + protected $_property = array(); + + /** + * Create a new instance. + * + * @param DOMElement $element (optional) DOMElement from which this + * object should be constructed. + */ + public function __construct($element = null) + { + $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + + foreach ($this->_property as $p) { + $element->appendChild($p->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them as members of this entry based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + + switch ($absoluteNodeName) { + + case $this->lookupNamespace('apps') . ':' . 'property'; + $property = new Zend_Gdata_Gapps_Extension_Property(); + $property->transferFromDOM($child); + $this->_property[] = $property; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Returns all property tags for this entry + * + * @param string $rel The rel value of the property to be found. If null, + * the array of properties is returned instead. + * @return mixed Either an array of Zend_Gdata_Gapps_Extension_Property + * objects if $rel is null, a single + * Zend_Gdata_Gapps_Extension_Property object if $rel is specified + * and a matching feed link is found, or null if $rel is + * specified and no matching property is found. + */ + public function getProperty($rel = null) + { + if ($rel == null) { + return $this->_property; + } else { + foreach ($this->_property as $p) { + if ($p->rel == $rel) { + return $p; + } + } + return null; + } + } + + /** + * Set the value of the property property for this object. + * + * @param array $value A collection of + * Zend_Gdata_Gapps_Extension_Property objects. + * @return Zend_Gdata_Gapps_MemberEntry Provides a fluent interface. + */ + public function setProperty($value) + { + $this->_property = $value; + return $this; + } + +} + + diff --git a/zend/library/Zend/Gdata/Gapps/MemberFeed.php b/zend/library/Zend/Gdata/Gapps/MemberFeed.php new file mode 100644 index 0000000..dc8d404 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/MemberFeed.php @@ -0,0 +1,53 @@ +setGroupId($groupId); + $this->setMemberId($memberId); + $this->setStartMemberId($startMemberId); + } + + /** + * Set the group id to query for. + * + * @see getGroupId + * @param string $value The group id to filter search results by, or null to + * disable. + */ + public function setGroupId($value) + { + $this->_groupId = $value; + } + + /** + * Get the group id to query for. If no group id is set, null will be + * returned. + * + * @param string $value The group id to filter search results by, or + * null if disabled. + * @return string The group id + */ + public function getGroupId() + { + return $this->_groupId; + } + + + /** + * Set the member id to query for. When set, only users with a member id + * matching this value will be returned in search results. Set to + * null to disable filtering by member id. + * + * @see getMemberId + * @param string $value The member id to filter search results by, or null to + * disable. + */ + public function setMemberId($value) + { + $this->_memberId = $value; + } + + /** + * Get the member id to query for. If no member id is set, null will be + * returned. + * + * @param string $value The member id to filter search results by, or + * null if disabled. + * @return The member id + */ + public function getMemberId() + { + return $this->_memberId; + } + + /** + * Set the first member id which should be displayed when retrieving + * a list of members. + * + * @param string $value The first member id to be returned, or null to + * disable. + */ + public function setStartMemberId($value) + { + if ($value !== null) { + $this->_params['start'] = $value; + } else { + unset($this->_params['start']); + } + } + + /** + * Get the first username which should be displayed when retrieving + * a list of users. + * + * @see setStartUsername + * @return string The first username to be returned, or null if + * disabled. + */ + public function getStartMemberId() + { + if (array_key_exists('start', $this->_params)) { + return $this->_params['start']; + } else { + return null; + } + } + + /** + * Returns the query URL generated by this query instance. + * + * @return string The query URL for this instance. + */ + public function getQueryUrl() + { + + $uri = Zend_Gdata_Gapps::APPS_BASE_FEED_URI; + $uri .= Zend_Gdata_Gapps::APPS_GROUP_PATH; + $uri .= '/' . $this->_domain; + if ($this->_groupId !== null) { + $uri .= '/' . $this->_groupId; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'groupId must not be null'); + } + + $uri .= '/member'; + + if ($this->_memberId !== null) { + $uri .= '/' . $this->_memberId; + } + $uri .= $this->getQueryString(); + return $uri; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/NicknameEntry.php b/zend/library/Zend/Gdata/Gapps/NicknameEntry.php new file mode 100644 index 0000000..0a65ffa --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/NicknameEntry.php @@ -0,0 +1,189 @@ + in the Google Data protocol. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Gapps + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Gdata_Gapps_NicknameEntry extends Zend_Gdata_Entry +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_NicknameEntry'; + + /** + * element used to hold information about the owner + * of this nickname, including their username. + * + * @var Zend_Gdata_Gapps_Extension_Login + */ + protected $_login = null; + + /** + * element used to hold the name of this nickname. + * + * @var Zend_Gdata_Gapps_Extension_Nickname + */ + protected $_nickname = null; + + /** + * Create a new instance. + * + * @param DOMElement $element (optional) DOMElement from which this + * object should be constructed. + */ + public function __construct($element = null) + { + $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_login !== null) { + $element->appendChild($this->_login->getDOM($element->ownerDocument)); + } + if ($this->_nickname !== null) { + $element->appendChild($this->_nickname->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them as members of this entry based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + + switch ($absoluteNodeName) { + case $this->lookupNamespace('apps') . ':' . 'login'; + $login = new Zend_Gdata_Gapps_Extension_Login(); + $login->transferFromDOM($child); + $this->_login = $login; + break; + case $this->lookupNamespace('apps') . ':' . 'nickname'; + $nickname = new Zend_Gdata_Gapps_Extension_Nickname(); + $nickname->transferFromDOM($child); + $this->_nickname = $nickname; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Get the value of the login property for this object. + * + * @see setLogin + * @return Zend_Gdata_Gapps_Extension_Login The requested object. + */ + public function getLogin() + { + return $this->_login; + } + + /** + * Set the value of the login property for this object. This property + * is used to store the username address of the current user. + * + * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for + * this instance's login property. + * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface. + */ + public function setLogin($value) + { + $this->_login = $value; + return $this; + } + + /** + * Get the value of the nickname property for this object. + * + * @see setNickname + * @return Zend_Gdata_Gapps_Extension_Nickname The requested object. + */ + public function getNickname() + { + return $this->_nickname; + } + + /** + * Set the value of the nickname property for this object. This property + * is used to store the the name of the current nickname. + * + * @param Zend_Gdata_Gapps_Extension_Nickname $value The desired value for + * this instance's nickname property. + * @return Zend_Gdata_Gapps_NicknameEntry Provides a fluent interface. + */ + public function setNickname($value) + { + $this->_nickname = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/NicknameFeed.php b/zend/library/Zend/Gdata/Gapps/NicknameFeed.php new file mode 100644 index 0000000..ee9b983 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/NicknameFeed.php @@ -0,0 +1,53 @@ +setNickname($nickname); + $this->setUsername($username); + $this->setStartNickname($startNickname); + } + + /** + * Set the nickname to query for. When set, only users with a nickname + * matching this value will be returned in search results. Set to + * null to disable filtering by username. + * + * @param string $value The nickname to filter search results by, or null + * to disable. + */ + public function setNickname($value) + { + $this->_nickname = $value; + } + + /** + * Get the nickname to query for. If no nickname is set, null will be + * returned. + * + * @see setNickname + * @return string The nickname to filter search results by, or null if + * disabled. + */ + public function getNickname() + { + return $this->_nickname; + } + + /** + * Set the username to query for. When set, only users with a username + * matching this value will be returned in search results. Set to + * null to disable filtering by username. + * + * @param string $value The username to filter search results by, or null + * to disable. + */ + public function setUsername($value) + { + if ($value !== null) { + $this->_params['username'] = $value; + } + else { + unset($this->_params['username']); + } + } + + /** + * Get the username to query for. If no username is set, null will be + * returned. + * + * @see setUsername + * @return string The username to filter search results by, or null if + * disabled. + */ + public function getUsername() + { + if (array_key_exists('username', $this->_params)) { + return $this->_params['username']; + } else { + return null; + } + } + + /** + * Set the first nickname which should be displayed when retrieving + * a list of nicknames. + * + * @param string $value The first nickname to be returned, or null to + * disable. + */ + public function setStartNickname($value) + { + if ($value !== null) { + $this->_params['startNickname'] = $value; + } else { + unset($this->_params['startNickname']); + } + } + + /** + * Get the first nickname which should be displayed when retrieving + * a list of nicknames. + * + * @return string The first nickname to be returned, or null to + * disable. + */ + public function getStartNickname() + { + if (array_key_exists('startNickname', $this->_params)) { + return $this->_params['startNickname']; + } else { + return null; + } + } + + /** + * Returns the URL generated for this query, based on it's current + * parameters. + * + * @return string A URL generated based on the state of this query. + */ + public function getQueryUrl() + { + + $uri = $this->getBaseUrl(); + $uri .= Zend_Gdata_Gapps::APPS_NICKNAME_PATH; + if ($this->_nickname !== null) { + $uri .= '/' . $this->_nickname; + } + $uri .= $this->getQueryString(); + return $uri; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/OwnerEntry.php b/zend/library/Zend/Gdata/Gapps/OwnerEntry.php new file mode 100644 index 0000000..adb1a36 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/OwnerEntry.php @@ -0,0 +1,158 @@ + in the Google Data protocol. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Gapps + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Gdata_Gapps_OwnerEntry extends Zend_Gdata_Entry +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_OwnerEntry'; + + /** + * element containing information about other items + * relevant to this entry. + * + * @var Zend_Gdata_Gapps_Extension_Property + */ + protected $_property = array(); + + /** + * Create a new instance. + * + * @param DOMElement $element (optional) DOMElement from which this + * object should be constructed. + */ + public function __construct($element = null) + { + $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + + foreach ($this->_property as $p) { + $element->appendChild($p->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them as owners of this entry based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + + switch ($absoluteNodeName) { + + case $this->lookupNamespace('apps') . ':' . 'property'; + $property = new Zend_Gdata_Gapps_Extension_Property(); + $property->transferFromDOM($child); + $this->_property[] = $property; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Returns all property tags for this entry + * + * @param string $rel The rel value of the property to be found. If null, + * the array of properties is returned instead. + * @return mixed Either an array of Zend_Gdata_Gapps_Extension_Property + * objects if $rel is null, a single + * Zend_Gdata_Gapps_Extension_Property object if $rel is specified + * and a matching feed link is found, or null if $rel is + * specified and no matching property is found. + */ + public function getProperty($rel = null) + { + if ($rel == null) { + return $this->_property; + } else { + foreach ($this->_property as $p) { + if ($p->rel == $rel) { + return $p; + } + } + return null; + } + } + + /** + * Set the value of the property property for this object. + * + * @param array $value A collection of + * Zend_Gdata_Gapps_Extension_Property objects. + * @return Zend_Gdata_Gapps_OwnerEntry Provides a fluent interface. + */ + public function setProperty($value) + { + $this->_property = $value; + return $this; + } + +} + diff --git a/zend/library/Zend/Gdata/Gapps/OwnerFeed.php b/zend/library/Zend/Gdata/Gapps/OwnerFeed.php new file mode 100644 index 0000000..97b74df --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/OwnerFeed.php @@ -0,0 +1,53 @@ +setGroupId($groupId); + $this->setOwnerEmail($ownerEmail); + } + + /** + * Set the group id to query for. + * + * @see getGroupId + * @param string $value + */ + public function setGroupId($value) + { + $this->_groupId = $value; + } + + /** + * Get the group id to query for. + * + * @return string + * + */ + public function getGroupId() + { + return $this->_groupId; + } + + /** + * Set the owner email to query for. + * + * @see getOwnerEmail + * @param string $value + */ + public function setOwnerEmail($value) + { + $this->_ownerEmail = $value; + } + + /** + * Get the owner email to query for. + * + * @return string + * + */ + public function getOwnerEmail() + { + return $this->_ownerEmail; + } + + /** + * Returns the query URL generated by this query instance. + * + * @return string The query URL for this instance. + */ + public function getQueryUrl() + { + $uri = Zend_Gdata_Gapps::APPS_BASE_FEED_URI; + $uri .= Zend_Gdata_Gapps::APPS_GROUP_PATH; + $uri .= '/' . $this->_domain; + if ($this->_groupId !== null) { + $uri .= '/' . $this->_groupId; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'groupId must not be null'); + } + + $uri .= '/owner'; + + if ($this->_ownerEmail !== null) { + $uri .= '/' . $this->_ownerEmail; + } + + $uri .= $this->getQueryString(); + return $uri; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/Query.php b/zend/library/Zend/Gdata/Gapps/Query.php new file mode 100644 index 0000000..ddd7409 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/Query.php @@ -0,0 +1,123 @@ +_domain = $domain; + } + + /** + * Set domain for this service instance. This should be a fully qualified + * domain, such as 'foo.example.com'. + * + * This value is used when calculating URLs for retrieving and posting + * entries. If no value is specified, a URL will have to be manually + * constructed prior to using any methods which interact with the Google + * Apps provisioning service. + * + * @param string $value The domain to be used for this session. + */ + public function setDomain($value) + { + $this->_domain = $value; + } + + /** + * Get domain for this service instance. This should be a fully qualified + * domain, such as 'foo.example.com'. If no domain is set, null will be + * returned. + * + * @see setDomain + * @return string The domain to be used for this session, or null if not + * set. + */ + public function getDomain() + { + return $this->_domain; + } + + /** + * Returns the base URL used to access the Google Apps service, based + * on the current domain. The current domain can be temporarily + * overridden by providing a fully qualified domain as $domain. + * + * @see setDomain + * @param string $domain (optional) A fully-qualified domain to use + * instead of the default domain for this service instance. + */ + public function getBaseUrl($domain = null) + { + if ($domain !== null) { + return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $domain; + } + else if ($this->_domain !== null) { + return Zend_Gdata_Gapps::APPS_BASE_FEED_URI . '/' . $this->_domain; + } + else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Domain must be specified.'); + } + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/ServiceException.php b/zend/library/Zend/Gdata/Gapps/ServiceException.php new file mode 100644 index 0000000..e776df9 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/ServiceException.php @@ -0,0 +1,208 @@ +setErrors($errors); + } + } + + /** + * Add a single Error object to the list of errors received by the + * server. + * + * @param Zend_Gdata_Gapps_Error $error An instance of an error returned + * by the server. The error's errorCode must be set. + * @throws Zend_Gdata_App_Exception + */ + public function addError($error) { + // Make sure that we don't try to index an error that doesn't + // contain an index value. + if ($error->getErrorCode() == null) { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception("Error encountered without corresponding error code."); + } + + $this->_errors[$error->getErrorCode()] = $error; + } + + /** + * Set the list of errors as sent by the server inside of an + * AppsForYourDomainErrors tag. + * + * @param array $array An associative array containing a collection of + * Zend_Gdata_Gapps_Error objects. All errors must have their + * errorCode value set. + * @throws Zend_Gdata_App_Exception + */ + public function setErrors($array) { + $this->_errors = array(); + foreach ($array as $error) { + $this->addError($error); + } + } + + /** + * Get the list of errors as sent by the server inside of an + * AppsForYourDomainErrors tag. + * + * @return array An associative array containing a collection of + * Zend_Gdata_Gapps_Error objects, indexed by error code. + */ + public function getErrors() { + return $this->_errors; + } + + /** + * Return the Error object associated with a specific error code. + * + * @return Zend_Gdata_Gapps_Error The Error object requested, or null + * if not found. + */ + public function getError($errorCode) { + if (array_key_exists($errorCode, $this->_errors)) { + $result = $this->_errors[$errorCode]; + return $result; + } else { + return null; + } + } + + /** + * Check whether or not a particular error code was returned by the + * server. + * + * @param integer $errorCode The error code to check against. + * @return boolean Whether or not the supplied error code was returned + * by the server. + */ + public function hasError($errorCode) { + return array_key_exists($errorCode, $this->_errors); + } + + /** + * Import an AppsForYourDomain error from XML. + * + * @param string $string The XML data to be imported + * @return Zend_Gdata_Gapps_ServiceException Provides a fluent interface. + * @throws Zend_Gdata_App_Exception + */ + public function importFromString($string) { + if ($string) { + // Check to see if an AppsForYourDomainError exists + // + // track_errors is temporarily enabled so that if an error + // occurs while parsing the XML we can append it to an + // exception by referencing $php_errormsg + @ini_set('track_errors', 1); + $doc = new DOMDocument(); + $success = @$doc->loadXML($string); + @ini_restore('track_errors'); + + if (!$success) { + require_once 'Zend/Gdata/App/Exception.php'; + // $php_errormsg is automatically generated by PHP if + // an error occurs while calling loadXML(), above. + throw new Zend_Gdata_App_Exception("DOMDocument cannot parse XML: $php_errormsg"); + } + + // Ensure that the outermost node is an AppsForYourDomain error. + // If it isn't, something has gone horribly wrong. + $rootElement = $doc->getElementsByTagName($this->_rootElement)->item(0); + if (!$rootElement) { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.'); + } + + foreach ($rootElement->childNodes as $errorNode) { + if (!($errorNode instanceof DOMText)) { + $error = new Zend_Gdata_Gapps_Error(); + $error->transferFromDom($errorNode); + $this->addError($error); + } + } + return $this; + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('XML passed to transferFromXML cannot be null'); + } + + } + + /** + * Get a human readable version of this exception. + * + * @return string + */ + public function __toString() { + $result = "The server encountered the following errors processing the request:"; + foreach ($this->_errors as $error) { + $result .= "\n" . $error->__toString(); + } + return $result; + } +} diff --git a/zend/library/Zend/Gdata/Gapps/UserEntry.php b/zend/library/Zend/Gdata/Gapps/UserEntry.php new file mode 100644 index 0000000..ed7e9e3 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/UserEntry.php @@ -0,0 +1,295 @@ + in the Google Data protocol. + * + * @category Zend + * @package Zend_Gdata + * @subpackage Gapps + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Zend_Gdata_Gapps_UserEntry extends Zend_Gdata_Entry +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_UserEntry'; + + /** + * element containing information about this user's + * account, including their username and permissions. + * + * @var Zend_Gdata_Gapps_Extension_Login + */ + protected $_login = null; + + /** + * element containing the user's actual name. + * + * @var Zend_Gdata_Gapps_Extension_Name + */ + protected $_name = null; + + /** + * element describing any storage quotas in place for + * this user. + * + * @var Zend_Gdata_Gapps_Extension_Quota + */ + protected $_quota = null; + + /** + * element containing information about other feeds + * relevant to this entry. + * + * @var Zend_Gdata_Extension_FeedLink + */ + protected $_feedLink = array(); + + /** + * Create a new instance. + * + * @param DOMElement $element (optional) DOMElement from which this + * object should be constructed. + */ + public function __construct($element = null) + { + $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); + parent::__construct($element); + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_login !== null) { + $element->appendChild($this->_login->getDOM($element->ownerDocument)); + } + if ($this->_name !== null) { + $element->appendChild($this->_name->getDOM($element->ownerDocument)); + } + if ($this->_quota !== null) { + $element->appendChild($this->_quota->getDOM($element->ownerDocument)); + } + foreach ($this->_feedLink as $feedLink) { + $element->appendChild($feedLink->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them as members of this entry based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + + switch ($absoluteNodeName) { + case $this->lookupNamespace('apps') . ':' . 'login'; + $login = new Zend_Gdata_Gapps_Extension_Login(); + $login->transferFromDOM($child); + $this->_login = $login; + break; + case $this->lookupNamespace('apps') . ':' . 'name'; + $name = new Zend_Gdata_Gapps_Extension_Name(); + $name->transferFromDOM($child); + $this->_name = $name; + break; + case $this->lookupNamespace('apps') . ':' . 'quota'; + $quota = new Zend_Gdata_Gapps_Extension_Quota(); + $quota->transferFromDOM($child); + $this->_quota = $quota; + break; + case $this->lookupNamespace('gd') . ':' . 'feedLink'; + $feedLink = new Zend_Gdata_Extension_FeedLink(); + $feedLink->transferFromDOM($child); + $this->_feedLink[] = $feedLink; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Get the value of the login property for this object. + * + * @see setLogin + * @return Zend_Gdata_Gapps_Extension_Login The requested object. + */ + public function getLogin() + { + return $this->_login; + } + + /** + * Set the value of the login property for this object. This property + * is used to store the username address of the current user. + * + * @param Zend_Gdata_Gapps_Extension_Login $value The desired value for + * this instance's login property. + * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface. + */ + public function setLogin($value) + { + $this->_login = $value; + return $this; + } + + /** + * Get the value of the name property for this object. + * + * @see setName + * @return Zend_Gdata_Gapps_Extension_Name The requested object. + */ + public function getName() + { + return $this->_name; + } + + /** + * Set the value of the name property for this object. This property + * is used to store the full name of the current user. + * + * @param Zend_Gdata_Gapps_Extension_Name $value The desired value for + * this instance's name property. + * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface. + */ + public function setName($value) + { + $this->_name = $value; + return $this; + } + + /** + * Get the value of the quota property for this object. + * + * @see setQuota + * @return Zend_Gdata_Gapps_Extension_Quota The requested object. + */ + public function getQuota() + { + return $this->_quota; + } + + /** + * Set the value of the quota property for this object. This property + * is used to store the amount of storage available for the current + * user. Quotas may not be modifiable depending on the domain used. + * + * @param Zend_Gdata_Gapps_Extension_Quota $value The desired value for + * this instance's quota property. + * @return Zend_Gdata_Gapps_UserEntry Provides a fluent interface. + */ + public function setQuota($value) + { + $this->_quota = $value; + return $this; + } + + /** + * Returns all feed links for this entry, or if a rel value is + * specified, the feed link associated with that value is returned. + * + * @param string $rel The rel value of the link to be found. If null, + * the array of links is returned instead. + * @return mixed Either an array of Zend_Gdata_Extension_FeedLink + * objects if $rel is null, a single + * Zend_Gdata_Extension_FeedLink object if $rel is specified + * and a matching feed link is found, or null if $rel is + * specified and no matching feed link is found. + */ + public function getFeedLink($rel = null) + { + if ($rel == null) { + return $this->_feedLink; + } else { + foreach ($this->_feedLink as $feedLink) { + if ($feedLink->rel == $rel) { + return $feedLink; + } + } + return null; + } + } + + /** + * Set the value of the feed link property for this object. This property + * is used to provide links to alternative feeds relevant to this entry. + * + * @param array $value A collection of + * Zend_Gdata_Gapps_Extension_FeedLink objects. + * @return Zend_Gdata_Gapps_EventEntry Provides a fluent interface. + */ + public function setFeedLink($value) + { + $this->_feedLink = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/Gapps/UserFeed.php b/zend/library/Zend/Gdata/Gapps/UserFeed.php new file mode 100644 index 0000000..7a295e8 --- /dev/null +++ b/zend/library/Zend/Gdata/Gapps/UserFeed.php @@ -0,0 +1,53 @@ +setUsername($username); + $this->setStartUsername($startUsername); + } + + /** + * Set the username to query for. When set, only users with a username + * matching this value will be returned in search results. Set to + * null to disable filtering by username. + * + * @see getUsername + * @param string $value The username to filter search results by, or null to + * disable. + */ + public function setUsername($value) + { + $this->_username = $value; + } + + /** + * Get the username to query for. If no username is set, null will be + * returned. + * + * @param string $value The username to filter search results by, or + * null if disabled. + */ + public function getUsername() + { + return $this->_username; + } + + /** + * Set the first username which should be displayed when retrieving + * a list of users. + * + * @param string $value The first username to be returned, or null to + * disable. + */ + public function setStartUsername($value) + { + if ($value !== null) { + $this->_params['startUsername'] = $value; + } else { + unset($this->_params['startUsername']); + } + } + + /** + * Get the first username which should be displayed when retrieving + * a list of users. + * + * @see setStartUsername + * @return string The first username to be returned, or null if + * disabled. + */ + public function getStartUsername() + { + if (array_key_exists('startUsername', $this->_params)) { + return $this->_params['startUsername']; + } else { + return null; + } + } + + /** + * Returns the query URL generated by this query instance. + * + * @return string The query URL for this instance. + */ + public function getQueryUrl() + { + $uri = $this->getBaseUrl(); + $uri .= Zend_Gdata_Gapps::APPS_USER_PATH; + if ($this->_username !== null) { + $uri .= '/' . $this->_username; + } + $uri .= $this->getQueryString(); + return $uri; + } + +} -- cgit v1.2.3