-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathModuleKey.php
More file actions
120 lines (98 loc) · 3.39 KB
/
ModuleKey.php
File metadata and controls
120 lines (98 loc) · 3.39 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
// vim: set ts=4 sw=4 sts=4 et:
/**
* LiteCommerce
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to licensing@litecommerce.com so we can send you a copy immediately.
*
* PHP version 5.3.0
*
* @category LiteCommerce
* @author Creative Development LLC <info@cdev.ru>
* @copyright Copyright (c) 2011 Creative Development LLC <info@cdev.ru>. All rights reserved
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.litecommerce.com/
* @see ____file_see____
* @since 1.0.0
*/
namespace XLite\Controller\Admin;
/**
* ModuleKey
*
* @see ____class_see____
* @since 1.0.0
*/
class ModuleKey extends \XLite\Controller\Admin\AAdmin
{
// {{{ Public methods for viewers
/**
* Return page title
*
* @return string
* @see ____func_see____
* @since 1.0.0
*/
public function getTitle()
{
return static::t('Enter license key');
}
// }}}
// {{{ "Register key" action handler
/**
* Action of license key registration
*
* @return void
* @see ____func_see____
* @since 1.0.0
*/
protected function doActionRegisterKey()
{
$key = \XLite\Core\Request::getInstance()->key;
$info = \XLite\Core\Marketplace::getInstance()->checkAddonKey($key);
if ($info) {
$module = \XLite\Core\Database::getRepo('\XLite\Model\Module')->findOneBy($info);
if ($module) {
$repo = \XLite\Core\Database::getRepo('\XLite\Model\ModuleKey');
$entity = $repo->findKey($info['author'], $info['name']);
if ($entity) {
$entity->setKeyValue($key);
$repo->update($entity);
} else {
$entity = $repo->insert($info + array('keyValue' => $key));
}
// Clear cache for proper installation
\XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST);
$this->showInfo(
__FUNCTION__,
'License key has been successfully verified for "{{name}}" module by "{{author}}" author',
array(
'name' => $module->getModuleName(),
'author' => $module->getAuthorName(),
)
);
} else {
$this->showError(
__FUNCTION__,
'Key is validated, but the module [' . explode(',', $info) . '] was not found'
);
}
} else {
$error = \XLite\Core\Marketplace::getInstance()->getError();
if ($error) {
$this->showError(__FUNCTION__, 'Response from marketplace: ' . $error);
} else {
$this->showError(__FUNCTION__, 'Response from marketplace is not received');
}
}
$this->setReturnURL($this->buildURL('addons_list_marketplace'));
}
// }}}
}