Changeset View
Changeset View
Standalone View
Standalone View
core/units/categories/categories_event_handler.php
Show First 20 Lines • Show All 559 Lines • ▼ Show 20 Line(s) | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function applyViewPermissionFilter(kDBList $object) | protected function applyViewPermissionFilter(kDBList $object) | ||||
{ | { | ||||
if ( !$this->Application->ConfigValue('CheckViewPermissionsInCatalog') ) { | if ( !$this->Application->ConfigValue('CheckViewPermissionsInCatalog') ) { | ||||
return; | return; | ||||
} | } | ||||
if ( $this->Application->RecallVar('user_id') == USER_ROOT ) { | if ( $this->Application->permissionCheckingDisabled() ) { | ||||
// 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 { | ||||
$count_helper = $this->Application->recallObject('CountHelper'); | $count_helper = $this->Application->recallObject('CountHelper'); | ||||
/* @var $count_helper kCountHelper */ | /* @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); | ||||
▲ Show 20 Lines • Show All 972 Lines • ▼ Show 20 Line(s) | |||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
* @see kDBEventHandler::OnListBuild() | * @see kDBEventHandler::OnListBuild() | ||||
*/ | */ | ||||
protected function SetPagination(kEvent $event) | protected function SetPagination(kEvent $event) | ||||
{ | { | ||||
parent::SetPagination($event); | parent::SetPagination($event); | ||||
if ( !$this->Application->isAdmin ) { | if ( !$this->Application->isAdmin && $this->Application->isWebRequest() ) { | ||||
$page_var = $event->getEventParam('page_var'); | $page_var = $event->getEventParam('page_var'); | ||||
if ( $page_var !== false ) { | if ( $page_var !== false ) { | ||||
$page = $this->Application->GetVar($page_var); | $page = $this->Application->GetVar($page_var); | ||||
if ( is_numeric($page) ) { | if ( is_numeric($page) ) { | ||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | /* @var $object kDBList */ | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | |||||
if ( !$sort_by ) { | if ( !$sort_by ) { | ||||
$this->Application->SetVar('sort_by', 'Relevance,desc|' . $default_sorting); | $this->Application->SetVar('sort_by', 'Relevance,desc|' . $default_sorting); | ||||
} | } | ||||
elseif ( strpos($sort_by, 'Relevance,') !== false ) { | elseif ( strpos($sort_by, 'Relevance,') !== false ) { | ||||
$this->Application->SetVar('sort_by', $sort_by . '|' . $default_sorting); | $this->Application->SetVar('sort_by', $sort_by . '|' . $default_sorting); | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
if ( $this->Application->isWebRequest() ) { | |||||
$sorting_settings = $this->getListSetting($event, 'Sortings'); | $sorting_settings = $this->getListSetting($event, 'Sortings'); | ||||
$sort_by = trim(getArrayValue($sorting_settings, 'Sort1') . ',' . getArrayValue($sorting_settings, 'Sort1_Dir'), ','); | $sort_by = trim(getArrayValue($sorting_settings, 'Sort1') . ',' . getArrayValue($sorting_settings, 'Sort1_Dir'), ','); | ||||
Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 142 characters | |||||
} | |||||
else { | |||||
$sort_by = ''; | |||||
} | |||||
if ( !$sort_by ) { | if ( !$sort_by ) { | ||||
$event->setEventParam('sort_by', 'Relevance,desc|' . $default_sorting); | $event->setEventParam('sort_by', 'Relevance,desc|' . $default_sorting); | ||||
} | } | ||||
elseif ( strpos($sort_by, 'Relevance,') !== false ) { | elseif ( strpos($sort_by, 'Relevance,') !== false ) { | ||||
$event->setEventParam('sort_by', $sort_by . '|' . $default_sorting); | $event->setEventParam('sort_by', $sort_by . '|' . $default_sorting); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 508 Lines • ▼ Show 20 Line(s) | |||||
); | ); | ||||
if ( $this->Application->ConfigValue('Catalog_PreselectModuleTab') ) { | if ( $this->Application->ConfigValue('Catalog_PreselectModuleTab') ) { | ||||
$section_adjustments['in-portal:browse']['url']['anchor'] = 'tab-c'; | $section_adjustments['in-portal:browse']['url']['anchor'] = 'tab-c'; | ||||
} | } | ||||
$config->addSectionAdjustments($section_adjustments); | $config->addSectionAdjustments($section_adjustments); | ||||
// prepare structure dropdown | if ( $this->Application->isWebRequest() ) { | ||||
$category_helper = $this->Application->recallObject('CategoryHelper'); | $category_helper = $this->Application->recallObject('CategoryHelper'); | ||||
/* @var $category_helper CategoryHelper */ | /* @var $category_helper CategoryHelper */ | ||||
Type comment must be in "/** @var ClassName $variable_name */" format Lint: CodingStandard.Commenting.TypeComment.WrongStyle: Type comment must be in "/** @var ClassName $variable_name */" format | |||||
$fields = $config->getFields(); | $fields = $config->getFields(); | ||||
// Prepare structure dropdown. | |||||
$fields['ParentId']['default'] = (int)$this->Application->GetVar('m_cat_id'); | $fields['ParentId']['default'] = (int)$this->Application->GetVar('m_cat_id'); | ||||
$fields['ParentId']['options'] = $category_helper->getStructureTreeAsOptions(); | $fields['ParentId']['options'] = $category_helper->getStructureTreeAsOptions(); | ||||
// limit design list by theme | // Limit design list by theme. | ||||
$theme_id = $this->_getCurrentThemeId(); | $theme_id = $this->_getCurrentThemeId(); | ||||
$design_sql = $fields['Template']['options_sql']; | $design_sql = $fields['Template']['options_sql']; | ||||
$design_sql = str_replace('(tf.FilePath = "/designs")', '(' . implode(' OR ', $this->getDesignFolders()) . ')' . ' AND (t.ThemeId = ' . $theme_id . ')', $design_sql); | $design_sql = str_replace( | ||||
'(tf.FilePath = "/designs")', | |||||
'(' . implode(' OR ', $this->getDesignFolders()) . ') AND (t.ThemeId = ' . $theme_id . ')', | |||||
$design_sql | |||||
); | |||||
$fields['Template']['options_sql'] = $design_sql; | $fields['Template']['options_sql'] = $design_sql; | ||||
// adds "Inherit From Parent" option to "Template" field | // Adds "Inherit From Parent" option to "Template" field. | ||||
$fields['Template']['options'] = Array (CATEGORY_TEMPLATE_INHERIT => $this->Application->Phrase('la_opt_InheritFromParent')); | $fields['Template']['options'] = array( | ||||
CATEGORY_TEMPLATE_INHERIT => $this->Application->Phrase('la_opt_InheritFromParent'), | |||||
); | |||||
$config->setFields($fields); | $config->setFields($fields); | ||||
} | |||||
if ($this->Application->isAdmin) { | if ($this->Application->isAdmin) { | ||||
// don't sort by Front-End sorting fields | // don't sort by Front-End sorting fields | ||||
$config_mapping = $config->getConfigMapping(); | $config_mapping = $config->getConfigMapping(); | ||||
$remove_keys = Array ('DefaultSorting1Field', 'DefaultSorting2Field', 'DefaultSorting1Dir', 'DefaultSorting2Dir'); | $remove_keys = Array ('DefaultSorting1Field', 'DefaultSorting2Field', 'DefaultSorting1Dir', 'DefaultSorting2Dir'); | ||||
foreach ($remove_keys as $remove_key) { | foreach ($remove_keys as $remove_key) { | ||||
unset($config_mapping[$remove_key]); | unset($config_mapping[$remove_key]); | ||||
▲ Show 20 Lines • Show All 669 Lines • Show Last 20 Lines |
Line exceeds maximum limit of 140 characters; contains 142 characters