Changeset View
Standalone View
core/kernel/db/db_event_handler.php
Show First 20 Lines • Show All 207 Lines • ▼ Show 20 Line(s) | |||||
*/ | */ | ||||
public function getPassedID(kEvent $event) | public function getPassedID(kEvent $event) | ||||
{ | { | ||||
if ( $event->getEventParam('raise_warnings') === false ) { | if ( $event->getEventParam('raise_warnings') === false ) { | ||||
$event->setEventParam('raise_warnings', 1); | $event->setEventParam('raise_warnings', 1); | ||||
} | } | ||||
if ( $event->Special == 'previous' || $event->Special == 'next' ) { | if ( $event->Special == 'previous' || $event->Special == 'next' ) { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->Application->recallObject($event->getEventParam('item')); | $object = $this->Application->recallObject($event->getEventParam('item')); | ||||
/* @var $object kDBItem */ | |||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', NULL); | $select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', NULL); | ||||
return $list_helper->getNavigationResource($object, $event->getEventParam('list'), $event->Special == 'next', $select_clause); | return $list_helper->getNavigationResource($object, $event->getEventParam('list'), $event->Special == 'next', $select_clause); | ||||
} | } | ||||
elseif ( $event->Special == 'filter' ) { | elseif ( $event->Special == 'filter' ) { | ||||
// temporary object, used to print filter options only | // temporary object, used to print filter options only | ||||
return 0; | return 0; | ||||
} | } | ||||
if ( preg_match('/^auto-(.*)/', $event->Special, $regs) && $this->Application->prefixRegistred($regs[1]) ) { | if ( preg_match('/^auto-(.*)/', $event->Special, $regs) && $this->Application->prefixRegistred($regs[1]) ) { | ||||
// <inp2:lang.auto-phrase_Field name="DateFormat"/> - returns field DateFormat value from language (LanguageId is extracted from current phrase object) | // <inp2:lang.auto-phrase_Field name="DateFormat"/> - returns field DateFormat value from language (LanguageId is extracted from current phrase object) | ||||
Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 167 characters | |||||
/** @var kDBItem $main_object */ | |||||
$main_object = $this->Application->recallObject($regs[1]); | $main_object = $this->Application->recallObject($regs[1]); | ||||
/* @var $main_object kDBItem */ | |||||
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); | $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); | ||||
return $main_object->GetDBField($id_field); | return $main_object->GetDBField($id_field); | ||||
} | } | ||||
// 1. get id from post (used in admin) | // 1. get id from post (used in admin) | ||||
$ret = $this->Application->GetVar($event->getPrefixSpecial(true) . '_id'); | $ret = $this->Application->GetVar($event->getPrefixSpecial(true) . '_id'); | ||||
if ( ($ret !== false) && ($ret != '') ) { | if ( ($ret !== false) && ($ret != '') ) { | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | |||||
$status_fields = $this->Application->getUnitOption($event->Prefix, 'StatusField'); | $status_fields = $this->Application->getUnitOption($event->Prefix, 'StatusField'); | ||||
if ( !$status_fields ) { | if ( !$status_fields ) { | ||||
return true; | return true; | ||||
} | } | ||||
$status_field = array_shift($status_fields); | $status_field = array_shift($status_fields); | ||||
if ( $status_field == 'Status' || $status_field == 'Enabled' ) { | if ( $status_field == 'Status' || $status_field == 'Enabled' ) { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
if ( !$object->isLoaded() ) { | if ( !$object->isLoaded() ) { | ||||
return true; | return true; | ||||
} | } | ||||
return $object->GetDBField($status_field) == STATUS_ACTIVE; | return $object->GetDBField($status_field) == STATUS_ACTIVE; | ||||
} | } | ||||
Show All 28 Lines | |||||
* | * | ||||
* Pattern: Prototype Manager | * Pattern: Prototype Manager | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnItemBuild(kEvent $event) | protected function OnItemBuild(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$this->dbBuild($object, $event); | $this->dbBuild($object, $event); | ||||
$sql = $this->ItemPrepareQuery($event); | $sql = $this->ItemPrepareQuery($event); | ||||
$sql = $this->Application->ReplaceLanguageTags($sql); | $sql = $this->Application->ReplaceLanguageTags($sql); | ||||
$object->setSelectSQL($sql); | $object->setSelectSQL($sql); | ||||
// 2. loads if allowed | // 2. loads if allowed | ||||
Show All 27 Lines | |||||
} | } | ||||
if ( !$perm_status ) { | if ( !$perm_status ) { | ||||
// when no permission to view item -> redirect to no permission template | // when no permission to view item -> redirect to no permission template | ||||
$this->_processItemLoadingError($event, $status_checked); | $this->_processItemLoadingError($event, $status_checked); | ||||
} | } | ||||
} | } | ||||
/** @var Params $actions */ | |||||
$actions = $this->Application->recallObject('kActions'); | $actions = $this->Application->recallObject('kActions'); | ||||
/* @var $actions Params */ | |||||
$actions->Set($event->getPrefixSpecial() . '_GoTab', ''); | $actions->Set($event->getPrefixSpecial() . '_GoTab', ''); | ||||
$actions->Set($event->getPrefixSpecial() . '_GoId', ''); | $actions->Set($event->getPrefixSpecial() . '_GoId', ''); | ||||
$actions->Set('forms[' . $event->getPrefixSpecial() . ']', $object->getFormName()); | $actions->Set('forms[' . $event->getPrefixSpecial() . ']', $object->getFormName()); | ||||
} | } | ||||
/** | /** | ||||
* Processes case, when item wasn't loaded because of lack of permissions | * Processes case, when item wasn't loaded because of lack of permissions | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
* Build sub-tables array from configs | * Build sub-tables array from configs | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnTempHandlerBuild(kEvent $event) | protected function OnTempHandlerBuild(kEvent $event) | ||||
{ | { | ||||
/** @var kTempTablesHandler $object */ | |||||
$object = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | $object = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); | ||||
Line exceeds 120 characters; contains 122 characters Lint: Generic.Files.LineLength.TooLong: Line exceeds 120 characters; contains 122 characters | |||||
/* @var $object kTempTablesHandler */ | |||||
/** @var kEvent $parent_event */ | |||||
$parent_event = $event->getEventParam('parent_event'); | $parent_event = $event->getEventParam('parent_event'); | ||||
/* @var $parent_event kEvent */ | |||||
if ( is_object($parent_event) ) { | if ( is_object($parent_event) ) { | ||||
$object->setParentEvent($parent_event); | $object->setParentEvent($parent_event); | ||||
} | } | ||||
$object->BuildTables($event->Prefix, $this->getSelectedIDs($event)); | $object->BuildTables($event->Prefix, $this->getSelectedIDs($event)); | ||||
} | } | ||||
Show All 16 Lines | |||||
* 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->isLoaded() && !is_array($id) && ($object->GetID() == $id) ) { | if ( $object->isLoaded() && !is_array($id) && ($object->GetID() == $id) ) { | ||||
// object is already loaded by same id | // object is already loaded by same id | ||||
return ; | return ; | ||||
} | } | ||||
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()); | ||||
} | } | ||||
else { | else { | ||||
$object->setID( is_array($id) ? false : $id ); | $object->setID( is_array($id) ? false : $id ); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Builds list | * Builds list | ||||
* | * | ||||
* Pattern: Prototype Manager | * Pattern: Prototype Manager | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnListBuild(kEvent $event) | protected function OnListBuild(kEvent $event) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
/*if ( $this->Application->isDebugMode() ) { | /*if ( $this->Application->isDebugMode() ) { | ||||
$event_params = http_build_query($event->getEventParams()); | $event_params = http_build_query($event->getEventParams()); | ||||
$this->Application->Debugger->appendHTML('InitList "<strong>' . $event->getPrefixSpecial() . '</strong>" (' . $event_params . ')'); | $this->Application->Debugger->appendHTML('InitList "<strong>' . $event->getPrefixSpecial() . '</strong>" (' . $event_params . ')'); | ||||
}*/ | }*/ | ||||
$this->dbBuild($object, $event); | $this->dbBuild($object, $event); | ||||
Show All 17 Lines | |||||
$object->linkToParent($this->getMainSpecial($event)); | $object->linkToParent($this->getMainSpecial($event)); | ||||
} | } | ||||
$this->AddFilters($event); | $this->AddFilters($event); | ||||
$this->SetCustomQuery($event); // new!, use this for dynamic queries based on specials for ex. | $this->SetCustomQuery($event); // new!, use this for dynamic queries based on specials for ex. | ||||
$this->SetPagination($event); | $this->SetPagination($event); | ||||
$this->SetSorting($event); | $this->SetSorting($event); | ||||
/** @var Params $actions */ | |||||
$actions = $this->Application->recallObject('kActions'); | $actions = $this->Application->recallObject('kActions'); | ||||
/* @var $actions Params */ | |||||
$actions->Set('remove_specials[' . $event->getPrefixSpecial() . ']', '0'); | $actions->Set('remove_specials[' . $event->getPrefixSpecial() . ']', '0'); | ||||
$actions->Set($event->getPrefixSpecial() . '_GoTab', ''); | $actions->Set($event->getPrefixSpecial() . '_GoTab', ''); | ||||
} | } | ||||
/** | /** | ||||
* Returns special of main item for linking with sub-item | * Returns special of main item for linking with sub-item | ||||
* | * | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
*/ | */ | ||||
protected function OnSetPerPage(kEvent $event) | protected function OnSetPerPage(kEvent $event) | ||||
{ | { | ||||
$per_page = $this->Application->GetVar($event->getPrefixSpecial(true) . '_PerPage'); | $per_page = $this->Application->GetVar($event->getPrefixSpecial(true) . '_PerPage'); | ||||
$event->SetRedirectParam($event->getPrefixSpecial() . '_PerPage', $per_page); | $event->SetRedirectParam($event->getPrefixSpecial() . '_PerPage', $per_page); | ||||
$event->SetRedirectParam('pass', 'all,' . $event->getPrefixSpecial()); | $event->SetRedirectParam('pass', 'all,' . $event->getPrefixSpecial()); | ||||
if ( !$this->Application->isAdminUser ) { | if ( !$this->Application->isAdminUser ) { | ||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$this->_passListParams($event, 'per_page'); | $this->_passListParams($event, 'per_page'); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Occurs when page is changed (only for hooking) | * Occurs when page is changed (only for hooking) | ||||
* | * | ||||
Show All 19 Lines | |||||
* @param string $skip_var | * @param string $skip_var | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _passListParams($event, $skip_var) | protected function _passListParams($event, $skip_var) | ||||
{ | { | ||||
$param_names = array_diff(Array ('page', 'per_page', 'sort_by'), Array ($skip_var)); | $param_names = array_diff(Array ('page', 'per_page', 'sort_by'), Array ($skip_var)); | ||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
foreach ($param_names as $param_name) { | foreach ($param_names as $param_name) { | ||||
$value = $this->Application->GetVar($param_name); | $value = $this->Application->GetVar($param_name); | ||||
switch ($param_name) { | switch ($param_name) { | ||||
case 'page': | case 'page': | ||||
if ( $value > 1 ) { | if ( $value > 1 ) { | ||||
$event->SetRedirectParam('page', $value); | $event->SetRedirectParam('page', $value); | ||||
} | } | ||||
break; | break; | ||||
case 'per_page': | case 'per_page': | ||||
if ( $value > 0 ) { | if ( $value > 0 ) { | ||||
if ( $value != $list_helper->getDefaultPerPage($event->Prefix) ) { | if ( $value != $list_helper->getDefaultPerPage($event->Prefix) ) { | ||||
$event->SetRedirectParam('per_page', $value); | $event->SetRedirectParam('per_page', $value); | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case 'sort_by': | case 'sort_by': | ||||
$event->setPseudoClass('_List'); | $event->setPseudoClass('_List'); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(Array ('main_list' => 1)); | $object = $event->getObject(Array ('main_list' => 1)); | ||||
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 kDBList */ | |||||
if ( $list_helper->hasUserSorting($object) ) { | if ( $list_helper->hasUserSorting($object) ) { | ||||
$event->SetRedirectParam('sort_by', $value); | $event->SetRedirectParam('sort_by', $value); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Set's correct page for list based on data provided with event | * Set's correct page for list based on data provided with event | ||||
* | * | ||||
* @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 All 39 Lines | |||||
* Returns current per-page setting for list | * Returns current per-page setting for list | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return int | * @return int | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function getPerPage(kEvent $event) | protected function getPerPage(kEvent $event) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$per_page = $event->getEventParam('per_page'); | $per_page = $event->getEventParam('per_page'); | ||||
if ( $per_page ) { | if ( $per_page ) { | ||||
// per-page is passed as tag parameter to PrintList, InitList, etc. | // per-page is passed as tag parameter to PrintList, InitList, etc. | ||||
$config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); | $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); | ||||
// 2. per-page setting is stored in configuration variable | // 2. per-page setting is stored in configuration variable | ||||
Show All 39 Lines | |||||
} | } | ||||
else { | else { | ||||
// per-page not found in request -> get from pesistent session (or session) | // per-page not found in request -> get from pesistent session (or session) | ||||
$per_page = $this->getListSetting($event, 'PerPage'); | $per_page = $this->getListSetting($event, 'PerPage'); | ||||
} | } | ||||
} | } | ||||
if ( !$per_page ) { | if ( !$per_page ) { | ||||
// per page wan't found in request/session/persistent session | // per page wan't found in request/session/persistent session | ||||
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 ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
// allow to override default per-page value from tag | // allow to override default per-page value from tag | ||||
$default_per_page = $event->getEventParam('default_per_page'); | $default_per_page = $event->getEventParam('default_per_page'); | ||||
if ( !is_numeric($default_per_page) ) { | if ( !is_numeric($default_per_page) ) { | ||||
$default_per_page = $this->Application->ConfigValue('DefaultGridPerPage'); | $default_per_page = $this->Application->ConfigValue('DefaultGridPerPage'); | ||||
} | } | ||||
Show All 10 Lines | |||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
* @see kDBEventHandler::OnListBuild() | * @see kDBEventHandler::OnListBuild() | ||||
*/ | */ | ||||
protected function SetSorting(kEvent $event) | protected function SetSorting(kEvent $event) | ||||
{ | { | ||||
$event->setPseudoClass('_List'); | $event->setPseudoClass('_List'); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
if ( $object->isMainList() ) { | if ( $object->isMainList() ) { | ||||
$sort_by = $this->Application->GetVar('sort_by'); | $sort_by = $this->Application->GetVar('sort_by'); | ||||
$cur_sort1 = $cur_sort1_dir = $cur_sort2 = $cur_sort2_dir = false; | $cur_sort1 = $cur_sort1_dir = $cur_sort2 = $cur_sort2_dir = false; | ||||
if ( $sort_by ) { | if ( $sort_by ) { | ||||
$sortings = explode('|', $sort_by); | $sortings = explode('|', $sort_by); | ||||
list ($cur_sort1, $cur_sort1_dir) = explode(',', $sortings[0]); | list ($cur_sort1, $cur_sort1_dir) = explode(',', $sortings[0]); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
if ( next($sorting) ) { | if ( next($sorting) ) { | ||||
$cur_sort2 = key($sorting); | $cur_sort2 = key($sorting); | ||||
$cur_sort2_dir = current($sorting); | $cur_sort2_dir = current($sorting); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// always add forced sorting before any user sorting fields | // always add forced sorting before any user sorting 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 Array $forced_sorting */ | |||||
$forced_sorting = getArrayValue($list_sortings, 'ForcedSorting'); | $forced_sorting = getArrayValue($list_sortings, 'ForcedSorting'); | ||||
/* @var $forced_sorting Array */ | |||||
if ( $forced_sorting ) { | if ( $forced_sorting ) { | ||||
foreach ($forced_sorting as $field => $dir) { | foreach ($forced_sorting as $field => $dir) { | ||||
$object->AddOrderField($field, $dir); | $object->AddOrderField($field, $dir); | ||||
} | } | ||||
} | } | ||||
// add user sorting fields | // add user sorting fields | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | |||||
* Add filters found in session | * Add filters found in session | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function AddFilters(kEvent $event) | protected function AddFilters(kEvent $event) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$edit_mark = rtrim($this->Application->GetSID() . '_' . $this->Application->GetTopmostWid($event->Prefix), '_'); | $edit_mark = rtrim($this->Application->GetSID() . '_' . $this->Application->GetTopmostWid($event->Prefix), '_'); | ||||
// add search filter | // add search filter | ||||
$filter_data = $this->Application->RecallVar($event->getPrefixSpecial() . '_search_filter'); | $filter_data = $this->Application->RecallVar($event->getPrefixSpecial() . '_search_filter'); | ||||
if ( $filter_data ) { | if ( $filter_data ) { | ||||
$filter_data = unserialize($filter_data); | $filter_data = unserialize($filter_data); | ||||
Show All 27 Lines | |||||
} | } | ||||
// add view filter | // add view filter | ||||
$view_filter = $this->Application->RecallVar($event->getPrefixSpecial() . '_view_filter'); | $view_filter = $this->Application->RecallVar($event->getPrefixSpecial() . '_view_filter'); | ||||
if ( $view_filter ) { | if ( $view_filter ) { | ||||
$view_filter = unserialize($view_filter); | $view_filter = unserialize($view_filter); | ||||
/** @var kMultipleFilter $temp_filter */ | |||||
$temp_filter = $this->Application->makeClass('kMultipleFilter'); | $temp_filter = $this->Application->makeClass('kMultipleFilter'); | ||||
/* @var $temp_filter kMultipleFilter */ | |||||
$filter_menu = $this->Application->getUnitOption($event->Prefix, 'FilterMenu'); | $filter_menu = $this->Application->getUnitOption($event->Prefix, 'FilterMenu'); | ||||
$group_key = 0; | $group_key = 0; | ||||
$group_count = count($filter_menu['Groups']); | $group_count = count($filter_menu['Groups']); | ||||
while ($group_key < $group_count) { | while ($group_key < $group_count) { | ||||
$group_info = $filter_menu['Groups'][$group_key]; | $group_info = $filter_menu['Groups'][$group_key]; | ||||
Show All 30 Lines | |||||
protected function applyItemFilters($event) | protected function applyItemFilters($event) | ||||
{ | { | ||||
$filter_values = $this->Application->GetVar('filters', Array ()); | $filter_values = $this->Application->GetVar('filters', Array ()); | ||||
if ( !$filter_values ) { | if ( !$filter_values ) { | ||||
return; | return; | ||||
} | } | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
$where_clause = Array ( | $where_clause = Array ( | ||||
'ItemPrefix = ' . $this->Conn->qstr($object->Prefix), | 'ItemPrefix = ' . $this->Conn->qstr($object->Prefix), | ||||
'FilterField IN (' . implode(',', $this->Conn->qstrArray(array_keys($filter_values))) . ')', | 'FilterField IN (' . implode(',', $this->Conn->qstrArray(array_keys($filter_values))) . ')', | ||||
'Enabled = 1', | 'Enabled = 1', | ||||
); | ); | ||||
$sql = 'SELECT * | $sql = 'SELECT * | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | |||||
if ( $this->Application->isAdmin || !$this->Application->GetVar('main_list') ) { | if ( $this->Application->isAdmin || !$this->Application->GetVar('main_list') ) { | ||||
$this->setListSetting($event, 'Sortings', Array ('Sort1' => $field, 'Sort1_Dir' => $dir)); | $this->setListSetting($event, 'Sortings', Array ('Sort1' => $field, 'Sort1_Dir' => $dir)); | ||||
} | } | ||||
else { | else { | ||||
$event->setPseudoClass('_List'); | $event->setPseudoClass('_List'); | ||||
$this->Application->SetVar('sort_by', $field . ',' . $dir); | $this->Application->SetVar('sort_by', $field . ',' . $dir); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(Array ('main_list' => 1)); | $object = $event->getObject(Array ('main_list' => 1)); | ||||
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 kDBList */ | |||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$this->_passListParams($event, 'sort_by'); | $this->_passListParams($event, 'sort_by'); | ||||
if ( $list_helper->hasUserSorting($object) ) { | if ( $list_helper->hasUserSorting($object) ) { | ||||
$event->SetRedirectParam('sort_by', $field . ',' . strtolower($dir)); | $event->SetRedirectParam('sort_by', $field . ',' . strtolower($dir)); | ||||
} | } | ||||
$event->SetRedirectParam('pass', 'm'); | $event->SetRedirectParam('pass', 'm'); | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
* special requested, then use list query | * special requested, then use list query | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function ItemPrepareQuery(kEvent $event) | protected function ItemPrepareQuery(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$sqls = $object->getFormOption('ItemSQLs', Array ()); | $sqls = $object->getFormOption('ItemSQLs', Array ()); | ||||
$special = isset($sqls[$event->Special]) ? $event->Special : ''; | $special = isset($sqls[$event->Special]) ? $event->Special : ''; | ||||
// preferred special not found in ItemSQLs -> use analog from ListSQLs | // preferred special not found in ItemSQLs -> use analog from ListSQLs | ||||
return isset($sqls[$special]) ? $sqls[$special] : $this->ListPrepareQuery($event); | return isset($sqls[$special]) ? $sqls[$special] : $this->ListPrepareQuery($event); | ||||
} | } | ||||
/** | /** | ||||
* Creates needed sql query to load list, | * Creates needed sql query to load list, | ||||
* if no query is defined in config for | * if no query is defined in config for | ||||
* special requested, then use default | * special requested, then use default | ||||
* query | * query | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function ListPrepareQuery(kEvent $event) | protected function ListPrepareQuery(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$sqls = $object->getFormOption('ListSQLs', Array ()); | $sqls = $object->getFormOption('ListSQLs', Array ()); | ||||
return $sqls[array_key_exists($event->Special, $sqls) ? $event->Special : '']; | return $sqls[array_key_exists($event->Special, $sqls) ? $event->Special : '']; | ||||
} | } | ||||
/** | /** | ||||
* Apply custom processing to item | * Apply custom processing to item | ||||
Show All 14 Lines | |||||
* Creates new kDBItem | * Creates new kDBItem | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCreate(kEvent $event) | protected function OnCreate(kEvent $event) | ||||
{ | { | ||||
/** @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 */ | |||||
$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($id, $field_values) = each($items_info); | list($id, $field_values) = each($items_info); | ||||
Show All 38 Lines | |||||
* Updates data in database based on request | * Updates data in database based on request | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _update(kEvent $event) | protected function _update(kEvent $event) | ||||
{ | { | ||||
/** @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 */ | |||||
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); | ||||
if ( $items_info ) { | if ( $items_info ) { | ||||
foreach ($items_info as $id => $field_values) { | foreach ($items_info as $id => $field_values) { | ||||
$object->Load($id); | $object->Load($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
Show All 21 Lines | |||||
*/ | */ | ||||
protected function OnDelete(kEvent $event) | protected function OnDelete(kEvent $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 kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
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 | |||||
Line exceeds maximum limit of 140 characters; contains 162 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 162 characters | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->DeleteItems($event->Prefix, $event->Special, Array ($this->getPassedID($event))); | $temp_handler->DeleteItems($event->Prefix, $event->Special, Array ($this->getPassedID($event))); | ||||
} | } | ||||
/** | /** | ||||
* Deletes all records from table | * Deletes all records from table | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnDeleteAll(kEvent $event) | protected function OnDeleteAll(kEvent $event) | ||||
{ | { | ||||
$sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . ' | $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . ' | ||||
FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName'); | FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName'); | ||||
$ids = $this->Conn->GetCol($sql); | $ids = $this->Conn->GetCol($sql); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
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" | |||||
Line exceeds maximum limit of 140 characters; contains 166 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 166 characters | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->DeleteItems($event->Prefix, $event->Special, $ids); | $temp_handler->DeleteItems($event->Prefix, $event->Special, $ids); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Prepares new kDBItem object | * Prepares new kDBItem object | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnNew(kEvent $event) | protected function OnNew(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $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 kDBItem */ | |||||
$object->Clear(0); | $object->Clear(0); | ||||
$this->Application->SetVar($event->getPrefixSpecial() . '_SaveEvent', 'OnCreate'); | $this->Application->SetVar($event->getPrefixSpecial() . '_SaveEvent', 'OnCreate'); | ||||
if ( $event->getEventParam('top_prefix') != $event->Prefix ) { | if ( $event->getEventParam('top_prefix') != $event->Prefix ) { | ||||
// this is subitem prefix, so use main item special | // this is subitem prefix, so use main item special | ||||
$table_info = $object->getLinkedInfo($this->getMainSpecial($event)); | $table_info = $object->getLinkedInfo($this->getMainSpecial($event)); | ||||
} | } | ||||
Show All 10 Lines | |||||
* Cancels kDBItem Editing/Creation | * Cancels kDBItem Editing/Creation | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCancel(kEvent $event) | protected function OnCancel(kEvent $event) | ||||
{ | { | ||||
/** @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 */ | |||||
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); | ||||
if ( $items_info ) { | if ( $items_info ) { | ||||
$delete_ids = Array (); | $delete_ids = Array (); | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
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" | |||||
Line exceeds maximum limit of 140 characters; contains 166 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 166 characters | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
foreach ($items_info as $id => $field_values) { | foreach ($items_info as $id => $field_values) { | ||||
$object->Load($id); | $object->Load($id); | ||||
// record created for using with selector (e.g. Reviews->Select User), and not validated => Delete it | // record created for using with selector (e.g. Reviews->Select User), and not validated => Delete it | ||||
if ( $object->isLoaded() && !$object->Validate() && ($id <= 0) ) { | if ( $object->isLoaded() && !$object->Validate() && ($id <= 0) ) { | ||||
$delete_ids[] = $id; | $delete_ids[] = $id; | ||||
} | } | ||||
} | } | ||||
Show All 17 Lines | |||||
*/ | */ | ||||
protected function OnMassDelete(kEvent $event) | protected function OnMassDelete(kEvent $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 kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
Line exceeds maximum limit of 140 characters; contains 162 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 162 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" | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
$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 ) { | ||||
Show All 33 Lines | |||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnEdit(kEvent $event) | protected function OnEdit(kEvent $event) | ||||
{ | { | ||||
$this->setTempWindowID($event); | $this->setTempWindowID($event); | ||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
/** @var kDBItem $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 kDBItem */ | |||||
$object->setPendingActions(null, true); | $object->setPendingActions(null, true); | ||||
$changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | $changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | ||||
$this->Application->RemoveVar($changes_var_name); | $this->Application->RemoveVar($changes_var_name); | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
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" | |||||
Line exceeds maximum limit of 140 characters; contains 162 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 162 characters | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->PrepareEdit(); | $temp_handler->PrepareEdit(); | ||||
$event->SetRedirectParam('m_lang', $this->Application->GetDefaultLanguageId()); | $event->SetRedirectParam('m_lang', $this->Application->GetDefaultLanguageId()); | ||||
$event->SetRedirectParam($event->getPrefixSpecial() . '_id', array_shift($ids)); | $event->SetRedirectParam($event->getPrefixSpecial() . '_id', array_shift($ids)); | ||||
$event->SetRedirectParam('pass', 'all,' . $event->getPrefixSpecial()); | $event->SetRedirectParam('pass', 'all,' . $event->getPrefixSpecial()); | ||||
$simultaneous_edit_message = $this->Application->GetVar('_simultaneous_edit_message'); | $simultaneous_edit_message = $this->Application->GetVar('_simultaneous_edit_message'); | ||||
Show All 15 Lines | |||||
{ | { | ||||
$event->CallSubEvent('OnPreSave'); | $event->CallSubEvent('OnPreSave'); | ||||
if ( $event->status != kEvent::erSUCCESS ) { | if ( $event->status != kEvent::erSUCCESS ) { | ||||
return; | return; | ||||
} | } | ||||
$skip_master = false; | $skip_master = false; | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
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" | |||||
Line exceeds maximum limit of 140 characters; contains 162 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 162 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 | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | $changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | ||||
if ( !$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { | if ( !$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1) ) { | ||||
$live_ids = $temp_handler->SaveEdit($event->getEventParam('master_ids') ? $event->getEventParam('master_ids') : Array ()); | $live_ids = $temp_handler->SaveEdit($event->getEventParam('master_ids') ? $event->getEventParam('master_ids') : Array ()); | ||||
if ( $live_ids === false ) { | if ( $live_ids === false ) { | ||||
// coping from table failed, because we have another coping process to same table, that wasn't finished | // coping from table failed, because we have another coping process to same table, that wasn't finished | ||||
$event->status = kEvent::erFAIL; | $event->status = kEvent::erFAIL; | ||||
return; | return; | ||||
} | } | ||||
if ( $live_ids ) { | if ( $live_ids ) { | ||||
// ensure, that newly created item ids are available as if they were selected from grid | // ensure, that newly created item ids are available as if they were selected from grid | ||||
// NOTE: only works if main item has sub-items !!! | // NOTE: only works if main item has sub-items !!! | ||||
$this->StoreSelectedIDs($event, $live_ids); | $this->StoreSelectedIDs($event, $live_ids); | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$this->SaveLoggedChanges($changes_var_name, $object->ShouldLogChanges()); | $this->SaveLoggedChanges($changes_var_name, $object->ShouldLogChanges()); | ||||
} | } | ||||
else { | else { | ||||
$event->status = kEvent::erFAIL; | $event->status = kEvent::erFAIL; | ||||
} | } | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | |||||
* Removes all temp tables and clears selected ids | * Removes all temp tables and clears selected ids | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnCancelEdit(kEvent $event) | protected function OnCancelEdit(kEvent $event) | ||||
{ | { | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
Line exceeds maximum limit of 140 characters; contains 162 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 162 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" | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->CancelEdit(); | $temp_handler->CancelEdit(); | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
$this->Application->RemoveVar($event->getPrefixSpecial() . '_modified'); | $this->Application->RemoveVar($event->getPrefixSpecial() . '_modified'); | ||||
$changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | $changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | ||||
$this->Application->RemoveVar($changes_var_name); | $this->Application->RemoveVar($changes_var_name); | ||||
$event->SetRedirectParam('opener', 'u'); | $event->SetRedirectParam('opener', 'u'); | ||||
} | } | ||||
/** | /** | ||||
* Allows to determine if we are creating new item or editing already created item | * Allows to determine if we are creating new item or editing already created item | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return bool | * @return bool | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function isNewItemCreate(kEvent $event) | public function isNewItemCreate(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject( Array ('raise_warnings' => 0) ); | $object = $event->getObject( Array ('raise_warnings' => 0) ); | ||||
Space after opening parenthesis of function call prohibited Lint: CodingStandard.Functions.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Space after opening parenthesis of function call prohibited Lint: PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
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 | |||||
/* @var $object kDBItem */ | |||||
return !$object->isLoaded(); | return !$object->isLoaded(); | ||||
} | } | ||||
/** | /** | ||||
* 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 | ||||
* | * | ||||
Show All 26 Lines | |||||
* Analog of OnPreSave event for usage in AJAX request | * Analog of OnPreSave event for usage in AJAX request | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
protected function OnPreSaveAjax(kEvent $event) | protected function OnPreSaveAjax(kEvent $event) | ||||
{ | { | ||||
/** @var AjaxFormHelper $ajax_form_helper */ | |||||
$ajax_form_helper = $this->Application->recallObject('AjaxFormHelper'); | $ajax_form_helper = $this->Application->recallObject('AjaxFormHelper'); | ||||
/* @var $ajax_form_helper AjaxFormHelper */ | |||||
$ajax_form_helper->transitEvent($event, 'OnPreSave'); | $ajax_form_helper->transitEvent($event, 'OnPreSave'); | ||||
} | } | ||||
/** | /** | ||||
* [HOOK] Saves sub-item | * [HOOK] Saves sub-item | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnPreSaveSubItem(kEvent $event) | protected function OnPreSaveSubItem(kEvent $event) | ||||
{ | { | ||||
$not_created = $this->isNewItemCreate($event); | $not_created = $this->isNewItemCreate($event); | ||||
$event->CallSubEvent($not_created ? 'OnCreate' : 'OnUpdate'); | $event->CallSubEvent($not_created ? 'OnCreate' : 'OnUpdate'); | ||||
if ( $event->status == kEvent::erSUCCESS ) { | if ( $event->status == kEvent::erSUCCESS ) { | ||||
No blank line found before "if" control structure Lint: CodingStandard.WhiteSpace.ControlStructureSpacing.NoLineBeforeOpen: No blank line found before "if" control structure | |||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$this->Application->SetVar($event->getPrefixSpecial() . '_id', $object->GetID()); | $this->Application->SetVar($event->getPrefixSpecial() . '_id', $object->GetID()); | ||||
} | } | ||||
else { | else { | ||||
$event->MasterEvent->status = $event->status; | $event->MasterEvent->status = $event->status; | ||||
} | } | ||||
$event->SetRedirectParam('opener', 's'); | $event->SetRedirectParam('opener', 's'); | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnPreCreate(kEvent $event) | protected function OnPreCreate(kEvent $event) | ||||
{ | { | ||||
$this->setTempWindowID($event); | $this->setTempWindowID($event); | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
$this->Application->SetVar('m_lang', $this->Application->GetDefaultLanguageId()); | $this->Application->SetVar('m_lang', $this->Application->GetDefaultLanguageId()); | ||||
/** @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 */ | |||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->Prefix . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->Prefix . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
Line exceeds maximum limit of 140 characters; contains 150 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 150 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" | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->PrepareEdit(); | $temp_handler->PrepareEdit(); | ||||
$object->setID(0); | $object->setID(0); | ||||
$this->Application->SetVar($event->getPrefixSpecial() . '_id', 0); | $this->Application->SetVar($event->getPrefixSpecial() . '_id', 0); | ||||
$this->Application->SetVar($event->getPrefixSpecial() . '_PreCreate', 1); | $this->Application->SetVar($event->getPrefixSpecial() . '_PreCreate', 1); | ||||
$changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | $changes_var_name = $this->Prefix . '_changes_' . $this->Application->GetTopmostWid($this->Prefix); | ||||
$this->Application->RemoveVar($changes_var_name); | $this->Application->RemoveVar($changes_var_name); | ||||
$event->redirect = false; | $event->redirect = false; | ||||
} | } | ||||
/** | /** | ||||
* Creates a new item in temp table and | * Creates a new item in temp table and | ||||
* stores item id in App vars and Session on success | * stores item id in App vars and Session on success | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnPreSaveCreated(kEvent $event) | protected function OnPreSaveCreated(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $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 | |||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
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" | |||||
Space after opening parenthesis of function call prohibited Lint: CodingStandard.Functions.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
/* @var $object kDBItem */ | |||||
$object->setID(0); | $object->setID(0); | ||||
$field_values = $this->getSubmittedFields($event); | $field_values = $this->getSubmittedFields($event); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$this->customProcessing($event, 'before'); | $this->customProcessing($event, 'before'); | ||||
if ( $object->Create() ) { | if ( $object->Create() ) { | ||||
Show All 12 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnReset(kEvent $event) | protected function OnReset(kEvent $event) | ||||
{ | { | ||||
//do nothing - should reset :) | //do nothing - should reset :) | ||||
if ( $this->isNewItemCreate($event) ) { | if ( $this->isNewItemCreate($event) ) { | ||||
// just reset id to 0 in case it was create | // just reset id to 0 in case it was create | ||||
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( Array ('skip_autoload' => true) ); | $object = $event->getObject( Array ('skip_autoload' => true) ); | ||||
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 | |||||
Expected 0 spaces before closing bracket; 1 found Lint: PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket: Expected 0 spaces before closing bracket; 1 found | |||||
Space after opening parenthesis of function call prohibited Lint: PSR2.Methods.FunctionCallSignature.SpaceAfterOpenBracket: Space after opening parenthesis of function call prohibited | |||||
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 kDBItem */ | |||||
$object->setID(0); | $object->setID(0); | ||||
$this->Application->SetVar($event->getPrefixSpecial() . '_id', 0); | $this->Application->SetVar($event->getPrefixSpecial() . '_id', 0); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Apply same processing to each item being selected in grid | * Apply same processing to each item being selected in grid | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function iterateItems(kEvent $event) | protected function iterateItems(kEvent $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 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 */ | |||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
$status_field = $object->getStatusField(); | $status_field = $object->getStatusField(); | ||||
$order_field = $this->Application->getUnitOption($event->Prefix, 'OrderField'); | $order_field = $this->Application->getUnitOption($event->Prefix, 'OrderField'); | ||||
if ( !$order_field ) { | if ( !$order_field ) { | ||||
Show All 37 Lines | |||||
*/ | */ | ||||
protected function OnMassClone(kEvent $event) | protected function OnMassClone(kEvent $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 kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
Line exceeds maximum limit of 140 characters; contains 162 characters Lint: Generic.Files.LineLength.MaxExceeded: Line exceeds maximum limit of 140 characters; contains 162 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" | |||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$ids = $this->StoreSelectedIDs($event); | $ids = $this->StoreSelectedIDs($event); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
$temp_handler->CloneItems($event->Prefix, $event->Special, $ids); | $temp_handler->CloneItems($event->Prefix, $event->Special, $ids); | ||||
} | } | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
Show All 23 Lines | |||||
* Saves data from editing form to database without checking required fields | * Saves data from editing form to database without checking required fields | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnPreSavePopup(kEvent $event) | protected function OnPreSavePopup(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$this->RemoveRequiredFields($object); | $this->RemoveRequiredFields($object); | ||||
$event->CallSubEvent('OnPreSave'); | $event->CallSubEvent('OnPreSave'); | ||||
$event->SetRedirectParam('opener', 'u'); | $event->SetRedirectParam('opener', 'u'); | ||||
} | } | ||||
/* End of Edit events */ | /* End of Edit events */ | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
* Occurs after creating item | * Occurs after creating item | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemCreate(kEvent $event) | protected function OnAfterItemCreate(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
if ( !$object->IsTempTable() ) { | if ( !$object->IsTempTable() ) { | ||||
$this->_processPendingActions($event); | $this->_processPendingActions($event); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Occurs before updating item | * Occurs before updating item | ||||
Show All 11 Lines | |||||
* Occurs after updating item | * Occurs after updating item | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemUpdate(kEvent $event) | protected function OnAfterItemUpdate(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
if ( !$object->IsTempTable() ) { | if ( !$object->IsTempTable() ) { | ||||
$this->_processPendingActions($event); | $this->_processPendingActions($event); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Occurs before deleting item, id of item being | * Occurs before deleting item, id of item being | ||||
Show All 15 Lines | |||||
* Also deletes subscriptions to that particual item once it's deleted | * Also deletes subscriptions to that particual item once it's deleted | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterItemDelete(kEvent $event) | protected function OnAfterItemDelete(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
// 1. delete direct subscriptions to item, that was deleted | // 1. delete direct subscriptions to item, that was deleted | ||||
$this->_deleteSubscriptions($event->Prefix, 'ItemId', $object->GetID()); | $this->_deleteSubscriptions($event->Prefix, 'ItemId', $object->GetID()); | ||||
/** @var Array $sub_items */ | |||||
$sub_items = $this->Application->getUnitOption($event->Prefix, 'SubItems', Array ()); | $sub_items = $this->Application->getUnitOption($event->Prefix, 'SubItems', 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 $sub_items Array */ | |||||
// 2. delete this item sub-items subscriptions, that reference item, that was deleted | // 2. delete this item sub-items subscriptions, that reference item, that was deleted | ||||
foreach ($sub_items as $sub_prefix) { | foreach ($sub_items as $sub_prefix) { | ||||
$this->_deleteSubscriptions($sub_prefix, 'ParentItemId', $object->GetID()); | $this->_deleteSubscriptions($sub_prefix, 'ParentItemId', $object->GetID()); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
Show All 21 Lines | |||||
FROM ' . TABLE_PREFIX . 'SystemEventSubscriptions | FROM ' . TABLE_PREFIX . 'SystemEventSubscriptions | ||||
WHERE ' . $field . ' = ' . $value . ' AND EmailTemplateId IN (' . implode(',', $email_template_ids) . ')'; | WHERE ' . $field . ' = ' . $value . ' AND EmailTemplateId IN (' . implode(',', $email_template_ids) . ')'; | ||||
$ids = $this->Conn->GetCol($sql); | $ids = $this->Conn->GetCol($sql); | ||||
if ( !$ids ) { | if ( !$ids ) { | ||||
return; | return; | ||||
} | } | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject('system-event-subscription_TempHandler', 'kTempTablesHandler'); | $temp_handler = $this->Application->recallObject('system-event-subscription_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 */ | |||||
$temp_handler->DeleteItems('system-event-subscription', '', $ids); | $temp_handler->DeleteItems('system-event-subscription', '', $ids); | ||||
} | } | ||||
/** | /** | ||||
* Occurs before validation attempt | * Occurs before validation attempt | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
* Id of copied item is passed as event' 'id' param | * Id of copied item is passed as event' 'id' param | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterCopyToLive(kEvent $event) | protected function OnAfterCopyToLive(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(array('skip_autoload' => true)); | $object = $event->getObject(array('skip_autoload' => true)); | ||||
/* @var $object kDBItem */ | |||||
$object->SwitchToLive(); | $object->SwitchToLive(); | ||||
$object->Load($event->getEventParam('id')); | $object->Load($event->getEventParam('id')); | ||||
$this->_processPendingActions($event); | $this->_processPendingActions($event); | ||||
} | } | ||||
/** | /** | ||||
* Processing file pending actions (e.g. delete scheduled files) | * Processing file pending actions (e.g. delete scheduled files) | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _processPendingActions(kEvent $event) | protected function _processPendingActions(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$update_required = false; | $update_required = false; | ||||
$temp_id = $event->getEventParam('temp_id'); | $temp_id = $event->getEventParam('temp_id'); | ||||
$id = $temp_id !== false ? $temp_id : $object->GetID(); | $id = $temp_id !== false ? $temp_id : $object->GetID(); | ||||
foreach ($object->getPendingActions($id) as $data) { | foreach ($object->getPendingActions($id) as $data) { | ||||
switch ( $data['action'] ) { | switch ( $data['action'] ) { | ||||
case 'delete': | case 'delete': | ||||
unlink($data['file']); | unlink($data['file']); | ||||
break; | break; | ||||
case 'make_live': | case 'make_live': | ||||
/** @var FileHelper $file_helper */ | |||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
/* @var $file_helper FileHelper */ | |||||
if ( !file_exists($data['file']) ) { | if ( !file_exists($data['file']) ) { | ||||
// file removal was requested too | // file removal was requested too | ||||
continue; | continue; | ||||
} | } | ||||
$old_name = basename($data['file']); | $old_name = basename($data['file']); | ||||
$new_name = $file_helper->ensureUniqueFilename(dirname($data['file']), kUtil::removeTempExtension($old_name)); | $new_name = $file_helper->ensureUniqueFilename(dirname($data['file']), kUtil::removeTempExtension($old_name)); | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnSearch(kEvent $event) | protected function OnSearch(kEvent $event) | ||||
{ | { | ||||
$event->setPseudoClass('_List'); | $event->setPseudoClass('_List'); | ||||
/** @var kSearchHelper $search_helper */ | |||||
$search_helper = $this->Application->recallObject('SearchHelper'); | $search_helper = $this->Application->recallObject('SearchHelper'); | ||||
/* @var $search_helper kSearchHelper */ | |||||
$search_helper->performSearch($event); | $search_helper->performSearch($event); | ||||
} | } | ||||
/** | /** | ||||
* Clear search keywords | * Clear search keywords | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnSearchReset(kEvent $event) | protected function OnSearchReset(kEvent $event) | ||||
{ | { | ||||
/** @var kSearchHelper $search_helper */ | |||||
$search_helper = $this->Application->recallObject('SearchHelper'); | $search_helper = $this->Application->recallObject('SearchHelper'); | ||||
/* @var $search_helper kSearchHelper */ | |||||
$search_helper->resetSearch($event); | $search_helper->resetSearch($event); | ||||
} | } | ||||
/** | /** | ||||
* Set's new filter value (filter_id meaning from config) | * Set's new filter value (filter_id meaning from config) | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnPreSaveAndOpenTranslator(kEvent $event) | protected function OnPreSaveAndOpenTranslator(kEvent $event) | ||||
{ | { | ||||
$this->Application->SetVar('allow_translation', true); | $this->Application->SetVar('allow_translation', true); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$this->RemoveRequiredFields($object); | $this->RemoveRequiredFields($object); | ||||
$event->CallSubEvent('OnPreSave'); | $event->CallSubEvent('OnPreSave'); | ||||
if ( $event->status == kEvent::erSUCCESS ) { | if ( $event->status == kEvent::erSUCCESS ) { | ||||
$resource_id = $this->Application->GetVar('translator_resource_id'); | $resource_id = $this->Application->GetVar('translator_resource_id'); | ||||
if ( $resource_id ) { | if ( $resource_id ) { | ||||
$t_prefixes = explode(',', $this->Application->GetVar('translator_prefixes')); | $t_prefixes = explode(',', $this->Application->GetVar('translator_prefixes')); | ||||
/** @var kDBItem $cdata */ | |||||
$cdata = $this->Application->recallObject($t_prefixes[1], NULL, Array ('skip_autoload' => true)); | $cdata = $this->Application->recallObject($t_prefixes[1], 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" | |||||
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 $cdata kDBItem */ | |||||
$cdata->Load($resource_id, 'ResourceId'); | $cdata->Load($resource_id, 'ResourceId'); | ||||
if ( !$cdata->isLoaded() ) { | if ( !$cdata->isLoaded() ) { | ||||
$cdata->SetDBField('ResourceId', $resource_id); | $cdata->SetDBField('ResourceId', $resource_id); | ||||
$cdata->Create(); | $cdata->Create(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
* Saves selected user in needed field | * Saves selected user in needed field | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnSelectUser(kEvent $event) | protected function OnSelectUser(kEvent $event) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$items_info = $this->Application->GetVar('u'); | $items_info = $this->Application->GetVar('u'); | ||||
if ( $items_info ) { | if ( $items_info ) { | ||||
list ($user_id, ) = each($items_info); | list ($user_id, ) = each($items_info); | ||||
$this->RemoveRequiredFields($object); | $this->RemoveRequiredFields($object); | ||||
$is_new = !$object->isLoaded(); | $is_new = !$object->isLoaded(); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
* @param kDBItem|kDBList $object | * @param kDBItem|kDBList $object | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function prepareObject(&$object, kEvent $event) | protected function prepareObject(&$object, kEvent $event) | ||||
{ | { | ||||
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); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns specific to each item type columns only | * Returns specific to each item type columns only | ||||
* | * | ||||
Show All 10 Lines | |||||
* Export form validation & processing | * Export form validation & processing | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnExportBegin(kEvent $event) | protected function OnExportBegin(kEvent $event) | ||||
{ | { | ||||
/** @var kCatDBItemExportHelper $export_helper */ | |||||
$export_helper = $this->Application->recallObject('CatItemExportHelper'); | $export_helper = $this->Application->recallObject('CatItemExportHelper'); | ||||
/* @var $export_helper kCatDBItemExportHelper */ | |||||
$export_helper->OnExportBegin($event); | $export_helper->OnExportBegin($event); | ||||
} | } | ||||
/** | /** | ||||
* Enter description here... | * Enter description here... | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Line(s) | |||||
* Validates MInput control fields | * Validates MInput control fields | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnValidateMInputFields(kEvent $event) | protected function OnValidateMInputFields(kEvent $event) | ||||
{ | { | ||||
/** @var MInputHelper $minput_helper */ | |||||
$minput_helper = $this->Application->recallObject('MInputHelper'); | $minput_helper = $this->Application->recallObject('MInputHelper'); | ||||
/* @var $minput_helper MInputHelper */ | |||||
$minput_helper->OnValidateMInputFields($event); | $minput_helper->OnValidateMInputFields($event); | ||||
} | } | ||||
/** | /** | ||||
* Validates individual object field and returns the result | * Validates individual object field and returns the result | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnValidateField(kEvent $event) | protected function OnValidateField(kEvent $event) | ||||
{ | { | ||||
$event->status = kEvent::erSTOP; | $event->status = kEvent::erSTOP; | ||||
$field = $this->Application->GetVar('field'); | $field = $this->Application->GetVar('field'); | ||||
if ( ($this->Application->GetVar('ajax') != 'yes') || !$field ) { | if ( ($this->Application->GetVar('ajax') != 'yes') || !$field ) { | ||||
return; | return; | ||||
} | } | ||||
/** @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 */ | |||||
$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 ($id, $field_values) = each($items_info); | list ($id, $field_values) = each($items_info); | ||||
$object->Load($id); | $object->Load($id); | ||||
$object->SetFieldsFromHash($field_values); | $object->SetFieldsFromHash($field_values); | ||||
$event->setEventParam('form_data', $field_values); | $event->setEventParam('form_data', $field_values); | ||||
$object->setID($id); | $object->setID($id); | ||||
$response = Array ('status' => 'OK'); | $response = Array ('status' => 'OK'); | ||||
$event->CallSubEvent($object->isLoaded() ? 'OnBeforeItemUpdate' : 'OnBeforeItemCreate'); | $event->CallSubEvent($object->isLoaded() ? 'OnBeforeItemUpdate' : 'OnBeforeItemCreate'); | ||||
// validate all fields, since "Password_plain" field sets error to "Password" field, which is passed here | // validate all fields, since "Password_plain" field sets error to "Password" field, which is passed here | ||||
$error_field = $object->GetFieldOption($field, 'error_field', false, $field); | $error_field = $object->GetFieldOption($field, 'error_field', false, $field); | ||||
if ( !$object->Validate() && $object->GetErrorPseudo($error_field) ) { | if ( !$object->Validate() && $object->GetErrorPseudo($error_field) ) { | ||||
$response['status'] = $object->GetErrorMsg($error_field, false); | $response['status'] = $object->GetErrorMsg($error_field, false); | ||||
} | } | ||||
/** @var AjaxFormHelper $ajax_form_helper */ | |||||
$ajax_form_helper = $this->Application->recallObject('AjaxFormHelper'); | $ajax_form_helper = $this->Application->recallObject('AjaxFormHelper'); | ||||
/* @var $ajax_form_helper AjaxFormHelper */ | |||||
$response['other_errors'] = $ajax_form_helper->getErrorMessages($object); | $response['other_errors'] = $ajax_form_helper->getErrorMessages($object); | ||||
$response['uploader_info'] = $ajax_form_helper->getUploaderInfo($object, array_keys($field_values)); | $response['uploader_info'] = $ajax_form_helper->getUploaderInfo($object, array_keys($field_values)); | ||||
$event->status = kEvent::erSTOP; // since event's OnBefore... events can change this event status | $event->status = kEvent::erSTOP; // since event's OnBefore... events can change this event status | ||||
echo json_encode($response); | echo json_encode($response); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event Event. | * @param kEvent $event Event. | ||||
* @param string $term Term. | * @param string $term Term. | ||||
* | * | ||||
* @return Array | * @return Array | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function getAutoCompleteSuggestions(kEvent $event, $term) | protected function getAutoCompleteSuggestions(kEvent $event, $term) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBItem */ | |||||
$field = $this->Application->GetVar('field'); | $field = $this->Application->GetVar('field'); | ||||
if ( !$field || !$term || !$object->isField($field) ) { | if ( !$field || !$term || !$object->isField($field) ) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$limit = $this->Application->GetVar('limit'); | $limit = $this->Application->GetVar('limit'); | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |
Line exceeds maximum limit of 140 characters; contains 167 characters