Index: branches/RC/core/units/general/cat_dbitem.php =================================================================== diff -u -r9021 -r9623 --- branches/RC/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 9021) +++ branches/RC/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 9623) @@ -418,10 +418,27 @@ function ChangeStatus($new_status) { $status_field = array_shift( $this->Application->getUnitOption($this->Prefix,'StatusField') ); + if ($new_status != $this->GetDBField($status_field)) { + // status was changed + $this->sendEmailEvents($new_status); + } $this->SetDBField($status_field, $new_status); + return $this->Update(); } + function sendEmailEvents($new_status) + { + $perm_prefix = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix'); + $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField'); + if (!$owner_field) { + $owner_field = 'CreatedById'; + } + + $event_name = $perm_prefix.'.'.($new_status == STATUS_ACTIVE ? 'APPROVE' : 'DENY'); + $this->Application->EmailEventUser($event_name, $this->GetDBField($owner_field)); + } + /** * Approves changes made to category item *