Index: trunk/kernel/include/item.php =================================================================== diff -u -N -r5340 -r6093 --- trunk/kernel/include/item.php (.../item.php) (revision 5340) +++ trunk/kernel/include/item.php (.../item.php) (revision 6093) @@ -247,7 +247,9 @@ function DeleteCustomData() { $cdata = new clsCustomDataList(); - $cdata->DeleteResource($this->Get('ResourceId'), $this->Prefix); + if ($this->Prefix) { + $cdata->DeleteResource($this->Get('ResourceId'), $this->Prefix); + } } function Delete($RecordOnly=FALSE) @@ -873,7 +875,10 @@ if (is_object($rs)) { if($rs->RecordCount() == 0 ) { - $sql = "INSERT INTO $SourceTable (CategoryId,ItemResourceId, PrimaryCat) VALUES (".(int)$CatId.",'".$this->Get("ResourceId")."',$Primary)"; + $sql = "INSERT INTO $SourceTable (CategoryId,ItemResourceId, PrimaryCat, ItemPrefix, Filename) + VALUES (".(int)$CatId.",'".$this->Get("ResourceId")."',$Primary, + '".$this->Prefix."', + ".$this->adodbConnection->qstr($this->Get('Filename')).")"; if($this->debuglevel) echo $sql."
\n"; $this->adodbConnection->Execute($sql); @@ -1106,17 +1111,22 @@ if($cat_id > 0) $this->refreshLastUpdate( $db->GetOne($sql) ); } - function StripDisallowed($string) + function StripDisallowed($filename) { - $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`', + $filenames_helper =& $this->Application->recallObject('FilenamesHelper'); + $table = TABLE_PREFIX.'CategoryItems'; + + return $filenames_helper->stripDisallowed($table, 'ItemResourceId', $this->Get('ResourceId'), $filename); + +/* $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~', '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ','); $string = str_replace($not_allowed, '_', $string); $string = preg_replace('/(_+)/', '_', $string); $string = $this->checkAutoFilename($string); - return $string; + return $string;*/ } function checkAutoFilename($filename) @@ -1151,6 +1161,7 @@ return $filename; } + function GenerateFilename() { if ( !$this->Get('AutomaticFilename') && $this->Get('Filename') ) @@ -1168,19 +1179,27 @@ function Update($UpdatedBy = null) { - parent::Update($UpdatedBy); + $ret = parent::Update($UpdatedBy); - $this->GenerateFilename(); - parent::Update($UpdatedBy); + $this->GenerateFilename(); + $db =& GetADODBConnection(); + if ($ret) { + $filename = $this->Get('Filename'); + $sql = 'UPDATE '.TABLE_PREFIX.'CategoryItems + SET Filename = '.$db->qstr($filename).' + WHERE ItemResourceId = '.$this->Get('ResourceId'); + $db->Query($sql); + } +// parent::Update($UpdatedBy); + } function Create() { parent::Create(); $this->GenerateFilename(); - parent::Update(); }