CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

View file

@ -0,0 +1,71 @@
<?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_Service
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Zend_Http_Client
*/
require_once 'Zend/Http/Client.php';
/**
* @category Zend
* @package Zend_Service
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Service_Abstract
{
/**
* HTTP Client used to query all web services
*
* @var Zend_Http_Client
*/
protected static $_httpClient = null;
/**
* Sets the HTTP client object to use for retrieving the feeds. If none
* is set, the default Zend_Http_Client will be used.
*
* @param Zend_Http_Client $httpClient
*/
final public static function setHttpClient(Zend_Http_Client $httpClient)
{
self::$_httpClient = $httpClient;
}
/**
* Gets the HTTP client object.
*
* @return Zend_Http_Client
*/
final public static function getHttpClient()
{
if (!self::$_httpClient instanceof Zend_Http_Client) {
self::$_httpClient = new Zend_Http_Client();
}
return self::$_httpClient;
}
}

View file

@ -0,0 +1,387 @@
<?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_Service
* @subpackage Akismet
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Akismet.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Version
*/
require_once 'Zend/Version.php';
/**
* @see Zend_Service_Abstract
*/
require_once 'Zend/Service/Abstract.php';
/**
* Akismet REST service implementation
*
* @uses Zend_Service_Abstract
* @category Zend
* @package Zend_Service
* @subpackage Akismet
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Akismet extends Zend_Service_Abstract
{
/**
* Akismet API key
* @var string
*/
protected $_apiKey;
/**
* Blog URL
* @var string
*/
protected $_blogUrl;
/**
* Charset used for encoding
* @var string
*/
protected $_charset = 'UTF-8';
/**
* TCP/IP port to use in requests
* @var int
*/
protected $_port = 80;
/**
* User Agent string to send in requests
* @var string
*/
protected $_userAgent;
/**
* Constructor
*
* @param string $apiKey Akismet API key
* @param string $blog Blog URL
* @return void
*/
public function __construct($apiKey, $blog)
{
$this->setBlogUrl($blog)
->setApiKey($apiKey)
->setUserAgent('Zend Framework/' . Zend_Version::VERSION . ' | Akismet/1.11');
}
/**
* Retrieve blog URL
*
* @return string
*/
public function getBlogUrl()
{
return $this->_blogUrl;
}
/**
* Set blog URL
*
* @param string $blogUrl
* @return Zend_Service_Akismet
* @throws Zend_Service_Exception if invalid URL provided
*/
public function setBlogUrl($blogUrl)
{
require_once 'Zend/Uri.php';
if (!Zend_Uri::check($blogUrl)) {
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('Invalid url provided for blog');
}
$this->_blogUrl = $blogUrl;
return $this;
}
/**
* Retrieve API key
*
* @return string
*/
public function getApiKey()
{
return $this->_apiKey;
}
/**
* Set API key
*
* @param string $apiKey
* @return Zend_Service_Akismet
*/
public function setApiKey($apiKey)
{
$this->_apiKey = $apiKey;
return $this;
}
/**
* Retrieve charset
*
* @return string
*/
public function getCharset()
{
return $this->_charset;
}
/**
* Set charset
*
* @param string $charset
* @return Zend_Service_Akismet
*/
public function setCharset($charset)
{
$this->_charset = $charset;
return $this;
}
/**
* Retrieve TCP/IP port
*
* @return int
*/
public function getPort()
{
return $this->_port;
}
/**
* Set TCP/IP port
*
* @param int $port
* @return Zend_Service_Akismet
* @throws Zend_Service_Exception if non-integer value provided
*/
public function setPort($port)
{
if (!is_int($port)) {
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('Invalid port');
}
$this->_port = $port;
return $this;
}
/**
* Retrieve User Agent string
*
* @return string
*/
public function getUserAgent()
{
return $this->_userAgent;
}
/**
* Set User Agent
*
* Should be of form "Some user agent/version | Akismet/version"
*
* @param string $userAgent
* @return Zend_Service_Akismet
* @throws Zend_Service_Exception with invalid user agent string
*/
public function setUserAgent($userAgent)
{
if (!is_string($userAgent)
|| !preg_match(":^[^\n/]*/[^ ]* \| Akismet/[0-9\.]*$:i", $userAgent))
{
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('Invalid User Agent string; must be of format "Application name/version | Akismet/version"');
}
$this->_userAgent = $userAgent;
return $this;
}
/**
* Post a request
*
* @param string $host
* @param string $path
* @param array $params
* @return mixed
*/
protected function _post($host, $path, array $params)
{
$uri = 'http://' . $host . ':' . $this->getPort() . $path;
$client = self::getHttpClient();
$client->setUri($uri);
$client->setConfig(array(
'useragent' => $this->getUserAgent(),
));
$client->setHeaders(array(
'Host' => $host,
'Content-Type' => 'application/x-www-form-urlencoded; charset=' . $this->getCharset()
));
$client->setParameterPost($params);
$client->setMethod(Zend_Http_Client::POST);
return $client->request();
}
/**
* Verify an API key
*
* @param string $key Optional; API key to verify
* @param string $blog Optional; blog URL against which to verify key
* @return boolean
*/
public function verifyKey($key = null, $blog = null)
{
if (null === $key) {
$key = $this->getApiKey();
}
if (null === $blog) {
$blog = $this->getBlogUrl();
}
$response = $this->_post('rest.akismet.com', '/1.1/verify-key', array(
'key' => $key,
'blog' => $blog
));
return ('valid' == $response->getBody());
}
/**
* Perform an API call
*
* @param string $path
* @param array $params
* @return Zend_Http_Response
* @throws Zend_Service_Exception if missing user_ip or user_agent fields
*/
protected function _makeApiCall($path, $params)
{
if (empty($params['user_ip']) || empty($params['user_agent'])) {
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('Missing required Akismet fields (user_ip and user_agent are required)');
}
if (!isset($params['blog'])) {
$params['blog'] = $this->getBlogUrl();
}
return $this->_post($this->getApiKey() . '.rest.akismet.com', $path, $params);
}
/**
* Check a comment for spam
*
* Checks a comment to see if it is spam. $params should be an associative
* array with one or more of the following keys (unless noted, all keys are
* optional):
* - blog: URL of the blog. If not provided, uses value returned by {@link getBlogUrl()}
* - user_ip (required): IP address of comment submitter
* - user_agent (required): User Agent used by comment submitter
* - referrer: contents of HTTP_REFERER header
* - permalink: location of the entry to which the comment was submitted
* - comment_type: typically, one of 'blank', 'comment', 'trackback', or 'pingback', but may be any value
* - comment_author: name submitted with the content
* - comment_author_email: email submitted with the content
* - comment_author_url: URL submitted with the content
* - comment_content: actual content
*
* Additionally, Akismet suggests returning the key/value pairs in the
* $_SERVER array, and these may be included in the $params.
*
* This method implements the Akismet comment-check REST method.
*
* @param array $params
* @return boolean
* @throws Zend_Service_Exception with invalid API key
*/
public function isSpam($params)
{
$response = $this->_makeApiCall('/1.1/comment-check', $params);
$return = trim($response->getBody());
if ('invalid' == $return) {
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('Invalid API key');
}
if ('true' == $return) {
return true;
}
return false;
}
/**
* Submit spam
*
* Takes the same arguments as {@link isSpam()}.
*
* Submits known spam content to Akismet to help train it.
*
* This method implements Akismet's submit-spam REST method.
*
* @param array $params
* @return void
* @throws Zend_Service_Exception with invalid API key
*/
public function submitSpam($params)
{
$response = $this->_makeApiCall('/1.1/submit-spam', $params);
$value = trim($response->getBody());
if ('invalid' == $value) {
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('Invalid API key');
}
}
/**
* Submit ham
*
* Takes the same arguments as {@link isSpam()}.
*
* Submits a comment that has been falsely categorized as spam by Akismet
* as a false positive, telling Akismet's filters not to filter such
* comments as spam in the future.
*
* Unlike {@link submitSpam()} and {@link isSpam()}, a valid API key is
* never necessary; as a result, this method never throws an exception
* (unless an exception happens with the HTTP client layer).
*
* this method implements Akismet's submit-ham REST method.
*
* @param array $params
* @return void
*/
public function submitHam($params)
{
$response = $this->_makeApiCall('/1.1/submit-ham', $params);
}
}

View file

@ -0,0 +1,323 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Amazon.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Rest_Client
*/
require_once 'Zend/Rest/Client.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon
{
/**
* Amazon Web Services Access Key ID
*
* @var string
*/
public $appId;
/**
* @var string
*/
protected $_secretKey = null;
/**
* @var string
*/
protected $_baseUri = null;
/**
* List of Amazon Web Service base URLs, indexed by country code
*
* @var array
*/
protected $_baseUriList = array('US' => 'http://webservices.amazon.com',
'UK' => 'http://webservices.amazon.co.uk',
'DE' => 'http://webservices.amazon.de',
'JP' => 'http://webservices.amazon.co.jp',
'FR' => 'http://webservices.amazon.fr',
'CA' => 'http://webservices.amazon.ca');
/**
* Reference to REST client object
*
* @var Zend_Rest_Client
*/
protected $_rest = null;
/**
* Constructs a new Amazon Web Services Client
*
* @param string $appId Developer's Amazon appid
* @param string $countryCode Country code for Amazon service; may be US, UK, DE, JP, FR, CA
* @throws Zend_Service_Exception
* @return Zend_Service_Amazon
*/
public function __construct($appId, $countryCode = 'US', $secretKey = null)
{
$this->appId = (string) $appId;
$this->_secretKey = $secretKey;
$countryCode = (string) $countryCode;
if (!isset($this->_baseUriList[$countryCode])) {
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception("Unknown country code: $countryCode");
}
$this->_baseUri = $this->_baseUriList[$countryCode];
}
/**
* Search for Items
*
* @param array $options Options to use for the Search Query
* @throws Zend_Service_Exception
* @return Zend_Service_Amazon_ResultSet
* @see http://www.amazon.com/gp/aws/sdk/main.html/102-9041115-9057709?s=AWSEcommerceService&v=2005-10-05&p=ApiReference/ItemSearchOperation
*/
public function itemSearch(array $options)
{
$client = $this->getRestClient();
$client->setUri($this->_baseUri);
$defaultOptions = array('ResponseGroup' => 'Small');
$options = $this->_prepareOptions('ItemSearch', $options, $defaultOptions);
$client->getHttpClient()->resetParameters();
$response = $client->restGet('/onca/xml', $options);
if ($response->isError()) {
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('An error occurred sending request. Status code: '
. $response->getStatus());
}
$dom = new DOMDocument();
$dom->loadXML($response->getBody());
self::_checkErrors($dom);
/**
* @see Zend_Service_Amazon_ResultSet
*/
require_once 'Zend/Service/Amazon/ResultSet.php';
return new Zend_Service_Amazon_ResultSet($dom);
}
/**
* Look up item(s) by ASIN
*
* @param string $asin Amazon ASIN ID
* @param array $options Query Options
* @see http://www.amazon.com/gp/aws/sdk/main.html/102-9041115-9057709?s=AWSEcommerceService&v=2005-10-05&p=ApiReference/ItemLookupOperation
* @throws Zend_Service_Exception
* @return Zend_Service_Amazon_Item|Zend_Service_Amazon_ResultSet
*/
public function itemLookup($asin, array $options = array())
{
$client = $this->getRestClient();
$client->setUri($this->_baseUri);
$client->getHttpClient()->resetParameters();
$defaultOptions = array('ResponseGroup' => 'Small');
$options['ItemId'] = (string) $asin;
$options = $this->_prepareOptions('ItemLookup', $options, $defaultOptions);
$response = $client->restGet('/onca/xml', $options);
if ($response->isError()) {
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception(
'An error occurred sending request. Status code: ' . $response->getStatus()
);
}
$dom = new DOMDocument();
$dom->loadXML($response->getBody());
self::_checkErrors($dom);
$xpath = new DOMXPath($dom);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
$items = $xpath->query('//az:Items/az:Item');
if ($items->length == 1) {
/**
* @see Zend_Service_Amazon_Item
*/
require_once 'Zend/Service/Amazon/Item.php';
return new Zend_Service_Amazon_Item($items->item(0));
}
/**
* @see Zend_Service_Amazon_ResultSet
*/
require_once 'Zend/Service/Amazon/ResultSet.php';
return new Zend_Service_Amazon_ResultSet($dom);
}
/**
* Returns a reference to the REST client
*
* @return Zend_Rest_Client
*/
public function getRestClient()
{
if($this->_rest === null) {
$this->_rest = new Zend_Rest_Client();
}
return $this->_rest;
}
/**
* Set REST client
*
* @param Zend_Rest_Client
* @return Zend_Service_Amazon
*/
public function setRestClient(Zend_Rest_Client $client)
{
$this->_rest = $client;
return $this;
}
/**
* Prepare options for request
*
* @param string $query Action to perform
* @param array $options User supplied options
* @param array $defaultOptions Default options
* @return array
*/
protected function _prepareOptions($query, array $options, array $defaultOptions)
{
$options['AWSAccessKeyId'] = $this->appId;
$options['Service'] = 'AWSECommerceService';
$options['Operation'] = (string) $query;
$options['Version'] = '2005-10-05';
// de-canonicalize out sort key
if (isset($options['ResponseGroup'])) {
$responseGroup = explode(',', $options['ResponseGroup']);
if (!in_array('Request', $responseGroup)) {
$responseGroup[] = 'Request';
$options['ResponseGroup'] = implode(',', $responseGroup);
}
}
$options = array_merge($defaultOptions, $options);
if($this->_secretKey !== null) {
$options['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z");;
ksort($options);
$options['Signature'] = self::computeSignature($this->_baseUri, $this->_secretKey, $options);
}
return $options;
}
/**
* Compute Signature for Authentication with Amazon Product Advertising Webservices
*
* @param string $baseUri
* @param string $secretKey
* @param array $options
* @return string
*/
static public function computeSignature($baseUri, $secretKey, array $options)
{
require_once "Zend/Crypt/Hmac.php";
$signature = self::buildRawSignature($baseUri, $options);
return base64_encode(
Zend_Crypt_Hmac::compute($secretKey, 'sha256', $signature, Zend_Crypt_Hmac::BINARY)
);
}
/**
* Build the Raw Signature Text
*
* @param string $baseUri
* @param array $options
* @return string
*/
static public function buildRawSignature($baseUri, $options)
{
ksort($options);
$params = array();
foreach($options AS $k => $v) {
$params[] = $k."=".rawurlencode($v);
}
return sprintf("GET\n%s\n/onca/xml\n%s",
str_replace('http://', '', $baseUri),
implode("&", $params)
);
}
/**
* Check result for errors
*
* @param DOMDocument $dom
* @throws Zend_Service_Exception
* @return void
*/
protected static function _checkErrors(DOMDocument $dom)
{
$xpath = new DOMXPath($dom);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
if ($xpath->query('//az:Error')->length >= 1) {
$code = $xpath->query('//az:Error/az:Code/text()')->item(0)->data;
$message = $xpath->query('//az:Error/az:Message/text()')->item(0)->data;
switch($code) {
case 'AWS.ECommerceService.NoExactMatches':
break;
default:
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception("$message ($code)");
}
}
}
}

View file

@ -0,0 +1,119 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Abstract
*/
require_once 'Zend/Service/Abstract.php';
/**
* Abstract Amazon class that handles the credentials for any of the Web Services that
* Amazon offers
*
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Service_Amazon_Abstract extends Zend_Service_Abstract
{
/**
* @var string Amazon Access Key
*/
protected static $_defaultAccessKey = null;
/**
* @var string Amazon Secret Key
*/
protected static $_defaultSecretKey = null;
/**
* @var string Amazon Secret Key
*/
protected $_secretKey;
/**
* @var string Amazon Access Key
*/
protected $_accessKey;
/**
* Set the keys to use when accessing SQS.
*
* @param string $access_key Set the default Access Key
* @param string $secret_key Set the default Secret Key
* @return void
*/
public static function setKeys($accessKey, $secretKey)
{
self::$_defaultAccessKey = $accessKey;
self::$_defaultSecretKey = $secretKey;
}
/**
* Create Amazon client.
*
* @param string $access_key Override the default Access Key
* @param string $secret_key Override the default Secret Key
* @return void
*/
public function __construct($accessKey=null, $secretKey=null)
{
if(!$accessKey) {
$accessKey = self::$_defaultAccessKey;
}
if(!$secretKey) {
$secretKey = self::$_defaultSecretKey;
}
if(!$accessKey || !$secretKey) {
require_once 'Zend/Service/Amazon/Exception.php';
throw new Zend_Service_Amazon_Exception("AWS keys were not supplied");
}
$this->_accessKey = $accessKey;
$this->_secretKey = $secretKey;
}
/**
* Method to fetch the Access Key
*
* @return string
*/
protected function _getAccessKey()
{
return $this->_accessKey;
}
/**
* Method to fetch the Secret AWS Key
*
* @return string
*/
protected function _getSecretKey()
{
return $this->_secretKey;
}
}

View file

@ -0,0 +1,58 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Accessories.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Accessories
{
/**
* @var string
*/
public $ASIN;
/**
* @var string
*/
public $Title;
/**
* Assigns values to properties relevant to Accessories
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
foreach (array('ASIN', 'Title') as $el) {
$this->$el = (string) $xpath->query("./az:$el/text()", $dom)->item(0)->data;
}
}
}

View file

@ -0,0 +1,86 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CustomerReview.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_CustomerReview
{
/**
* @var string
*/
public $Rating;
/**
* @var string
*/
public $HelpfulVotes;
/**
* @var string
*/
public $CustomerId;
/**
* @var string
*/
public $TotalVotes;
/**
* @var string
*/
public $Date;
/**
* @var string
*/
public $Summary;
/**
* @var string
*/
public $Content;
/**
* Assigns values to properties relevant to CustomerReview
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
foreach (array('Rating', 'HelpfulVotes', 'CustomerId', 'TotalVotes', 'Date', 'Summary', 'Content') as $el) {
$result = $xpath->query("./az:$el/text()", $dom);
if ($result->length == 1) {
$this->$el = (string) $result->item(0)->data;
}
}
}
}

View file

@ -0,0 +1,87 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ec2.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Amazon Ec2 Interface to allow easy creation of the Ec2 Components
*
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2
{
/**
* Factory method to fetch what you want to work with.
*
* @param string $section Create the method that you want to work with
* @param string $key Override the default aws key
* @param string $secret_key Override the default aws secretkey
* @throws Zend_Service_Amazon_Ec2_Exception
* @return object
*/
public static function factory($section, $key = null, $secret_key = null)
{
switch(strtolower($section)) {
case 'keypair':
$class = 'Zend_Service_Amazon_Ec2_Keypair';
break;
case 'eip':
// break left out
case 'elasticip':
$class = 'Zend_Service_Amazon_Ec2_Elasticip';
break;
case 'ebs':
$class = 'Zend_Service_Amazon_Ec2_Ebs';
break;
case 'availabilityzones':
// break left out
case 'zones':
$class = 'Zend_Service_Amazon_Ec2_Availabilityzones';
break;
case 'ami':
// break left out
case 'image':
$class = 'Zend_Service_Amazon_Ec2_Image';
break;
case 'instance':
$class = 'Zend_Service_Amazon_Ec2_Instance';
break;
case 'security':
// break left out
case 'securitygroups':
$class = 'Zend_Service_Amazon_Ec2_Securitygroups';
break;
default:
throw new Zend_Service_Amazon_Ec2_Exception('Invalid Section: ' . $section);
break;
}
if (!class_exists($class)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($class);
}
return new $class($key, $secret_key);
}
}

View file

@ -0,0 +1,277 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Abstract
*/
require_once 'Zend/Service/Amazon/Abstract.php';
/**
* @see Zend_Service_Amazon_Ec2_Response
*/
require_once 'Zend/Service/Amazon/Ec2/Response.php';
/**
* @see Zend_Service_Amazon_Ec2_Exception
*/
require_once 'Zend/Service/Amazon/Ec2/Exception.php';
/**
* Provides the basic functionality to send a request to the Amazon Ec2 Query API
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Service_Amazon_Ec2_Abstract extends Zend_Service_Amazon_Abstract
{
/**
* The HTTP query server
*/
protected $_ec2Endpoint = 'ec2.amazonaws.com';
/**
* The API version to use
*/
protected $_ec2ApiVersion = '2009-04-04';
/**
* Signature Version
*/
protected $_ec2SignatureVersion = '2';
/**
* Signature Encoding Method
*/
protected $_ec2SignatureMethod = 'HmacSHA256';
/**
* Period after which HTTP request will timeout in seconds
*/
protected $_httpTimeout = 10;
/**
* @var string Amazon Region
*/
protected static $_defaultRegion = null;
/**
* @var string Amazon Region
*/
protected $_region;
/**
* An array that contains all the valid Amazon Ec2 Regions.
*
* @var array
*/
protected static $_validEc2Regions = array('eu-west-1', 'us-east-1');
/**
* Create Amazon client.
*
* @param string $access_key Override the default Access Key
* @param string $secret_key Override the default Secret Key
* @param string $region Sets the AWS Region
* @return void
*/
public function __construct($accessKey=null, $secretKey=null, $region=null)
{
if(!$region) {
$region = self::$_defaultRegion;
} else {
// make rue the region is valid
if(!empty($region) && !in_array(strtolower($region), self::$_validEc2Regions, true)) {
require_once 'Zend/Service/Amazon/Exception.php';
throw new Zend_Service_Amazon_Exception('Invalid Amazon Ec2 Region');
}
}
$this->_region = $region;
parent::__construct($accessKey, $secretKey);
}
/**
* Set which region you are working in. It will append the
* end point automaticly
*
* @param string $region
*/
public static function setRegion($region)
{
if(in_array(strtolower($region), self::$_validEc2Regions, true)) {
self::$_defaultRegion = $region;
} else {
require_once 'Zend/Service/Amazon/Exception.php';
throw new Zend_Service_Amazon_Exception('Invalid Amazon Ec2 Region');
}
}
/**
* Method to fetch the AWS Region
*
* @return string
*/
protected function _getRegion()
{
return (!empty($this->_region)) ? $this->_region . '.' : '';
}
/**
* Sends a HTTP request to the queue service using Zend_Http_Client
*
* @param array $params List of parameters to send with the request
* @return Zend_Service_Amazon_Ec2_Response
* @throws Zend_Service_Amazon_Ec2_Exception
*/
protected function sendRequest(array $params = array())
{
$url = 'https://' . $this->_getRegion() . $this->_ec2Endpoint . '/';
$params = $this->addRequiredParameters($params);
try {
/* @var $request Zend_Http_Client */
$request = self::getHttpClient();
$request->resetParameters();
$request->setConfig(array(
'timeout' => $this->_httpTimeout
));
$request->setUri($url);
$request->setMethod(Zend_Http_Client::POST);
$request->setParameterPost($params);
$httpResponse = $request->request();
} catch (Zend_Http_Client_Exception $zhce) {
$message = 'Error in request to AWS service: ' . $zhce->getMessage();
throw new Zend_Service_Amazon_Ec2_Exception($message, $zhce->getCode(), $zhce);
}
$response = new Zend_Service_Amazon_Ec2_Response($httpResponse);
$this->checkForErrors($response);
return $response;
}
/**
* Adds required authentication and version parameters to an array of
* parameters
*
* The required parameters are:
* - AWSAccessKey
* - SignatureVersion
* - Timestamp
* - Version and
* - Signature
*
* If a required parameter is already set in the <tt>$parameters</tt> array,
* it is overwritten.
*
* @param array $parameters the array to which to add the required
* parameters.
*
* @return array
*/
protected function addRequiredParameters(array $parameters)
{
$parameters['AWSAccessKeyId'] = $this->_getAccessKey();
$parameters['SignatureVersion'] = $this->_ec2SignatureVersion;
$parameters['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
$parameters['Version'] = $this->_ec2ApiVersion;
$parameters['SignatureMethod'] = $this->_ec2SignatureMethod;
$parameters['Signature'] = $this->signParameters($parameters);
return $parameters;
}
/**
* Computes the RFC 2104-compliant HMAC signature for request parameters
*
* This implements the Amazon Web Services signature, as per the following
* specification:
*
* 1. Sort all request parameters (including <tt>SignatureVersion</tt> and
* excluding <tt>Signature</tt>, the value of which is being created),
* ignoring case.
*
* 2. Iterate over the sorted list and append the parameter name (in its
* original case) and then its value. Do not URL-encode the parameter
* values before constructing this string. Do not use any separator
* characters when appending strings.
*
* @param array $parameters the parameters for which to get the signature.
* @param string $secretKey the secret key to use to sign the parameters.
*
* @return string the signed data.
*/
protected function signParameters(array $paramaters)
{
$data = "POST\n";
$data .= $this->_getRegion() . $this->_ec2Endpoint . "\n";
$data .= "/\n";
uksort($paramaters, 'strcmp');
unset($paramaters['Signature']);
$arrData = array();
foreach($paramaters as $key => $value) {
$arrData[] = $key . '=' . str_replace("%7E", "~", rawurlencode($value));
}
$data .= implode('&', $arrData);
require_once 'Zend/Crypt/Hmac.php';
$hmac = Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'SHA256', $data, Zend_Crypt_Hmac::BINARY);
return base64_encode($hmac);
}
/**
* Checks for errors responses from Amazon
*
* @param Zend_Service_Amazon_Ec2_Response $response the response object to
* check.
*
* @return void
*
* @throws Zend_Service_Amazon_Ec2_Exception if one or more errors are
* returned from Amazon.
*/
private function checkForErrors(Zend_Service_Amazon_Ec2_Response $response)
{
$xpath = new DOMXPath($response->getDocument());
$list = $xpath->query('//Error');
if ($list->length > 0) {
$node = $list->item(0);
$code = $xpath->evaluate('string(Code/text())', $node);
$message = $xpath->evaluate('string(Message/text())', $node);
throw new Zend_Service_Amazon_Ec2_Exception($message, 0, $code);
}
}
}

View file

@ -0,0 +1,76 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Availabilityzones.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface to query which Availibity Zones your account has access to.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Availabilityzones extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Describes availability zones that are currently available to the account
* and their states.
*
* @param string|array $zoneName Name of an availability zone.
* @return array An array that contains all the return items. Keys: zoneName and zoneState.
*/
public function describe($zoneName = null)
{
$params = array();
$params['Action'] = 'DescribeAvailabilityZones';
if(is_array($zoneName) && !empty($zoneName)) {
foreach($zoneName as $k=>$name) {
$params['ZoneName.' . ($k+1)] = $name;
}
} elseif($zoneName) {
$params['ZoneName.1'] = $zoneName;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:item');
$return = array();
foreach ($nodes as $k => $node) {
$item = array();
$item['zoneName'] = $xpath->evaluate('string(ec2:zoneName/text())', $node);
$item['zoneState'] = $xpath->evaluate('string(ec2:zoneState/text())', $node);
$return[] = $item;
unset($item);
}
return $return;
}
}

View file

@ -0,0 +1,357 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CloudWatch.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface that allows yout to run, terminate, reboot and describe Amazon
* Ec2 Instances.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_CloudWatch extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* The HTTP query server
*/
protected $_ec2Endpoint = 'monitoring.amazonaws.com';
/**
* The API version to use
*/
protected $_ec2ApiVersion = '2009-05-15';
/**
* XML Namespace for the CloudWatch Stuff
*/
protected $_xmlNamespace = 'http://monitoring.amazonaws.com/doc/2009-05-15/';
/**
* The following metrics are available from each EC2 instance.
*
* CPUUtilization: The percentage of allocated EC2 compute units that are
* currently in use on the instance. This metric identifies the processing
* power required to run an application upon a selected instance.
*
* NetworkIn: The number of bytes received on all network interfaces by
* the instance. This metric identifies the volume of incoming network
* traffic to an application on a single instance.
*
* NetworkOut: The number of bytes sent out on all network interfaces
* by the instance. This metric identifies the volume of outgoing network
* traffic to an application on a single instance.
*
* DiskWriteOps: Completed write operations to all hard disks available to
* the instance. This metric identifies the rate at which an application
* writes to a hard disk. This can be used to determine the speed in which
* an application saves data to a hard disk.
*
* DiskReadBytes: Bytes read from all disks available to the instance. This
* metric is used to determine the volume of the data the application reads
* from the hard disk of the instance. This can be used to determine the
* speed of the application for the customer.
*
* DiskReadOps: Completed read operations from all disks available to the
* instances. This metric identifies the rate at which an application reads
* a disk. This can be used to determine the speed in which an application
* reads data from a hard disk.
*
* DiskWriteBytes: Bytes written to all disks available to the instance. This
* metric is used to determine the volume of the data the application writes
* onto the hard disk of the instance. This can be used to determine the speed
* of the application for the customer.
*
* Latency: Time taken between a request and the corresponding response as seen
* by the load balancer.
*
* RequestCount: The number of requests processed by the LoadBalancer.
*
* HealthyHostCount: The number of healthy instances. Both Load Balancing dimensions,
* LoadBalancerName and AvailabilityZone, should be specified when retreiving
* HealthyHostCount.
*
* UnHealthyHostCount: The number of unhealthy instances. Both Load Balancing dimensions,
* LoadBalancerName and AvailabilityZone, should be specified when retreiving
* UnHealthyHostCount.
*
* Amazon CloudWatch data for a new EC2 instance becomes available typically
* within one minute of the end of the first aggregation period for the new
* instance. You can use the currently available dimensions for EC2 instances
* along with these metrics in order to refine the slice of data you want returned,
* such as metric CPUUtilization and dimension ImageId to get all CPUUtilization
* data for instances using the specified AMI.
*
* @var array
*/
protected $_validMetrics = array('CPUUtilization', 'NetworkIn', 'NetworkOut',
'DiskWriteOps', 'DiskReadBytes', 'DiskReadOps',
'DiskWriteBytes', 'Latency', 'RequestCount',
'HealthyHostCount', 'UnHealthyHostCount');
/**
* Amazon CloudWatch not only aggregates the raw data coming in, it also computes
* several statistics on the data. The following table lists the statistics that you can request:
*
* Minimum: The lowest value observed during the specified period. This can be used to
* determine low volumes of activity for your application.
*
* Maximum: The highest value observed during the specified period. You can use this to
* determine high volumes of activity for your application.
*
* Sum: The sum of all values received (if appropriate, for example a rate would not be
* summed, but a number of items would be). This statistic is useful for determining
* the total volume of a metric.
*
* Average: The Average of all values received during the specified period. By comparing
* this statistic with the minimum and maximum statistics, you can determine the full
* scope of a metric and how close the average use is to the minimum and the maximum.
* This will allow you to increase or decrease your resources as needed.
*
* Samples: The count (number) of measures used. This statistic is always returned to
* show the user the size of the dataset collected. This will allow the user to properly
* weight the data.
*
* Statistics are computed within a period you specify, such as all CPUUtilization within a
* five minute period. At a minimum, all data is aggregated into one minute intervals. This
* is the minimum resolution of the data. It is this data that can be aggregated into larger
* periods of time that you request.
*
* Aggregate data is generally available from the service within one minute from the end of the
* aggregation period. Delays in data propagation might cause late or partially late data in
* some cases. If your data is delayed, you should check the services Health Dashboard for
* any current operational issues with either Amazon CloudWatch or the services collecting
* the data, such as EC2 or Elastic Load Balancing.
*
* @var array
*/
protected $_validStatistics = array('Average', 'Maximum', 'Minimum', 'Samples', 'Sum');
/**
* Valid Dimention Keys for getMetricStatistics
*
* ImageId: This dimension filters the data you request for all instances running
* this EC2 Amazon Machine Image (AMI).
*
* AvailabilityZone: This dimension filters the data you request for all instances
* running in that EC2 Availability Zone.
*
* AutoScalingGroupName: This dimension filters the data you request for all instances
* in a specified capacity group. An AutoScalingGroup is a collection of instances
* defined by customers of the Auto Scaling service. This dimension is only available
* for EC2 metrics when the instances are in such an AutoScalingGroup.
*
* InstanceId: This dimension filters the data you request for only the identified
* instance. This allows a user to pinpoint an exact instance from which to monitor data.
*
* InstanceType: This dimension filters the data you request for all instances running
* with this specified instance type. This allows a user to catagorize his data by the
* type of instance running. For example, a user might compare data from an m1.small instance
* and an m1.large instance to determine which has the better business value for his application.
*
* LoadBalancerName: This dimension filters the data you request for the specified LoadBalancer
* name. A LoadBalancer is represented by a DNS name and provides the single destination to
* which all requests intended for your application should be directed. This metric allows
* you to examine data from all instances connected to a single LoadBalancer.
*
* @var array
*/
protected $_validDimensionsKeys = array('ImageId', 'AvailabilityZone', 'AutoScalingGroupName',
'InstanceId', 'InstanceType', 'LoadBalancerName');
/**
* Returns data for one or more statistics of given a metric
*
* Note:
* The maximum number of datapoints that the Amazon CloudWatch service will
* return in a single GetMetricStatistics request is 1,440. If a request is
* made that would generate more datapoints than this amount, Amazon CloudWatch
* will return an error. You can alter your request by narrowing the time range
* (StartTime, EndTime) or increasing the Period in your single request. You may
* also get all of the data at the granularity you originally asked for by making
* multiple requests with adjacent time ranges.
*
* @param array $options The options you want to get statistics for:
* ** Required **
* MeasureName: The measure name that corresponds to
* the measure for the gathered metric. Valid EC2 Values are
* CPUUtilization, NetworkIn, NetworkOut, DiskWriteOps
* DiskReadBytes, DiskReadOps, DiskWriteBytes. Valid Elastic
* Load Balancing Metrics are Latency, RequestCount, HealthyHostCount
* UnHealthyHostCount
* Statistics: The statistics to be returned for the given metric. Valid
* values are Average, Maximum, Minimum, Samples, Sum. You can specify
* this as a string or as an array of values. If you don't specify one
* it will default to Average instead of failing out. If you specify an incorrect
* option it will just skip it.
* ** Optional **
* Dimensions: Amazon CloudWatch allows you to specify one Dimension to further filter
* metric data on. If you don't specify a dimension, the service returns the aggregate
* of all the measures with the given measure name and time range.
* Unit: The standard unit of Measurement for a given Measure. Valid Values: Seconds,
* Percent, Bytes, Bits, Count, Bytes/Second, Bits/Second, Count/Second, and None
* Constraints: When using count/second as the unit, you should use Sum as the statistic
* instead of Average. Otherwise, the sample returns as equal to the number of requests
* instead of the number of 60-second intervals. This will cause the Average to
* always equals one when the unit is count/second.
* StartTime: The timestamp of the first datapoint to return, inclusive. For example,
* 2008-02-26T19:00:00+00:00. We round your value down to the nearest minute.
* You can set your start time for more than two weeks in the past. However,
* you will only get data for the past two weeks. (in ISO 8601 format)
* Constraints: Must be before EndTime
* EndTime: The timestamp to use for determining the last datapoint to return. This is
* the last datapoint to fetch, exclusive. For example, 2008-02-26T20:00:00+00:00.
* (in ISO 8601 format)
*/
public function getMetricStatistics(array $options)
{
$_usedStatistics = array();
$params = array();
$params['Action'] = 'GetMetricStatistics';
if (!isset($options['Period'])) {
$options['Period'] = 60;
}
if (!isset($options['Namespace'])) {
$options['Namespace'] = 'AWS/EC2';
}
if (!isset($options['MeasureName']) || !in_array($options['MeasureName'], $this->_validMetrics, true)) {
throw new Zend_Service_Amazon_Ec2_Exception('Invalid Metric Type: ' . $options['MeasureName']);
}
if(!isset($options['Statistics'])) {
$options['Statistics'][] = 'Average';
} elseif(!is_array($options['Statistics'])) {
$options['Statistics'][] = $options['Statistics'];
}
foreach($options['Statistics'] as $k=>$s) {
if(!in_array($s, $this->_validStatistics, true)) continue;
$options['Statistics.member.' . ($k+1)] = $s;
$_usedStatistics[] = $s;
}
unset($options['Statistics']);
if(isset($options['StartTime'])) {
if(!is_numeric($options['StartTime'])) $options['StartTime'] = strtotime($options['StartTime']);
$options['StartTime'] = gmdate('c', $options['StartTime']);
} else {
$options['StartTime'] = gmdate('c', strtotime('-1 hour'));
}
if(isset($options['EndTime'])) {
if(!is_numeric($options['EndTime'])) $options['EndTime'] = strtotime($options['EndTime']);
$options['EndTime'] = gmdate('c', $options['EndTime']);
} else {
$options['EndTime'] = gmdate('c');
}
if(isset($options['Dimensions'])) {
$x = 1;
foreach($options['Dimensions'] as $dimKey=>$dimVal) {
if(!in_array($dimKey, $this->_validDimensionsKeys, true)) continue;
$options['Dimensions.member.' . $x . '.Name'] = $dimKey;
$options['Dimensions.member.' . $x . '.Value'] = $dimVal;
$x++;
}
unset($options['Dimensions']);
}
$params = array_merge($params, $options);
$response = $this->sendRequest($params);
$response->setNamespace($this->_xmlNamespace);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:GetMetricStatisticsResult/ec2:Datapoints/ec2:member');
$return = array();
$return['label'] = $xpath->evaluate('string(//ec2:GetMetricStatisticsResult/ec2:Label/text())');
foreach ( $nodes as $node ) {
$item = array();
$item['Timestamp'] = $xpath->evaluate('string(ec2:Timestamp/text())', $node);
$item['Unit'] = $xpath->evaluate('string(ec2:Unit/text())', $node);
$item['Samples'] = $xpath->evaluate('string(ec2:Samples/text())', $node);
foreach($_usedStatistics as $us) {
$item[$us] = $xpath->evaluate('string(ec2:' . $us . '/text())', $node);
}
$return['datapoints'][] = $item;
unset($item, $node);
}
return $return;
}
/**
* Return the Metrics that are aviable for your current monitored instances
*
* @param string $nextToken The NextToken parameter is an optional parameter
* that allows you to retrieve the next set of results
* for your ListMetrics query.
* @return array
*/
public function listMetrics($nextToken = null)
{
$params = array();
$params['Action'] = 'ListMetrics';
if (!empty($nextToken)) {
$params['NextToken'] = $nextToken;
}
$response = $this->sendRequest($params);
$response->setNamespace($this->_xmlNamespace);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:ListMetricsResult/ec2:Metrics/ec2:member');
$return = array();
foreach ( $nodes as $node ) {
$item = array();
$item['MeasureName'] = $xpath->evaluate('string(ec2:MeasureName/text())', $node);
$item['Namespace'] = $xpath->evaluate('string(ec2:Namespace/text())', $node);
$item['Deminsions']['name'] = $xpath->evaluate('string(ec2:Dimensions/ec2:member/ec2:Name/text())', $node);
$item['Deminsions']['value'] = $xpath->evaluate('string(ec2:Dimensions/ec2:member/ec2:Value/text())', $node);
if (empty($item['Deminsions']['name'])) {
$item['Deminsions'] = array();
}
$return[] = $item;
unset($item, $node);
}
return $return;
}
}

