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:
43: private function _setPimPluginCollection() {
44: return $this->_PimPluginCollection = new PimPluginCollection();
45: }
46:
47: 48: 49: 50: 51: 52:
53: private function _setPimPluginRelationsCollection() {
54: return $this->_PimPluginRelationsCollection = new PimPluginRelationsCollection();
55: }
56:
57: 58: 59: 60: 61: 62:
63: private function _setApiNavSubCollection() {
64: return $this->_ApiNavSubCollection = new cApiNavSubCollection();
65: }
66:
67:
68: 69: 70: 71: 72: 73:
74: public function __construct() {
75:
76:
77:
78: $this->_setPimPluginCollection();
79: $this->_setPimPluginRelationsCollection();
80:
81:
82: $this->_setApiNavSubCollection();
83: }
84:
85: 86: 87: 88: 89: 90: 91:
92: public function changeActiveStatus($pluginId) {
93:
94:
95: $this->_PimPluginCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
96: $this->_PimPluginCollection->query();
97: $plugin = $this->_PimPluginCollection->next();
98:
99:
100: $pluginName = $plugin->get('name');
101: $pluginActiveStatus = $plugin->get('active');
102:
103:
104: $this->_PimPluginRelationsCollection->setWhere('idplugin', cSecurity::toInteger($pluginId));
105: $this->_PimPluginRelationsCollection->setWhere('type', 'navs');
106: $this->_PimPluginRelationsCollection->query();
107:
108: if ($pluginActiveStatus == 1) {
109:
110: $plugin->set('active', 0);
111: $plugin->store();
112:
113:
114:
115: while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
116: $idnavs = $relation->get('iditem');
117: $this->changeNavSubStatus($idnavs, 0);
118: }
119:
120: parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully disabled. To apply the changes please login into backend again.', 'pim'));
121: } else {
122: $plugin->set('active', 1);
123: $plugin->store();
124:
125:
126:
127: while (($relation = $this->_PimPluginRelationsCollection->next()) !== false) {
128: $idnavs = $relation->get('iditem');
129: $this->changeNavSubStatus($idnavs, 1);
130: }
131:
132: parent::info(i18n('The plugin', 'pim') . ' <strong>' . $pluginName . '</strong> ' . i18n('has been sucessfully enabled. To apply the changes please login into backend again.', 'pim'));
133: }
134: }
135:
136: 137: 138: 139: 140: 141: 142: 143:
144: private function changeNavSubStatus($idnavs, $online) {
145: $this->_ApiNavSubCollection->setWhere('idnavs', cSecurity::toInteger($idnavs));
146: $this->_ApiNavSubCollection->query();
147:
148: $navSub = $this->_ApiNavSubCollection->next();
149: $navSub->set('online', cSecurity::toInteger($online));
150: $navSub->store();
151:
152: return true;
153: }
154:
155: }
156: ?>