Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/cat_event_handler.php
Show First 20 Lines • Show All 2354 Lines • ▼ Show 20 Line(s) | |||||
*/ | */ | ||||
protected function OnBeforeItemCreate(kEvent $event) | protected function OnBeforeItemCreate(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeItemCreate($event); | parent::OnBeforeItemCreate($event); | ||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | /* @var $object kCatDBItem */ | ||||
$is_admin = $this->Application->isAdminUser; | |||||
$owner_field = $this->getOwnerField($event->Prefix); | $owner_field = $this->getOwnerField($event->Prefix); | ||||
if ( (!$object->IsTempTable() && !$is_admin) || ($is_admin && !$object->GetDBField($owner_field)) ) { | // Don't allow creating records on behalf of another user. | ||||
// Front-end OR owner not specified -> set to currently logged-in user | if ( !$this->Application->isAdminUser && !defined('CRON') ) { | ||||
$object->SetDBField($owner_field, $object->GetOriginalField($owner_field)); | |||||
} | |||||
// Auto-assign records to currently logged-in user. | |||||
if ( !$object->GetDBField($owner_field) ) { | |||||
$object->SetDBField($owner_field, $this->Application->RecallVar('user_id')); | $object->SetDBField($owner_field, $this->Application->RecallVar('user_id')); | ||||
} | } | ||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin ) { | ||||
$this->setItemStatusByPermission($event); | $this->setItemStatusByPermission($event); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 712 Lines • Show Last 20 Lines |