Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/users/users_event_handler.php
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | |||||
$user_id = $this->Application->RecallVar('user_id'); | $user_id = $this->Application->RecallVar('user_id'); | ||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ( ($event->Name == 'OnCreate' || $event->Name == 'OnRegisterAjax') && $user_id == USER_GUEST ) { | if ( ($event->Name == 'OnCreate' || $event->Name == 'OnRegisterAjax') && $user_id == USER_GUEST ) { | ||||
// "Guest" can create new users | // "Guest" can create new users | ||||
return true; | return true; | ||||
} | } | ||||
if ( $event->Name == 'OnUpdate' && $user_id > 0 ) { | if ( substr($event->Name, 0, 8) == 'OnUpdate' && $user_id > 0 ) { | ||||
$user_dummy = $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true)); | $user_dummy = $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true)); | ||||
/* @var $user_dummy UsersItem */ | /* @var $user_dummy UsersItem */ | ||||
foreach ($items_info as $id => $field_values) { | foreach ($items_info as $id => $field_values) { | ||||
if ( $id != $user_id ) { | if ( $id != $user_id ) { | ||||
// registered users can update their record only | // registered users can update their record only | ||||
return false; | return false; | ||||
} | } | ||||
Show All 15 Lines | |||||
return true; | return true; | ||||
} | } | ||||
if ( $event->Name == 'OnResetLostPassword' && $event->Special == 'forgot' && $user_id == USER_GUEST ) { | if ( $event->Name == 'OnResetLostPassword' && $event->Special == 'forgot' && $user_id == USER_GUEST ) { | ||||
// non-logged in users can reset their password, when reset code is valid | // non-logged in users can reset their password, when reset code is valid | ||||
return is_numeric($this->getPassedID($event)); | return is_numeric($this->getPassedID($event)); | ||||
} | } | ||||
if ( $event->Name == 'OnUpdate' && $user_id <= 0 ) { | if ( substr($event->Name, 0, 8) == 'OnUpdate' && $user_id <= 0 ) { | ||||
// guests are not allowed to update their record, because they don't have it :) | // guests are not allowed to update their record, because they don't have it :) | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return parent::CheckPermission($event); | return parent::CheckPermission($event); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 686 Lines • ▼ Show 20 Line(s) | |||||
parent::OnUpdate($event); | parent::OnUpdate($event); | ||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin ) { | ||||
$this->setNextTemplate($event); | $this->setNextTemplate($event); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Updates kDBItem via AJAX. | |||||
* | |||||
* @param kEvent $event Event. | |||||
* | |||||
* @return void | |||||
*/ | |||||
protected function OnUpdateAjax(kEvent $event) | |||||
{ | |||||
/** @var AjaxFormHelper $ajax_form_helper */ | |||||
$ajax_form_helper = $this->Application->recallObject('AjaxFormHelper'); | |||||
$ajax_form_helper->transitEvent($event, 'OnUpdate'); | |||||
} | |||||
/** | |||||
* Checks state against country | * Checks state against country | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemUpdate(kEvent $event) | protected function OnBeforeItemUpdate(kEvent $event) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1030 Lines • Show Last 20 Lines |