Changeset View
Standalone View
core/kernel/db/cat_event_handler.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
* Load item if id is available | * Load item if id is available | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function LoadItem(kEvent $event) | protected function LoadItem(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$id = $this->getPassedID($event); | $id = $this->getPassedID($event); | ||||
if ( $object->Load($id) ) { | if ( $object->Load($id) ) { | ||||
/** @var Params $actions */ | |||||
$actions = $this->Application->recallObject('kActions'); | $actions = $this->Application->recallObject('kActions'); | ||||
/* @var $actions Params */ | |||||
$actions->Set($event->getPrefixSpecial() . '_id', $object->GetID()); | $actions->Set($event->getPrefixSpecial() . '_id', $object->GetID()); | ||||
$use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | ||||
if ( $use_pending_editing && $event->Special != 'original' ) { | if ( $use_pending_editing && $event->Special != 'original' ) { | ||||
$this->Application->SetVar($event->Prefix . '.original_id', $object->GetDBField('OrgId')); | $this->Application->SetVar($event->Prefix . '.original_id', $object->GetDBField('OrgId')); | ||||
} | } | ||||
Show All 22 Lines | |||||
if ( $event->Name == 'OnExport' ) { | if ( $event->Name == 'OnExport' ) { | ||||
// save category_id before doing export | // save category_id before doing export | ||||
$this->Application->LinkVar('m_cat_id'); | $this->Application->LinkVar('m_cat_id'); | ||||
} | } | ||||
if ( in_array($event->Name, $this->_getMassPermissionEvents()) ) { | if ( in_array($event->Name, $this->_getMassPermissionEvents()) ) { | ||||
$items = $this->_getPermissionCheckInfo($event); | $items = $this->_getPermissionCheckInfo($event); | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
if ( ($event->Name == 'OnSave') && array_key_exists(0, $items) ) { | if ( ($event->Name == 'OnSave') && array_key_exists(0, $items) ) { | ||||
// adding new item (ID = 0) | // adding new item (ID = 0) | ||||
$perm_value = $perm_helper->AddCheckPermission($items[0]['CategoryId'], $event->Prefix) > 0; | $perm_value = $perm_helper->AddCheckPermission($items[0]['CategoryId'], $event->Prefix) > 0; | ||||
} | } | ||||
else { | else { | ||||
// leave only items, that can be edited | // leave only items, that can be edited | ||||
$ids = Array (); | $ids = Array (); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Returns information used in permission checking | * Returns information used in permission checking | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return Array | * @return Array | ||||
*/ | */ | ||||
function _getPermissionCheckInfo($event) | function _getPermissionCheckInfo($event) | ||||
{ | { | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
// when saving data from temp table to live table check by data from temp table | // when saving data from temp table to live table check by data from temp table | ||||
$item_ids = $this->_getPermissionCheckIDs($event); | $item_ids = $this->_getPermissionCheckIDs($event); | ||||
$items = $perm_helper->GetCategoryItemData($event->Prefix, $item_ids, $event->Name == 'OnSave'); | $items = $perm_helper->GetCategoryItemData($event->Prefix, $item_ids, $event->Name == 'OnSave'); | ||||
if (!$items) { | if (!$items) { | ||||
// when item not present in temp table, then permission is not checked, because there are no data in db to check | // when item not present in temp table, then permission is not checked, because there are no data in db to check | ||||
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | ||||
Show All 21 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCopy($event) | protected function OnCopy($event) | ||||
{ | { | ||||
$this->Application->RemoveVar('clipboard'); | $this->Application->RemoveVar('clipboard'); | ||||
/** @var kClipboardHelper $clipboard_helper */ | |||||
$clipboard_helper = $this->Application->recallObject('ClipboardHelper'); | $clipboard_helper = $this->Application->recallObject('ClipboardHelper'); | ||||
/* @var $clipboard_helper kClipboardHelper */ | |||||
$clipboard_helper->setClipboard($event, 'copy', $this->StoreSelectedIDs($event)); | $clipboard_helper->setClipboard($event, 'copy', $this->StoreSelectedIDs($event)); | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
} | } | ||||
/** | /** | ||||
* Add selected items to clipboard with mode = CUT | * Add selected items to clipboard with mode = CUT | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCut($event) | protected function OnCut($event) | ||||
{ | { | ||||
$this->Application->RemoveVar('clipboard'); | $this->Application->RemoveVar('clipboard'); | ||||
/** @var kClipboardHelper $clipboard_helper */ | |||||
$clipboard_helper = $this->Application->recallObject('ClipboardHelper'); | $clipboard_helper = $this->Application->recallObject('ClipboardHelper'); | ||||
/* @var $clipboard_helper kClipboardHelper */ | |||||
$clipboard_helper->setClipboard($event, 'cut', $this->StoreSelectedIDs($event)); | $clipboard_helper->setClipboard($event, 'cut', $this->StoreSelectedIDs($event)); | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
} | } | ||||
/** | /** | ||||
* Checks permission for OnPaste event | * Checks permission for OnPaste event | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
function _checkPastePermission($event) | function _checkPastePermission($event) | ||||
{ | { | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$category_id = $this->Application->GetVar('m_cat_id'); | $category_id = $this->Application->GetVar('m_cat_id'); | ||||
if ($perm_helper->AddCheckPermission($category_id, $event->Prefix) == 0) { | if ($perm_helper->AddCheckPermission($category_id, $event->Prefix) == 0) { | ||||
// no items left for editing -> no permission | // no items left for editing -> no permission | ||||
return $perm_helper->finalizePermissionCheck($event, false); | return $perm_helper->finalizePermissionCheck($event, false); | ||||
} | } | ||||
return true; | return true; | ||||
Show All 15 Lines | |||||
$clipboard_data = $event->getEventParam('clipboard_data'); | $clipboard_data = $event->getEventParam('clipboard_data'); | ||||
if ( !$clipboard_data['cut'] && !$clipboard_data['copy'] ) { | if ( !$clipboard_data['cut'] && !$clipboard_data['copy'] ) { | ||||
return; | return; | ||||
} | } | ||||
if ( $clipboard_data['copy'] ) { | if ( $clipboard_data['copy'] ) { | ||||
/** @var kTempTablesHandler $temp */ | |||||
$temp = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | $temp = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | ||||
/* @var $temp kTempTablesHandler */ | |||||
$this->Application->SetVar('ResetCatBeforeClone', 1); // used in "kCatDBEventHandler::OnBeforeClone" | $this->Application->SetVar('ResetCatBeforeClone', 1); // used in "kCatDBEventHandler::OnBeforeClone" | ||||
$temp->CloneItems($event->Prefix, $event->Special, $clipboard_data['copy']); | $temp->CloneItems($event->Prefix, $event->Special, $clipboard_data['copy']); | ||||
} | } | ||||
if ( $clipboard_data['cut'] ) { | if ( $clipboard_data['cut'] ) { | ||||
/** @var kCatDBItem $object */ | |||||
$object = $this->Application->recallObject($event->getPrefixSpecial() . '.item', $event->Prefix, Array ('skip_autoload' => true)); | $object = $this->Application->recallObject($event->getPrefixSpecial() . '.item', $event->Prefix, Array ('skip_autoload' => true)); | ||||
Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 142 characters | |||||
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" | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
/* @var $object kCatDBItem */ | |||||
foreach ($clipboard_data['cut'] as $id) { | foreach ($clipboard_data['cut'] as $id) { | ||||
$object->Load($id); | $object->Load($id); | ||||
$object->MoveToCat(); | $object->MoveToCat(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Show All 14 Lines | |||||
} | } | ||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
$to_delete = Array (); | $to_delete = Array (); | ||||
$recycle_bin = $this->Application->ConfigValue('RecycleBinFolder'); | $recycle_bin = $this->Application->ConfigValue('RecycleBinFolder'); | ||||
if ( $recycle_bin ) { | if ( $recycle_bin ) { | ||||
/** @var CategoriesItem $rb */ | |||||
$rb = $this->Application->recallObject('c.recycle', NULL, array ('skip_autoload' => true)); | $rb = $this->Application->recallObject('c.recycle', NULL, array ('skip_autoload' => true)); | ||||
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Lint: Generic.PHP.LowerCaseConstant.Found: TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
/* @var $rb CategoriesItem */ | |||||
$rb->Load($recycle_bin); | $rb->Load($recycle_bin); | ||||
/** @var kCatDBItem $object */ | |||||
$object = $this->Application->recallObject($event->Prefix . '.recycleitem', NULL, Array ('skip_autoload' => true)); | $object = $this->Application->recallObject($event->Prefix . '.recycleitem', NULL, Array ('skip_autoload' => true)); | ||||
Line exceeds 120 characters; contains 127 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 127 characters | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
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" | |||||
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Lint: Generic.PHP.LowerCaseConstant.Found: TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" | |||||
/* @var $object kCatDBItem */ | |||||
foreach ($ids as $id) { | foreach ($ids as $id) { | ||||
$object->Load($id); | $object->Load($id); | ||||
if ( preg_match('/^' . preg_quote($rb->GetDBField('ParentPath'), '/') . '/', $object->GetDBField('ParentPath')) ) { | if ( preg_match('/^' . preg_quote($rb->GetDBField('ParentPath'), '/') . '/', $object->GetDBField('ParentPath')) ) { | ||||
$to_delete[] = $id; | $to_delete[] = $id; | ||||
continue; | continue; | ||||
} | } | ||||
$object->MoveToCat($recycle_bin); | $object->MoveToCat($recycle_bin); | ||||
} | } | ||||
$ids = $to_delete; | $ids = $to_delete; | ||||
} | } | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | ||||
Line exceeds 120 characters; contains 124 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 124 characters | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$event->setEventParam('ids', $ids); | $event->setEventParam('ids', $ids); | ||||
$this->customProcessing($event, 'before'); | $this->customProcessing($event, 'before'); | ||||
$ids = $event->getEventParam('ids'); | $ids = $event->getEventParam('ids'); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
$temp_handler->DeleteItems($event->Prefix, $event->Special, $ids); | $temp_handler->DeleteItems($event->Prefix, $event->Special, $ids); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
// processing keyword_string param of ListProducts tag | // processing keyword_string param of ListProducts tag | ||||
$this->Application->SetVar('keywords', $keywords); | $this->Application->SetVar('keywords', $keywords); | ||||
$type = 'simple'; | $type = 'simple'; | ||||
} | } | ||||
$search_event = $event_mapping[$type]; | $search_event = $event_mapping[$type]; | ||||
$this->$search_event($event); | $this->$search_event($event); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
/** @var kSearchHelper $search_helper */ | /** @var kSearchHelper $search_helper */ | ||||
$search_helper = $this->Application->recallObject('SearchHelper'); | $search_helper = $this->Application->recallObject('SearchHelper'); | ||||
$search_sql = ' FROM ' . $search_helper->getSearchTable() . ' search_result | $search_sql = ' FROM ' . $search_helper->getSearchTable() . ' search_result | ||||
JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId'; | JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId'; | ||||
$sql = str_replace('FROM %1$s', $search_sql, $object->GetPlainSelectSQL()); | $sql = str_replace('FROM %1$s', $search_sql, $object->GetPlainSelectSQL()); | ||||
Show All 31 Lines | |||||
if (!$prefix_special) { | if (!$prefix_special) { | ||||
$prefix_special = $this->Application->Parser->GetParam('PrefixSpecial'); | $prefix_special = $this->Application->Parser->GetParam('PrefixSpecial'); | ||||
} | } | ||||
$id = false; | $id = false; | ||||
if ($prefix_special !== false) { | if ($prefix_special !== false) { | ||||
$processed_prefix = $this->Application->processPrefix($prefix_special); | $processed_prefix = $this->Application->processPrefix($prefix_special); | ||||
if ($processed_prefix['prefix'] == $related_prefix) { | if ($processed_prefix['prefix'] == $related_prefix) { | ||||
// printing related categories within list of items (not on details page) | // printing related categories within list of items (not on details page) | ||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
/** @var kDBList $list */ | |||||
$list = $this->Application->recallObject($prefix_special); | $list = $this->Application->recallObject($prefix_special); | ||||
/* @var $list kDBList */ | |||||
$id = $list->GetID(); | $id = $list->GetID(); | ||||
} | } | ||||
} | } | ||||
if ($id === false) { | if ($id === false) { | ||||
// printing related categories for single item (possibly on details page) | // printing related categories for single item (possibly on details page) | ||||
if ($related_prefix == 'c') { | if ($related_prefix == 'c') { | ||||
$id = $this->Application->GetVar('m_cat_id'); | $id = $this->Application->GetVar('m_cat_id'); | ||||
} | } | ||||
else { | else { | ||||
$id = $this->Application->GetVar($related_prefix . '_id'); | $id = $this->Application->GetVar($related_prefix . '_id'); | ||||
} | } | ||||
} | } | ||||
/** @var kCatDBItem $p_item */ | |||||
$p_item = $this->Application->recallObject($related_prefix.'.current', NULL, Array('skip_autoload' => true)); | $p_item = $this->Application->recallObject($related_prefix.'.current', NULL, Array('skip_autoload' => true)); | ||||
Expected 1 space after concat operator; 0 found Lint: CodingStandard.Strings.ConcatenationSpacing.NoSpaceAfter: Expected 1 space after concat operator; 0 found | |||||
Expected 1 space before concat operator; 0 found Lint: CodingStandard.Strings.ConcatenationSpacing.NoSpaceBefore: Expected 1 space before concat operator; 0 found | |||||
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Lint: Generic.PHP.LowerCaseConstant.Found: TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" | |||||
Line exceeds 120 characters; contains 121 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 121 characters | |||||
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 $p_item kCatDBItem */ | |||||
$p_item->Load( (int)$id ); | $p_item->Load( (int)$id ); | ||||
$p_resource_id = $p_item->GetDBField('ResourceId'); | $p_resource_id = $p_item->GetDBField('ResourceId'); | ||||
$sql = 'SELECT SourceId, TargetId FROM '.$rel_table.' | $sql = 'SELECT SourceId, TargetId FROM '.$rel_table.' | ||||
WHERE | WHERE | ||||
(Enabled = 1) | (Enabled = 1) | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | |||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
* @see kDBEventHandler::OnListBuild() | * @see kDBEventHandler::OnListBuild() | ||||
*/ | */ | ||||
protected function SetCustomQuery(kEvent $event) | protected function SetCustomQuery(kEvent $event) | ||||
{ | { | ||||
parent::SetCustomQuery($event); | parent::SetCustomQuery($event); | ||||
/** @var kCatDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBList */ | |||||
// add category filter if needed | // add category filter if needed | ||||
if ($event->Special != 'showall' && $event->Special != 'user') { | if ($event->Special != 'showall' && $event->Special != 'user') { | ||||
if ( (string)$event->getEventParam('parent_cat_id') !== '' ) { | if ( (string)$event->getEventParam('parent_cat_id') !== '' ) { | ||||
$parent_cat_id = $event->getEventParam('parent_cat_id'); | $parent_cat_id = $event->getEventParam('parent_cat_id'); | ||||
} | } | ||||
else { | else { | ||||
$parent_cat_id = $this->Application->GetVar('c_id'); | $parent_cat_id = $this->Application->GetVar('c_id'); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
$this->applyViewPermissionFilter($object); | $this->applyViewPermissionFilter($object); | ||||
$types = $event->getEventParam('types'); | $types = $event->getEventParam('types'); | ||||
$this->applyItemStatusFilter($object, $types); | $this->applyItemStatusFilter($object, $types); | ||||
$except_types = $event->getEventParam('except'); | $except_types = $event->getEventParam('except'); | ||||
$type_clauses = $this->getTypeClauses($event); | $type_clauses = $this->getTypeClauses($event); | ||||
/** @var kSearchHelper $search_helper */ | |||||
$search_helper = $this->Application->recallObject('SearchHelper'); | $search_helper = $this->Application->recallObject('SearchHelper'); | ||||
/* @var $search_helper kSearchHelper */ | |||||
$search_helper->SetComplexFilter($event, $type_clauses, $types, $except_types); | $search_helper->SetComplexFilter($event, $type_clauses, $types, $except_types); | ||||
} | } | ||||
/** | /** | ||||
* Adds filter, that uses *.VIEW permissions to determine if an item should be shown to a user. | * Adds filter, that uses *.VIEW permissions to determine if an item should be shown to a user. | ||||
* | * | ||||
* @param kCatDBList $object Object. | * @param kCatDBList $object Object. | ||||
* | * | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function applyViewPermissionFilter(kCatDBList $object) | protected function applyViewPermissionFilter(kCatDBList $object) | ||||
{ | { | ||||
if ( !$this->Application->ConfigValue('CheckViewPermissionsInCatalog') ) { | if ( !$this->Application->ConfigValue('CheckViewPermissionsInCatalog') ) { | ||||
return; | return; | ||||
} | } | ||||
if ( $this->Application->RecallVar('user_id') == USER_ROOT ) { | if ( $this->Application->RecallVar('user_id') == USER_ROOT ) { | ||||
// for "root" CATEGORY.VIEW permission is checked for items lists too | // for "root" CATEGORY.VIEW permission is checked for items lists too | ||||
$view_perm = 1; | $view_perm = 1; | ||||
} | } | ||||
else { | else { | ||||
// for any real user item list view permission is checked instead of CATEGORY.VIEW | // for any real user item list view permission is checked instead of CATEGORY.VIEW | ||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
/** @var kCountHelper $count_helper */ | |||||
$count_helper = $this->Application->recallObject('CountHelper'); | $count_helper = $this->Application->recallObject('CountHelper'); | ||||
/* @var $count_helper kCountHelper */ | |||||
list ($view_perm, $view_filter) = $count_helper->GetPermissionClause($object->Prefix, 'perm'); | list ($view_perm, $view_filter) = $count_helper->GetPermissionClause($object->Prefix, 'perm'); | ||||
$object->addFilter('perm_filter2', $view_filter); | $object->addFilter('perm_filter2', $view_filter); | ||||
} | } | ||||
$object->addFilter('perm_filter', 'perm.PermId = ' . $view_perm); | $object->addFilter('perm_filter', 'perm.PermId = ' . $view_perm); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function prepareObject(&$object, kEvent $event) | protected function prepareObject(&$object, kEvent $event) | ||||
{ | { | ||||
$this->prepareItemStatuses($event); | $this->prepareItemStatuses($event); | ||||
$object->addCalculatedField('CachedNavbar', 'l' . $this->Application->GetVar('m_lang') . '_CachedNavbar'); | $object->addCalculatedField('CachedNavbar', 'l' . $this->Application->GetVar('m_lang') . '_CachedNavbar'); | ||||
if ( $event->Special == 'export' || $event->Special == 'import' ) { | if ( $event->Special == 'export' || $event->Special == 'import' ) { | ||||
/** @var kCatDBItemExportHelper $export_helper */ | |||||
$export_helper = $this->Application->recallObject('CatItemExportHelper'); | $export_helper = $this->Application->recallObject('CatItemExportHelper'); | ||||
/* @var $export_helper kCatDBItemExportHelper */ | |||||
$export_helper->prepareExportColumns($event); | $export_helper->prepareExportColumns($event); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Creates calculated fields for all item statuses based on config settings | * Creates calculated fields for all item statuses based on config settings | ||||
* | * | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemUpdate(kEvent $event) | protected function OnBeforeItemUpdate(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeItemUpdate($event); | parent::OnBeforeItemUpdate($event); | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
// update hits field | // update hits field | ||||
$property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); | $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); | ||||
if ( $property_map ) { | if ( $property_map ) { | ||||
$click_field = $property_map['ClickField']; | $click_field = $property_map['ClickField']; | ||||
if ( $this->Application->isAdminUser && ($this->Application->GetVar($click_field . '_original') !== false) && floor($this->Application->GetVar($click_field . '_original')) != $object->GetDBField($click_field) ) { | if ( $this->Application->isAdminUser && ($this->Application->GetVar($click_field . '_original') !== false) && floor($this->Application->GetVar($click_field . '_original')) != $object->GetDBField($click_field) ) { | ||||
$sql = 'SELECT MAX(' . $click_field . ') | $sql = 'SELECT MAX(' . $click_field . ') | ||||
Show All 21 Lines | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemLoad(kEvent $event) | protected function OnAfterItemLoad(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterItemLoad($event); | parent::OnAfterItemLoad($event); | ||||
$special = substr($event->Special, -6); | $special = substr($event->Special, -6); | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
if ( $special == 'import' || $special == 'export' ) { | if ( $special == 'import' || $special == 'export' ) { | ||||
$image_data = $object->getPrimaryImageData(); | $image_data = $object->getPrimaryImageData(); | ||||
if ( $image_data ) { | if ( $image_data ) { | ||||
$thumbnail_image = $image_data[$image_data['LocalThumb'] ? 'ThumbPath' : 'ThumbUrl']; | $thumbnail_image = $image_data[$image_data['LocalThumb'] ? 'ThumbPath' : 'ThumbUrl']; | ||||
if ( $image_data['SameImages'] ) { | if ( $image_data['SameImages'] ) { | ||||
$full_image = ''; | $full_image = ''; | ||||
Show All 20 Lines | |||||
$new_options[$key] = $val; | $new_options[$key] = $val; | ||||
} | } | ||||
$object->SetFieldOption('Status', 'options', $new_options); | $object->SetFieldOption('Status', 'options', $new_options); | ||||
} | } | ||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin ) { | ||||
// linking existing images for item with virtual fields | // linking existing images for item with virtual fields | ||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
/** @var ImageHelper $image_helper */ | |||||
$image_helper = $this->Application->recallObject('ImageHelper'); | $image_helper = $this->Application->recallObject('ImageHelper'); | ||||
/* @var $image_helper ImageHelper */ | |||||
$image_helper->LoadItemImages($object); | $image_helper->LoadItemImages($object); | ||||
// linking existing files for item with virtual fields | // linking existing files for item with virtual fields | ||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
/* @var $file_helper FileHelper */ | |||||
$file_helper->LoadItemFiles($object); | $file_helper->LoadItemFiles($object); | ||||
} | } | ||||
if ( $object->isVirtualField('MoreCategories') ) { | if ( $object->isVirtualField('MoreCategories') ) { | ||||
// set item's additional categories to virtual field (used in editing) | // set item's additional categories to virtual field (used in editing) | ||||
$item_categories = $this->getItemCategories($object->GetDBField('ResourceId')); | $item_categories = $this->getItemCategories($object->GetDBField('ResourceId')); | ||||
$object->SetDBField('MoreCategories', $item_categories ? '|' . implode('|', $item_categories) . '|' : ''); | $object->SetDBField('MoreCategories', $item_categories ? '|' . implode('|', $item_categories) . '|' : ''); | ||||
Show All 12 Lines | |||||
parent::OnAfterItemUpdate($event); | parent::OnAfterItemUpdate($event); | ||||
$this->CalculateHotLimit($event); | $this->CalculateHotLimit($event); | ||||
if ( substr($event->Special, -6) == 'import' ) { | if ( substr($event->Special, -6) == 'import' ) { | ||||
$this->setCustomExportColumns($event); | $this->setCustomExportColumns($event); | ||||
} | } | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin ) { | ||||
/** @var ImageHelper $image_helper */ | |||||
$image_helper = $this->Application->recallObject('ImageHelper'); | $image_helper = $this->Application->recallObject('ImageHelper'); | ||||
/* @var $image_helper ImageHelper */ | |||||
// process image upload in virtual fields | // process image upload in virtual fields | ||||
$image_helper->SaveItemImages($object); | $image_helper->SaveItemImages($object); | ||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
/* @var $file_helper FileHelper */ | |||||
// process file upload in virtual fields | // process file upload in virtual fields | ||||
$file_helper->SaveItemFiles($object); | $file_helper->SaveItemFiles($object); | ||||
if ( $event->Special != '-item' ) { | if ( $event->Special != '-item' ) { | ||||
// don't touch categories during cloning | // don't touch categories during cloning | ||||
$this->processAdditionalCategories($object, 'update'); | $this->processAdditionalCategories($object, 'update'); | ||||
} | } | ||||
Show All 26 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemCreate(kEvent $event) | protected function OnAfterItemCreate(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterItemCreate($event); | parent::OnAfterItemCreate($event); | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
if ( substr($event->Special, -6) == 'import' ) { | if ( substr($event->Special, -6) == 'import' ) { | ||||
$this->setCustomExportColumns($event); | $this->setCustomExportColumns($event); | ||||
} | } | ||||
$object->assignPrimaryCategory(); | $object->assignPrimaryCategory(); | ||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin ) { | ||||
/** @var ImageHelper $image_helper */ | |||||
$image_helper = $this->Application->recallObject('ImageHelper'); | $image_helper = $this->Application->recallObject('ImageHelper'); | ||||
/* @var $image_helper ImageHelper */ | |||||
// process image upload in virtual fields | // process image upload in virtual fields | ||||
$image_helper->SaveItemImages($object); | $image_helper->SaveItemImages($object); | ||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
/* @var $file_helper FileHelper */ | |||||
// process file upload in virtual fields | // process file upload in virtual fields | ||||
$file_helper->SaveItemFiles($object); | $file_helper->SaveItemFiles($object); | ||||
if ( $event->Special != '-item' ) { | if ( $event->Special != '-item' ) { | ||||
// don't touch categories during cloning | // don't touch categories during cloning | ||||
$this->processAdditionalCategories($object, 'create'); | $this->processAdditionalCategories($object, 'create'); | ||||
} | } | ||||
Show All 31 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnSimpleSearch($event) | function OnSimpleSearch($event) | ||||
{ | { | ||||
$event->redirect = false; | $event->redirect = false; | ||||
$keywords = $this->Application->unescapeRequestVariable(trim($this->Application->GetVar('keywords'))); | $keywords = $this->Application->unescapeRequestVariable(trim($this->Application->GetVar('keywords'))); | ||||
/** @var kHTTPQuery $query_object */ | |||||
$query_object = $this->Application->recallObject('HTTPQuery'); | $query_object = $this->Application->recallObject('HTTPQuery'); | ||||
/* @var $query_object kHTTPQuery */ | |||||
/** @var kSearchHelper $search_helper */ | /** @var kSearchHelper $search_helper */ | ||||
$search_helper = $this->Application->recallObject('SearchHelper'); | $search_helper = $this->Application->recallObject('SearchHelper'); | ||||
$search_table = $search_helper->getSearchTable(); | $search_table = $search_helper->getSearchTable(); | ||||
$sql = 'SHOW TABLES LIKE "'.$search_table.'"'; | $sql = 'SHOW TABLES LIKE "'.$search_table.'"'; | ||||
if(!isset($query_object->Get['keywords']) && | if(!isset($query_object->Get['keywords']) && | ||||
Show All 10 Lines | |||||
} | } | ||||
$this->Application->StoreVar('keywords', $keywords); | $this->Application->StoreVar('keywords', $keywords); | ||||
$this->saveToSearchLog($keywords, 0); // 0 - simple search, 1 - advanced search | $this->saveToSearchLog($keywords, 0); // 0 - simple search, 1 - advanced search | ||||
$event->setPseudoClass('_List'); | $event->setPseudoClass('_List'); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$this->Application->SetVar($event->getPrefixSpecial().'_Page', 1); | $this->Application->SetVar($event->getPrefixSpecial().'_Page', 1); | ||||
$lang = $this->Application->GetVar('m_lang'); | $lang = $this->Application->GetVar('m_lang'); | ||||
$items_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); | $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); | ||||
$module_name = $this->Application->findModule('Var', $event->Prefix, 'Name'); | $module_name = $this->Application->findModule('Var', $event->Prefix, 'Name'); | ||||
$sql = 'SELECT * | $sql = 'SELECT * | ||||
FROM ' . $this->Application->getUnitOption('confs', 'TableName') . ' | FROM ' . $this->Application->getUnitOption('confs', 'TableName') . ' | ||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Enter description here... | * Enter description here... | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @todo Change all hardcoded Products table & In-Commerce module usage to dynamic usage from item config !!! | * @todo Change all hardcoded Products table & In-Commerce module usage to dynamic usage from item config !!! | ||||
*/ | */ | ||||
function OnAdvancedSearch($event) | function OnAdvancedSearch($event) | ||||
{ | { | ||||
/** @var kHTTPQuery $query_object */ | |||||
$query_object = $this->Application->recallObject('HTTPQuery'); | $query_object = $this->Application->recallObject('HTTPQuery'); | ||||
/* @var $query_object kHTTPQuery */ | |||||
if ( !isset($query_object->Post['andor']) ) { | if ( !isset($query_object->Post['andor']) ) { | ||||
// used when navigating by pages or changing sorting in search results | // used when navigating by pages or changing sorting in search results | ||||
return; | return; | ||||
} | } | ||||
$this->Application->RemoveVar('keywords'); | $this->Application->RemoveVar('keywords'); | ||||
$this->Application->RemoveVar('Search_Keywords'); | $this->Application->RemoveVar('Search_Keywords'); | ||||
$module_name = $this->Application->findModule('Var', $event->Prefix, 'Name'); | $module_name = $this->Application->findModule('Var', $event->Prefix, 'Name'); | ||||
$sql = 'SELECT * | $sql = 'SELECT * | ||||
FROM '.$this->Application->getUnitOption('confs', 'TableName').' | FROM '.$this->Application->getUnitOption('confs', 'TableName').' | ||||
WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1)'; | WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1)'; | ||||
$search_config = $this->Conn->Query($sql); | $search_config = $this->Conn->Query($sql); | ||||
$lang = $this->Application->GetVar('m_lang'); | $lang = $this->Application->GetVar('m_lang'); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$object->SetPage(1); | $object->SetPage(1); | ||||
$items_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); | $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName'); | ||||
$search_keywords = $this->Application->GetVar('value'); // will not be changed | $search_keywords = $this->Application->GetVar('value'); // will not be changed | ||||
$keywords = $this->Application->GetVar('value'); // will be changed down there | $keywords = $this->Application->GetVar('value'); // will be changed down there | ||||
▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Line(s) | |||||
* Returns human readable representation of searched data to be placed in search log | * Returns human readable representation of searched data to be placed in search log | ||||
* @param string $type | * @param string $type | ||||
* @param Array $search_data | * @param Array $search_data | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function getHuman($type, $search_data) | protected function getHuman($type, $search_data) | ||||
{ | { | ||||
// all 3 variables are retrieved from $search_data array | // all 3 variables are retrieved from $search_data array | ||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
/* @var $search_config Array */ | /** @var Array $search_config */ | ||||
/* @var $verb string */ | /** @var string $verb */ | ||||
/* @var $value string */ | /** @var string $value */ | ||||
$type = ucfirst(strtolower($type)); | $type = ucfirst(strtolower($type)); | ||||
extract($search_data, EXTR_SKIP); | extract($search_data, EXTR_SKIP); | ||||
switch ($type) { | switch ($type) { | ||||
case 'Field': | case 'Field': | ||||
return $this->Application->Phrase($search_config['DisplayName']); | return $this->Application->Phrase($search_config['DisplayName']); | ||||
break; | break; | ||||
Show All 39 Lines | |||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
* @see kDBEventHandler::OnListBuild() | * @see kDBEventHandler::OnListBuild() | ||||
*/ | */ | ||||
protected function SetPagination(kEvent $event) | protected function SetPagination(kEvent $event) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
// get PerPage (forced -> session -> config -> 10) | // get PerPage (forced -> session -> config -> 10) | ||||
$object->SetPerPage($this->getPerPage($event)); | $object->SetPerPage($this->getPerPage($event)); | ||||
// main lists on Front-End have special get parameter for page | // main lists on Front-End have special get parameter for page | ||||
$page = $object->isMainList() ? $this->Application->GetVar('page') : false; | $page = $object->isMainList() ? $this->Application->GetVar('page') : false; | ||||
if ( !$page ) { | if ( !$page ) { | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
$selected_ids = false; | $selected_ids = false; | ||||
} | } | ||||
$selected_cats_ids = $this->Application->GetVar('export_categories'); | $selected_cats_ids = $this->Application->GetVar('export_categories'); | ||||
$this->Application->StoreVar($event->Prefix . '_export_ids', $selected_ids ? implode(',', $selected_ids) : ''); | $this->Application->StoreVar($event->Prefix . '_export_ids', $selected_ids ? implode(',', $selected_ids) : ''); | ||||
$this->Application->StoreVar($event->Prefix . '_export_cats_ids', $selected_cats_ids); | $this->Application->StoreVar($event->Prefix . '_export_cats_ids', $selected_cats_ids); | ||||
/** @var kCatDBItemExportHelper $export_helper */ | |||||
$export_helper = $this->Application->recallObject('CatItemExportHelper'); | $export_helper = $this->Application->recallObject('CatItemExportHelper'); | ||||
/* @var $export_helper kCatDBItemExportHelper */ | |||||
$redirect_params = Array ( | $redirect_params = Array ( | ||||
$this->Prefix . '.export_event' => 'OnNew', | $this->Prefix . '.export_event' => 'OnNew', | ||||
'pass' => 'all,' . $this->Prefix . '.export' | 'pass' => 'all,' . $this->Prefix . '.export' | ||||
); | ); | ||||
$event->setRedirectParams($redirect_params); | $event->setRedirectParams($redirect_params); | ||||
} | } | ||||
/** | /** | ||||
* Performs each export step & displays progress percent | * Performs each export step & displays progress percent | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnExportProgress($event) | function OnExportProgress($event) | ||||
{ | { | ||||
/** @var kCatDBItemExportHelper $export_object */ | |||||
$export_object = $this->Application->recallObject('CatItemExportHelper'); | $export_object = $this->Application->recallObject('CatItemExportHelper'); | ||||
/* @var $export_object kCatDBItemExportHelper */ | |||||
$action_method = 'perform'.ucfirst($event->Special); | $action_method = 'perform'.ucfirst($event->Special); | ||||
$field_values = $export_object->$action_method($event); | $field_values = $export_object->$action_method($event); | ||||
// finish code is done from JS now | // finish code is done from JS now | ||||
if ($field_values['start_from'] == $field_values['total_records']) { | if ($field_values['start_from'] == $field_values['total_records']) { | ||||
if ($event->Special == 'import') { | if ($event->Special == 'import') { | ||||
$this->Application->StoreVar('PermCache_UpdateRequired', 1); | $this->Application->StoreVar('PermCache_UpdateRequired', 1); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
* Create/Update primary image record in info found in imported data | * Create/Update primary image record in info found in imported data | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function restorePrimaryImage($event) | protected function restorePrimaryImage($event) | ||||
{ | { | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
if ( !$object->GetDBField('ThumbnailImage') && !$object->GetDBField('FullImage') ) { | if ( !$object->GetDBField('ThumbnailImage') && !$object->GetDBField('FullImage') ) { | ||||
return ; | return ; | ||||
} | } | ||||
$image_data = $object->getPrimaryImageData(); | $image_data = $object->getPrimaryImageData(); | ||||
/** @var kDBItem $image */ | |||||
$image = $this->Application->recallObject('img', NULL, Array ('skip_autoload' => true)); | $image = $this->Application->recallObject('img', NULL, Array ('skip_autoload' => true)); | ||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Lint: Generic.PHP.LowerCaseConstant.Found: TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" | |||||
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 $image kDBItem */ | |||||
if ( $image_data ) { | if ( $image_data ) { | ||||
$image->Load($image_data['ImageId']); | $image->Load($image_data['ImageId']); | ||||
} | } | ||||
else { | else { | ||||
$image->Clear(); | $image->Clear(); | ||||
$image->SetDBField('Name', 'main'); | $image->SetDBField('Name', 'main'); | ||||
$image->SetDBField('DefaultImg', 1); | $image->SetDBField('DefaultImg', 1); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnNew(kEvent $event) | protected function OnNew(kEvent $event) | ||||
{ | { | ||||
parent::OnNew($event); | parent::OnNew($event); | ||||
if ( $event->Special == 'import' || $event->Special == 'export' ) { | if ( $event->Special == 'import' || $event->Special == 'export' ) { | ||||
/** @var kCatDBItemExportHelper $export_helper */ | |||||
$export_helper = $this->Application->recallObject('CatItemExportHelper'); | $export_helper = $this->Application->recallObject('CatItemExportHelper'); | ||||
/* @var $export_helper kCatDBItemExportHelper */ | |||||
$export_helper->setRequiredFields($event); | $export_helper->setRequiredFields($event); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Process items selected in item_selector | * Process items selected in item_selector | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnProcessSelected($event) | function OnProcessSelected($event) | ||||
{ | { | ||||
$dst_field = $this->Application->RecallVar('dst_field'); | $dst_field = $this->Application->RecallVar('dst_field'); | ||||
$selected_ids = $this->Application->GetVar('selected_ids'); | $selected_ids = $this->Application->GetVar('selected_ids'); | ||||
if ( $dst_field == 'ItemCategory' ) { | if ( $dst_field == 'ItemCategory' ) { | ||||
// Item Edit -> Categories Tab -> New Categories | // Item Edit -> Categories Tab -> New Categories | ||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
$category_ids = explode(',', $selected_ids['c']); | $category_ids = explode(',', $selected_ids['c']); | ||||
foreach ($category_ids as $category_id) { | foreach ($category_ids as $category_id) { | ||||
$object->assignToCategory($category_id); | $object->assignToCategory($category_id); | ||||
} | } | ||||
} | } | ||||
if ($dst_field == 'ImportCategory') { | if ($dst_field == 'ImportCategory') { | ||||
Show All 15 Lines | |||||
function OnSaveSettings($event) | function OnSaveSettings($event) | ||||
{ | { | ||||
$event->redirect = false; | $event->redirect = false; | ||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ( $items_info ) { | if ( $items_info ) { | ||||
list($id, $field_values) = each($items_info); | list($id, $field_values) = each($items_info); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(Array ('skip_autoload' => true)); | ||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
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 $object kDBItem */ | |||||
$object->setID($id); | $object->setID($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! | $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! | ||||
$field_values['ImportSource'] = 2; | $field_values['ImportSource'] = 2; | ||||
$field_values['ImportLocalFilename'] = $object->GetDBField('ImportFilename'); | $field_values['ImportLocalFilename'] = $object->GetDBField('ImportFilename'); | ||||
Show All 31 Lines | |||||
* Stores item's owner login into separate field together with id | * Stores item's owner login into separate field together with id | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @param string $id_field | * @param string $id_field | ||||
* @param string $cached_field | * @param string $cached_field | ||||
*/ | */ | ||||
function cacheItemOwner($event, $id_field, $cached_field) | function cacheItemOwner($event, $id_field, $cached_field) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$object->SetDBField($cached_field, $object->GetField($id_field)); | $object->SetDBField($cached_field, $object->GetField($id_field)); | ||||
} | } | ||||
/** | /** | ||||
* Saves edited item into temp table | * Saves edited item into temp table | ||||
* If there is no id, new item is created in temp table | * If there is no id, new item is created in temp table | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnPreSave(kEvent $event) | protected function OnPreSave(kEvent $event) | ||||
{ | { | ||||
parent::OnPreSave($event); | parent::OnPreSave($event); | ||||
$use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | ||||
if ( $event->status == kEvent::erSUCCESS && $use_pending_editing ) { | if ( $event->status == kEvent::erSUCCESS && $use_pending_editing ) { | ||||
// decision: clone or not clone | // decision: clone or not clone | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
if ( $object->GetID() == 0 || $object->GetDBField('OrgId') > 0 ) { | if ( $object->GetID() == 0 || $object->GetDBField('OrgId') > 0 ) { | ||||
// new items or cloned items shouldn't be cloned again | // new items or cloned items shouldn't be cloned again | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$owner_field = $this->getOwnerField($event->Prefix); | $owner_field = $this->getOwnerField($event->Prefix); | ||||
if ( $perm_helper->ModifyCheckPermission($object->GetDBField($owner_field), $object->GetDBField('CategoryId'), $event->Prefix) == 2 ) { | if ( $perm_helper->ModifyCheckPermission($object->GetDBField($owner_field), $object->GetDBField('CategoryId'), $event->Prefix) == 2 ) { | ||||
// 1. clone original item | // 1. clone original item | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | ||||
Line exceeds 120 characters; contains 132 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 132 characters | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$cloned_ids = $temp_handler->CloneItems($event->Prefix, $event->Special, Array ($object->GetID()), NULL, NULL, NULL, true); | $cloned_ids = $temp_handler->CloneItems($event->Prefix, $event->Special, Array ($object->GetID()), NULL, NULL, NULL, true); | ||||
$ci_table = $this->Application->GetTempName(TABLE_PREFIX . 'CategoryItems'); | $ci_table = $this->Application->GetTempName(TABLE_PREFIX . 'CategoryItems'); | ||||
// 2. delete record from CategoryItems (about cloned item) that was automatically created during call of Create method of kCatDBItem | // 2. delete record from CategoryItems (about cloned item) that was automatically created during call of Create method of kCatDBItem | ||||
$sql = 'SELECT ResourceId | $sql = 'SELECT ResourceId | ||||
FROM ' . $object->TableName . ' | FROM ' . $object->TableName . ' | ||||
WHERE ' . $object->IDField . ' = ' . $cloned_ids[0]; | WHERE ' . $object->IDField . ' = ' . $cloned_ids[0]; | ||||
Show All 39 Lines | |||||
protected function OnPreCreate(kEvent $event) | protected function OnPreCreate(kEvent $event) | ||||
{ | { | ||||
parent::OnPreCreate($event); | parent::OnPreCreate($event); | ||||
if ( $event->status != kEvent::erSUCCESS ) { | if ( $event->status != kEvent::erSUCCESS ) { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$owner_field = $this->getOwnerField($event->Prefix); | $owner_field = $this->getOwnerField($event->Prefix); | ||||
$object->SetDBField($owner_field, $this->Application->RecallVar('user_id')); | $object->SetDBField($owner_field, $this->Application->RecallVar('user_id')); | ||||
} | } | ||||
/** | /** | ||||
* Occurs before original item of item in pending editing got deleted (for hooking only) | * Occurs before original item of item in pending editing got deleted (for hooking only) | ||||
* | * | ||||
Show All 25 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeClone(kEvent $event) | protected function OnBeforeClone(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeClone($event); | parent::OnBeforeClone($event); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$object->SetDBField('ResourceId', 0); // this will reset it | $object->SetDBField('ResourceId', 0); // this will reset it | ||||
if ( $this->Application->GetVar('ResetCatBeforeClone') ) { | if ( $this->Application->GetVar('ResetCatBeforeClone') ) { | ||||
$object->SetDBField('CategoryId', NULL); | $object->SetDBField('CategoryId', NULL); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Set status for new category item based on user permission in category | * Set status for new category item based on user permission in category | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemCreate(kEvent $event) | protected function OnBeforeItemCreate(kEvent $event) | ||||
{ | { | ||||
parent::OnBeforeItemCreate($event); | parent::OnBeforeItemCreate($event); | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
$owner_field = $this->getOwnerField($event->Prefix); | $owner_field = $this->getOwnerField($event->Prefix); | ||||
// Don't allow creating records on behalf of another user. | // Don't allow creating records on behalf of another user. | ||||
if ( !$this->Application->isAdminUser && !defined('CRON') ) { | if ( !$this->Application->isAdminUser && !defined('CRON') ) { | ||||
$object->SetDBField($owner_field, $object->GetOriginalField($owner_field)); | $object->SetDBField($owner_field, $object->GetOriginalField($owner_field)); | ||||
} | } | ||||
Show All 15 Lines | |||||
function setItemStatusByPermission($event) | function setItemStatusByPermission($event) | ||||
{ | { | ||||
$use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | ||||
if (!$use_pending_editing) { | if (!$use_pending_editing) { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$primary_category = $object->GetDBField('CategoryId') > 0 ? $object->GetDBField('CategoryId') : $this->Application->GetVar('m_cat_id'); | $primary_category = $object->GetDBField('CategoryId') > 0 ? $object->GetDBField('CategoryId') : $this->Application->GetVar('m_cat_id'); | ||||
$item_status = $perm_helper->AddCheckPermission($primary_category, $event->Prefix); | $item_status = $perm_helper->AddCheckPermission($primary_category, $event->Prefix); | ||||
if ($item_status == STATUS_DISABLED) { | if ($item_status == STATUS_DISABLED) { | ||||
$event->status = kEvent::erFAIL; | $event->status = kEvent::erFAIL; | ||||
} | } | ||||
else { | else { | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
$use_pending = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | $use_pending = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing'); | ||||
if ($this->Application->isAdminUser || !$use_pending) { | if ($this->Application->isAdminUser || !$use_pending) { | ||||
parent::OnUpdate($event); | parent::OnUpdate($event); | ||||
$this->SetFrontRedirectTemplate($event, 'modify'); | $this->SetFrontRedirectTemplate($event, 'modify'); | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(Array('skip_autoload' => true)); | $object = $event->getObject(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 $object kCatDBItem */ | |||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ($items_info) { | if ($items_info) { | ||||
Expected 1 spaces after "if" opening bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace: Expected 1 spaces after "if" opening bracket; 0 found | |||||
Expected 1 spaces before "if" closing bracket; 0 found Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace: Expected 1 spaces before "if" closing bracket; 0 found | |||||
No blank line found before "if" control structure Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.NoLineBeforeOpen: No blank line found before "if" control structure | |||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); | ||||
Expected 1 space before concat operator; 0 found Lint: CodingStandard.Strings.ConcatenationSpacing.NoSpaceBefore: Expected 1 space before concat operator; 0 found | |||||
Expected 1 space after concat operator; 0 found Lint: CodingStandard.Strings.ConcatenationSpacing.NoSpaceAfter: Expected 1 space after concat operator; 0 found | |||||
Line exceeds 120 characters; contains 126 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 126 characters | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$owner_field = $this->getOwnerField($event->Prefix); | $owner_field = $this->getOwnerField($event->Prefix); | ||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
/* @var $file_helper FileHelper */ | |||||
foreach ($items_info as $id => $field_values) { | foreach ($items_info as $id => $field_values) { | ||||
$object->Load($id); | $object->Load($id); | ||||
$edit_perm = $perm_helper->ModifyCheckPermission($object->GetDBField($owner_field), $object->GetDBField('CategoryId'), $event->Prefix); | $edit_perm = $perm_helper->ModifyCheckPermission($object->GetDBField($owner_field), $object->GetDBField('CategoryId'), $event->Prefix); | ||||
if ($use_pending && !$object->GetDBField('OrgId') && ($edit_perm == STATUS_PENDING)) { | if ($use_pending && !$object->GetDBField('OrgId') && ($edit_perm == STATUS_PENDING)) { | ||||
// pending editing enabled + not pending copy -> get/create pending copy & save changes to it | // pending editing enabled + not pending copy -> get/create pending copy & save changes to it | ||||
$original_id = $object->GetID(); | $original_id = $object->GetID(); | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
* @param string $template_key - {suggest,modify} | * @param string $template_key - {suggest,modify} | ||||
*/ | */ | ||||
function SetFrontRedirectTemplate($event, $template_key) | function SetFrontRedirectTemplate($event, $template_key) | ||||
{ | { | ||||
if ( $this->Application->isAdmin || $event->status != kEvent::erSUCCESS ) { | if ( $this->Application->isAdmin || $event->status != kEvent::erSUCCESS ) { | ||||
return; | return; | ||||
} | } | ||||
// prepare redirect template | // prepare redirect template | ||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$is_active = ($object->GetDBField('Status') == STATUS_ACTIVE); | $is_active = ($object->GetDBField('Status') == STATUS_ACTIVE); | ||||
$next_template = $is_active ? 'confirm_template' : 'pending_confirm_template'; | $next_template = $is_active ? 'confirm_template' : 'pending_confirm_template'; | ||||
$event->redirect = $this->Application->GetVar($template_key . '_' . $next_template); | $event->redirect = $this->Application->GetVar($template_key . '_' . $next_template); | ||||
$event->SetRedirectParam('opener', 's'); | $event->SetRedirectParam('opener', 's'); | ||||
// send email events | // send email events | ||||
Show All 30 Lines | |||||
parent::iterateItems($event); | parent::iterateItems($event); | ||||
} | } | ||||
if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { | if ( $this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { | ||||
$event->status = kEvent::erFAIL; | $event->status = kEvent::erFAIL; | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(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" | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
/* @var $object kCatDBItem */ | |||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
foreach ($ids as $id) { | foreach ($ids as $id) { | ||||
$object->Load($id); | $object->Load($id); | ||||
switch ( $event->Name ) { | switch ( $event->Name ) { | ||||
Show All 32 Lines | |||||
* Checks, that currently loaded item is allowed for viewing (non permission-based) | * Checks, that currently loaded item is allowed for viewing (non permission-based) | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return bool | * @return bool | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function checkItemStatus(kEvent $event) | protected function checkItemStatus(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
if ( !$object->isLoaded() ) { | if ( !$object->isLoaded() ) { | ||||
if ( $event->Special != 'previous' && $event->Special != 'next' ) { | if ( $event->Special != 'previous' && $event->Special != 'next' ) { | ||||
$this->_errorNotFound($event); | $this->_errorNotFound($event); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
Show All 24 Lines | |||||
} | } | ||||
$types = $event->getEventParam('types'); | $types = $event->getEventParam('types'); | ||||
$types = $types ? explode(',', $types) : Array (); | $types = $types ? explode(',', $types) : Array (); | ||||
if ( in_array('search', $types) ) { | if ( in_array('search', $types) ) { | ||||
$event->setPseudoClass('_List'); | $event->setPseudoClass('_List'); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
// 1. no user sorting - sort by relevance | // 1. no user sorting - sort by relevance | ||||
$default_sortings = parent::_getDefaultSorting($event); | $default_sortings = parent::_getDefaultSorting($event); | ||||
$default_sorting = key($default_sortings['Sorting']) . ',' . current($default_sortings['Sorting']); | $default_sorting = key($default_sortings['Sorting']) . ',' . current($default_sortings['Sorting']); | ||||
if ( $object->isMainList() ) { | if ( $object->isMainList() ) { | ||||
$sort_by = $this->Application->GetVar('sort_by', ''); | $sort_by = $this->Application->GetVar('sort_by', ''); | ||||
Show All 18 Lines | |||||
/** | /** | ||||
* Removes forced sortings | * Removes forced sortings | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
protected function _removeForcedSortings(kEvent $event) | protected function _removeForcedSortings(kEvent $event) | ||||
{ | { | ||||
/** @var Array $list_sortings */ | |||||
$list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ()); | $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ()); | ||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
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 $list_sortings Array */ | |||||
foreach ($list_sortings as $special => $sortings) { | foreach ($list_sortings as $special => $sortings) { | ||||
unset($list_sortings[$special]['ForcedSorting']); | unset($list_sortings[$special]['ForcedSorting']); | ||||
} | } | ||||
$this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings); | $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
if (defined('IS_INSTALL') && IS_INSTALL) { | if (defined('IS_INSTALL') && IS_INSTALL) { | ||||
$this->addViewPermissionJoin($event); | $this->addViewPermissionJoin($event); | ||||
return ; | return ; | ||||
} | } | ||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin ) { | ||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
/* @var $file_helper FileHelper */ | |||||
$file_helper->createItemFiles($event->Prefix, true); // create image fields | $file_helper->createItemFiles($event->Prefix, true); // create image fields | ||||
$file_helper->createItemFiles($event->Prefix, false); // create file fields | $file_helper->createItemFiles($event->Prefix, false); // create file fields | ||||
} | } | ||||
$this->changeSortings($event)->addViewPermissionJoin($event); | $this->changeSortings($event)->addViewPermissionJoin($event); | ||||
// add grids for advanced view (with primary category column) | // add grids for advanced view (with primary category column) | ||||
$grids = $this->Application->getUnitOption($this->Prefix, 'Grids'); | $grids = $this->Application->getUnitOption($this->Prefix, 'Grids'); | ||||
$process_grids = Array ('Default', 'Radio'); | $process_grids = Array ('Default', 'Radio'); | ||||
foreach ($process_grids as $process_grid) { | foreach ($process_grids as $process_grid) { | ||||
$grid_data = $grids[$process_grid]; | $grid_data = $grids[$process_grid]; | ||||
$grid_data['Fields']['CachedNavbar'] = Array ('title' => 'la_col_Path', 'data_block' => 'grid_primary_category_td', 'filter_block' => 'grid_like_filter'); | $grid_data['Fields']['CachedNavbar'] = Array ('title' => 'la_col_Path', 'data_block' => 'grid_primary_category_td', 'filter_block' => 'grid_like_filter'); | ||||
$grids[$process_grid . 'ShowAll'] = $grid_data; | $grids[$process_grid . 'ShowAll'] = $grid_data; | ||||
} | } | ||||
$this->Application->setUnitOption($this->Prefix, 'Grids', $grids); | $this->Application->setUnitOption($this->Prefix, 'Grids', $grids); | ||||
// add options for CategoryId field (quick way to select item's primary category) | // add options for CategoryId field (quick way to select item's primary category) | ||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
Inline comments must end in full-stops, exclamation marks, or question marks Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
/** @var CategoryHelper $category_helper */ | |||||
$category_helper = $this->Application->recallObject('CategoryHelper'); | $category_helper = $this->Application->recallObject('CategoryHelper'); | ||||
/* @var $category_helper CategoryHelper */ | |||||
$virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); | $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); | ||||
$virtual_fields['CategoryId']['default'] = (int)$this->Application->GetVar('m_cat_id'); | $virtual_fields['CategoryId']['default'] = (int)$this->Application->GetVar('m_cat_id'); | ||||
$virtual_fields['CategoryId']['options'] = $category_helper->getStructureTreeAsOptions(); | $virtual_fields['CategoryId']['options'] = $category_helper->getStructureTreeAsOptions(); | ||||
$this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); | $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); | ||||
} | } | ||||
Show All 22 Lines | |||||
// remove all forced sortings in Admin Console | // remove all forced sortings in Admin Console | ||||
$remove_sortings = array_merge($remove_sortings, Array ('Priority', 'EditorsPick')); | $remove_sortings = array_merge($remove_sortings, Array ('Priority', 'EditorsPick')); | ||||
} | } | ||||
if ( !$remove_sortings ) { | if ( !$remove_sortings ) { | ||||
return $this; | return $this; | ||||
} | } | ||||
/** @var Array $list_sortings */ | |||||
$list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ()); | $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ()); | ||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
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 $list_sortings Array */ | |||||
foreach ($list_sortings as $special => $sorting_fields) { | foreach ($list_sortings as $special => $sorting_fields) { | ||||
foreach ($remove_sortings as $sorting_field) { | foreach ($remove_sortings as $sorting_field) { | ||||
unset($list_sortings[$special]['ForcedSorting'][$sorting_field]); | unset($list_sortings[$special]['ForcedSorting'][$sorting_field]); | ||||
} | } | ||||
} | } | ||||
$this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings); | $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings); | ||||
Show All 13 Lines | |||||
{ | { | ||||
if ( $this->Application->ConfigValue('CheckViewPermissionsInCatalog') ) { | if ( $this->Application->ConfigValue('CheckViewPermissionsInCatalog') ) { | ||||
$join_clause = 'LEFT JOIN ' . TABLE_PREFIX . 'CategoryPermissionsCache perm ON perm.CategoryId = ' . TABLE_PREFIX . '%3$sCategoryItems.CategoryId'; | $join_clause = 'LEFT JOIN ' . TABLE_PREFIX . 'CategoryPermissionsCache perm ON perm.CategoryId = ' . TABLE_PREFIX . '%3$sCategoryItems.CategoryId'; | ||||
} | } | ||||
else { | else { | ||||
$join_clause = ''; | $join_clause = ''; | ||||
} | } | ||||
/** @var array $list_sqls */ | |||||
$list_sqls = $this->Application->getUnitOption($event->Prefix, 'ListSQLs'); | $list_sqls = $this->Application->getUnitOption($event->Prefix, 'ListSQLs'); | ||||
/* @var $list_sqls array */ | |||||
foreach ($list_sqls as $special => $list_sql) { | foreach ($list_sqls as $special => $list_sql) { | ||||
$list_sqls[$special] = str_replace('{PERM_JOIN}', $join_clause, $list_sql); | $list_sqls[$special] = str_replace('{PERM_JOIN}', $join_clause, $list_sql); | ||||
} | } | ||||
$this->Application->setUnitOption($event->Prefix, 'ListSQLs', $list_sqls); | $this->Application->setUnitOption($event->Prefix, 'ListSQLs', $list_sqls); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Returns file contents associated with item | * Returns file contents associated with item | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnDownloadFile($event) | function OnDownloadFile($event) | ||||
{ | { | ||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kCatDBItem */ | |||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
$field = $this->Application->GetVar('field'); | $field = $this->Application->GetVar('field'); | ||||
if (!preg_match('/^File([\d]+)/', $field)) { | if (!preg_match('/^File([\d]+)/', $field)) { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
/* @var $file_helper FileHelper */ | |||||
$filename = $object->GetField($field, 'full_path'); | $filename = $object->GetField($field, 'full_path'); | ||||
$file_helper->DownloadFile($filename); | $file_helper->DownloadFile($filename); | ||||
} | } | ||||
/** | /** | ||||
* Saves user's vote | * Saves user's vote | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnMakeVote($event) | function OnMakeVote($event) | ||||
{ | { | ||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
if ($this->Application->GetVar('ajax') != 'yes') { | if ($this->Application->GetVar('ajax') != 'yes') { | ||||
// this is supposed to call from AJAX only | // this is supposed to call from AJAX only | ||||
return ; | return ; | ||||
} | } | ||||
/** @var RatingHelper $rating_helper */ | |||||
$rating_helper = $this->Application->recallObject('RatingHelper'); | $rating_helper = $this->Application->recallObject('RatingHelper'); | ||||
/* @var $rating_helper RatingHelper */ | |||||
/** @var kCatDBItem $object */ | |||||
$object = $event->getObject( Array ('skip_autoload' => true) ); | $object = $event->getObject( Array ('skip_autoload' => true) ); | ||||
Space after opening parenthesis of function call prohibited Lint: PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Space after opening parenthesis of function call prohibited Lint: CodingStandard.Functions.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Expected 0 spaces before closing bracket; 1 found Lint: CodingStandard.Functions.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
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" | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
/* @var $object kCatDBItem */ | |||||
$object->Load( $this->Application->GetVar('id') ); | $object->Load( $this->Application->GetVar('id') ); | ||||
echo $rating_helper->makeVote($object); | echo $rating_helper->makeVote($object); | ||||
} | } | ||||
/** | /** | ||||
* Marks review as useful | * Marks review as useful | ||||
Show All 9 Lines | |||||
} | } | ||||
$review_id = (int)$this->Application->GetVar('review_id'); | $review_id = (int)$this->Application->GetVar('review_id'); | ||||
if ( !$review_id ) { | if ( !$review_id ) { | ||||
return; | return; | ||||
} | } | ||||
/** @var SpamHelper $spam_helper */ | |||||
$spam_helper = $this->Application->recallObject('SpamHelper'); | $spam_helper = $this->Application->recallObject('SpamHelper'); | ||||
/* @var $spam_helper SpamHelper */ | |||||
$spam_helper->InitHelper($review_id, 'ReviewHelpful', strtotime('+1 month') - strtotime('now')); | $spam_helper->InitHelper($review_id, 'ReviewHelpful', strtotime('+1 month') - strtotime('now')); | ||||
$field = (int)$this->Application->GetVar('helpful') ? 'HelpfulCount' : 'NotHelpfulCount'; | $field = (int)$this->Application->GetVar('helpful') ? 'HelpfulCount' : 'NotHelpfulCount'; | ||||
$sql = 'SELECT ' . $field . ' | $sql = 'SELECT ' . $field . ' | ||||
FROM ' . $this->Application->getUnitOption('rev', 'TableName') . ' | FROM ' . $this->Application->getUnitOption('rev', 'TableName') . ' | ||||
WHERE ' . $this->Application->getUnitOption('rev', 'IDField') . ' = ' . $review_id; | WHERE ' . $this->Application->getUnitOption('rev', 'IDField') . ' = ' . $review_id; | ||||
$count = $this->Conn->GetOne($sql); | $count = $this->Conn->GetOne($sql); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
* Set's new unique resource id to user | * Set's new unique resource id to user | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemValidate(kEvent $event) | protected function OnAfterItemValidate(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$resource_id = $object->GetDBField('ResourceId'); | $resource_id = $object->GetDBField('ResourceId'); | ||||
if ( !$resource_id ) { | if ( !$resource_id ) { | ||||
$object->SetDBField('ResourceId', $this->Application->NextResourceId()); | $object->SetDBField('ResourceId', $this->Application->NextResourceId()); | ||||
} | } | ||||
} | } | ||||
} | } |
Line exceeds maximum limit of 140 characters; contains 142 characters