Index: branches/5.2.x/core/units/modules/modules_event_handler.php =================================================================== diff -u -N -r14787 -r14989 --- branches/5.2.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 14787) +++ branches/5.2.x/core/units/modules/modules_event_handler.php (.../modules_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Application->SetVar($event->getPrefixSpecial(true).'_id', $event->Special); + $this->Application->SetVar($event->getPrefixSpecial(true) . '_id', $event->Special); + parent::OnItemBuild($event); } @@ -36,21 +39,31 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ - if ($event->Special) { - $object->addFilter('current_module', '%1$s.Name = '.$event->Special); + if ( $event->Special ) { + $object->addFilter('current_module', '%1$s.Name = ' . $event->Special); } $object->addFilter('not_core', '%1$s.Name <> "Core"'); } - function mapEvents() + /** + * Define alternative event processing method names + * + * @return void + * @see kEventHandler::$eventMethods + * @access protected + */ + protected function mapEvents() { parent::mapEvents(); + $this->eventMethods['OnMassApprove'] = 'moduleAction'; $this->eventMethods['OnMassDecline'] = 'moduleAction'; } Index: branches/5.2.x/core/units/custom_fields/custom_fields_event_handler.php =================================================================== diff -u -N -r14888 -r14989 --- branches/5.2.x/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 14888) +++ branches/5.2.x/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBList */ $item_type = $this->Application->GetVar('cf_type'); - if (!$item_type) { + if ( !$item_type ) { $prefix = $event->getEventParam('SourcePrefix'); $item_type = $this->Application->getUnitOption($prefix, 'ItemType'); } - if ($event->Special == 'general') { + if ( $event->Special == 'general' ) { $object->addFilter('generaltab_filter', '%1$s.OnGeneralTab = 1'); } - if ($item_type) { + if ( $item_type ) { $hidden_fields = $this->Conn->qstrArray($this->_getHiddenFields($event)); - if ($hidden_fields) { + if ( $hidden_fields ) { $object->addFilter('hidden_filter', '%1$s.FieldName NOT IN (' . implode(',', $hidden_fields) . ')'); } - $object->addFilter('itemtype_filter', '%1$s.Type = '.$item_type); + $object->addFilter('itemtype_filter', '%1$s.Type = ' . $item_type); } - if (!($this->Application->isDebugMode() && $this->Application->isAdminUser)) { + if ( !($this->Application->isDebugMode() && $this->Application->isAdminUser) ) { $object->addFilter('user_filter', '%1$s.IsSystem = 0'); } } Index: branches/5.2.x/core/units/users/users_event_handler.php =================================================================== diff -u -N -r14973 -r14989 --- branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14973) +++ branches/5.2.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Array('self' => 'view'), // because setting to logged in user only @@ -57,7 +61,7 @@ * @param kEvent $event * @access protected */ - function OnItemBuild(&$event) + protected function OnItemBuild(kEvent &$event) { parent::OnItemBuild($event); @@ -77,38 +81,40 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ - if ($event->Special == 'regular') { + if ( $event->Special == 'regular' ) { $object->addFilter('primary_filter', '%1$s.UserType = ' . UserType::USER); } - if ($event->Special == 'admins') { + if ( $event->Special == 'admins' ) { $object->addFilter('primary_filter', '%1$s.UserType = ' . UserType::ADMIN); } - if (!$this->Application->isAdminUser) { - $object->addFilter('status_filter', '%1$s.Status = '.STATUS_ACTIVE); + if ( !$this->Application->isAdminUser ) { + $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE); } - if ($event->Special == 'online') { + if ( $event->Special == 'online' ) { $object->addFilter('online_users_filter', 's.PortalUserId IS NOT NULL'); } - if ($event->Special == 'group') { + if ( $event->Special == 'group' ) { $group_id = $this->Application->GetVar('g_id'); - if ($group_id !== false) { + if ( $group_id !== false ) { // show only users, that user doesn't belong to current group $sql = 'SELECT PortalUserId - FROM ' . $this->Application->GetTempName(TABLE_PREFIX.'UserGroup', 'prefix:g') . ' + FROM ' . $this->Application->GetTempName(TABLE_PREFIX . 'UserGroup', 'prefix:g') . ' WHERE GroupId = ' . (int)$group_id; $user_ids = $this->Conn->GetCol($sql); - if ($user_ids) { + if ( $user_ids ) { $object->addFilter('already_member_filter', '%1$s.PortalUserId NOT IN (' . implode(',', $user_ids) . ')'); } } @@ -122,7 +128,7 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { if ( $event->Name == 'OnLogin' || $event->Name == 'OnLoginAjax' || $event->Name == 'OnLogout' ) { // permission is checked in OnLogin event directly @@ -1090,8 +1096,9 @@ * * @param kEvent $event * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { switch ($event->Special) { case 'ord': @@ -1104,7 +1111,7 @@ case 'profile': $id = $this->Application->GetVar('user_id'); - if (!$id) { + if ( !$id ) { // if none user_id given use current user id $id = $this->Application->RecallVar('user_id'); } @@ -1116,7 +1123,7 @@ $user_helper =& $this->Application->recallObject('UserHelper'); /* @var $user_helper UserHelper */ - $id = $user_helper->validateUserCode( $this->Application->GetVar('user_key'), 'forgot_password' ); + $id = $user_helper->validateUserCode($this->Application->GetVar('user_key'), 'forgot_password'); if ( is_numeric($id) ) { return $id; @@ -1261,8 +1268,9 @@ * * @param kEvent $event * @return bool + * @access protected */ - function checkItemStatus(&$event) + protected function checkItemStatus(kEvent &$event) { $object =& $event->getObject(); /* @var $object kDBItem */ @@ -1786,7 +1794,7 @@ * @return void * @access protected */ - protected function LoadItem(&$event) + protected function LoadItem(kEvent &$event) { $id = $this->getPassedID($event); @@ -1797,7 +1805,7 @@ /* @var $object kDBItem */ $object->Clear($id); - return ; + return; } parent::LoadItem($event); Index: branches/5.2.x/core/units/images/image_event_handler.php =================================================================== diff -u -N -r14879 -r14989 --- branches/5.2.x/core/units/images/image_event_handler.php (.../image_event_handler.php) (revision 14879) +++ branches/5.2.x/core/units/images/image_event_handler.php (.../image_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ 'ImageAction', 'OnBeforeDeleteFromLive'=>'ImageAction', 'OnBeforeCopyToLive'=>'ImageAction', @@ -44,14 +59,15 @@ } /** - * Get's special of main item for linking with subitem + * Returns special of main item for linking with sub-item * * @param kEvent $event * @return string + * @access protected */ - function getMainSpecial(&$event) + protected function getMainSpecial(kEvent &$event) { - if ($event->Special == 'list' && !$this->Application->isAdmin) { + if ( $event->Special == 'list' && !$this->Application->isAdmin ) { // ListImages aggregated tag uses this special return ''; } @@ -314,32 +330,30 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); $object =& $event->getObject(); /* @var $object kDBList */ - if (!$this->Application->isAdminUser) { + if ( !$this->Application->isAdminUser ) { $object->addFilter('active', '%1$s.Enabled = 1'); } $product_id = $event->getEventParam('product_id'); - if ($product_id) { + if ( $product_id ) { $object->removeFilter('parent_filter'); $sql = 'SELECT ResourceId - FROM '.$this->Application->getUnitOption('p', 'TableName').' - WHERE ProductId = '.$product_id; - $resource_id = (int) $this->Conn->GetOne($sql); + FROM ' . $this->Application->getUnitOption('p', 'TableName') . ' + WHERE ProductId = ' . $product_id; + $resource_id = (int)$this->Conn->GetOne($sql); - $object->addFilter('product_images', '%1$s.ResourceId = '.$resource_id); + $object->addFilter('product_images', '%1$s.ResourceId = ' . $resource_id); } - /********************************************/ - $search_helper =& $this->Application->recallObject('SearchHelper'); /* @var $search_helper kSearchHelper */ Index: branches/5.2.x/core/units/skins/skin_eh.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/skins/skin_eh.php (.../skin_eh.php) (revision 14628) +++ branches/5.2.x/core/units/skins/skin_eh.php (.../skin_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Array ('self' => true), ); @@ -31,10 +39,11 @@ * * @param kEvent $event * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { - if ($event->Special == 'primary') { + if ( $event->Special == 'primary' ) { return Array ('IsPrimary' => 1); } Index: branches/5.2.x/core/units/files/file_eh.php =================================================================== diff -u -N -r14675 -r14989 --- branches/5.2.x/core/units/files/file_eh.php (.../file_eh.php) (revision 14675) +++ branches/5.2.x/core/units/files/file_eh.php (.../file_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Array('subitem' => 'view'), + + $permissions = Array ( + 'OnDownloadFile' => Array ('subitem' => 'view'), ); $this->permMapping = array_merge($this->permMapping, $permissions); @@ -74,15 +78,15 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); $object =& $event->getObject(); /* @var $object kDBList */ - if (!$this->Application->isAdminUser) { - $object->addFilter('active_filter', '%1$s.Status = '.STATUS_ACTIVE); + if ( !$this->Application->isAdminUser ) { + $object->addFilter('active_filter', '%1$s.Status = ' . STATUS_ACTIVE); } } Index: branches/5.2.x/core/units/filters/item_filter_eh.php =================================================================== diff -u -N -r14979 -r14989 --- branches/5.2.x/core/units/filters/item_filter_eh.php (.../item_filter_eh.php) (revision 14979) +++ branches/5.2.x/core/units/filters/item_filter_eh.php (.../item_filter_eh.php) (revision 14989) @@ -19,8 +19,11 @@ /** * Allows to override standard permission mapping * + * @return void + * @access protected + * @see kEventHandler::$permMapping */ - function mapPermissions() + protected function mapPermissions() { parent::mapPermissions(); @@ -39,20 +42,20 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); if ( !$this->Application->isAdmin ) { $object =& $event->getObject(); /* @var $object kDBList */ - $prefix_info = $this->Application->processPrefix( $event->getEventParam('prefix') ); + $prefix_info = $this->Application->processPrefix($event->getEventParam('prefix')); $object->addFilter('prefix_filter', '%1$s.ItemPrefix = ' . $this->Conn->qstr($prefix_info['prefix'])); $object->addFilter('status_filter', '%1$s.Enabled = 1'); - if ($event->Special == 'used') { + if ( $event->Special == 'used' ) { $filters = array_keys($this->Application->GetVar('filters', Array ())); if ( $filters ) { @@ -120,7 +123,7 @@ * @return void * @access protected */ - protected function LoadItem(&$event) + protected function LoadItem(kEvent &$event) { static $cache = null; Index: branches/5.2.x/core/units/themes/themes_eh.php =================================================================== diff -u -N -r14714 -r14989 --- branches/5.2.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 14714) +++ branches/5.2.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Array('self' => true), ); @@ -37,9 +41,9 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { - if ($event->Name == 'OnItemBuild') { + if ( $event->Name == 'OnItemBuild' ) { // check permission without using $event->getSection(), // so first cache rebuild won't lead to "ldefault_Name" field being used return true; @@ -164,20 +168,20 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); $object =& $event->getObject(); /* @var $object kDBList */ - if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) { + if ( in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser ) { // "enabled" special or Front-End $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE); } // site domain theme picker - if ($event->Special == 'selected' || $event->Special == 'available') { + if ( $event->Special == 'selected' || $event->Special == 'available' ) { $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper'); /* @var $edit_picker_helper EditPickerHelper */ @@ -187,7 +191,7 @@ // apply domain-based theme filtering $themes = $this->Application->siteDomainField('Themes'); - if (strlen($themes)) { + if ( strlen($themes) ) { $themes = explode('|', substr($themes, 1, -1)); $object->addFilter('domain_filter', '%1$s.ThemeId IN (' . implode(',', $themes) . ')'); } Index: branches/5.2.x/core/units/forms/forms/forms_eh.php =================================================================== diff -u -N -r14699 -r14989 --- branches/5.2.x/core/units/forms/forms/forms_eh.php (.../forms_eh.php) (revision 14699) +++ branches/5.2.x/core/units/forms/forms/forms_eh.php (.../forms_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Array('self' => true), + 'OnItemBuild' => Array ('self' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); Index: branches/5.2.x/core/units/forms/submission_log/submission_log_eh.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/forms/submission_log/submission_log_eh.php (.../submission_log_eh.php) (revision 14628) +++ branches/5.2.x/core/units/forms/submission_log/submission_log_eh.php (.../submission_log_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Array ('subitem' => 'add|edit'), 'OnSaveDraft' => Array ('subitem' => 'add|edit'), @@ -38,12 +46,12 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { $section = $event->getSection(); $form_id = $this->Application->GetVar('form_id'); - if ($form_id) { + if ( $form_id ) { // copy form_id to env to be passed info upload links $this->Application->SetVar($event->getPrefixSpecial() . '_form_id', $form_id); } @@ -77,7 +85,7 @@ $form =& $form_submission_helper->getForm($form_submission); /* @var $form kDBItem */ - + $from_email = $form->GetDBField('ReplyFromEmail'); $to_email = $form_submission_helper->getFieldByRole($form_submission, SubmissionFormField::COMMUNICATION_ROLE_EMAIL); Index: branches/5.2.x/core/kernel/event_handler.php =================================================================== diff -u -N -r14851 -r14989 --- branches/5.2.x/core/kernel/event_handler.php (.../event_handler.php) (revision 14851) +++ branches/5.2.x/core/kernel/event_handler.php (.../event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ getPrefixSpecial(true) instead of * $event->getPrefixSpecial() as usual. This is due PHP * is converting "." symbols in variable names during * submit info "_". $event->getPrefixSpecial optional - * 1st parameter returns correct corrent Prefix_Special - * for variables beeing submitted such way (e.g. variable + * 1st parameter returns correct current Prefix_Special + * for variables being submitted such way (e.g. variable * name that will be converted by PHP: "users.read_only_id" * will be submitted as "users_read_only_id". * @@ -68,6 +68,7 @@ /** * Define alternative event processing method names * + * @return void * @see kEventHandler::$eventMethods * @access protected */ @@ -79,6 +80,7 @@ /** * Allows to override standard permission mapping * + * @return void * @access protected * @see kEventHandler::$permMapping */ @@ -104,7 +106,7 @@ * @param kEvent $event * @access public */ - public function processEvent(&$event) + public function processEvent(kEvent &$event) { $event_name = $event->Name; @@ -124,9 +126,10 @@ * Sample dummy event * * @param kEvent $event + * @return void * @access protected */ - protected function OnBuild(&$event) + protected function OnBuild(kEvent &$event) { } @@ -135,13 +138,14 @@ * Returns to previous template in opener stack * * @param kEvent $event + * @return void * @access protected */ - protected function OnGoBack(&$event) + protected function OnGoBack(kEvent &$event) { $url = $this->Application->RecallVar('export_finish_url'); - if ($url) { + if ( $url ) { $this->Application->Redirect('external:' . $url); } @@ -158,7 +162,7 @@ * @return void * @access protected */ - protected function prepareObject(&$object, &$event) + protected function prepareObject(&$object, kEvent &$event) { } @@ -170,7 +174,7 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { $perm_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ Index: branches/5.2.x/core/units/priorites/priority_eh.php =================================================================== diff -u -N -r14851 -r14989 --- branches/5.2.x/core/units/priorites/priority_eh.php (.../priority_eh.php) (revision 14851) +++ branches/5.2.x/core/units/priorites/priority_eh.php (.../priority_eh.php) (revision 14989) @@ -1,6 +1,6 @@ permMapping = array_merge($this->permMapping, $permissions); } - function mapEvents() + /** + * Define alternative event processing method names + * + * @return void + * @see kEventHandler::$eventMethods + * @access protected + */ + protected function mapEvents() { parent::mapEvents(); Index: branches/5.2.x/core/units/category_items/category_items_event_handler.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 14628) +++ branches/5.2.x/core/units/category_items/category_items_event_handler.php (.../category_items_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ getObject(); + /* @var $object kDBList */ $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); /* @var $ml_formatter kMultiLanguage */ - - $object->addCalculatedField('CategoryName', 'c.'.$ml_formatter->LangFieldName('CachedNavbar')); + + $object->addCalculatedField('CategoryName', 'c.' . $ml_formatter->LangFieldName('CachedNavbar')); } /** @@ -41,18 +44,20 @@ */ function OnSetPrimary(&$event) { - $object =& $event->getObject( Array('skip_autoload' => true) ); + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + $ids = $this->StoreSelectedIDs($event); - if($ids) - { + if ( $ids ) { $id = array_shift($ids); $table_info = $object->getLinkedInfo(); - $this->Conn->Query('UPDATE '.$object->TableName.' SET PrimaryCat = 0 WHERE '.$table_info['ForeignKey'].' = '.$table_info['ParentId']); - $this->Conn->Query('UPDATE '.$object->TableName.' SET PrimaryCat = 1 WHERE ('.$table_info['ForeignKey'].' = '.$table_info['ParentId'].') AND (CategoryId = '.$id.')'); + $this->Conn->Query('UPDATE ' . $object->TableName . ' SET PrimaryCat = 0 WHERE ' . $table_info['ForeignKey'] . ' = ' . $table_info['ParentId']); + $this->Conn->Query('UPDATE ' . $object->TableName . ' SET PrimaryCat = 1 WHERE (' . $table_info['ForeignKey'] . ' = ' . $table_info['ParentId'] . ') AND (CategoryId = ' . $id . ')'); } - $event->setRedirectParams(Array('opener' => 's'), true); + + $event->setRedirectParams(Array ('opener' => 's'), true); } /** Index: branches/5.2.x/core/units/statistics/statistics_event_handler.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/statistics/statistics_event_handler.php (.../statistics_event_handler.php) (revision 14628) +++ branches/5.2.x/core/units/statistics/statistics_event_handler.php (.../statistics_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBList */ - if ($event->Special == 'summary') { + if ( $event->Special == 'summary' ) { $object->addFilter('summary_filter', '%1$s.AdminSummary = 1'); } $module_list = ''; foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - $module_list .= $this->Conn->qstr($module_name).','; + $module_list .= $this->Conn->qstr($module_name) . ','; } $module_list = substr($module_list, 0, -1); - $object->addFilter('status_filter', '%1$s.Module IN ('.$module_list.')'); + $object->addFilter('status_filter', '%1$s.Module IN (' . $module_list . ')'); } } \ No newline at end of file Index: branches/5.2.x/core/units/scheduled_tasks/scheduled_task_eh.php =================================================================== diff -u -N -r14880 -r14989 --- branches/5.2.x/core/units/scheduled_tasks/scheduled_task_eh.php (.../scheduled_task_eh.php) (revision 14880) +++ branches/5.2.x/core/units/scheduled_tasks/scheduled_task_eh.php (.../scheduled_task_eh.php) (revision 14989) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBList */ - if (!$this->Application->isAdminUser) { - $keywords = kUtil::unhtmlentities( trim($this->Application->GetVar('keywords')) ); - $object->addFilter('search_filter', '%1$s.SearchTerm LIKE ' . $this->Conn->qstr($keywords).' OR %1$s.SearchTerm LIKE ' . $this->Conn->qstr($keywords . '_')); + if ( !$this->Application->isAdminUser ) { + $keywords = kUtil::unhtmlentities(trim($this->Application->GetVar('keywords'))); + $object->addFilter('search_filter', '%1$s.SearchTerm LIKE ' . $this->Conn->qstr($keywords) . ' OR %1$s.SearchTerm LIKE ' . $this->Conn->qstr($keywords . '_')); } } } \ No newline at end of file Index: branches/5.2.x/core/units/content/content_eh.php =================================================================== diff -u -N -r14856 -r14989 --- branches/5.2.x/core/units/content/content_eh.php (.../content_eh.php) (revision 14856) +++ branches/5.2.x/core/units/content/content_eh.php (.../content_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ Index: branches/5.2.x/core/units/page_revisions/page_revision_eh.php =================================================================== diff -u -N -r14856 -r14989 --- branches/5.2.x/core/units/page_revisions/page_revision_eh.php (.../page_revision_eh.php) (revision 14856) +++ branches/5.2.x/core/units/page_revisions/page_revision_eh.php (.../page_revision_eh.php) (revision 14989) @@ -20,8 +20,10 @@ * Checks permissions of user * * @param kEvent $event + * @return bool + * @access public */ - function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { if ( $event->Name == 'OnItemBuild' ) { return true; @@ -53,8 +55,10 @@ * Lists all current page revisions * * @param kEvent $event + * @return void + * @access protected */ - function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); @@ -81,8 +85,10 @@ * Returns current page revision * * @param kEvent $event + * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { if ( $event->Special == 'current' ) { $page =& $this->Application->recallObject('st.-virtual'); Index: branches/5.2.x/core/units/promo_blocks/promo_block_eh.php =================================================================== diff -u -N -r14929 -r14989 --- branches/5.2.x/core/units/promo_blocks/promo_block_eh.php (.../promo_block_eh.php) (revision 14929) +++ branches/5.2.x/core/units/promo_blocks/promo_block_eh.php (.../promo_block_eh.php) (revision 14989) @@ -17,10 +17,13 @@ class PromoBlockEventHandler extends kDBEventHandler { /** - * Categories are sorted using special sorting event + * Define alternative event processing method names * + * @return void + * @see kEventHandler::$eventMethods + * @access protected */ - function mapEvents() + protected function mapEvents() { parent::mapEvents(); @@ -35,8 +38,11 @@ /** * Allows to override standard permission mapping * + * @return void + * @access protected + * @see kEventHandler::$permMapping */ - function mapPermissions() + protected function mapPermissions() { parent::mapPermissions(); @@ -90,7 +96,7 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); Index: branches/5.2.x/core/units/selectors/selectors_event_handler.php =================================================================== diff -u -N -r14699 -r14989 --- branches/5.2.x/core/units/selectors/selectors_event_handler.php (.../selectors_event_handler.php) (revision 14699) +++ branches/5.2.x/core/units/selectors/selectors_event_handler.php (.../selectors_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Array('subitem' => 'add|edit'), - 'OnMassResetToBase' => Array('subitem' => 'add|edit'), + 'OnResetToBase' => Array('subitem' => 'add|edit'), + 'OnMassResetToBase' => Array('subitem' => 'add|edit'), - 'OnOpenStyleEditor' => Array('subitem' => 'add|edit'), - 'OnSaveStyle' => Array('subitem' => 'add|edit'), - ); + 'OnOpenStyleEditor' => Array('subitem' => 'add|edit'), + 'OnSaveStyle' => Array('subitem' => 'add|edit'), + ); + $this->permMapping = array_merge($this->permMapping, $permissions); } @@ -96,12 +101,14 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ - switch ( $event->Special ) { + switch ($event->Special) { case 'base': $object->addFilter('type_filter', '%1$s.Type = 1'); break; @@ -165,12 +172,13 @@ } /** - * Gets special of main item for linking with sub-item + * Returns special of main item for linking with sub-item * * @param kEvent $event * @return string + * @access protected */ - function getMainSpecial(&$event) + protected function getMainSpecial(kEvent &$event) { return ''; } Index: branches/5.2.x/core/units/favorites/favorites_eh.php =================================================================== diff -u -N -r14675 -r14989 --- branches/5.2.x/core/units/favorites/favorites_eh.php (.../favorites_eh.php) (revision 14675) +++ branches/5.2.x/core/units/favorites/favorites_eh.php (.../favorites_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Array('subitem' => true), + 'OnFavoriteToggle' => Array ('subitem' => true), ); + $this->permMapping = array_merge($this->permMapping, $permissions); } Index: branches/5.2.x/core/units/mailing_lists/mailing_list_eh.php =================================================================== diff -u -N -r14675 -r14989 --- branches/5.2.x/core/units/mailing_lists/mailing_list_eh.php (.../mailing_list_eh.php) (revision 14675) +++ branches/5.2.x/core/units/mailing_lists/mailing_list_eh.php (.../mailing_list_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Name == 'OnLoadBlock' || $event->Name == 'OnSaveBlock') { + if ( $event->Name == 'OnLoadBlock' || $event->Name == 'OnSaveBlock' ) { return $this->Application->isAdminUser; } Index: branches/5.2.x/core/units/configuration/configuration_event_handler.php =================================================================== diff -u -N -r14955 -r14989 --- branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 14955) +++ branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ setEventParam('PermSection', $this->Application->GetVar('section')); return parent::CheckPermission($event); @@ -48,22 +55,24 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ $module = $this->Application->GetVar('module'); $section = $this->Application->GetVar('section'); - $object->addFilter('module_filter', '%1$s.ModuleOwner = '.$this->Conn->qstr($module)); - $object->addFilter('section_filter', '%1$s.Section = '.$this->Conn->qstr($section)); + $object->addFilter('module_filter', '%1$s.ModuleOwner = ' . $this->Conn->qstr($module)); + $object->addFilter('section_filter', '%1$s.Section = ' . $this->Conn->qstr($section)); - if (!$this->Application->ConfigValue('AllowAdminConsoleInterfaceChange')) { + if ( !$this->Application->ConfigValue('AllowAdminConsoleInterfaceChange') ) { $object->addFilter('interface_change_filter', '%1$s.VariableName <> "AdminConsoleInterface"'); } - if (defined('IS_INSTALL') && IS_INSTALL) { + if ( defined('IS_INSTALL') && IS_INSTALL ) { $object->addFilter('install_filter', '%1$s.Install = 1'); } Index: branches/5.2.x/core/units/forms/form_fields/form_field_eh.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/forms/form_fields/form_field_eh.php (.../form_field_eh.php) (revision 14628) +++ branches/5.2.x/core/units/forms/form_fields/form_field_eh.php (.../form_field_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Special == 'import' || $event->Special == 'export') { + if ( $event->Special == 'import' || $event->Special == 'export' ) { $this->RemoveRequiredFields($object); - $object->setRequired( Array ('LangFile', 'PhraseType', 'Module') ); + $object->setRequired(Array ('LangFile', 'PhraseType', 'Module')); // allow multiple phrase types to be selected during import/export $object->SetFieldOption('PhraseType', 'type', 'string'); @@ -45,20 +45,27 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { - if (!$this->Application->isAdmin && $this->Application->isDebugMode(false) && kUtil::constOn('DBG_PHRASES')) { + if ( !$this->Application->isAdmin && $this->Application->isDebugMode(false) && kUtil::constOn('DBG_PHRASES') ) { $allow_events = Array ('OnCreate', 'OnUpdate'); - if (in_array($event->Name, $allow_events)) { + if ( in_array($event->Name, $allow_events) ) { return true; } } return parent::CheckPermission($event); } - function mapPermissions() + /** + * Allows to override standard permission mapping + * + * @return void + * @access protected + * @see kEventHandler::$permMapping + */ + protected function mapPermissions() { parent::mapPermissions(); Index: branches/5.2.x/core/units/reviews/reviews_event_handler.php =================================================================== diff -u -N -r14851 -r14989 --- branches/5.2.x/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 14851) +++ branches/5.2.x/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Special == 'product' && !$this->Application->isAdmin) { + if ( $event->Special == 'product' && !$this->Application->isAdmin ) { // rev.product should auto-link return ''; } @@ -39,9 +40,9 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { - if ($event->Name == 'OnAddReview' || $event->Name == 'OnCreate') { + if ( $event->Name == 'OnAddReview' || $event->Name == 'OnCreate' ) { $perm_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ @@ -53,9 +54,10 @@ $res = $this->Application->CheckPermission($perm_name, 0, $main_object->GetDBField('CategoryId')) || $this->Application->CheckPermission($perm_name.'.PENDING', 0, $main_object->GetDBField('CategoryId')); - if (!$res) { + if ( !$res ) { $event->status = kEvent::erPERM_FAIL; } + return $res; } @@ -65,15 +67,15 @@ $perm_category = $this->_getReviewCategory($event); - if (in_array($event->Name, $check_events)) { + if ( in_array($event->Name, $check_events) ) { // check for PRODUCT.VIEW permission $perm_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ $perm_prefix = $this->getPermPrefix($event); - if ($perm_category === false) { + if ( $perm_category === false ) { // no item id present -> allow return true; } @@ -173,16 +175,18 @@ * @access protected * @see OnListBuild */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ if ( !$this->Application->isAdminUser ) { $object->addFilter('active', '%1$s.Status = ' . STATUS_ACTIVE); } - switch ( $event->Special ) { + switch ($event->Special) { case 'showall': $object->clearFilters(); break; Index: branches/5.2.x/core/units/languages/languages_event_handler.php =================================================================== diff -u -N -r14968 -r14989 --- branches/5.2.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 14968) +++ branches/5.2.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Array('self' => true), - 'OnSetPrimary' => Array('self' => 'advanced:set_primary|add|edit'), - 'OnImportLanguage' => Array('self' => 'advanced:import'), - 'OnExportLanguage' => Array('self' => 'advanced:export'), - 'OnExportProgress' => Array('self' => 'advanced:export'), + + $permissions = Array ( + 'OnChangeLanguage' => Array ('self' => true), + 'OnSetPrimary' => Array ('self' => 'advanced:set_primary|add|edit'), + 'OnImportLanguage' => Array ('self' => 'advanced:import'), + 'OnExportLanguage' => Array ('self' => 'advanced:export'), + 'OnExportProgress' => Array ('self' => 'advanced:export'), 'OnReflectMultiLingualFields' => Array ('self' => 'view'), 'OnSynchronizeLanguages' => Array ('self' => 'edit'), ); @@ -43,9 +47,9 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { - if ($event->Name == 'OnItemBuild') { + if ( $event->Name == 'OnItemBuild' ) { // check permission without using $event->getSection(), // so first cache rebuild won't lead to "ldefault_Name" field being used return true; @@ -58,10 +62,12 @@ * Allows to get primary language object * * @param kEvent $event + * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { - if ($event->Special == 'primary') { + if ( $event->Special == 'primary' ) { return $this->Application->GetDefaultLanguageId(); } @@ -236,17 +242,19 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ - if (in_array($event->Special, Array ('enabled', 'selected', 'available'))) { + if ( in_array($event->Special, Array ('enabled', 'selected', 'available')) ) { $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE); } // site domain language picker - if ($event->Special == 'selected' || $event->Special == 'available') { + if ( $event->Special == 'selected' || $event->Special == 'available' ) { $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper'); /* @var $edit_picker_helper EditPickerHelper */ @@ -256,7 +264,7 @@ // apply domain-based language filtering $languages = $this->Application->siteDomainField('Languages'); - if (strlen($languages)) { + if ( strlen($languages) ) { $languages = explode('|', substr($languages, 1, -1)); $object->addFilter('domain_filter', '%1$s.LanguageId IN (' . implode(',', $languages) . ')'); } @@ -552,8 +560,10 @@ * Returns to previous template in opener stack * * @param kEvent $event + * @return void + * @access protected */ - function OnGoBack(&$event) + protected function OnGoBack(kEvent &$event) { $event->SetRedirectParam('opener', 'u'); } Index: branches/5.2.x/core/units/helpers/permissions_helper.php =================================================================== diff -u -N -r14870 -r14989 --- branches/5.2.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 14870) +++ branches/5.2.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 14989) @@ -1,6 +1,6 @@ getEventParam('top_prefix'); - $event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); + $event_handler =& $this->Application->recallObject($event->Prefix . '_EventHandler'); /* @var $event_handler kCatDBEventHandler */ $raise_warnings = $event->getEventParam('raise_warnings'); $event->setEventParam('raise_warnings', 0); - if ($event->Prefix != $top_prefix) { - $top_event = new kEvent($top_prefix.':'.$event->Name); + if ( $event->Prefix != $top_prefix ) { + $top_event = new kEvent($top_prefix . ':' . $event->Name); $id = $event_handler->getPassedID($top_event); } else { @@ -200,19 +200,19 @@ $event->setEventParam('raise_warnings', $raise_warnings); $owner_id = USER_ROOT; // owner is root if not detected - if (!$id) { + if ( !$id ) { // item being created -> check by current (before editing started, saved in OnPreCreate event) category permissions // note: category in session is placed on catalog data import start $category_id = $this->Application->isAdmin ? $this->Application->RecallVar('m_cat_id') : $this->Application->GetVar('m_cat_id'); } - elseif ($top_prefix == 'c' || $top_prefix == 'st') { + elseif ( $top_prefix == 'c' || $top_prefix == 'st' ) { $category_id = $id; } else { // item being edited -> check by it's primary category permissions $items_info = $this->GetCategoryItemData($top_prefix, $id); - if ($items_info) { + if ( $items_info ) { $category_id = $items_info[$id]['CategoryId']; $owner_id = $items_info[$id]['CreatedById']; } @@ -224,7 +224,7 @@ // specific permission check for pending & owner permissions: begin $uploader_events = Array ('OnUploadFile', 'OnDeleteFile', 'OnViewFile'); - if (in_array($event->Name, $uploader_events)) { + if ( in_array($event->Name, $uploader_events) ) { // don't recall target object during uploader-related, because OnItemLoad will use incorrect // $user_id in Firefox (during Flash problems session will be used from Internet Exploere) $new_item = false; @@ -234,36 +234,36 @@ $check_status = $this->checkCombinedPermissions($event, $owner_id, (int)$category_id, $new_item); } - if (isset($check_status)) { + if ( isset($check_status) ) { return $this->finalizePermissionCheck($event, $check_status); } // specific permission check for pending & owner permissions: end $perm_status = false; $check_perms = $this->getPermissionByEvent($event, $event_perm_mapping); - if ($check_perms === true) { + if ( $check_perms === true ) { // event is defined in mapping but is not checked by permissions return true; } $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); foreach ($check_perms as $perm_name) { // check if at least one of required permissions is set - if (!isset($perm_mapping[$perm_name])) { + if ( !isset($perm_mapping[$perm_name]) ) { // not mapped permission (e.g. advanced:approve) -> skip continue; } - if ($perm_name == 'debug' && $this->Application->isDebugMode(false)) { + if ( $perm_name == 'debug' && $this->Application->isDebugMode(false) ) { // universal "debug" permission return true; } - $perm_name = $item_prefix.'.'.$perm_mapping[$perm_name]; + $perm_name = $item_prefix . '.' . $perm_mapping[$perm_name]; $perm_status = $this->CheckPermission($perm_name, 0, (int)$category_id); - if ($perm_status) { + if ( $perm_status ) { return $perm_status; } } @@ -437,9 +437,9 @@ } elseif ($perm_event) { // check permission by event name - list ($prefix, $event) = explode(':', $perm_event); + list ($prefix, ) = explode(':', $perm_event); - $event_handler =& $this->Application->recallObject($prefix.'_EventHandler'); + $event_handler =& $this->Application->recallObject($prefix . '_EventHandler'); /* @var $event_handler kEventHandler */ return $event_handler->CheckPermission( new kEvent($perm_event) ); Index: branches/5.2.x/core/units/forms/form_submissions/form_submissions_eh.php =================================================================== diff -u -N -r14955 -r14989 --- branches/5.2.x/core/units/forms/form_submissions/form_submissions_eh.php (.../form_submissions_eh.php) (revision 14955) +++ branches/5.2.x/core/units/forms/form_submissions/form_submissions_eh.php (.../form_submissions_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Application->isAdmin) { - if ($event->Name == 'OnCreate') { + if ( !$this->Application->isAdmin ) { + if ( $event->Name == 'OnCreate' ) { // anybody can submit forms on front return true; } @@ -43,12 +43,15 @@ /** * Always allow to view feedback form * + * @return void + * @access protected + * @see kEventHandler::$permMapping */ - function mapPermissions() + protected function mapPermissions() { parent::mapPermissions(); - $permissions = Array( + $permissions = Array ( 'OnItemBuild' => Array ('self' => true), 'OnEdit' => Array ('self' => 'view', 'subitem' => 'view'), ); @@ -178,8 +181,10 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ @@ -191,15 +196,16 @@ * * @param kEvent $event * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { - if ($event->Special == 'last') { + if ( $event->Special == 'last' ) { // allow user to see his last submitted form return $this->Application->RecallVar('last_submission_id'); } - if ($this->Application->isAdminUser) { + if ( $this->Application->isAdminUser ) { // don't check ids in admin return parent::getPassedID($event); } Index: branches/5.2.x/core/units/user_profile/user_profile_eh.php =================================================================== diff -u -N -r14955 -r14989 --- branches/5.2.x/core/units/user_profile/user_profile_eh.php (.../user_profile_eh.php) (revision 14955) +++ branches/5.2.x/core/units/user_profile/user_profile_eh.php (.../user_profile_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Array('subitem' => true), - 'OnUpdate' => Array('subitem' => true), + 'OnItemBuild' => Array ('subitem' => true), + 'OnUpdate' => Array ('subitem' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); Index: branches/5.2.x/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r14879 -r14989 --- branches/5.2.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 14879) +++ branches/5.2.x/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 14989) @@ -1,6 +1,6 @@ array('self' => true), - 'OnClosePopup' => array('self' => true), - 'OnSaveSetting' => array('self' => true), - 'OnDropTempTablesByWID' => Array('self' => true), + $permissions = Array ( + 'OnSaveColumns' => Array ('self' => true), + 'OnClosePopup' => Array ('self' => true), + 'OnSaveSetting' => Array ('self' => true), + 'OnDropTempTablesByWID' => Array ('self' => true), ); + $this->permMapping = array_merge($this->permMapping, $permissions); } @@ -36,7 +44,7 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { $perm_value = null; Index: branches/5.2.x/core/units/fck/fck_eh.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 14628) +++ branches/5.2.x/core/units/fck/fck_eh.php (.../fck_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Application->isAdminUser) { + if ( $this->Application->isAdminUser ) { // this limits all event execution only to logged-in users in admin return true; } @@ -196,7 +196,7 @@ /** * Uploads a file from FCK file browser - * + * * @param kEvent $event * @return void * @access protected Index: branches/5.2.x/core/kernel/event_manager.php =================================================================== diff -u -N -r14879 -r14989 --- branches/5.2.x/core/kernel/event_manager.php (.../event_manager.php) (revision 14879) +++ branches/5.2.x/core/kernel/event_manager.php (.../event_manager.php) (revision 14989) @@ -1,6 +1,6 @@ isRecursion($event) || !$this->verifyEventPrefix($event) ) { - return ; + return; } $this->pushEvent($event); - if (!$event->SkipBeforeHooks) { + if ( !$event->SkipBeforeHooks ) { $this->Hooks->runHooks($event, hBEFORE); - if ($event->status == kEvent::erFATAL) { - return ; + if ( $event->status == kEvent::erFATAL ) { + return; } } @@ -262,11 +262,11 @@ $event_handler->processEvent($event); - if ($event->status == kEvent::erFATAL) { - return ; + if ( $event->status == kEvent::erFATAL ) { + return; } - if (!$event->SkipAfterHooks) { + if ( !$event->SkipAfterHooks ) { $this->Hooks->runHooks($event, hAFTER); } Index: branches/5.2.x/core/units/translator/translator_event_handler.php =================================================================== diff -u -N -r14675 -r14989 --- branches/5.2.x/core/units/translator/translator_event_handler.php (.../translator_event_handler.php) (revision 14675) +++ branches/5.2.x/core/units/translator/translator_event_handler.php (.../translator_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Array('subitem' => 'add|edit'), - 'OnSaveAndClose' => Array('subitem' => 'add|edit'), - ); + 'OnChangeLanguage' => Array('subitem' => 'add|edit'), + 'OnSaveAndClose' => Array('subitem' => 'add|edit'), + ); + $this->permMapping = array_merge($this->permMapping, $permissions); } @@ -37,12 +42,13 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { - list($prefix, $field) = $this->getPrefixAndField($event); + list($prefix, ) = $this->getPrefixAndField($event); $top_prefix = $this->Application->GetTopmostPrefix($prefix, true); $event->setEventParam('top_prefix', $top_prefix); + return parent::CheckPermission($event); } Index: branches/5.2.x/core/units/relationship/relationship_event_handler.php =================================================================== diff -u -N -r14680 -r14989 --- branches/5.2.x/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 14680) +++ branches/5.2.x/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Application->GetVar('module'); - if (strlen($module) > 0) { + if ( strlen($module) > 0 ) { // checking permission when lising module email events in separate section $module = explode(':', $module, 2); - if (count($module) == 1) { + if ( count($module) == 1 ) { $main_prefix = $this->Application->findModule('Name', $module[0], 'Var'); } else { - $exceptions = Array('Category' => 'c', 'Users' => 'u'); - $main_prefix = $exceptions[ $module[1] ]; + $exceptions = Array ('Category' => 'c', 'Users' => 'u'); + $main_prefix = $exceptions[$module[1]]; } - $section = $this->Application->getUnitOption($main_prefix.'.email', 'PermSection'); + $section = $this->Application->getUnitOption($main_prefix . '.email', 'PermSection'); $event->setEventParam('PermSection', $section); } @@ -82,17 +85,19 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ - if ($event->Special == 'module') { + if ( $event->Special == 'module' ) { $module = $this->Application->GetVar('module'); - $object->addFilter('module_filter', '%1$s.Module = '.$this->Conn->qstr($module)); + $object->addFilter('module_filter', '%1$s.Module = ' . $this->Conn->qstr($module)); } - if (!$event->Special && !$this->Application->isDebugMode()) { + if ( !$event->Special && !$this->Application->isDebugMode() ) { // no special $object->addFilter('enabled_filter', '%1$s.Enabled <> ' . STATUS_DISABLED); } Index: branches/5.2.x/core/units/groups/groups_event_handler.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/groups/groups_event_handler.php (.../groups_event_handler.php) (revision 14628) +++ branches/5.2.x/core/units/groups/groups_event_handler.php (.../groups_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBList */ switch ($event->Special) { case 'user': $user_id = $this->Application->GetVar('u_id'); - if ($user_id !== false) { + if ( $user_id !== false ) { // show only groups, that user doesn't belong to - $table_name = $this->Application->GetTempName(TABLE_PREFIX.'UserGroup', 'prefix:u'); + $table_name = $this->Application->GetTempName(TABLE_PREFIX . 'UserGroup', 'prefix:u'); $sql = 'SELECT GroupId FROM ' . $table_name . ' @@ -46,12 +48,12 @@ array_push($group_ids, $this->Application->ConfigValue('User_GuestGroup')); // Guest array_push($group_ids, $this->Application->ConfigValue('User_LoggedInGroup')); // Everyone - $object->addFilter('already_member_filter', '%1$s.GroupId NOT IN ('.implode(',', $group_ids).')'); + $object->addFilter('already_member_filter', '%1$s.GroupId NOT IN (' . implode(',', $group_ids) . ')'); } break; } } - + /** * Refreshes left tree on save * @@ -64,5 +66,5 @@ parent::OnSave($event); $this->Application->StoreVar('refresh_tree', 1); - } + } } \ No newline at end of file Index: branches/5.2.x/core/units/visits/visits_event_handler.php =================================================================== diff -u -N -r14675 -r14989 --- branches/5.2.x/core/units/visits/visits_event_handler.php (.../visits_event_handler.php) (revision 14675) +++ branches/5.2.x/core/units/visits/visits_event_handler.php (.../visits_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Array('self' => true), + + $permissions = Array ( + 'OnItemBuild' => Array ('self' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); @@ -67,8 +71,10 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ @@ -101,20 +107,19 @@ * @return void * @access protected */ - protected function prepareObject(&$object, &$event) + protected function prepareObject(&$object, kEvent &$event) { $types = $event->getEventParam('types'); - if(method_exists($object, 'AddGroupByField')) - { - if( ($types == 'myvisitors' || !$types) && $object->Special == 'incommerce') - { + + if ( method_exists($object, 'AddGroupByField') ) { + if ( (!$types || $types == 'myvisitors') && $object->Special == 'incommerce' ) { $object->addCalculatedField('OrderTotalAmountSum', 'SUM(IF(ord.Status = 4, ord.SubTotal+ord.ShippingCost+ord.VAT, 0))'); $object->addCalculatedField('OrderAffiliateCommissionSum', 'SUM( IF(ord.Status = 4,ord.AffiliateCommission,0))'); $object->addCalculatedField('OrderCountByVisit', 'SUM( IF(ord.Status = 4, 1, 0) )'); } - if (!$types){ - $object->AddGroupByField('%1$s.VisitId'); + if ( !$types ) { + $object->AddGroupByField('%1$s.VisitId'); } } } Index: branches/5.2.x/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r14851 -r14989 --- branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 14851) +++ branches/5.2.x/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Name == 'OnResetCMSMenuCache') { + if ( $event->Name == 'OnResetCMSMenuCache' ) { // events from "Tools -> System Tools" section are controlled via that section "edit" permission $perm_helper =& $this->Application->recallObject('PermissionsHelper'); @@ -75,27 +78,27 @@ return $perm_helper->finalizePermissionCheck($event, $perm_value); } - if (!$this->Application->isAdmin) { - if ($event->Name == 'OnSetSortingDirect') { + if ( !$this->Application->isAdmin ) { + if ( $event->Name == 'OnSetSortingDirect' ) { // allow sorting on front event without view permission return true; } - if ($event->Name == 'OnItemBuild') { + if ( $event->Name == 'OnItemBuild' ) { $category_id = $this->getPassedID($event); - if ($category_id == 0) { + if ( $category_id == 0 ) { return true; } } } - if (in_array($event->Name, $this->_getMassPermissionEvents())) { + if ( in_array($event->Name, $this->_getMassPermissionEvents()) ) { $items = $this->_getPermissionCheckInfo($event); $perm_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ - if (($event->Name == 'OnSave') && array_key_exists(0, $items)) { + if ( ($event->Name == 'OnSave') && array_key_exists(0, $items) ) { // adding new item (ID = 0) $perm_value = $perm_helper->AddCheckPermission($items[0]['ParentId'], $event->Prefix) > 0; } @@ -104,12 +107,12 @@ $ids = Array (); $check_method = in_array($event->Name, Array ('OnMassDelete', 'OnCut')) ? 'DeleteCheckPermission' : 'ModifyCheckPermission'; foreach ($items as $item_id => $item_data) { - if ($perm_helper->$check_method($item_data['CreatedById'], $item_data['ParentId'], $event->Prefix) > 0) { + if ( $perm_helper->$check_method($item_data['CreatedById'], $item_data['ParentId'], $event->Prefix) > 0 ) { $ids[] = $item_id; } } - if (!$ids) { + if ( !$ids ) { // no items left for editing -> no permission return $perm_helper->finalizePermissionCheck($event, false); } @@ -121,7 +124,7 @@ return $perm_helper->finalizePermissionCheck($event, $perm_value); } - if ($event->Name == 'OnRecalculatePriorities') { + if ( $event->Name == 'OnRecalculatePriorities' ) { $perm_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ @@ -130,7 +133,7 @@ return $perm_helper->AddCheckPermission($category_id, $event->Prefix) || $perm_helper->ModifyCheckPermission(0, $category_id, $event->Prefix); } - if ($event->Name == 'OnPasteClipboard') { + if ( $event->Name == 'OnPasteClipboard' ) { // forces permission check to work by current category for "Paste In Category" operation $category_id = $this->Application->GetVar('m_cat_id'); $this->Application->SetVar('c_id', $category_id); @@ -264,7 +267,7 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); @@ -564,18 +567,23 @@ } /** - * Enter description here... + * Returns ID of current item to be edited + * by checking ID passed in get/post as prefix_id + * or by looking at first from selected ids, stored. + * Returned id is also stored in Session in case + * it was explicitly passed as get/post * * @param kEvent $event * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { - if (($event->Special == 'page') || ($event->Special == '-virtual') || ($event->Prefix == 'st')) { + if ( ($event->Special == 'page') || ($event->Special == '-virtual') || ($event->Prefix == 'st') ) { return $this->_getPassedStructureID($event); } - if ($this->Application->isAdmin) { + if ( $this->Application->isAdmin ) { return parent::getPassedID($event); } @@ -671,20 +679,23 @@ * @return void * @access protected */ - protected function prepareObject(&$object, &$event) + protected function prepareObject(&$object, kEvent &$event) { - if ($event->Special != '-virtual') { - $object =& $event->getObject( Array('skip_autoload' => true) ); - - $object->addCalculatedField( - 'IsNew', - ' IF(%1$s.NewItem = 2, - IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '. - $this->Application->ConfigValue('Category_DaysNew'). - '*3600*24), 1, 0), - %1$s.NewItem - )'); + if ( $event->Special == '-virtual' ) { + return; } + + $object =& $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + + $object->addCalculatedField( + 'IsNew', + ' IF(%1$s.NewItem = 2, + IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '. + $this->Application->ConfigValue('Category_DaysNew'). + '*3600*24), 1, 0), + %1$s.NewItem + )'); } /** @@ -1505,8 +1516,9 @@ * * @param kEvent $event * @return bool + * @access protected */ - function checkItemStatus(&$event) + protected function checkItemStatus(kEvent &$event) { $object =& $event->getObject(); /* @var $object kDBItem */ @@ -2515,7 +2527,7 @@ * @return void * @access protected */ - protected function LoadItem(&$event) + protected function LoadItem(kEvent &$event) { if ( $event->Special != '-virtual' ) { parent::LoadItem($event); Index: branches/5.2.x/core/units/logs/change_logs/change_log_eh.php =================================================================== diff -u -N -r14639 -r14989 --- branches/5.2.x/core/units/logs/change_logs/change_log_eh.php (.../change_log_eh.php) (revision 14639) +++ branches/5.2.x/core/units/logs/change_logs/change_log_eh.php (.../change_log_eh.php) (revision 14989) @@ -1,6 +1,6 @@ SetVar('m_theme', $theme_id); - $this->SetVar('theme.current_id', $theme_id); // KOSTJA: this is to fool theme' getPassedId + $this->SetVar('theme.current_id', $theme_id); // KOSTJA: this is to fool theme' getPassedID $theme =& $this->recallObject('theme.current'); /* @var $theme ThemeItem */ Index: branches/5.2.x/core/kernel/db/cat_event_handler.php =================================================================== diff -u -N -r14955 -r14989 --- branches/5.2.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 14955) +++ branches/5.2.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Array ('self' => 'add|edit|advanced:import'), 'OnResetSettings' => Array ('self' => 'add|edit|advanced:import'), @@ -47,7 +51,7 @@ * @return void * @access protected */ - function LoadItem(&$event) + protected function LoadItem(kEvent &$event) { $object =& $event->getObject(); /* @var $object kDBItem */ @@ -78,27 +82,27 @@ * @return bool * @access public */ - public function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { - if (!$this->Application->isAdmin) { - if ($event->Name == 'OnSetSortingDirect') { + if ( !$this->Application->isAdmin ) { + if ( $event->Name == 'OnSetSortingDirect' ) { // allow sorting on front event without view permission return true; } } - if ($event->Name == 'OnExport') { + if ( $event->Name == 'OnExport' ) { // save category_id before doing export $this->Application->LinkVar('m_cat_id'); } - if (in_array($event->Name, $this->_getMassPermissionEvents())) { + if ( in_array($event->Name, $this->_getMassPermissionEvents()) ) { $items = $this->_getPermissionCheckInfo($event); $perm_helper =& $this->Application->recallObject('PermissionsHelper'); /* @var $perm_helper kPermissionsHelper */ - if (($event->Name == 'OnSave') && array_key_exists(0, $items)) { + if ( ($event->Name == 'OnSave') && array_key_exists(0, $items) ) { // adding new item (ID = 0) $perm_value = $perm_helper->AddCheckPermission($items[0]['CategoryId'], $event->Prefix) > 0; } @@ -107,12 +111,12 @@ $ids = Array (); $check_method = in_array($event->Name, Array ('OnMassDelete', 'OnCut')) ? 'DeleteCheckPermission' : 'ModifyCheckPermission'; foreach ($items as $item_id => $item_data) { - if ($perm_helper->$check_method($item_data['CreatedById'], $item_data['CategoryId'], $event->Prefix) > 0) { + if ( $perm_helper->$check_method($item_data['CreatedById'], $item_data['CategoryId'], $event->Prefix) > 0 ) { $ids[] = $item_id; } } - if (!$ids) { + if ( !$ids ) { // no items left for editing -> no permission return $perm_helper->finalizePermissionCheck($event, false); } @@ -125,13 +129,13 @@ } $export_events = Array ('OnSaveSettings', 'OnResetSettings', 'OnExportBegin'); - if (in_array($event->Name, $export_events)) { + if ( in_array($event->Name, $export_events) ) { // when import settings before selecting target import category return $this->Application->CheckPermission('in-portal:main_import.view'); } - if ($event->Name == 'OnProcessSelected') { - if ($this->Application->RecallVar('dst_field') == 'ImportCategory') { + if ( $event->Name == 'OnProcessSelected' ) { + if ( $this->Application->RecallVar('dst_field') == 'ImportCategory' ) { // when selecting target import category return $this->Application->CheckPermission('in-portal:main_import.view'); } @@ -587,7 +591,7 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { parent::SetCustomQuery($event); @@ -743,13 +747,12 @@ * @return void * @access protected */ - protected function prepareObject(&$object, &$event) + protected function prepareObject(&$object, kEvent &$event) { $this->prepareItemStatuses($event); + $object->addCalculatedField('CachedNavbar', 'l' . $this->Application->GetVar('m_lang') . '_CachedNavbar'); - $object->addCalculatedField('CachedNavbar', 'l'.$this->Application->GetVar('m_lang').'_CachedNavbar'); - - if ($event->Special == 'export' || $event->Special == 'import') { + if ( $event->Special == 'export' || $event->Special == 'import' ) { $export_helper =& $this->Application->recallObject('CatItemExportHelper'); /* @var $export_helper kCatDBItemExportHelper */ @@ -2639,8 +2642,9 @@ * * @param kEvent $event * @return bool + * @access protected */ - function checkItemStatus(&$event) + protected function checkItemStatus(kEvent &$event) { $object =& $event->getObject(); /* @var $object kDBItem */ Index: branches/5.2.x/core/units/forms/drafts/draft_eh.php =================================================================== diff -u -N -r14628 -r14989 --- branches/5.2.x/core/units/forms/drafts/draft_eh.php (.../draft_eh.php) (revision 14628) +++ branches/5.2.x/core/units/forms/drafts/draft_eh.php (.../draft_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Special == 'related') { + if ( $event->Special == 'related' ) { $form_submission =& $this->Application->recallObject('formsubs'); /* @var $form_submission kDBItem */ Index: branches/5.2.x/core/units/spam_reports/spam_report_eh.php =================================================================== diff -u -N -r14789 -r14989 --- branches/5.2.x/core/units/spam_reports/spam_report_eh.php (.../spam_report_eh.php) (revision 14789) +++ branches/5.2.x/core/units/spam_reports/spam_report_eh.php (.../spam_report_eh.php) (revision 14989) @@ -19,8 +19,11 @@ /** * Allows to override standard permission mapping * + * @return void + * @access protected + * @see kEventHandler::$permMapping */ - function mapPermissions() + protected function mapPermissions() { parent::mapPermissions(); Index: branches/5.2.x/core/units/site_domains/site_domain_eh.php =================================================================== diff -u -N -r14941 -r14989 --- branches/5.2.x/core/units/site_domains/site_domain_eh.php (.../site_domain_eh.php) (revision 14941) +++ branches/5.2.x/core/units/site_domains/site_domain_eh.php (.../site_domain_eh.php) (revision 14989) @@ -1,6 +1,6 @@ Name == 'OnItemBuild') { + if ( $event->Name == 'OnItemBuild' ) { // check permission without using $event->getSection(), // so first cache rebuild won't lead to "ldefault_Name" field being used return true; @@ -38,15 +38,17 @@ * Returns ID of site domain, that matches current url * * @param kEvent $event + * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { - if ($event->Special == 'current') { - if ($this->Application->isAdmin) { + if ( $event->Special == 'current' ) { + if ( $this->Application->isAdmin ) { $event->setEventParam('raise_warnings', 0); } else { - if (PROTOCOL == 'https://') { + if ( PROTOCOL == 'https://' ) { return $this->querySiteDomain('SSLUrl', rtrim($this->Application->BaseURL(), '/')); } @@ -103,8 +105,10 @@ * Load item if id is available * * @param kEvent $event + * @return void + * @access protected */ - function LoadItem(&$event) + protected function LoadItem(kEvent &$event) { if ( $this->Application->isAdmin ) { // don't load domain data from cache Index: branches/5.2.x/core/units/country_states/country_state_eh.php =================================================================== diff -u -N -r14820 -r14989 --- branches/5.2.x/core/units/country_states/country_state_eh.php (.../country_state_eh.php) (revision 14820) +++ branches/5.2.x/core/units/country_states/country_state_eh.php (.../country_state_eh.php) (revision 14989) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBList */ - if (($event->Special == 'selected') || ($event->Special == 'available')) { + if ( ($event->Special == 'selected') || ($event->Special == 'available') ) { $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper'); /* @var $edit_picker_helper EditPickerHelper */ Index: branches/5.2.x/core/units/permissions/permissions_event_handler.php =================================================================== diff -u -N -r14675 -r14989 --- branches/5.2.x/core/units/permissions/permissions_event_handler.php (.../permissions_event_handler.php) (revision 14675) +++ branches/5.2.x/core/units/permissions/permissions_event_handler.php (.../permissions_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Array('subitem' => 'advanced:manage_permissions'), - ); + + $permissions = Array ( + 'OnGroupSavePermissions' => Array ('subitem' => 'advanced:manage_permissions'), + ); + $this->permMapping = array_merge($this->permMapping, $permissions); } Index: branches/5.2.x/core/units/config_search/config_search_event_handler.php =================================================================== diff -u -N -r14955 -r14989 --- branches/5.2.x/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 14955) +++ branches/5.2.x/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ Application->GetVar('module'); $main_prefix = $this->Application->findModule('Name', $module, 'Var'); @@ -41,14 +41,16 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { + parent::SetCustomQuery($event); + $object =& $event->getObject(); /* @var $object kDBList */ // show only items that belong to selected module $module = $this->Application->GetVar('module'); - $object->addFilter('module_filter', '%1$s.ModuleName = '.$this->Conn->qstr($module)); + $object->addFilter('module_filter', '%1$s.ModuleName = ' . $this->Conn->qstr($module)); // don't show disabled search items $object->addFilter('active_filter', '%1$s.SimpleSearch <> -1'); Index: branches/5.2.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r14974 -r14989 --- branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 14974) +++ branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 14989) @@ -1,6 +1,6 @@ getPrefixSpecial(true) instead of * $event->getPrefixSpecial() as usual. This is due PHP * is converting "." symbols in variable names during * submit info "_". $event->getPrefixSpecial optional - * 1st parameter returns correct corrent Prefix_Special - * for variables beeing submitted such way (e.g. variable + * 1st parameter returns correct current Prefix_Special + * for variables being submitted such way (e.g. variable * name that will be converted by PHP: "users.read_only_id" * will be submitted as "users_read_only_id". * @@ -51,40 +51,40 @@ * @return bool * @access public */ - function CheckPermission(&$event) + public function CheckPermission(kEvent &$event) { $section = $event->getSection(); - if (!$this->Application->isAdmin) { - $allow_events = Array('OnSearch', 'OnSearchReset', 'OnNew'); - if (in_array($event->Name, $allow_events)) { + if ( !$this->Application->isAdmin ) { + $allow_events = Array ('OnSearch', 'OnSearchReset', 'OnNew'); + if ( in_array($event->Name, $allow_events) ) { // allow search on front return true; } } - elseif (($event->Name == 'OnPreSaveAndChangeLanguage') && !$this->UseTempTables($event)) { + elseif ( ($event->Name == 'OnPreSaveAndChangeLanguage') && !$this->UseTempTables($event) ) { // allow changing language in grids, when not in editing mode return $this->Application->CheckPermission($section . '.view', 1); } - if (!preg_match('/^CATEGORY:(.*)/', $section)) { + if ( !preg_match('/^CATEGORY:(.*)/', $section) ) { // only if not category item events - if ((substr($event->Name, 0, 9) == 'OnPreSave') || ($event->Name == 'OnSave')) { - if ($this->isNewItemCreate($event)) { - return $this->Application->CheckPermission($section.'.add', 1); + if ( (substr($event->Name, 0, 9) == 'OnPreSave') || ($event->Name == 'OnSave') ) { + if ( $this->isNewItemCreate($event) ) { + return $this->Application->CheckPermission($section . '.add', 1); } else { - return $this->Application->CheckPermission($section.'.add', 1) || $this->Application->CheckPermission($section.'.edit', 1); + return $this->Application->CheckPermission($section . '.add', 1) || $this->Application->CheckPermission($section . '.edit', 1); } } } - if ($event->Name == 'OnPreCreate') { + if ( $event->Name == 'OnPreCreate' ) { // save category_id before item create (for item category selector not to destroy permission checking category) $this->Application->LinkVar('m_cat_id'); } - if ($event->Name == 'OnSaveWidths') { + if ( $event->Name == 'OnSaveWidths' ) { return $this->Application->isAdminUser; } @@ -94,96 +94,108 @@ /** * Allows to override standard permission mapping * + * @return void + * @access protected + * @see kEventHandler::$permMapping */ - function mapPermissions() + protected function mapPermissions() { parent::mapPermissions(); - $permissions = Array( - 'OnLoad' => Array('self' => 'view', 'subitem' => 'view'), - 'OnItemBuild' => Array('self' => 'view', 'subitem' => 'view'), - 'OnSuggestValues' => Array('self' => 'view', 'subitem' => 'view'), - 'OnBuild' => Array('self' => true), + $permissions = Array ( + 'OnLoad' => Array ('self' => 'view', 'subitem' => 'view'), + 'OnItemBuild' => Array ('self' => 'view', 'subitem' => 'view'), + 'OnSuggestValues' => Array ('self' => 'view', 'subitem' => 'view'), - 'OnNew' => Array('self' => 'add', 'subitem' => 'add|edit'), - 'OnCreate' => Array('self' => 'add', 'subitem' => 'add|edit'), - 'OnUpdate' => Array('self' => 'edit', 'subitem' => 'add|edit'), - 'OnSetPrimary' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), - 'OnDelete' => Array('self' => 'delete', 'subitem' => 'add|edit'), - 'OnDeleteAll' => Array('self' => 'delete', 'subitem' => 'add|edit'), - 'OnMassDelete' => Array('self' => 'delete', 'subitem' => 'add|edit'), - 'OnMassClone' => Array('self' => 'add', 'subitem' => 'add|edit'), + 'OnBuild' => Array ('self' => true), - 'OnCut' => array('self'=>'edit', 'subitem' => 'edit'), - 'OnCopy' => array('self'=>'edit', 'subitem' => 'edit'), - 'OnPaste' => array('self'=>'edit', 'subitem' => 'edit'), + 'OnNew' => Array ('self' => 'add', 'subitem' => 'add|edit'), + 'OnCreate' => Array ('self' => 'add', 'subitem' => 'add|edit'), + 'OnUpdate' => Array ('self' => 'edit', 'subitem' => 'add|edit'), + 'OnSetPrimary' => Array ('self' => 'add|edit', 'subitem' => 'add|edit'), + 'OnDelete' => Array ('self' => 'delete', 'subitem' => 'add|edit'), + 'OnDeleteAll' => Array ('self' => 'delete', 'subitem' => 'add|edit'), + 'OnMassDelete' => Array ('self' => 'delete', 'subitem' => 'add|edit'), + 'OnMassClone' => Array ('self' => 'add', 'subitem' => 'add|edit'), - 'OnSelectItems' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), - 'OnProcessSelected' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), - 'OnStoreSelected' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), - 'OnSelectUser' => Array('self' => 'add|edit', 'subitem' => 'add|edit'), + 'OnCut' => Array ('self'=>'edit', 'subitem' => 'edit'), + 'OnCopy' => Array ('self'=>'edit', 'subitem' => 'edit'), + 'OnPaste' => Array ('self'=>'edit', 'subitem' => 'edit'), - 'OnMassApprove' => Array('self' => 'advanced:approve|edit', 'subitem' => 'advanced:approve|add|edit'), - 'OnMassDecline' => Array('self' => 'advanced:decline|edit', 'subitem' => 'advanced:decline|add|edit'), - 'OnMassMoveUp' => Array('self' => 'advanced:move_up|edit', 'subitem' => 'advanced:move_up|add|edit'), - 'OnMassMoveDown' => Array('self' => 'advanced:move_down|edit', 'subitem' => 'advanced:move_down|add|edit'), + 'OnSelectItems' => Array ('self' => 'add|edit', 'subitem' => 'add|edit'), + 'OnProcessSelected' => Array ('self' => 'add|edit', 'subitem' => 'add|edit'), + 'OnStoreSelected' => Array ('self' => 'add|edit', 'subitem' => 'add|edit'), + 'OnSelectUser' => Array ('self' => 'add|edit', 'subitem' => 'add|edit'), - 'OnPreCreate' => Array('self' => 'add|add.pending', 'subitem' => 'edit|edit.pending'), - 'OnEdit' => Array('self' => 'edit|edit.pending', 'subitem' => 'edit|edit.pending'), + 'OnMassApprove' => Array ('self' => 'advanced:approve|edit', 'subitem' => 'advanced:approve|add|edit'), + 'OnMassDecline' => Array ('self' => 'advanced:decline|edit', 'subitem' => 'advanced:decline|add|edit'), + 'OnMassMoveUp' => Array ('self' => 'advanced:move_up|edit', 'subitem' => 'advanced:move_up|add|edit'), + 'OnMassMoveDown' => Array ('self' => 'advanced:move_down|edit', 'subitem' => 'advanced:move_down|add|edit'), - 'OnExport' => Array('self' => 'view|advanced:export'), - 'OnExportBegin' => Array('self' => 'view|advanced:export'), - 'OnExportProgress' => Array('self' => 'view|advanced:export'), + 'OnPreCreate' => Array ('self' => 'add|add.pending', 'subitem' => 'edit|edit.pending'), + 'OnEdit' => Array ('self' => 'edit|edit.pending', 'subitem' => 'edit|edit.pending'), + 'OnExport' => Array ('self' => 'view|advanced:export'), + 'OnExportBegin' => Array ('self' => 'view|advanced:export'), + 'OnExportProgress' => Array ('self' => 'view|advanced:export'), - 'OnSetAutoRefreshInterval' => Array ('self' => true, 'subitem' => true), - 'OnAutoRefreshToggle' => Array ('self' => true, 'subitem' => true), - // theese event do not harm, but just in case check them too :) - 'OnCancelEdit' => Array('self' => true, 'subitem' => true), - 'OnCancel' => Array('self' => true, 'subitem' => true), - 'OnReset' => Array('self' => true, 'subitem' => true), + 'OnSetAutoRefreshInterval' => Array ('self' => true, 'subitem' => true), + 'OnAutoRefreshToggle' => Array ('self' => true, 'subitem' => true), - 'OnSetSorting' => Array('self' => true, 'subitem' => true), - 'OnSetSortingDirect' => Array('self' => true, 'subitem' => true), - 'OnResetSorting' => Array('self' => true, 'subitem' => true), + // theese event do not harm, but just in case check them too :) + 'OnCancelEdit' => Array ('self' => true, 'subitem' => true), + 'OnCancel' => Array ('self' => true, 'subitem' => true), + 'OnReset' => Array ('self' => true, 'subitem' => true), - 'OnSetFilter' => Array('self' => true, 'subitem' => true), - 'OnApplyFilters' => Array('self' => true, 'subitem' => true), - 'OnRemoveFilters' => Array('self' => true, 'subitem' => true), - 'OnSetFilterPattern' => Array('self' => true, 'subitem' => true), + 'OnSetSorting' => Array ('self' => true, 'subitem' => true), + 'OnSetSortingDirect' => Array ('self' => true, 'subitem' => true), + 'OnResetSorting' => Array ('self' => true, 'subitem' => true), - 'OnSetPerPage' => Array('self' => true, 'subitem' => true), - 'OnSetPage' => Array('self' => true, 'subitem' => true), + 'OnSetFilter' => Array ('self' => true, 'subitem' => true), + 'OnApplyFilters' => Array ('self' => true, 'subitem' => true), + 'OnRemoveFilters' => Array ('self' => true, 'subitem' => true), + 'OnSetFilterPattern' => Array ('self' => true, 'subitem' => true), - 'OnSearch' => Array('self' => true, 'subitem' => true), - 'OnSearchReset' => Array('self' => true, 'subitem' => true), + 'OnSetPerPage' => Array ('self' => true, 'subitem' => true), + 'OnSetPage' => Array ('self' => true, 'subitem' => true), - 'OnGoBack' => Array('self' => true, 'subitem' => true), + 'OnSearch' => Array ('self' => true, 'subitem' => true), + 'OnSearchReset' => Array ('self' => true, 'subitem' => true), - // it checks permission itself since flash uploader does not send cookies - 'OnUploadFile' => Array ('self' => true, 'subitem' => true), - 'OnDeleteFile' => Array ('self' => true, 'subitem' => true), + 'OnGoBack' => Array ('self' => true, 'subitem' => true), - 'OnViewFile' => Array ('self' => true, 'subitem' => true), - 'OnSaveWidths' => Array ('self' => true, 'subitem' => true), + // it checks permission itself since flash uploader does not send cookies + 'OnUploadFile' => Array ('self' => true, 'subitem' => true), + 'OnDeleteFile' => Array ('self' => true, 'subitem' => true), - 'OnValidateMInputFields' => Array ('self' => 'view'), - 'OnValidateField' => Array ('self' => true, 'subitem' => true), - ); + 'OnViewFile' => Array ('self' => true, 'subitem' => true), + 'OnSaveWidths' => Array ('self' => true, 'subitem' => true), + + 'OnValidateMInputFields' => Array ('self' => 'view'), + 'OnValidateField' => Array ('self' => true, 'subitem' => true), + ); + $this->permMapping = array_merge($this->permMapping, $permissions); } - function mapEvents() + /** + * Define alternative event processing method names + * + * @return void + * @see kEventHandler::$eventMethods + * @access protected + */ + protected function mapEvents() { - $events_map = Array( - 'OnRemoveFilters' => 'FilterAction', - 'OnApplyFilters' => 'FilterAction', - 'OnMassApprove'=>'iterateItems', - 'OnMassDecline'=>'iterateItems', - 'OnMassMoveUp'=>'iterateItems', - 'OnMassMoveDown'=>'iterateItems', - ); + $events_map = Array ( + 'OnRemoveFilters' => 'FilterAction', + 'OnApplyFilters' => 'FilterAction', + 'OnMassApprove' => 'iterateItems', + 'OnMassDecline' => 'iterateItems', + 'OnMassMoveUp' => 'iterateItems', + 'OnMassMoveDown' => 'iterateItems', + ); $this->eventMethods = array_merge($this->eventMethods, $events_map); } @@ -197,15 +209,16 @@ * * @param kEvent $event * @return int + * @access public */ - function getPassedID(&$event) + public function getPassedID(kEvent &$event) { - if ($event->getEventParam('raise_warnings') === false) { + if ( $event->getEventParam('raise_warnings') === false ) { $event->setEventParam('raise_warnings', 1); } if ( $event->Special == 'previous' || $event->Special == 'next' ) { - $object =& $this->Application->recallObject( $event->getEventParam('item') ); + $object =& $this->Application->recallObject($event->getEventParam('item')); /* @var $object kDBItem */ $list_helper =& $this->Application->recallObject('ListHelper'); @@ -220,7 +233,7 @@ 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]) ) { // - returns field DateFormat value from language (LanguageId is extracted from current phrase object) $main_object =& $this->Application->recallObject($regs[1]); /* @var $main_object kDBItem */ @@ -230,28 +243,28 @@ } // 1. get id from post (used in admin) - $ret = $this->Application->GetVar($event->getPrefixSpecial(true).'_id'); - if (($ret !== false) && ($ret != '')) { + $ret = $this->Application->GetVar($event->getPrefixSpecial(true) . '_id'); + if ( ($ret !== false) && ($ret != '') ) { return $ret; } // 2. get id from env (used in front) - $ret = $this->Application->GetVar($event->getPrefixSpecial().'_id'); - if (($ret !== false) && ($ret != '')) { + $ret = $this->Application->GetVar($event->getPrefixSpecial() . '_id'); + if ( ($ret !== false) && ($ret != '') ) { return $ret; } // recall selected ids array and use the first one - $ids = $this->Application->GetVar($event->getPrefixSpecial().'_selected_ids'); - if ($ids != '') { - $ids = explode(',',$ids); - if ($ids) { + $ids = $this->Application->GetVar($event->getPrefixSpecial() . '_selected_ids'); + if ( $ids != '' ) { + $ids = explode(',', $ids); + if ( $ids ) { $ret = array_shift($ids); } } else { // if selected ids are not yet stored $this->StoreSelectedIDs($event); - return $this->Application->GetVar($event->getPrefixSpecial().'_id'); // StoreSelectedIDs sets this variable + return $this->Application->GetVar($event->getPrefixSpecial() . '_id'); // StoreSelectedIDs sets this variable } return $ret; @@ -265,19 +278,19 @@ * * @param kEvent $event * @param Array $direct_ids - * - * @return Array ids stored + * @return Array + * @access protected */ - function StoreSelectedIDs(&$event, $direct_ids = null) + protected function StoreSelectedIDs(kEvent &$event, $direct_ids = null) { $wid = $this->Application->GetTopmostWid($event->Prefix); - $session_name = rtrim($event->getPrefixSpecial().'_selected_ids_'.$wid, '_'); + $session_name = rtrim($event->getPrefixSpecial() . '_selected_ids_' . $wid, '_'); $ids = $event->getEventParam('ids'); - if (isset($direct_ids) || ($ids !== false)) { + if ( isset($direct_ids) || ($ids !== false) ) { // save ids directly if they given + reset array indexes $resulting_ids = $direct_ids ? array_values($direct_ids) : ($ids ? array_values($ids) : false); - if ($resulting_ids) { + if ( $resulting_ids ) { $this->Application->SetVar($event->getPrefixSpecial() . '_selected_ids', implode(',', $resulting_ids)); $this->Application->LinkVar($event->getPrefixSpecial() . '_selected_ids', $session_name, '', true); $this->Application->SetVar($event->getPrefixSpecial() . '_id', $resulting_ids[0]); @@ -288,38 +301,37 @@ return Array (); } - $ret = Array(); + $ret = Array (); // May be we don't need this part: ? - $passed = $this->Application->GetVar($event->getPrefixSpecial(true).'_id'); - if($passed !== false && $passed != '') - { + $passed = $this->Application->GetVar($event->getPrefixSpecial(true) . '_id'); + if ( $passed !== false && $passed != '' ) { array_push($ret, $passed); } - $ids = Array(); + $ids = Array (); // get selected ids from post & save them to session - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if($items_info) - { - $id_field = $this->Application->getUnitOption($event->Prefix,'IDField'); - foreach($items_info as $id => $field_values) - { - if( getArrayValue($field_values,$id_field) ) array_push($ids,$id); + $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); + if ( $items_info ) { + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + foreach ($items_info as $id => $field_values) { + if ( getArrayValue($field_values, $id_field) ) { + array_push($ids, $id); + } } - //$ids=array_keys($items_info); + //$ids = array_keys($items_info); } $ret = array_unique(array_merge($ret, $ids)); - $this->Application->SetVar($event->getPrefixSpecial().'_selected_ids', implode(',',$ret)); - $this->Application->LinkVar($event->getPrefixSpecial().'_selected_ids', $session_name, '', !$ret); // optional when IDs are missing + $this->Application->SetVar($event->getPrefixSpecial() . '_selected_ids', implode(',', $ret)); + $this->Application->LinkVar($event->getPrefixSpecial() . '_selected_ids', $session_name, '', !$ret); // optional when IDs are missing // This is critical - otherwise getPassedID will return last ID stored in session! (not exactly true) // this smells... needs to be refactored - $first_id = getArrayValue($ret,0); - if (($first_id === false) && ($event->getEventParam('raise_warnings') == 1)) { + $first_id = getArrayValue($ret, 0); + if ( ($first_id === false) && ($event->getEventParam('raise_warnings') == 1) ) { if ( $this->Application->isDebugMode() ) { $this->Application->Debugger->appendTrace(); } @@ -336,17 +348,18 @@ * * @param kEvent $event * @param bool $from_session return ids from session (written, when editing was started) - * @return array + * @return Array + * @access protected */ - function getSelectedIDs(&$event, $from_session = false) + protected function getSelectedIDs(kEvent &$event, $from_session = false) { - if ($from_session) { + if ( $from_session ) { $wid = $this->Application->GetTopmostWid($event->Prefix); - $var_name = rtrim($event->getPrefixSpecial().'_selected_ids_'.$wid, '_'); + $var_name = rtrim($event->getPrefixSpecial() . '_selected_ids_' . $wid, '_'); $ret = $this->Application->RecallVar($var_name); } else { - $ret = $this->Application->GetVar($event->getPrefixSpecial().'_selected_ids'); + $ret = $this->Application->GetVar($event->getPrefixSpecial() . '_selected_ids'); } return explode(',', $ret); @@ -356,30 +369,35 @@ * Stores IDs, selected in grid in session * * @param kEvent $event + * @return void + * @access protected */ - function OnStoreSelected(&$event) + protected function OnStoreSelected(kEvent &$event) { $this->StoreSelectedIDs($event); $id = $this->Application->GetVar($event->getPrefixSpecial() . '_id'); - if ($id !== false) { + if ( $id !== false ) { $event->SetRedirectParam($event->getPrefixSpecial() . '_id', $id); $event->SetRedirectParam('pass', 'all,' . $event->getPrefixSpecial()); } } /** - * Returs associative array of submitted fields for current item + * Returns associative array of submitted fields for current item * Could be used while creating/editing single item - * meaning on any edit form, except grid edit * * @param kEvent $event + * @return Array + * @access protected */ - function getSubmittedFields(&$event) + protected function getSubmittedFields(kEvent &$event) { - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - $field_values = $items_info ? array_shift($items_info) : Array(); + $items_info = $this->Application->GetVar($event->getPrefixSpecial(true)); + $field_values = $items_info ? array_shift($items_info) : Array (); + return $field_values; } @@ -388,31 +406,34 @@ * from Application variables and Session * * @param kEvent $event + * @return void + * @access protected */ - function clearSelectedIDs(&$event) + protected function clearSelectedIDs(kEvent &$event) { $prefix_special = $event->getPrefixSpecial(); $ids = implode(',', $this->getSelectedIDs($event, true)); $event->setEventParam('ids', $ids); $wid = $this->Application->GetTopmostWid($event->Prefix); - $session_name = rtrim($prefix_special.'_selected_ids_'.$wid, '_'); + $session_name = rtrim($prefix_special . '_selected_ids_' . $wid, '_'); $this->Application->RemoveVar($session_name); - $this->Application->SetVar($prefix_special.'_selected_ids', ''); + $this->Application->SetVar($prefix_special . '_selected_ids', ''); - $this->Application->SetVar($prefix_special.'_id', ''); // $event->getPrefixSpecial(true).'_id' too may be + $this->Application->SetVar($prefix_special . '_id', ''); // $event->getPrefixSpecial(true) . '_id' too may be } /** * Common builder part for Item & List * * @param kDBBase|kDBItem|kDBList $object * @param kEvent $event - * @access private + * @return void + * @access protected */ - function dbBuild(&$object, &$event) + protected function dbBuild(&$object, kEvent &$event) { // for permission checking inside item/list build events $event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix, true)); @@ -422,10 +443,10 @@ } else { $request_forms = $this->Application->GetVar('forms', Array ()); - $form_name = (string)getArrayValue( $request_forms, $object->getPrefixSpecial() ); + $form_name = (string)getArrayValue($request_forms, $object->getPrefixSpecial()); } - $object->Configure( $event->getEventParam('populate_ml_fields') || $this->Application->getUnitOption($event->Prefix, 'PopulateMlFields'), $form_name ); + $object->Configure($event->getEventParam('populate_ml_fields') || $this->Application->getUnitOption($event->Prefix, 'PopulateMlFields'), $form_name); $this->PrepareObject($object, $event); $parent_event = $event->getEventParam('parent_event'); @@ -437,24 +458,24 @@ // force live table if specified or is original item $live_table = $event->getEventParam('live_table') || $event->Special == 'original'; - if( $this->UseTempTables($event) && !$live_table ) - { + if ( $this->UseTempTables($event) && !$live_table ) { $object->SwitchToTemp(); } $this->Application->setEvent($event->getPrefixSpecial(), ''); $save_event = $this->UseTempTables($event) && $this->Application->GetTopmostPrefix($event->Prefix) == $event->Prefix ? 'OnSave' : 'OnUpdate'; - $this->Application->SetVar($event->getPrefixSpecial().'_SaveEvent',$save_event); + $this->Application->SetVar($event->getPrefixSpecial() . '_SaveEvent', $save_event); } /** * Checks, that currently loaded item is allowed for viewing (non permission-based) * * @param kEvent $event * @return bool + * @access protected */ - function checkItemStatus(&$event) + protected function checkItemStatus(kEvent &$event) { $status_fields = $this->Application->getUnitOption($event->Prefix, 'StatusField'); if ( !$status_fields ) { @@ -481,13 +502,14 @@ * Shows not found template content * * @param kEvent $event - * + * @return void + * @access protected */ - function _errorNotFound(&$event) + protected function _errorNotFound(kEvent &$event) { - if ($event->getEventParam('raise_warnings') === 0) { + if ( $event->getEventParam('raise_warnings') === 0 ) { // when it's possible, that autoload fails do nothing - return ; + return; } if ( $this->Application->isDebugMode() ) { @@ -513,7 +535,7 @@ // in case if missing item is recalled first from event (not from template) $this->Application->InitParser(); - $this->Application->HTML = $this->Application->ParseBlock( Array ('name' => $error_template) ); + $this->Application->HTML = $this->Application->ParseBlock(Array ('name' => $error_template)); $this->Application->Done(); exit; } @@ -526,7 +548,7 @@ * @param kEvent $event * @access protected */ - function OnItemBuild(&$event) + protected function OnItemBuild(kEvent &$event) { $object =& $event->getObject(); /* @var $object kDBItem */ @@ -539,21 +561,21 @@ // 2. loads if allowed $auto_load = $this->Application->getUnitOption($event->Prefix,'AutoLoad'); - $skip_autload = $event->getEventParam('skip_autoload'); + $skip_autoload = $event->getEventParam('skip_autoload'); - if ($auto_load && !$skip_autload) { + if ( $auto_load && !$skip_autoload ) { $perm_status = true; $user_id = $this->Application->InitDone ? $this->Application->RecallVar('user_id') : USER_ROOT; $event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix, true)); $status_checked = false; - if ($user_id == USER_ROOT || $this->CheckPermission($event)) { + if ( $user_id == USER_ROOT || $this->CheckPermission($event) ) { // don't autoload item, when user doesn't have view permission $this->LoadItem($event); $status_checked = true; $editing_mode = defined('EDITING_MODE') ? EDITING_MODE : false; - if ($user_id != USER_ROOT && !$this->Application->isAdmin && !($editing_mode || $this->checkItemStatus($event))) { + if ( $user_id != USER_ROOT && !$this->Application->isAdmin && !($editing_mode || $this->checkItemStatus($event)) ) { // non-root user AND on front-end AND (not editing mode || incorrect status) $perm_status = false; } @@ -593,19 +615,21 @@ $actions =& $this->Application->recallObject('kActions'); /* @var $actions Params */ - $actions->Set($event->getPrefixSpecial().'_GoTab', ''); - $actions->Set($event->getPrefixSpecial().'_GoId', ''); - $actions->Set('forms[' . $event->getPrefixSpecial() . ']', $object->getFormName()); + $actions->Set($event->getPrefixSpecial() . '_GoTab', ''); + $actions->Set($event->getPrefixSpecial() . '_GoId', ''); + $actions->Set('forms[' . $event->getPrefixSpecial() . ']', $object->getFormName()); } /** - * Build subtables array from configs + * Build sub-tables array from configs * * @param kEvent $event + * @return void + * @access protected */ - function OnTempHandlerBuild(&$event) + protected function OnTempHandlerBuild(kEvent &$event) { - $object =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + $object =& $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler'); /* @var $object kTempTablesHandler */ $parent_event = $event->getEventParam('parent_event'); @@ -614,16 +638,17 @@ $object->setParentEvent($parent_event); } - $object->BuildTables( $event->Prefix, $this->getSelectedIDs($event) ); + $object->BuildTables($event->Prefix, $this->getSelectedIDs($event)); } /** * Checks, that object used in event should use temp tables * * @param kEvent $event * @return bool + * @access protected */ - function UseTempTables(&$event) + protected function UseTempTables(kEvent &$event) { $top_prefix = $this->Application->GetTopmostPrefix($event->Prefix); // passed parent, not always actual $special = ($top_prefix == $event->Prefix) ? $event->Special : $this->getMainSpecial($event); @@ -632,25 +657,13 @@ } /** - * Returns table prefix from event (temp or live) - * - * @param kEvent $event - * @return string - * @todo Needed? Should be refactored (by Alex) - */ - function TablePrefix(&$event) - { - return $this->UseTempTables($event) ? $this->Application->GetTempTablePrefix('prefix:'.$event->Prefix).TABLE_PREFIX : TABLE_PREFIX; - } - - /** * Load item if id is available * * @param kEvent $event * @return void * @access protected */ - protected function LoadItem(&$event) + protected function LoadItem(kEvent &$event) { $object =& $event->getObject(); /* @var $object kDBItem */ @@ -681,7 +694,7 @@ * @param kEvent $event * @access protected */ - function OnListBuild(&$event) + protected function OnListBuild(kEvent &$event) { $object =& $event->getObject(); /* @var $object kDBList */ @@ -710,7 +723,7 @@ $object->reset(); if ( $event->getEventParam('skip_parent_filter') === false ) { - $object->linkToParent( $this->getMainSpecial($event) ); + $object->linkToParent($this->getMainSpecial($event)); } $this->AddFilters($event); @@ -726,19 +739,20 @@ } /** - * Get's special of main item for linking with subitem + * Returns special of main item for linking with sub-item * * @param kEvent $event * @return string + * @access protected */ - function getMainSpecial(&$event) + protected function getMainSpecial(kEvent &$event) { $main_special = $event->getEventParam('main_special'); - if ($main_special === false) { + if ( $main_special === false ) { // main item's special not passed - if (substr($event->Special, -5) == '-item') { + if ( substr($event->Special, -5) == '-item' ) { // temp handler added "-item" to given special -> process that here return substr($event->Special, 0, -5); } @@ -758,13 +772,13 @@ * @access protected * @see kDBEventHandler::OnListBuild() */ - protected function SetCustomQuery(&$event) + protected function SetCustomQuery(kEvent &$event) { } /** - * Set's new perpage for grid + * Set's new per-page for grid * * @param kEvent $event */ @@ -2756,7 +2770,7 @@ * @return void * @access protected */ - protected function prepareObject(&$object, &$event) + protected function prepareObject(&$object, kEvent &$event) { if ( $event->Special == 'export' || $event->Special == 'import' ) { $export_helper =& $this->Application->recallObject('CatItemExportHelper');