public function updateRequest(array $params) { $this->checkXP(); $pluginDto = $this->getPluginDtoByKey($params); $language = OW::getLanguage(); $remotePluginInfo = (array) $this->pluginService->getItemInfoForUpdate($pluginDto->getKey(), $pluginDto->getDeveloperKey()); if (empty($remotePluginInfo) || !empty($remotePluginInfo['error'])) { $this->assign('mode', 'error'); $this->assign('text', $language->text('admin', 'plugin_update_request_error')); $this->assign('returnUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'index')); } else { if ((bool) $remotePluginInfo['freeware']) { $this->assign('mode', 'free'); $this->assign('text', $language->text('admin', 'free_plugin_request_text', array('oldVersion' => $pluginDto->getBuild(), 'newVersion' => $remotePluginInfo['build'], 'name' => $pluginDto->getTitle()))); $this->assign('redirectUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'update', $params)); $this->assign('returnUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'index')); } else { if ($pluginDto->getLicenseKey() != null) { $result = $this->pluginService->checkLicenseKey($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $pluginDto->getLicenseKey()); if ($result === true) { $params['licenseKey'] = $pluginDto->getLicenseKey(); $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'update', $params)); return; } } $this->assign('text', $language->text('admin', 'com_plugin_request_text', array('oldVersion' => $pluginDto->getBuild(), 'newVersion' => $remotePluginInfo['build'], 'name' => $pluginDto->getTitle()))); $form = new Form('license-key'); $licenseKey = new TextField('key'); $licenseKey->setValue($pluginDto->getLicenseKey()); $licenseKey->setRequired(); $licenseKey->setLabel($language->text('admin', 'com_plugin_request_key_label')); $form->addElement($licenseKey); $submit = new Submit('submit'); $submit->setValue($language->text('admin', 'license_form_submit_label')); $form->addElement($submit); $button = new Button('button'); $button->setValue($language->text('admin', 'license_form_leave_label')); $button->addAttribute('onclick', "window.location='" . OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'index') . "'"); $form->addElement($button); $this->addForm($form); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); $params['licenseKey'] = $data['key']; $result = $this->pluginService->checkLicenseKey($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $data['key']); if ($result === true) { $pluginDto->setLicenseKey($data['key']); BOL_PluginService::getInstance()->savePlugin($pluginDto); $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Plugins', 'update', $params)); } else { OW::getFeedback()->error($language->text('admin', 'plugins_manage_invalid_license_key_error_message')); $this->redirect(); } } } } } }