| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
// import dependencies. |
| 10 |
cssJSToolbox::import('framework:mvc:controller-ajax.inc.php'); |
| 11 |
|
| 12 |
/** |
| 13 |
* |
| 14 |
*/ |
| 15 |
class CJTsetupController extends CJTAjaxController { |
| 16 |
|
| 17 |
/** |
| 18 |
* put your comment there... |
| 19 |
* |
| 20 |
* @var mixed |
| 21 |
*/ |
| 22 |
protected $controllerInfo = array('model' => 'setup'); |
| 23 |
|
| 24 |
/** |
| 25 |
* put your comment there... |
| 26 |
* |
| 27 |
*/ |
| 28 |
public function __construct() { |
| 29 |
parent::__construct(); |
| 30 |
// Register actions! |
| 31 |
$this->registryAction('activationFormView'); |
| 32 |
$this->registryAction('getState'); |
| 33 |
$this->registryAction('license'); |
| 34 |
$this->registryAction('reset'); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Display Activation form! |
| 39 |
* |
| 40 |
*/ |
| 41 |
protected function activationFormViewAction() { |
| 42 |
// Display activation for for the requested component! |
| 43 |
parent::displayAction(); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* put your comment there... |
| 48 |
* |
| 49 |
*/ |
| 50 |
protected function getStateAction() { |
| 51 |
# Get component product types |
| 52 |
$licenseTypes = $this->model->getExtensionProductTypes($_REQUEST['component']); |
| 53 |
# Return license state back |
| 54 |
$this->response = $this->model->getStateStruct($licenseTypes); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* put your comment there... |
| 59 |
* |
| 60 |
*/ |
| 61 |
protected function licenseAction() { |
| 62 |
// Read request parameters! |
| 63 |
$action = $_REQUEST['licenseAction']; |
| 64 |
$state['component'] = $_REQUEST['component']; |
| 65 |
$state['license'] = $_REQUEST['license']; |
| 66 |
// Initializing! |
| 67 |
$model =& $this->model; |
| 68 |
// Request EDD through EDD SL APIs! |
| 69 |
$state['response'] = $model->dispatchLicenseAction($action, $state['component'], $state['license']); |
| 70 |
// Cahe only if the request is 'activate' or 'deactivate' and the returned state is valid or 'deactivated! respectively. |
| 71 |
if (($action != 'check') && ($state['response']['license'] == 'valid')) { |
| 72 |
$state['action'] = $model->cacheState($state['component'], $action, $state); |
| 73 |
} |
| 74 |
// Return state object includes (component, license, edd response [and action only if valid]) |
| 75 |
$this->response = $state; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* put your comment there... |
| 80 |
* |
| 81 |
*/ |
| 82 |
protected function resetAction() { |
| 83 |
// Initializing! |
| 84 |
$model =& $this->model; |
| 85 |
// Read request parameters! |
| 86 |
$state['component'] = $_REQUEST['component']; |
| 87 |
$state['license'] = false; |
| 88 |
// Remove License state cache! |
| 89 |
$state['response']['license'] = $model->removeCachedLicense($state); |
| 90 |
// Set response parameters. |
| 91 |
$state['action'] = 'reset'; |
| 92 |
// With DUMMY EDD response so we're standarizing the response for all actions |
| 93 |
// even those not belongs to EDD real requests!! |
| 94 |
$state['response']['item_name'] = $state['component']['name']; |
| 95 |
$this->response = $state; |
| 96 |
} |
| 97 |
|
| 98 |
} // End class. |
| 99 |
|