Changeset View
Changeset View
Standalone View
Standalone View
core/units/content/content_eh.php
Show All 19 Lines | |||||
* Checks user permission to execute given $event | * Checks user permission to execute given $event | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return bool | * @return bool | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function CheckPermission(kEvent $event) | public function CheckPermission(kEvent $event) | ||||
{ | { | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$user_id = $this->Application->RecallVar('user_id'); | $user_id = $this->Application->RecallVar('user_id'); | ||||
// user can change top category | // user can change top category | ||||
$top_category = $this->Application->getBaseCategory(); | $top_category = $this->Application->getBaseCategory(); | ||||
$perm_status = $perm_helper->CheckUserPermission($user_id, 'CATEGORY.MODIFY', 0, $top_category); | $perm_status = $perm_helper->CheckUserPermission($user_id, 'CATEGORY.MODIFY', 0, $top_category); | ||||
return $perm_helper->finalizePermissionCheck($event, $perm_status); | return $perm_helper->finalizePermissionCheck($event, $perm_status); | ||||
Show All 32 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnEdit(kEvent $event) | protected function OnEdit(kEvent $event) | ||||
{ | { | ||||
parent::OnEdit($event); | parent::OnEdit($event); | ||||
/** @var fckFCKHelper $fck_helper */ | |||||
$fck_helper = $this->Application->recallObject('FCKHelper'); | $fck_helper = $this->Application->recallObject('FCKHelper'); | ||||
/* @var $fck_helper fckFCKHelper */ | |||||
$transit_params = $fck_helper->getTransitParams(); | $transit_params = $fck_helper->getTransitParams(); | ||||
foreach ($transit_params as $param_name => $param_value) { | foreach ($transit_params as $param_name => $param_value) { | ||||
$event->SetRedirectParam($param_name, $param_value); | $event->SetRedirectParam($param_name, $param_value); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ( !$items_info ) { | if ( !$items_info ) { | ||||
return ''; | return ''; | ||||
} | } | ||||
list ($object, $revision) = $this->getContentBlockAndRevision($event); | list ($object, $revision) = $this->getContentBlockAndRevision($event); | ||||
/* @var $revision kDBItem */ | /** @var kDBItem $revision */ | ||||
/* @var $object kDBItem */ | /** @var kDBItem $object */ | ||||
list (, $field_values) = each($items_info); | list (, $field_values) = each($items_info); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$updated = $object->Update(); | $updated = $object->Update(); | ||||
if ( $updated ) { | if ( $updated ) { | ||||
$revision->SetDBField('AutoSavedOn_date', adodb_mktime()); | $revision->SetDBField('AutoSavedOn_date', adodb_mktime()); | ||||
$revision->SetDBField('AutoSavedOn_time', adodb_mktime()); | $revision->SetDBField('AutoSavedOn_time', adodb_mktime()); | ||||
$revision->Update(); | $revision->Update(); | ||||
} | } | ||||
if ( $is_draft ) { | if ( $is_draft ) { | ||||
if ( $updated ) { | if ( $updated ) { | ||||
/** @var PageHelper $page_helper */ | |||||
$page_helper = $this->Application->recallObject('PageHelper'); | $page_helper = $this->Application->recallObject('PageHelper'); | ||||
/* @var $page_helper PageHelper */ | |||||
return $revision->GetField('AutoSavedOn') . ' (' . $page_helper->getAgoTime($revision->GetDBField('AutoSavedOn')) . ')'; | return $revision->GetField('AutoSavedOn') . ' (' . $page_helper->getAgoTime($revision->GetDBField('AutoSavedOn')) . ')'; | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
return $updated; | return $updated; | ||||
} | } | ||||
Show All 9 Lines | |||||
{ | { | ||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
if ( $this->Application->GetVar('ajax') != 'yes' ) { | if ( $this->Application->GetVar('ajax') != 'yes' ) { | ||||
return; | return; | ||||
} | } | ||||
list (, $revision) = $this->getContentBlockAndRevision($event); | list (, $revision) = $this->getContentBlockAndRevision($event); | ||||
/* @var $revision kDBItem */ | /** @var kDBItem $revision */ | ||||
/** @var PageHelper $page_helper */ | |||||
$page_helper = $this->Application->recallObject('PageHelper'); | $page_helper = $this->Application->recallObject('PageHelper'); | ||||
/* @var $page_helper PageHelper */ | |||||
$time = $revision->GetField('AutoSavedOn'); | $time = $revision->GetField('AutoSavedOn'); | ||||
if ( $time ) { | if ( $time ) { | ||||
echo $time . ' (' . $page_helper->getAgoTime($revision->GetDBField('AutoSavedOn')) . ')'; | echo $time . ' (' . $page_helper->getAgoTime($revision->GetDBField('AutoSavedOn')) . ')'; | ||||
} | } | ||||
} | } | ||||
Show All 18 Lines | |||||
* Returns content block. | * Returns content block. | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* | * | ||||
* @return kDBItem[] | * @return kDBItem[] | ||||
*/ | */ | ||||
function getContentBlockAndRevision($event) | function getContentBlockAndRevision($event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(Array('skip_autoload' => true)); | $object = $event->getObject(Array('skip_autoload' => true)); | ||||
Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
/* @var $object kDBItem */ | |||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ( !$items_info ) { | if ( !$items_info ) { | ||||
return array(); | return array(); | ||||
} | } | ||||
list ($id,) = each($items_info); | list ($id,) = each($items_info); | ||||
$object->Load($id); | $object->Load($id); | ||||
/** @var kDBItem $revision */ | |||||
$revision = $this->Application->recallObject('page-revision', null, Array('skip_autoload' => true)); | $revision = $this->Application->recallObject('page-revision', null, Array('skip_autoload' => true)); | ||||
PHP keywords must be lowercase; expected "array" but found "Array" Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
/* @var $revision kDBItem */ | |||||
$revision->Load($object->GetDBField('RevisionId')); | $revision->Load($object->GetDBField('RevisionId')); | ||||
if ( $this->Application->ConfigValue('EnablePageContentRevisionControl') && !$revision->GetDBField('IsDraft') ) { | if ( $this->Application->ConfigValue('EnablePageContentRevisionControl') && !$revision->GetDBField('IsDraft') ) { | ||||
// editing live revision of a page's content block -> get draft for current user and page | // editing live revision of a page's content block -> get draft for current user and page | ||||
$load_keys = Array( | $load_keys = Array( | ||||
'PageId' => $revision->GetDBField('PageId'), | 'PageId' => $revision->GetDBField('PageId'), | ||||
'IsDraft' => 1, | 'IsDraft' => 1, | ||||
Show All 23 Lines |
PHP keywords must be lowercase; expected "array" but found "Array"