Ver Fonte

ZF-7418: Allow users to nullify query parameters when constructing a
Zend_Gdata_Calendar_EventQuery.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17333 44c647ce-9c0f-0410-b52a-842ac1e357ba

tjohns há 16 anos atrás
pai
commit
035ae82e75

+ 55 - 11
library/Zend/Gdata/Calendar/EventQuery.php

@@ -47,18 +47,58 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
 
 
     const CALENDAR_FEED_URI = 'http://www.google.com/calendar/feeds';
     const CALENDAR_FEED_URI = 'http://www.google.com/calendar/feeds';
 
 
+    /**
+     * The default URI used for feeds.
+     */
     protected $_defaultFeedUri = self::CALENDAR_FEED_URI;
     protected $_defaultFeedUri = self::CALENDAR_FEED_URI;
+    
+    /**
+     * The comment ID to retrieve. If null, no specific comment will be
+     * retrieved unless already included in the query URI. The event ID
+     * ($_event) must be set, otherwise this property is ignored.
+     */
     protected $_comments = null;
     protected $_comments = null;
-    protected $_user = null;
-    protected $_visibility = null;
-    protected $_projection = null;
+    
+    /**
+     * The calendar address to be requested by queries. This may be an email
+     * address if requesting the primary calendar for a user. Defaults to
+     * "default" (the currently authenticated user). A null value should be
+     * used when the calendar address has already been set as part of the
+     * query URI.
+     */
+    protected $_user = 'default';
+    
+    /*
+     * The visibility to be requested by queries. Defaults to "public". A
+     * null value should be used when the calendar address has already been
+     * set as part of the query URI.
+     */
+    protected $_visibility = 'public';
+    
+    /**
+     * Projection to be requested by queries. Defaults to "full". A null value
+     * should be used when the calendar address has already been set as part
+     * of the query URI.
+     */
+    protected $_projection = 'full';
+    
+    /**
+     * The event ID to retrieve. If null, no specific event will be retrieved
+     * unless already included in the query URI.
+     */
     protected $_event = null;
     protected $_event = null;
 
 
     /**
     /**
      * Create Gdata_Calendar_EventQuery object.  If a URL is provided,
      * Create Gdata_Calendar_EventQuery object.  If a URL is provided,
      * it becomes the base URL, and additional URL components may be
      * it becomes the base URL, and additional URL components may be
-     * appended.  For instance, if $url is 'http://www.foo.com', the
-     * default URL constructed will be 'http://www.foo.com/default/public/full'
+     * appended.  For instance, if $url is 'http://www.google.com/calendar',
+     * the default URL constructed will be
+     * 'http://www.google.com/calendar/default/public/full'.
+     *
+     * If the URL already contains a calendar ID, projection, visibility,
+     * event ID, or comment ID, you will need to set these fields to null
+     * to prevent them from being inserted. See this class's properties for
+     * more information.
      *
      *
      * @param string $url The URL to use as the base path for requests
      * @param string $url The URL to use as the base path for requests
      */
      */
@@ -68,6 +108,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_comments
      * @param string $value
      * @param string $value
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      */
      */
@@ -78,6 +119,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_event
      * @param string $value
      * @param string $value
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      */
      */
@@ -88,6 +130,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_projection
      * @param string $value
      * @param string $value
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      */
      */
@@ -98,6 +141,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_user
      * @param string $value
      * @param string $value
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      */
      */
@@ -108,6 +152,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_visibility
      * @param bool $value
      * @param bool $value
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      * @return Zend_Gdata_Calendar_EventQuery Provides a fluent interface
      */
      */
@@ -118,6 +163,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_comments;
      * @return string comments
      * @return string comments
      */
      */
     public function getComments()
     public function getComments()
@@ -126,6 +172,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_event;
      * @return string event
      * @return string event
      */
      */
     public function getEvent()
     public function getEvent()
@@ -134,6 +181,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_projection
      * @return string projection
      * @return string projection
      */
      */
     public function getProjection()
     public function getProjection()
@@ -142,6 +190,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_user
      * @return string user
      * @return string user
      */
      */
     public function getUser()
     public function getUser()
@@ -150,6 +199,7 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
     }
     }
 
 
     /**
     /**
+     * @see $_visibility
      * @return string visibility
      * @return string visibility
      */
      */
     public function getVisibility()
     public function getVisibility()
@@ -421,18 +471,12 @@ class Zend_Gdata_Calendar_EventQuery extends Zend_Gdata_Query
         }
         }
         if ($this->getUser() != null) {
         if ($this->getUser() != null) {
             $uri .= '/' . $this->getUser();
             $uri .= '/' . $this->getUser();
-        } else {
-            $uri .= '/default';
         }
         }
         if ($this->getVisibility() != null) {
         if ($this->getVisibility() != null) {
             $uri .= '/' . $this->getVisibility();
             $uri .= '/' . $this->getVisibility();
-        } else {
-            $uri .= '/public';
         }
         }
         if ($this->getProjection() != null) {
         if ($this->getProjection() != null) {
             $uri .= '/' . $this->getProjection();
             $uri .= '/' . $this->getProjection();
-        } else {
-            $uri .= '/full';
         }
         }
         if ($this->getEvent() != null) {
         if ($this->getEvent() != null) {
             $uri .= '/' . $this->getEvent();
             $uri .= '/' . $this->getEvent();

+ 10 - 0
tests/Zend/Gdata/Calendar/EventQueryTest.php

@@ -249,6 +249,16 @@ class Zend_Gdata_Calendar_EventQueryTest extends PHPUnit_Framework_TestCase
         $this->query->resetParameters();
         $this->query->resetParameters();
         $this->assertEquals("http://www.google.com/calendar/feeds/default/public/full",
         $this->assertEquals("http://www.google.com/calendar/feeds/default/public/full",
                 $this->query->getQueryUrl());
                 $this->query->getQueryUrl());
+    }
 
 
+    public function testCanNullifyParameters()
+    {
+       $testURI = "http://www.google.com/calendar/feeds/foo%40group.calendar.google.com/private/full";
+       $this->query = new Zend_Gdata_Calendar_EventQuery($testURI);
+       $this->query->setUser(null);
+       $this->query->setVisibility(null);
+       $this->query->setProjection(null);
+       $result = $this->query->getQueryUrl();
+       $this->assertEquals($testURI, $result);
     }
     }
 }
 }