View file

@ -0,0 +1,342 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Ebs.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface to create, describe, attach, detach and delete Elastic Block
* Storage Volumes and Snaphsots.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Ebs extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Creates a new Amazon EBS volume that you can mount from any Amazon EC2 instance.
*
* You must specify an availability zone when creating a volume. The volume and
* any instance to which it attaches must be in the same availability zone.
*
* @param string $size The size of the volume, in GiB.
* @param string $availabilityZone The availability zone in which to create the new volume.
* @return array
*/
public function createNewVolume($size, $availabilityZone)
{
$params = array();
$params['Action'] = 'CreateVolume';
$params['AvailabilityZone'] = $availabilityZone;
$params['Size'] = $size;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['volumeId'] = $xpath->evaluate('string(//ec2:volumeId/text())');
$return['size'] = $xpath->evaluate('string(//ec2:size/text())');
$return['status'] = $xpath->evaluate('string(//ec2:status/text())');
$return['createTime'] = $xpath->evaluate('string(//ec2:createTime/text())');
$return['availabilityZone'] = $xpath->evaluate('string(//ec2:availabilityZone/text())');
return $return;
}
/**
* Creates a new Amazon EBS volume that you can mount from any Amazon EC2 instance.
*
* You must specify an availability zone when creating a volume. The volume and
* any instance to which it attaches must be in the same availability zone.
*
* @param string $snapshotId The snapshot from which to create the new volume.
* @param string $availabilityZone The availability zone in which to create the new volume.
* @return array
*/
public function createVolumeFromSnapshot($snapshotId, $availabilityZone)
{
$params = array();
$params['Action'] = 'CreateVolume';
$params['AvailabilityZone'] = $availabilityZone;
$params['SnapshotId'] = $snapshotId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['volumeId'] = $xpath->evaluate('string(//ec2:volumeId/text())');
$return['size'] = $xpath->evaluate('string(//ec2:size/text())');
$return['status'] = $xpath->evaluate('string(//ec2:status/text())');
$return['createTime'] = $xpath->evaluate('string(//ec2:createTime/text())');
$return['availabilityZone'] = $xpath->evaluate('string(//ec2:availabilityZone/text())');
$return['snapshotId'] = $xpath->evaluate('string(//ec2:snapshotId/text())');
return $return;
}
/**
* Lists one or more Amazon EBS volumes that you own, If you do not
* specify any volumes, Amazon EBS returns all volumes that you own.
*
* @param string|array $volumeId The ID or array of ID's of the volume(s) to list
* @return array
*/
public function describeVolume($volumeId = null)
{
$params = array();
$params['Action'] = 'DescribeVolumes';
if(is_array($volumeId) && !empty($volumeId)) {
foreach($volumeId as $k=>$name) {
$params['VolumeId.' . ($k+1)] = $name;
}
} elseif($volumeId) {
$params['VolumeId.1'] = $volumeId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:volumeSet/ec2:item', $response->getDocument());
$return = array();
foreach ($nodes as $node) {
$item = array();
$item['volumeId'] = $xpath->evaluate('string(ec2:volumeId/text())', $node);
$item['size'] = $xpath->evaluate('string(ec2:size/text())', $node);
$item['status'] = $xpath->evaluate('string(ec2:status/text())', $node);
$item['createTime'] = $xpath->evaluate('string(ec2:createTime/text())', $node);
$attachmentSet = $xpath->query('ec2:attachmentSet/ec2:item', $node);
if($attachmentSet->length == 1) {
$_as = $attachmentSet->item(0);
$as = array();
$as['volumeId'] = $xpath->evaluate('string(ec2:volumeId/text())', $_as);
$as['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $_as);
$as['device'] = $xpath->evaluate('string(ec2:device/text())', $_as);
$as['status'] = $xpath->evaluate('string(ec2:status/text())', $_as);
$as['attachTime'] = $xpath->evaluate('string(ec2:attachTime/text())', $_as);
$item['attachmentSet'] = $as;
}
$return[] = $item;
unset($item, $node);
}
return $return;
}
public function describeAttachedVolumes($instanceId)
{
$volumes = $this->describeVolume();
$return = array();
foreach($volumes as $vol) {
if(isset($vol['attachmentSet']) && $vol['attachmentSet']['instanceId'] == $instanceId) {
$return[] = $vol;
}
}
return $return;
}
/**
* Attaches an Amazon EBS volume to an instance
*
* @param string $volumeId The ID of the Amazon EBS volume
* @param string $instanceId The ID of the instance to which the volume attaches
* @param string $device Specifies how the device is exposed to the instance (e.g., /dev/sdh).
* @return array
*/
public function attachVolume($volumeId, $instanceId, $device)
{
$params = array();
$params['Action'] = 'AttachVolume';
$params['VolumeId'] = $volumeId;
$params['InstanceId'] = $instanceId;
$params['Device'] = $device;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['volumeId'] = $xpath->evaluate('string(//ec2:volumeId/text())');
$return['instanceId'] = $xpath->evaluate('string(//ec2:instanceId/text())');
$return['device'] = $xpath->evaluate('string(//ec2:device/text())');
$return['status'] = $xpath->evaluate('string(//ec2:status/text())');
$return['attachTime'] = $xpath->evaluate('string(//ec2:attachTime/text())');
return $return;
}
/**
* Detaches an Amazon EBS volume from an instance
*
* @param string $volumeId The ID of the Amazon EBS volume
* @param string $instanceId The ID of the instance from which the volume will detach
* @param string $device The device name
* @param boolean $force Forces detachment if the previous detachment attempt did not occur cleanly
* (logging into an instance, unmounting the volume, and detaching normally).
* This option can lead to data loss or a corrupted file system. Use this option
* only as a last resort to detach an instance from a failed instance. The
* instance will not have an opportunity to flush file system caches nor
* file system meta data.
* @return array
*/
public function detachVolume($volumeId, $instanceId = null, $device = null, $force = false)
{
$params = array();
$params['Action'] = 'DetachVolume';
$params['VolumeId'] = $volumeId;
$params['InstanceId'] = strval($instanceId);
$params['Device'] = strval($device);
$params['Force'] = strval($force);
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['volumeId'] = $xpath->evaluate('string(//ec2:volumeId/text())');
$return['instanceId'] = $xpath->evaluate('string(//ec2:instanceId/text())');
$return['device'] = $xpath->evaluate('string(//ec2:device/text())');
$return['status'] = $xpath->evaluate('string(//ec2:status/text())');
$return['attachTime'] = $xpath->evaluate('string(//ec2:attachTime/text())');
return $return;
}
/**
* Deletes an Amazon EBS volume
*
* @param string $volumeId The ID of the volume to delete
* @return boolean
*/
public function deleteVolume($volumeId)
{
$params = array();
$params['Action'] = 'DeleteVolume';
$params['volumeId'] = $volumeId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
/**
* Creates a snapshot of an Amazon EBS volume and stores it in Amazon S3. You can use snapshots for backups,
* to launch instances from identical snapshots, and to save data before shutting down an instance
*
* @param string $volumeId The ID of the Amazon EBS volume to snapshot
* @return array
*/
public function createSnapshot($volumeId)
{
$params = array();
$params['Action'] = 'CreateSnapshot';
$params['VolumeId'] = $volumeId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['snapshotId'] = $xpath->evaluate('string(//ec2:snapshotId/text())');
$return['volumeId'] = $xpath->evaluate('string(//ec2:volumeId/text())');
$return['status'] = $xpath->evaluate('string(//ec2:status/text())');
$return['startTime'] = $xpath->evaluate('string(//ec2:startTime/text())');
$return['progress'] = $xpath->evaluate('string(//ec2:progress/text())');
return $return;
}
/**
* Describes the status of Amazon EBS snapshots
*
* @param string|array $snapshotId The ID or arry of ID's of the Amazon EBS snapshot
* @return array
*/
public function describeSnapshot($snapshotId = null)
{
$params = array();
$params['Action'] = 'DescribeSnapshots';
if(is_array($snapshotId) && !empty($snapshotId)) {
foreach($snapshotId as $k=>$name) {
$params['SnapshotId.' . ($k+1)] = $name;
}
} elseif($snapshotId) {
$params['SnapshotId.1'] = $snapshotId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:snapshotSet/ec2:item', $response->getDocument());
$return = array();
foreach ($nodes as $node) {
$item = array();
$item['snapshotId'] = $xpath->evaluate('string(ec2:snapshotId/text())', $node);
$item['volumeId'] = $xpath->evaluate('string(ec2:volumeId/text())', $node);
$item['status'] = $xpath->evaluate('string(ec2:status/text())', $node);
$item['startTime'] = $xpath->evaluate('string(ec2:startTime/text())', $node);
$item['progress'] = $xpath->evaluate('string(ec2:progress/text())', $node);
$return[] = $item;
unset($item, $node);
}
return $return;
}
/**
* Deletes a snapshot of an Amazon EBS volume that is stored in Amazon S3
*
* @param string $snapshotId The ID of the Amazon EBS snapshot to delete
* @return boolean
*/
public function deleteSnapshot($snapshotId)
{
$params = array();
$params['Action'] = 'DeleteSnapshot';
$params['SnapshotId'] = $snapshotId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
}

View file

@ -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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Elasticip.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface to allocate, associate, describe and release Elastic IP address
* from your account.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Elasticip extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Acquires an elastic IP address for use with your account
*
* @return string Returns the newly Allocated IP Address
*/
public function allocate()
{
$params = array();
$params['Action'] = 'AllocateAddress';
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$ip = $xpath->evaluate('string(//ec2:publicIp/text())');
return $ip;
}
/**
* Lists elastic IP addresses assigned to your account.
*
* @param string|array $publicIp Elastic IP or list of addresses to describe.
* @return array
*/
public function describe($publicIp = null)
{
$params = array();
$params['Action'] = 'DescribeAddresses';
if(is_array($publicIp) && !empty($publicIp)) {
foreach($publicIp as $k=>$name) {
$params['PublicIp.' . ($k+1)] = $name;
}
} elseif($publicIp) {
$params['PublicIp.1'] = $publicIp;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:item');
$return = array();
foreach ($nodes as $k => $node) {
$item = array();
$item['publicIp'] = $xpath->evaluate('string(ec2:publicIp/text())', $node);
$item['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $node);
$return[] = $item;
unset($item);
}
return $return;
}
/**
* Releases an elastic IP address that is associated with your account
*
* @param string $publicIp IP address that you are releasing from your account.
* @return boolean
*/
public function release($publicIp)
{
$params = array();
$params['Action'] = 'ReleaseAddress';
$params['PublicIp'] = $publicIp;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
/**
* Associates an elastic IP address with an instance
*
* @param string $instanceId The instance to which the IP address is assigned
* @param string $publicIp IP address that you are assigning to the instance.
* @return boolean
*/
public function associate($instanceId, $publicIp)
{
$params = array();
$params['Action'] = 'AssociateAddress';
$params['PublicIp'] = $publicIp;
$params['InstanceId'] = $instanceId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
/**
* Disassociates the specified elastic IP address from the instance to which it is assigned.
* This is an idempotent operation. If you enter it more than once, Amazon EC2 does not return an error.
*
* @param string $publicIp IP address that you are disassociating from the instance.
* @return boolean
*/
public function disassocate($publicIp)
{
$params = array();
$params['Action'] = 'DisssociateAddress';
$params['PublicIp'] = $publicIp;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
}

View file

@ -0,0 +1,51 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Exception
*/
require_once 'Zend/Service/Amazon/Exception.php';
/**
* The Custom Exception class that allows you to have access to the AWS Error Code.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Exception extends Zend_Service_Amazon_Exception
{
private $awsErrorCode = '';
public function __construct($message, $code = 0, $awsErrorCode = '')
{
parent::__construct($message, $code);
$this->awsErrorCode = $awsErrorCode;
}
public function getErrorCode()
{
return $this->awsErrorCode;
}
}

View file

@ -0,0 +1,333 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Image.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface to register, describe and deregister Amamzon Machine Instances (AMI)
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Image extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Registers an AMI with Amazon EC2. Images must be registered before
* they can be launched.
*
* Each AMI is associated with an unique ID which is provided by the Amazon
* EC2 service through the RegisterImage operation. During registration, Amazon
* EC2 retrieves the specified image manifest from Amazon S3 and verifies that
* the image is owned by the user registering the image.
*
* The image manifest is retrieved once and stored within the Amazon EC2.
* Any modifications to an image in Amazon S3 invalidates this registration.
* If you make changes to an image, deregister the previous image and register
* the new image. For more information, see DeregisterImage.
*
* @param string $imageLocation Full path to your AMI manifest in Amazon S3 storage.
* @return string The ami fro the newly registred image;
*/
public function register($imageLocation)
{
$params = array();
$params['Action'] = 'RegisterImage';
$params['ImageLocation']= $imageLocation;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$amiId = $xpath->evaluate('string(//ec2:imageId/text())');
return $amiId;
}
/**
* Returns information about AMIs, AKIs, and ARIs available to the user.
* Information returned includes image type, product codes, architecture,
* and kernel and RAM disk IDs. Images available to the user include public
* images available for any user to launch, private images owned by the user
* making the request, and private images owned by other users for which the
* user has explicit launch permissions.
*
* Launch permissions fall into three categories:
* public: The owner of the AMI granted launch permissions for the AMI
* to the all group. All users have launch permissions for these AMIs.
* explicit: The owner of the AMI granted launch permissions to a specific user.
* implicit: A user has implicit launch permissions for all AMIs he or she owns.
*
* The list of AMIs returned can be modified by specifying AMI IDs, AMI owners,
* or users with launch permissions. If no options are specified, Amazon EC2 returns
* all AMIs for which the user has launch permissions.
*
* If you specify one or more AMI IDs, only AMIs that have the specified IDs are returned.
* If you specify an invalid AMI ID, a fault is returned. If you specify an AMI ID for which
* you do not have access, it will not be included in the returned results.
*
* If you specify one or more AMI owners, only AMIs from the specified owners and for
* which you have access are returned. The results can include the account IDs of the
* specified owners, amazon for AMIs owned by Amazon or self for AMIs that you own.
*
* If you specify a list of executable users, only users that have launch permissions
* for the AMIs are returned. You can specify account IDs (if you own the AMI(s)), self
* for AMIs for which you own or have explicit permissions, or all for public AMIs.
*
* @param string|array $imageId A list of image descriptions
* @param string|array $owner Owners of AMIs to describe.
* @param string|array $executableBy AMIs for which specified users have access.
* @return array
*/
public function describe($imageId = null, $owner = null, $executableBy = null)
{
$params = array();
$params['Action'] = 'DescribeImages';
if(is_array($imageId) && !empty($imageId)) {
foreach($imageId as $k=>$name) {
$params['ImageId.' . ($k+1)] = $name;
}
} elseif($imageId) {
$params['ImageId.1'] = $imageId;
}
if(is_array($owner) && !empty($owner)) {
foreach($owner as $k=>$name) {
$params['Owner.' . ($k+1)] = $name;
}
} elseif($owner) {
$params['Owner.1'] = $owner;
}
if(is_array($executableBy) && !empty($executableBy)) {
foreach($executableBy as $k=>$name) {
$params['ExecutableBy.' . ($k+1)] = $name;
}
} elseif($executableBy) {
$params['ExecutableBy.1'] = $executableBy;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:imagesSet/ec2:item');
$return = array();
foreach ($nodes as $node) {
$item = array();
$item['imageId'] = $xpath->evaluate('string(ec2:imageId/text())', $node);
$item['imageLocation'] = $xpath->evaluate('string(ec2:imageLocation/text())', $node);
$item['imageState'] = $xpath->evaluate('string(ec2:imageState/text())', $node);
$item['imageOwnerId'] = $xpath->evaluate('string(ec2:imageOwnerId/text())', $node);
$item['isPublic'] = $xpath->evaluate('string(ec2:isPublic/text())', $node);
$item['architecture'] = $xpath->evaluate('string(ec2:architecture/text())', $node);
$item['imageType'] = $xpath->evaluate('string(ec2:imageType/text())', $node);
$item['kernelId'] = $xpath->evaluate('string(ec2:kernelId/text())', $node);
$item['ramdiskId'] = $xpath->evaluate('string(ec2:ramdiskId/text())', $node);
$item['platform'] = $xpath->evaluate('string(ec2:platform/text())', $node);
$return[] = $item;
unset($item, $node);
}
return $return;
}
/**
* Deregisters an AMI. Once deregistered, instances of the AMI can no longer be launched.
*
* @param string $imageId Unique ID of a machine image, returned by a call
* to RegisterImage or DescribeImages.
* @return boolean
*/
public function deregister($imageId)
{
$params = array();
$params['Action'] = 'DeregisterImage';
$params['ImageId'] = $imageId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
/**
* Modifies an attribute of an AMI.
*
* Valid Attributes:
* launchPermission: Controls who has permission to launch the AMI. Launch permissions
* can be granted to specific users by adding userIds.
* To make the AMI public, add the all group.
* productCodes: Associates a product code with AMIs. This allows developers to
* charge users for using AMIs. The user must be signed up for the
* product before they can launch the AMI. This is a write once attribute;
* after it is set, it cannot be changed or removed.
*
* @param string $imageId AMI ID to modify.
* @param string $attribute Specifies the attribute to modify. See the preceding
* attributes table for supported attributes.
* @param string $operationType Specifies the operation to perform on the attribute.
* See the preceding attributes table for supported operations for attributes.
* Valid Values: add | remove
* Required for launchPermssion Attribute
*
* @param string|array $userId User IDs to add to or remove from the launchPermission attribute.
* Required for launchPermssion Attribute
* @param string|array $userGroup User groups to add to or remove from the launchPermission attribute.
* Currently, the all group is available, which will make it a public AMI.
* Required for launchPermssion Attribute
* @param string $productCode Attaches a product code to the AMI. Currently only one product code
* can be associated with an AMI. Once set, the product code cannot be changed or reset.
* Required for productCodes Attribute
* @return boolean
*/
public function modifyAttribute($imageId, $attribute, $operationType = 'add', $userId = null, $userGroup = null, $productCode = null)
{
$params = array();
$params['Action'] = 'ModifyImageAttribute';
$parmas['ImageId'] = $imageId;
$params['Attribute'] = $attribute;
switch($attribute) {
case 'launchPermission':
// break left out
case 'launchpermission':
$params['Attribute'] = 'launchPermission';
$params['OperationType'] = $operationType;
if(is_array($userId) && !empty($userId)) {
foreach($userId as $k=>$name) {
$params['UserId.' . ($k+1)] = $name;
}
} elseif($userId) {
$params['UserId.1'] = $userId;
}
if(is_array($userGroup) && !empty($userGroup)) {
foreach($userGroup as $k=>$name) {
$params['UserGroup.' . ($k+1)] = $name;
}
} elseif($userGroup) {
$params['UserGroup.1'] = $userGroup;
}
break;
case 'productCodes':
// break left out
case 'productcodes':
$params['Attribute'] = 'productCodes';
$params['ProductCode.1'] = $productCode;
break;
default:
require_once 'Zend/Service/Amazon/Ec2/Exception.php';
throw new Zend_Service_Amazon_Ec2_Exception('Invalid Attribute Passed In. Valid Image Attributes are launchPermission and productCode.');
break;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
/**
* Returns information about an attribute of an AMI. Only one attribute can be specified per call.
*
* @param string $imageId ID of the AMI for which an attribute will be described.
* @param string $attribute Specifies the attribute to describe. Valid Attributes are
* launchPermission, productCodes
*/
public function describeAttribute($imageId, $attribute)
{
$params = array();
$params['Action'] = 'DescribeImageAttribute';
$params['ImageId'] = $imageId;
$params['Attribute'] = $attribute;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['imageId'] = $xpath->evaluate('string(//ec2:imageId/text())');
// check for launchPermission
if($attribute == 'launchPermission') {
$lPnodes = $xpath->query('//ec2:launchPermission/ec2:item');
if($lPnodes->length > 0) {
$return['launchPermission'] = array();
foreach($lPnodes as $node) {
$return['launchPermission'][] = $xpath->evaluate('string(ec2:userId/text())', $node);
}
}
}
// check for product codes
if($attribute == 'productCodes') {
$pCnodes = $xpath->query('//ec2:productCodes/ec2:item');
if($pCnodes->length > 0) {
$return['productCodes'] = array();
foreach($pCnodes as $node) {
$return['productCodes'][] = $xpath->evaluate('string(ec2:productCode/text())', $node);
}
}
}
return $return;
}
/**
* Resets an attribute of an AMI to its default value. The productCodes attribute cannot be reset
*
* @param string $imageId ID of the AMI for which an attribute will be reset.
* @param String $attribute Specifies the attribute to reset. Currently, only launchPermission is supported.
* In the case of launchPermission, all public and explicit launch permissions for
* the AMI are revoked.
* @return boolean
*/
public function resetAttribute($imageId, $attribute)
{
$params = array();
$params['Action'] = 'ResetImageAttribute';
$params['ImageId'] = $imageId;
$params['Attribute'] = $attribute;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
}

View file

@ -0,0 +1,529 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Instance.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface that allows yout to run, terminate, reboot and describe Amazon
* Ec2 Instances.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Instance extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Constant for Small Instance TYpe
*/
const SMALL = 'm1.small';
/**
* Constant for Large Instance TYpe
*/
const LARGE = 'm1.large';
/**
* Constant for X-Large Instance TYpe
*/
const XLARGE = 'm1.xlarge';
/**
* Constant for High CPU Medium Instance TYpe
*/
const HCPU_MEDIUM = 'c1.medium';
/**
* Constant for High CPU X-Large Instance TYpe
*/
const HCPU_XLARGE = 'c1.xlarge';
/**
* Launches a specified number of Instances.
*
* If Amazon EC2 cannot launch the minimum number AMIs you request, no
* instances launch. If there is insufficient capacity to launch the
* maximum number of AMIs you request, Amazon EC2 launches as many
* as possible to satisfy the requested maximum values.
*
* Every instance is launched in a security group. If you do not specify
* a security group at launch, the instances start in your default security group.
* For more information on creating security groups, see CreateSecurityGroup.
*
* An optional instance type can be specified. For information
* about instance types, see Instance Types.
*
* You can provide an optional key pair ID for each image in the launch request
* (for more information, see CreateKeyPair). All instances that are created
* from images that use this key pair will have access to the associated public
* key at boot. You can use this key to provide secure access to an instance of an
* image on a per-instance basis. Amazon EC2 public images use this feature to
* provide secure access without passwords.
*
* Launching public images without a key pair ID will leave them inaccessible.
*
* @param array $options An array that contins the options to start an instance.
* Required Values:
* imageId string ID of the AMI with which to launch instances.
* Optional Values:
* minCount integer Minimum number of instances to launch.
* maxCount integer Maximum number of instances to launch.
* keyName string Name of the key pair with which to launch instances.
* securityGruop string|array Names of the security groups with which to associate the instances.
* userData string The user data available to the launched instances. This should not be Base64 encoded.
* instanceType constant Specifies the instance type.
* placement string Specifies the availability zone in which to launch the instance(s). By default, Amazon EC2 selects an availability zone for you.
* kernelId string The ID of the kernel with which to launch the instance.
* ramdiskId string The ID of the RAM disk with which to launch the instance.
* blockDeviceVirtualName string Specifies the virtual name to map to the corresponding device name. For example: instancestore0
* blockDeviceName string Specifies the device to which you are mapping a virtual name. For example: sdb
* monitor boolean Turn on CloudWatch Monitoring for an instance.
* @return array
*/
public function run(array $options)
{
$_defaultOptions = array(
'minCount' => 1,
'maxCount' => 1,
'instanceType' => Zend_Service_Amazon_Ec2_Instance::SMALL
);
// set / override the defualt optoins if they are not passed into the array;
$options = array_merge($_defaultOptions, $options);
if(!isset($options['imageId'])) {
require_once 'Zend/Service/Amazon/Ec2/Exception.php';
throw new Zend_Service_Amazon_Ec2_Exception('No Image Id Provided');
}
$params = array();
$params['Action'] = 'RunInstances';
$params['ImageId'] = $options['imageId'];
$params['MinCount'] = $options['minCount'];
$params['MaxCount'] = $options['maxCount'];
if(isset($options['keyName'])) {
$params['KeyName'] = $options['keyName'];
}
if(is_array($options['securityGroup']) && !empty($options['securityGroup'])) {
foreach($options['securityGroup'] as $k=>$name) {
$params['SecurityGroup.' . ($k+1)] = $name;
}
} elseif(isset($options['securityGroup'])) {
$params['SecurityGroup.1'] = $options['securityGroup'];
}
if(isset($options['userData'])) {
$params['UserData'] = base64_encode($options['userData']);
}
if(isset($options['instanceType'])) {
$params['InstanceType'] = $options['instanceType'];
}
if(isset($options['placement'])) {
$params['Placement.AvailabilityZone'] = $options['placement'];
}
if(isset($options['kernelId'])) {
$params['KernelId'] = $options['kernelId'];
}
if(isset($options['ramdiskId'])) {
$params['RamdiskId'] = $options['ramdiskId'];
}
if(isset($options['blockDeviceVirtualName']) && isset($options['blockDeviceName'])) {
$params['BlockDeviceMapping.n.VirtualName'] = $options['blockDeviceVirtualName'];
$params['BlockDeviceMapping.n.DeviceName'] = $options['blockDeviceName'];
}
if(isset($options['monitor']) && $options['monitor'] === true) {
$params['Monitoring.Enabled'] = true;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['reservationId'] = $xpath->evaluate('string(//ec2:reservationId/text())');
$return['ownerId'] = $xpath->evaluate('string(//ec2:ownerId/text())');
$gs = $xpath->query('//ec2:groupSet/ec2:item');
foreach($gs as $gs_node) {
$return['groupSet'][] = $xpath->evaluate('string(ec2:groupId/text())', $gs_node);
unset($gs_node);
}
unset($gs);
$is = $xpath->query('//ec2:instancesSet/ec2:item');
foreach($is as $is_node) {
$item = array();
$item['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $is_node);
$item['imageId'] = $xpath->evaluate('string(ec2:imageId/text())', $is_node);
$item['instanceState']['code'] = $xpath->evaluate('string(ec2:instanceState/ec2:code/text())', $is_node);
$item['instanceState']['name'] = $xpath->evaluate('string(ec2:instanceState/ec2:name/text())', $is_node);
$item['privateDnsName'] = $xpath->evaluate('string(ec2:privateDnsName/text())', $is_node);
$item['dnsName'] = $xpath->evaluate('string(ec2:dnsName/text())', $is_node);
$item['keyName'] = $xpath->evaluate('string(ec2:keyName/text())', $is_node);
$item['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $is_node);
$item['amiLaunchIndex'] = $xpath->evaluate('string(ec2:amiLaunchIndex/text())', $is_node);
$item['launchTime'] = $xpath->evaluate('string(ec2:launchTime/text())', $is_node);
$item['availabilityZone'] = $xpath->evaluate('string(ec2:placement/ec2:availabilityZone/text())', $is_node);
$return['instances'][] = $item;
unset($item);
unset($is_node);
}
unset($is);
return $return;
}
/**
* Returns information about instances that you own.
*
* If you specify one or more instance IDs, Amazon EC2 returns information
* for those instances. If you do not specify instance IDs, Amazon EC2
* returns information for all relevant instances. If you specify an invalid
* instance ID, a fault is returned. If you specify an instance that you do
* not own, it will not be included in the returned results.
*
* Recently terminated instances might appear in the returned results.
* This interval is usually less than one hour.
*
* @param string|array $instaceId Set of instances IDs of which to get the status.
* @param boolean Ture to ignore Terminated Instances.
* @return array
*/
public function describe($instanceId = null, $ignoreTerminated = false)
{
$params = array();
$params['Action'] = 'DescribeInstances';
if(is_array($instanceId) && !empty($instanceId)) {
foreach($instanceId as $k=>$name) {
$params['InstanceId.' . ($k+1)] = $name;
}
} elseif($instanceId) {
$params['InstanceId.1'] = $instanceId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:reservationSet/ec2:item');
$return = array();
$return['instances'] = array();
foreach($nodes as $node) {
if($xpath->evaluate('string(ec2:instancesSet/ec2:item/ec2:instanceState/ec2:code/text())', $node) == 48 && $ignoreTerminated) continue;
$item = array();
$item['reservationId'] = $xpath->evaluate('string(ec2:reservationId/text())', $node);
$item['ownerId'] = $xpath->evaluate('string(ec2:ownerId/text())', $node);
$gs = $xpath->query('ec2:groupSet/ec2:item', $node);
foreach($gs as $gs_node) {
$item['groupSet'][] = $xpath->evaluate('string(ec2:groupId/text())', $gs_node);
unset($gs_node);
}
unset($gs);
$is = $xpath->query('ec2:instancesSet/ec2:item', $node);
foreach($is as $is_node) {
$item['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $is_node);
$item['imageId'] = $xpath->evaluate('string(ec2:imageId/text())', $is_node);
$item['instanceState']['code'] = $xpath->evaluate('string(ec2:instanceState/ec2:code/text())', $is_node);
$item['instanceState']['name'] = $xpath->evaluate('string(ec2:instanceState/ec2:name/text())', $is_node);
$item['privateDnsName'] = $xpath->evaluate('string(ec2:privateDnsName/text())', $is_node);
$item['dnsName'] = $xpath->evaluate('string(ec2:dnsName/text())', $is_node);
$item['keyName'] = $xpath->evaluate('string(ec2:keyName/text())', $is_node);
$item['productCode'] = $xpath->evaluate('string(ec2:productCodesSet/ec2:item/ec2:productCode/text())', $is_node);
$item['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $is_node);
$item['launchTime'] = $xpath->evaluate('string(ec2:launchTime/text())', $is_node);
$item['availabilityZone'] = $xpath->evaluate('string(ec2:placement/ec2:availabilityZone/text())', $is_node);
$item['kernelId'] = $xpath->evaluate('string(ec2:kernelId/text())', $is_node);
$item['ramediskId'] = $xpath->evaluate('string(ec2:ramediskId/text())', $is_node);
$item['amiLaunchIndex'] = $xpath->evaluate('string(ec2:amiLaunchIndex/text())', $is_node);
$item['monitoringState'] = $xpath->evaluate('string(ec2:monitoring/ec2:state/text())', $is_node);
unset($is_node);
}
$return['instances'][] = $item;
unset($item);
unset($is);
}
return $return;
}
/**
* Returns information about instances that you own that were started from
* a specific imageId
*
* Recently terminated instances might appear in the returned results.
* This interval is usually less than one hour.
*
* @param string $imageId The imageId used to start the Instance.
* @param boolean Ture to ignore Terminated Instances.
* @return array
*/
public function describeByImageId($imageId, $ignoreTerminated = false)
{
$arrInstances = $this->describe(null, $ignoreTerminated);
$return = array();
foreach($arrInstances['instances'] as $instance) {
if($instance['imageId'] !== $imageId) continue;
$return[] = $instance;
}
return $return;
}
/**
* Shuts down one or more instances. This operation is idempotent; if you terminate
* an instance more than once, each call will succeed.
*
* Terminated instances will remain visible after termination (approximately one hour).
*
* @param string|array $instanceId One or more instance IDs returned.
* @return array
*/
public function terminate($instanceId)
{
$params = array();
$params['Action'] = 'TerminateInstances';
if(is_array($instanceId) && !empty($instanceId)) {
foreach($instanceId as $k=>$name) {
$params['InstanceId.' . ($k+1)] = $name;
}
} elseif($instanceId) {
$params['InstanceId.1'] = $instanceId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:instancesSet/ec2:item');
$return = array();
foreach($nodes as $node) {
$item = array();
$item['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $node);
$item['shutdownState']['code'] = $xpath->evaluate('string(ec2:shutdownState/ec2:code/text())', $node);
$item['shutdownState']['name'] = $xpath->evaluate('string(ec2:shutdownState/ec2:name/text())', $node);
$item['previousState']['code'] = $xpath->evaluate('string(ec2:previousState/ec2:code/text())', $node);
$item['previousState']['name'] = $xpath->evaluate('string(ec2:previousState/ec2:name/text())', $node);
$return[] = $item;
unset($item);
}
return $return;
}
/**
* Requests a reboot of one or more instances.
*
* This operation is asynchronous; it only queues a request to reboot the specified instance(s). The operation
* will succeed if the instances are valid and belong to the user. Requests to reboot terminated instances are ignored.
*
* @param string|array $instanceId One or more instance IDs.
* @return boolean
*/
public function reboot($instanceId)
{
$params = array();
$params['Action'] = 'RebootInstances';
if(is_array($instanceId) && !empty($instanceId)) {
foreach($instanceId as $k=>$name) {
$params['InstanceId.' . ($k+1)] = $name;
}
} elseif($instanceId) {
$params['InstanceId.1'] = $instanceId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = $xpath->evaluate('string(//ec2:return/text())');
return ($return === "true");
}
/**
* Retrieves console output for the specified instance.
*
* Instance console output is buffered and posted shortly after instance boot, reboot, and termination.
* Amazon EC2 preserves the most recent 64 KB output which will be available for at least one hour after the most recent post.
*
* @param string $instanceId An instance ID
* @return array
*/
public function consoleOutput($instanceId)
{
$params = array();
$params['Action'] = 'GetConsoleOutput';
$params['InstanceId'] = $instanceId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['instanceId'] = $xpath->evaluate('string(//ec2:instanceId/text())');
$return['timestamp'] = $xpath->evaluate('string(//ec2:timestamp/text())');
$return['output'] = base64_decode($xpath->evaluate('string(//ec2:output/text())'));
return $return;
}
/**
* Returns true if the specified product code is attached to the specified instance.
* The operation returns false if the product code is not attached to the instance.
*
* The confirmProduct operation can only be executed by the owner of the AMI.
* This feature is useful when an AMI owner is providing support and wants to
* verify whether a user's instance is eligible.
*
* @param string $productCode The product code to confirm.
* @param string $instanceId The instance for which to confirm the product code.
* @return array|boolean An array if the product code is attached to the instance, false if it is not.
*/
public function confirmProduct($productCode, $instanceId)
{
$params = array();
$params['Action'] = 'ConfirmProductInstance';
$params['ProductCode'] = $productCode;
$params['InstanceId'] = $instanceId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$result = $xpath->evaluate('string(//ec2:result/text())');
if($result === "true") {
$return['result'] = true;
$return['ownerId'] = $xpath->evaluate('string(//ec2:ownerId/text())');
return $return;
}
return false;
}
/**
* Turn on Amazon CloudWatch Monitoring for an instance or a list of instances
*
* @param array|string $instanceId The instance or list of instances you want to enable monitoring for
* @return array
*/
public function monitor($instanceId)
{
$params = array();
$params['Action'] = 'MonitorInstances';
if(is_array($instanceId) && !empty($instanceId)) {
foreach($instanceId as $k=>$name) {
$params['InstanceId.' . ($k+1)] = $name;
}
} elseif($instanceId) {
$params['InstanceId.1'] = $instanceId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$items = $xpath->query('//ec2:instancesSet/ec2:item');
$arrReturn = array();
foreach($items as $item) {
$i = array();
$i['instanceid'] = $xpath->evaluate('string(//ec2:instanceId/text())', $item);
$i['monitorstate'] = $xpath->evaluate('string(//ec2:monitoring/ec2:state/text())');
$arrReturn[] = $i;
unset($i);
}
return $arrReturn;
}
/**
* Turn off Amazon CloudWatch Monitoring for an instance or a list of instances
*
* @param array|string $instanceId The instance or list of instances you want to disable monitoring for
* @return array
*/
public function unmonitor($instanceId)
{
$params = array();
$params['Action'] = 'UnmonitorInstances';
if(is_array($instanceId) && !empty($instanceId)) {
foreach($instanceId as $k=>$name) {
$params['InstanceId.' . ($k+1)] = $name;
}
} elseif($instanceId) {
$params['InstanceId.1'] = $instanceId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$items = $xpath->query('//ec2:instancesSet/ec2:item');
$arrReturn = array();
foreach($items as $item) {
$i = array();
$i['instanceid'] = $xpath->evaluate('string(//ec2:instanceId/text())', $item);
$i['monitorstate'] = $xpath->evaluate('string(//ec2:monitoring/ec2:state/text())');
$arrReturn[] = $i;
unset($i);
}
return $arrReturn;
}
}

View file

@ -0,0 +1,143 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Reserved.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* Allows you to interface with the reserved instances on Amazon Ec2
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Instance_Reserved extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Describes Reserved Instances that you purchased.
*
* @param string|array $instanceId IDs of the Reserved Instance to describe.
* @return array
*/
public function describeInstances($instanceId)
{
$params = array();
$params['Action'] = 'DescribeReservedInstances';
if(is_array($instanceId) && !empty($instanceId)) {
foreach($instanceId as $k=>$name) {
$params['ReservedInstancesId.' . ($k+1)] = $name;
}
} elseif($instanceId) {
$params['ReservedInstancesId.1'] = $instanceId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$items = $xpath->query('//ec2:reservedInstancesSet/ec2:item');
$return = array();
foreach($items as $item) {
$i = array();
$i['reservedInstancesId'] = $xpath->evaluate('string(ec2:reservedInstancesId/text())', $item);
$i['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $item);
$i['availabilityZone'] = $xpath->evaluate('string(ec2:availabilityZone/text())', $item);
$i['duration'] = $xpath->evaluate('string(ec2:duration/text())', $item);
$i['fixedPrice'] = $xpath->evaluate('string(ec2:fixedPrice/text())', $item);
$i['usagePrice'] = $xpath->evaluate('string(ec2:usagePrice/text())', $item);
$i['productDescription'] = $xpath->evaluate('string(ec2:productDescription/text())', $item);
$i['instanceCount'] = $xpath->evaluate('string(ec2:instanceCount/text())', $item);
$i['state'] = $xpath->evaluate('string(ec2:state/text())', $item);
$return[] = $i;
unset($i);
}
return $return;
}
/**
* Describes Reserved Instance offerings that are available for purchase.
* With Amazon EC2 Reserved Instances, you purchase the right to launch Amazon
* EC2 instances for a period of time (without getting insufficient capacity
* errors) and pay a lower usage rate for the actual time used.
*
* @return array
*/
public function describeOfferings()
{
$params = array();
$params['Action'] = 'DescribeReservedInstancesOfferings';
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$items = $xpath->query('//ec2:reservedInstancesOfferingsSet/ec2:item');
$return = array();
foreach($items as $item) {
$i = array();
$i['reservedInstancesOfferingId'] = $xpath->evaluate('string(ec2:reservedInstancesOfferingId/text())', $item);
$i['instanceType'] = $xpath->evaluate('string(ec2:instanceType/text())', $item);
$i['availabilityZone'] = $xpath->evaluate('string(ec2:availabilityZone/text())', $item);
$i['duration'] = $xpath->evaluate('string(ec2:duration/text())', $item);
$i['fixedPrice'] = $xpath->evaluate('string(ec2:fixedPrice/text())', $item);
$i['usagePrice'] = $xpath->evaluate('string(ec2:usagePrice/text())', $item);
$i['productDescription'] = $xpath->evaluate('string(ec2:productDescription/text())', $item);
$return[] = $i;
unset($i);
}
return $return;
}
/**
* Purchases a Reserved Instance for use with your account. With Amazon EC2
* Reserved Instances, you purchase the right to launch Amazon EC2 instances
* for a period of time (without getting insufficient capacity errors) and
* pay a lower usage rate for the actual time used.
*
* @param string $offeringId The offering ID of the Reserved Instance to purchase
* @param integer $intanceCount The number of Reserved Instances to purchase.
* @return string The ID of the purchased Reserved Instances.
*/
public function purchaseOffering($offeringId, $intanceCount = 1)
{
$params = array();
$params['Action'] = 'PurchaseReservedInstancesOffering';
$params['OfferingId.1'] = $offeringId;
$params['instanceCount.1'] = intval($intanceCount);
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$reservedInstancesId = $xpath->evaluate('string(//ec2:reservedInstancesId/text())');
return $reservedInstancesId;
}
}

View file

@ -0,0 +1,195 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Windows.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* @see Zend_Crypt_Hmac
*/
require_once 'Zend/Crypt/Hmac.php';
/**
* @see Zend_Json
*/
require_once 'Zend/Json.php';
/**
* An Amazon EC2 interface that allows yout to run, terminate, reboot and describe Amazon
* Ec2 Instances.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Instance_Windows extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Bundles an Amazon EC2 instance running Windows
*
* @param string $instanceId The instance you want to bundle
* @param string $s3Bucket Where you want the ami to live on S3
* @param string $s3Prefix The prefix you want to assign to the AMI on S3
* @param integer $uploadExpiration The expiration of the upload policy. Amazon recommends 12 hours or longer.
* This is based in nubmer of minutes. Default is 1440 minutes (24 hours)
* @return array containing the information on the new bundle operation
*/
public function bundle($instanceId, $s3Bucket, $s3Prefix, $uploadExpiration = 1440)
{
$params = array();
$params['Action'] = 'BundleInstance';
$params['InstanceId'] = $instanceId;
$params['Storage.S3.AWSAccessKeyId'] = $this->_getAccessKey();
$params['Storage.S3.Bucket'] = $s3Bucket;
$params['Storage.S3.Prefix'] = $s3Prefix;
$uploadPolicy = $this->_getS3UploadPolicy($s3Bucket, $s3Prefix, $uploadExpiration);
$params['Storage.S3.UploadPolicy'] = $uploadPolicy;
$params['Storage.S3.UploadPolicySignature'] = $this->_signS3UploadPolicy($uploadPolicy);
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['instanceId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:instanceId/text())');
$return['bundleId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:bundleId/text())');
$return['state'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:state/text())');
$return['startTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:startTime/text())');
$return['updateTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:updateTime/text())');
$return['progress'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:progress/text())');
$return['storage']['s3']['bucket'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:bucket/text())');
$return['storage']['s3']['prefix'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:prefix/text())');
return $return;
}
/**
* Cancels an Amazon EC2 bundling operation
*
* @param string $bundleId The ID of the bundle task to cancel
* @return array Information on the bundle task
*/
public function cancelBundle($bundleId)
{
$params = array();
$params['Action'] = 'CancelBundleTask';
$params['BundleId'] = $bundleId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['instanceId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:instanceId/text())');
$return['bundleId'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:bundleId/text())');
$return['state'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:state/text())');
$return['startTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:startTime/text())');
$return['updateTime'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:updateTime/text())');
$return['progress'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:progress/text())');
$return['storage']['s3']['bucket'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:bucket/text())');
$return['storage']['s3']['prefix'] = $xpath->evaluate('string(//ec2:bundleInstanceTask/ec2:storage/ec2:S3/ec2:prefix/text())');
return $return;
}
/**
* Describes current bundling tasks
*
* @param string|array $bundleId A single or a list of bundle tasks that you want
* to find information for.
* @return array Information for the task that you requested
*/
public function describeBundle($bundleId = '')
{
$params = array();
$params['Action'] = 'DescribeBundleTasks';
if(is_array($bundleId) && !empty($bundleId)) {
foreach($bundleId as $k=>$name) {
$params['bundleId.' . ($k+1)] = $name;
}
} elseif(!empty($bundleId)) {
$params['bundleId.1'] = $bundleId;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$items = $xpath->evaluate('//ec2:bundleInstanceTasksSet/ec2:item');
$return = array();
foreach($items as $item) {
$i = array();
$i['instanceId'] = $xpath->evaluate('string(ec2:instanceId/text())', $item);
$i['bundleId'] = $xpath->evaluate('string(ec2:bundleId/text())', $item);
$i['state'] = $xpath->evaluate('string(ec2:state/text())', $item);
$i['startTime'] = $xpath->evaluate('string(ec2:startTime/text())', $item);
$i['updateTime'] = $xpath->evaluate('string(ec2:updateTime/text())', $item);
$i['progress'] = $xpath->evaluate('string(ec2:progress/text())', $item);
$i['storage']['s3']['bucket'] = $xpath->evaluate('string(ec2:storage/ec2:S3/ec2:bucket/text())', $item);
$i['storage']['s3']['prefix'] = $xpath->evaluate('string(ec2:storage/ec2:S3/ec2:prefix/text())', $item);
$return[] = $i;
unset($i);
}
return $return;
}
/**
* Generates the S3 Upload Policy Information
*
* @param string $bucketName Which bucket you want the ami to live in on S3
* @param string $prefix The prefix you want to assign to the AMI on S3
* @param integer $expireInMinutes The expiration of the upload policy. Amazon recommends 12 hours or longer.
* This is based in nubmer of minutes. Default is 1440 minutes (24 hours)
* @return string Base64 encoded string that is the upload policy
*/
protected function _getS3UploadPolicy($bucketName, $prefix, $expireInMinutes = 1440)
{
$arrParams = array();
$arrParams['expiration'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", (time() + ($expireInMinutes * 60)));
$arrParams['conditions'][] = array('bucket' => $bucketName);
$arrParams['conditions'][] = array('acl' => 'ec2-bundle-read');
$arrParams['conditions'][] = array('starts-with', '$key', $prefix);
return base64_encode(Zend_Json::encode($arrParams));
}
/**
* Signed S3 Upload Policy
*
* @param string $policy Base64 Encoded string that is the upload policy
* @return string SHA1 encoded S3 Upload Policy
*/
protected function _signS3UploadPolicy($policy)
{
$hmac = Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'SHA1', $policy, Zend_Crypt_Hmac::BINARY);
return $hmac;
}
}

View file

@ -0,0 +1,137 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Keypair.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface to create, delete and describe Ec2 KeyPairs.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Keypair extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Creates a new 2048 bit RSA key pair and returns a unique ID that can
* be used to reference this key pair when launching new instances.
*
* @param string $keyName A unique name for the key pair.
* @throws Zend_Service_Amazon_Ec2_Exception
* @return array
*/
public function create($keyName)
{
$params = array();
$params['Action'] = 'CreateKeyPair';
if(!$keyName) {
require_once 'Zend/Service/Amazon/Ec2/Exception.php';
throw new Zend_Service_Amazon_Ec2_Exception('Invalid Key Name');
}
$params['KeyName'] = $keyName;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$return['keyName'] = $xpath->evaluate('string(//ec2:keyName/text())');
$return['keyFingerprint'] = $xpath->evaluate('string(//ec2:keyFingerprint/text())');
$return['keyMaterial'] = $xpath->evaluate('string(//ec2:keyMaterial/text())');
return $return;
}
/**
* Returns information about key pairs available to you. If you specify
* key pairs, information about those key pairs is returned. Otherwise,
* information for all registered key pairs is returned.
*
* @param string|rarray $keyName Key pair IDs to describe.
* @return array
*/
public function describe($keyName = null)
{
$params = array();
$params['Action'] = 'DescribeKeyPairs';
if(is_array($keyName) && !empty($keyName)) {
foreach($keyName as $k=>$name) {
$params['KeyName.' . ($k+1)] = $name;
}
} elseif($keyName) {
$params['KeyName.1'] = $keyName;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:keySet/ec2:item');
$return = array();
foreach ($nodes as $k => $node) {
$item = array();
$item['keyName'] = $xpath->evaluate('string(ec2:keyName/text())', $node);
$item['keyFingerprint'] = $xpath->evaluate('string(ec2:keyFingerprint/text())', $node);
$return[] = $item;
unset($item);
}
return $return;
}
/**
* Deletes a key pair
*
* @param string $keyName Name of the key pair to delete.
* @throws Zend_Service_Amazon_Ec2_Exception
* @return boolean Return true or false from the deletion.
*/
public function delete($keyName)
{
$params = array();
$params['Action'] = 'DeleteKeyPair';
if(!$keyName) {
require_once 'Zend/Service/Amazon/Ec2/Exception.php';
throw new Zend_Service_Amazon_Ec2_Exception('Invalid Key Name');
}
$params['KeyName'] = $keyName;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$success = $xpath->evaluate('string(//ec2:return/text())');
return ($success === "true");
}
}

View file

@ -0,0 +1,77 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Region.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface to query which Regions your account has access to.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Region extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Describes availability zones that are currently available to the account
* and their states.
*
* @param string|array $region Name of an region.
* @return array An array that contains all the return items. Keys: regionName and regionUrl.
*/
public function describe($region = null)
{
$params = array();
$params['Action'] = 'DescribeRegions';
if(is_array($region) && !empty($region)) {
foreach($region as $k=>$name) {
$params['Region.' . ($k+1)] = $name;
}
} elseif($region) {
$params['Region.1'] = $region;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$nodes = $xpath->query('//ec2:item');
$return = array();
foreach ($nodes as $k => $node) {
$item = array();
$item['regionName'] = $xpath->evaluate('string(ec2:regionName/text())', $node);
$item['regionUrl'] = $xpath->evaluate('string(ec2:regionUrl/text())', $node);
$return[] = $item;
unset($item);
}
return $return;
}
}

View file

@ -0,0 +1,163 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Response.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Http_Response
*/
require_once 'Zend/Http/Response.php';
/**
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Response {
/**
* XML namespace used for EC2 responses.
*/
protected $_xmlNamespace = 'http://ec2.amazonaws.com/doc/2009-04-04/';
/**
* The original HTTP response
*
* This contains the response body and headers.
*
* @var Zend_Http_Response
*/
private $_httpResponse = null;
/**
* The response document object
*
* @var DOMDocument
*/
private $_document = null;
/**
* The response XPath
*
* @var DOMXPath
*/
private $_xpath = null;
/**
* Last error code
*
* @var integer
*/
private $_errorCode = 0;
/**
* Last error message
*
* @var string
*/
private $_errorMessage = '';
/**
* Creates a new high-level EC2 response object
*
* @param Zend_Http_Response $httpResponse the HTTP response.
*/
public function __construct(Zend_Http_Response $httpResponse)
{
$this->_httpResponse = $httpResponse;
}
/**
* Gets the XPath object for this response
*
* @return DOMXPath the XPath object for response.
*/
public function getXPath()
{
if ($this->_xpath === null) {
$document = $this->getDocument();
if ($document === false) {
$this->_xpath = false;
} else {
$this->_xpath = new DOMXPath($document);
$this->_xpath->registerNamespace('ec2',
$this->getNamespace());
}
}
return $this->_xpath;
}
/**
* Gets the document object for this response
*
* @return DOMDocument the DOM Document for this response.
*/
public function getDocument()
{
try {
$body = $this->_httpResponse->getBody();
} catch (Zend_Http_Exception $e) {
$body = false;
}
if ($this->_document === null) {
if ($body !== false) {
// turn off libxml error handling
$errors = libxml_use_internal_errors();
$this->_document = new DOMDocument();
if (!$this->_document->loadXML($body)) {
$this->_document = false;
}
// reset libxml error handling
libxml_clear_errors();
libxml_use_internal_errors($errors);
} else {
$this->_document = false;
}
}
return $this->_document;
}
/**
* Return the current set XML Namespace.
*
* @return string
*/
public function getNamespace()
{
return $this->_xmlNamespace;
}
/**
* Set a new XML Namespace
*
* @param string $namespace
*/
public function setNamespace($namespace)
{
$this->_xmlNamespace = $namespace;
}
}

View file

@ -0,0 +1,301 @@
<?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_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Securitygroups.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Ec2_Abstract
*/
require_once 'Zend/Service/Amazon/Ec2/Abstract.php';
/**
* An Amazon EC2 interface to create, delete, describe, grand and revoke sercurity permissions.
*
* @category Zend
* @package Zend_Service_Amazon
* @subpackage Ec2
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Ec2_Securitygroups extends Zend_Service_Amazon_Ec2_Abstract
{
/**
* Creates a new security group.
*
* Every instance is launched in a security group. If no security group is specified
* during launch, the instances are launched in the default security group. Instances
* within the same security group have unrestricted network access to each other.
* Instances will reject network access attempts from other instances in a different
* security group. As the owner of instances you can grant or revoke specific permissions
* using the {@link authorizeIp}, {@link authorizeGroup}, {@link revokeGroup} and
* {$link revokeIp} operations.
*
* @param string $name Name of the new security group.
* @param string $description Description of the new security group.
* @return boolean
*/
public function create($name, $description)
{
$params = array();
$params['Action'] = 'CreateSecurityGroup';
$params['GroupName'] = $name;
$params['GroupDescription'] = $description;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$success = $xpath->evaluate('string(//ec2:return/text())');
return ($success === "true");
}
/**
* Returns information about security groups that you own.
*
* If you specify security group names, information about those security group is returned.
* Otherwise, information for all security group is returned. If you specify a group
* that does not exist, a fault is returned.
*
* @param string|array $name List of security groups to describe
* @return array
*/
public function describe($name = null)
{
$params = array();
$params['Action'] = 'DescribeSecurityGroups';
if(is_array($name) && !empty($name)) {
foreach($name as $k=>$name) {
$params['GroupName.' . ($k+1)] = $name;
}
} elseif($name) {
$params['GroupName.1'] = $name;
}
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$return = array();
$nodes = $xpath->query('//ec2:securityGroupInfo/ec2:item');
foreach($nodes as $node) {
$item = array();
$item['ownerId'] = $xpath->evaluate('string(ec2:ownerId/text())', $node);
$item['groupName'] = $xpath->evaluate('string(ec2:groupName/text())', $node);
$item['groupDescription'] = $xpath->evaluate('string(ec2:groupDescription/text())', $node);
$ip_nodes = $xpath->query('ec2:ipPermissions/ec2:item', $node);
foreach($ip_nodes as $ip_node) {
$sItem = array();
$sItem['ipProtocol'] = $xpath->evaluate('string(ec2:ipProtocol/text())', $ip_node);
$sItem['fromPort'] = $xpath->evaluate('string(ec2:fromPort/text())', $ip_node);
$sItem['toPort'] = $xpath->evaluate('string(ec2:toPort/text())', $ip_node);
$ips = $xpath->query('ec2:ipRanges/ec2:item', $ip_node);
$sItem['ipRanges'] = array();
foreach($ips as $ip) {
$sItem['ipRanges'][] = $xpath->evaluate('string(ec2:cidrIp/text())', $ip);
}
if(count($sItem['ipRanges']) == 1) {
$sItem['ipRanges'] = $sItem['ipRanges'][0];
}
$item['ipPermissions'][] = $sItem;
unset($ip_node, $sItem);
}
$return[] = $item;
unset($item, $node);
}
return $return;
}
/**
* Deletes a security group.
*
* If you attempt to delete a security group that contains instances, a fault is returned.
* If you attempt to delete a security group that is referenced by another security group,
* a fault is returned. For example, if security group B has a rule that allows access
* from security group A, security group A cannot be deleted until the allow rule is removed.
*
* @param string $name Name of the security group to delete.
* @return boolean
*/
public function delete($name)
{
$params = array();
$params['Action'] = 'DeleteSecurityGroup';
$params['GroupName'] = $name;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$success = $xpath->evaluate('string(//ec2:return/text())');
return ($success === "true");
}
/**
* Adds permissions to a security group
*
* Permissions are specified by the IP protocol (TCP, UDP or ICMP), the source of the request
* (by IP range or an Amazon EC2 user-group pair), the source and destination port ranges
* (for TCP and UDP), and the ICMP codes and types (for ICMP). When authorizing ICMP, -1
* can be used as a wildcard in the type and code fields.
*
* Permission changes are propagated to instances within the security group as quickly as
* possible. However, depending on the number of instances, a small delay might occur.
*
*
* @param string $name Name of the group to modify.
* @param string $ipProtocol IP protocol to authorize access to when operating on a CIDR IP.
* @param integer $fromPort Bottom of port range to authorize access to when operating on a CIDR IP.
* This contains the ICMP type if ICMP is being authorized.
* @param integer $toPort Top of port range to authorize access to when operating on a CIDR IP.
* This contains the ICMP code if ICMP is being authorized.
* @param string $cidrIp CIDR IP range to authorize access to when operating on a CIDR IP.
* @return boolean
*/
public function authorizeIp($name, $ipProtocol, $fromPort, $toPort, $cidrIp)
{
$params = array();
$params['Action'] = 'AuthorizeSecurityGroupIngress';
$params['GroupName'] = $name;
$params['IpProtocol'] = $ipProtocol;
$params['FromPort'] = $fromPort;
$params['ToPort'] = $toPort;
$params['CidrIp'] = $cidrIp;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$success = $xpath->evaluate('string(//ec2:return/text())');
return ($success === "true");
}
/**
* Adds permissions to a security group
*
* When authorizing a user/group pair permission, GroupName, SourceSecurityGroupName and
* SourceSecurityGroupOwnerId must be specified.
*
* Permission changes are propagated to instances within the security group as quickly as
* possible. However, depending on the number of instances, a small delay might occur.
*
* @param string $name Name of the group to modify.
* @param string $groupName Name of security group to authorize access to when operating on a user/group pair.
* @param string $ownerId Owner of security group to authorize access to when operating on a user/group pair.
* @return boolean
*/
public function authorizeGroup($name, $groupName, $ownerId)
{
$params = array();
$params['Action'] = 'AuthorizeSecurityGroupIngress';
$params['GroupName'] = $name;
$params['SourceSecurityGroupName'] = $groupName;
$params['SourceSecurityGroupOwnerId'] = $ownerId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$success = $xpath->evaluate('string(//ec2:return/text())');
return ($success === "true");
}
/**
* Revokes permissions from a security group. The permissions used to revoke must be specified
* using the same values used to grant the permissions.
*
* Permissions are specified by the IP protocol (TCP, UDP or ICMP), the source of the request
* (by IP range or an Amazon EC2 user-group pair), the source and destination port ranges
* (for TCP and UDP), and the ICMP codes and types (for ICMP). When authorizing ICMP, -1
* can be used as a wildcard in the type and code fields.
*
* Permission changes are propagated to instances within the security group as quickly as
* possible. However, depending on the number of instances, a small delay might occur.
*
*
* @param string $name Name of the group to modify.
* @param string $ipProtocol IP protocol to revoke access to when operating on a CIDR IP.
* @param integer $fromPort Bottom of port range to revoke access to when operating on a CIDR IP.
* This contains the ICMP type if ICMP is being revoked.
* @param integer $toPort Top of port range to revoked access to when operating on a CIDR IP.
* This contains the ICMP code if ICMP is being revoked.
* @param string $cidrIp CIDR IP range to revoke access to when operating on a CIDR IP.
* @return boolean
*/
public function revokeIp($name, $ipProtocol, $fromPort, $toPort, $cidrIp)
{
$params = array();
$params['Action'] = 'RevokeSecurityGroupIngress';
$params['GroupName'] = $name;
$params['IpProtocol'] = $ipProtocol;
$params['FromPort'] = $fromPort;
$params['ToPort'] = $toPort;
$params['CidrIp'] = $cidrIp;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$success = $xpath->evaluate('string(//ec2:return/text())');
return ($success === "true");
}
/**
* Revokes permissions from a security group. The permissions used to revoke must be specified
* using the same values used to grant the permissions.
*
* Permission changes are propagated to instances within the security group as quickly as
* possible. However, depending on the number of instances, a small delay might occur.
*
* When revoking a user/group pair permission, GroupName, SourceSecurityGroupName and
* SourceSecurityGroupOwnerId must be specified.
*
* @param string $name Name of the group to modify.
* @param string $groupName Name of security group to revoke access to when operating on a user/group pair.
* @param string $ownerId Owner of security group to revoke access to when operating on a user/group pair.
* @return boolean
*/
public function revokeGroup($name, $groupName, $ownerId)
{
$params = array();
$params['Action'] = 'RevokeSecurityGroupIngress';
$params['GroupName'] = $name;
$params['SourceSecurityGroupName'] = $groupName;
$params['SourceSecurityGroupOwnerId'] = $ownerId;
$response = $this->sendRequest($params);
$xpath = $response->getXPath();
$success = $xpath->evaluate('string(//ec2:return/text())');
return ($success === "true");
}
}

View file

@ -0,0 +1,58 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: EditorialReview.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_EditorialReview
{
/**
* @var string
*/
public $Source;
/**
* @var string
*/
public $Content;
/**
* Assigns values to properties relevant to EditorialReview
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
foreach (array('Source', 'Content') as $el) {
$this->$el = (string) $xpath->query("./az:$el/text()", $dom)->item(0)->data;
}
}
}

View file

@ -0,0 +1,35 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Exception extends Zend_Service_Exception
{}

View file

@ -0,0 +1,69 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Image.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Image
{
/**
* Image URL
*
* @var Zend_Uri
*/
public $Url;
/**
* Image height in pixels
*
* @var int
*/
public $Height;
/**
* Image width in pixels
*
* @var int
*/
public $Width;
/**
* Assigns values to properties relevant to Image
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
$this->Url = Zend_Uri::factory($xpath->query('./az:URL/text()', $dom)->item(0)->data);
$this->Height = (int) $xpath->query('./az:Height/text()', $dom)->item(0)->data;
$this->Width = (int) $xpath->query('./az:Width/text()', $dom)->item(0)->data;
}
}

View file

@ -0,0 +1,261 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Item.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Item
{
/**
* @var string
*/
public $ASIN;
/**
* @var string
*/
public $DetailPageURL;
/**
* @var int
*/
public $SalesRank;
/**
* @var int
*/
public $TotalReviews;
/**
* @var int
*/
public $AverageRating;
/**
* @var string
*/
public $SmallImage;
/**
* @var string
*/
public $MediumImage;
/**
* @var string
*/
public $LargeImage;
/**
* @var string
*/
public $Subjects;
/**
* @var Zend_Service_Amazon_OfferSet
*/
public $Offers;
/**
* @var Zend_Service_Amazon_CustomerReview[]
*/
public $CustomerReviews = array();
/**
* @var Zend_Service_Amazon_SimilarProducts[]
*/
public $SimilarProducts = array();
/**
* @var Zend_Service_Amazon_Accessories[]
*/
public $Accessories = array();
/**
* @var array
*/
public $Tracks = array();
/**
* @var Zend_Service_Amazon_ListmaniaLists[]
*/
public $ListmaniaLists = array();
protected $_dom;
/**
* Parse the given <Item> element
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
$this->ASIN = $xpath->query('./az:ASIN/text()', $dom)->item(0)->data;
$result = $xpath->query('./az:DetailPageURL/text()', $dom);
if ($result->length == 1) {
$this->DetailPageURL = $result->item(0)->data;
}
if ($xpath->query('./az:ItemAttributes/az:ListPrice', $dom)->length >= 1) {
$this->CurrencyCode = (string) $xpath->query('./az:ItemAttributes/az:ListPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
$this->Amount = (int) $xpath->query('./az:ItemAttributes/az:ListPrice/az:Amount/text()', $dom)->item(0)->data;
$this->FormattedPrice = (string) $xpath->query('./az:ItemAttributes/az:ListPrice/az:FormattedPrice/text()', $dom)->item(0)->data;
}
$result = $xpath->query('./az:ItemAttributes/az:*/text()', $dom);
if ($result->length >= 1) {
foreach ($result as $v) {
if (isset($this->{$v->parentNode->tagName})) {
if (is_array($this->{$v->parentNode->tagName})) {
array_push($this->{$v->parentNode->tagName}, (string) $v->data);
} else {
$this->{$v->parentNode->tagName} = array($this->{$v->parentNode->tagName}, (string) $v->data);
}
} else {
$this->{$v->parentNode->tagName} = (string) $v->data;
}
}
}
foreach (array('SmallImage', 'MediumImage', 'LargeImage') as $im) {
$result = $xpath->query("./az:ImageSets/az:ImageSet[position() = 1]/az:$im", $dom);
if ($result->length == 1) {
/**
* @see Zend_Service_Amazon_Image
*/
require_once 'Zend/Service/Amazon/Image.php';
$this->$im = new Zend_Service_Amazon_Image($result->item(0));
}
}
$result = $xpath->query('./az:SalesRank/text()', $dom);
if ($result->length == 1) {
$this->SalesRank = (int) $result->item(0)->data;
}
$result = $xpath->query('./az:CustomerReviews/az:Review', $dom);
if ($result->length >= 1) {
/**
* @see Zend_Service_Amazon_CustomerReview
*/
require_once 'Zend/Service/Amazon/CustomerReview.php';
foreach ($result as $review) {
$this->CustomerReviews[] = new Zend_Service_Amazon_CustomerReview($review);
}
$this->AverageRating = (float) $xpath->query('./az:CustomerReviews/az:AverageRating/text()', $dom)->item(0)->data;
$this->TotalReviews = (int) $xpath->query('./az:CustomerReviews/az:TotalReviews/text()', $dom)->item(0)->data;
}
$result = $xpath->query('./az:EditorialReviews/az:*', $dom);
if ($result->length >= 1) {
/**
* @see Zend_Service_Amazon_EditorialReview
*/
require_once 'Zend/Service/Amazon/EditorialReview.php';
foreach ($result as $r) {
$this->EditorialReviews[] = new Zend_Service_Amazon_EditorialReview($r);
}
}
$result = $xpath->query('./az:SimilarProducts/az:*', $dom);
if ($result->length >= 1) {
/**
* @see Zend_Service_Amazon_SimilarProduct
*/
require_once 'Zend/Service/Amazon/SimilarProduct.php';
foreach ($result as $r) {
$this->SimilarProducts[] = new Zend_Service_Amazon_SimilarProduct($r);
}
}
$result = $xpath->query('./az:ListmaniaLists/*', $dom);
if ($result->length >= 1) {
/**
* @see Zend_Service_Amazon_ListmaniaList
*/
require_once 'Zend/Service/Amazon/ListmaniaList.php';
foreach ($result as $r) {
$this->ListmaniaLists[] = new Zend_Service_Amazon_ListmaniaList($r);
}
}
$result = $xpath->query('./az:Tracks/az:Disc', $dom);
if ($result->length > 1) {
foreach ($result as $disk) {
foreach ($xpath->query('./*/text()', $disk) as $t) {
// TODO: For consistency in a bugfix all tracks are appended to one single array
// Erroreous line: $this->Tracks[$disk->getAttribute('number')] = (string) $t->data;
$this->Tracks[] = (string) $t->data;
}
}
} else if ($result->length == 1) {
foreach ($xpath->query('./*/text()', $result->item(0)) as $t) {
$this->Tracks[] = (string) $t->data;
}
}
$result = $xpath->query('./az:Offers', $dom);
$resultSummary = $xpath->query('./az:OfferSummary', $dom);
if ($result->length > 1 || $resultSummary->length == 1) {
/**
* @see Zend_Service_Amazon_OfferSet
*/
require_once 'Zend/Service/Amazon/OfferSet.php';
$this->Offers = new Zend_Service_Amazon_OfferSet($dom);
}
$result = $xpath->query('./az:Accessories/*', $dom);
if ($result->length > 1) {
/**
* @see Zend_Service_Amazon_Accessories
*/
require_once 'Zend/Service/Amazon/Accessories.php';
foreach ($result as $r) {
$this->Accessories[] = new Zend_Service_Amazon_Accessories($r);
}
}
$this->_dom = $dom;
}
/**
* Returns the item's original XML
*
* @return string
*/
public function asXml()
{
return $this->_dom->ownerDocument->saveXML($this->_dom);
}
}

View file

@ -0,0 +1,58 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ListmaniaList.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_ListmaniaList
{
/**
* @var string
*/
public $ListId;
/**
* @var string
*/
public $ListName;
/**
* Assigns values to properties relevant to ListmaniaList
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
foreach (array('ListId', 'ListName') as $el) {
$this->$el = (string) $xpath->query("./az:$el/text()", $dom)->item(0)->data;
}
}
}

View file

@ -0,0 +1,111 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Offer.php 21155 2010-02-23 17:11:12Z matthew $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Offer
{
/**
* @var string
*/
public $MerchantId;
/**
* @var string
*/
public $MerchantName;
/**
* @var string
*/
public $GlancePage;
/**
* @var string
*/
public $Condition;
/**
* @var string
*/
public $OfferListingId;
/**
* @var string
*/
public $Price;
/**
* @var string
*/
public $CurrencyCode;
/**
* @var string
*/
public $Availability;
/**
* @var boolean
*/
public $IsEligibleForSuperSaverShipping = false;
/**
* Parse the given Offer element
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
$this->MerchantId = (string) $xpath->query('./az:Merchant/az:MerchantId/text()', $dom)->item(0)->data;
$name = $xpath->query('./az:Merchant/az:Name/text()', $dom);
if ($name->length == 1) {
$this->MerchantName = (string) $name->item(0)->data;
}
$this->GlancePage = (string) $xpath->query('./az:Merchant/az:GlancePage/text()', $dom)->item(0)->data;
$this->Condition = (string) $xpath->query('./az:OfferAttributes/az:Condition/text()', $dom)->item(0)->data;
$this->OfferListingId = (string) $xpath->query('./az:OfferListing/az:OfferListingId/text()', $dom)->item(0)->data;
$Price = $xpath->query('./az:OfferListing/az:Price/az:Amount', $dom);
if ($Price->length == 1) {
$this->Price = (int) $xpath->query('./az:OfferListing/az:Price/az:Amount/text()', $dom)->item(0)->data;
$this->CurrencyCode = (string) $xpath->query('./az:OfferListing/az:Price/az:CurrencyCode/text()', $dom)->item(0)->data;
}
$availability = $xpath->query('./az:OfferListing/az:Availability/text()', $dom)->item(0);
if($availability instanceof DOMText) {
$this->Availability = (string) $availability->data;
}
$result = $xpath->query('./az:OfferListing/az:IsEligibleForSuperSaverShipping/text()', $dom);
if ($result->length >= 1) {
$this->IsEligibleForSuperSaverShipping = (bool) $result->item(0)->data;
}
}
}

View file

@ -0,0 +1,118 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: OfferSet.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_OfferSet
{
/**
* @var string
*/
public $LowestNewPrice;
/**
* @var string
*/
public $LowestNewPriceCurrency;
/**
* @var string
*/
public $LowestUsedPrice;
/**
* @var string
*/
public $LowestUsedPriceCurrency;
/**
* @var int
*/
public $TotalNew;
/**
* @var int
*/
public $TotalUsed;
/**
* @var int
*/
public $TotalCollectible;
/**
* @var int
*/
public $TotalRefurbished;
/**
* @var Zend_Service_Amazon_Offer[]
*/
public $Offers;
/**
* Parse the given Offer Set Element
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
$offer = $xpath->query('./az:OfferSummary', $dom);
if ($offer->length == 1) {
$lowestNewPrice = $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount', $dom);
if ($lowestNewPrice->length == 1) {
$this->LowestNewPrice = (int) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:Amount/text()', $dom)->item(0)->data;
$this->LowestNewPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestNewPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
}
$lowestUsedPrice = $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount', $dom);
if ($lowestUsedPrice->length == 1) {
$this->LowestUsedPrice = (int) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:Amount/text()', $dom)->item(0)->data;
$this->LowestUsedPriceCurrency = (string) $xpath->query('./az:OfferSummary/az:LowestUsedPrice/az:CurrencyCode/text()', $dom)->item(0)->data;
}
$this->TotalNew = (int) $xpath->query('./az:OfferSummary/az:TotalNew/text()', $dom)->item(0)->data;
$this->TotalUsed = (int) $xpath->query('./az:OfferSummary/az:TotalUsed/text()', $dom)->item(0)->data;
$this->TotalCollectible = (int) $xpath->query('./az:OfferSummary/az:TotalCollectible/text()', $dom)->item(0)->data;
$this->TotalRefurbished = (int) $xpath->query('./az:OfferSummary/az:TotalRefurbished/text()', $dom)->item(0)->data;
}
$offers = $xpath->query('./az:Offers/az:Offer', $dom);
if ($offers->length >= 1) {
/**
* @see Zend_Service_Amazon_Offer
*/
require_once 'Zend/Service/Amazon/Offer.php';
foreach ($offers as $offer) {
$this->Offers[] = new Zend_Service_Amazon_Offer($offer);
}
}
}
}

View file

@ -0,0 +1,98 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Query.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon
*/
require_once 'Zend/Service/Amazon.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Query extends Zend_Service_Amazon
{
/**
* Search parameters
*
* @var array
*/
protected $_search = array();
/**
* Search index
*
* @var string
*/
protected $_searchIndex = null;
/**
* Prepares query parameters
*
* @param string $method
* @param array $args
* @throws Zend_Service_Exception
* @return Zend_Service_Amazon_Query Provides a fluent interface
*/
public function __call($method, $args)
{
if (strtolower($method) === 'asin') {
$this->_searchIndex = 'asin';
$this->_search['ItemId'] = $args[0];
return $this;
}
if (strtolower($method) === 'category') {
$this->_searchIndex = $args[0];
$this->_search['SearchIndex'] = $args[0];
} else if (isset($this->_search['SearchIndex']) || $this->_searchIndex !== null || $this->_searchIndex === 'asin') {
$this->_search[$method] = $args[0];
} else {
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('You must set a category before setting the search parameters');
}
return $this;
}
/**
* Search using the prepared query
*
* @return Zend_Service_Amazon_Item|Zend_Service_Amazon_ResultSet
*/
public function search()
{
if ($this->_searchIndex === 'asin') {
return $this->itemLookup($this->_search['ItemId'], $this->_search);
}
return $this->itemSearch($this->_search);
}
}

View file

@ -0,0 +1,170 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ResultSet.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Item
*/
require_once 'Zend/Service/Amazon/Item.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_ResultSet implements SeekableIterator
{
/**
* A DOMNodeList of <Item> elements
*
* @var DOMNodeList
*/
protected $_results = null;
/**
* Amazon Web Service Return Document
*
* @var DOMDocument
*/
protected $_dom;
/**
* XPath Object for $this->_dom
*
* @var DOMXPath
*/
protected $_xpath;
/**
* Current index for SeekableIterator
*
* @var int
*/
protected $_currentIndex = 0;
/**
* Create an instance of Zend_Service_Amazon_ResultSet and create the necessary data objects
*
* @param DOMDocument $dom
* @return void
*/
public function __construct(DOMDocument $dom)
{
$this->_dom = $dom;
$this->_xpath = new DOMXPath($dom);
$this->_xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
$this->_results = $this->_xpath->query('//az:Item');
}
/**
* Total Number of results returned
*
* @return int Total number of results returned
*/
public function totalResults()
{
$result = $this->_xpath->query('//az:TotalResults/text()');
return (int) $result->item(0)->data;
}
/**
* Total Number of pages returned
*
* @return int Total number of pages returned
*/
public function totalPages()
{
$result = $this->_xpath->query('//az:TotalPages/text()');
return (int) $result->item(0)->data;
}
/**
* Implement SeekableIterator::current()
*
* @return Zend_Service_Amazon_Item
*/
public function current()
{
return new Zend_Service_Amazon_Item($this->_results->item($this->_currentIndex));
}
/**
* Implement SeekableIterator::key()
*
* @return int
*/
public function key()
{
return $this->_currentIndex;
}
/**
* Implement SeekableIterator::next()
*
* @return void
*/
public function next()
{
$this->_currentIndex += 1;
}
/**
* Implement SeekableIterator::rewind()
*
* @return void
*/
public function rewind()
{
$this->_currentIndex = 0;
}
/**
* Implement SeekableIterator::seek()
*
* @param int $index
* @throws OutOfBoundsException
* @return void
*/
public function seek($index)
{
$indexInt = (int) $index;
if ($indexInt >= 0 && (null === $this->_results || $indexInt < $this->_results->length)) {
$this->_currentIndex = $indexInt;
} else {
throw new OutOfBoundsException("Illegal index '$index'");
}
}
/**
* Implement SeekableIterator::valid()
*
* @return boolean
*/
public function valid()
{
return null !== $this->_results && $this->_currentIndex < $this->_results->length;
}
}

View file

@ -0,0 +1,900 @@
<?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_Service
* @subpackage Amazon_S3
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: S3.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_Abstract
*/
require_once 'Zend/Service/Amazon/Abstract.php';
/**
* @see Zend_Crypt_Hmac
*/
require_once 'Zend/Crypt/Hmac.php';
/**
* Amazon S3 PHP connection class
*
* @category Zend
* @package Zend_Service
* @subpackage Amazon_S3
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://docs.amazonwebservices.com/AmazonS3/2006-03-01/
*/
class Zend_Service_Amazon_S3 extends Zend_Service_Amazon_Abstract
{
/**
* Store for stream wrapper clients
*
* @var array
*/
protected static $_wrapperClients = array();
/**
* Endpoint for the service
*
* @var Zend_Uri_Http
*/
protected $_endpoint;
const S3_ENDPOINT = 's3.amazonaws.com';
const S3_ACL_PRIVATE = 'private';
const S3_ACL_PUBLIC_READ = 'public-read';
const S3_ACL_PUBLIC_WRITE = 'public-read-write';
const S3_ACL_AUTH_READ = 'authenticated-read';
const S3_REQUESTPAY_HEADER = 'x-amz-request-payer';
const S3_ACL_HEADER = 'x-amz-acl';
const S3_CONTENT_TYPE_HEADER = 'Content-Type';
/**
* Set S3 endpoint to use
*
* @param string|Zend_Uri_Http $endpoint
* @return Zend_Service_Amazon_S3
*/
public function setEndpoint($endpoint)
{
if (!($endpoint instanceof Zend_Uri_Http)) {
$endpoint = Zend_Uri::factory($endpoint);
}
if (!$endpoint->valid()) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception('Invalid endpoint supplied');
}
$this->_endpoint = $endpoint;
return $this;
}
/**
* Get current S3 endpoint
*
* @return Zend_Uri_Http
*/
public function getEndpoint()
{
return $this->_endpoint;
}
/**
* Constructor
*
* @param string $accessKey
* @param string $secretKey
* @param string $region
*/
public function __construct($accessKey=null, $secretKey=null, $region=null)
{
parent::__construct($accessKey, $secretKey, $region);
$this->setEndpoint('http://'.self::S3_ENDPOINT);
}
/**
* Verify if the bucket name is valid
*
* @param string $bucket
* @return boolean
*/
public function _validBucketName($bucket)
{
$len = strlen($bucket);
if ($len < 3 || $len > 255) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Bucket name \"$bucket\" must be between 3 and 255 characters long");
}
if (preg_match('/[^a-z0-9\._-]/', $bucket)) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Bucket name \"$bucket\" contains invalid characters");
}
if (preg_match('/(\d){1,3}\.(\d){1,3}\.(\d){1,3}\.(\d){1,3}/', $bucket)) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Bucket name \"$bucket\" cannot be an IP address");
}
return true;
}
/**
* Add a new bucket
*
* @param string $bucket
* @return boolean
*/
public function createBucket($bucket, $location = null)
{
$this->_validBucketName($bucket);
if($location) {
$data = '<CreateBucketConfiguration><LocationConstraint>'.$location.'</LocationConstraint></CreateBucketConfiguration>';
}
else {
$data = null;
}
$response = $this->_makeRequest('PUT', $bucket, null, array(), $data);
return ($response->getStatus() == 200);
}
/**
* Checks if a given bucket name is available
*
* @param string $bucket
* @return boolean
*/
public function isBucketAvailable($bucket)
{
$response = $this->_makeRequest('HEAD', $bucket, array('max-keys'=>0));
return ($response->getStatus() != 404);
}
/**
* Checks if a given object exists
*
* @param string $object
* @return boolean
*/
public function isObjectAvailable($object)
{
$response = $this->_makeRequest('HEAD', $object);
return ($response->getStatus() == 200);
}
/**
* Remove a given bucket. All objects in the bucket must be removed prior
* to removing the bucket.
*
* @param string $bucket
* @return boolean
*/
public function removeBucket($bucket)
{
$response = $this->_makeRequest('DELETE', $bucket);
// Look for a 204 No Content response
return ($response->getStatus() == 204);
}
/**
* Get metadata information for a given object
*
* @param string $object
* @return array|false
*/
public function getInfo($object)
{
$info = array();
$object = $this->_fixupObjectName($object);
$response = $this->_makeRequest('HEAD', $object);
if ($response->getStatus() == 200) {
$info['type'] = $response->getHeader('Content-type');
$info['size'] = $response->getHeader('Content-length');
$info['mtime'] = strtotime($response->getHeader('Last-modified'));
$info['etag'] = $response->getHeader('ETag');
}
else {
return false;
}
return $info;
}
/**
* List the S3 buckets
*
* @return array|false
*/
public function getBuckets()
{
$response = $this->_makeRequest('GET');
if ($response->getStatus() != 200) {
return false;
}
$xml = new SimpleXMLElement($response->getBody());
$buckets = array();
foreach ($xml->Buckets->Bucket as $bucket) {
$buckets[] = (string)$bucket->Name;
}
return $buckets;
}
/**
* Remove all objects in the bucket.
*
* @param string $bucket
* @return boolean
*/
public function cleanBucket($bucket)
{
$objects = $this->getObjectsByBucket($bucket);
if (!$objects) {
return false;
}
foreach ($objects as $object) {
$this->removeObject("$bucket/$object");
}
return true;
}
/**
* List the objects in a bucket.
*
* Provides the list of object keys that are contained in the bucket. Valid params include the following.
* prefix - Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders.
* marker - Indicates where in the bucket to begin listing. The list will only include keys that occur lexicographically after marker. This is convenient for pagination: To get the next page of results use the last key of the current page as the marker.
* max-keys - The maximum number of keys you'd like to see in the response body. The server might return fewer than this many keys, but will not return more.
* delimiter - Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the CommonPrefixes collection. These rolled-up keys are not returned elsewhere in the response.
*
* @param string $bucket
* @param array $params S3 GET Bucket Paramater
* @return array|false
*/
public function getObjectsByBucket($bucket, $params = array())
{
$response = $this->_makeRequest('GET', $bucket, $params);
if ($response->getStatus() != 200) {
return false;
}
$xml = new SimpleXMLElement($response->getBody());
$objects = array();
if (isset($xml->Contents)) {
foreach ($xml->Contents as $contents) {
foreach ($contents->Key as $object) {
$objects[] = (string)$object;
}
}
}
return $objects;
}
/**
* Make sure the object name is valid
*
* @param string $object
* @return string
*/
protected function _fixupObjectName($object)
{
$nameparts = explode('/', $object);
$this->_validBucketName($nameparts[0]);
$firstpart = array_shift($nameparts);
if (count($nameparts) == 0) {
return $firstpart;
}
return $firstpart.'/'.join('/', array_map('rawurlencode', $nameparts));
}
/**
* Get an object
*
* @param string $object
* @param bool $paidobject This is "requestor pays" object
* @return string|false
*/
public function getObject($object, $paidobject=false)
{
$object = $this->_fixupObjectName($object);
if ($paidobject) {
$response = $this->_makeRequest('GET', $object, null, array(self::S3_REQUESTPAY_HEADER => 'requester'));
}
else {
$response = $this->_makeRequest('GET', $object);
}
if ($response->getStatus() != 200) {
return false;
}
return $response->getBody();
}
/**
* Get an object using streaming
*
* Can use either provided filename for storage or create a temp file if none provided.
*
* @param string $object Object path
* @param string $streamfile File to write the stream to
* @param bool $paidobject This is "requestor pays" object
* @return Zend_Http_Response_Stream|false
*/
public function getObjectStream($object, $streamfile = null, $paidobject=false)
{
$object = $this->_fixupObjectName($object);
self::getHttpClient()->setStream($streamfile?$streamfile:true);
if ($paidobject) {
$response = $this->_makeRequest('GET', $object, null, array(self::S3_REQUESTPAY_HEADER => 'requester'));
}
else {
$response = $this->_makeRequest('GET', $object);
}
self::getHttpClient()->setStream(null);
if ($response->getStatus() != 200 || !($response instanceof Zend_Http_Response_Stream)) {
return false;
}
return $response;
}
/**
* Upload an object by a PHP string
*
* @param string $object Object name
* @param string|resource $data Object data (can be string or stream)
* @param array $meta Metadata
* @return boolean
*/
public function putObject($object, $data, $meta=null)
{
$object = $this->_fixupObjectName($object);
$headers = (is_array($meta)) ? $meta : array();
if(!is_resource($data)) {
$headers['Content-MD5'] = base64_encode(md5($data, true));
}
$headers['Expect'] = '100-continue';
if (!isset($headers[self::S3_CONTENT_TYPE_HEADER])) {
$headers[self::S3_CONTENT_TYPE_HEADER] = self::getMimeType($object);
}
$response = $this->_makeRequest('PUT', $object, null, $headers, $data);
// Check the MD5 Etag returned by S3 against and MD5 of the buffer
if ($response->getStatus() == 200) {
// It is escaped by double quotes for some reason
$etag = str_replace('"', '', $response->getHeader('Etag'));
if (is_resource($data) || $etag == md5($data)) {
return true;
}
}
return false;
}
/**
* Put file to S3 as object
*
* @param string $path File name
* @param string $object Object name
* @param array $meta Metadata
* @return boolean
*/
public function putFile($path, $object, $meta=null)
{
$data = @file_get_contents($path);
if ($data === false) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Cannot read file $path");
}
if (!is_array($meta)) {
$meta = array();
}
if (!isset($meta[self::S3_CONTENT_TYPE_HEADER])) {
$meta[self::S3_CONTENT_TYPE_HEADER] = self::getMimeType($path);
}
return $this->putObject($object, $data, $meta);
}
/**
* Put file to S3 as object, using streaming
*
* @param string $path File name
* @param string $object Object name
* @param array $meta Metadata
* @return boolean
*/
public function putFileStream($path, $object, $meta=null)
{
$data = @fopen($path, "rb");
if ($data === false) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Cannot open file $path");
}
if (!is_array($meta)) {
$meta = array();
}
if (!isset($meta[self::S3_CONTENT_TYPE_HEADER])) {
$meta[self::S3_CONTENT_TYPE_HEADER] = self::getMimeType($path);
}
if(!isset($meta['Content-MD5'])) {
$headers['Content-MD5'] = base64_encode(md5_file($path, true));
}
return $this->putObject($object, $data, $meta);
}
/**
* Remove a given object
*
* @param string $object
* @return boolean
*/
public function removeObject($object)
{
$object = $this->_fixupObjectName($object);
$response = $this->_makeRequest('DELETE', $object);
// Look for a 204 No Content response
return ($response->getStatus() == 204);
}
/**
* Make a request to Amazon S3
*
* @param string $method Request method
* @param string $path Path to requested object
* @param array $params Request parameters
* @param array $headers HTTP headers
* @param string|resource $data Request data
* @return Zend_Http_Response
*/
public function _makeRequest($method, $path='', $params=null, $headers=array(), $data=null)
{
$retry_count = 0;
if (!is_array($headers)) {
$headers = array($headers);
}
$headers['Date'] = gmdate(DATE_RFC1123, time());
if(is_resource($data) && $method != 'PUT') {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Only PUT request supports stream data");
}
// build the end point out
$parts = explode('/', $path, 2);
$endpoint = clone($this->_endpoint);
if ($parts[0]) {
// prepend bucket name to the hostname
$endpoint->setHost($parts[0].'.'.$endpoint->getHost());
}
if (!empty($parts[1])) {
$endpoint->setPath('/'.$parts[1]);
}
else {
$endpoint->setPath('/');
if ($parts[0]) {
$path = $parts[0].'/';
}
}
self::addSignature($method, $path, $headers);
$client = self::getHttpClient();
$client->resetParameters();
$client->setUri($endpoint);
$client->setAuth(false);
// Work around buglet in HTTP client - it doesn't clean headers
// Remove when ZHC is fixed
$client->setHeaders(array('Content-MD5' => null,
'Expect' => null,
'Range' => null,
'x-amz-acl' => null));
$client->setHeaders($headers);
if (is_array($params)) {
foreach ($params as $name=>$value) {
$client->setParameterGet($name, $value);
}
}
if (($method == 'PUT') && ($data !== null)) {
if (!isset($headers['Content-type'])) {
$headers['Content-type'] = self::getMimeType($path);
}
$client->setRawData($data, $headers['Content-type']);
}
do {
$retry = false;
$response = $client->request($method);
$response_code = $response->getStatus();
// Some 5xx errors are expected, so retry automatically
if ($response_code >= 500 && $response_code < 600 && $retry_count <= 5) {
$retry = true;
$retry_count++;
sleep($retry_count / 4 * $retry_count);
}
else if ($response_code == 307) {
// Need to redirect, new S3 endpoint given
// This should never happen as Zend_Http_Client will redirect automatically
}
else if ($response_code == 100) {
// echo 'OK to Continue';
}
} while ($retry);
return $response;
}
/**
* Add the S3 Authorization signature to the request headers
*
* @param string $method
* @param string $path
* @param array &$headers
* @return string
*/
protected function addSignature($method, $path, &$headers)
{
if (!is_array($headers)) {
$headers = array($headers);
}
$type = $md5 = $date = '';
// Search for the Content-type, Content-MD5 and Date headers
foreach ($headers as $key=>$val) {
if (strcasecmp($key, 'content-type') == 0) {
$type = $val;
}
else if (strcasecmp($key, 'content-md5') == 0) {
$md5 = $val;
}
else if (strcasecmp($key, 'date') == 0) {
$date = $val;
}
}
// If we have an x-amz-date header, use that instead of the normal Date
if (isset($headers['x-amz-date']) && isset($date)) {
$date = '';
}
$sig_str = "$method\n$md5\n$type\n$date\n";
// For x-amz- headers, combine like keys, lowercase them, sort them
// alphabetically and remove excess spaces around values
$amz_headers = array();
foreach ($headers as $key=>$val) {
$key = strtolower($key);
if (substr($key, 0, 6) == 'x-amz-') {
if (is_array($val)) {
$amz_headers[$key] = $val;
}
else {
$amz_headers[$key][] = preg_replace('/\s+/', ' ', $val);
}
}
}
if (!empty($amz_headers)) {
ksort($amz_headers);
foreach ($amz_headers as $key=>$val) {
$sig_str .= $key.':'.implode(',', $val)."\n";
}
}
$sig_str .= '/'.parse_url($path, PHP_URL_PATH);
if (strpos($path, '?location') !== false) {
$sig_str .= '?location';
}
else if (strpos($path, '?acl') !== false) {
$sig_str .= '?acl';
}
else if (strpos($path, '?torrent') !== false) {
$sig_str .= '?torrent';
}
$signature = base64_encode(Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'sha1', utf8_encode($sig_str), Zend_Crypt_Hmac::BINARY));
$headers['Authorization'] = 'AWS '.$this->_getAccessKey().':'.$signature;
return $sig_str;
}
/**
* Attempt to get the content-type of a file based on the extension
*
* @param string $path
* @return string
*/
public static function getMimeType($path)
{
$ext = substr(strrchr($path, '.'), 1);
if(!$ext) {
// shortcut
return 'binary/octet-stream';
}
switch (strtolower($ext)) {
case 'xls':
$content_type = 'application/excel';
break;
case 'hqx':
$content_type = 'application/macbinhex40';
break;
case 'doc':
case 'dot':
case 'wrd':
$content_type = 'application/msword';
break;
case 'pdf':
$content_type = 'application/pdf';
break;
case 'pgp':
$content_type = 'application/pgp';
break;
case 'ps':
case 'eps':
case 'ai':
$content_type = 'application/postscript';
break;
case 'ppt':
$content_type = 'application/powerpoint';
break;
case 'rtf':
$content_type = 'application/rtf';
break;
case 'tgz':
case 'gtar':
$content_type = 'application/x-gtar';
break;
case 'gz':
$content_type = 'application/x-gzip';
break;
case 'php':
case 'php3':
case 'php4':
$content_type = 'application/x-httpd-php';
break;
case 'js':
$content_type = 'application/x-javascript';
break;
case 'ppd':
case 'psd':
$content_type = 'application/x-photoshop';
break;
case 'swf':
case 'swc':
case 'rf':
$content_type = 'application/x-shockwave-flash';
break;
case 'tar':
$content_type = 'application/x-tar';
break;
case 'zip':
$content_type = 'application/zip';
break;
case 'mid':
case 'midi':
case 'kar':
$content_type = 'audio/midi';
break;
case 'mp2':
case 'mp3':
case 'mpga':
$content_type = 'audio/mpeg';
break;
case 'ra':
$content_type = 'audio/x-realaudio';
break;
case 'wav':
$content_type = 'audio/wav';
break;
case 'bmp':
$content_type = 'image/bitmap';
break;
case 'gif':
$content_type = 'image/gif';
break;
case 'iff':
$content_type = 'image/iff';
break;
case 'jb2':
$content_type = 'image/jb2';
break;
case 'jpg':
case 'jpe':
case 'jpeg':
$content_type = 'image/jpeg';
break;
case 'jpx':
$content_type = 'image/jpx';
break;
case 'png':
$content_type = 'image/png';
break;
case 'tif':
case 'tiff':
$content_type = 'image/tiff';
break;
case 'wbmp':
$content_type = 'image/vnd.wap.wbmp';
break;
case 'xbm':
$content_type = 'image/xbm';
break;
case 'css':
$content_type = 'text/css';
break;
case 'txt':
$content_type = 'text/plain';
break;
case 'htm':
case 'html':
$content_type = 'text/html';
break;
case 'xml':
$content_type = 'text/xml';
break;
case 'xsl':
$content_type = 'text/xsl';
break;
case 'mpg':
case 'mpe':
case 'mpeg':
$content_type = 'video/mpeg';
break;
case 'qt':
case 'mov':
$content_type = 'video/quicktime';
break;
case 'avi':
$content_type = 'video/x-ms-video';
break;
case 'eml':
$content_type = 'message/rfc822';
break;
default:
$content_type = 'binary/octet-stream';
break;
}
return $content_type;
}
/**
* Register this object as stream wrapper client
*
* @param string $name
* @return Zend_Service_Amazon_S3
*/
public function registerAsClient($name)
{
self::$_wrapperClients[$name] = $this;
return $this;
}
/**
* Unregister this object as stream wrapper client
*
* @param string $name
* @return Zend_Service_Amazon_S3
*/
public function unregisterAsClient($name)
{
unset(self::$_wrapperClients[$name]);
return $this;
}
/**
* Get wrapper client for stream type
*
* @param string $name
* @return Zend_Service_Amazon_S3
*/
public static function getWrapperClient($name)
{
return self::$_wrapperClients[$name];
}
/**
* Register this object as stream wrapper
*
* @param string $name
* @return Zend_Service_Amazon_S3
*/
public function registerStreamWrapper($name='s3')
{
/**
* @see Zend_Service_Amazon_S3_Stream
*/
require_once 'Zend/Service/Amazon/S3/Stream.php';
stream_register_wrapper($name, 'Zend_Service_Amazon_S3_Stream');
$this->registerAsClient($name);
}
/**
* Unregister this object as stream wrapper
*
* @param string $name
* @return Zend_Service_Amazon_S3
*/
public function unregisterStreamWrapper($name='s3')
{
stream_wrapper_unregister($name);
$this->unregisterAsClient($name);
}
}

View file

@ -0,0 +1,37 @@
<?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_Service
* @subpackage Amazon_S3
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Zend_Service_Amazon_Exception
*/
require_once 'Zend/Service/Amazon/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_S3_Exception extends Zend_Service_Amazon_Exception
{}

View file

@ -0,0 +1,497 @@
<?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_Service
* @subpackage Amazon_S3
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Stream.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Amazon_S3
*/
require_once 'Zend/Service/Amazon/S3.php';
/**
* Amazon S3 PHP stream wrapper
*
* @category Zend
* @package Zend_Service
* @subpackage Amazon_S3
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_S3_Stream
{
/**
* @var boolean Write the buffer on fflush()?
*/
private $_writeBuffer = false;
/**
* @var integer Current read/write position
*/
private $_position = 0;
/**
* @var integer Total size of the object as returned by S3 (Content-length)
*/
private $_objectSize = 0;
/**
* @var string File name to interact with
*/
private $_objectName = null;
/**
* @var string Current read/write buffer
*/
private $_objectBuffer = null;
/**
* @var array Available buckets
*/
private $_bucketList = array();
/**
* @var Zend_Service_Amazon_S3
*/
private $_s3 = null;
/**
* Retrieve client for this stream type
*
* @param string $path
* @return Zend_Service_Amazon_S3
*/
protected function _getS3Client($path)
{
if ($this->_s3 === null) {
$url = explode(':', $path);
if (!$url) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Unable to parse URL $path");
}
$this->_s3 = Zend_Service_Amazon_S3::getWrapperClient($url[0]);
if (!$this->_s3) {
/**
* @see Zend_Service_Amazon_S3_Exception
*/
require_once 'Zend/Service/Amazon/S3/Exception.php';
throw new Zend_Service_Amazon_S3_Exception("Unknown client for wrapper {$url[0]}");
}
}
return $this->_s3;
}
/**
* Extract object name from URL
*
* @param string $path
* @return string
*/
protected function _getNamePart($path)
{
$url = parse_url($path);
if ($url['host']) {
return !empty($url['path']) ? $url['host'].$url['path'] : $url['host'];
}
return '';
}
/**
* Open the stream
*
* @param string $path
* @param string $mode
* @param integer $options
* @param string $opened_path
* @return boolean
*/
public function stream_open($path, $mode, $options, $opened_path)
{
$name = $this->_getNamePart($path);
// If we open the file for writing, just return true. Create the object
// on fflush call
if (strpbrk($mode, 'wax')) {
$this->_objectName = $name;
$this->_objectBuffer = null;
$this->_objectSize = 0;
$this->_position = 0;
$this->_writeBuffer = true;
$this->_getS3Client($path);
return true;
}
else {
// Otherwise, just see if the file exists or not
$info = $this->_getS3Client($path)->getInfo($name);
if ($info) {
$this->_objectName = $name;
$this->_objectBuffer = null;
$this->_objectSize = $info['size'];
$this->_position = 0;
$this->_writeBuffer = false;
$this->_getS3Client($path);
return true;
}
}
return false;
}
/**
* Close the stream
*
* @return void
*/
public function stream_close()
{
$this->_objectName = null;
$this->_objectBuffer = null;
$this->_objectSize = 0;
$this->_position = 0;
$this->_writeBuffer = false;
unset($this->_s3);
}
/**
* Read from the stream
*
* @param integer $count
* @return string
*/
public function stream_read($count)
{
if (!$this->_objectName) {
return false;
}
$range_start = $this->_position;
$range_end = $this->_position+$count;
// Only fetch more data from S3 if we haven't fetched any data yet (postion=0)
// OR, the range end position is greater than the size of the current object
// buffer AND if the range end position is less than or equal to the object's
// size returned by S3
if (($this->_position == 0) || (($range_end > strlen($this->_objectBuffer)) && ($range_end <= $this->_objectSize))) {
$headers = array(
'Range' => "$range_start-$range_end"
);
$response = $this->_s3->_makeRequest('GET', $this->_objectName, null, $headers);
if ($response->getStatus() == 200) {
$this->_objectBuffer .= $response->getBody();
}
}
$data = substr($this->_objectBuffer, $this->_position, $count);
$this->_position += strlen($data);
return $data;
}
/**
* Write to the stream
*
* @param string $data
* @return integer
*/
public function stream_write($data)
{
if (!$this->_objectName) {
return 0;
}
$len = strlen($data);
$this->_objectBuffer .= $data;
$this->_objectSize += $len;
// TODO: handle current position for writing!
return $len;
}
/**
* End of the stream?
*
* @return boolean
*/
public function stream_eof()
{
if (!$this->_objectName) {
return true;
}
return ($this->_position >= $this->_objectSize);
}
/**
* What is the current read/write position of the stream
*
* @return integer
*/
public function stream_tell()
{
return $this->_position;
}
/**
* Update the read/write position of the stream
*
* @param integer $offset
* @param integer $whence
* @return boolean
*/
public function stream_seek($offset, $whence)
{
if (!$this->_objectName) {
return false;
}
switch ($whence) {
case SEEK_CUR:
// Set position to current location plus $offset
$new_pos = $this->_position + $offset;
break;
case SEEK_END:
// Set position to end-of-file plus $offset
$new_pos = $this->_objectSize + $offset;
break;
case SEEK_SET:
default:
// Set position equal to $offset
$new_pos = $offset;
break;
}
$ret = ($new_pos >= 0 && $new_pos <= $this->_objectSize);
if ($ret) {
$this->_position = $new_pos;
}
return $ret;
}
/**
* Flush current cached stream data to storage
*
* @return boolean
*/
public function stream_flush()
{
// If the stream wasn't opened for writing, just return false
if (!$this->_writeBuffer) {
return false;
}
$ret = $this->_s3->putObject($this->_objectName, $this->_objectBuffer);
$this->_objectBuffer = null;
return $ret;
}
/**
* Returns data array of stream variables
*
* @return array
*/
public function stream_stat()
{
if (!$this->_objectName) {
return false;
}
$stat = array();
$stat['dev'] = 0;
$stat['ino'] = 0;
$stat['mode'] = 0777;
$stat['nlink'] = 0;
$stat['uid'] = 0;
$stat['gid'] = 0;
$stat['rdev'] = 0;
$stat['size'] = 0;
$stat['atime'] = 0;
$stat['mtime'] = 0;
$stat['ctime'] = 0;
$stat['blksize'] = 0;
$stat['blocks'] = 0;
if(($slash = strchr($this->_objectName, '/')) === false || $slash == strlen($this->_objectName)-1) {
/* bucket */
$stat['mode'] |= 040000;
} else {
$stat['mode'] |= 0100000;
}
$info = $this->_s3->getInfo($this->_objectName);
if (!empty($info)) {
$stat['size'] = $info['size'];
$stat['atime'] = time();
$stat['mtime'] = $info['mtime'];
}
return $stat;
}
/**
* Attempt to delete the item
*
* @param string $path
* @return boolean
*/
public function unlink($path)
{
return $this->_getS3Client($path)->removeObject($this->_getNamePart($path));
}
/**
* Attempt to rename the item
*
* @param string $path_from
* @param string $path_to
* @return boolean False
*/
public function rename($path_from, $path_to)
{
// TODO: Renaming isn't supported, always return false
return false;
}
/**
* Create a new directory
*
* @param string $path
* @param integer $mode
* @param integer $options
* @return boolean
*/
public function mkdir($path, $mode, $options)
{
return $this->_getS3Client($path)->createBucket(parse_url($path, PHP_URL_HOST));
}
/**
* Remove a directory
*
* @param string $path
* @param integer $options
* @return boolean
*/
public function rmdir($path, $options)
{
return $this->_getS3Client($path)->removeBucket(parse_url($path, PHP_URL_HOST));
}
/**
* Attempt to open a directory
*
* @param string $path
* @param integer $options
* @return boolean
*/
public function dir_opendir($path, $options)
{
if (preg_match('@^([a-z0-9+.]|-)+://$@', $path)) {
$this->_bucketList = $this->_getS3Client($path)->getBuckets();
}
else {
$host = parse_url($path, PHP_URL_HOST);
$this->_bucketList = $this->_getS3Client($path)->getObjectsByBucket($host);
}
return ($this->_bucketList !== false);
}
/**
* Return array of URL variables
*
* @param string $path
* @param integer $flags
* @return array
*/
public function url_stat($path, $flags)
{
$stat = array();
$stat['dev'] = 0;
$stat['ino'] = 0;
$stat['mode'] = 0777;
$stat['nlink'] = 0;
$stat['uid'] = 0;
$stat['gid'] = 0;
$stat['rdev'] = 0;
$stat['size'] = 0;
$stat['atime'] = 0;
$stat['mtime'] = 0;
$stat['ctime'] = 0;
$stat['blksize'] = 0;
$stat['blocks'] = 0;
$name = $this->_getNamePart($path);
if(($slash = strchr($name, '/')) === false || $slash == strlen($name)-1) {
/* bucket */
$stat['mode'] |= 040000;
} else {
$stat['mode'] |= 0100000;
}
$info = $this->_getS3Client($path)->getInfo($name);
if (!empty($info)) {
$stat['size'] = $info['size'];
$stat['atime'] = time();
$stat['mtime'] = $info['mtime'];
}
return $stat;
}
/**
* Return the next filename in the directory
*
* @return string
*/
public function dir_readdir()
{
$object = current($this->_bucketList);
if ($object !== false) {
next($this->_bucketList);
}
return $object;
}
/**
* Reset the directory pointer
*
* @return boolean True
*/
public function dir_rewinddir()
{
reset($this->_bucketList);
return true;
}
/**
* Close a directory
*
* @return boolean True
*/
public function dir_closedir()
{
$this->_bucketList = array();
return true;
}
}

View file

@ -0,0 +1,61 @@
<?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_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SimilarProduct.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_SimilarProduct
{
/**
* @var string
*/
public $ASIN;
/**
* @var string
*/
public $Title;
/**
* Assigns values to properties relevant to SimilarProduct
*
* @param DOMElement $dom
* @return void
*/
public function __construct(DOMElement $dom)
{
$xpath = new DOMXPath($dom->ownerDocument);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
foreach (array('ASIN', 'Title') as $el) {
$text = $xpath->query("./az:$el/text()", $dom)->item(0);
if($text instanceof DOMText) {
$this->$el = (string)$text->data;
}
}
}
}

View file

@ -0,0 +1,444 @@
<?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_Service
* @subpackage Amazon_Sqs
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Sqs.php 21323 2010-03-04 18:27:32Z stas $
*/
/**
* @see Zend_Service_Amazon_Abstract
*/
require_once 'Zend/Service/Amazon/Abstract.php';
/**
* @see Zend_Crypt_Hmac
*/
require_once 'Zend/Crypt/Hmac.php';
/**
* Class for connecting to the Amazon Simple Queue Service (SQS)
*
* @category Zend
* @package Zend_Service
* @subpackage Amazon_Sqs
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://aws.amazon.com/sqs/ Amazon Simple Queue Service
*/
class Zend_Service_Amazon_Sqs extends Zend_Service_Amazon_Abstract
{
/**
* Default timeout for createQueue() function
*/
const CREATE_TIMEOUT_DEFAULT = 30;
/**
* HTTP end point for the Amazon SQS service
*/
protected $_sqsEndpoint = 'queue.amazonaws.com';
/**
* The API version to use
*/
protected $_sqsApiVersion = '2009-02-01';
/**
* Signature Version
*/
protected $_sqsSignatureVersion = '2';
/**
* Signature Encoding Method
*/
protected $_sqsSignatureMethod = 'HmacSHA256';
/**
* Constructor
*
* @param string $accessKey
* @param string $secretKey
* @param string $region
*/
public function __construct($accessKey = null, $secretKey = null, $region = null)
{
parent::__construct($accessKey, $secretKey, $region);
}
/**
* Create a new queue
*
* Visibility timeout is how long a message is left in the queue "invisible"
* to other readers. If the message is acknowleged (deleted) before the
* timeout, then the message is deleted. However, if the timeout expires
* then the message will be made available to other queue readers.
*
* @param string $queue_name queue name
* @param integer $timeout default visibility timeout
* @return string|boolean
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function create($queue_name, $timeout = null)
{
$params = array();
$params['QueueName'] = $queue_name;
$timeout = ($timeout === null) ? self::CREATE_TIMEOUT_DEFAULT : (int)$timeout;
$params['DefaultVisibilityTimeout'] = $timeout;
$retry_count = 0;
do {
$retry = false;
$result = $this->_makeRequest(null, 'CreateQueue', $params);
if ($result->CreateQueueResult->QueueUrl === null) {
if ($result->Error->Code == 'AWS.SimpleQueueService.QueueNameExists') {
return false;
} elseif ($result->Error->Code == 'AWS.SimpleQueueService.QueueDeletedRecently') {
// Must sleep for 60 seconds, then try re-creating the queue
sleep(60);
$retry = true;
$retry_count++;
} else {
require_once 'Zend/Service/Amazon/Sqs/Exception.php';
throw new Zend_Service_Amazon_Sqs_Exception($result->Error->Code);
}
} else {
return (string) $result->CreateQueueResult->QueueUrl;
}
} while ($retry);
return false;
}
/**
* Delete a queue and all of it's messages
*
* Returns false if the queue is not found, true if the queue exists
*
* @param string $queue_url queue URL
* @return boolean
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function delete($queue_url)
{
$result = $this->_makeRequest($queue_url, 'DeleteQueue');
if ($result->Error->Code !== null) {
require_once 'Zend/Service/Amazon/Sqs/Exception.php';
throw new Zend_Service_Amazon_Sqs_Exception($result->Error->Code);
}
return true;
}
/**
* Get an array of all available queues
*
* @return array
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function getQueues()
{
$result = $this->_makeRequest(null, 'ListQueues');
if ($result->ListQueuesResult->QueueUrl === null) {
require_once 'Zend/Service/Amazon/Sqs/Exception.php';
throw new Zend_Service_Amazon_Sqs_Exception($result->Error->Code);
}
$queues = array();
foreach ($result->ListQueuesResult->QueueUrl as $queue_url) {
$queues[] = (string)$queue_url;
}
return $queues;
}
/**
* Return the approximate number of messages in the queue
*
* @param string $queue_url Queue URL
* @return integer
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function count($queue_url)
{
return (int)$this->getAttribute($queue_url, 'ApproximateNumberOfMessages');
}
/**
* Send a message to the queue
*
* @param string $queue_url Queue URL
* @param string $message Message to send to the queue
* @return string Message ID
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function send($queue_url, $message)
{
$params = array();
$params['MessageBody'] = urlencode($message);
$checksum = md5($params['MessageBody']);
$result = $this->_makeRequest($queue_url, 'SendMessage', $params);
if ($result->SendMessageResult->MessageId === null) {
require_once 'Zend/Service/Amazon/Sqs/Exception.php';
throw new Zend_Service_Amazon_Sqs_Exception($result->Error->Code);
} else if ((string) $result->SendMessageResult->MD5OfMessageBody != $checksum) {
require_once 'Zend/Service/Amazon/Sqs/Exception.php';
throw new Zend_Service_Amazon_Sqs_Exception('MD5 of body does not match message sent');
}
return (string) $result->SendMessageResult->MessageId;
}
/**
* Get messages in the queue
*
* @param string $queue_url Queue name
* @param integer $max_messages Maximum number of messages to return
* @param integer $timeout Visibility timeout for these messages
* @return array
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function receive($queue_url, $max_messages = null, $timeout = null)
{
$params = array();
// If not set, the visibility timeout on the queue is used
if ($timeout !== null) {
$params['VisibilityTimeout'] = (int)$timeout;
}
// SQS will default to only returning one message
if ($max_messages !== null) {
$params['MaxNumberOfMessages'] = (int)$max_messages;
}
$result = $this->_makeRequest($queue_url, 'ReceiveMessage', $params);
if ($result->ReceiveMessageResult->Message === null) {
require_once 'Zend/Service/Amazon/Sqs/Exception.php';
throw new Zend_Service_Amazon_Sqs_Exception($result->Error->Code);
}
$data = array();
foreach ($result->ReceiveMessageResult->Message as $message) {
$data[] = array(
'message_id' => (string)$message->MessageId,
'handle' => (string)$message->ReceiptHandle,
'md5' => (string)$message->MD5OfBody,
'body' => urldecode((string)$message->Body),
);
}
return $data;
}
/**
* Delete a message from the queue
*
* Returns true if the message is deleted, false if the deletion is
* unsuccessful.
*
* @param string $queue_url Queue URL
* @param string $handle Message handle as returned by SQS
* @return boolean
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function deleteMessage($queue_url, $handle)
{
$params = array();
$params['ReceiptHandle'] = (string)$handle;
$result = $this->_makeRequest($queue_url, 'DeleteMessage', $params);
if ($result->Error->Code !== null) {
return false;
}
// Will always return true unless ReceiptHandle is malformed
return true;
}
/**
* Get the attributes for the queue
*
* @param string $queue_url Queue URL
* @param string $attribute
* @return string
* @throws Zend_Service_Amazon_Sqs_Exception
*/
public function getAttribute($queue_url, $attribute = 'All')
{
$params = array();
$params['AttributeName'] = $attribute;
$result = $this->_makeRequest($queue_url, 'GetQueueAttributes', $params);
if ($result->GetQueueAttributesResult->Attribute === null) {
require_once 'Zend/Service/Amazon/Sqs/Exception.php';
throw new Zend_Service_Amazon_Sqs_Exception($result->Error->Code);
}
if(count($result->GetQueueAttributesResult->Attribute) > 1) {
$attr_result = array();
foreach($result->GetQueueAttributesResult->Attribute as $attribute) {
$attr_result[(string)$attribute->Name] = (string)$attribute->Value;
}
return $attr_result;
} else {
return (string) $result->GetQueueAttributesResult->Attribute->Value;
}
}
/**
* Make a request to Amazon SQS
*
* @param string $queue Queue Name
* @param string $action SQS action
* @param array $params
* @return SimpleXMLElement
*/
private function _makeRequest($queue_url, $action, $params = array())
{
$params['Action'] = $action;
$params = $this->addRequiredParameters($queue_url, $params);
if ($queue_url === null) {
$queue_url = '/';
}
$client = self::getHttpClient();
switch ($action) {
case 'ListQueues':
case 'CreateQueue':
$client->setUri('http://'.$this->_sqsEndpoint);
break;
default:
$client->setUri($queue_url);
break;
}
$retry_count = 0;
do {
$retry = false;
$client->resetParameters();
$client->setParameterGet($params);
$response = $client->request('GET');
$response_code = $response->getStatus();
// Some 5xx errors are expected, so retry automatically
if ($response_code >= 500 && $response_code < 600 && $retry_count <= 5) {
$retry = true;
$retry_count++;
sleep($retry_count / 4 * $retry_count);
}
} while ($retry);
unset($client);
return new SimpleXMLElement($response->getBody());
}
/**
* Adds required authentication and version parameters to an array of
* parameters
*
* The required parameters are:
* - AWSAccessKey
* - SignatureVersion
* - Timestamp
* - Version and
* - Signature
*
* If a required parameter is already set in the <tt>$parameters</tt> array,
* it is overwritten.
*
* @param string $queue_url Queue URL
* @param array $parameters the array to which to add the required
* parameters.
* @return array
*/
protected function addRequiredParameters($queue_url, array $parameters)
{
$parameters['AWSAccessKeyId'] = $this->_getAccessKey();
$parameters['SignatureVersion'] = $this->_sqsSignatureVersion;
$parameters['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z', time()+10);
$parameters['Version'] = $this->_sqsApiVersion;
$parameters['SignatureMethod'] = $this->_sqsSignatureMethod;
$parameters['Signature'] = $this->_signParameters($queue_url, $parameters);
return $parameters;
}
/**
* Computes the RFC 2104-compliant HMAC signature for request parameters
*
* This implements the Amazon Web Services signature, as per the following
* specification:
*
* 1. Sort all request parameters (including <tt>SignatureVersion</tt> and
* excluding <tt>Signature</tt>, the value of which is being created),
* ignoring case.
*
* 2. Iterate over the sorted list and append the parameter name (in its
* original case) and then its value. Do not URL-encode the parameter
* values before constructing this string. Do not use any separator
* characters when appending strings.
*
* @param string $queue_url Queue URL
* @param array $parameters the parameters for which to get the signature.
*
* @return string the signed data.
*/
protected function _signParameters($queue_url, array $paramaters)
{
$data = "GET\n";
$data .= $this->_sqsEndpoint . "\n";
if ($queue_url !== null) {
$data .= parse_url($queue_url, PHP_URL_PATH);
}
else {
$data .= '/';
}
$data .= "\n";
uksort($paramaters, 'strcmp');
unset($paramaters['Signature']);
$arrData = array();
foreach($paramaters as $key => $value) {
$arrData[] = $key . '=' . str_replace('%7E', '~', urlencode($value));
}
$data .= implode('&', $arrData);
$hmac = Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'SHA256', $data, Zend_Crypt_Hmac::BINARY);
return base64_encode($hmac);
}
}

View file

@ -0,0 +1,38 @@
<?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_Service
* @subpackage Amazon_Sqs
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Zend_Service_Amazon/Exception
*/
require_once 'Zend/Service/Amazon/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage Amazon_Sqs
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Amazon_Sqs_Exception extends Zend_Service_Amazon_Exception
{}

View file

@ -0,0 +1,681 @@
<?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_Service
* @subpackage Audioscrobbler
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Audioscrobbler.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Http_Client
*/
require_once 'Zend/Http/Client.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage Audioscrobbler
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Audioscrobbler
{
/**
* Zend_Http_Client Object
*
* @var Zend_Http_Client
* @access protected
*/
protected $_client;
/**
* Array that contains parameters being used by the webservice
*
* @var array
* @access protected
*/
protected $_params;
/**
* Holds error information (e.g., for handling simplexml_load_string() warnings)
*
* @var array
* @access protected
*/
protected $_error = null;
/**
* Sets up character encoding, instantiates the HTTP client, and assigns the web service version.
*/
public function __construct()
{
$this->set('version', '1.0');
iconv_set_encoding('output_encoding', 'UTF-8');
iconv_set_encoding('input_encoding', 'UTF-8');
iconv_set_encoding('internal_encoding', 'UTF-8');
}
/**
* Set Http Client
*
* @param Zend_Http_Client $client
*/
public function setHttpClient(Zend_Http_Client $client)
{
$this->_client = $client;
}
/**
* Get current http client.
*
* @return Zend_Http_Client
*/
public function getHttpClient()
{
if($this->_client == null) {
$this->lazyLoadHttpClient();
}
return $this->_client;
}
/**
* Lazy load Http Client if none is instantiated yet.
*
* @return void
*/
protected function lazyLoadHttpClient()
{
$this->_client = new Zend_Http_Client();
}
/**
* Returns a field value, or false if the named field does not exist
*
* @param string $field
* @return string|false
*/
public function get($field)
{
if (array_key_exists($field, $this->_params)) {
return $this->_params[$field];
} else {
return false;
}
}
/**
* Generic set action for a field in the parameters being used
*
* @param string $field name of field to set
* @param string $value value to assign to the named field
* @return Zend_Service_Audioscrobbler Provides a fluent interface
*/
public function set($field, $value)
{
$this->_params[$field] = urlencode($value);
return $this;
}
/**
* Protected method that queries REST service and returns SimpleXML response set
*
* @param string $service name of Audioscrobbler service file we're accessing
* @param string $params parameters that we send to the service if needded
* @throws Zend_Http_Client_Exception
* @throws Zend_Service_Exception
* @return SimpleXMLElement result set
* @access protected
*/
protected function _getInfo($service, $params = null)
{
$service = (string) $service;
$params = (string) $params;
if ($params === '') {
$this->getHttpClient()->setUri("http://ws.audioscrobbler.com{$service}");
} else {
$this->getHttpClient()->setUri("http://ws.audioscrobbler.com{$service}?{$params}");
}
$response = $this->getHttpClient()->request();
$responseBody = $response->getBody();
if (preg_match('/No such path/', $responseBody)) {
/**
* @see Zend_Http_Client_Exception
*/
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri());
} elseif (preg_match('/No user exists with this name/', $responseBody)) {
/**
* @see Zend_Http_Client_Exception
*/
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('No user exists with this name');
} elseif (!$response->isSuccessful()) {
/**
* @see Zend_Http_Client_Exception
*/
require_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
}
set_error_handler(array($this, '_errorHandler'));
if (!$simpleXmlElementResponse = simplexml_load_string($responseBody)) {
restore_error_handler();
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
$exception = new Zend_Service_Exception('Response failed to load with SimpleXML');
$exception->error = $this->_error;
$exception->response = $responseBody;
throw $exception;
}
restore_error_handler();
return $simpleXmlElementResponse;
}
/**
* Utility function to get Audioscrobbler profile information (eg: Name, Gender)
*
* @return array containing information
*/
public function userGetProfileInformation()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/profile.xml";
return $this->_getInfo($service);
}
/**
* Utility function get this user's 50 most played artists
*
* @return array containing info
*/
public function userGetTopArtists()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/topartists.xml";
return $this->_getInfo($service);
}
/**
* Utility function to get this user's 50 most played albums
*
* @return SimpleXMLElement object containing result set
*/
public function userGetTopAlbums()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/topalbums.xml";
return $this->_getInfo($service);
}
/**
* Utility function to get this user's 50 most played tracks
* @return SimpleXML object containing resut set
*/
public function userGetTopTracks()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/toptracks.xml";
return $this->_getInfo($service);
}
/**
* Utility function to get this user's 50 most used tags
*
* @return SimpleXMLElement object containing result set
*/
public function userGetTopTags()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/tags.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns the user's top tags used most used on a specific artist
*
* @return SimpleXMLElement object containing result set
*/
public function userGetTopTagsForArtist()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/artisttags.xml";
$params = "artist={$this->get('artist')}";
return $this->_getInfo($service, $params);
}
/**
* Utility function that returns this user's top tags for an album
*
* @return SimpleXMLElement object containing result set
*/
public function userGetTopTagsForAlbum()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/albumtags.xml";
$params = "artist={$this->get('artist')}&album={$this->get('album')}";
return $this->_getInfo($service, $params);
}
/**
* Utility function that returns this user's top tags for a track
*
* @return SimpleXMLElement object containing result set
*/
public function userGetTopTagsForTrack()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/tracktags.xml";
$params = "artist={$this->get('artist')}&track={$this->get('track')}";
return $this->_getInfo($service, $params);
}
/**
* Utility function that retrieves this user's list of friends
* @return SimpleXMLElement object containing result set
*/
public function userGetFriends()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/friends.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of people with similar listening preferences to this user
*
* @return SimpleXMLElement object containing result set
*/
public function userGetNeighbours()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/neighbours.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of the 10 most recent tracks played by this user
*
* @return SimpleXMLElement object containing result set
*/
public function userGetRecentTracks()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/recenttracks.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of the 10 tracks most recently banned by this user
*
* @return SimpleXMLElement object containing result set
*/
public function userGetRecentBannedTracks()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/recentbannedtracks.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of the 10 tracks most recently loved by this user
*
* @return SimpleXMLElement object containing result set
*/
public function userGetRecentLovedTracks()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/recentlovedtracks.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of dates of available weekly charts for a this user
*
* Should actually be named userGetWeeklyChartDateList() but we have to follow audioscrobbler's naming
*
* @return SimpleXMLElement object containing result set
*/
public function userGetWeeklyChartList()
{
$service = "/{$this->get('version')}/user/{$this->get('user')}/weeklychartlist.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns weekly album chart data for this user
*
* @param integer $from optional UNIX timestamp for start of date range
* @param integer $to optional UNIX timestamp for end of date range
* @return SimpleXMLElement object containing result set
*/
public function userGetWeeklyAlbumChart($from = NULL, $to = NULL)
{
$params = "";
if ($from != NULL && $to != NULL) {
$from = (int)$from;
$to = (int)$to;
$params = "from={$from}&to={$to}";
}
$service = "/{$this->get('version')}/user/{$this->get('user')}/weeklyalbumchart.xml";
return $this->_getInfo($service, $params);
}
/**
* Utility function that returns weekly artist chart data for this user
*
* @param integer $from optional UNIX timestamp for start of date range
* @param integer $to optional UNIX timestamp for end of date range
* @return SimpleXMLElement object containing result set
*/
public function userGetWeeklyArtistChart($from = NULL, $to = NULL)
{
$params = "";
if ($from != NULL && $to != NULL) {
$from = (int)$from;
$to = (int)$to;
$params = "from={$from}&to={$to}";
}
$service = "/{$this->get('version')}/user/{$this->get('user')}/weeklyartistchart.xml";
return $this->_getInfo($service, $params);
}
/**
* Utility function that returns weekly track chart data for this user
*
* @param integer $from optional UNIX timestamp for start of date range
* @param integer $to optional UNIX timestamp for end of date range
* @return SimpleXMLElement object containing result set
*/
public function userGetWeeklyTrackChart($from = NULL, $to = NULL)
{
$params = "";
if ($from != NULL && $to != NULL) {
$from = (int)$from;
$to = (int)$to;
$params = "from={$from}&to={$to}";
}
$service = "/{$this->get('version')}/user/{$this->get('user')}/weeklytrackchart.xml";
return $this->_getInfo($service, $params);
}
/**
* Utility function that returns a list of artists similiar to this artist
*
* @return SimpleXMLElement object containing result set
*/
public function artistGetRelatedArtists()
{
$service = "/{$this->get('version')}/artist/{$this->get('artist')}/similar.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of this artist's top listeners
*
* @return SimpleXMLElement object containing result set
*/
public function artistGetTopFans()
{
$service = "/{$this->get('version')}/artist/{$this->get('artist')}/fans.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of this artist's top-rated tracks
*
* @return SimpleXMLElement object containing result set
*/
public function artistGetTopTracks()
{
$service = "/{$this->get('version')}/artist/{$this->get('artist')}/toptracks.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of this artist's top-rated albums
*
* @return SimpleXMLElement object containing result set
*/
public function artistGetTopAlbums()
{
$service = "/{$this->get('version')}/artist/{$this->get('artist')}/topalbums.xml";
return $this->_getInfo($service);
}
/**
* Utility function that returns a list of this artist's top-rated tags
*
* @return SimpleXMLElement object containing result set
*/
public function artistGetTopTags()
{
$service = "/{$this->get('version')}/artist/{$this->get('artist')}/toptags.xml";
return $this->_getInfo($service);
}
/**
* Get information about an album
*
* @return SimpleXMLElement
*/
public function albumGetInfo()
{
$service = "/{$this->get('version')}/album/{$this->get('artist')}/{$this->get('album')}/info.xml";
return $this->_getInfo($service);
}
/**
* Get top fans of the current track.
*
* @return SimpleXMLElement
*/
public function trackGetTopFans()
{
$service = "/{$this->get('version')}/track/{$this->get('artist')}/{$this->get('track')}/fans.xml";
return $this->_getInfo($service);
}
/**
* Get top tags of the current track.
*
* @return SimpleXMLElement
*/
public function trackGetTopTags()
{
$service = "/{$this->get('version')}/track/{$this->get('artist')}/{$this->get('track')}/toptags.xml";
return $this->_getInfo($service);
}
/**
* Get Top Tags.
*
* @return SimpleXMLElement
*/
public function tagGetTopTags()
{
$service = "/{$this->get('version')}/tag/toptags.xml";
return $this->_getInfo($service);
}
/**
* Get top albums by current tag.
*
* @return SimpleXMLElement
*/
public function tagGetTopAlbums()
{
$service = "/{$this->get('version')}/tag/{$this->get('tag')}/topalbums.xml";
return $this->_getInfo($service);
}
/**
* Get top artists by current tag.
*
* @return SimpleXMLElement
*/
public function tagGetTopArtists()
{
$service = "/{$this->get('version')}/tag/{$this->get('tag')}/topartists.xml";
return $this->_getInfo($service);
}
/**
* Get Top Tracks by currently set tag.
*
* @return SimpleXMLElement
*/
public function tagGetTopTracks()
{
$service = "/{$this->get('version')}/tag/{$this->get('tag')}/toptracks.xml";
return $this->_getInfo($service);
}
/**
* Get weekly chart list by current set group.
*
* @see set()
* @return SimpleXMLElement
*/
public function groupGetWeeklyChartList()
{
$service = "/{$this->get('version')}/group/{$this->get('group')}/weeklychartlist.xml";
return $this->_getInfo($service);
}
/**
* Retrieve weekly Artist Charts
*
* @param int $from
* @param int $to
* @return SimpleXMLElement
*/
public function groupGetWeeklyArtistChartList($from = NULL, $to = NULL)
{
if ($from != NULL && $to != NULL) {
$from = (int)$from;
$to = (int)$to;
$params = "from={$from}&$to={$to}";
} else {
$params = "";
}
$service = "/{$this->get('version')}/group/{$this->get('group')}/weeklyartistchart.xml";
return $this->_getInfo($service, $params);
}
/**
* Retrieve Weekly Track Charts
*
* @param int $from
* @param int $to
* @return SimpleXMLElement
*/
public function groupGetWeeklyTrackChartList($from = NULL, $to = NULL)
{
if ($from != NULL && $to != NULL) {
$from = (int)$from;
$to = (int)$to;
$params = "from={$from}&to={$to}";
} else {
$params = "";
}
$service = "/{$this->get('version')}/group/{$this->get('group')}/weeklytrackchart.xml";
return $this->_getInfo($service, $params);
}
/**
* Retrieve Weekly album charts.
*
* @param int $from
* @param int $to
* @return SimpleXMLElement
*/
public function groupGetWeeklyAlbumChartList($from = NULL, $to = NULL)
{
if ($from != NULL && $to != NULL) {
$from = (int)$from;
$to = (int)$to;
$params = "from={$from}&to={$to}";
} else {
$params = "";
}
$service = "/{$this->get('version')}/group/{$this->get('group')}/weeklyalbumchart.xml";
return $this->_getInfo($service, $params);
}
/**
* Saves the provided error information to this instance
*
* @param integer $errno
* @param string $errstr
* @param string $errfile
* @param integer $errline
* @param array $errcontext
* @return void
*/
protected function _errorHandler($errno, $errstr, $errfile, $errline, array $errcontext)
{
$this->_error = array(
'errno' => $errno,
'errstr' => $errstr,
'errfile' => $errfile,
'errline' => $errline,
'errcontext' => $errcontext
);
}
/**
* Call Intercept for set($name, $field)
*
* @param string $method
* @param array $args
* @return Zend_Service_Audioscrobbler
*/
public function __call($method, $args)
{
if(substr($method, 0, 3) !== "set") {
require_once "Zend/Service/Exception.php";
throw new Zend_Service_Exception(
"Method ".$method." does not exist in class Zend_Service_Audioscrobbler."
);
}
$field = strtolower(substr($method, 3));
if(!is_array($args) || count($args) != 1) {
require_once "Zend/Service/Exception.php";
throw new Zend_Service_Exception(
"A value is required for setting a parameter field."
);
}
$this->set($field, $args[0]);
return $this;
}
}

View file

@ -0,0 +1,616 @@
<?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_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Delicious.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Rest_Client
*/
require_once 'Zend/Rest/Client.php';
/**
* @see Zend_Json_Decoder
*/
require_once 'Zend/Json/Decoder.php';
/**
* @see Zend_Service_Delicious_SimplePost
*/
require_once 'Zend/Service/Delicious/SimplePost.php';
/**
* @see Zend_Service_Delicious_Post
*/
require_once 'Zend/Service/Delicious/Post.php';
/**
* @see Zend_Service_Delicious_PostList
*/
require_once 'Zend/Service/Delicious/PostList.php';
/**
* Zend_Service_Delicious is a concrete implementation of the del.icio.us web service
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious
{
const API_URI = 'https://api.del.icio.us';
const PATH_UPDATE = '/v1/posts/update';
const PATH_TAGS = '/v1/tags/get';
const PATH_TAG_RENAME = '/v1/tags/rename';
const PATH_BUNDLES = '/v1/tags/bundles/all';
const PATH_BUNDLE_DELETE = '/v1/tags/bundles/delete';
const PATH_BUNDLE_ADD = '/v1/tags/bundles/set';
const PATH_DATES = '/v1/posts/dates';
const PATH_POST_DELETE = '/v1/posts/delete';
const PATH_POSTS_GET = '/v1/posts/get';
const PATH_POSTS_ALL = '/v1/posts/all';
const PATH_POSTS_ADD = '/v1/posts/add';
const PATH_POSTS_RECENT = '/v1/posts/recent';
const JSON_URI = 'http://del.icio.us';
const JSON_POSTS = '/feeds/json/%s/%s';
const JSON_TAGS = '/feeds/json/tags/%s';
const JSON_NETWORK = '/feeds/json/network/%s';
const JSON_FANS = '/feeds/json/fans/%s';
const JSON_URL = '/feeds/json/url/data';
/**
* Zend_Service_Rest instance
*
* @var Zend_Service_Rest
*/
protected $_rest;
/**
* Username
*
* @var string
*/
protected $_authUname;
/**
* Password
*
* @var string
*/
protected $_authPass;
/**
* Microtime of last request
*
* @var float
*/
protected static $_lastRequestTime = 0;
/**
* Constructs a new del.icio.us Web Services Client
*
* @param string $uname Client username
* @param string $pass Client password
* @return void
*/
public function __construct($uname = null, $pass = null)
{
$this->_rest = new Zend_Rest_Client();
$this->_rest->getHttpClient()->setConfig(array('ssltransport' => 'ssl'));
$this->setAuth($uname, $pass);
}
/**
* Set client username and password
*
* @param string $uname Client user name
* @param string $pass Client password
* @return Zend_Service_Delicious Provides a fluent interface
*/
public function setAuth($uname, $pass)
{
$this->_authUname = $uname;
$this->_authPass = $pass;
return $this;
}
/**
* Get time of the last update
*
* @throws Zend_Service_Delicious_Exception
* @return Zend_Date
*/
public function getLastUpdate()
{
$response = $this->makeRequest(self::PATH_UPDATE);
$rootNode = $response->documentElement;
if ($rootNode && $rootNode->nodeName == 'update') {
/**
* @todo replace strtotime() with Zend_Date equivalent
*/
return new Zend_Date(strtotime($rootNode->getAttribute('time')));
} else {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('del.icio.us web service has returned something odd!');
}
}
/**
* Get all tags, returning an array with tags as keys and number of corresponding posts as values
*
* @return array list of tags
*/
public function getTags()
{
$response = $this->makeRequest(self::PATH_TAGS);
return self::_xmlResponseToArray($response, 'tags', 'tag', 'tag', 'count');
}
/**
* Rename a tag
*
* @param string $old Old tag name
* @param string $new New tag name
* @return Zend_Service_Delicious Provides a fluent interface
*/
public function renameTag($old, $new)
{
$response = $this->makeRequest(self::PATH_TAG_RENAME, array('old' => $old, 'new' => $new));
self::_evalXmlResult($response);
return $this;
}
/**
* Get all bundles, returning an array with bundles as keys and array of tags as values
*
* @return array list of bundles
*/
public function getBundles()
{
$response = $this->makeRequest(self::PATH_BUNDLES);
$bundles = self::_xmlResponseToArray($response, 'bundles', 'bundle', 'name', 'tags');
foreach ($bundles as &$tags) {
$tags = explode(' ', $tags);
}
return $bundles;
}
/**
* Adds a new bundle
*
* @param string $bundle Name of new bundle
* @param array $tags Array of tags
* @return Zend_Service_Delicious Provides a fluent interface
*/
public function addBundle($bundle, array $tags)
{
$tags = implode(' ', (array) $tags);
$response = $this->makeRequest(self::PATH_BUNDLE_ADD, array('bundle' => $bundle, 'tags' => $tags));
self::_evalXmlResult($response);
return $this;
}
/**
* Delete a bundle
*
* @param string $bundle Name of bundle to be deleted
* @return Zend_Service_Delicious Provides a fluent interface
*/
public function deleteBundle($bundle)
{
$response = $this->makeRequest(self::PATH_BUNDLE_DELETE, array('bundle' => $bundle));
self::_evalXmlResult($response);
return $this;
}
/**
* Delete a post
*
* @param string $url URL of post to be deleted
* @return Zend_Service_Delicious Provides a fluent interface
*/
public function deletePost($url)
{
$response = $this->makeRequest(self::PATH_POST_DELETE, array('url' => $url));
self::_evalXmlResult($response);
return $this;
}
/**
* Get number of posts by date
*
* Returns array where keys are dates and values are numbers of posts
*
* @param string $tag Optional filtering by tag
* @return array list of dates
*/
public function getDates($tag = null)
{
$parms = array();
if ($tag) {
$parms['tag'] = $tag;
}
$response = $this->makeRequest(self::PATH_DATES, $parms);
return self::_xmlResponseToArray($response, 'dates', 'date', 'date', 'count');
}
/**
* Get posts matching the arguments
*
* If no date or url is given, most recent date will be used
*
* @param string $tag Optional filtering by tag
* @param Zend_Date $dt Optional filtering by date
* @param string $url Optional filtering by url
* @throws Zend_Service_Delicious_Exception
* @return Zend_Service_Delicious_PostList
*/
public function getPosts($tag = null, Zend_Date $dt = null, $url = null)
{
$parms = array();
if ($tag) {
$parms['tag'] = $tag;
}
if ($url) {
$parms['url'] = $url;
}
if ($dt) {
$parms['dt'] = $dt->get('Y-m-d\TH:i:s\Z');
}
$response = $this->makeRequest(self::PATH_POSTS_GET, $parms);
return $this->_parseXmlPostList($response);
}
/**
* Get all posts
*
* @param string $tag Optional filtering by tag
* @return Zend_Service_Delicious_PostList
*/
public function getAllPosts($tag = null)
{
$parms = array();
if ($tag) {
$parms['tag'] = $tag;
}
$response = $this->makeRequest(self::PATH_POSTS_ALL, $parms);
return $this->_parseXmlPostList($response);
}
/**
* Get recent posts
*
* @param string $tag Optional filtering by tag
* @param string $count Maximum number of posts to be returned (default 15)
* @return Zend_Service_Delicious_PostList
*/
public function getRecentPosts($tag = null, $count = 15)
{
$parms = array();
if ($tag) {
$parms['tag'] = $tag;
}
if ($count) {
$parms['count'] = $count;
}
$response = $this->makeRequest(self::PATH_POSTS_RECENT, $parms);
return $this->_parseXmlPostList($response);
}
/**
* Create new post
*
* @return Zend_Service_Delicious_Post
*/
public function createNewPost($title, $url)
{
return new Zend_Service_Delicious_Post($this, array('title' => $title, 'url' => $url));
}
/**
* Get posts of a user
*
* @param string $user Owner of the posts
* @param int $count Number of posts (default 15, max. 100)
* @param string $tag Optional filtering by tag
* @return Zend_Service_Delicious_PostList
*/
public function getUserPosts($user, $count = null, $tag = null)
{
$parms = array();
if ($count) {
$parms['count'] = $count;
}
$path = sprintf(self::JSON_POSTS, $user, $tag);
$res = $this->makeRequest($path, $parms, 'json');
return new Zend_Service_Delicious_PostList($this, $res);
}
/**
* Get tags of a user
*
* Returned array has tags as keys and number of posts as values
*
* @param string $user Owner of the posts
* @param int $atleast Include only tags for which there are at least ### number of posts
* @param int $count Number of tags to get (default all)
* @param string $sort Order of returned tags ('alpha' || 'count')
* @return array
*/
public function getUserTags($user, $atleast = null, $count = null, $sort = 'alpha')
{
$parms = array();
if ($atleast) {
$parms['atleast'] = $atleast;
}
if ($count) {
$parms['count'] = $count;
}
if ($sort) {
$parms['sort'] = $sort;
}
$path = sprintf(self::JSON_TAGS, $user);
return $this->makeRequest($path, $parms, 'json');
}
/**
* Get network of a user
*
* @param string $user Owner of the network
* @return array
*/
public function getUserNetwork($user)
{
$path = sprintf(self::JSON_NETWORK, $user);
return $this->makeRequest($path, array(), 'json');
}
/**
* Get fans of a user
*
* @param string $user Owner of the fans
* @return array
*/
public function getUserFans($user)
{
$path = sprintf(self::JSON_FANS, $user);
return $this->makeRequest($path, array(), 'json');
}
/**
* Get details on a particular bookmarked URL
*
* Returned array contains four elements:
* - hash - md5 hash of URL
* - top_tags - array of tags and their respective usage counts
* - url - URL for which details were returned
* - total_posts - number of users that have bookmarked URL
*
* If URL hasen't been bookmarked null is returned.
*
* @param string $url URL for which to get details
* @return array
*/
public function getUrlDetails($url)
{
$parms = array('hash' => md5($url));
$res = $this->makeRequest(self::JSON_URL, $parms, 'json');
if(isset($res[0])) {
return $res[0];
} else {
return null;
}
}
/**
* Handles all GET requests to a web service
*
* @param string $path Path
* @param array $parms Array of GET parameters
* @param string $type Type of a request ("xml"|"json")
* @return mixed decoded response from web service
* @throws Zend_Service_Delicious_Exception
*/
public function makeRequest($path, array $parms = array(), $type = 'xml')
{
// if previous request was made less then 1 sec ago
// wait until we can make a new request
$timeDiff = microtime(true) - self::$_lastRequestTime;
if ($timeDiff < 1) {
usleep((1 - $timeDiff) * 1000000);
}
$this->_rest->getHttpClient()->setAuth($this->_authUname, $this->_authPass);
switch ($type) {
case 'xml':
$this->_rest->setUri(self::API_URI);
break;
case 'json':
$parms['raw'] = true;
$this->_rest->setUri(self::JSON_URI);
break;
default:
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('Unknown request type');
}
self::$_lastRequestTime = microtime(true);
$response = $this->_rest->restGet($path, $parms);
if (!$response->isSuccessful()) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception("Http client reported an error: '{$response->getMessage()}'");
}
$responseBody = $response->getBody();
switch ($type) {
case 'xml':
$dom = new DOMDocument() ;
if (!@$dom->loadXML($responseBody)) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('XML Error');
}
return $dom;
case 'json':
return Zend_Json_Decoder::decode($responseBody);
}
}
/**
* Transform XML string to array
*
* @param DOMDocument $response
* @param string $root Name of root tag
* @param string $child Name of children tags
* @param string $attKey Attribute of child tag to be used as a key
* @param string $attValue Attribute of child tag to be used as a value
* @return array
* @throws Zend_Service_Delicious_Exception
*/
private static function _xmlResponseToArray(DOMDocument $response, $root, $child, $attKey, $attValue)
{
$rootNode = $response->documentElement;
$arrOut = array();
if ($rootNode->nodeName == $root) {
$childNodes = $rootNode->childNodes;
for ($i = 0; $i < $childNodes->length; $i++) {
$currentNode = $childNodes->item($i);
if ($currentNode->nodeName == $child) {
$arrOut[$currentNode->getAttribute($attKey)] = $currentNode->getAttribute($attValue);
}
}
} else {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('del.icio.us web service has returned something odd!');
}
return $arrOut;
}
/**
* Constructs Zend_Service_Delicious_PostList from XML response
*
* @param DOMDocument $response
* @return Zend_Service_Delicious_PostList
* @throws Zend_Service_Delicious_Exception
*/
private function _parseXmlPostList(DOMDocument $response)
{
$rootNode = $response->documentElement;
if ($rootNode->nodeName == 'posts') {
return new Zend_Service_Delicious_PostList($this, $rootNode->childNodes);
} else {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('del.icio.us web service has returned something odd!');
}
}
/**
* Evaluates XML response
*
* @param DOMDocument $response
* @return void
* @throws Zend_Service_Delicious_Exception
*/
private static function _evalXmlResult(DOMDocument $response)
{
$rootNode = $response->documentElement;
if ($rootNode && $rootNode->nodeName == 'result') {
if ($rootNode->hasAttribute('code')) {
$strResponse = $rootNode->getAttribute('code');
} else {
$strResponse = $rootNode->nodeValue;
}
if ($strResponse != 'done' && $strResponse != 'ok') {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception("del.icio.us web service: '{$strResponse}'");
}
} else {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('del.icio.us web service has returned something odd!');
}
}
}

