Index: branches/5.1.x/core/units/modules/modules_event_handler.php =================================================================== diff -u -N -r13581 -r13750 --- branches/5.1.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 13581) +++ branches/5.1.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 13750) @@ -1,6 +1,6 @@ getObject( Array('skip_autoload' => true) ); + /* @var $object kDBItem */ + $ids = $this->StoreSelectedIDs($event); - if (!$ids) { - return true; + return ; } - $status_field = array_shift( $this->Application->getUnitOption($event->Prefix, 'StatusField') ); + $updated = 0; + $status_field = $this->Application->getUnitOption($event->Prefix, 'StatusField'); + $status_field = array_shift($status_field); foreach ($ids as $id) { - if (($event->Name == 'OnMassDecline') && ($id == 'In-Portal')) { - // don't allow to disable in-portal - continue; - } + $object->Load($id); - if ($id == 'Core') { + if (in_array($id, Array ('In-Portal', 'Core')) || !$object->isLoaded()) { // don't allow any kind of manupulations with kernel + // approve/decline on not installed module continue; } - $object->Load($id); + $enabled = $event->Name == 'OnMassApprove' ? 1 : 0; + $object->SetDBField($status_field, $enabled); - $object->SetDBField($status_field, $event->Name == 'OnMassApprove' ? 1 : 0); + if (!$object->GetChangedFields()) { + // no changes -> skip + continue; + } if ($object->Update()) { + $updated++; + $sql = 'UPDATE ' . TABLE_PREFIX . 'ImportScripts - SET Status = ' . ($event->Name == 'OnMassApprove' ? STATUS_ACTIVE : STATUS_DISABLED) . ' - WHERE Module = "' . $object->GetDBField('Name') . '"'; + SET Status = ' . $enabled . ' + WHERE Module = "' . $object->GetDBField('Name') . '"'; $this->Conn->Query($sql); - - $event->status = erSUCCESS; - $event->redirect_params = Array('opener' => 's'); //stay! } else { $event->status = erFAIL; @@ -103,8 +107,13 @@ } } - $this->Application->UnitConfigReader->ResetParsedData(true); //true to reset sections cache also - $event->SetRedirectParam('RefreshTree', 1); + if ($updated) { + $event->status = erSUCCESS; + $event->redirect_params = Array ('opener' => 's'); //stay! + + $this->Application->UnitConfigReader->ResetParsedData(true); //true to reset sections cache also + $event->SetRedirectParam('RefreshTree', 1); + } } /**