1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23: 24:
25: class PimPluginSetupStatus extends PimPluginSetup {
26:
27:
28:
29: protected $_PimPluginCollection;
30:
31:
32: protected $_PimPluginRelationsCollection;
33:
34:
35: protected $_ApiNavSubCollection;
36:
37: 38: 39: 40: 41:
42: private function _setPimPluginCollection() {
43: return $this->_PimPluginCollection = new PimPluginCollection();
44: }
45:
46: 47: 48: 49: 50:
51: private function _setPimPluginRelationsCollection() {
52: return $this->_PimPluginRelationsCollection = new PimPluginRelationsCollection();
53: }
54:
55: 56: 57: 58: 59:
60: private function _setApiNavSubCollection() {
61: return $this->_ApiNavSubCollection = new cApiNavSubCollection();
62: }
63:
64:
65: 66: 67:
68: public function __construct() {
69:
70:
71:
72: $this->_setPimPluginCollection();
73: $this->_setPimPluginRelationsCollection();
74:
75:
76: $this->_setApiNavSubCollection();
77: }
78:
79: 80: 81: 82: 83:
84: public function changeActiveStatus($pluginId) {
85:
86:
87: $this->_PimPluginCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
88: $this->_PimPluginCollection->query();
89: $plugin = $this->_PimPluginCollection->next();
90:
91:
92: $pluginName = $plugin->get('name');
93: $pluginActiveStatus = $plugin->get('active');
94:
95:
96: $this->_PimPluginRelationsCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
97: $this->_PimPluginRelationsCollection->setWhere('type', 'navs');
98: $this->_PimPluginRelationsCollection->query();
99:
100: if ($pluginActiveStatus == 1) {
101:
102: $plugin->set('active', 0);
103: $plugin->store();
104:
105:
106:
107: while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
108: $idnavs = $relation->get('iditem');
109: $this->changeNavSubStatus($idnavs, 0);
110: }
111:
112: parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully disabled. To apply the changes please login into backend again.', 'pim'));
113: } else {
114: $plugin->set('active', 1);
115: $plugin->store();
116:
117:
118:
119: while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
120: $idnavs = $relation->get('iditem');
121: $this->changeNavSubStatus($idnavs, 1);
122: }
123:
124: parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully enabled. To apply the changes please login into backend again.', 'pim'));
125: }
126: }
127:
128: 129: 130: 131: 132: 133: 134:
135: private function changeNavSubStatus($idnavs, $online) {
136: $this->_ApiNavSubCollection->setWhere('idnavs', cSecurity::toInteger($idnavs));
137: $this->_ApiNavSubCollection->query();
138:
139: $navSub = $this->_ApiNavSubCollection->next();
140: $navSub->set('online', cSecurity::toInteger($online));
141: $navSub->store();
142:
143: return true;
144: }
145:
146: }
147: ?>