View file

@ -0,0 +1,39 @@
<?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_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_Exception extends Zend_Service_Exception
{}

View file

@ -0,0 +1,292 @@
<?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_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Post.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Date
*/
require_once 'Zend/Date.php';
/**
* @see Zend_Service_Delicious_SimplePost
*/
require_once 'Zend/Service/Delicious/SimplePost.php';
/**
* Zend_Service_Delicious_Post represents a post of a user that can be edited
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_Post extends Zend_Service_Delicious_SimplePost
{
/**
* Service that has downloaded the post
*
* @var Zend_Service_Delicious
*/
protected $_service;
/**
* @var int Number of people that have the same post
*/
protected $_others;
/**
* @var Zend_Date Post date
*/
protected $_date;
/**
* @var bool Post share
*/
protected $_shared = true;
/**
* @var string Post hash
*/
protected $_hash;
/**
* Constructs a new del.icio.us post
*
* @param Zend_Service_Delicious $service Service that has downloaded the post
* @param DOMElement|array $values Post content
* @throws Zend_Service_Delicious_Exception
* @return void
*/
public function __construct(Zend_Service_Delicious $service, $values)
{
$this->_service = $service;
if ($values instanceof DOMElement) {
$values = self::_parsePostNode($values);
}
if (!is_array($values) || !isset($values['url']) || !isset($values['title'])) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception("Second argument must be array with at least 2 keys ('url' and"
. " 'title')");
}
if (isset($values['date']) && ! $values['date'] instanceof Zend_Date) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception("Date has to be an instance of Zend_Date");
}
foreach (array('url', 'title', 'notes', 'others', 'tags', 'date', 'shared', 'hash') as $key) {
if (isset($values[$key])) {
$this->{"_$key"} = $values[$key];
}
}
}
/**
* Setter for title
*
* @param string $newTitle
* @return Zend_Service_Delicious_Post
*/
public function setTitle($newTitle)
{
$this->_title = (string) $newTitle;
return $this;
}
/**
* Setter for notes
*
* @param string $newNotes
* @return Zend_Service_Delicious_Post
*/
public function setNotes($newNotes)
{
$this->_notes = (string) $newNotes;
return $this;
}
/**
* Setter for tags
*
* @param array $tags
* @return Zend_Service_Delicious_Post
*/
public function setTags(array $tags)
{
$this->_tags = $tags;
return $this;
}
/**
* Add a tag
*
* @param string $tag
* @return Zend_Service_Delicious_Post
*/
public function addTag($tag)
{
$this->_tags[] = (string) $tag;
return $this;
}
/**
* Remove a tag
*
* @param string $tag
* @return Zend_Service_Delicious_Post
*/
public function removeTag($tag)
{
$this->_tags = array_diff($this->_tags, array((string) $tag));
return $this;
}
/**
* Getter for date
*
* @return Zend_Date
*/
public function getDate()
{
return $this->_date;
}
/**
* Getter for others
*
* This property is only populated when posts are retrieved
* with getPosts() method. The getAllPosts() and getRecentPosts()
* methods will not populate this property.
*
* @return int
*/
public function getOthers()
{
return $this->_others;
}
/**
* Getter for hash
*
* @return string
*/
public function getHash()
{
return $this->_hash;
}
/**
* Getter for shared
*
* @return bool
*/
public function getShared()
{
return $this->_shared;
}
/**
* Setter for shared
*
* @param bool $isShared
* @return Zend_Service_Delicious_Post
*/
public function setShared($isShared)
{
$this->_shared = (bool) $isShared;
return $this;
}
/**
* Deletes post
*
* @return Zend_Service_Delicious
*/
public function delete()
{
return $this->_service->deletePost($this->_url);
}
/**
* Saves post
*
* @return DOMDocument
*/
public function save()
{
$parms = array(
'url' => $this->_url,
'description'=> $this->_title,
'extended' => $this->_notes,
'shared' => ($this->_shared ? 'yes' : 'no'),
'tags' => implode(' ', (array) $this->_tags),
'replace' => 'yes'
);
/*
if ($this->_date instanceof Zend_Date) {
$parms['dt'] = $this->_date->get('Y-m-d\TH:i:s\Z');
}
*/
return $this->_service->makeRequest(Zend_Service_Delicious::PATH_POSTS_ADD, $parms);
}
/**
* Extracts content from the DOM element of a post
*
* @param DOMElement $node
* @return array
*/
protected static function _parsePostNode(DOMElement $node)
{
return array(
'url' => $node->getAttribute('href'),
'title' => $node->getAttribute('description'),
'notes' => $node->getAttribute('extended'),
'others' => (int) $node->getAttribute('others'),
'tags' => explode(' ', $node->getAttribute('tag')),
/**
* @todo replace strtotime() with Zend_Date equivalent
*/
'date' => new Zend_Date(strtotime($node->getAttribute('time'))),
'shared' => ($node->getAttribute('shared') == 'no' ? false : true),
'hash' => $node->getAttribute('hash')
);
}
}

