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