Index: trunk/core/units/general/cat_dbitem.php =================================================================== diff -u -r7391 -r7635 --- trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 7391) +++ trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 7635) @@ -22,13 +22,13 @@ * @var bool */ var $usePendingEditing = false; - + function Clear() { parent::Clear(); $this->CategoryPath = Array(); } - + /** * Set's prefix and special * @@ -41,13 +41,14 @@ parent::Init($prefix, $special, $event_params); $this->usePendingEditing = $this->Application->getUnitOption($this->Prefix, 'UsePendingEditing'); } - + function Create($force_id=false, $system_create=false) { if (!$this->Validate()) return false; $this->SetDBField('ResourceId', $this->Application->NextResourceId()); $this->SetDBField('Modified', adodb_mktime() ); + $this->UpdateFormattersSubFields(array('Modified')); if ($this->mode != 't' && !$this->Application->IsAdmin()) { $this->SetDBField('CreatedById', $this->Application->RecallVar('user_id')); @@ -68,7 +69,7 @@ 'ItemPrefix' => $this->Prefix, 'Filename' => $this->GetDBField('Filename'), ); - $this->Conn->doInsert($fields_hash, $this->CategoryItemsTable()); + $this->Conn->doInsert($fields_hash, $this->CategoryItemsTable()); } return $ret; } @@ -77,6 +78,7 @@ { $this->VirtualFields['ResourceId'] = Array(); $this->SetDBField('Modified', adodb_mktime() ); + $this->UpdateFormattersSubFields(array('Modified')); $this->SetDBField('ModifiedById', $this->Application->RecallVar('user_id')); if ($this->useFilenames) { @@ -109,11 +111,11 @@ if ($this->Application->IsTempTable($this->TableName)) { $table = $this->Application->GetTempName($table, 'prefix:'.$this->Prefix); } - + return $table; } - - + + function checkFilename() { if( !$this->GetDBField('AutomaticFilename') ) @@ -154,6 +156,10 @@ $original_checked = true; } while ($res !== false); $this->SetDBField($title_field, $new_name); + + // this is needed, because Create will create items in its own CategoryId (if it's set), + // but we need to create it in target Paste category @see{kCatDBItem::Create} and its primary_category detection + $this->SetDBField('CategoryId', $cat_id); } function MoveToCat($cat_id=null) @@ -401,14 +407,14 @@ } return $image_data; } - + function ChangeStatus($new_status) { $status_field = array_shift( $this->Application->getUnitOption($this->Prefix,'StatusField') ); $this->SetDBField($status_field, $new_status); return $this->Update(); } - + /** * Approves changes made to category item * @@ -422,19 +428,19 @@ // non-pending copy of original link return $this->ChangeStatus(STATUS_ACTIVE); } - + if ($this->raiseEvent('OnBeforeDeleteOriginal', null, Array('original_id' => $original_id))) { // delete original item, because changes made in pending copy (this item) got to be approved in this method $temp_handler =& $this->Application->recallObject($this->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); $temp_handler->DeleteItems($this->Prefix, $this->Special, Array($original_id)); - + $this->SetDBField('OrgId', 0); return $this->ChangeStatus(STATUS_ACTIVE); } - + return false; } - + /** * Decline changes made to category item * @@ -443,12 +449,12 @@ function DeclineChanges() { $original_id = $this->GetDBField('OrgId'); - + if (!($this->usePendingEditing && $original_id)) { // non-pending copy of original link return $this->ChangeStatus(STATUS_DISABLED); } - + // delete this item, because changes made in pending copy (this item) will be declined in this method $temp_handler =& $this->Application->recallObject($this->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); $temp_handler->DeleteItems($this->Prefix, $this->Special, Array($this->GetID()));