View file

@ -0,0 +1,300 @@
<?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_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PostList.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* List of posts retrived from the del.icio.us web service
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_PostList implements Countable, Iterator, ArrayAccess
{
/**
* @var array Array of Zend_Service_Delicious_Post
*/
protected $_posts = array();
/**
* @var Zend_Service_Delicious Service that has downloaded the post list
*/
protected $_service;
/**
* @var int Iterator key
*/
protected $_iteratorKey = 0;
/**
* @param Zend_Service_Delicious $service Service that has downloaded the post
* @param DOMNodeList|array $posts
* @return void
*/
public function __construct(Zend_Service_Delicious $service, $posts = null)
{
$this->_service = $service;
if ($posts instanceof DOMNodeList) {
$this->_constructFromNodeList($posts);
} else if (is_array($posts)) {
$this->_constructFromArray($posts);
}
}
/**
* Transforms DOMNodeList to array of posts
*
* @param DOMNodeList $nodeList
* @return void
*/
private function _constructFromNodeList(DOMNodeList $nodeList)
{
for ($i = 0; $i < $nodeList->length; $i++) {
$curentNode = $nodeList->item($i);
if($curentNode->nodeName == 'post') {
$this->_addPost(new Zend_Service_Delicious_Post($this->_service, $curentNode));
}
}
}
/**
* Transforms the Array to array of posts
*
* @param array $postList
* @return void
*/
private function _constructFromArray(array $postList)
{
foreach ($postList as $f_post) {
$this->_addPost(new Zend_Service_Delicious_SimplePost($f_post));
}
}
/**
* Add a post
*
* @param Zend_Service_Delicious_SimplePost $post
* @return Zend_Service_Delicious_PostList
*/
protected function _addPost(Zend_Service_Delicious_SimplePost $post)
{
$this->_posts[] = $post;
return $this;
}
/**
* Filter list by list of tags
*
* @param array $tags
* @return Zend_Service_Delicious_PostList
*/
public function withTags(array $tags)
{
$postList = new self($this->_service);
foreach ($this->_posts as $post) {
if (count(array_diff($tags, $post->getTags())) == 0) {
$postList->_addPost($post);
}
}
return $postList;
}
/**
* Filter list by tag
*
* @param string $tag
* @return Zend_Service_Delicious_PostList
*/
public function withTag($tag)
{
return $this->withTags(func_get_args());
}
/**
* Filter list by urls matching a regular expression
*
* @param string $regexp
* @return Zend_Service_Delicious_PostList
*/
public function withUrl($regexp)
{
$postList = new self($this->_service);
foreach ($this->_posts as $post) {
if (preg_match($regexp, $post->getUrl())) {
$postList->_addPost($post);
}
}
return $postList;
}
/**
* Return number of posts
*
* Implement Countable::count()
*
* @return int
*/
public function count()
{
return count($this->_posts);
}
/**
* Return the current element
*
* Implement Iterator::current()
*
* @return Zend_Service_Delicious_SimplePost
*/
public function current()
{
return $this->_posts[$this->_iteratorKey];
}
/**
* Return the key of the current element
*
* Implement Iterator::key()
*
* @return int
*/
public function key()
{
return $this->_iteratorKey;
}
/**
* Move forward to next element
*
* Implement Iterator::next()
*
* @return void
*/
public function next()
{
$this->_iteratorKey += 1;
}
/**
* Rewind the Iterator to the first element
*
* Implement Iterator::rewind()
*
* @return void
*/
public function rewind()
{
$this->_iteratorKey = 0;
}
/**
* Check if there is a current element after calls to rewind() or next()
*
* Implement Iterator::valid()
*
* @return bool
*/
public function valid()
{
$numItems = $this->count();
if ($numItems > 0 && $this->_iteratorKey < $numItems) {
return true;
} else {
return false;
}
}
/**
* Whether the offset exists
*
* Implement ArrayAccess::offsetExists()
*
* @param int $offset
* @return bool
*/
public function offsetExists($offset)
{
return ($offset < $this->count());
}
/**
* Return value at given offset
*
* Implement ArrayAccess::offsetGet()
*
* @param int $offset
* @throws OutOfBoundsException
* @return Zend_Service_Delicious_SimplePost
*/
public function offsetGet($offset)
{
if ($this->offsetExists($offset)) {
return $this->_posts[$offset];
} else {
throw new OutOfBoundsException('Illegal index');
}
}
/**
* Throws exception because all values are read-only
*
* Implement ArrayAccess::offsetSet()
*
* @param int $offset
* @param string $value
* @throws Zend_Service_Delicious_Exception
*/
public function offsetSet($offset, $value)
{
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('You are trying to set read-only property');
}
/**
* Throws exception because all values are read-only
*
* Implement ArrayAccess::offsetUnset()
*
* @param int $offset
* @throws Zend_Service_Delicious_Exception
*/
public function offsetUnset($offset)
{
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('You are trying to unset read-only property');
}
}

