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