These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @author Pierre-Henry Soria <[email protected]> |
||
4 | * @copyright (c) 2016-2017, Pierre-Henry Soria. All Rights Reserved. |
||
5 | * @license GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory. |
||
6 | * @package PH7 / App / System / Module / Admin / From / Processing |
||
7 | */ |
||
8 | namespace PH7; |
||
9 | |||
10 | defined('PH7') or exit('Restricted access'); |
||
11 | |||
12 | use |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
13 | PH7\Framework\Cache\Cache, |
||
14 | PH7\Framework\Mvc\Model\Module as ModuleModel; |
||
15 | |||
16 | class DisableModuleFormProcess extends Form |
||
17 | { |
||
18 | public function __construct() |
||
19 | { |
||
20 | parent::__construct(); |
||
21 | |||
22 | $oModuleModel = new ModuleModel; |
||
23 | |||
24 | // First, disable all mods as uncheckboxes elements aren't send throughth the form |
||
25 | $this->disableMods($oModuleModel); |
||
26 | |||
27 | // Then, enable the mods selected to be enabled |
||
28 | foreach($this->httpRequest->post('module_id') as $iModId) { |
||
29 | $oModuleModel->update($iModId, '1'); // Need to be string because in DB it's an "enum" type |
||
30 | } |
||
31 | unset($oModuleModel); |
||
32 | |||
33 | $this->clearCache(); |
||
34 | |||
35 | \PFBC\Form::setSuccess('form_module', t('Module Status have been saved!')); |
||
36 | } |
||
37 | |||
38 | protected function disableMods(ModuleModel $oModuleModel) |
||
39 | { |
||
40 | foreach ($oModuleModel->get() as $oMod) { |
||
41 | // Need to be string because in DB it's an "enum" type |
||
42 | $oModuleModel->update($oMod->moduleId, '0'); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | private function clearCache() |
||
47 | { |
||
48 | (new Cache)->start(ModuleModel::CACHE_GROUP, null, null)->clear(); |
||
49 | } |
||
50 | } |
||
51 |