View file

@ -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_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SimplePost.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Represents a publicly available post
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_SimplePost
{
/**
* @var string Post url
*/
protected $_url;
/**
* @var string Post title
*/
protected $_title;
/**
* @var string Post notes
*/
protected $_notes;
/**
* @var array Post tags
*/
protected $_tags = array();
/**
* Constructor
*
* @param array $post Post data
* @return void
* @throws Zend_Service_Delicious_Exception
*/
public function __construct(array $post)
{
if (!isset($post['u']) || !isset($post['d'])) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('Title and URL not set.');
}
$this->_url = $post['u'];
$this->_title = $post['d'];
if (isset($post['t'])) {
$this->_tags = $post['t'];
}
if (isset($post['n'])) {
$this->_notes = $post['n'];
}
}
/**
* Getter for URL
*
* @return string
*/
public function getUrl()
{
return $this->_url;
}
/**
* Getter for title
*
* @return string
*/
public function getTitle()
{
return $this->_title;
}
/**
* Getter for notes
*
* @return string
*/
public function getNotes()
{
return $this->_notes;
}
/**
* Getter for tags
*
* @return array
*/
public function getTags()
{
return $this->_tags;
}
}

View file

@ -0,0 +1,399 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: BaseUserService.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Client/ClientAbstract.php';
/**
* @see Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/BaseUserService/GetQuotaInformationResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/BaseUserService/ChangeQuotaPoolResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_BaseUserService_GetAccountBalanceResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/BaseUserService/GetAccountBalanceResponse.php';
/**
* @see Zend_Service_DeveloperGarden_BaseUserService_AccountBalance
*/
require_once 'Zend/Service/DeveloperGarden/BaseUserService/AccountBalance.php';
/**
* @see Zend_Service_DeveloperGarden_Request_BaseUserService_GetQuotaInformation
*/
require_once 'Zend/Service/DeveloperGarden/Request/BaseUserService/GetQuotaInformation.php';
/**
* @see Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool
*/
require_once 'Zend/Service/DeveloperGarden/Request/BaseUserService/ChangeQuotaPool.php';
/**
* @see Zend_Service_DeveloperGarden_Request_BaseUserService_GetAccountBalance
*/
require_once 'Zend/Service/DeveloperGarden/Request/BaseUserService/GetAccountBalance.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_BaseUserService extends Zend_Service_DeveloperGarden_Client_ClientAbstract
{
/**
* wsdl file
*
* @var string
*/
protected $_wsdlFile = 'https://gateway.developer.telekom.com/p3gw-mod-odg-admin/services/ODGBaseUserService?wsdl';
/**
* wsdl file local
*
* @var string
*/
protected $_wsdlFileLocal = 'Wsdl/ODGBaseUserService.wsdl';
/**
* Response, Request Classmapping
*
* @var array
*
*/
protected $_classMap = array(
'getQuotaInformationResponse' =>
'Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse',
'changeQuotaPoolResponse' =>
'Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse',
'getAccountBalanceResponse' =>
'Zend_Service_DeveloperGarden_Response_BaseUserService_GetAccountBalanceResponse',
'AccountBalance' =>
'Zend_Service_DeveloperGarden_BaseUserService_AccountBalance',
);
/**
* array with all QuotaModuleIds
*
* @var array
*/
protected $_moduleIds = array(
'SmsProduction' => 'SmsProduction',
'SmsSandbox' => 'SmsSandbox',
'VoiceCallProduction' => 'VoiceButlerProduction',
'VoiceCallSandbox' => 'VoiceButlerSandbox',
'ConferenceCallProduction' => 'CCSProduction',
'ConferenceCallSandbox' => 'CCSSandbox',
'LocalSearchProduction' => 'localsearchProduction',
'LocalSearchSandbox' => 'localsearchSandbox',
'IPLocationProduction' => 'IPLocationProduction',
'IPLocationSandbox' => 'IPLocationSandbox'
);
/**
* returns an array with all possible ModuleIDs
*
* @return array
*/
public function getModuleIds()
{
return $this->_moduleIds;
}
/**
* checks the moduleId and throws exception if not valid
*
* @param string $moduleId
* @throws Zend_Service_DeveloperGarden_Client_Exception
* @return void
*/
protected function _checkModuleId($moduleId)
{
if (!in_array($moduleId, $this->_moduleIds)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('moduleId not valid');
}
}
/**
* returns the correct module string
*
* @param string $module
* @param integer $environment
* @return string
*/
protected function _buildModuleString($module, $environment)
{
$moduleString = $module;
switch($environment) {
case self::ENV_PRODUCTION :
$moduleString .= 'Production';
break;
case self::ENV_SANDBOX :
$moduleString .= 'Sandbox';
break;
default:
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception(
'Not a valid environment supplied.'
);
}
if (!in_array($moduleString, $this->_moduleIds)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception(
'Not a valid module name supplied.'
);
}
return $moduleString;
}
/**
* returns the request object with the specific moduleId
*
* @param string $moduleId
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
protected function _getRequestModule($moduleId)
{
return new Zend_Service_DeveloperGarden_Request_BaseUserService_GetQuotaInformation(
$moduleId
);
}
/**
* returns the request object with the specific moduleId and new quotaMax value
*
* @param string $moduleId
* @param integer $quotaMax
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
protected function _getChangeRequestModule($moduleId, $quotaMax)
{
return new Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool(
$moduleId,
$quotaMax
);
}
/**
* returns the Quota Information for SMS Service
*
* @param int $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
public function getSmsQuotaInformation($environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('Sms', $environment);
$request = $this->_getRequestModule($moduleId);
return $this->getQuotaInformation($request);
}
/**
* returns the Quota Information for VoiceCall Service
*
* @param int $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
public function getVoiceCallQuotaInformation($environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('VoiceButler', $environment);
$request = $this->_getRequestModule($moduleId);
return $this->getQuotaInformation($request);
}
/**
* returns the Quota Information for SMS ConferenceCall
*
* @param int $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
public function getConfernceCallQuotaInformation($environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('CCS', $environment);
$request = $this->_getRequestModule($moduleId);
return $this->getQuotaInformation($request);
}
/**
* returns the Quota Information for LocaleSearch Service
*
* @param int $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
public function getLocalSearchQuotaInformation($environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('localsearch', $environment);
$request = $this->_getRequestModule($moduleId);
return $this->getQuotaInformation($request);
}
/**
* returns the Quota Information for IPLocation Service
*
* @param int $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
public function getIPLocationQuotaInformation($environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('IPLocation', $environment);
$request = $this->_getRequestModule($moduleId);
return $this->getQuotaInformation($request);
}
/**
* returns the quota information
*
* @param Zend_Service_DeveloperGarden_Request_BaseUserService $request
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetQuotaInformationResponse
*/
public function getQuotaInformation(
Zend_Service_DeveloperGarden_Request_BaseUserService_GetQuotaInformation $request
) {
$this->_checkModuleId($request->getModuleId());
return $this->getSoapClient()
->getQuotaInformation($request)
->parse();
}
/**
* sets new user quota for the sms service
*
* @param integer $quotaMax
* @param integer $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
*/
public function changeSmsQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('Sms', $environment);
$request = $this->_getChangeRequestModule($moduleId, $quotaMax);
return $this->changeQuotaPool($request);
}
/**
* sets new user quota for the voice call service
*
* @param integer $quotaMax
* @param integer $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
*/
public function changeVoiceCallQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('VoiceButler', $environment);
$request = $this->_getChangeRequestModule($moduleId, $quotaMax);
return $this->changeQuotaPool($request);
}
/**
* sets new user quota for the IPLocation service
*
* @param integer $quotaMax
* @param integer $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
*/
public function changeIPLocationQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('IPLocation', $environment);
$request = $this->_getChangeRequestModule($moduleId, $quotaMax);
return $this->changeQuotaPool($request);
}
/**
* sets new user quota for the Conference Call service
*
* @param integer $quotaMax
* @param integer $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
*/
public function changeConferenceCallQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('CCS', $environment);
$request = $this->_getChangeRequestModule($moduleId, $quotaMax);
return $this->changeQuotaPool($request);
}
/**
* sets new user quota for the Local Search service
*
* @param integer $quotaMax
* @param integer $environment
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
*/
public function changeLocalSearchQuotaPool($quotaMax = 0, $environment = self::ENV_PRODUCTION)
{
self::checkEnvironment($environment);
$moduleId = $this->_buildModuleString('localsearch', $environment);
$request = $this->_getChangeRequestModule($moduleId, $quotaMax);
return $this->changeQuotaPool($request);
}
/**
* set new quota values for the defined module
*
* @param Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool $request
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_ChangeQuotaPoolResponse
*/
public function changeQuotaPool(
Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool $request
) {
$this->_checkModuleId($request->getModuleId());
return $this->getSoapClient()
->changeQuotaPool($request)
->parse();
}
/**
* get the result for a list of accounts
*
* @param array $accounts
* @return Zend_Service_DeveloperGarden_Response_BaseUserService_GetAccountBalanceResponse
*/
public function getAccountBalance(array $accounts = array())
{
$request = new Zend_Service_DeveloperGarden_Request_BaseUserService_GetAccountBalance(
$accounts
);
return $this->getSoapClient()
->getAccountBalance($request)
->parse();
}
}

View file

@ -0,0 +1,62 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AccountBalance.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_BaseUserService_AccountBalance
{
/**
* @var integer
*/
public $Account = null;
/**
* @var integer $Credits
*/
public $Credits = null;
/**
* returns the account id
*
* @return integer
*/
public function getAccount()
{
return $this->Account;
}
/**
* returns the credits
*
* @return integer
*/
public function getCredits()
{
return $this->Credits;
}
}

View file

@ -0,0 +1,430 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ClientAbstract.php 20419 2010-01-19 13:20:12Z bate $
*/
/**
* @see Zend_Service_DeveloperGarden_Client_Soap
*/
require_once 'Zend/Service/DeveloperGarden/Client/Soap.php';
/**
* @see Zend_Service_DeveloperGarden_Credential
*/
require_once 'Zend/Service/DeveloperGarden/Credential.php';
/**
* @see Zend_Service_DeveloperGarden_SecurityTokenServer
*/
require_once 'Zend/Service/DeveloperGarden/SecurityTokenServer.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Service_DeveloperGarden_Client_ClientAbstract
{
/**
* constants for using with the odg api
*/
const ENV_PRODUCTION = 1; // Production Environment
const ENV_SANDBOX = 2; // Sandbox Environment, limited access to the api
const ENV_MOCK = 3; // Api calls are without any functionality
const PARTICIPANT_MUTE_OFF = 0; // removes mute from participant in a conference
const PARTICIPANT_MUTE_ON = 1; // mute participant in a conference
const PARTICIPANT_RECALL = 2; // recalls the participant in a conference
/**
* array of all possible env types
*
* @var int
*/
static protected $_consts = null;
/**
* Available options
*
* @var array available options
*/
protected $_options = array();
/**
* The service id to generate the auth service token
*
* @var string
*/
protected $_serviceAuthId = 'https://odg.t-online.de';
/**
* Variable that holds the Zend_Service_DeveloperGarden env value
*
* @var int
*/
protected $_serviceEnvironment = Zend_Service_DeveloperGarden_Client_ClientAbstract::ENV_PRODUCTION;
/**
* wsdl file
*
* @var string
*/
protected $_wsdlFile = null;
/**
* the local wsdlFile
*
* @var string
*/
protected $_wsdlFileLocal = null;
/**
* should we use the local wsdl file?
*
* @var boolean
*/
protected $_useLocalWsdl = true;
/**
* class with credentials
*
* @var Zend_Service_DeveloperGarden_Credential
*/
protected $_credential = null;
/**
* The internal Soap Client
*
* @var Zend_Soap_Client
*/
protected $_soapClient = null;
/**
* array with options for classmapping
*
* @var array
*/
protected $_classMap = array();
/**
* constructor
*
* @param array $options Associative array of options
*/
public function __construct(array $options = array())
{
$this->_credential = new Zend_Service_DeveloperGarden_Credential();
while (list($name, $value) = each($options)) {
switch (ucfirst($name)) {
case 'Username' :
$this->_credential->setUsername($value);
break;
case 'Password' :
$this->_credential->setPassword($value);
break;
case 'Realm' :
$this->_credential->setRealm($value);
break;
case 'Environment' :
$this->setEnvironment($value);
}
}
if (empty($this->_wsdlFile)) {
require_once 'Zend/Service/DeveloperGarden/Exception.php';
throw new Zend_Service_DeveloperGarden_Exception('_wsdlFile not set for this service.');
}
if (!empty($this->_wsdlFileLocal)) {
$this->_wsdlFileLocal = realpath(dirname(__FILE__) . '/../' . $this->_wsdlFileLocal);
}
if (empty($this->_wsdlFileLocal) || $this->_wsdlFileLocal === false) {
require_once 'Zend/Service/DeveloperGarden/Exception.php';
throw new Zend_Service_DeveloperGarden_Exception('_wsdlFileLocal not set for this service.');
}
}
/**
* Set an option
*
* @param string $name
* @param mixed $value
* @throws Zend_Service_DeveloperGarden_Client_Exception
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setOption($name, $value)
{
if (!is_string($name)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('Incorrect option name: ' . $name);
}
$name = strtolower($name);
if (array_key_exists($name, $this->_options)) {
$this->_options[$name] = $value;
}
return $this;
}
/**
* get an option value from the internal options object
*
* @param string $name
* @return mixed
*/
public function getOption($name)
{
$name = strtolower($name);
if (array_key_exists($name, $this->_options)) {
return $this->_options[$name];
}
return null;
}
/**
* returns the internal soap client
* if not allready exists we create an instance of
* Zend_Soap_Client
*
* @final
* @return Zend_Service_DeveloperGarden_Client_Soap
*/
final public function getSoapClient()
{
if ($this->_soapClient === null) {
/**
* init the soapClient
*/
$this->_soapClient = new Zend_Service_DeveloperGarden_Client_Soap(
$this->getWsdl(),
$this->getClientOptions()
);
$this->_soapClient->setCredential($this->_credential);
$tokenService = new Zend_Service_DeveloperGarden_SecurityTokenServer(
array(
'username' => $this->_credential->getUsername(),
'password' => $this->_credential->getPassword(),
'environment' => $this->getEnvironment(),
'realm' => $this->_credential->getRealm(),
)
);
$this->_soapClient->setTokenService($tokenService);
}
return $this->_soapClient;
}
/**
* sets new environment
*
* @param int $environment
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setEnvironment($environment)
{
self::checkEnvironment($environment);
$this->_serviceEnvironment = $environment;
return $this;
}
/**
* returns the current configured environemnt
*
* @return int
*/
public function getEnvironment()
{
return $this->_serviceEnvironment;
}
/**
* returns the wsdl file path, a uri or the local path
*
* @return string
*/
public function getWsdl()
{
if ($this->_useLocalWsdl) {
$retVal = $this->_wsdlFileLocal;
} else {
$retVal = $this->_wsdlFile;
}
return $retVal;
}
/**
* switch to the local wsdl file usage
*
* @param boolen $use
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setUseLocalWsdl($use = true)
{
$this->_useLocalWsdl = (boolean) $use;
return $this;
}
/**
* sets a new wsdl file
*
* @param string $wsdlFile
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setWsdl($wsdlFile = null)
{
if (empty($wsdlFile)) {
require_once 'Zend/Service/DeveloperGarden/Exception.php';
throw new Zend_Service_DeveloperGarden_Exception('_wsdlFile not set for this service.');
}
$this->_wsdlFile = $wsdlFile;
return $this;
}
/**
* sets a new local wsdl file
*
* @param string $wsdlFile
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setLocalWsdl($wsdlFile = null)
{
if (empty($wsdlFile)) {
require_once 'Zend/Service/DeveloperGarden/Exception.php';
throw new Zend_Service_DeveloperGarden_Exception('_wsdlFileLocal not set for this service.');
}
$this->_wsdlFileLocal = $wsdlFile;
return $this;
}
/**
* returns an array with configured options for this client
*
* @return array
*/
public function getClientOptions()
{
$options = array(
'soap_version' => SOAP_1_1,
);
if (!empty($this->_classMap)) {
$options['classmap'] = $this->_classMap;
}
$wsdlCache = Zend_Service_DeveloperGarden_SecurityTokenServer_Cache::getWsdlCache();
if (!is_null($wsdlCache)) {
$options['cache_wsdl'] = $wsdlCache;
}
return $options;
}
/**
* returns the internal credential object
*
* @return Zend_Service_DeveloperGarden_Credential
*/
public function getCredential()
{
return $this->_credential;
}
/**
* helper method to create const arrays
* @return null
*/
static protected function _buildConstArray()
{
$r = new ReflectionClass(__CLASS__);
foreach ($r->getConstants() as $k => $v) {
$s = explode('_', $k, 2);
if (!isset(self::$_consts[$s[0]])) {
self::$_consts[$s[0]] = array();
}
self::$_consts[$s[0]][$v] = $k;
}
}
/**
* returns an array of all available environments
*
* @return array
*/
static public function getParticipantActions()
{
if (empty(self::$_consts)) {
self::_buildConstArray();
}
return self::$_consts['PARTICIPANT'];
}
/**
* checks if the given action is valid
* otherwise it @throws Zend_Service_DeveloperGarden_Exception
*
* @param int $action
* @throws Zend_Service_DeveloperGarden_Client_Exception
* @return void
*/
static public function checkParticipantAction($action)
{
if (!array_key_exists($action, self::getParticipantActions())) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception(
'Wrong Participant Action ' . $action . ' supplied.'
);
}
}
/**
* returns an array of all available environments
*
* @return array
*/
static public function getEnvironments()
{
if (empty(self::$_consts)) {
self::_buildConstArray();
}
return self::$_consts['ENV'];
}
/**
* checks if the given environemnt is valid
* otherwise it @throws Zend_Service_DeveloperGarden_Client_Exception
*
* @param int $environment
* @throws Zend_Service_DeveloperGarden_Client_Exception
* @return void
*/
static public function checkEnvironment($environment)
{
if (!array_key_exists($environment, self::getEnvironments())) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception(
'Wrong environment ' . $environment . ' supplied.'
);
}
}
}

View file

@ -0,0 +1,38 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* Zend_Service_Exception
*/
require_once 'Zend/Service/DeveloperGarden/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Client_Exception extends Zend_Service_DeveloperGarden_Exception
{
}

View file

@ -0,0 +1,340 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Soap.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Soap_Client
*/
require_once 'Zend/Soap/Client.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Client_Soap extends Zend_Soap_Client
{
/**
* class with credential interface
*
* @var Zend_Service_DeveloperGarden_Credential
*/
private $_credential = null;
/**
* WSSE Security Ext Namespace
*
* @var string
*/
const WSSE_NAMESPACE_SECEXT = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
/**
* WSSE Saml Namespace
*
* @var string
*/
const WSSE_NAMESPACE_SAML = 'urn:oasis:names:tc:SAML:2.0:assertion';
/**
* Security Element
*
* @var string
*/
const WSSE_SECURITY_ELEMENT = 'Security';
/**
* UsernameToken Element
*
* @var string
*/
const WSSE_ELEMENT_USERNAMETOKEN = 'UsernameToken';
/**
* Usernae Element
*
* @var string
*/
const WSSE_ELEMENT_USERNAME = 'Username';
/**
* Password Element
*
* @var string
*/
const WSSE_ELEMENT_PASSWORD = 'Password';
/**
* Password Element WSSE Type
*
*/
const WSSE_ELEMENT_PASSWORD_TYPE = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText';
/**
* is this client used by the token service
*
* @var Zend_Service_DeveloperGarden_SecurityTokenServer
*/
protected $_tokenService = null;
/**
* Perform a SOAP call but first check for adding STS Token or fetch one
*
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
/**
* add WSSE Security header
*/
if (!is_null($this->_tokenService)) {
// if login method we addWsseLoginHeader
if (in_array('login', $arguments)) {
$this->addWsseLoginHeader();
} elseif ($name == 'getTokens') {
$this->addWsseTokenHeader($this->_tokenService->getLoginToken());
} else {
$this->addWsseSecurityTokenHeader($this->_tokenService->getTokens());
}
}
return parent::__call($name, $arguments);
}
/**
* sets the internal handling for handle token service
*
* @param Zend_Service_DeveloperGarden_SecurityTokenServer $isTokenService
* @return Zend_Service_DeveloperGarden_Client_Soap
*/
public function setTokenService(Zend_Service_DeveloperGarden_SecurityTokenServer $tokenService)
{
$this->_tokenService = $tokenService;
return $this;
}
/**
* returns the currently configured tokenService object
*
* @return Zend_Service_DeveloperGarden_SecurityTokenServer
*/
public function getTokenService()
{
return $this->_tokenService;
}
/**
* Sets new credential callback object
*
* @param Zend_Service_DeveloperGarden_Credential $credential
* @return Zend_Service_DeveloperGarden_Client_Soap
*/
public function setCredential(Zend_Service_DeveloperGarden_Credential $credential)
{
$this->_credential = $credential;
return $this;
}
/**
* returns the internal credential callback object
*
* @return Zend_Service_DeveloperGarden_Credential
*/
public function getCredential()
{
return $this->_credential;
}
/**
* creates the login header and add
*
* @return SoapHeader
*/
public function getWsseLoginHeader()
{
$dom = new DOMDocument();
/**
* Security Element
*/
$securityElement = $dom->createElementNS(
self::WSSE_NAMESPACE_SECEXT,
'wsse:' . self::WSSE_SECURITY_ELEMENT
);
$securityElement->setAttribute('mustUnderstand', true);
/**
* Username Token Element
*/
$usernameTokenElement = $dom->createElementNS(
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_ELEMENT_USERNAMETOKEN
);
/**
* Username Element
*/
$usernameElement = $dom->createElementNS(
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_ELEMENT_USERNAME,
$this->_credential->getUsername(true)
);
/**
* Password Element
*/
$passwordElement = $dom->createElementNS(
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_ELEMENT_PASSWORD,
$this->_credential->getPassword()
);
$passwordElement->setAttribute('Type', self::WSSE_ELEMENT_PASSWORD_TYPE);
$usernameTokenElement->appendChild($usernameElement);
$usernameTokenElement->appendChild($passwordElement);
$securityElement->appendChild($usernameTokenElement);
$dom->appendChild($securityElement);
$authSoapVar = new SoapVar(
$dom->saveXML($securityElement),
XSD_ANYXML,
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_SECURITY_ELEMENT
);
$authSoapHeader = new SoapHeader(
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_SECURITY_ELEMENT,
$authSoapVar,
true
);
return $authSoapHeader;
}
/**
* creates the token auth header for direct calls
*
* @param Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse $token
* @return SoapHeader
*/
public function getWsseTokenHeader(
Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse $token
) {
$format = '<wsse:%s xmlns:wsse="%s" SOAP-ENV:mustUnderstand="1">%s</wsse:%s>';
$securityHeader = sprintf(
$format,
self::WSSE_SECURITY_ELEMENT,
self::WSSE_NAMESPACE_SECEXT,
$token->getTokenData(),
self::WSSE_SECURITY_ELEMENT
);
$authSoapVar = new SoapVar(
$securityHeader,
XSD_ANYXML,
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_SECURITY_ELEMENT
);
$authSoapHeader = new SoapHeader(
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_SECURITY_ELEMENT,
$authSoapVar,
true
);
return $authSoapHeader;
}
/**
* creates the security token auth header for direct calls
*
* @param Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse $token
* @return SoapHeader
*/
public function getWsseSecurityTokenHeader(
Zend_Service_DeveloperGarden_Response_SecurityTokenServer_GetTokensResponse $token
) {
$format = '<wsse:%s xmlns:wsse="%s" SOAP-ENV:mustUnderstand="1">%s</wsse:%s>';
$securityHeader = sprintf(
$format,
self::WSSE_SECURITY_ELEMENT,
self::WSSE_NAMESPACE_SECEXT,
$token->getTokenData(),
self::WSSE_SECURITY_ELEMENT
);
$authSoapVar = new SoapVar(
$securityHeader,
XSD_ANYXML,
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_SECURITY_ELEMENT
);
$authSoapHeader = new SoapHeader(
self::WSSE_NAMESPACE_SECEXT,
self::WSSE_SECURITY_ELEMENT,
$authSoapVar,
true
);
return $authSoapHeader;
}
/**
* adds the login specific header to the client
*
* @return Zend_Service_DeveloperGarden_Client_Soap
*/
public function addWsseLoginHeader()
{
return $this->addSoapInputHeader($this->getWsseLoginHeader());
}
/**
* adds the earlier fetched token to the header
*
* @param Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse $token
* @return Zend_Service_DeveloperGarden_Client_Soap
*/
public function addWsseTokenHeader(
Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse $token
) {
return $this->addSoapInputHeader($this->getWsseTokenHeader($token));
}
/**
* adds the earlier fetched token to the header
*
* @param Zend_Service_DeveloperGarden_Response_SecurityTokenServer_SecurityTokenResponse $token
* @return Zend_Service_DeveloperGarden_Client_Soap
*/
public function addWsseSecurityTokenHeader(
Zend_Service_DeveloperGarden_Response_SecurityTokenServer_GetTokensResponse $token
) {
return $this->addSoapInputHeader($this->getWsseSecurityTokenHeader($token));
}
}

View file

