Index: branches/5.3.x/core/kernel/db/cat_dbitem.php =================================================================== diff -u -N -r15483 -r15677 --- branches/5.3.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 15483) +++ branches/5.3.x/core/kernel/db/cat_dbitem.php (.../cat_dbitem.php) (revision 15677) @@ -1,6 +1,6 @@ Application->getUnitOption($this->Prefix,'StatusField') ); - if ($new_status != $this->GetDBField($status_field)) { + $status_field = $this->getStatusField(); + + if ( $new_status != $this->GetDBField($status_field) ) { // status was changed - $this->sendEmailEvents($new_status, $pending_editing); + $this->sendEmails($new_status, $pending_editing); } + $this->SetDBField($status_field, $new_status); return $this->Update(); } - function sendEmailEvents($new_status, $pending_editing = false) + function sendEmails($new_status, $pending_editing = false) { $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); if (!$owner_field) { @@ -496,7 +498,7 @@ } $event_name .= $new_status == STATUS_ACTIVE ? '.APPROVE' : '.DENY'; - $this->Application->EmailEventUser($event_name, $this->GetDBField($owner_field)); + $this->Application->emailUser($event_name, $this->GetDBField($owner_field)); } /** @@ -549,7 +551,7 @@ $temp_handler->DeleteItems($this->Prefix, $this->Special, Array ($this->GetID())); - $this->sendEmailEvents(STATUS_DISABLED, true); + $this->sendEmails(STATUS_DISABLED, true); // original item is not changed here, because it is already enabled (thrus pending copy is visible to item's owner or admin with permission) return true; } @@ -599,26 +601,21 @@ */ protected function GetKeyClause($method = null, $keys_hash = null) { - if ($method == 'load') { + if ( $method == 'load' && !isset($keys_hash) ) { // 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); } - $primary_category_clause = Array ('`' . $ci_table . '`.`PrimaryCat`' => 1); - - if (!isset($keys_hash)) { - $keys_hash = Array ($this->IDField => $this->ID); - } - - // merge primary category clause in any case to be sure, that - // CategoryId field will always contain primary category of item - $keys_hash = array_merge($keys_hash, $primary_category_clause); + // ensures, that CategoryId calculated field has primary category id in it + $keys_hash = Array ( + $this->IDField => $this->ID, + '`' . $ci_table . '`.`PrimaryCat`' => 1 + ); } return parent::GetKeyClause($method, $keys_hash); } - } \ No newline at end of file