Skip to content

Commit

Permalink
Merge branch 'master' into imp_6_2
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 4, 2013
2 parents df30133 + ffbb528 commit 48706c4
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 100 deletions.
26 changes: 14 additions & 12 deletions framework/Mongo/lib/Horde/Mongo/Client.php
Expand Up @@ -23,8 +23,8 @@
class Horde_Mongo_Client extends MongoClient implements Serializable
{
/**
* Database name (Horde_Mongo_Client forces connections to this single
* database to ease configuration).
* Database name (Horde_Mongo_Client uses this single database by default
* to ease configuration).
*
* @var string
*/
Expand Down Expand Up @@ -54,30 +54,32 @@ public function __construct($server = null, array $options = array())
*/
public function dropDB($db)
{
return parent::dropDB($this->dbname);
}

/**
* @see MongoClient#__get
*/
public function __get($dbname)
{
return parent::__get($this->dbname);
if (empty($db)) {
$db = $this->dbname;
}
return parent::dropDB($db);
}

/**
* @see MongoClient#selectCollection
*/
public function selectCollection($db, $collection = null)
{
return parent::selectCollection($this->dbname, $collection);
if (empty($db)) {
$db = $this->dbname;
}
return parent::selectCollection($db, $collection);
}

/**
* @see MongoClient#selectDB
*/
public function selectDB($name)
{
if (!empty($name)) {
$this->dbname = $name;
}

return parent::selectDB($this->dbname);
}

Expand Down
103 changes: 58 additions & 45 deletions framework/Service_Gravatar/lib/Horde/Service/Gravatar.php
Expand Up @@ -52,14 +52,14 @@ class Horde_Service_Gravatar
/**
* Constructor.
*
* The default Gravatar base URL is Horde_Service_Gravatar::STANDARD. If you
* need URLs in an HTTPS context you should provide the base URL parameter
* as Horde_Service_Gravatar::SECURE. In case you wish to access another URL
* offering the Gravatar API you can specify the base URL of this service as
* $base.
*
* @param string $base The base Gravatar URL.
* @param Horde_Http_Client $client The HTTP client to access the server.
* The default Gravatar base URL is Horde_Service_Gravatar::STANDARD. If
* you need URLs in an HTTPS context you should provide the base URL
* parameter as Horde_Service_Gravatar::SECURE. In case you wish to access
* another URL offering the Gravatar API you can specify the base URL of
* this service as $base.
*
* @param string $base The base Gravatar URL.
* @param Horde_Http_Client $client The HTTP client to access the server.
*/
public function __construct(
$base = self::STANDARD,
Expand All @@ -76,11 +76,9 @@ public function __construct(
/**
* Return the Gravatar ID for the specified mail address.
*
* @param string $mail The mail address.
* @param string $mail The mail address.
*
* @return string The Gravatar ID.
*
* @throws InvalidArgumentException In case the mail address is no string.
* @return string The Gravatar ID.
*/
public function getId($mail)
{
Expand All @@ -92,33 +90,54 @@ public function getId($mail)

/**
* Return the Gravatar image URL for the specified mail address. The
* returned URL can be directly used with an <img/> tag e.g. <img
* src="http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50" />
*
* @param string $mail The mail address.
* @param integer $size An optinoal size parameter. Valid values are
* between 1 and 512.
*
* @return string The image URL.
*
* @throws InvalidArgumentException In case the mail address is no string.
* returned URL can be directly used with an IMG tag e.g.:
* &lt;img src="http://www.gravatar.com/avatar/hash" /&gt;
*
* @param string $mail The mail address.
* @param mixed $opts Additional options. If an integer, treated as the
* 'size' option. If an array, the following options
* are available:
* <pre>
* - default: (string) Default behavior. Valid values are '404', 'mm',
* 'identicon', 'monsterid', 'wavatar', 'retro', 'blank', or
* a URL-encoded URL to use as the default image.
* - rating: (string) Rating. Valid values are 'g', 'pg', 'r', and 'x'.
* - size: (integer) Image size. Valid values are between 1 and 512.
* </pre>
*
* @return Horde_Url The image URL.
*/
public function getAvatarUrl($mail, $size = null)
public function getAvatarUrl($mail, $opts = array())
{
if (!empty($size) && ($size < 1 || $size > 512)) {
if (is_integer($opts)) {
$opts = array('size' => $opts);
}

if (!empty($opts['size']) &&
(($opts['size'] < 1) || ($opts['size'] > 512))) {
throw InvalidArgumentException('The size parameter is out of bounds');
}
return $this->_base . '/avatar/' . $this->getId($mail) . (!empty($size) ? '?s=' . $size : '');

$url = new Horde_Url($this->_base . '/avatar/' . $this->getId($mail));
if (!empty($opts['default'])) {
$url->add('d', $opts['default']);
}
if (!empty($opts['rating'])) {
$url->add('r', $opts['rating']);
}
if (!empty($opts['size'])) {
$url->add('s', $opts['size']);
}

return $url;
}

/**
* Return the Gravatar profile URL.
*
* @param string $mail The mail address.
*
* @return string The profile URL.
* @param string $mail The mail address.
*
* @throws InvalidArgumentException In case the mail address is no string.
* @return string The profile URL.
*/
public function getProfileUrl($mail)
{
Expand All @@ -128,11 +147,9 @@ public function getProfileUrl($mail)
/**
* Fetch the Gravatar profile information.
*
* @param string $mail The mail address.
* @param string $mail The mail address.
*
* @return string The profile information.
*
* @throws InvalidArgumentException In case the mail address is no string.
* @return string The profile information.
*/
public function fetchProfile($mail)
{
Expand All @@ -143,11 +160,9 @@ public function fetchProfile($mail)
/**
* Return the Gravatar profile information as an array.
*
* @param string $mail The mail address.
*
* @return array The profile information.
* @param string $mail The mail address.
*
* @throws InvalidArgumentException In case the mail address is no string.
* @return array The profile information.
*/
public function getProfile($mail)
{
Expand All @@ -157,16 +172,14 @@ public function getProfile($mail)
/**
* Fetch the avatar image.
*
* @param string $mail The mail address.
* @param integer $size An optional size parameter.
*
* @return resource The image as stream resource.
* @param string $mail The mail address.
* @param mixed $opts Additional options. See getAvatarUrl().
*
* @throws InvalidArgumentException In case the mail address is no string.
* @return resource The image as stream resource.
*/
public function fetchAvatar($mail, $size = null)
public function fetchAvatar($mail, $opts = array())
{
return $this->_client->get($this->getAvatarUrl($mail, $size))->getStream();
return $this->_client->get($this->getAvatarUrl($mail, $opts))->getStream();
}

}
}
13 changes: 13 additions & 0 deletions framework/Service_Gravatar/package.xml
Expand Up @@ -22,6 +22,9 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Add &apos;default&apos; and &apos;rating&apos; options to getAvatarUrl().
* [mms] Change second parameter to getAvatarUrl() and fetchAvatar() to an array so that additional options can be provided.
* [mms] getAvatarUrl() now returns a Horde_Url object.
* Initial release.
</notes>
<contents>
Expand Down Expand Up @@ -78,6 +81,13 @@
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
<package>
<name>Horde_Url</name>
<channel>pear.horde.org</channel>
<min>2.0.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
</required>
<optional>
<package>
Expand Down Expand Up @@ -117,6 +127,9 @@
<date>2012-11-19</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Add &apos;default&apos; and &apos;rating&apos; options to getAvatarUrl().
* [mms] Change second parameter to getAvatarUrl() and fetchAvatar() to an array so that additional options can be provided.
* [mms] getAvatarUrl() now returns a Horde_Url object.
* Initial release.
</notes>
</release>
Expand Down
@@ -1,31 +1,24 @@
<?php
/**
* Horde_Service_Gravatar abstracts communication with Services supporting the
* Gravatar API (http://www.gravatar.com/site/implement/).
*
* PHP version 5
*
* @category Horde
* @package Service_Gravatar
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
*/

/**
* Horde_Service_Gravatar abstracts communication with Services supporting the
* Gravatar API (http://www.gravatar.com/site/implement/).
*
* Copyright 2011-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Service_Gravatar
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
* @category Horde
* @copyright 2011-2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
* @package Service_Gravatar
*/

/**
* @author Gunnar Wrobel <wrobel@pardus.de>
* @category Horde
* @copyright 2011-2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
* @package Service_Gravatar
*/
class Horde_Service_Gravatar_GravatarTest
extends PHPUnit_Framework_TestCase
Expand Down
@@ -1,31 +1,24 @@
<?php
/**
* Horde_Service_Gravatar abstracts communication with Services supporting the
* Gravatar API (http://www.gravatar.com/site/implement/).
*
* PHP version 5
*
* @category Horde
* @package Service_Gravatar
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
*/

/**
* Horde_Service_Gravatar abstracts communication with Services supporting the
* Gravatar API (http://www.gravatar.com/site/implement/).
*
* Copyright 2011-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Service_Gravatar
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
* @category Horde
* @copyright 2011-2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
* @package Service_Gravatar
*/

/**
* @author Gunnar Wrobel <wrobel@pardus.de>
* @category Horde
* @copyright 2011-2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Service_Gravatar
* @package Service_Gravatar
*/
class Horde_Service_Gravatar_ServerTest extends Horde_Test_Case
{
Expand Down
4 changes: 3 additions & 1 deletion turba/lib/Driver.php
Expand Up @@ -569,7 +569,9 @@ public function search(array $search_criteria, $sort_order = null,
$strict_fields[$strict_field] = true;
}
foreach ($custom_strict as $strict_field) {
$strict_fields[$this->map[$strict_field]] = true;
if (isset($this->map[$strict_field])) {
$strict_fields[$this->map[$strict_field]] = true;
}
}

/* Translate the Turba attributes to driver-specific attributes. */
Expand Down

0 comments on commit 48706c4

Please sign in to comment.