@ -0,0 +1,872 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ConferenceCall.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Client/ClientAbstract.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/CreateConferenceRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/CreateConferenceResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/CreateConferenceResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_NewParticipantRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/NewParticipantRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_NewParticipantResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/NewParticipantResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_NewParticipantResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/NewParticipantResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_GetParticipantStatusRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/GetParticipantStatusRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetParticipantStatusResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetParticipantStatusResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetParticipantStatusResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetParticipantStatusResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateParticipantRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/UpdateParticipantRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateParticipantResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/UpdateParticipantResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveParticipantRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/RemoveParticipantRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveParticipantResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/RemoveParticipantResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceListRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/GetConferenceListRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceListResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceListResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceListResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceListResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/RemoveConferenceRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveConferenceResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/RemoveConferenceResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/CCSResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceStatusRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/GetConferenceStatusRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceStatusResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceStatusResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceStatusResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceStatusResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_GetRunningConferenceRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/GetRunningConferenceRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetRunningConferenceResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetRunningConferenceResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetRunningConferenceResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetRunningConferenceResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateListRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/GetConferenceTemplateListRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateListResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceTemplateListResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateListResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceTemplateListResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceTemplateRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/CreateConferenceTemplateRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceTemplateResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/CreateConferenceTemplateResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceTemplateResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/CreateConferenceTemplateResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/GetConferenceTemplateRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceTemplateResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceTemplateResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/RemoveConferenceTemplateRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveConferenceTemplateResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/RemoveConferenceTemplateResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/UpdateConferenceTemplateRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateConferenceTemplateResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/UpdateConferenceTemplateResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateParticipantRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/GetConferenceTemplateParticipantRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateParticipantResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceTemplateParticipantResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateParticipantResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/GetConferenceTemplateParticipantResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateParticipantRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/RemoveConferenceTemplateParticipantRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveConferenceTemplateParticipantResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/RemoveConferenceTemplateParticipantResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateParticipantRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/UpdateConferenceTemplateParticipantRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateConferenceTemplateParticipantResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/UpdateConferenceTemplateParticipantResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_AddConferenceTemplateParticipantRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/AddConferenceTemplateParticipantRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_AddConferenceTemplateParticipantResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/AddConferenceTemplateParticipantResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_AddConferenceTemplateParticipantResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/AddConferenceTemplateParticipantResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_CommitConferenceRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/CommitConferenceRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_CommitConferenceResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/CommitConferenceResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/ConferenceCall/UpdateConferenceRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateConferenceResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/ConferenceCall/UpdateConferenceResponse.php';
/**
* @see Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
require_once 'Zend/Service/DeveloperGarden/ConferenceCall/ConferenceDetail.php';
/**
* @see Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
require_once 'Zend/Service/DeveloperGarden/ConferenceCall/ConferenceSchedule.php';
/**
* @see Zend_Service_DeveloperGarden_ConferenceCall_Participant
*/
require_once 'Zend/Service/DeveloperGarden/ConferenceCall/Participant.php';
/**
* @see Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
require_once 'Zend/Service/DeveloperGarden/ConferenceCall/ParticipantDetail.php';
/**
* @see Zend_Service_DeveloperGarden_ConferenceCall_ParticipantStatus
*/
require_once 'Zend/Service/DeveloperGarden/ConferenceCall/ParticipantStatus.php';
/**
* @see Zend_Service_DeveloperGarden_ConferenceCall_ConferenceAccount
*/
require_once 'Zend/Service/DeveloperGarden/ConferenceCall/ConferenceAccount.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall
extends Zend_Service_DeveloperGarden_Client_ClientAbstract
{
/**
* wsdl file
*
* @var string
*/
protected $_wsdlFile = 'https://gateway.developer.telekom.com/p3gw-mod-odg-ccs/services/ccsPort?wsdl';
/**
* the local WSDL file
*
* @var string
*/
protected $_wsdlFileLocal = 'Wsdl/ccsPort.wsdl';
/**
* Response, Request Classmapping
*
* @var array
*
*/
protected $_classMap = array(
//Struct
'ConferenceDetailStruct' => 'Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail',
'ConferenceAccStruct' => 'Zend_Service_DeveloperGarden_ConferenceCall_ConferenceAccount',
'ScheduleStruct' => 'Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule',
'ParticipantStruct' => 'Zend_Service_DeveloperGarden_ConferenceCall_Participant',
'ParticipantDetailStruct' => 'Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail',
'ParticipantStatusStruct' => 'Zend_Service_DeveloperGarden_ConferenceCall_ParticipantStatus',
//Responses
'CCSResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType',
//Conference
'createConferenceResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceResponse',
'createConferenceResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceResponseType',
'removeConferenceResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveConferenceResponse',
'commitConferenceResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_CommitConferenceResponse',
'updateConferenceResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateConferenceResponse',
'getConferenceStatusResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceStatusResponse',
'getConferenceStatusResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceStatusResponseType',
'getRunningConferenceResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetRunningConferenceResponse',
'getRunningConferenceResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetRunningConferenceResponseType',
'getConferenceListResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceListResponse',
'getConferenceListResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceListResponseType',
//Participant
'newParticipantResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_NewParticipantResponse',
'newParticipantResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_NewParticipantResponseType',
'removeParticipantResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveParticipantResponse',
'updateParticipantResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateParticipantResponse',
'getParticipantStatusResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetParticipantStatusResponse',
'getParticipantStatusResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetParticipantStatusResponseType',
//Templates
'createConferenceTemplateResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceTemplateResponse',
'createConferenceTemplateResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceTemplateResponseType',
'getConferenceTemplateResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateResponse',
'getConferenceTemplateResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateResponseType',
'updateConferenceTemplateResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateConferenceTemplateResponse',
'removeConferenceTemplateResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveConferenceTemplateResponse',
'getConferenceTemplateListResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateListResponse',
'getConferenceTemplateListResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateListResponseType',
'addConferenceTemplateParticipantResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_AddConferenceTemplateParticipantResponse',
'addConferenceTemplateParticipantResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_AddConferenceTemplateParticipantResponseType',
'getConferenceTemplateParticipantResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateParticipantResponse',
'getConferenceTemplateParticipantResponseType' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateParticipantResponseType',
'updateConferenceTemplateParticipantResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_UpdateConferenceTemplateParticipantResponse',
'removeConferenceTemplateParticipantResponse' => 'Zend_Service_DeveloperGarden_Response_ConferenceCall_RemoveConferenceTemplateParticipantResponse',
);
/**
* creates a new conference, ownerId should be between 3 and 39
* chars
*
* @param string $ownerId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule
* @param integer $account
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceResponseType
*/
public function createConference($ownerId,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule = null,
$account = null
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest(
$this->getEnvironment(),
$ownerId,
$conferenceDetails,
$conferenceSchedule,
$account
);
$result = $this->getSoapClient()->createConference(array(
'createConferenceRequest' => $request
));
return $result->parse();
}
/**
* commits the given conference
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CommitConferenceResponse
*/
public function commitConference($conferenceId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_CommitConferenceRequest(
$this->getEnvironment(),
$conferenceId
);
$result = $this->getSoapClient()->commitConference(array(
'commitConferenceRequest' => $request
));
return $result->parse();
}
/**
* updates a conference with the given parameter
*
* @param string $conferenceId
* @param string $ownerId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule
* @param string $account
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function updateConference(
$conferenceId,
$ownerId = null,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails = null,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule = null,
$account = null
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceRequest(
$this->getEnvironment(),
$conferenceId,
$ownerId,
$conferenceDetails,
$conferenceSchedule,
$account
);
$result = $this->getSoapClient()->updateConference(array(
'updateConferenceRequest' => $request
));
return $result->parse();
}
/**
* get conference status details
*
* @param string $conferenceId
* @param integer $what
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceStatusResponseType
*/
public function getConferenceStatus($conferenceId, $what = 0)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceStatusRequest(
$this->getEnvironment(),
$conferenceId,
$what
);
$result = $this->getSoapClient()->getConferenceStatus(array(
'getConferenceStatusRequest' => $request
));
return $result->parse();
}
/**
* returns the conferenceId of the running conference instance for a planned
* recurring conference or the current conferenceId
*
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_GetRunningConferenceResponseType
*/
public function getRunningConference($conferenceId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_GetRunningConferenceRequest(
$this->getEnvironment(),
$conferenceId
);
$result = $this->getSoapClient()->getRunningConference(array(
'getRunningConferenceRequest' => $request
));
return $result->parse();
}
/**
* remove a conference
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function removeConference($conferenceId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceRequest(
$this->getEnvironment(),
$conferenceId
);
$result = $this->getSoapClient()->removeConference(array(
'removeConferenceRequest' => $request
));
return $result->parse();
}
/**
* returns a list of conferences
*
* @param integer $what
* @param string $ownerId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceListResponseType
*/
public function getConferenceList($what = 0, $ownerId = null)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceListRequest(
$this->getEnvironment(),
$what,
$ownerId
);
$result = $this->getSoapClient()->getConferenceList(array(
'getConferenceListRequest' => $request
));
return $result->parse();
}
/**
* adds a new participant to the given conference
*
* @param string $conferenceId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_NewParticipantResponseType
*/
public function newParticipant(
$conferenceId,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_NewParticipantRequest(
$this->getEnvironment(),
$conferenceId,
$participant
);
$result = $this->getSoapClient()->newParticipant(array(
'newParticipantRequest' => $request
));
return $result->parse();
}
/**
* fetches the participant details for the given conferenceId
*
* @param string $conferenceId
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_GetParticipantStatusResponseType
*/
public function getParticipantStatus($conferenceId, $participantId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_GetParticipantStatusRequest(
$this->getEnvironment(),
$conferenceId,
$participantId
);
$result = $this->getSoapClient()->getParticipantStatus(array(
'getParticipantStatusRequest' => $request
));
return $result->parse();
}
/**
* removes the given participant from the conference
*
* @param string $conferenceId
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function removeParticipant($conferenceId, $participantId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveParticipantRequest(
$this->getEnvironment(),
$conferenceId,
$participantId
);
$result = $this->getSoapClient()->removeParticipant(array(
'removeParticipantRequest' => $request
));
return $result->parse();
}
/**
* updates the participant in the given conference
*
* @param string $conferenceId
* @param string $participantId
* @param integer $action
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function updateParticipant(
$conferenceId,
$participantId,
$action = null,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant = null
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateParticipantRequest(
$this->getEnvironment(),
$conferenceId,
$participantId,
$action,
$participant
);
$result = $this->getSoapClient()->updateParticipant(array(
'updateParticipantRequest' => $request
));
return $result->parse();
}
/**
* creates a new conference template
*
* @param string $ownerId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
* @param array $participants
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CreateConferenceTemplateResponseType
*/
public function createConferenceTemplate(
$ownerId,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails,
array $participants = null
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceTemplateRequest(
$this->getEnvironment(),
$ownerId,
$conferenceDetails,
$participants
);
$result = $this->getSoapClient()->createConferenceTemplate(array(
'createConferenceTemplateRequest' => $request
));
return $result->parse();
}
/**
* get a specific template
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateResponseType
*/
public function getConferenceTemplate($templateId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateRequest(
$this->getEnvironment(),
$templateId
);
$result = $this->getSoapClient()->getConferenceTemplate(array(
'getConferenceTemplateRequest' => $request
));
return $result->parse();
}
/**
* updates a conference template
*
* @param string $templateId
* @param string $initiatorId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function updateConferenceTemplate(
$templateId,
$initiatorId = null,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails = null
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateRequest(
$this->getEnvironment(),
$templateId,
$initiatorId,
$conferenceDetails
);
$result = $this->getSoapClient()->updateConferenceTemplate(array(
'updateConferenceTemplateRequest' => $request
));
return $result->parse();
}
/**
* remove a conference template
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function removeConferenceTemplate($templateId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateRequest(
$this->getEnvironment(),
$templateId
);
$result = $this->getSoapClient()->removeConferenceTemplate(array(
'removeConferenceTemplateRequest' => $request
));
return $result->parse();
}
/**
* lists all available conference templates for the given owner
*
* @param string $ownerId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateListResponseType
*/
public function getConferenceTemplateList($ownerId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateListRequest(
$this->getEnvironment(),
$ownerId
);
$result = $this->getSoapClient()->getConferenceTemplateList(array(
'getConferenceTemplateListRequest' => $request
));
return $result->parse();
}
/**
* adds a new participants to the template
*
* @param string $templateId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_AddConferenceTemplateParticipantResponseType
*/
public function addConferenceTemplateParticipant(
$templateId,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_AddConferenceTemplateParticipantRequest(
$this->getEnvironment(),
$templateId,
$participant
);
$result = $this->getSoapClient()->addConferenceTemplateParticipant(array(
'addConferenceTemplateParticipantRequest' => $request
));
return $result->parse();
}
/**
* returns a praticipant for the given templateId
*
* @param string $templateId
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_GetConferenceTemplateParticipantResponseType
*/
public function getConferenceTemplateParticipant($templateId, $participantId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateParticipantRequest(
$this->getEnvironment(),
$templateId,
$participantId
);
$result = $this->getSoapClient()->getConferenceTemplateParticipant(array(
'getConferenceTemplateParticipantRequest' => $request
));
return $result->parse();
}
/**
* updates the participants details
*
* @param string $templateId
* @param string $participantId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function updateConferenceTemplateParticipant(
$templateId,
$participantId,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
) {
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateParticipantRequest(
$this->getEnvironment(),
$templateId,
$participantId,
$participant
);
$result = $this->getSoapClient()->updateConferenceTemplateParticipant(array(
'updateConferenceTemplateParticipantRequest' => $request
));
return $result->parse();
}
/**
* removes a praticipant from the given templateId
*
* @param string $templateId
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Response_ConferenceCall_CCSResponseType
*/
public function removeConferenceTemplateParticipant($templateId, $participantId)
{
$request = new Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateParticipantRequest(
$this->getEnvironment(),
$templateId,
$participantId
);
$result = $this->getSoapClient()->removeConferenceTemplateParticipant(array(
'removeConferenceTemplateParticipantRequest' => $request
));
return $result->parse();
}
}

View file

@ -0,0 +1,62 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ConferenceAccount.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall_ConferenceAccount
{
/**
* type of billing
*
* @var string
*/
public $billingtype = null;
/**
* account id
*
* @var integer
*/
public $account = null;
/**
* @return integer
*/
public function getAccount()
{
return $this->account;
}
/**
* @return string
*/
public function getBillingType()
{
return $this->billingtype;
}
}

View file

@ -0,0 +1,129 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ConferenceDetail.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
{
/**
* name of this conference
*
* @var string
*/
public $name = null;
/**
* description of this conference
*
* @var string
*/
public $description = null;
/**
* duration in seconds of this conference
*
* @var integer
*/
public $duration = null;
/**
* create object
*
* @param string $name
* @param string $description
* @param integer $duration
*
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public function __construct($name, $description, $duration)
{
$this->setName($name);
$this->setDescription($description);
$this->setDuration($duration);
}
/**
* sets new duration for this conference in seconds
*
* @param integer $duration
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public function setDuration($duration)
{
$this->duration = $duration;
return $this;
}
/**
* @return string
*/
public function getDuration()
{
return $this->duration;
}
/**
* set the description of this conference
*
* @param $description the $description to set
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* sets the name of this conference
*
* @param string $name
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
}

View file

@ -0,0 +1,262 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ConferenceSchedule.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
{
/**
* @var integer
*/
public $minute = null;
/**
* @var integer
*/
public $hour = null;
/**
* @var integer
*/
public $dayOfMonth = null;
/**
* @var integer
*/
public $month = null;
/**
* @var integer
*/
public $year = null;
/**
* @var integer
*/
public $recurring = 0;
/**
* @var integer
*/
public $notify = 0;
/**
* possible recurring values
*
* @var array
*/
private $_recurringValues = array(
0 => 'no recurring',
1 => 'hourly',
2 => 'daily',
3 => 'weekly',
4 => 'monthly',
);
/**
* constructor for schedule object, all times are in UTC
*
* @param integer $minute
* @param integer $hour
* @param integer $dayOfMonth
* @param integer $month
* @param integer $year
* @param integer $recurring
* @param integer $notify
*/
public function __construct($minute, $hour, $dayOfMonth, $month, $year, $recurring = 0, $notify = 0)
{
$this->setMinute($minute)
->setHour($hour)
->setDayOfMonth($dayOfMonth)
->setMonth($month)
->setYear($year)
->setRecurring($recurring)
->setNotify($notify);
}
/**
* returns the value of $minute
*
* @return integer
*/
public function getMinute()
{
return $this->minute;
}
/**
* sets $minute
*
* @param integer $minute
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public function setMinute($minute)
{
$this->minute = $minute;
return $this;
}
/**
* returns the value of $hour
*
* @return integer
*/
public function getHour()
{
return $this->hour;
}
/**
* sets $hour
*
* @param integer $hour
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public function setHour($hour)
{
$this->hour = $hour;
return $this;
}
/**
* returns the value of $dayOfMonth
*
* @return integer
*/
public function getDayOfMonth()
{
return $this->dayOfMonth;
}
/**
* sets $dayOfMonth
*
* @param integer $dayOfMonth
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public function setDayOfMonth($dayOfMonth)
{
$this->dayOfMonth = $dayOfMonth;
return $this;
}
/**
* returns the value of $month
*
* @return integer
*/
public function getMonth()
{
return $this->month;
}
/**
* sets $month
*
* @param integer $month
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public function setMonth($month)
{
$this->month = $month;
return $this;
}
/**
* returns the value of $year
*
* @return integer
*/
public function getYear()
{
return $this->year;
}
/**
* sets $year
*
* @param integer $year
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public function setYear($year)
{
$this->year = $year;
return $this;
}
/**
* returns the value of $recurring
*
* @return integer
*/
public function getRecurring()
{
return $this->recurring;
}
/**
* sets $recurring
*
* @param integer $recurring
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public function setRecurring($recurring)
{
if (!array_key_exists($recurring, $this->_recurringValues)) {
require_once 'Zend/Service/DeveloperGarden/ConferenceCall/Exception.php';
throw new Zend_Service_DeveloperGarden_ConferenceCall_Exception(
'Unknown ConferenceCall recurring mode.'
);
}
$this->recurring = $recurring;
return $this;
}
/**
* returns the value of $notify
*
* @return integer
*/
public function getNotify()
{
return $this->notify;
}
/**
* sets $notify
*
* @param integer $notify
* @return Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public function setNotify($notify)
{
$this->notify = $notify;
return $this;
}
}

View file

@ -0,0 +1,38 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* Zend_Service_Exception
*/
require_once 'Zend/Service/DeveloperGarden/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall_Exception extends Zend_Service_DeveloperGarden_Exception
{
}

View file

@ -0,0 +1,84 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Participant.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Validate_Ip
*/
require_once 'Zend/Validate/Ip.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall_Participant
{
/**
* @var Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public $detail = null;
/**
* @var string
*/
public $participantId = null;
/**
* @var array
*/
public $status = null;
/**
* participant details
*
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public function getDetail()
{
return $this->detail;
}
/**
* participant id
*
* @return string
*/
public function getParticipantId()
{
return $this->participantId;
}
/**
* get the status
* returns an
* array of Zend_Service_DeveloperGarden_ConferenceCall_ParticipantStatus
*
* @return array
*/
public function getStatus()
{
return $this->status;
}
}

View file

@ -0,0 +1,195 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ParticipantDetail.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Validate_EmailAddress
*/
require_once 'Zend/Validate/EmailAddress.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
{
/**
* @var string
*/
public $firstName = null;
/**
* @var string
*/
public $lastName = null;
/**
* @var string
*/
public $number = null;
/**
* @var string
*/
public $email = null;
/**
* @var integer
*/
public $flags = null;
/**
* constructor for participant object
*
* @param string $firstName
* @param string $lastName
* @param string $number
* @param string $email
* @param integer $isInitiator
*/
public function __construct($firstName, $lastName, $number, $email, $isInitiator = false)
{
$this->setFirstName($firstName)
->setLastName($lastName)
->setNumber($number)
->setEmail($email)
->setFlags((int) $isInitiator);
}
/**
* returns the value of $firstName
*
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* sets $firstName
*
* @param string $firstName
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
return $this;
}
/**
* returns the value of $lastName
*
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* sets $lastName
*
* @param string $lastName
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
return $this;
}
/**
* returns the value of $number
*
* @return string
*/
public function getNumber()
{
return $this->number;
}
/**
* sets $number
*
* @param string $number
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}
/**
* returns the value of $email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* sets $email
*
* @param string email
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public function setEmail($email)
{
$validator = new Zend_Validate_EmailAddress();
if (!$validator->isValid($email)) {
require_once 'Zend/Service/DeveloperGarden/Exception.php';
throw new Zend_Service_DeveloperGarden_Exception('Not a valid e-mail address.');
}
$this->email = $email;
return $this;
}
/**
* returns the value of $flags
*
* @return integer
*/
public function getFlags()
{
return $this->flags;
}
/**
* sets $flags (ie, initiator flag)
*
* @param integer $flags
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public function setFlags($flags)
{
$this->flags = $flags;
return $this;
}
}

View file

@ -0,0 +1,103 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ParticipantStatus.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Validate_Ip
*/
require_once 'Zend/Validate/Ip.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_ConferenceCall_ParticipantStatus
{
/**
* @var string
*/
public $name = null;
/**
* @var string
*/
public $value = null;
/**
* constructor for participant status object
*
* @param string $vame
* @param string $value
*/
public function __construct($name, $value = null)
{
$this->setName($name)
->setValue($value);
}
/**
* returns the value of $name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* sets $name
*
* @param string $name
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantStatus
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* returns the value of $value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* sets $value
*
* @param string $value
* @return Zend_Service_DeveloperGarden_ConferenceCall_ParticipantStatus
*/
public function setValue($value = null)
{
$this->value = $value;
return $this;
}
}

View file

@ -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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Credential.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Credential
{
/**
* Service Auth Username
*
* @var string
*/
protected $_username = null;
/**
* Service Password
*
* @var string
*/
protected $_password = null;
/**
* Service Realm - default t-online.de
*
* @var string
*/
protected $_realm = 't-online.de';
/**
* constructor to init the internal data
*
* @param string $username
* @param string $password
* @param string $realm
* @return Zend_Service_DeveloperGarden_Credential
*/
public function __construct($username = null, $password = null, $realm = null)
{
if (!empty($username)) {
$this->setUsername($username);
}
if (!empty($password)) {
$this->setPassword($password);
}
if (!empty($realm)) {
$this->setRealm($realm);
}
}
/**
* split the password into an array
*
* @param string $password
* @throws Zend_Service_DeveloperGarden_Client_Exception
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setPassword($password = null)
{
if (empty($password)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('Empty password not permitted.');
}
if (!is_string($password)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('Password must be a string.');
}
$this->_password = $password;
return $this;
}
/**
* returns the current configured password
*
* @return string
*/
public function getPassword()
{
return $this->_password;
}
/**
* set the new login
*
* @param string $username
* @throws Zend_Service_DeveloperGarden_Client_Exception
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setUsername($username = null)
{
if (empty($username)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('Empty username not permitted.');
}
if (!is_string($username)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('Username must be a string.');
}
$this->_username = $username;
return $this;
}
/**
* returns the username
*
* if $withRealm == true we combine username and realm like
* username@realm
*
* @param $boolean withRealm
* @return string|null
*/
public function getUsername($withRealm = false)
{
$retValue = $this->_username;
if ($withRealm) {
$retValue = sprintf(
'%s@%s',
$this->_username,
$this->_realm
);
}
return $retValue;
}
/**
* set the new realm
*
* @param string $realm
* @throws Zend_Service_DeveloperGarden_Client_Exception
* @return Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
public function setRealm($realm = null)
{
if (empty($realm)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('Empty realm not permitted.');
}
if (!is_string($realm)) {
require_once 'Zend/Service/DeveloperGarden/Client/Exception.php';
throw new Zend_Service_DeveloperGarden_Client_Exception('Realm must be a string.');
}
$this->_realm = $realm;
return $this;
}
/**
* returns the realm
*
* @return string|null
*/
public function getRealm()
{
return $this->_realm;
}
}

View file

@ -0,0 +1,38 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Exception extends Zend_Service_Exception
{
}

View file

@ -0,0 +1,120 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: IpLocation.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Client/ClientAbstract.php';
/**
* @see Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/IpLocation/LocateIPResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/IpLocation/LocateIPResponse.php';
/**
* @see Zend_Service_DeveloperGarden_Response_IpLocation_IPAddressLocationType
*/
require_once 'Zend/Service/DeveloperGarden/Response/IpLocation/IPAddressLocationType.php';
/**
* @see Zend_Service_DeveloperGarden_Response_IpLocation_RegionType
*/
require_once 'Zend/Service/DeveloperGarden/Response/IpLocation/RegionType.php';
/**
* @see Zend_Service_DeveloperGarden_Response_IpLocation_GeoCoordinatesType
*/
require_once 'Zend/Service/DeveloperGarden/Response/IpLocation/GeoCoordinatesType.php';
/**
* @see Zend_Service_DeveloperGarden_Response_IpLocation_CityType
*/
require_once 'Zend/Service/DeveloperGarden/Response/IpLocation/CityType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_IpLocation_LocateIPRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/IpLocation/LocateIPRequest.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_IpLocation
extends Zend_Service_DeveloperGarden_Client_ClientAbstract
{
/**
* wsdl file
*
* @var string
*/
protected $_wsdlFile = 'https://gateway.developer.telekom.com/p3gw-mod-odg-iplocation/services/IPLocation?wsdl';
/**
* wsdl file local
*
* @var string
*/
protected $_wsdlFileLocal = 'Wsdl/IPLocation.wsdl';
/**
* Response, Request Classmapping
*
* @var array
*
*/
protected $_classMap = array(
'LocateIPResponseType' => 'Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponseType',
'IPAddressLocationType' => 'Zend_Service_DeveloperGarden_Response_IpLocation_IPAddressLocationType',
'RegionType' => 'Zend_Service_DeveloperGarden_Response_IpLocation_RegionType',
'GeoCoordinatesType' => 'Zend_Service_DeveloperGarden_Response_IpLocation_GeoCoordinatesType',
'CityType' => 'Zend_Service_DeveloperGarden_Response_IpLocation_CityType',
);
/**
* locate the given Ip address or array of addresses
*
* @param Zend_Service_DeveloperGarden_IpLocation_IpAddress|string $ip
* @return Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponse
*/
public function locateIP($ip)
{
$request = new Zend_Service_DeveloperGarden_Request_IpLocation_LocateIPRequest(
$this->getEnvironment(),
$ip
);
$result = $this->getSoapClient()->locateIP($request);
$response = new Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponse($result);
return $response->parse();
}
}

View file

@ -0,0 +1,130 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: IpAddress.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Validate_Ip
*/
require_once 'Zend/Validate/Ip.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_IpLocation_IpAddress
{
/**
* the ip version
* ip v4 = 4
* ip v6 = 6
*
* @var integer
*/
private $_version = 4;
/**
* currently supported versions
*
* @var array
*/
private $_versionSupported = array(
4,
//6, not supported yet
);
private $_address = null;
/**
* create ipaddress object
*
* @param string $ip
* @param integer $version
*
* @return Zend_Service_Developergarde_IpLocation_IpAddress
*/
public function __construct($ip, $version = 4)
{
$this->setIp($ip)
->setVersion($version);
}
/**
* sets new ip address
*
* @param string $ip
* @throws Zend_Service_DeveloperGarden_Exception
* @return Zend_Service_DeveloperGarden_IpLocation_IpAddress
*/
public function setIp($ip)
{
$validator = new Zend_Validate_Ip();
if (!$validator->isValid($ip)) {
$message = $validator->getMessages();
require_once 'Zend/Service/DeveloperGarden/Exception.php';
throw new Zend_Service_DeveloperGarden_Exception($message['notIpAddress']);
}
$this->_address = $ip;
return $this;
}
/**
* returns the current address
*
* @return string
*/
public function getIp()
{
return $this->_address;
}
/**
* sets new ip version
*
* @param integer $version
* @throws Zend_Service_DeveloperGarden_Exception
* @return Zend_Service_DeveloperGarden_IpLocation_IpAddress
*/
public function setVersion($version)
{
if (!in_array($version, $this->_versionSupported)) {
require_once 'Zend/Service/DeveloperGarden/Exception.php';
throw new Zend_Service_DeveloperGarden_Exception('Ip Version ' . (int)$version . ' is not supported.');
}
$this->_version = $version;
return $this;
}
/**
* returns the ip version
*
* @return integer
*/
public function getVersion()
{
return $this->_version;
}
}

View file

@ -0,0 +1,105 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: LocalSearch.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Client_ClientAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Client/ClientAbstract.php';
/**
* @see Zend_Service_DeveloperGarden_Response_LocalSearch_LocalSearchResponseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/LocalSearch/LocalSearchResponseType.php';
/**
* @see Zend_Service_DeveloperGarden_Request_LocalSearch_LocalSearchRequest
*/
require_once 'Zend/Service/DeveloperGarden/Request/LocalSearch/LocalSearchRequest.php';
/**
* @see Zend_Service_DeveloperGarden_Response_LocalSearch_LocalSearchResponse
*/
require_once 'Zend/Service/DeveloperGarden/Response/LocalSearch/LocalSearchResponse.php';
/**
* @see Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
require_once 'Zend/Service/DeveloperGarden/LocalSearch/SearchParameters.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_LocalSearch
extends Zend_Service_DeveloperGarden_Client_ClientAbstract
{
/**
* wsdl file
*
* @var string
*/
protected $_wsdlFile = 'https://gateway.developer.telekom.com/p3gw-mod-odg-localsearch/services/localsearch?wsdl';
/**
* wsdl file local
*
* @var string
*/
protected $_wsdlFileLocal = 'Wsdl/localsearch.wsdl';
/**
* Response, Request Classmapping
*
* @var array
*
*/
protected $_classMap = array(
'LocalSearchResponseType' => 'Zend_Service_DeveloperGarden_Response_LocalSearch_LocalSearchResponseType'
);
/**
* localSearch with the given parameters
*
* @param Zend_Service_DeveloperGarden_LocalSearch_SearchParameters $searchParameters
* @param integer $account
* @return Zend_Service_DeveloperGarden_Response_LocalSearch_LocalSearchResponseType
*/
public function localSearch(
Zend_Service_DeveloperGarden_LocalSearch_SearchParameters $searchParameters,
$account = null
) {
$request = new Zend_Service_DeveloperGarden_Request_LocalSearch_LocalSearchRequest(
$this->getEnvironment(),
$searchParameters,
$account
);
$result = $this->getSoapClient()->localSearch($request);
$response = new Zend_Service_DeveloperGarden_Response_LocalSearch_LocalSearchResponse($result);
return $response->parse();
}
}

View file

@ -0,0 +1,38 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* Zend_Service_Exception
*/
require_once 'Zend/Service/DeveloperGarden/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_LocalSearch_Exception extends Zend_Service_DeveloperGarden_Exception
{
}

View file

@ -0,0 +1,536 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SearchParameters.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
{
/**
* possible search parameters, incl. default values
*
* @var array
*/
private $_parameters = array(
'what' => null,
'dymwhat' => null,
'dymrelated' => null,
'hits' => null,
'collapse' => null,
'where' => null,
'dywhere' => null,
'radius' => null,
'lx' => null,
'ly' => null,
'rx' => null,
'ry' => null,
'transformgeocode' => null,
'sort' => null,
'spatial' => null,
'sepcomm' => null,
'filter' => null, // can be ONLINER or OFFLINER
'openingtime' => null, // can be now or HH::MM
'kategorie' => null, // @see http://www.suchen.de/kategorie-katalog
'site' => null,
'typ' => null,
'name' => null,
'page' => null,
'city' => null,
'plz' => null,
'strasse' => null,
'bundesland' => null,
);
/**
* possible collapse values
*
* @var array
*/
private $_possibleCollapseValues = array(
true,
false,
'ADDRESS_COMPANY',
'DOMAIN'
);
/**
* sets a new search word
* alias for setWhat
*
* @param string $searchValue
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setSearchValue($searchValue)
{
return $this->setWhat($searchValue);
}
/**
* sets a new search word
*
* @param string $searchValue
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setWhat($searchValue)
{
$this->_parameters['what'] = $searchValue;
return $this;
}
/**
* enable the did you mean what feature
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function enableDidYouMeanWhat()
{
$this->_parameters['dymwhat'] = 'true';
return $this;
}
/**
* disable the did you mean what feature
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function disableDidYouMeanWhat()
{
$this->_parameters['dymwhat'] = 'false';
return $this;
}
/**
* enable the did you mean where feature
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function enableDidYouMeanWhere()
{
$this->_parameters['dymwhere'] = 'true';
return $this;
}
/**
* disable the did you mean where feature
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function disableDidYouMeanWhere()
{
$this->_parameters['dymwhere'] = 'false';
return $this;
}
/**
* enable did you mean related, if true Kihno will be corrected to Kino
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function enableDidYouMeanRelated()
{
$this->_parameters['dymrelated'] = 'true';
return $this;
}
/**
* diable did you mean related, if false Kihno will not be corrected to Kino
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function disableDidYouMeanRelated()
{
$this->_parameters['dymrelated'] = 'true';
return $this;
}
/**
* set the max result hits for this search
*
* @param integer $hits
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setHits($hits = 10)
{
require_once 'Zend/Validate/Between.php';
$validator = new Zend_Validate_Between(0, 1000);
if (!$validator->isValid($hits)) {
$message = $validator->getMessages();
require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
throw new Zend_Service_DeveloperGarden_LocalSearch_Exception(current($message));
}
$this->_parameters['hits'] = $hits;
return $this;
}
/**
* If true, addresses will be collapsed for a single domain, common values
* are:
* ADDRESS_COMPANY to collapse by address
* DOMAIN to collapse by domain (same like collapse=true)
* false
*
* @param mixed $value
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setCollapse($value)
{
if (!in_array($value, $this->_possibleCollapseValues, true)) {
require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
throw new Zend_Service_DeveloperGarden_LocalSearch_Exception('Not a valid value provided.');
}
$this->_parameters['collapse'] = $value;
return $this;
}
/**
* set a specific search location
* examples:
* +47°5453.10, 11° 10 56.76
* 47°5453.10;11°1056.76
* 47.914750,11.182533
* +47.914750 ; +11.1824
* Darmstadt
* Berlin
*
* @param string $where
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setWhere($where)
{
require_once 'Zend/Validate/NotEmpty.php';
$validator = new Zend_Validate_NotEmpty();
if (!$validator->isValid($where)) {
$message = $validator->getMessages();
require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
throw new Zend_Service_DeveloperGarden_LocalSearch_Exception(current($message));
}
$this->_parameters['where'] = $where;
return $this;
}
/**
* returns the defined search location (ie city, country)
*
* @return string
*/
public function getWhere()
{
return $this->_parameters['where'];
}
/**
* enable the spatial search feature
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function enableSpatial()
{
$this->_parameters['spatial'] = 'true';
return $this;
}
/**
* disable the spatial search feature
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function disableSpatial()
{
$this->_parameters['spatial'] = 'false';
return $this;
}
/**
* sets spatial and the given radius for a circle search
*
* @param integer $radius
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setRadius($radius)
{
require_once 'Zend/Validate/Int.php';
$validator = new Zend_Validate_Int();
if (!$validator->isValid($radius)) {
$message = $validator->getMessages();
require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
throw new Zend_Service_DeveloperGarden_LocalSearch_Exception(current($message));
}
$this->_parameters['radius'] = $radius;
$this->_parameters['transformgeocode'] = 'false';
return $this;
}
/**
* sets the values for a rectangle search
* lx = longitude left top
* ly = latitude left top
* rx = longitude right bottom
* ry = latitude right bottom
*
* @param $lx
* @param $ly
* @param $rx
* @param $ry
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setRectangle($lx, $ly, $rx, $ry)
{
$this->_parameters['lx'] = $lx;
$this->_parameters['ly'] = $ly;
$this->_parameters['rx'] = $rx;
$this->_parameters['ry'] = $ry;
return $this;
}
/**
* if set, the service returns the zipcode for the result
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setTransformGeoCode()
{
$this->_parameters['transformgeocode'] = 'true';
$this->_parameters['radius'] = null;
return $this;
}
/**
* sets the sort value
* possible values are: 'relevance' and 'distance' (only with spatial enabled)
*
* @param string $sort
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setSort($sort)
{
if (!in_array($sort, array('relevance', 'distance'))) {
require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
throw new Zend_Service_DeveloperGarden_LocalSearch_Exception('Not a valid sort value provided.');
}
$this->_parameters['sort'] = $sort;
return $this;
}
/**
* enable the separation of phone numbers
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function enablePhoneSeparation()
{
$this->_parameters['sepcomm'] = 'true';
return $this;
}
/**
* disable the separation of phone numbers
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function disablePhoneSeparation()
{
$this->_parameters['sepcomm'] = 'true';
return $this;
}
/**
* if this filter is set, only results with a website are returned
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setFilterOnliner()
{
$this->_parameters['filter'] = 'ONLINER';
return $this;
}
/**
* if this filter is set, only results without a website are returned
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setFilterOffliner()
{
$this->_parameters['filter'] = 'OFFLINER';
return $this;
}
/**
* removes the filter value
*
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function disableFilter()
{
$this->_parameters['filter'] = null;
return $this;
}
/**
* set a filter to get just results who are open at the given time
* possible values:
* now = open right now
* HH:MM = at the given time (ie 20:00)
*
* @param string $time
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setOpeningTime($time = null)
{
$this->_parameters['openingtime'] = $time;
return $this;
}
/**
* sets a category filter
*
* @see http://www.suchen.de/kategorie-katalog
* @param $category
* @return unknown_type
*/
public function setCategory($category = null)
{
$this->_parameters['kategorie'] = $category;
return $this;
}
/**
* sets the site filter
* ie: www.developergarden.com
*
* @param string $site
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setSite($site)
{
$this->_parameters['site'] = $site;
return $this;
}
/**
* sets a filter to the given document type
* ie: pdf, html
*
* @param string $type
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setDocumentType($type)
{
$this->_parameters['typ'] = $type;
return $this;
}
/**
* sets a filter for the company name
* ie: Deutsche Telekom
*
* @param string $name
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setName($name)
{
$this->_parameters['name'] = $name;
return $this;
}
/**
* sets a filter for the zip code
*
* @param string $zip
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setZipCode($zip)
{
$this->_parameters['plz'] = $zip;
return $this;
}
/**
* sets a filter for the street
*
* @param string $street
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setStreet($street)
{
$this->_parameters['strasse'] = $street;
return $this;
}
/**
* sets a filter for the county
*
* @param string $county
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function setCounty($county)
{
$this->_parameters['bundesland'] = $county;
return $this;
}
/**
* sets a raw parameter with the value
*
* @param string $key
* @param mixed $value
* @return unknown_type
*/
public function setRawParameter($key, $value)
{
$this->_parameters[$key] = $value;
return $this;
}
/**
* returns the parameters as an array
*
* @return array
*/
public function getSearchParameters()
{
$retVal = array();
foreach ($this->_parameters as $key => $value) {
if (is_null($value)) {
continue;
}
$param = array(
'parameter' => $key,
'value' => $value
);
$retVal[] = $param;
}
return $retVal;
}
}

View file

@ -0,0 +1,103 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ChangeQuotaPool.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_BaseUserService_ChangeQuotaPool
{
/**
* string module id
*
* @var string
*/
public $moduleId = null;
/**
* integer >= 0 to set new user quota
*
* @var integer
*/
public $quotaMax = 0;
/**
* constructor give them the module id
*
* @param string $moduleId
* @param integer $quotaMax
* @return Zend_Service_Developergarde_Request_ChangeQuotaPool
*/
public function __construct($moduleId = null, $quotaMax = 0)
{
$this->setModuleId($moduleId)
->setQuotaMax($quotaMax);
}
/**
* sets a new moduleId
*
* @param integer $moduleId
* @return Zend_Service_Developergarde_Request_ChangeQuotaPool
*/
public function setModuleId($moduleId = null)
{
$this->moduleId = $moduleId;
return $this;
}
/**
* returns the moduleId
*
* @return string
*/
public function getModuleId()
{
return $this->moduleId;
}
/**
* sets new QuotaMax value
*
* @param integer $quotaMax
* @return Zend_Service_Developergarde_Request_ChangeQuotaPool
*/
public function setQuotaMax($quotaMax = 0)
{
$this->quotaMax = $quotaMax;
return $this;
}
/**
* returns the quotaMax value
*
* @return integer
*/
public function getQuotaMax()
{
return $this->quotaMax;
}
}

View file

@ -0,0 +1,72 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetAccountBalance.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_BaseUserService_GetAccountBalance
{
/**
* array of accounts
*
* @var array
*/
public $Account = array();
/**
* constructor give them the account ids or an empty array
*
* @param array $Account
* @return Zend_Service_DeveloperGarden_Request_GetAccountBalance
*/
public function __construct(array $Account = array())
{
$this->setAccount($Account);
}
/**
* sets a new Account array
*
* @param array $Account
* @return Zend_Service_DeveloperGarden_Request_BaseUserService
*/
public function setAccount(array $Account = array())
{
$this->Account = $Account;
return $this;
}
/**
* returns the moduleId
*
* @return string
*/
public function getAccount()
{
return $this->Account;
}
}

View file

@ -0,0 +1,72 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetQuotaInformation.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_BaseUserService_GetQuotaInformation
{
/**
* string module id
*
* @var string
*/
public $moduleId = null;
/**
* constructor give them the module id
*
* @param string $moduleId
* @return Zend_Service_DeveloperGarden_Request_BaseUserService
*/
public function __construct($moduleId = null)
{
$this->setModuleId($moduleId);
}
/**
* sets a new moduleId
*
* @param integer $moduleId
* @return Zend_Service_DeveloperGarden_Request_BaseUserService
*/
public function setModuleId($moduleId = null)
{
$this->moduleId = $moduleId;
return $this;
}
/**
* returns the moduleId
*
* @return string
*/
public function getModuleId()
{
return $this->moduleId;
}
}

View file

@ -0,0 +1,91 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AddConferenceTemplateParticipantRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_AddConferenceTemplateParticipantRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the template id
*
* @var string
*/
public $templateId = null;
/**
* the participant details
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public $participant = null;
/**
* constructor
*
* @param integer $environment
* @param string $templateId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
*/
public function __construct($environment, $templateId,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant = null
) {
parent::__construct($environment);
$this->setTemplateId($templateId)
->setParticipant($participant);
}
/**
* set the template id
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_AddConferenceTemplateParticipantRequest
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
/**
* sets new participant
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_AddConferenceTemplateParticipantRequest
*/
public function setParticipant(Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant)
{
$this->participant = $participant;
return $this;
}
}

