Index: branches/5.2.x/units/posts/post_eh.php =================================================================== diff -u -N -r15008 -r15060 --- branches/5.2.x/units/posts/post_eh.php (.../post_eh.php) (revision 15008) +++ branches/5.2.x/units/posts/post_eh.php (.../post_eh.php) (revision 15060) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBItem */ - $perm_status = $this->checkPostPermission($event, 'TOPIC.REPLY.OWNER.DELETE|TOPIC.REPLY.DELETE'); - if (!$perm_status) { + if ( !$this->checkPostPermission($event, 'TOPIC.REPLY.OWNER.DELETE|TOPIC.REPLY.DELETE') ) { $event->status = kEvent::erFAIL; } } @@ -178,7 +183,7 @@ * @return void * @access protected */ - protected function OnAfterItemLoad(&$event) + protected function OnAfterItemLoad(kEvent &$event) { parent::OnAfterItemLoad($event); @@ -204,7 +209,7 @@ * @return void * @access protected */ - protected function OnAfterItemCreate(&$event) + protected function OnAfterItemCreate(kEvent &$event) { parent::OnAfterItemCreate($event); @@ -288,12 +293,14 @@ * Goes to next_template after post creation * * @param kEvent $event + * @return void + * @access protected */ - function OnCreate(&$event) + protected function OnCreate(kEvent &$event) { parent::OnCreate($event); - if ($event->status == kEvent::erSUCCESS && !$this->Application->isAdmin) { + if ( $event->status == kEvent::erSUCCESS && !$this->Application->isAdmin ) { $event->SetRedirectParam('opener', 's'); $event->redirect = $this->Application->GetVar('next_template'); } @@ -321,16 +328,20 @@ * Moves reference to last post in topic, when it is deleted * * @param kEvent $event + * @return void + * @access protected */ - function OnAfterItemDelete(&$event) + protected function OnAfterItemDelete(kEvent &$event) { + parent::OnAfterItemDelete($event); + $object =& $event->getObject(); /* @var $object kDBItem */ $topic_id = $object->GetDBField('TopicId'); - if (!$topic_id) { + if ( !$topic_id ) { // deleting non-existing post - return ; + return; } $post_helper =& $this->Application->recallObject('PostHelper'); @@ -340,31 +351,31 @@ $post_helper->updatePostCount($topic_id, -1); // update post owner posts counter - $sql = 'UPDATE '.TABLE_PREFIX.'UserPersistentSessionData + $sql = 'UPDATE ' . TABLE_PREFIX . 'UserPersistentSessionData SET VariableValue = IF (VariableValue > 0, VariableValue - 1, 0) - WHERE (PortalUserId = '.$object->GetDBField('CreatedById').') AND (VariableName = "bb_posts")'; + WHERE (PortalUserId = ' . $object->GetDBField('CreatedById') . ') AND (VariableName = "bb_posts")'; $this->Conn->Query($sql); - $main_object =& $this->Application->recallObject('bb.-item', null, Array('skip_autoload' => true)); + $main_object =& $this->Application->recallObject('bb.-item', null, Array ('skip_autoload' => true)); /* @var $main_object kCatDBItem */ $main_object->Load($topic_id); $post_helper->updateTodayPostsCount($main_object, $object->GetDBField('CreatedOn'), -1); - if ($main_object->GetDBField('LastPostId') == $object->GetID()) { + if ( $main_object->GetDBField('LastPostId') == $object->GetID() ) { $sql = 'SELECT PostingId, CreatedOn - FROM '.$object->TableName.' - WHERE TopicId = '.$topic_id.' + FROM ' . $object->TableName . ' + WHERE TopicId = ' . $topic_id . ' ORDER BY PostingId DESC'; $last_post = $this->Conn->GetRow($sql); $fields_hash = Array ( 'LastPostId' => $last_post['PostingId'], 'LastPostDate' => $last_post['CreatedOn'], ); - $this->Conn->doUpdate($fields_hash, $main_object->TableName, $main_object->IDField.' = '.$topic_id); + $this->Conn->doUpdate($fields_hash, $main_object->TableName, $main_object->IDField . ' = ' . $topic_id); } } @@ -390,39 +401,43 @@ * Deletes items & preserves clean env * * @param kEvent $event + * @return void + * @access protected */ - function OnDelete(&$event) + protected function OnDelete(kEvent &$event) { parent::OnDelete($event); - if ($event->status == kEvent::erSUCCESS && !$this->Application->isAdmin) { + if ( $event->status == kEvent::erSUCCESS && !$this->Application->isAdmin ) { $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); - $event->SetRedirectParam('pass', 'm,'.$parent_prefix); + $event->SetRedirectParam('pass', 'm,' . $parent_prefix); } } /** * Prepares new reply form * * @param kEvent $event + * @return void + * @access protected */ - function OnNew(&$event) + protected function OnNew(kEvent &$event) { parent::OnNew($event); $reply_to = $this->Application->GetVar('reply_to'); - if ($reply_to > 0) { + if ( $reply_to > 0 ) { $object =& $event->getObject(); /* @var $object kDBItem */ - $source_post =& $this->Application->recallObject($event->Prefix.'.-item', null, Array ('skip_autoload' => true)); + $source_post =& $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true)); /* @var $source_post kDBItem */ $source_post->Load($reply_to); - $object->SetDBField('Subject', 'Re: '.$source_post->GetDBField('Subject')); - $object->SetDBField('PostingText', '[quote id='.$reply_to.']'.$source_post->GetDBField('PostingText').'[/quote]'); + $object->SetDBField('Subject', 'Re: ' . $source_post->GetDBField('Subject')); + $object->SetDBField('PostingText', '[quote id=' . $reply_to . ']' . $source_post->GetDBField('PostingText') . '[/quote]'); } } } \ No newline at end of file