]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Oauth/Http/UserAuthorization.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Oauth / Http / UserAuthorization.php
1 <?php
2 /**
3  * Zend Framework
4  *
5  * LICENSE
6  *
7  * This source file is subject to the new BSD license that is bundled
8  * with this package in the file LICENSE.txt.
9  * It is also available through the world-wide-web at this URL:
10  * http://framework.zend.com/license/new-bsd
11  * If you did not receive a copy of the license and are unable to
12  * obtain it through the world-wide-web, please send an email
13  * to license@zend.com so we can send you a copy immediately.
14  *
15  * @category   Zend
16  * @package    Zend_Oauth
17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
19
20  */
21
22 /** Zend_Oauth_Http */
23 require_once 'Zend/Oauth/Http.php';
24
25 /** Zend_Uri_Http */
26 require_once 'Zend/Uri/Http.php';
27
28 /**
29  * @category   Zend
30  * @package    Zend_Oauth
31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
33  */
34 class Zend_Oauth_Http_UserAuthorization extends Zend_Oauth_Http
35 {
36     /**
37      * Generate a redirect URL from the allowable parameters and configured
38      * values.
39      *
40      * @return string
41      */
42     public function getUrl()
43     {
44         $params = $this->assembleParams();
45         $uri    = Zend_Uri_Http::fromString($this->_consumer->getUserAuthorizationUrl());
46
47         $uri->setQuery(
48             $this->_httpUtility->toEncodedQueryString($params)
49         );
50
51         return $uri->getUri();
52     }
53
54     /**
55      * Assemble all parameters for inclusion in a redirect URL.
56      *
57      * @return array
58      */
59     public function assembleParams()
60     {
61         $params = array(
62             'oauth_token' => $this->_consumer->getLastRequestToken()->getToken(),
63         );
64
65         if (!Zend_Oauth_Client::$supportsRevisionA) {
66             $callback = $this->_consumer->getCallbackUrl();
67             if (!empty($callback)) {
68                 $params['oauth_callback'] = $callback;
69             }
70         }
71
72         if (!empty($this->_parameters)) {
73             $params = array_merge($params, $this->_parameters);
74         }
75
76         return $params;
77     }
78 }