View file

@ -0,0 +1,69 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CommitConferenceRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_CommitConferenceRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
*/
public function __construct($environment, $conferenceId)
{
parent::__construct($environment);
$this->setConferenceId($conferenceId);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CommitConferenceRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
}

View file

@ -0,0 +1,136 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CreateConferenceRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* account to be used for this conference
*
* @var integer
*/
public $account = null;
/**
* unique owner id
*
* @var string
*/
public $ownerId = null;
/**
* object with details for this conference
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public $detail = null;
/**
* object with schedule for this conference
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public $schedule = null;
/**
* constructor
*
* @param integer $environment
* @param string $ownerId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule
* @param integer $account
*/
public function __construct($environment, $ownerId,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule = null,
$account = null
) {
parent::__construct($environment);
$this->setOwnerId($ownerId)
->setDetail($conferenceDetails)
->setSchedule($conferenceSchedule)
->setAccount($account);
}
/**
* sets $schedule
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $schedule
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setSchedule(
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $schedule = null
) {
$this->schedule = $schedule;
return $this;
}
/**
* sets $detail
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setDetail(Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail)
{
$this->detail = $detail;
return $this;
}
/**
* sets $ownerId
*
* @param string $ownerId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setOwnerId($ownerId)
{
$this->ownerId = $ownerId;
return $this;
}
/**
* sets $account
*
* @param $account
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setAccount($account = null)
{
$this->account = $account;
return $this;
}
}

View file

@ -0,0 +1,113 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CreateConferenceTemplateRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceTemplateRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* unique owner id
*
* @var string
*/
public $ownerId = null;
/**
* object with details for this conference
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public $detail = null;
/**
* array with Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail elements
*
* @var array
*/
public $participants = null;
/**
* constructor
*
* @param integer $environment
* @param string $ownerId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
* @param array $conferenceParticipants
*/
public function __construct($environment, $ownerId,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails,
array $conferenceParticipants = null
) {
parent::__construct($environment);
$this->setOwnerId($ownerId)
->setDetail($conferenceDetails)
->setParticipants($conferenceParticipants);
}
/**
* sets $participants
*
* @param array $participants
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceTemplateRequest
*/
public function setParticipants(array $participants = null)
{
$this->participants = $participants;
return $this;
}
/**
* sets $detail
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceTemplateRequest
*/
public function setDetail(Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail)
{
$this->detail = $detail;
return $this;
}
/**
* sets $ownerId
*
* @param string $ownerId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceTemplateRequest
*/
public function setOwnerId($ownerId)
{
$this->ownerId = $ownerId;
return $this;
}
}

View file

@ -0,0 +1,104 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetConferenceListRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceListRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* @var integer
*/
public $what = null;
/**
* possible what values
*
* @var array
*/
private $_whatValues = array(
0 => 'all conferences',
1 => 'just ad-hoc conferences',
2 => 'just planned conferences',
3 => 'just failed conferences',
);
/**
* unique owner id
*
* @var string
*/
public $ownerId = null;
/**
* constructor
*
* @param integer $environment
* @param integer $what
* @param string $ownerId
*/
public function __construct($environment, $what = 0, $ownerId = null)
{
parent::__construct($environment);
$this->setWhat($what)
->setOwnerId($ownerId);
}
/**
* sets $what
*
* @param integer $what
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceListRequest
*/
public function setWhat($what)
{
if (!array_key_exists($what, $this->_whatValues)) {
require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
throw new Zend_Service_DeveloperGarden_Request_Exception('What value not allowed.');
}
$this->what = $what;
return $this;
}
/**
* sets $ownerId
*
* @param $ownerId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceListRequest
*/
public function setOwnerId($ownerId)
{
$this->ownerId = $ownerId;
return $this;
}
}

View file

@ -0,0 +1,106 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetConferenceStatusRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceStatusRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* what
*
* @var integer
*/
public $what = null;
/**
* possible what values
*
* @var array
*/
private $_whatValues = array(
0 => 'all conferences',
1 => 'just detail, acc and startTime',
2 => 'just participants',
3 => 'just schedule',
);
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
* @param integer $what
*/
public function __construct($environment, $conferenceId, $what)
{
parent::__construct($environment);
$this->setConferenceId($conferenceId)
->setWhat($what);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceStatusRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
/**
* sets $what
*
* @param integer $what
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceStatusRequest
*/
public function setWhat($what)
{
if (!array_key_exists($what, $this->_whatValues)) {
require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
throw new Zend_Service_DeveloperGarden_Request_Exception('What value not allowed.');
}
$this->what = $what;
return $this;
}
}

View file

@ -0,0 +1,69 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetConferenceTemplateListRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateListRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* unique owner id
*
* @var string
*/
public $ownerId = null;
/**
* constructor
*
* @param integer $environment
* @param string $ownerId
*/
public function __construct($environment, $ownerId = null)
{
parent::__construct($environment);
$this->setOwnerId($ownerId);
}
/**
* sets $ownerId
*
* @param $ownerId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateListRequest
*/
public function setOwnerId($ownerId)
{
$this->ownerId = $ownerId;
return $this;
}
}

View file

@ -0,0 +1,90 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetConferenceTemplateParticipantRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateParticipantRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the template id
*
* @var string
*/
public $templateId = null;
/**
* the participant id
*
* @var string
*/
public $participantId = null;
/**
* constructor
*
* @param integer $environment
* @param string $templateId
* @param string $participantId
*/
public function __construct($environment, $templateId, $participantId)
{
parent::__construct($environment);
$this->setTemplateId($templateId)
->setParticipantId($participantId);
}
/**
* set the template id
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateParticipantRequest
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
/**
* set the participant id
*
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateParticipantRequest
*/
public function setParticipantId($participantId)
{
$this->participantId = $participantId;
return $this;
}
}

View file

@ -0,0 +1,69 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetConferenceTemplateRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the template id
*
* @var string
*/
public $templateId = null;
/**
* constructor
*
* @param integer $environment
* @param string $templateId
*/
public function __construct($environment, $templateId)
{
parent::__construct($environment);
$this->setTemplateId($templateId);
}
/**
* set the template id
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetConferenceTemplateRequest
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
}

View file

@ -0,0 +1,90 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetParticipantStatusRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_GetParticipantStatusRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* the participant id
*
* @var string
*/
public $participantId = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
* @param string $participantId
*/
public function __construct($environment, $conferenceId, $participantId)
{
parent::__construct($environment);
$this->setConferenceId($conferenceId)
->setParticipantId($participantId);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetParticipantStatusRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
/**
* set the participant id
*
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetParticipantStatusRequest
*/
public function setParticipantId($participantId)
{
$this->participantId = $participantId;
return $this;
}
}

View file

@ -0,0 +1,69 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetRunningConferenceRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_GetRunningConferenceRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
*/
public function __construct($environment, $conferenceId)
{
parent::__construct($environment);
$this->setConferenceId($conferenceId);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_GetRunningConferenceRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
}

View file

@ -0,0 +1,91 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NewParticipantRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_NewParticipantRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* conference participant
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public $participant = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
*/
public function __construct($environment, $conferenceId,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant)
{
parent::__construct($environment);
$this->setConferenceId($conferenceId)
->setParticipant($participant);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_NewParticipantRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
/**
* sets new participant
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_NewParticipantRequest
*/
public function setParticipant(Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant)
{
$this->participant = $participant;
return $this;
}
}

View file

@ -0,0 +1,69 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RemoveConferenceRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
*/
public function __construct($environment, $conferenceId)
{
parent::__construct($environment);
$this->setConferenceId($conferenceId);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
}

View file

@ -0,0 +1,90 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RemoveConferenceTemplateParticipantRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateParticipantRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the template id
*
* @var string
*/
public $templateId = null;
/**
* the participant id
*
* @var string
*/
public $participantId = null;
/**
* constructor
*
* @param integer $environment
* @param string $templateId
* @param string $participantId
*/
public function __construct($environment, $templateId, $participantId)
{
parent::__construct($environment);
$this->setTemplateId($templateId)
->setParticipantId($participantId);
}
/**
* set the template id
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateParticipantRequest
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
/**
* set the participant id
*
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateParticipantRequest
*/
public function setParticipantId($participantId)
{
$this->participantId = $participantId;
return $this;
}
}

View file

@ -0,0 +1,69 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RemoveConferenceTemplateRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the template id
*
* @var string
*/
public $templateId = null;
/**
* constructor
*
* @param integer $environment
* @param string $templateId
*/
public function __construct($environment, $templateId)
{
parent::__construct($environment);
$this->setTemplateId($templateId);
}
/**
* set the template id
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveConferenceTemplateRequest
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
}

View file

@ -0,0 +1,90 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RemoveParticipantRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveParticipantRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* the participant id
*
* @var string
*/
public $participantId = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
* @param string $participantId
*/
public function __construct($environment, $conferenceId, $participantId)
{
parent::__construct($environment);
$this->setConferenceId($conferenceId)
->setParticipantId($participantId);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveParticipantRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
/**
* set the participant id
*
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_RemoveParticipantRequest
*/
public function setParticipantId($participantId)
{
$this->participantId = $participantId;
return $this;
}
}

View file

@ -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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: UpdateConferenceRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* conference id
*
* @var string
*/
public $conferenceId = null;
/**
* account to be used for this conference
*
* @var integer
*/
public $account = null;
/**
* unique owner id
*
* @var string
*/
public $ownerId = null;
/**
* object with details for this conference
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public $detail = null;
/**
* object with schedule for this conference
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule
*/
public $schedule = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
* @param string $ownerId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule
* @param integer $account
*/
public function __construct($environment, $conferenceId, $ownerId = null,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails = null,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $conferenceSchedule = null,
$account = null
) {
parent::__construct($environment);
$this->setConferenceId($conferenceId)
->setOwnerId($ownerId)
->setDetail($conferenceDetails)
->setSchedule($conferenceSchedule)
->setAccount($account);
}
/**
* sets $conferenceId
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId= $conferenceId;
return $this;
}
/**
* sets $schedule
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $schedule
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setSchedule(
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceSchedule $schedule = null
) {
$this->schedule = $schedule;
return $this;
}
/**
* sets $detail
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setDetail(
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail = null
) {
$this->detail = $detail;
return $this;
}
/**
* sets $ownerId
*
* @param string $ownerId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setOwnerId($ownerId = null)
{
$this->ownerId = $ownerId;
return $this;
}
/**
* sets $account
*
* @param $account
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_CreateConferenceRequest
*/
public function setAccount($account = null)
{
$this->account = $account;
return $this;
}
}

View file

@ -0,0 +1,113 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: UpdateConferenceTemplateParticipantRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateParticipantRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the template id
*
* @var string
*/
public $templateId = null;
/**
* the participant id
*
* @var string
*/
public $participantId = null;
/**
* the participant details
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public $participant = null;
/**
* constructor
*
* @param integer $environment
* @param string $templateId
* @param string $participantId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
*/
public function __construct($environment, $templateId, $participantId,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant = null
) {
parent::__construct($environment);
$this->setTemplateId($templateId)
->setParticipantId($participantId)
->setParticipant($participant);
}
/**
* set the template id
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateParticipantRequest
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
/**
* set the participant id
*
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateParticipantRequest
*/
public function setParticipantId($participantId)
{
$this->participantId = $participantId;
return $this;
}
/**
* sets new participant
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateParticipantRequest
*/
public function setParticipant(
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
) {
$this->participant = $participant;
return $this;
}
}

View file

@ -0,0 +1,113 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: UpdateConferenceTemplateRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the template id
*
* @var string
*/
public $templateId = null;
/**
* the initiator id
*
* @var string
*/
public $initiatorId = null;
/**
* the details
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail
*/
public $detail = null;
/**
* constructor
*
* @param integer $environment
* @param string $templateId
* @param string $initiatorId
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails
*/
public function __construct($environment, $templateId, $initiatorId = null,
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $conferenceDetails = null
) {
parent::__construct($environment);
$this->setTemplateId($templateId)
->setInitiatorId($initiatorId)
->setDetail($conferenceDetails);
}
/**
* set the template id
*
* @param string $templateId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateRequest
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
/**
* set the initiator id
*
* @param string $initiatorId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateRequest
*/
public function setInitiatorId($initiatorId)
{
$this->initiatorId = $initiatorId;
return $this;
}
/**
* sets $detail
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateConferenceTemplateRequest
*/
public function setDetail(
Zend_Service_DeveloperGarden_ConferenceCall_ConferenceDetail $detail = null
) {
$this->detail = $detail;
return $this;
}
}

View file

@ -0,0 +1,138 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: UpdateParticipantRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateParticipantRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the conference id
*
* @var string
*/
public $conferenceId = null;
/**
* the participant id
*
* @var string
*/
public $participantId = null;
/**
* conference participant
*
* @var Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail
*/
public $participant = null;
/**
* possible action
*
* @var integer
*/
public $action = null;
/**
* constructor
*
* @param integer $environment
* @param string $conferenceId
* @param string $participantId
* @param integer $action
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
*/
public function __construct($environment, $conferenceId, $participantId,
$action = null,
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant = null
) {
parent::__construct($environment);
$this->setConferenceId($conferenceId)
->setParticipantId($participantId)
->setAction($action)
->setParticipant($participant);
}
/**
* set the conference id
*
* @param string $conferenceId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateParticipantRequest
*/
public function setConferenceId($conferenceId)
{
$this->conferenceId = $conferenceId;
return $this;
}
/**
* set the participant id
*
* @param string $participantId
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateParticipantRequest
*/
public function setParticipantId($participantId)
{
$this->participantId = $participantId;
return $this;
}
/**
* sets new action
*
* @param integer $action
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateParticipantRequest
*/
public function setAction($action = null)
{
if ($action !== null) {
Zend_Service_DeveloperGarden_ConferenceCall::checkParticipantAction($action);
}
$this->action = $action;
return $this;
}
/**
* sets new participant
*
* @param Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant
* @return Zend_Service_DeveloperGarden_Request_ConferenceCall_UpdateParticipantRequest
*/
public function setParticipant(
Zend_Service_DeveloperGarden_ConferenceCall_ParticipantDetail $participant = null
) {
$this->participant = $participant;
return $this;
}
}

View file

@ -0,0 +1,39 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* Zend_Service_DeveloperGarden_Exception
*/
require_once 'Zend/Service/DeveloperGarden/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_Exception
extends Zend_Service_DeveloperGarden_Exception
{
}

View file

@ -0,0 +1,114 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: LocateIPRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @see Zend_Service_DeveloperGarden_IpLocation_IpAddress
*/
require_once 'Zend/Service/DeveloperGarden/IpLocation/IpAddress.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_IpLocation_LocateIPRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the ip addresses to lookup for
*
* @var Zend_Service_DeveloperGarden_Request_IpLocation_IpAddress
*/
public $address = null;
/**
* the account
*
* @var string
*/
public $account = null;
/**
* constructor give them the environment
*
* @param integer $environment
* @param Zend_Service_DeveloperGarden_IpLocation_IpAddress|array $ip
*
* @return Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
public function __construct($environment, $ip = null)
{
parent::__construct($environment);
if ($ip !== null) {
$this->setIp($ip);
}
}
/**
* sets new ip or array of ips
*
* @param Zend_Service_DeveloperGarden_IpLocation_IpAddress|array $ip
*
* @return Zend_Service_DeveloperGarden_Request_IpLocation_LocateIPRequest
*/
public function setIp($ip)
{
if ($ip instanceof Zend_Service_DeveloperGarden_IpLocation_IpAddress) {
$this->address[] = array(
'ipType' => $ip->getVersion(),
'ipAddress' => $ip->getIp(),
);
return $this;
}
if (is_array($ip)) {
foreach ($ip as $ipObject) {
if (!$ipObject instanceof Zend_Service_DeveloperGarden_IpLocation_IpAddress
&& !is_string($ipObject)
) {
require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
throw new Zend_Service_DeveloperGarden_Request_Exception(
'Not a valid Ip Address object found.'
);
}
$this->setIp($ipObject);
}
return $this;
}
if (!is_string($ip)) {
require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
throw new Zend_Service_DeveloperGarden_Request_Exception('Not a valid Ip Address object found.');
}
return $this->setIp(new Zend_Service_DeveloperGarden_IpLocation_IpAddress($ip));
}
}

View file

@ -0,0 +1,113 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: LocalSearchRequest.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_LocalSearch_LocalSearchRequest
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* array of search parameters
*
* @var array
*/
public $searchParameters = null;
/**
* original object
*
* @var Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
private $_searchParameters = null;
/**
* account id
*
* @var integer
*/
public $account = null;
/**
* constructor give them the environment and the sessionId
*
* @param integer $environment
* @param Zend_Service_DeveloperGarden_LocalSearch_SearchParameters $searchParameters
* @param integer $account
* @return Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
public function __construct($environment,
Zend_Service_DeveloperGarden_LocalSearch_SearchParameters $searchParameters,
$account = null
) {
parent::__construct($environment);
$this->setSearchParameters($searchParameters)
->setAccount($account);
}
/**
* @param integer $account
*/
public function setAccount($account = null)
{
$this->account = $account;
return $this;
}
/**
* @return integer
*/
public function getAccount()
{
return $this->account;
}
/**
* @param Zend_Service_DeveloperGarden_LocalSearch_SearchParameters $searchParameters
*/
public function setSearchParameters(
Zend_Service_DeveloperGarden_LocalSearch_SearchParameters $searchParameters
) {
$this->searchParameters = $searchParameters->getSearchParameters();
$this->_searchParameters = $searchParameters;
return $this;
}
/**
* @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
*/
public function getSearchParameters()
{
return $this->_searchParameters;
}
}

View file

@ -0,0 +1,72 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: RequestAbstract.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* environment value
*
* @var integer
*/
public $environment = null;
/**
* constructor give them the environment
*
* @param integer $environment
* @return Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
public function __construct($environment)
{
$this->setEnvironment($environment);
}
/**
* sets a new moduleId
*
* @param integer $environment
* @return Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
public function setEnvironment($environment)
{
$this->environment = $environment;
return $this;
}
/**
* the current configured environment value
*
* @return integer
*/
public function getEnvironment()
{
return $this->environment;
}
}

View file

@ -0,0 +1,46 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SendFlashSMS.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/SendSms/SendSmsAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_SendSms_SendFlashSMS
extends Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
{
/**
* this is the sms type
* 2 = FlashSMS
*
* @var integer
*/
protected $_smsType = 2;
}

View file

@ -0,0 +1,46 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SendSMS.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/SendSms/SendSmsAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_SendSms_SendSMS
extends Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
{
/**
* this is the sms type
* 1 = normal SMS
*
* @var integer
*/
protected $_smsType = 1;
}

View file

@ -0,0 +1,281 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SendSmsAbstract.php 20419 2010-01-19 13:20:12Z bate $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the number or numbers to receive this sms
*
* @var string
*/
public $number = null;
/**
* the message of this sms
*
* @var string
*/
public $message = null;
/**
* name of the sender
*
* @var string
*/
public $originator = null;
/**
* account
*
* @var integer
*/
public $account = null;
/**
* array of special chars that are used for counting
* message length
*
* @var array
*/
private $_specialChars = array(
'|',
'^',
'{',
'}',
'[',
']',
'~',
'\\',
"\n",
// '€', removed because its counted in utf8 correctly
);
/**
* what SMS type is it
*
* 1 = SMS
* 2 = FlashSMS
*
* @var integer
*/
protected $_smsType = 1;
/**
* the counter for increasing message count
* if more than this 160 chars we send a 2nd or counting
* sms message
*
* @var integer
*/
protected $_smsLength = 153;
/**
* maximum length of an sms message
*
* @var integer
*/
protected $_maxLength = 765;
/**
* the maximum numbers to send an sms
*
* @var integer
*/
protected $_maxNumbers = 10;
/**
* returns the assigned numbers
*
* @return string $number
*/
public function getNumber()
{
return $this->number;
}
/**
* set a new number(s)
*
* @param string $number
* @throws Zend_Service_DeveloperGarden_Request_Exception
*
* @return Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
*/
public function setNumber($number)
{
$this->number = $number;
if ($this->getNumberCount() > $this->_maxNumbers) {
require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
throw new Zend_Service_DeveloperGarden_Request_Exception('The message is too long.');
}
return $this;
}
/**
* returns the current message
*
* @return string $message
*/
public function getMessage()
{
return $this->message;
}
/**
* sets a new message
*
* @param string $message
* @throws Zend_Service_DeveloperGarden_Request_Exception
*
* @return Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
*/
public function setMessage($message)
{
$this->message = $message;
if ($this->getMessageLength() > $this->_maxLength) {
require_once 'Zend/Service/DeveloperGarden/Request/Exception.php';
throw new Zend_Service_DeveloperGarden_Request_Exception('The message is too long.');
}
return $this;
}
/**
* returns the originator
*
* @return the $originator
*/
public function getOriginator()
{
return $this->originator;
}
/**
* the originator name
*
* @param string $originator
* @return Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
*/
public function setOriginator($originator)
{
$this->originator = $originator;
return $this;
}
/**
* the account
* @return integer $account
*/
public function getAccount()
{
return $this->account;
}
/**
* sets a new accounts
*
* @param $account the $account to set
* @return Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
*/
public function setAccount($account)
{
$this->account = $account;
return $this;
}
/**
* returns the calculated message length
*
* @return integer
*/
public function getMessageLength()
{
$message = $this->getMessage();
$length = strlen($message);
foreach ($this->_specialChars as $char) {
$c = (substr_count($message, $char) * 2) - 1;
if ($c > 0) {
$length += $c;
}
}
return $length;
}
/**
* returns the count of sms messages that would be send
*
* @return integer
*/
public function getMessageCount()
{
$smsLength = $this->getMessageLength();
$retValue = 1;
if ($smsLength > 160) {
$retValue = ceil($smsLength / $this->_smsLength);
}
return $retValue;
}
/**
* returns the count of numbers in this sms
*
* @return integer
*/
public function getNumberCount()
{
$number = $this->getNumber();
$retValue = 0;
if (!empty($number)) {
$retValue = count(explode(',', $number));
}
return $retValue;
}
/**
* returns the sms type
* currently we have
* 1 = Sms
* 2 = FlashSms
*
* @return integer
*/
public function getSmsType()
{
return $this->_smsType;
}
}

View file

@ -0,0 +1,39 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: GetValidatedNumbers.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_SmsValidation_GetValidatedNumbers
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
}

View file

@ -0,0 +1,80 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Invalidate.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_SmsValidation_Invalidate
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the number
*
* @var string
*/
public $number = null;
/**
* create the class for validation a sms keyword
*
* @param integer $environment
* @param string $keyword
* @param string $number
*/
public function __construct($environment, $number = null)
{
parent::__construct($environment);
$this->setNumber($number);
}
/**
* returns the number
*
* @return string $number
*/
public function getNumber()
{
return $this->number;
}
/**
* set a new number
*
* @param string $number
* @return Zend_Service_DeveloperGarden_Request_SmsValidation_Validate
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}
}

View file

@ -0,0 +1,39 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SendValidationKeyword.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/SendSms/SendSmsAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_SmsValidation_SendValidationKeyword
extends Zend_Service_DeveloperGarden_Request_SendSms_SendSmsAbstract
{
}

View file

@ -0,0 +1,110 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Validate.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/RequestAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_SmsValidation_Validate
extends Zend_Service_DeveloperGarden_Request_RequestAbstract
{
/**
* the keyword to be used for validation
*
* @var string
*/
public $keyword = null;
/**
* the number
*
* @var string
*/
public $number = null;
/**
* returns the keyword
*
* @return string $keyword
*/
public function getKeyword ()
{
return $this->keyword;
}
/**
* create the class for validation a sms keyword
*
* @param integer $environment
* @param string $keyword
* @param string $number
*/
public function __construct($environment, $keyword = null, $number = null)
{
parent::__construct($environment);
$this->setKeyword($keyword)
->setNumber($number);
}
/**
* set a new keyword
*
* @param string $keyword
* @return Zend_Service_DeveloperGarden_Request_SmsValidation_Validate
*/
public function setKeyword($keyword)
{
$this->keyword = $keyword;
return $this;
}
/**
* returns the number
*
* @return string $number
*/
public function getNumber()
{
return $this->number;
}
/**
* set a new number
*
* @param string $number
* @return Zend_Service_DeveloperGarden_Request_SmsValidation_Validate
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}
}

View file

@ -0,0 +1,100 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: CallStatus.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_VoiceButler_VoiceButlerAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/VoiceButler/VoiceButlerAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_VoiceButler_CallStatus
extends Zend_Service_DeveloperGarden_Request_VoiceButler_VoiceButlerAbstract
{
/**
* extend the keep alive for this call
*
* @var integer
*/
public $keepAlive = null;
/**
* constructor give them the environment and the sessionId
*
* @param integer $environment
* @param string $sessionId
* @param integer $keepAlive
* @return Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
public function __construct($environment, $sessionId, $keepAlive = null)
{
parent::__construct($environment);
$this->setSessionId($sessionId)
->setKeepAlive($keepAlive);
}
/**
* @return string
*/
public function getSessionId()
{
return $this->sessionId;
}
/**
* sets new sessionId
*
* @param string $sessionId
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_CallStatus
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* @return integer
*/
public function getKeepAlive()
{
return $this->keepAlive;
}
/**
* sets new keepAlive flag
*
* @param integer $keepAlive
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_CallStatus
*/
public function setKeepAlive($keepAlive)
{
$this->keepAlive = $keepAlive;
return $this;
}
}

View file

@ -0,0 +1,238 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NewCall.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_VoiceButler_VoiceButlerAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/VoiceButler/VoiceButlerAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
extends Zend_Service_DeveloperGarden_Request_VoiceButler_VoiceButlerAbstract
{
/**
* the first number to be called
*
* @var string
*/
public $aNumber = null;
/**
* the second number to be called
*
* @var string
*/
public $bNumber = null;
/**
* Calling Line Identity Restriction (CLIR) disabled for $aNumber
*
* @var boolean
*/
public $privacyA = null;
/**
* Calling Line Identity Restriction (CLIR) disabled for $bNumber
*
* @var boolean
*/
public $privacyB = null;
/**
* time in seconds to wait for $aNumber
*
* @var integer
*/
public $expiration = null;
/**
* max duration for this call in seconds
*
* @var integer
*/
public $maxDuration = null;
/**
* param not used right now
*
* @var string
*/
public $greeter = null;
/**
* Account Id which will be pay for this call
*
* @var integer
*/
public $account = null;
/**
* @return string
*/
public function getANumber()
{
return $this->aNumber;
}
/**
* @param string $aNumber
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setANumber($aNumber)
{
$this->aNumber = $aNumber;
return $this;
}
/**
* @return string
*/
public function getBNumber()
{
return $this->bNumber;
}
/**
* @param string $bNumber
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setBNumber($bNumber)
{
$this->bNumber = $bNumber;
return $this;
}
/**
* @return boolean
*/
public function getPrivacyA()
{
return $this->privacyA;
}
/**
* @param boolean $privacyA
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setPrivacyA($privacyA)
{
$this->privacyA = $privacyA;
return $this;
}
/**
* @return boolean
*/
public function getPrivacyB()
{
return $this->privacyB;
}
/**
* @param boolean $privacyB
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setPrivacyB($privacyB)
{
$this->privacyB = $privacyB;
return $this;
}
/**
* @return integer
*/
public function getExpiration()
{
return $this->expiration;
}
/**
* @param integer $expiration
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setExpiration($expiration)
{
$this->expiration = $expiration;
return $this;
}
/**
* @return integer
*/
public function getMaxDuration()
{
return $this->maxDuration;
}
/**
* @param integer $maxDuration
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setMaxDuration($maxDuration)
{
$this->maxDuration = $maxDuration;
return $this;
}
/**
* @return string
*/
public function getGreeter()
{
return $this->greeter;
}
/**
* @param string $greeter
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setGreeter($greeter)
{
$this->greeter = $greeter;
return $this;
}
/**
* @return string
*/
public function getAccount()
{
return $this->account;
}
/**
* @param integer $account
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
public function setAccount($account)
{
$this->account = $account;
return $this;
}
}

View file

@ -0,0 +1,92 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: NewCallSequenced.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_VoiceButler_NewCall
*/
require_once 'Zend/Service/DeveloperGarden/Request/VoiceButler/NewCall.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_VoiceButler_NewCallSequenced
extends Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
{
/**
* array of second numbers to be called sequenced
*
* @var array
*/
public $bNumber = null;
/**
* max wait value to wait for new number to be called
*
* @var integer
*/
public $maxWait = null;
/**
* @return array
*/
public function getBNumber()
{
return $this->bNumber;
}
/**
* @param array $bNumber
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCall
*/
/*public function setBNumber(array $bNumber)
{
$this->bNumber = $bNumber;
return $this;
}*/
/**
* returns the max wait value
*
* @return integer
*/
public function getMaxWait()
{
return $this->maxWait;
}
/**
* sets new max wait value for next number call
*
* @param integer $maxWait
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_NewCallSequenced
*/
public function setMaxWait($maxWait)
{
$this->maxWait = $maxWait;
return $this;
}
}

View file

@ -0,0 +1,78 @@
<?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_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: TearDownCall.php 20166 2010-01-09 19:00:17Z bkarwin $
*/
/**
* @see Zend_Service_DeveloperGarden_VoiceButler_VoiceButlerAbstract
*/
require_once 'Zend/Service/DeveloperGarden/Request/VoiceButler/VoiceButlerAbstract.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Request_VoiceButler_TearDownCall
extends Zend_Service_DeveloperGarden_Request_VoiceButler_VoiceButlerAbstract
{
/**
* the session id
*
* @var string
*/
public $sessionId = null;
/**
* constructor give them the environment and the sessionId
*
* @param integer $environment
* @param string $sessionId
* @return Zend_Service_DeveloperGarden_Request_RequestAbstract
*/
public function __construct($environment, $sessionId)
{
parent::__construct($environment);
$this->setSessionId($sessionId);
}
/**
* @return string
*/
public function getSessionId()
{
return $this->sessionId;
}
/**
* sets new sessionId
*
* @param string $sessionId
* @return Zend_Service_DeveloperGarden_Request_VoiceButler_TearDownCall
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
}

Some files were not shown because too many files have changed in this diff Show more