This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
HOAuthAdminAction.php
53 lines (45 loc) · 1.4 KB
/
HOAuthAdminAction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* HOAuthAdminAction - administrative action. Helps to create config for HybridAuth
*
* @uses CAction
* @version 1.2.4
* @copyright Copyright © 2013 Sviatoslav Danylenko
* @author Sviatoslav Danylenko <dev@udf.su>
* @license MIT ({@link http://opensource.org/licenses/MIT})
* @link https://github.com/SleepWalker/hoauth
*/
class HOAuthAdminAction extends CAction
{
/**
* @var string $endPointUrl url with wich will the social network comunicate
*/
private $endPointUrl;
/**
* @var string $configPath path to the HybridAuth config file
*/
private $configPath;
/**
* @var string $route id of module and controller (eg. module/controller) for wich to generate oauth urls
*/
public $route = false;
public function run()
{
if(!$this->route) {
$this->route = $this->controller->module ? $this->controller->module->id . '/' . $this->controller->id : $this->controller->id . '/oauth';
}
$endpoint_url = Yii::app()->createAbsoluteUrl($this->route);
$this->endPointUrl = $endpoint_url;
require_once(dirname(__FILE__).'/models/UserOAuth.php');
$this->configPath = UserOAuth::getConfigPath();
$this->controller->renderText($this->getForm($this->configPath, $this->endPointUrl));
Yii::app()->end();
}
public function getForm($config_path, $endpoint_url)
{
$path = dirname(__FILE__);
ob_start();
include($path.'/hybridauth/install.php');
return ob_get_clean();
}
}