diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /webmail/program/lib/Zend/Gdata/Gapps | |
Diffstat (limited to '')
31 files changed, 6450 insertions, 0 deletions
diff --git a/webmail/program/lib/Zend/Gdata/Gapps.php b/webmail/program/lib/Zend/Gdata/Gapps.php new file mode 100644 index 0000000..91f214b --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps.php @@ -0,0 +1,1683 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: Gapps.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata + */ +require_once 'Zend/Gdata.php'; + +/** + * @see Zend_Gdata_Gapps_UserFeed + */ +require_once 'Zend/Gdata/Gapps/UserFeed.php'; + +/** + * @see Zend_Gdata_Gapps_NicknameFeed + */ +require_once 'Zend/Gdata/Gapps/NicknameFeed.php'; + +/** + * @see Zend_Gdata_Gapps_GroupFeed + */ +require_once 'Zend/Gdata/Gapps/GroupFeed.php'; + +/** + * @see Zend_Gdata_Gapps_MemberFeed + */ +require_once 'Zend/Gdata/Gapps/MemberFeed.php'; + +/** + * @see Zend_Gdata_Gapps_OwnerFeed + */ +require_once 'Zend/Gdata/Gapps/OwnerFeed.php'; + +/** + * @see Zend_Gdata_Gapps_EmailListFeed + */ +require_once 'Zend/Gdata/Gapps/EmailListFeed.php'; + +/** + * @see Zend_Gdata_Gapps_EmailListRecipientFeed + */ +require_once 'Zend/Gdata/Gapps/EmailListRecipientFeed.php'; + + +/** + * Service class for interacting with the Google Apps Provisioning API. + * + * Like other service classes in this module, this class provides access via + * an HTTP client to Google servers for working with entries and feeds. + * + * Because of the nature of this API, all access must occur over an + * authenticated connection. + * + * @link http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html + * + * @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 extends Zend_Gdata +{ + + const APPS_BASE_FEED_URI = 'https://apps-apis.google.com/a/feeds'; + const AUTH_SERVICE_NAME = 'apps'; + + /** + * Path to user feeds on the Google Apps server. + */ + const APPS_USER_PATH = '/user/2.0'; + + /** + * Path to nickname feeds on the Google Apps server. + */ + const APPS_NICKNAME_PATH = '/nickname/2.0'; + + /** + * Path to group feeds on the Google Apps server. + */ + const APPS_GROUP_PATH = '/group/2.0'; + + /** + * Path to email list feeds on the Google Apps server. + */ + const APPS_EMAIL_LIST_PATH = '/emailList/2.0'; + + /** + * Path to email list recipient feeds on the Google Apps server. + */ + const APPS_EMAIL_LIST_RECIPIENT_POSTFIX = '/recipient'; + + /** + * The domain which is being administered via the Provisioning API. + * + * @var string + */ + protected $_domain = null; + + /** + * Namespaces used for Zend_Gdata_Gapps + * + * @var array + */ + public static $namespaces = array( + array('apps', 'http://schemas.google.com/apps/2006', 1, 0) + ); + + /** + * Create Gdata_Gapps object + * + * @param Zend_Http_Client $client (optional) The HTTP client to use when + * when communicating with the Google Apps servers. + * @param string $domain (optional) The Google Apps domain which is to be + * accessed. + * @param string $applicationId The identity of the app in the form of Company-AppName-Version + */ + public function __construct($client = null, $domain = null, $applicationId = 'MyCompany-MyApp-1.0') + { + $this->registerPackage('Zend_Gdata_Gapps'); + $this->registerPackage('Zend_Gdata_Gapps_Extension'); + parent::__construct($client, $applicationId); + $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME); + $this->_domain = $domain; + } + + /** + * Convert an exception to an ServiceException if an AppsForYourDomain + * XML document is contained within the original exception's HTTP + * response. If conversion fails, throw the original error. + * + * @param Zend_Gdata_Exception $e The exception to convert. + * @throws Zend_Gdata_Gapps_ServiceException + * @throws mixed + */ + public static function throwServiceExceptionIfDetected($e) { + // Check to make sure that there actually response! + // This can happen if the connection dies before the request + // completes. (See ZF-5949) + $response = $e->getResponse(); + if (!$response) { + require_once('Zend/Gdata/App/IOException.php'); + throw new Zend_Gdata_App_IOException('No HTTP response received (possible connection failure)'); + } + + try { + // Check to see if there is an AppsForYourDomainErrors + // datastructure in the response. If so, convert it to + // an exception and throw it. + require_once 'Zend/Gdata/Gapps/ServiceException.php'; + $error = new Zend_Gdata_Gapps_ServiceException(); + $error->importFromString($response->getBody()); + throw $error; + } catch (Zend_Gdata_App_Exception $e2) { + // Unable to convert the response to a ServiceException, + // most likely because the server didn't return an + // AppsForYourDomainErrors document. Throw the original + // exception. + throw $e; + } + } + + /** + * Imports a feed located at $uri. + * This method overrides the default behavior of Zend_Gdata_App, + * providing support for Zend_Gdata_Gapps_ServiceException. + * + * @param string $uri + * @param Zend_Http_Client $client (optional) The client used for + * communication + * @param string $className (optional) The class which is used as the + * return type + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + * @return Zend_Gdata_App_Feed + */ + public static function import($uri, $client = null, $className='Zend_Gdata_App_Feed') + { + try { + return parent::import($uri, $client, $className); + } catch (Zend_Gdata_App_HttpException $e) { + self::throwServiceExceptionIfDetected($e); + } + } + + /** + * GET a URI using client object. + * This method overrides the default behavior of Zend_Gdata_App, + * providing support for Zend_Gdata_Gapps_ServiceException. + * + * @param string $uri GET URI + * @param array $extraHeaders Extra headers to add to the request, as an + * array of string-based key/value pairs. + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + * @return Zend_Http_Response + */ + public function get($uri, $extraHeaders = array()) + { + try { + return parent::get($uri, $extraHeaders); + } catch (Zend_Gdata_App_HttpException $e) { + self::throwServiceExceptionIfDetected($e); + } + } + + /** + * POST data with client object. + * This method overrides the default behavior of Zend_Gdata_App, + * providing support for Zend_Gdata_Gapps_ServiceException. + * + * @param mixed $data The Zend_Gdata_App_Entry or XML to post + * @param string $uri (optional) POST URI + * @param integer $remainingRedirects (optional) + * @param string $contentType Content-type of the data + * @param array $extraHaders Extra headers to add tot he request + * @return Zend_Http_Response + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_App_InvalidArgumentException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function post($data, $uri = null, $remainingRedirects = null, + $contentType = null, $extraHeaders = null) + { + try { + return parent::post($data, $uri, $remainingRedirects, $contentType, $extraHeaders); + } catch (Zend_Gdata_App_HttpException $e) { + self::throwServiceExceptionIfDetected($e); + } + } + + /** + * PUT data with client object + * This method overrides the default behavior of Zend_Gdata_App, + * providing support for Zend_Gdata_Gapps_ServiceException. + * + * @param mixed $data The Zend_Gdata_App_Entry or XML to post + * @param string $uri (optional) PUT URI + * @param integer $remainingRedirects (optional) + * @param string $contentType Content-type of the data + * @param array $extraHaders Extra headers to add tot he request + * @return Zend_Http_Response + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_App_InvalidArgumentException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function put($data, $uri = null, $remainingRedirects = null, + $contentType = null, $extraHeaders = null) + { + try { + return parent::put($data, $uri, $remainingRedirects, $contentType, $extraHeaders); + } catch (Zend_Gdata_App_HttpException $e) { + self::throwServiceExceptionIfDetected($e); + } + } + + /** + * DELETE entry with client object + * This method overrides the default behavior of Zend_Gdata_App, + * providing support for Zend_Gdata_Gapps_ServiceException. + * + * @param mixed $data The Zend_Gdata_App_Entry or URL to delete + * @param integer $remainingRedirects (optional) + * @return void + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_App_InvalidArgumentException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function delete($data, $remainingRedirects = null) + { + try { + return parent::delete($data, $remainingRedirects); + } catch (Zend_Gdata_App_HttpException $e) { + self::throwServiceExceptionIfDetected($e); + } + } + + /** + * 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. + * + * @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. + * + * @param string $domain (optional) A fully-qualified domain to use + * instead of the default domain for this service instance. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function getBaseUrl($domain = null) + { + if ($domain !== null) { + return self::APPS_BASE_FEED_URI . '/' . $domain; + } else if ($this->_domain !== null) { + return self::APPS_BASE_FEED_URI . '/' . $this->_domain; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Domain must be specified.'); + } + } + + /** + * Retrieve a UserFeed containing multiple UserEntry objects. + * + * @param mixed $location (optional) The location for the feed, as a URL + * or Query. + * @return Zend_Gdata_Gapps_UserFeed + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getUserFeed($location = null) + { + if ($location === null) { + $uri = $this->getBaseUrl() . self::APPS_USER_PATH; + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getFeed($uri, 'Zend_Gdata_Gapps_UserFeed'); + } + + /** + * Retreive NicknameFeed object containing multiple NicknameEntry objects. + * + * @param mixed $location (optional) The location for the feed, as a URL + * or Query. + * @return Zend_Gdata_Gapps_NicknameFeed + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getNicknameFeed($location = null) + { + if ($location === null) { + $uri = $this->getBaseUrl() . self::APPS_NICKNAME_PATH; + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getFeed($uri, 'Zend_Gdata_Gapps_NicknameFeed'); + } + + /** + * Retreive GroupFeed object containing multiple GroupEntry + * objects. + * + * @param mixed $location (optional) The location for the feed, as a URL + * or Query. + * @return Zend_Gdata_Gapps_GroupFeed + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getGroupFeed($location = null) + { + if ($location === null) { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain(); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getFeed($uri, 'Zend_Gdata_Gapps_GroupFeed'); + } + + /** + * Retreive MemberFeed object containing multiple MemberEntry + * objects. + * + * @param mixed $location (optional) The location for the feed, as a URL + * or Query. + * @return Zend_Gdata_Gapps_MemberFeed + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getMemberFeed($location = null) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getFeed($uri, 'Zend_Gdata_Gapps_MemberFeed'); + } + + /** + * Retreive OwnerFeed object containing multiple OwnerEntry + * objects. + * + * @param mixed $location (optional) The location for the feed, as a URL + * or Query. + * @return Zend_Gdata_Gapps_OwnerFeed + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getOwnerFeed($location = null) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getFeed($uri, 'Zend_Gdata_Gapps_OwnerFeed'); + } + + /** + * Retreive EmailListFeed object containing multiple EmailListEntry + * objects. + * + * @param mixed $location (optional) The location for the feed, as a URL + * or Query. + * @return Zend_Gdata_Gapps_EmailListFeed + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getEmailListFeed($location = null) + { + if ($location === null) { + $uri = $this->getBaseUrl() . self::APPS_NICKNAME_PATH; + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getFeed($uri, 'Zend_Gdata_Gapps_EmailListFeed'); + } + + /** + * Retreive EmailListRecipientFeed object containing multiple + * EmailListRecipientEntry objects. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_EmailListRecipientFeed + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getEmailListRecipientFeed($location) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getFeed($uri, 'Zend_Gdata_Gapps_EmailListRecipientFeed'); + } + + /** + * Retreive a single UserEntry object. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_UserEntry + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getUserEntry($location) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getEntry($uri, 'Zend_Gdata_Gapps_UserEntry'); + } + + /** + * Retreive a single NicknameEntry object. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_NicknameEntry + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getNicknameEntry($location) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getEntry($uri, 'Zend_Gdata_Gapps_NicknameEntry'); + } + + /** + * Retreive a single GroupEntry object. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_GroupEntry + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getGroupEntry($location = null) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getEntry($uri, 'Zend_Gdata_Gapps_GroupEntry'); + } + + /** + * Retreive a single MemberEntry object. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_MemberEntry + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getMemberEntry($location = null) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getEntry($uri, 'Zend_Gdata_Gapps_MemberEntry'); + } + + /** + * Retreive a single OwnerEntry object. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_OwnerEntry + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getOwnerEntry($location = null) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getEntry($uri, 'Zend_Gdata_Gapps_OwnerEntry'); + } + + /** + * Retreive a single EmailListEntry object. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_EmailListEntry + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getEmailListEntry($location) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getEntry($uri, 'Zend_Gdata_Gapps_EmailListEntry'); + } + + /** + * Retreive a single EmailListRecipientEntry object. + * + * @param mixed $location The location for the feed, as a URL or Query. + * @return Zend_Gdata_Gapps_EmailListRecipientEntry + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function getEmailListRecipientEntry($location) + { + if ($location === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Location must not be null'); + } else if ($location instanceof Zend_Gdata_Query) { + $uri = $location->getQueryUrl(); + } else { + $uri = $location; + } + return parent::getEntry($uri, 'Zend_Gdata_Gapps_EmailListRecipientEntry'); + } + + /** + * Create a new user from a UserEntry. + * + * @param Zend_Gdata_Gapps_UserEntry $user The user entry to insert. + * @param string $uri (optional) The URI where the user should be + * uploaded to. If null, the default user creation URI for + * this domain will be used. + * @return Zend_Gdata_Gapps_UserEntry The inserted user entry as + * returned by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function insertUser($user, $uri = null) + { + if ($uri === null) { + $uri = $this->getBaseUrl() . self::APPS_USER_PATH; + } + $newEntry = $this->insertEntry($user, $uri, 'Zend_Gdata_Gapps_UserEntry'); + return $newEntry; + } + + /** + * Create a new nickname from a NicknameEntry. + * + * @param Zend_Gdata_Gapps_NicknameEntry $nickname The nickname entry to + * insert. + * @param string $uri (optional) The URI where the nickname should be + * uploaded to. If null, the default nickname creation URI for + * this domain will be used. + * @return Zend_Gdata_Gapps_NicknameEntry The inserted nickname entry as + * returned by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function insertNickname($nickname, $uri = null) + { + if ($uri === null) { + $uri = $this->getBaseUrl() . self::APPS_NICKNAME_PATH; + } + $newEntry = $this->insertEntry($nickname, $uri, 'Zend_Gdata_Gapps_NicknameEntry'); + return $newEntry; + } + + /** + * Create a new group from a GroupEntry. + * + * @param Zend_Gdata_Gapps_GroupEntry $group The group entry to insert. + * @param string $uri (optional) The URI where the group should be + * uploaded to. If null, the default user creation URI for + * this domain will be used. + * @return Zend_Gdata_Gapps_GroupEntry The inserted group entry as + * returned by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function insertGroup($group, $uri = null) + { + if ($uri === null) { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain(); + } + $newEntry = $this->insertEntry($group, $uri, 'Zend_Gdata_Gapps_GroupEntry'); + return $newEntry; + } + + /** + * Create a new member from a MemberEntry. + * + * @param Zend_Gdata_Gapps_MemberEntry $member The member entry to insert. + * @param string $uri (optional) The URI where the group should be + * uploaded to. If null, the default user creation URI for + * this domain will be used. + * @return Zend_Gdata_Gapps_MemberEntry The inserted member entry as + * returned by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function insertMember($member, $uri = null) + { + if ($uri === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'URI must not be null'); + } + $newEntry = $this->insertEntry($member, $uri, 'Zend_Gdata_Gapps_MemberEntry'); + return $newEntry; + } + + /** + * Create a new group from a OwnerEntry. + * + * @param Zend_Gdata_Gapps_OwnerEntry $owner The owner entry to insert. + * @param string $uri (optional) The URI where the owner should be + * uploaded to. If null, the default user creation URI for + * this domain will be used. + * @return Zend_Gdata_Gapps_OwnerEntry The inserted owner entry as + * returned by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function insertOwner($owner, $uri = null) + { + if ($uri === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'URI must not be null'); + } + $newEntry = $this->insertEntry($owner, $uri, 'Zend_Gdata_Gapps_OwnerEntry'); + return $newEntry; + } + + /** + * Create a new email list from an EmailListEntry. + * + * @param Zend_Gdata_Gapps_EmailListEntry $emailList The email list entry + * to insert. + * @param string $uri (optional) The URI where the email list should be + * uploaded to. If null, the default email list creation URI for + * this domain will be used. + * @return Zend_Gdata_Gapps_EmailListEntry The inserted email list entry + * as returned by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function insertEmailList($emailList, $uri = null) + { + if ($uri === null) { + $uri = $this->getBaseUrl() . self::APPS_EMAIL_LIST_PATH; + } + $newEntry = $this->insertEntry($emailList, $uri, 'Zend_Gdata_Gapps_EmailListEntry'); + return $newEntry; + } + + /** + * Create a new email list recipient from an EmailListRecipientEntry. + * + * @param Zend_Gdata_Gapps_EmailListRecipientEntry $recipient The recipient + * entry to insert. + * @param string $uri (optional) The URI where the recipient should be + * uploaded to. If null, the default recipient creation URI for + * this domain will be used. + * @return Zend_Gdata_Gapps_EmailListRecipientEntry The inserted + * recipient entry as returned by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function insertEmailListRecipient($recipient, $uri = null) + { + if ($uri === null) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'URI must not be null'); + } elseif ($uri instanceof Zend_Gdata_Gapps_EmailListEntry) { + $uri = $uri->getLink('edit')->href; + } + $newEntry = $this->insertEntry($recipient, $uri, 'Zend_Gdata_Gapps_EmailListRecipientEntry'); + return $newEntry; + } + + /** + * Provides a magic factory method to instantiate new objects with + * shorter syntax than would otherwise be required by the Zend Framework + * naming conventions. For more information, see Zend_Gdata_App::__call(). + * + * This overrides the default behavior of __call() so that query classes + * do not need to have their domain manually set when created with + * a magic factory method. + * + * @see Zend_Gdata_App::__call() + * @param string $method The method name being called + * @param array $args The arguments passed to the call + * @throws Zend_Gdata_App_Exception + */ + public function __call($method, $args) { + if (preg_match('/^new(\w+Query)/', $method, $matches)) { + $class = $matches[1]; + $foundClassName = null; + foreach ($this->_registeredPackages as $name) { + try { + // Autoloading disabled on next line for compatibility + // with magic factories. See ZF-6660. + if (!class_exists($name . '_' . $class, false)) { + require_once 'Zend/Loader.php'; + @Zend_Loader::loadClass($name . '_' . $class); + } + $foundClassName = $name . '_' . $class; + break; + } catch (Zend_Exception $e) { + // package wasn't here- continue searching + } + } + if ($foundClassName != null) { + $reflectionObj = new ReflectionClass($foundClassName); + // Prepend the domain to the query + $args = array_merge(array($this->getDomain()), $args); + return $reflectionObj->newInstanceArgs($args); + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception( + "Unable to find '${class}' in registered packages"); + } + } else { + return parent::__call($method, $args); + } + + } + + // Convenience methods + // Specified at http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_e + + /** + * Create a new user entry and send it to the Google Apps servers. + * + * @param string $username The username for the new user. + * @param string $givenName The given name for the new user. + * @param string $familyName The family name for the new user. + * @param string $password The password for the new user as a plaintext string + * (if $passwordHashFunction is null) or a SHA-1 hashed + * value (if $passwordHashFunction = 'SHA-1'). + * @param string $quotaLimitInMB (optional) The quota limit for the new user in MB. + * @return Zend_Gdata_Gapps_UserEntry (optional) The new user entry as returned by + * server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function createUser ($username, $givenName, $familyName, $password, + $passwordHashFunction = null, $quotaLimitInMB = null) { + $user = $this->newUserEntry(); + $user->login = $this->newLogin(); + $user->login->username = $username; + $user->login->password = $password; + $user->login->hashFunctionName = $passwordHashFunction; + $user->name = $this->newName(); + $user->name->givenName = $givenName; + $user->name->familyName = $familyName; + if ($quotaLimitInMB !== null) { + $user->quota = $this->newQuota(); + $user->quota->limit = $quotaLimitInMB; + } + return $this->insertUser($user); + } + + /** + * Retrieve a user based on their username. + * + * @param string $username The username to search for. + * @return Zend_Gdata_Gapps_UserEntry The username to search for, or null + * if no match found. + * @throws Zend_Gdata_App_InvalidArgumentException + * @throws Zend_Gdata_App_HttpException + */ + public function retrieveUser ($username) { + $query = $this->newUserQuery($username); + try { + $user = $this->getUserEntry($query); + } catch (Zend_Gdata_Gapps_ServiceException $e) { + // Set the user to null if not found + if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { + $user = null; + } else { + throw $e; + } + } + return $user; + } + + /** + * Retrieve a page of users in alphabetical order, starting with the + * provided username. + * + * @param string $startUsername (optional) The first username to retrieve. + * If null or not declared, the page will begin with the first + * user in the domain. + * @return Zend_Gdata_Gapps_UserFeed Collection of Zend_Gdata_UserEntry + * objects representing all users in the domain. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrievePageOfUsers ($startUsername = null) { + $query = $this->newUserQuery(); + $query->setStartUsername($startUsername); + return $this->getUserFeed($query); + } + + /** + * Retrieve all users in the current domain. Be aware that + * calling this function on a domain with many users will take a + * signifigant amount of time to complete. On larger domains this may + * may cause execution to timeout without proper precautions in place. + * + * @return Zend_Gdata_Gapps_UserFeed Collection of Zend_Gdata_UserEntry + * objects representing all users in the domain. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrieveAllUsers () { + return $this->retrieveAllEntriesForFeed($this->retrievePageOfUsers()); + } + + /** + * Overwrite a specified username with the provided UserEntry. The + * UserEntry does not need to contain an edit link. + * + * This method is provided for compliance with the Google Apps + * Provisioning API specification. Normally users will instead want to + * call UserEntry::save() instead. + * + * @see Zend_Gdata_App_Entry::save + * @param string $username The username whose data will be overwritten. + * @param Zend_Gdata_Gapps_UserEntry $userEntry The user entry which + * will be overwritten. + * @return Zend_Gdata_Gapps_UserEntry The UserEntry returned by the + * server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function updateUser($username, $userEntry) { + return $this->updateEntry($userEntry, $this->getBaseUrl() . + self::APPS_USER_PATH . '/' . $username); + } + + /** + * Mark a given user as suspended. + * + * @param string $username The username associated with the user who + * should be suspended. + * @return Zend_Gdata_Gapps_UserEntry The UserEntry for the modified + * user. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function suspendUser($username) { + $user = $this->retrieveUser($username); + $user->login->suspended = true; + return $user->save(); + } + + /** + * Mark a given user as not suspended. + * + * @param string $username The username associated with the user who + * should be restored. + * @return Zend_Gdata_Gapps_UserEntry The UserEntry for the modified + * user. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function restoreUser($username) { + $user = $this->retrieveUser($username); + $user->login->suspended = false; + return $user->save(); + } + + /** + * Delete a user by username. + * + * @param string $username The username associated with the user who + * should be deleted. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function deleteUser($username) { + $this->delete($this->getBaseUrl() . self::APPS_USER_PATH . '/' . + $username); + } + + /** + * Create a nickname for a given user. + * + * @param string $username The username to which the new nickname should + * be associated. + * @param string $nickname The new nickname to be created. + * @return Zend_Gdata_Gapps_NicknameEntry The nickname entry which was + * created by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function createNickname($username, $nickname) { + $entry = $this->newNicknameEntry(); + $nickname = $this->newNickname($nickname); + $login = $this->newLogin($username); + $entry->nickname = $nickname; + $entry->login = $login; + return $this->insertNickname($entry); + } + + /** + * Retrieve the entry for a specified nickname. + * + * @param string $nickname The nickname to be retrieved. + * @return Zend_Gdata_Gapps_NicknameEntry The requested nickname entry. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrieveNickname($nickname) { + $query = $this->newNicknameQuery(); + $query->setNickname($nickname); + try { + $nickname = $this->getNicknameEntry($query); + } catch (Zend_Gdata_Gapps_ServiceException $e) { + // Set the nickname to null if not found + if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { + $nickname = null; + } else { + throw $e; + } + } + return $nickname; + } + + /** + * Retrieve all nicknames associated with a specific username. + * + * @param string $username The username whose nicknames should be + * returned. + * @return Zend_Gdata_Gapps_NicknameFeed A feed containing all nicknames + * for the given user, or null if + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrieveNicknames($username) { + $query = $this->newNicknameQuery(); + $query->setUsername($username); + $nicknameFeed = $this->retrieveAllEntriesForFeed( + $this->getNicknameFeed($query)); + return $nicknameFeed; + } + + /** + * Retrieve a page of nicknames in alphabetical order, starting with the + * provided nickname. + * + * @param string $startNickname (optional) The first nickname to + * retrieve. If null or not declared, the page will begin with + * the first nickname in the domain. + * @return Zend_Gdata_Gapps_NicknameFeed Collection of Zend_Gdata_NicknameEntry + * objects representing all nicknames in the domain. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrievePageOfNicknames ($startNickname = null) { + $query = $this->newNicknameQuery(); + $query->setStartNickname($startNickname); + return $this->getNicknameFeed($query); + } + + /** + * Retrieve all nicknames in the current domain. Be aware that + * calling this function on a domain with many nicknames will take a + * signifigant amount of time to complete. On larger domains this may + * may cause execution to timeout without proper precautions in place. + * + * @return Zend_Gdata_Gapps_NicknameFeed Collection of Zend_Gdata_NicknameEntry + * objects representing all nicknames in the domain. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrieveAllNicknames () { + return $this->retrieveAllEntriesForFeed($this->retrievePageOfNicknames()); + } + + /** + * Delete a specified nickname. + * + * @param string $nickname The name of the nickname to be deleted. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function deleteNickname($nickname) { + $this->delete($this->getBaseUrl() . self::APPS_NICKNAME_PATH . '/' . $nickname); + } + + /** + * Create a new group. + * + * @param string $groupId A unique identifier for the group + * @param string $groupName The name of the group + * @param string $description A description of the group + * @param string $emailPermission The subscription permission of the group + * @return Zend_Gdata_Gapps_GroupEntry The group entry as created on the server. + */ + public function createGroup($groupId, $groupName, $description = null, $emailPermission = null) + { + $i = 0; + $group = $this->newGroupEntry(); + + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'groupId'; + $properties[$i]->value = $groupId; + $i++; + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'groupName'; + $properties[$i]->value = $groupName; + $i++; + + if($description != null) { + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'description'; + $properties[$i]->value = $description; + $i++; + } + + if($emailPermission != null) { + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'emailPermission'; + $properties[$i]->value = $emailPermission; + $i++; + } + + $group->property = $properties; + + return $this->insertGroup($group); + } + + /** + * Retrieves a group based on group id + * + * @param string $groupId The unique identifier for the group + * @return Zend_Gdata_Gapps_GroupEntry The group entry as returned by the server. + */ + public function retrieveGroup($groupId) + { + $query = $this->newGroupQuery($groupId); + //$query->setGroupId($groupId); + + try { + $group = $this->getGroupEntry($query); + } catch (Zend_Gdata_Gapps_ServiceException $e) { + // Set the group to null if not found + if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) { + $group = null; + } else { + throw $e; + } + } + return $group; + } + + /** + * Retrieve all groups in the current domain. Be aware that + * calling this function on a domain with many groups will take a + * signifigant amount of time to complete. On larger domains this may + * may cause execution to timeout without proper precautions in place. + * + * @return Zend_Gdata_Gapps_GroupFeed Collection of Zend_Gdata_GroupEntry objects + * representing all groups apart of the domain. + */ + public function retrieveAllGroups() + { + return $this->retrieveAllEntriesForFeed($this->retrievePageOfGroups()); + } + + /** + * Delete a group + * + * @param string $groupId The unique identifier for the group + */ + public function deleteGroup($groupId) + { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId; + + $this->delete($uri); + } + + /** + * Check to see if a member id or group id is a member of group + * + * @param string $memberId Member id or group group id + * @param string $groupId Group to be checked for + * @return bool True, if given entity is a member + */ + public function isMember($memberId, $groupId) + { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId . '/member/' . $memberId; + + //if the enitiy is not a member, an exception is thrown + try { + $results = $this->get($uri); + } catch (Exception $e) { + $results = false; + } + + if($results) { + return TRUE; + } else { + return FALSE; + } + } + + /** + * Add an email address to a group as a member + * + * @param string $recipientAddress Email address, member id, or group id + * @param string $groupId The unique id of the group + * @return Zend_Gdata_Gapps_MemberEntry The member entry returned by the server + */ + public function addMemberToGroup($recipientAddress, $groupId) + { + $member = $this->newMemberEntry(); + + $properties[] = $this->newProperty(); + $properties[0]->name = 'memberId'; + $properties[0]->value = $recipientAddress; + + $member->property = $properties; + + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId . '/member'; + + return $this->insertMember($member, $uri); + } + + /** + * Remove a member id from a group + * + * @param string $memberId Member id or group id + * @param string $groupId The unique id of the group + */ + public function removeMemberFromGroup($memberId, $groupId) + { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId . '/member/' . $memberId; + + return $this->delete($uri); + } + + /** + * Retrieves all the members of a group + * + * @param string $groupId The unique id of the group + * @return Zend_Gdata_Gapps_MemberFeed Collection of MemberEntry objects + * representing all members apart of the group. + */ + public function retrieveAllMembers($groupId) + { + return $this->retrieveAllEntriesForFeed( + $this->retrievePageOfMembers($groupId)); + } + + /** + * Add an email as an owner of a group + * + * @param string $email Owner's email + * @param string $groupId Group ownership to be checked for + * @return Zend_Gdata_Gapps_OwnerEntry The OwnerEntry returned by the server + */ + public function addOwnerToGroup($email, $groupId) + { + $owner = $this->newOwnerEntry(); + + $properties[] = $this->newProperty(); + $properties[0]->name = 'email'; + $properties[0]->value = $email; + + $owner->property = $properties; + + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId . '/owner'; + + return $this->insertOwner($owner, $uri); + } + + /** + * Retrieves all the owners of a group + * + * @param string $groupId The unique identifier for the group + * @return Zend_Gdata_Gapps_OwnerFeed Collection of Zend_Gdata_OwnerEntry + * objects representing all owners apart of the group. + */ + public function retrieveGroupOwners($groupId) + { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId . '/owner'; + + return $this->getOwnerFeed($uri); + } + + /** + * Checks to see if an email is an owner of a group + * + * @param string $email Owner's email + * @param string $groupId Group ownership to be checked for + * @return bool True, if given entity is an owner + */ + public function isOwner($email, $groupId) + { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId . '/owner/' . $email; + + //if the enitiy is not an owner of the group, an exception is thrown + try { + $results = $this->get($uri); + } catch (Exception $e) { + $results = false; + } + + if($results) { + return TRUE; + } else { + return FALSE; + } + } + + /** + * Remove email as an owner of a group + * + * @param string $email Owner's email + * @param string $groupId The unique identifier for the group + */ + public function removeOwnerFromGroup($email, $groupId) + { + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId . '/owner/' . $email; + + return $this->delete($uri); + } + + /** + * Update group properties with new values. any property not defined will not + * be updated + * + * @param string $groupId A unique identifier for the group + * @param string $groupName The name of the group + * @param string $description A description of the group + * @param string $emailPermission The subscription permission of the group + * @return Zend_Gdata_Gapps_GroupEntry The group entry as updated on the server. + */ + public function updateGroup($groupId, $groupName = null, $description = null, + $emailPermission = null) + { + $i = 0; + $group = $this->newGroupEntry(); + + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'groupId'; + $properties[$i]->value = $groupId; + $i++; + + if($groupName != null) { + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'groupName'; + $properties[$i]->value = $groupName; + $i++; + } + + if($description != null) { + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'description'; + $properties[$i]->value = $description; + $i++; + } + + if($emailPermission != null) { + $properties[$i] = $this->newProperty(); + $properties[$i]->name = 'emailPermission'; + $properties[$i]->value = $emailPermission; + $i++; + } + + $group->property = $properties; + + $uri = self::APPS_BASE_FEED_URI . self::APPS_GROUP_PATH . '/'; + $uri .= $this->getDomain() . '/' . $groupId; + + return $this->updateEntry($group, $uri, 'Zend_Gdata_Gapps_GroupEntry'); + } + + /** + * Retrieve all of the groups that a user is a member of + * + * @param string $memberId Member username + * @param bool $directOnly (Optional) If true, members with direct association + * only will be considered + * @return Zend_Gdata_Gapps_GroupFeed Collection of Zend_Gdata_GroupEntry + * objects representing all groups member is apart of in the domain. + */ + public function retrieveGroups($memberId, $directOnly = null) + { + $query = $this->newGroupQuery(); + $query->setMember($memberId); + if($directOnly != null) { + $query->setDirectOnly($directOnly); + } + return $this->getGroupFeed($query); + } + + /** + * Retrieve a page of groups in alphabetical order, starting with the + * provided group. + * + * @param string $startGroup (optional) The first group to + * retrieve. If null or not defined, the page will begin + * with the first group in the domain. + * @return Zend_Gdata_Gapps_GroupFeed Collection of Zend_Gdata_GroupEntry + * objects representing the groups in the domain. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrievePageOfGroups ($startGroup = null) + { + $query = $this->newGroupQuery(); + $query->setStartGroupId($startGroup); + return $this->getGroupFeed($query); + } + + /** + * Gets page of Members + * + * @param string $groupId The group id which should be searched. + * @param string $startMember (optinal) The address of the first member, + * or null to start with the first member in the list. + * @return Zend_Gdata_Gapps_MemberFeed Collection of Zend_Gdata_MemberEntry + * objects + */ + public function retrievePageOfMembers($groupId, $startMember = null) + { + $query = $this->newMemberQuery($groupId); + $query->setStartMemberId($startMember); + return $this->getMemberFeed($query); + } + + /** + * Create a new email list. + * + * @param string $emailList The name of the email list to be created. + * @return Zend_Gdata_Gapps_EmailListEntry The email list entry + * as created on the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function createEmailList($emailList) { + $entry = $this->newEmailListEntry(); + $list = $this->newEmailList(); + $list->name = $emailList; + $entry->emailList = $list; + return $this->insertEmailList($entry); + } + + /** + * Retrieve all email lists associated with a recipient. + * + * @param string $username The recipient whose associated email lists + * should be returned. + * @return Zend_Gdata_Gapps_EmailListFeed The list of email lists found as + * Zend_Gdata_EmailListEntry objects. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrieveEmailLists($recipient) { + $query = $this->newEmailListQuery(); + $query->recipient = $recipient; + return $this->getEmailListFeed($query); + } + + /** + * Retrieve a page of email lists in alphabetical order, starting with the + * provided email list. + * + * @param string $startEmailListName (optional) The first list to + * retrieve. If null or not defined, the page will begin + * with the first email list in the domain. + * @return Zend_Gdata_Gapps_EmailListFeed Collection of Zend_Gdata_EmailListEntry + * objects representing all nicknames in the domain. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrievePageOfEmailLists ($startNickname = null) { + $query = $this->newEmailListQuery(); + $query->setStartEmailListName($startNickname); + return $this->getEmailListFeed($query); + } + + /** + * Retrieve all email lists associated with the curent domain. Be aware that + * calling this function on a domain with many email lists will take a + * signifigant amount of time to complete. On larger domains this may + * may cause execution to timeout without proper precautions in place. + * + * @return Zend_Gdata_Gapps_EmailListFeed The list of email lists found + * as Zend_Gdata_Gapps_EmailListEntry objects. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrieveAllEmailLists() { + return $this->retrieveAllEntriesForFeed($this->retrievePageOfEmailLists()); + } + + /** + * Delete a specified email list. + * + * @param string $emailList The name of the emailList to be deleted. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function deleteEmailList($emailList) { + $this->delete($this->getBaseUrl() . self::APPS_EMAIL_LIST_PATH . '/' + . $emailList); + } + + /** + * Add a specified recipient to an existing emailList. + * + * @param string $recipientAddress The address of the recipient to be + * added to the email list. + * @param string $emailList The name of the email address to which the + * recipient should be added. + * @return Zend_Gdata_Gapps_EmailListRecipientEntry The recipient entry + * created by the server. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function addRecipientToEmailList($recipientAddress, $emailList) { + $entry = $this->newEmailListRecipientEntry(); + $who = $this->newWho(); + $who->email = $recipientAddress; + $entry->who = $who; + $address = $this->getBaseUrl() . self::APPS_EMAIL_LIST_PATH . '/' . + $emailList . self::APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/'; + return $this->insertEmailListRecipient($entry, $address); + } + + /** + * Retrieve a page of email list recipients in alphabetical order, + * starting with the provided email list recipient. + * + * @param string $emaiList The email list which should be searched. + * @param string $startRecipient (optinal) The address of the first + * recipient, or null to start with the first recipient in + * the list. + * @return Zend_Gdata_Gapps_EmailListRecipientFeed Collection of + * Zend_Gdata_EmailListRecipientEntry objects representing all + * recpients in the specified list. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrievePageOfRecipients ($emailList, + $startRecipient = null) { + $query = $this->newEmailListRecipientQuery(); + $query->setEmailListName($emailList); + $query->setStartRecipient($startRecipient); + return $this->getEmailListRecipientFeed($query); + } + + /** + * Retrieve all recipients associated with an email list. Be aware that + * calling this function on a domain with many email lists will take a + * signifigant amount of time to complete. On larger domains this may + * may cause execution to timeout without proper precautions in place. + * + * @param string $emaiList The email list which should be searched. + * @return Zend_Gdata_Gapps_EmailListRecipientFeed The list of email lists + * found as Zend_Gdata_Gapps_EmailListRecipientEntry objects. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function retrieveAllRecipients($emailList) { + return $this->retrieveAllEntriesForFeed( + $this->retrievePageOfRecipients($emailList)); + } + + /** + * Remove a specified recipient from an email list. + * + * @param string $recipientAddress The recipient to be removed. + * @param string $emailList The list from which the recipient should + * be removed. + * @throws Zend_Gdata_App_Exception + * @throws Zend_Gdata_App_HttpException + * @throws Zend_Gdata_Gapps_ServiceException + */ + public function removeRecipientFromEmailList($recipientAddress, $emailList) { + $this->delete($this->getBaseUrl() . self::APPS_EMAIL_LIST_PATH . '/' + . $emailList . self::APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/' + . $recipientAddress); + } + +} diff --git a/webmail/program/lib/Zend/Gdata/Gapps/EmailListEntry.php b/webmail/program/lib/Zend/Gdata/Gapps/EmailListEntry.php new file mode 100644 index 0000000..b31e43f --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/EmailListEntry.php @@ -0,0 +1,214 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailListEntry.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Entry + */ +require_once 'Zend/Gdata/Entry.php'; + +/** + * @see Zend_Gdata_Extension_FeedLink + */ +require_once 'Zend/Gdata/Extension/FeedLink.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_EmailList + */ +require_once 'Zend/Gdata/Gapps/Extension/EmailList.php'; + +/** + * Data model class for a Google Apps Email List Entry. + * + * Each email list entry describes a single email list within a Google Apps + * hosted domain. Email lists may contain multiple recipients, as + * described by instances of Zend_Gdata_Gapps_EmailListRecipient. Multiple + * entries are contained within instances of Zend_Gdata_Gapps_EmailListFeed. + * + * To transfer email list entries to and from the Google Apps servers, + * including creating new entries, refer to the Google Apps service class, + * Zend_Gdata_Gapps. + * + * This class represents <atom:entry> 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'; + + /** + * <apps:emailList> child element containing general information about + * this email list. + * + * @var Zend_Gdata_Gapps_Extension_EmailList + */ + protected $_emailList = null; + + /** + * <gd:feedLink> 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 <apps:emailList> 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 <gd:feedLink> 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/webmail/program/lib/Zend/Gdata/Gapps/EmailListFeed.php b/webmail/program/lib/Zend/Gdata/Gapps/EmailListFeed.php new file mode 100644 index 0000000..92fde8b --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/EmailListFeed.php @@ -0,0 +1,53 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailListFeed.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Feed + */ +require_once 'Zend/Gdata/Feed.php'; + +/** + * @see Zend_Gdata_Gapps_EmailListEntry + */ +require_once 'Zend/Gdata/Gapps/EmailListEntry.php'; + +/** + * Data model for a collection of Google Apps email list entries, usually + * provided by the Google Apps servers. + * + * For information on requesting this feed from a server, see the Google + * Apps service class, Zend_Gdata_Gapps. + * + * @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_EmailListFeed extends Zend_Gdata_Feed +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_EmailListEntry'; + protected $_feedClassName = 'Zend_Gdata_Gapps_EmailListFeed'; + +} diff --git a/webmail/program/lib/Zend/Gdata/Gapps/EmailListQuery.php b/webmail/program/lib/Zend/Gdata/Gapps/EmailListQuery.php new file mode 100644 index 0000000..2502824 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/EmailListQuery.php @@ -0,0 +1,187 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailListQuery.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Gapps_Query + */ +require_once('Zend/Gdata/Gapps/Query.php'); + +/** + * Assists in constructing queries for Google Apps email list entries. + * Instances of this class can be provided in many places where a URL is + * required. + * + * For information on submitting queries to a server, see the Google Apps + * service class, Zend_Gdata_Gapps. + * + * @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_EmailListQuery extends Zend_Gdata_Gapps_Query +{ + + /** + * A string which, if not null, indicates which email list should + * be retrieved by this query. + * + * @var string + */ + protected $_emailListName = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + * @param string $emailListName (optional) Value for the emailListName + * property. + * @param string $recipient (optional) Value for the recipient + * property. + * @param string $startEmailListName (optional) Value for the + * startEmailListName property. + */ + public function __construct($domain = null, $emailListName = null, + $recipient = null, $startEmailListName = null) + { + parent::__construct($domain); + $this->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/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientEntry.php b/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientEntry.php new file mode 100644 index 0000000..961afd0 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientEntry.php @@ -0,0 +1,146 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailListRecipientEntry.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Entry + */ +require_once 'Zend/Gdata/Entry.php'; + +/** + * @see Zend_Gdata_Extension_Who + */ +require_once 'Zend/Gdata/Extension/Who.php'; + +/** + * Data model class for a Google Apps Email List Recipient Entry. + * + * Each instance of this class represents a recipient of an email list + * hosted on a Google Apps domain. Each email list may contain multiple + * recipients. Email lists themselves are described by + * Zend_Gdata_EmailListEntry. Multiple recipient entries are contained within + * instances of Zend_Gdata_Gapps_EmailListRecipientFeed. + * + * To transfer email list recipients to and from the Google Apps servers, + * including creating new recipients, refer to the Google Apps service class, + * Zend_Gdata_Gapps. + * + * This class represents <atom:entry> 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'; + + /** + * <gd:who> 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/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientFeed.php b/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientFeed.php new file mode 100644 index 0000000..8f17984 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientFeed.php @@ -0,0 +1,53 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailListRecipientFeed.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Feed + */ +require_once 'Zend/Gdata/Feed.php'; + +/** + * @see Zend_Gdata_Gapps_EmailListRecipientEntry + */ +require_once 'Zend/Gdata/Gapps/EmailListRecipientEntry.php'; + +/** + * Data model for a collection of Google Apps email list recipient entries, + * usually provided by the Google Apps servers. + * + * For information on requesting this feed from a server, see the Google + * Apps service class, Zend_Gdata_Gapps. + * + * @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_EmailListRecipientFeed extends Zend_Gdata_Feed +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_EmailListRecipientEntry'; + protected $_feedClassName = 'Zend_Gdata_Gapps_EmailListRecipientFeed'; + +} diff --git a/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientQuery.php b/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientQuery.php new file mode 100644 index 0000000..94ad16c --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/EmailListRecipientQuery.php @@ -0,0 +1,153 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailListRecipientQuery.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Gapps_Query + */ +require_once('Zend/Gdata/Gapps/Query.php'); + +/** + * Assists in constructing queries for Google Apps email list recipient + * entries. Instances of this class can be provided in many places where a + * URL is required. + * + * For information on submitting queries to a server, see the Google Apps + * service class, Zend_Gdata_Gapps. + * + * @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_EmailListRecipientQuery extends Zend_Gdata_Gapps_Query +{ + + /** + * If not null, specifies the name of the email list which + * should be requested by this query. + * + * @var string + */ + protected $_emailListName = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + * @param string $emailListName (optional) Value for the emailListName + * property. + * @param string $startRecipient (optional) Value for the + * startRecipient property. + */ + public function __construct($domain = null, $emailListName = null, + $startRecipient = null) + { + parent::__construct($domain); + $this->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/webmail/program/lib/Zend/Gdata/Gapps/Error.php b/webmail/program/lib/Zend/Gdata/Gapps/Error.php new file mode 100644 index 0000000..7a7a73f --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Error.php @@ -0,0 +1,233 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: Error.php 24593 2012-01-05 20:35:02Z matthew $ + */ + + +/** + * Zend_Gdata_App_Base + */ +require_once 'Zend/Gdata/App/Base.php'; + +/** + * Gdata Gapps Error class. This class is used to represent errors returned + * within an AppsForYourDomainErrors message received from the Google Apps + * servers. + * + * Several different errors may be represented by this class, determined by + * the error code returned by the server. For a list of error codes + * available at the time of this writing, see getErrorCode. + * + * @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_Error extends Zend_Gdata_App_Base +{ + + // Error codes as defined at + // http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_d + + const UNKNOWN_ERROR = 1000; + const USER_DELETED_RECENTLY = 1100; + const USER_SUSPENDED = 1101; + const DOMAIN_USER_LIMIT_EXCEEDED = 1200; + const DOMAIN_ALIAS_LIMIT_EXCEEDED = 1201; + const DOMAIN_SUSPENDED = 1202; + const DOMAIN_FEATURE_UNAVAILABLE = 1203; + const ENTITY_EXISTS = 1300; + const ENTITY_DOES_NOT_EXIST = 1301; + const ENTITY_NAME_IS_RESERVED = 1302; + const ENTITY_NAME_NOT_VALID = 1303; + const INVALID_GIVEN_NAME = 1400; + const INVALID_FAMILY_NAME = 1401; + const INVALID_PASSWORD = 1402; + const INVALID_USERNAME = 1403; + const INVALID_HASH_FUNCTION_NAME = 1404; + const INVALID_HASH_DIGEST_LENGTH = 1405; + const INVALID_EMAIL_ADDRESS = 1406; + const INVALID_QUERY_PARAMETER_VALUE = 1407; + const TOO_MANY_RECIPIENTS_ON_EMAIL_LIST = 1500; + + protected $_errorCode = null; + protected $_reason = null; + protected $_invalidInput = null; + + public function __construct($errorCode = null, $reason = null, + $invalidInput = null) { + parent::__construct("Google Apps error received: $errorCode ($reason)"); + $this->_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/webmail/program/lib/Zend/Gdata/Gapps/Extension/EmailList.php b/webmail/program/lib/Zend/Gdata/Gapps/Extension/EmailList.php new file mode 100644 index 0000000..0fa1bdf --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Extension/EmailList.php @@ -0,0 +1,144 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailList.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Extension + */ +require_once 'Zend/Gdata/Extension.php'; + +/** + * @see Zend_Gdata_Gapps + */ +require_once 'Zend/Gdata/Gapps.php'; + +/** + * Represents the apps:emailList element used by the Apps data API. This + * class represents properties of an email list and is usually contained + * within an instance of Zend_Gdata_Gapps_EmailListEntry. + * + * @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_Extension_EmailList extends Zend_Gdata_Extension +{ + + protected $_rootNamespace = 'apps'; + protected $_rootElement = 'emailList'; + + /** + * The name of the email list. This name is used as the email address + * for this list. + * + * @var string + */ + protected $_name = null; + + /** + * Constructs a new Zend_Gdata_Gapps_Extension_EmailList object. + * + * @param string $name (optional) The name to be used for this email list. + */ + public function __construct($name = null) + { + $this->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/webmail/program/lib/Zend/Gdata/Gapps/Extension/Login.php b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Login.php new file mode 100644 index 0000000..f958581 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Login.php @@ -0,0 +1,485 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: Login.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Extension + */ +require_once 'Zend/Gdata/Extension.php'; + +/** + * @see Zend_Gdata_Gapps + */ +require_once 'Zend/Gdata/Gapps.php'; + +/** + * Represents the apps:login element used by the Apps data API. This + * class is used to describe properties of a user, and is usually contained + * within instances of Zene_Gdata_Gapps_UserEntry or any other class + * which is linked to a particular username. + * + * @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_Extension_Login extends Zend_Gdata_Extension +{ + + protected $_rootNamespace = 'apps'; + protected $_rootElement = 'login'; + + /** + * The username for this user. This is used as the user's email address + * and when logging in to Google Apps-hosted services. + * + * @var string + */ + protected $_username = null; + + /** + * The password for the user. May be in cleartext or as an SHA-1 + * digest, depending on the value of _hashFunctionName. + * + * @var string + */ + protected $_password = null; + + /** + * Specifies whether the password stored in _password is in cleartext + * or is an SHA-1 digest of a password. If the password is cleartext, + * then this should be null. If the password is an SHA-1 digest, then + * this should be set to 'SHA-1'. + * + * At the time of writing, no other hash functions are supported + * + * @var string + */ + protected $_hashFunctionName = null; + + /** + * True if the user has administrative rights for this domain, false + * otherwise. + * + * @var boolean + */ + protected $_admin = null; + + /** + * True if the user has agreed to the terms of service for Google Apps, + * false otherwise. + * + * @var boolean. + */ + protected $_agreedToTerms = null; + + /** + * True if this user has been suspended, false otherwise. + * + * @var boolean + */ + protected $_suspended = null; + + /** + * True if the user will be required to change their password at + * their next login, false otherwise. + * + * @var boolean + */ + protected $_changePasswordAtNextLogin = null; + + /** + * Constructs a new Zend_Gdata_Gapps_Extension_Login object. + * + * @param string $username (optional) The username to be used for this + * login. + * @param string $password (optional) The password to be used for this + * login. + * @param string $hashFunctionName (optional) The name of the hash + * function used to protect the password, or null if no + * has function has been applied. As of this writing, + * the only valid values are 'SHA-1' or null. + * @param boolean $admin (optional) Whether the user is an administrator + * or not. + * @param boolean $suspended (optional) Whether this login is suspended or not. + * @param boolean $changePasswordAtNextLogin (optional) Whether + * the user is required to change their password at their + * next login. + * @param boolean $agreedToTerms (optional) Whether the user has + * agreed to the terms of service. + */ + public function __construct($username = null, $password = null, + $hashFunctionName = null, $admin = null, $suspended = null, + $changePasswordAtNextLogin = null, $agreedToTerms = null) + { + $this->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/webmail/program/lib/Zend/Gdata/Gapps/Extension/Name.php b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Name.php new file mode 100644 index 0000000..54a17ff --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Name.php @@ -0,0 +1,181 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: Name.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Extension + */ +require_once 'Zend/Gdata/Extension.php'; + +/** + * @see Zend_Gdata_Gapps + */ +require_once 'Zend/Gdata/Gapps.php'; + +/** + * Represents the apps:name element used by the Apps data API. This is used + * to represent a user's full name. This class is usually contained within + * instances of Zend_Gdata_Gapps_UserEntry. + * + * @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_Extension_Name extends Zend_Gdata_Extension +{ + + protected $_rootNamespace = 'apps'; + protected $_rootElement = 'name'; + + /** + * The associated user's family name. + * + * @var string + */ + protected $_familyName = null; + + /** + * The associated user's given name. + * + * @var string + */ + protected $_givenName = null; + + /** + * Constructs a new Zend_Gdata_Gapps_Extension_Name object. + * + * @param string $familyName (optional) The familyName to be set for this + * object. + * @param string $givenName (optional) The givenName to be set for this + * object. + */ + public function __construct($familyName = null, $givenName = null) + { + $this->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/webmail/program/lib/Zend/Gdata/Gapps/Extension/Nickname.php b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Nickname.php new file mode 100644 index 0000000..c321074 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Nickname.php @@ -0,0 +1,142 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: Nickname.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Extension + */ +require_once 'Zend/Gdata/Extension.php'; + +/** + * @see Zend_Gdata_Gapps + */ +require_once 'Zend/Gdata/Gapps.php'; + +/** + * Represents the apps:nickname element used by the Apps data API. This + * is used to describe a nickname's properties, and is usually contained + * within instances of Zend_Gdata_Gapps_NicknameEntry. + * + * @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_Extension_Nickname extends Zend_Gdata_Extension +{ + + protected $_rootNamespace = 'apps'; + protected $_rootElement = 'nickname'; + + /** + * The name of the nickname. This name is used as the email address + * for this nickname. + * + * @var string + */ + protected $_name = null; + + /** + * Constructs a new Zend_Gdata_Gapps_Extension_Nickname object. + * @param string $name (optional) The nickname being represented. + */ + public function __construct($name = null) + { + $this->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/webmail/program/lib/Zend/Gdata/Gapps/Extension/Property.php b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Property.php new file mode 100644 index 0000000..546c511 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Property.php @@ -0,0 +1,179 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: EmailList.php 20096 2010-01-06 02:05:09Z bkarwin $ + */ + +/** + * @see Zend_Gdata_Extension + */ +require_once 'Zend/Gdata/Extension.php'; + +/** + * @see Zend_Gdata_Gapps + */ +require_once 'Zend/Gdata/Gapps.php'; + +/** + * Represents the apps:Property element used by the Apps data API. + * + * @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_Extension_Property extends Zend_Gdata_Extension +{ + + protected $_rootNamespace = 'apps'; + protected $_rootElement = 'property'; + + /** + * The name of the property + * + * @var string + */ + protected $_name = null; + + /** + * The value of the property + * @var string + */ + protected $_value = null; + + /** + * Constructs a new Zend_Gdata_Gapps_Extension_Property object. + * + * @param string $name The name of the property + * @param string $value The value of the property + */ + public function __construct($name = null, $value = null) + { + $this->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/webmail/program/lib/Zend/Gdata/Gapps/Extension/Quota.php b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Quota.php new file mode 100644 index 0000000..95ee0bc --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Extension/Quota.php @@ -0,0 +1,142 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: Quota.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Extension + */ +require_once 'Zend/Gdata/Extension.php'; + +/** + * @see Zend_Gdata_Gapps + */ +require_once 'Zend/Gdata/Gapps.php'; + +/** + * Represents the apps:quota element used by the Apps data API. This is + * used to indicate the amount of storage space available to a user. Quotas + * may not be able to be set, depending on the domain used. This class + * is usually contained within an instance of Zend_Gdata_Gapps_UserEntry. + * + * @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_Extension_Quota extends Zend_Gdata_Extension +{ + + protected $_rootNamespace = 'apps'; + protected $_rootElement = 'quota'; + + /** + * The amount of storage space available to the user in megabytes. + * + * @var integer + */ + protected $_limit = null; + + /** + * Constructs a new Zend_Gdata_Gapps_Extension_Quota object. + * + * @param string $limit (optional) The limit, in bytes, for this quota. + */ + public function __construct($limit = null) + { + $this->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/webmail/program/lib/Zend/Gdata/Gapps/GroupEntry.php b/webmail/program/lib/Zend/Gdata/Gapps/GroupEntry.php new file mode 100644 index 0000000..e8e86d9 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/GroupEntry.php @@ -0,0 +1,158 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Entry + */ +require_once 'Zend/Gdata/Entry.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Property + */ +require_once 'Zend/Gdata/Gapps/Extension/Property.php'; + +/** + * Data model class for a Google Apps Group Entry. + * + * Each group entry describes a single group within a Google Apps hosted + * domain. + * + * To transfer group entries to and from the Google Apps servers, including + * creating new entries, refer to the Google Apps service class, + * Zend_Gdata_Gapps. + * + * This class represents <atom:entry> 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'; + + /** + * <apps:property> 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/webmail/program/lib/Zend/Gdata/Gapps/GroupFeed.php b/webmail/program/lib/Zend/Gdata/Gapps/GroupFeed.php new file mode 100644 index 0000000..eea9e08 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/GroupFeed.php @@ -0,0 +1,53 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Feed + */ +require_once 'Zend/Gdata/Feed.php'; + +/** + * @see Zend_Gdata_Gapps_GroupEntry + */ +require_once 'Zend/Gdata/Gapps/GroupEntry.php'; + +/** + * Data model for a collection of Google Apps group entries, usually + * provided by the Google Apps servers. + * + * For information on requesting this feed from a server, see the Google + * Apps service class, Zend_Gdata_Gapps. + * + * @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_GroupFeed extends Zend_Gdata_Feed +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_GroupEntry'; + protected $_feedClassName = 'Zend_Gdata_Gapps_GroupFeed'; + +}
\ No newline at end of file diff --git a/webmail/program/lib/Zend/Gdata/Gapps/GroupQuery.php b/webmail/program/lib/Zend/Gdata/Gapps/GroupQuery.php new file mode 100644 index 0000000..d11e43c --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/GroupQuery.php @@ -0,0 +1,226 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Gapps_Query + */ +require_once('Zend/Gdata/Gapps/Query.php'); + +/** + * Assists in constructing queries for Google Apps group entries. + * Instances of this class can be provided in many places where a URL is + * required. + * + * For information on submitting queries to a server, see the Google Apps + * service class, Zend_Gdata_Gapps. + * + * @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_GroupQuery extends Zend_Gdata_Gapps_Query +{ + + /** + * If not null, specifies the group id of the group who should be + * retrieved by this query. + * + * @var string + */ + protected $_groupId = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + * @param string $groupId (optional) Value for the groupId property. + * @param string $startGroupName (optional) Value for the + * startGroupName property. + */ + public function __construct($domain = null, $groupId = null, + $startGroupId = null) + { + parent::__construct($domain); + $this->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/webmail/program/lib/Zend/Gdata/Gapps/MemberEntry.php b/webmail/program/lib/Zend/Gdata/Gapps/MemberEntry.php new file mode 100644 index 0000000..3777d7f --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/MemberEntry.php @@ -0,0 +1,159 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Entry + */ +require_once 'Zend/Gdata/Entry.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Property + */ +require_once 'Zend/Gdata/Gapps/Extension/Property.php'; + +/** + * Data model class for a Google Apps Member Entry. + * + * Each member entry describes a single member within a Google Apps hosted + * domain. + * + * To transfer member entries to and from the Google Apps servers, including + * creating new entries, refer to the Google Apps service class, + * Zend_Gdata_Gapps. + * + * This class represents <atom:entry> 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'; + + /** + * <apps:property> 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/webmail/program/lib/Zend/Gdata/Gapps/MemberFeed.php b/webmail/program/lib/Zend/Gdata/Gapps/MemberFeed.php new file mode 100644 index 0000000..dc8d404 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/MemberFeed.php @@ -0,0 +1,53 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Feed + */ +require_once 'Zend/Gdata/Feed.php'; + +/** + * @see Zend_Gdata_Gapps_MemberEntry + */ +require_once 'Zend/Gdata/Gapps/MemberEntry.php'; + +/** + * Data model for a collection of Google Apps member entries, usually + * provided by the Google Apps servers. + * + * For information on requesting this feed from a server, see the Google + * Apps service class, Zend_Gdata_Gapps. + * + * @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_MemberFeed extends Zend_Gdata_Feed +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_MemberEntry'; + protected $_feedClassName = 'Zend_Gdata_Gapps_MemberFeed'; + +} diff --git a/webmail/program/lib/Zend/Gdata/Gapps/MemberQuery.php b/webmail/program/lib/Zend/Gdata/Gapps/MemberQuery.php new file mode 100644 index 0000000..87a0472 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/MemberQuery.php @@ -0,0 +1,194 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Gapps_Query + */ +require_once('Zend/Gdata/Gapps/Query.php'); + +/** + * Assists in constructing queries for Google Apps member entries. + * Instances of this class can be provided in many places where a URL is + * required. + * + * For information on submitting queries to a server, see the Google Apps + * service class, Zend_Gdata_Gapps. + * + * @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_MemberQuery extends Zend_Gdata_Gapps_Query +{ + + /** + * If not null, specifies the group id + * + * @var string + */ + protected $_groupId = null; + + /** + * If not null, specifies the member id of the user who should be + * retrieved by this query. + * + * @var string + */ + protected $_memberId = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + * @param string $groupId (optional) Value for the groupId property. + * @param string $memberId (optional) Value for the memberId property. + * @param string $startMemberId (optional) Value for the + * startMemberId property. + */ + public function __construct($domain = null, $groupId = null, $memberId = null, + $startMemberId = null) + { + parent::__construct($domain); + $this->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/webmail/program/lib/Zend/Gdata/Gapps/NicknameEntry.php b/webmail/program/lib/Zend/Gdata/Gapps/NicknameEntry.php new file mode 100644 index 0000000..0a65ffa --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/NicknameEntry.php @@ -0,0 +1,189 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: NicknameEntry.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Entry + */ +require_once 'Zend/Gdata/Entry.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Login + */ +require_once 'Zend/Gdata/Gapps/Extension/Login.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Nickname + */ +require_once 'Zend/Gdata/Gapps/Extension/Nickname.php'; + +/** + * Data model class for a Google Apps Nickname Entry. + * + * Each nickname entry describes a single nickname within a Google Apps + * hosted domain. Each user may own several nicknames, but each nickname may + * only belong to one user. Multiple entries are contained within instances + * of Zend_Gdata_Gapps_NicknameFeed. + * + * To transfer nickname entries to and from the Google Apps servers, + * including creating new entries, refer to the Google Apps service class, + * Zend_Gdata_Gapps. + * + * This class represents <atom:entry> 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'; + + /** + * <apps:login> element used to hold information about the owner + * of this nickname, including their username. + * + * @var Zend_Gdata_Gapps_Extension_Login + */ + protected $_login = null; + + /** + * <apps:nickname> 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/webmail/program/lib/Zend/Gdata/Gapps/NicknameFeed.php b/webmail/program/lib/Zend/Gdata/Gapps/NicknameFeed.php new file mode 100644 index 0000000..ee9b983 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/NicknameFeed.php @@ -0,0 +1,53 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: NicknameFeed.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Feed + */ +require_once 'Zend/Gdata/Feed.php'; + +/** + * @see Zend_Gdata_Gapps_NicknameEntry + */ +require_once 'Zend/Gdata/Gapps/NicknameEntry.php'; + +/** + * Data model for a collection of Google Apps nickname entries, usually + * provided by the Google Apps servers. + * + * For information on requesting this feed from a server, see the Google + * Apps service class, Zend_Gdata_Gapps. + * + * @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_NicknameFeed extends Zend_Gdata_Feed +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_NicknameEntry'; + protected $_feedClassName = 'Zend_Gdata_Gapps_NicknameFeed'; + +} diff --git a/webmail/program/lib/Zend/Gdata/Gapps/NicknameQuery.php b/webmail/program/lib/Zend/Gdata/Gapps/NicknameQuery.php new file mode 100644 index 0000000..5ea9c48 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/NicknameQuery.php @@ -0,0 +1,186 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: NicknameQuery.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Gapps_Query + */ +require_once('Zend/Gdata/Gapps/Query.php'); + +/** + * Assists in constructing queries for Google Apps nickname entries. + * Instances of this class can be provided in many places where a URL is + * required. + * + * For information on submitting queries to a server, see the Google Apps + * service class, Zend_Gdata_Gapps. + * + * @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_NicknameQuery extends Zend_Gdata_Gapps_Query +{ + + /** + * If not null, indicates the name of the nickname entry which + * should be returned by this query. + * + * @var string + */ + protected $_nickname = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + * @param string $nickname (optional) Value for the nickname + * property. + * @param string $username (optional) Value for the username + * property. + * @param string $startNickname (optional) Value for the + * startNickname property. + */ + public function __construct($domain = null, $nickname = null, + $username = null, $startNickname = null) + { + parent::__construct($domain); + $this->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/webmail/program/lib/Zend/Gdata/Gapps/OwnerEntry.php b/webmail/program/lib/Zend/Gdata/Gapps/OwnerEntry.php new file mode 100644 index 0000000..adb1a36 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/OwnerEntry.php @@ -0,0 +1,158 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Entry + */ +require_once 'Zend/Gdata/Entry.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Property + */ +require_once 'Zend/Gdata/Gapps/Extension/Property.php'; + +/** + * Data model class for a Google Apps Owner Entry. + * + * Each owner entry describes a single owner within a Google Apps hosted + * domain. + * + * To transfer owner entries to and from the Google Apps servers, including + * creating new entries, refer to the Google Apps service class, + * Zend_Gdata_Gapps. + * + * This class represents <atom:entry> 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'; + + /** + * <apps:property> 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/webmail/program/lib/Zend/Gdata/Gapps/OwnerFeed.php b/webmail/program/lib/Zend/Gdata/Gapps/OwnerFeed.php new file mode 100644 index 0000000..97b74df --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/OwnerFeed.php @@ -0,0 +1,53 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Feed + */ +require_once 'Zend/Gdata/Feed.php'; + +/** + * @see Zend_Gdata_Gapps_OwnerEntry + */ +require_once 'Zend/Gdata/Gapps/OwnerEntry.php'; + +/** + * Data model for a collection of Google Apps owner entries, usually + * provided by the Google Apps servers. + * + * For information on requesting this feed from a server, see the Google + * Apps service class, Zend_Gdata_Gapps. + * + * @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_OwnerFeed extends Zend_Gdata_Feed +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_OwnerEntry'; + protected $_feedClassName = 'Zend_Gdata_Gapps_OwnerFeed'; + +} diff --git a/webmail/program/lib/Zend/Gdata/Gapps/OwnerQuery.php b/webmail/program/lib/Zend/Gdata/Gapps/OwnerQuery.php new file mode 100644 index 0000000..4f424d2 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/OwnerQuery.php @@ -0,0 +1,147 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id:$ + */ + +/** + * @see Zend_Gdata_Gapps_Query + */ +require_once('Zend/Gdata/Gapps/Query.php'); + +/** + * Assists in constructing queries for Google Apps owner entries. + * Instances of this class can be provided in many places where a URL is + * required. + * + * For information on submitting queries to a server, see the Google Apps + * service class, Zend_Gdata_Gapps. + * + * @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_OwnerQuery extends Zend_Gdata_Gapps_Query +{ + + /** + * Group owner is refering to + * + * @var string + */ + protected $_groupId = null; + + /** + * The email of the owner + * + * @var string + */ + protected $_ownerEmail = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + * @param string $groupId (optional) Value for the groupId property. + * @param string $ownerEmail (optional) Value for the OwnerEmail property. + */ + public function __construct($domain = null, $groupId = null, $ownerEmail = null) + { + parent::__construct($domain); + $this->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/webmail/program/lib/Zend/Gdata/Gapps/Query.php b/webmail/program/lib/Zend/Gdata/Gapps/Query.php new file mode 100644 index 0000000..ddd7409 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/Query.php @@ -0,0 +1,123 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: Query.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * Zend_Gdata_Query + */ +require_once('Zend/Gdata/Query.php'); + +/** + * Zend_Gdata_Gapps + */ +require_once('Zend/Gdata/Gapps.php'); + +/** + * Assists in constructing queries for Google Apps entries. This class + * provides common methods used by all other Google Apps query classes. + * + * This class should never be instantiated directly. Instead, instantiate a + * class which inherits from this class. + * + * @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 + */ +abstract class Zend_Gdata_Gapps_Query extends Zend_Gdata_Query +{ + + /** + * The domain which is being administered via the Provisioning API. + * + * @var string + */ + protected $_domain = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + */ + public function __construct($domain = null) + { + parent::__construct(); + $this->_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/webmail/program/lib/Zend/Gdata/Gapps/ServiceException.php b/webmail/program/lib/Zend/Gdata/Gapps/ServiceException.php new file mode 100644 index 0000000..e776df9 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/ServiceException.php @@ -0,0 +1,208 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: ServiceException.php 24593 2012-01-05 20:35:02Z matthew $ + */ + + +/** + * Zend_Exception + */ +require_once 'Zend/Exception.php'; + +/** + * Zend_Gdata_Gapps_Error + */ +require_once 'Zend/Gdata/Gapps/Error.php'; + +/** + * Gdata Gapps Exception class. This is thrown when an + * AppsForYourDomainErrors message is received from the Google Apps + * servers. + * + * Several different errors may be represented by this exception. For a list + * of error codes available, see getErrorCode. + * + * @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_ServiceException extends Zend_Exception +{ + + protected $_rootElement = "AppsForYourDomainErrors"; + + /** + * Array of Zend_Gdata_Error objects indexed by error code. + * + * @var array + */ + protected $_errors = array(); + + /** + * Create a new ServiceException. + * + * @return array An array containing a collection of + * Zend_Gdata_Gapps_Error objects. + */ + public function __construct($errors = null) { + parent::__construct("Server errors encountered"); + if ($errors !== null) { + $this->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/webmail/program/lib/Zend/Gdata/Gapps/UserEntry.php b/webmail/program/lib/Zend/Gdata/Gapps/UserEntry.php new file mode 100644 index 0000000..ed7e9e3 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/UserEntry.php @@ -0,0 +1,295 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: UserEntry.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Entry + */ +require_once 'Zend/Gdata/Entry.php'; + +/** + * @see Zend_Gdata_Extension_FeedLink + */ +require_once 'Zend/Gdata/Extension/FeedLink.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Login + */ +require_once 'Zend/Gdata/Gapps/Extension/Login.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Name + */ +require_once 'Zend/Gdata/Gapps/Extension/Name.php'; + +/** + * @see Zend_Gdata_Gapps_Extension_Quota + */ +require_once 'Zend/Gdata/Gapps/Extension/Quota.php'; + +/** + * Data model class for a Google Apps User Entry. + * + * Each user entry describes a single user within a Google Apps hosted + * domain. + * + * To transfer user entries to and from the Google Apps servers, including + * creating new entries, refer to the Google Apps service class, + * Zend_Gdata_Gapps. + * + * This class represents <atom:entry> 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'; + + /** + * <apps:login> element containing information about this user's + * account, including their username and permissions. + * + * @var Zend_Gdata_Gapps_Extension_Login + */ + protected $_login = null; + + /** + * <apps:name> element containing the user's actual name. + * + * @var Zend_Gdata_Gapps_Extension_Name + */ + protected $_name = null; + + /** + * <apps:quotq> element describing any storage quotas in place for + * this user. + * + * @var Zend_Gdata_Gapps_Extension_Quota + */ + protected $_quota = null; + + /** + * <gd:feedLink> 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/webmail/program/lib/Zend/Gdata/Gapps/UserFeed.php b/webmail/program/lib/Zend/Gdata/Gapps/UserFeed.php new file mode 100644 index 0000000..7a295e8 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/UserFeed.php @@ -0,0 +1,53 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: UserFeed.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Feed + */ +require_once 'Zend/Gdata/Feed.php'; + +/** + * @see Zend_Gdata_Gapps_UserEntry + */ +require_once 'Zend/Gdata/Gapps/UserEntry.php'; + +/** + * Data model for a collection of Google Apps user entries, usually + * provided by the Google Apps servers. + * + * For information on requesting this feed from a server, see the Google + * Apps service class, Zend_Gdata_Gapps. + * + * @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_UserFeed extends Zend_Gdata_Feed +{ + + protected $_entryClassName = 'Zend_Gdata_Gapps_UserEntry'; + protected $_feedClassName = 'Zend_Gdata_Gapps_UserFeed'; + +} diff --git a/webmail/program/lib/Zend/Gdata/Gapps/UserQuery.php b/webmail/program/lib/Zend/Gdata/Gapps/UserQuery.php new file mode 100644 index 0000000..2c65a38 --- /dev/null +++ b/webmail/program/lib/Zend/Gdata/Gapps/UserQuery.php @@ -0,0 +1,147 @@ +<?php + +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@zend.com so we can send you a copy immediately. + * + * @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 + * @version $Id: UserQuery.php 24593 2012-01-05 20:35:02Z matthew $ + */ + +/** + * @see Zend_Gdata_Gapps_Query + */ +require_once('Zend/Gdata/Gapps/Query.php'); + +/** + * Assists in constructing queries for Google Apps user entries. + * Instances of this class can be provided in many places where a URL is + * required. + * + * For information on submitting queries to a server, see the Google Apps + * service class, Zend_Gdata_Gapps. + * + * @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_UserQuery extends Zend_Gdata_Gapps_Query +{ + + /** + * If not null, specifies the username of the user who should be + * retrieved by this query. + * + * @var string + */ + protected $_username = null; + + /** + * Create a new instance. + * + * @param string $domain (optional) The Google Apps-hosted domain to use + * when constructing query URIs. + * @param string $username (optional) Value for the username + * property. + * @param string $startUsername (optional) Value for the + * startUsername property. + */ + public function __construct($domain = null, $username = null, + $startUsername = null) + { + parent::__construct($domain); + $this->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; + } + +} |
