Create oauth controller interface for oauth-specific actions; small refactoring on tabs.js
This commit is contained in:
parent
7006b55818
commit
9ed3145473
5 changed files with 80 additions and 50 deletions
|
@ -29,6 +29,7 @@ require_once "GoogleAnalytics.php";
|
|||
require_once "Timezone.php";
|
||||
require_once "Auth.php";
|
||||
require_once "interface/OAuth2.php";
|
||||
require_once "interface/OAuth2Controller.php";
|
||||
require_once "TaskManager.php";
|
||||
require_once "UsabilityHints.php";
|
||||
require_once "MediaType.php";
|
||||
|
@ -180,6 +181,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
->appendFile($baseUrl . 'js/libs/jquery-ui-1.8.24.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/bootstrap/bootstrap.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/libs/underscore-min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/libs/angular.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
|
||||
// ->appendFile($baseUrl . 'js/libs/jquery.stickyPanel.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
->appendFile($baseUrl . 'js/qtip/jquery.qtip.js?' . $CC_CONFIG['airtime_version'], 'text/javascript')
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
interface OAuth2Controller {
|
||||
|
||||
/**
|
||||
* Send user to a third-party service to authorize before being redirected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function authorizeAction();
|
||||
|
||||
/**
|
||||
* Clear the previously saved request token from the preferences
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deauthorizeAction();
|
||||
|
||||
/**
|
||||
* Called when user successfully completes third-party authorization
|
||||
* Store the returned request token for future requests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirectAction();
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
require_once "ThirdPartyController.php";
|
||||
require_once "ise/php-soundcloud/src/Soundcloud/Service.php";
|
||||
|
||||
class SoundcloudController extends ThirdPartyController {
|
||||
class SoundcloudController extends ThirdPartyController implements OAuth2Controller {
|
||||
|
||||
/**
|
||||
* @var SoundcloudService
|
||||
|
@ -23,6 +23,39 @@ class SoundcloudController extends ThirdPartyController {
|
|||
$this->_service = new SoundcloudService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send user to SoundCloud to authorize before being redirected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function authorizeAction() {
|
||||
$auth_url = $this->_service->getAuthorizeUrl();
|
||||
header('Location: ' . $auth_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previously saved request token from preferences
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deauthorizeAction() {
|
||||
$function = $this->_SERVICE_TOKEN_ACCESSOR;
|
||||
Application_Model_Preference::$function("");
|
||||
header('Location: ' . $this->_baseUrl . 'preference'); // Redirect back to the preference page
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when user successfully completes SoundCloud authorization
|
||||
* Store the returned request token for future requests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirectAction() {
|
||||
$code = $_GET['code'];
|
||||
$this->_service->requestNewAccessToken($code);
|
||||
header('Location: ' . $this->_baseUrl . 'preference'); // Redirect back to the preference page
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the permalink to a file on SoundCloud and redirect to it.
|
||||
*/
|
||||
|
|
|
@ -31,39 +31,6 @@ abstract class ThirdPartyController extends Zend_Controller_Action {
|
|||
$this->_helper->viewRenderer->setNoRender(true); // Don't use (phtml) templates
|
||||
}
|
||||
|
||||
/**
|
||||
* Send user to a third-party service to authorize before being redirected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function authorizeAction() {
|
||||
$auth_url = $this->_service->getAuthorizeUrl();
|
||||
header('Location: ' . $auth_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previously saved request token from the preferences
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deauthorizeAction() {
|
||||
$function = $this->_SERVICE_TOKEN_ACCESSOR;
|
||||
Application_Model_Preference::$function("");
|
||||
header('Location: ' . $this->_baseUrl . 'preference'); // Redirect back to the preference page
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when user successfully completes third-party authorization
|
||||
* Store the returned request token for future requests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirectAction() {
|
||||
$code = $_GET['code'];
|
||||
$this->_service->requestNewAccessToken($code);
|
||||
header('Location: ' . $this->_baseUrl . 'preference'); // Redirect back to the preference page
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload the file with the given id to a third-party service
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue