| @@ -47,9 +47,12 @@ | ||
| 47 | 47 | * put your comment there... |
| 48 | 48 | * |
| 49 | 49 | */ |
| 50 | 50 | protected function getStateAction() { |
| 51 | - $this->response = $this->model->getStateStruct($_REQUEST['component']); | |
| 51 | + # Get component product types | |
| 52 | + $licenseTypes = $this->model->getExtensionProductTypes($_REQUEST['component']); | |
| 53 | + # Return license state back | |
| 54 | + $this->response = $this->model->getStateStruct($licenseTypes); | |
| 52 | 55 | } |
| 53 | 56 | |
| 54 | 57 | /** |
| 55 | 58 | * put your comment there... |
| @@ -56,30 +59,17 @@ | ||
| 56 | 59 | * |
| 57 | 60 | */ |
| 58 | 61 | protected function licenseAction() { |
| 59 | 62 | // Read request parameters! |
| 60 | - $action = $_REQUEST['eddAction']; | |
| 63 | + $action = $_REQUEST['licenseAction']; | |
| 61 | 64 | $state['component'] = $_REQUEST['component']; |
| 62 | 65 | $state['license'] = $_REQUEST['license']; |
| 63 | 66 | // Initializing! |
| 64 | 67 | $model =& $this->model; |
| 65 | 68 | // Request EDD through EDD SL APIs! |
| 66 | - $state['response'] = $model->dispatchEddCall($action, $state['component'], $state['license']); | |
| 67 | - // Standarize response object! As check and activate responde by 'valid' and 'invalid' and deactivate responde | |
| 68 | - // by deactivated and faild we then need to make them all likce check and activate! | |
| 69 | - if (($action == 'deactivate') && ($state['response']['license'] != 'error')) { | |
| 70 | - $map = array('deactivated' => 'valid', 'failed' => 'invalid'); | |
| 71 | - $deactivateResponseState = $state['response']['license']; | |
| 72 | - $state['response']['license'] = $map[$deactivateResponseState]; | |
| 73 | - } | |
| 69 | + $state['response'] = $model->dispatchLicenseAction($action, $state['component'], $state['license']); | |
| 74 | 70 | // Cahe only if the request is 'activate' or 'deactivate' and the returned state is valid or 'deactivated! respectively. |
| 75 | 71 | if (($action != 'check') && ($state['response']['license'] == 'valid')) { |
| 76 | - // We need to standarize the response object so the access will be always the same | |
| 77 | - // EDD return 'deactivated' and 'valid' with the success request using 'deactivate' and 'activate' repectively! | |
| 78 | - // Use valid instead of deactivate! | |
| 79 | - if ($action == 'deactivate') { | |
| 80 | - $state['response']['license'] = 'valid'; | |
| 81 | - } | |
| 82 | 72 | $state['action'] = $model->cacheState($state['component'], $action, $state); |
| 83 | 73 | } |
| 84 | 74 | // Return state object includes (component, license, edd response [and action only if valid]) |
| 85 | 75 | $this->response = $state; |