Index: branches/5.0.x/core/units/themes/themes_eh.php =================================================================== diff -u -N -r12357 -r12588 --- branches/5.0.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 12357) +++ branches/5.0.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 12588) @@ -1,6 +1,6 @@ setPrimary($id); + + $rebuild_event = new kEvent('adm:OnRebuildThemes'); + $this->Application->HandleEvent($rebuild_event); } $this->clearSelectedIDs($event); @@ -68,7 +71,7 @@ } /** - * Set correct parent path for newly created categories + * Set's primary theme (when checkbox used on editing form) * * @param kEvent $event */ @@ -85,6 +88,35 @@ } /** + * Also rebuilds theme files, when enabled theme is saved + * + * @param kEvent $event + */ + function OnSave(&$event) + { + parent::OnSave($event); + + if (($event->status != erSUCCESS) || !$event->getEventParam('ids')) { + return ; + } + + $ids = $event->getEventParam('ids'); + + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + + $sql = 'SELECT COUNT(*) + FROM ' . $table_name . ' + WHERE ' . $id_field . ' IN (' . $ids . ') AND (Enabled = 1)'; + $enabled_themes = $this->Conn->GetOne($sql); + + if ($enabled_themes) { + $rebuild_event = new kEvent('adm:OnRebuildThemes'); + $this->Application->HandleEvent($rebuild_event); + } + } + + /** * Allows to change the theme * * @param kEvent $event