Index: branches/5.3.x/core/kernel/db/cat_dbitem.php =================================================================== diff -u -N -r15677 -r15698 --- branches/5.3.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 15677) +++ branches/5.3.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 15698) @@ -1,6 +1,6 @@ usePendingEditing = $this->Application->getUnitOption($this->Prefix, 'UsePendingEditing'); + $this->usePendingEditing = $this->getUnitConfig()->getUsePendingEditing(); } /** @@ -151,7 +151,7 @@ */ public function NameCopy($master=null, $foreign_key=null, $title_field=null, $format='Copy %1$s of %2$s') { - $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField'); + $title_field = $this->getUnitConfig()->getTitleField(); if (!$title_field) return; $new_name = $this->GetDBField($title_field); @@ -262,9 +262,9 @@ */ function DeleteFromCategories($delete_category_ids) { - $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); // because item was loaded before by ResourceId + $id_field = $this->getUnitConfig()->getIDField(); // because item was loaded before by ResourceId - $ci_table = $this->Application->getUnitOption($this->Prefix . '-ci', 'TableName'); + $ci_table = $this->Application->getUnitConfig($this->Prefix . '-ci')->getTableName(); $resource_id = $this->GetDBField('ResourceId'); $item_cats_sql = ' SELECT CategoryId @@ -341,7 +341,7 @@ return ; } - $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField'); + $title_field = $this->getUnitConfig()->getTitleField(); if ( preg_match('/l([\d]+)_(.*)/', $title_field, $regs) ) { // if title field is multilingual, then use it's name from primary language @@ -473,9 +473,9 @@ function ChangeStatus($new_status, $pending_editing = false) { - $status_field = $this->getStatusField(); + $status_field = $this->getUnitConfig()->getStatusField(true); - if ( $new_status != $this->GetDBField($status_field) ) { + if ($new_status != $this->GetDBField($status_field)) { // status was changed $this->sendEmails($new_status, $pending_editing); } @@ -487,12 +487,11 @@ function sendEmails($new_status, $pending_editing = false) { - $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); - if (!$owner_field) { - $owner_field = 'CreatedById'; - } + $config = $this->getUnitConfig(); - $event_name = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix'); + $owner_field = $config->getOwnerField('CreatedById'); + $event_name = $config->getPermItemPrefix(); + if ($pending_editing) { $event_name .= '.MODIFY'; } @@ -563,24 +562,25 @@ $id = $this->GetID(); if (!in_array($id, $already_viewed)) { - $property_map = $this->Application->getUnitOption($this->Prefix, 'ItemPropertyMappings'); + $property_map = $this->getUnitConfig()->getItemPropertyMappings(Array ()); + if (!$property_map) { return ; } + $hits_field = $property_map['ClickField']; $new_hits = $this->GetDBField($hits_field) + 1; $sql = 'SELECT MAX('.$hits_field.') FROM '.$this->TableName.' WHERE FLOOR('.$hits_field.') = '.$new_hits; $max_hits = $this->Conn->GetOne($sql); + if ($max_hits) { $new_hits = $max_hits + 0.000001; } - $fields_hash = Array ( - $hits_field => $new_hits, - ); + $fields_hash = Array ($hits_field => $new_hits,); $this->Conn->doUpdate($fields_hash, $this->TableName, $this->IDField.' = '.$id); array_push($already_viewed, $id); @@ -605,7 +605,7 @@ // for item with many categories makes primary to load $ci_table = TABLE_PREFIX . 'CategoryItems'; - if ( $this->IsTempTable() ) { + if ($this->IsTempTable()) { $ci_table = $this->Application->GetTempName($ci_table, 'prefix:' . $this->Prefix); }