Index: trunk/core/units/themes/themes_config.php =================================================================== diff -u -N -r8074 -r8075 --- trunk/core/units/themes/themes_config.php (.../themes_config.php) (revision 8074) +++ trunk/core/units/themes/themes_config.php (.../themes_config.php) (revision 8075) @@ -62,7 +62,7 @@ 'Name' => Array('type' => 'string','not_null' => 1, 'required' => 1, 'default' => ''), 'Enabled' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(1=>'la_Enabled', 0=>'la_Disabled'), 'use_phrases'=>1, 'not_null' => 1, 'default' => 1), 'Description' => Array('type' => 'string','default' => null), - 'PrimaryTheme' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), + 'PrimaryTheme' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0), 'CacheTimeout' => Array('type' => 'int', 'not_null' => 1, 'default' => 0), 'StylesheetId' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Stylesheets', 'option_key_field' => 'StylesheetId', 'option_title_field' => 'Name', 'not_null' => 1, 'default' => 0), ), @@ -75,6 +75,7 @@ 'Name' => Array( 'title'=>'la_col_Name',), 'Description' => Array( 'title'=>'la_col_Description', ), 'Enabled' => Array( 'title'=>'la_col_Status', 'filter_block' => 'grid_options_filter'), +// 'PrimaryTheme' => Array( 'title'=>'la_col_Primary', 'filter_block' => 'grid_options_filter'), ), ), Index: trunk/core/units/themes/themes_eh.php =================================================================== diff -u -N -r8069 -r8075 --- trunk/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 8069) +++ trunk/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 8075) @@ -16,23 +16,44 @@ $ids = $this->StoreSelectedIDs($event); if ($ids) { $id = array_shift($ids); - - $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); - - $sql = 'UPDATE '.$table_name.' - SET PrimaryTheme = 0'; - $this->Conn->Query($sql); - - - $sql = 'UPDATE '.$table_name.' - SET PrimaryTheme = 1, Enabled = 1 - WHERE '.$id_field.' = '.$id; - $this->Conn->Query($sql); + $this->setPrimary($id); } $this->clearSelectedIDs($event); } + + function setPrimary($id) + { + $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); + + $sql = 'UPDATE '.$table_name.' + SET PrimaryTheme = 0'; + $this->Conn->Query($sql); + + + $sql = 'UPDATE '.$table_name.' + SET PrimaryTheme = 1, Enabled = 1 + WHERE '.$id_field.' = '.$id; + $this->Conn->Query($sql); + } + + /** + * Set correct parent path for newly created categories + * + * @param kEvent $event + */ + function OnAfterCopyToLive(&$event) + { + $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true)); + /* @var $object kDBItem */ + + $object->Load($event->getEventParam('id')); + + if ($object->GetDBField('PrimaryTheme')) { + $this->setPrimary($event->getEventParam('id')); + } + } } ?> \ No newline at end of file