Page MenuHomeIn-Portal Phabricator

in-bulletin
No OneTemporary

File Metadata

Created
Mon, Feb 24, 12:57 PM

in-bulletin

Index: branches/5.3.x/units/private_messages/private_message_eh.php
===================================================================
--- branches/5.3.x/units/private_messages/private_message_eh.php (revision 16396)
+++ branches/5.3.x/units/private_messages/private_message_eh.php (revision 16397)
@@ -1,300 +1,304 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PrivateMessageEventHandler extends kDBEventHandler {
/**
* Allows to override standard permission mapping
*
* @return void
* @access protected
* @see kEventHandler::$permMapping
*/
protected function mapPermissions()
{
parent::mapPermissions();
$permissions = Array (
'OnItemBuild' => Array ('self' => true),
'OnCreate' => Array ('self' => true),
'OnDelete' => Array ('self' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
/**
* Applies folder & message owner filter to message list
*
* @param kEvent $event
* @return void
* @access protected
* @see kDBEventHandler::OnListBuild()
*/
protected function SetCustomQuery(kEvent $event)
{
parent::SetCustomQuery($event);
$folder_id = $this->Application->GetVar('folder_id');
if ( $folder_id === false ) {
$folder_id = PM_FOLDER_INBOX;
$this->Application->SetVar('folder_id', $folder_id);
}
$object = $event->getObject();
/* @var $object kDBList */
$user_id = $this->Application->RecallVar('user_id');
if ( $folder_id == PM_FOLDER_INBOX ) {
$object->addFilter('owner_filter', '%1$s.ToId = ' . $user_id);
}
else {
$object->addFilter('owner_filter', '%1$s.FromId = ' . $user_id);
}
$object->addFilter('folder_filter', '%1$s.FolderId = ' . $folder_id);
}
/**
* Puts message to Sent folder
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemCreate(kEvent $event)
{
parent::OnBeforeItemCreate($event);
$object = $event->getObject();
/* @var $object kDBItem */
if ( $object->GetDBField('FolderId') != PM_FOLDER_SENT ) {
// when creating "Inbox" message (from "Sent" message) don't reset folder & status
return ;
}
$user_id = $this->Application->RecallVar('user_id');
$object->SetDBField('FromId', $user_id);
$object->SetDBField('FolderId', PM_FOLDER_SENT);
$object->SetDBField('Status', PM_STATUS_READ);
}
/**
* Creates 1st post when topic is created
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemCreate(kEvent $event)
{
parent::OnAfterItemCreate($event);
$object = $event->getObject();
/* @var $object kDBItem */
$this->Application->emailUser('PM.ADD', $object->GetDBField('ToId'), $object->getEmailParams());
if ( $object->GetDBField('FolderId') != PM_FOLDER_SENT ) {
// 1. create message in sender's "Sent" folder (this method only for this step)
// 2. create message body (shared)
// 3. create message copy in recipient's "Inbox" folder
return ;
}
$message_body = $this->Application->recallObject($event->Prefix . '-body', null, Array ('skip_autoload' => true));
/* @var $message_body kDBItem */
// 1. create message body (for sender & recipient)
$copy_fields = Array ('Subject', 'Body', 'ShowSignatures', 'DisableSmileys', 'DisableBBCodes');
$message_body->SetDBFieldsFromHash($object->GetFieldValues(), $copy_fields);
$body_created = $message_body->Create();
if ( $body_created ) {
// 2. link body with message
$object->SetDBField('PMBodyId', $message_body->GetID());
$object->Update();
// 3. create message in recipient's Inbox folder
$object->SetDBField('FolderId', PM_FOLDER_INBOX);
$object->SetDBField('Status', PM_STATUS_UNREAD);
$object->Create();
}
}
/**
* Sets post options to virtual fields
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemLoad(kEvent $event)
{
parent::OnAfterItemLoad($event);
$object = $event->getObject();
/* @var $object kDBItem */
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$options_map = $post_helper->getOptionsMap();
$post_options = $object->GetDBField('Options');
foreach ($options_map as $option_name => $field_name) {
$option_value = $post_helper->GetPostOption($option_name, $post_options);
$object->SetDBField($field_name, (int)$option_value);
}
}
/**
* Goes to next_template after post creation
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnCreate(kEvent $event)
{
parent::OnCreate($event);
if ( $event->status == kEvent::erSUCCESS && !$this->Application->isAdmin ) {
$event->SetRedirectParam('opener', 's');
$event->redirect = $this->Application->GetVar('next_template');
}
}
/**
* Prevents user from deleting other user private messages
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemDelete(kEvent $event)
{
parent::OnBeforeItemDelete($event);
$object = $event->getObject();
/* @var $object kDBItem */
$user_id = $this->Application->RecallVar('user_id');
$owner_field = ($object->GetDBField('FolderId') == PM_FOLDER_INBOX) ? 'ToId' : 'FromId';
if ( $object->GetDBField($owner_field) != $user_id ) {
$event->status = kEvent::erFAIL;
}
}
/**
* Updates reference counter in message body record
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemDelete(kEvent $event)
{
parent::OnAfterItemDelete($event);
$object = $event->getObject();
/* @var $object kDBItem */
$config = $this->Application->getUnitConfig($event->Prefix . '-body');
$sql = 'UPDATE ' . $config->getTableName() . '
SET ReferenceCount = ReferenceCount - 1
WHERE ' . $config->getIDField() . ' = ' . $object->GetDBField('PMBodyId');
$this->Conn->Query($sql);
}
/**
* Sets default values to posting options based on persistent session
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterConfigRead(kEvent $event)
{
parent::OnAfterConfigRead($event);
+ if ( !$this->Application->LoggedIn() ) {
+ return;
+ }
+
$config = $event->getUnitConfig();
$virtual_fields = $config->getVirtualFields();
$virtual_fields['DisableBBCodes']['default'] = (int)!$this->Application->RecallPersistentVar('bbcode');
$virtual_fields['DisableSmileys']['default'] = (int)!$this->Application->RecallPersistentVar('smileys');
$virtual_fields['ShowSignatures']['default'] = (int)$this->Application->RecallPersistentVar('show_sig');
$config->setVirtualFields($virtual_fields);
}
/**
* Checks, that current user is recipient or sender of viewed message
*
* @param kEvent $event
* @return bool
* @access protected
*/
protected function checkItemStatus(kEvent $event)
{
$object = $event->getObject();
/* @var $object kDBItem */
if ( !$object->isLoaded() ) {
return true;
}
$user_id = $this->Application->RecallVar('user_id');
return ($object->GetDBField('FromId') == $user_id) || ($object->GetDBField('ToId') == $user_id);
}
/**
* Prepares new reply & new message form
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnNew(kEvent $event)
{
parent::OnNew($event);
$reply_to = $this->Application->GetVar('reply_to');
$user_id = $this->Application->GetVar('user_id');
$object = $event->getObject();
/* @var $object kDBItem */
if ( $reply_to > 0 ) {
// reply to message
$source_msg = $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true));
/* @var $source_msg kDBItem */
$source_msg->Load($reply_to);
$object->SetDBField('ToId', $source_msg->GetDBField('FromId'));
$object->SetDBField('Subject', 'Re: ' . $source_msg->GetDBField('Subject'));
}
elseif ( $user_id > 0 ) {
// send message to any user by id
$object->SetDBField('ToId', $user_id);
}
}
}
Index: branches/5.3.x/units/topics/topics_event_handler.php
===================================================================
--- branches/5.3.x/units/topics/topics_event_handler.php (revision 16396)
+++ branches/5.3.x/units/topics/topics_event_handler.php (revision 16397)
@@ -1,306 +1,343 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class TopicsEventHandler extends kCatDBEventHandler {
/**
* Checks topic lock permission
*
* @param kEvent $event
* @return bool
* @access public
*/
public function CheckPermission(kEvent $event)
{
if ( $event->Name == 'OnTopicLockToggle' ) {
$object = $event->getObject();
/* @var $object kCatDBItem */
if ( !$object->isLoaded() ) {
$event->status = kEvent::erPERM_FAIL;
return false;
}
$category_id = $object->GetDBField('CategoryId');
$perm_status = $this->Application->CheckPermission('TOPIC.LOCK', 0, $category_id);
if ( !$perm_status ) {
$event->status = kEvent::erPERM_FAIL;
}
return $perm_status;
}
if ( $event->Name == 'OnToogleCategoryTopicsSubscribe' || $event->Name == 'OnToogleTopicPostsSubscribe' ) {
return $this->Application->LoggedIn();
}
return parent::CheckPermission($event);
}
/**
* Lock or unlock topic
*
* @param kEvent $event
*/
function OnToggleLock($event)
{
$object = $event->getObject();
/* @var $object kDBItem */
$new_type = $object->GetDBField('TopicType') ? 0 : 1;
$object->SetDBField('TopicType', $new_type);
$object->Update();
}
/**
* Cache topic owner
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemUpdate(kEvent $event)
{
parent::OnBeforeItemUpdate($event);
$this->cacheItemOwner($event, 'OwnerId', 'PostedBy');
}
/**
* Cache topic owner
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemCreate(kEvent $event)
{
parent::OnBeforeItemCreate($event);
$this->cacheItemOwner($event, 'OwnerId', 'PostedBy');
$object = $event->getObject();
/* @var $object kCatDBItem */
if ( !$object->GetDBField('TodayDate') ) {
$object->SetDBField('TodayDate', date('Y-m-d'));
}
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$object->SetDBField('TopicText', $post_helper->CensorText($object->GetDBField('TopicText')));
}
/**
* Creates 1st post when topic is created
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemCreate(kEvent $event)
{
parent::OnAfterItemCreate($event);
if ( $event->Special == '-item' ) {
// don't create first post when cloning
return ;
}
$object = $event->getObject();
/* @var $object kDBItem */
$post = $this->Application->recallObject($event->Prefix . '-post', null, Array ('skip_autoload' => true));
/* @var $post kDBItem */
$post->SetDBField('Pending', $object->GetDBField('Status') == STATUS_ACTIVE ? 0 : 1);
$post->SetDBField('Subject', '');
$post->SetDBField('PostingText', $object->GetDBField('PostingText'));
$post->SetDBField('ShowSignatures', $object->GetDBField('ShowSignatures'));
$post->SetDBField('DisableSmileys', $object->GetDBField('DisableSmileys'));
$post->SetDBField('DisableBBCodes', $object->GetDBField('DisableBBCodes'));
$post->Create();
// need to update category topic count here
}
/**
* Approves 1st post when topic got approved
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemUpdate(kEvent $event)
{
parent::OnAfterItemUpdate($event);
if ( !$this->Application->isAdminUser ) {
return;
}
$object = $event->getObject();
/* @var $object kCatDBItem */
if ( $object->GetDBField('Posts') == 1 ) {
$post = $this->Application->recallObject($event->Prefix . '-post', null, Array ('skip_autoload' => true));
/* @var $post kDBItem */
$main_status = $object->GetDBField('Status');
$post->Load($object->GetDBField('LastPostId'));
if ( $post->isLoaded() ) {
$post->SetDBField('Pending', $main_status == STATUS_ACTIVE ? 0 : 1);
$post->Update();
}
}
}
/**
* Makes first post body field non-required when topic has posts already
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemLoad(kEvent $event)
{
parent::OnAfterItemLoad($event);
$object = $event->getObject();
/* @var $object kCatDBItem */
if ( $object->GetDBField('Posts') > 0 || !$this->Application->isAdminUser ) {
$object->setRequired('PostingText', false);
}
}
/**
* Locks or unlocks topic
*
* @param kEvent $event
*/
function OnTopicLockToggle($event)
{
$object = $event->getObject();
/* @var $object kCatDBItem */
$topic_type = $object->GetDBField('TopicType');
$object->SetDBField('TopicType', $topic_type == 1 ? 0 : 1);
$object->Update();
}
/**
* Sets default values to posting options based on persistent session
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterConfigRead(kEvent $event)
{
parent::OnAfterConfigRead($event);
+ if ( !$this->Application->LoggedIn() ) {
+ return;
+ }
+
$config = $event->getUnitConfig();
$fields = $config->getFields();
$fields['NotifyOwnerOnChanges']['default'] = (int)$this->Application->RecallPersistentVar('owner_notify');
$config->setFields($fields);
$virtual_fields = $config->getVirtualFields();
$virtual_fields['DisableBBCodes']['default'] = (int)!$this->Application->RecallPersistentVar('bbcode');
$virtual_fields['DisableSmileys']['default'] = (int)!$this->Application->RecallPersistentVar('smileys');
$virtual_fields['ShowSignatures']['default'] = (int)$this->Application->RecallPersistentVar('show_sig');
$config->setVirtualFields($virtual_fields);
}
/**
* [HOOK] Allows to add cloned subitem to given prefix
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnCloneSubItem(kEvent $event)
{
parent::OnCloneSubItem($event);
if ( $event->MasterEvent->Prefix == 'rev' ) {
$sub_item_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix;
$event->MasterEvent->getUnitConfig()->addClones(Array (
$sub_item_prefix => Array (
'ConfigMapping' => Array (
'PerPage' => 'Perpage_TopicReviews',
'ReviewDelayInterval' => 'topic_ReviewDelay_Interval',
'ReviewDelayValue' => 'topic_ReviewDelay_Value',
)
),
));
}
}
/**
* Subscribes/unsubscribes to new topics in given current category
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnToogleCategoryTopicsSubscribe(kEvent $event)
{
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$manager = $post_helper->getSubscriptionManager('CategoryTopics');
if ( $manager->subscribed() ) {
$manager->unsubscribe();
}
else {
$manager->subscribe();
}
}
/**
* Subscribes/unsubscribes to new posts in current topic
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnToogleTopicPostsSubscribe(kEvent $event)
{
$object = $event->getObject();
/* @var $object kDBItem */
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$manager = $post_helper->getSubscriptionManager('TopicPosts', Array ($object->GetID()));
if ( $manager->subscribed() ) {
$manager->unsubscribe();
}
else {
$manager->subscribe();
}
}
- }
\ No newline at end of file
+
+ /**
+ * Adds fields for forum preferences.
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnModifyUserProfileConfig(kEvent $event)
+ {
+ $checkbox_field = array(
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options' => array(1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
+ 'default' => 0,
+ );
+ $text_field = array('type' => 'string', 'default' => '');
+
+ $new_virtual_fields = array(
+ 'show_sig' => $checkbox_field,
+ 'Perpage_Topics' => $text_field,
+ 'Perpage_Postings' => $text_field,
+ 'owner_notify' => $checkbox_field,
+ 'bb_pm_notify' => $checkbox_field,
+ 'bbcode' => $checkbox_field,
+ 'smileys' => $checkbox_field,
+ 'bb_signatures' => $checkbox_field,
+ 'my_signature' => $text_field,
+ );
+
+ $config = $event->MasterEvent->getUnitConfig();
+ $config->setVirtualFields(array_merge($config->getVirtualFields(array()), $new_virtual_fields));
+ }
+
+ }
Index: branches/5.3.x/units/topics/topics_config.php
===================================================================
--- branches/5.3.x/units/topics/topics_config.php (revision 16396)
+++ branches/5.3.x/units/topics/topics_config.php (revision 16397)
@@ -1,574 +1,585 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
$config = Array (
'Prefix' => 'bb',
'ItemClass' => Array ('class' => 'kCatDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kCatDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'TopicsEventHandler', 'file' => 'topics_event_handler.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'TopicsTagProcessor', 'file' => 'topics_tag_processor.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'PerPage',
4 => 'event',
5 => 'mode',
),
'ConfigPriority' => 0,
'Hooks' => Array (
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => '',
'HookToSpecial' => '*',
'HookToEvent' => Array ('OnAfterConfigRead'),
'DoPrefix' => 'cdata',
'DoSpecial' => '*',
'DoEvent' => 'OnDefineCustomFields',
),
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'rev',
'HookToSpecial' => '*',
'HookToEvent' => Array ('OnAfterConfigRead'),
'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnCloneSubItem',
),
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'fav',
'HookToSpecial' => '*',
'HookToEvent' => Array ('OnAfterConfigRead'),
'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnCloneSubItem',
),
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'rel',
'HookToSpecial' => '*',
'HookToEvent' => Array ('OnAfterConfigRead'),
'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnCloneSubItem',
),
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'img',
'HookToSpecial' => '*',
'HookToEvent' => Array ('OnAfterConfigRead'),
'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnCloneSubItem',
),
Array (
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'ci',
'HookToSpecial' => '*',
'HookToEvent' => Array ('OnAfterConfigRead'),
'DoPrefix' => '',
'DoSpecial' => '*',
'DoEvent' => 'OnCloneSubItem',
),
+
+ array(
+ 'Mode' => hBEFORE,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'user-profile',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => array('OnAfterConfigRead'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '*',
+ 'DoEvent' => 'OnModifyUserProfileConfig',
+ ),
),
'CatalogItem' => true,
'AdminTemplatePath' => 'topics',
'AdminTemplatePrefix' => 'topics_',
'SearchConfigPostfix' => 'topics',
'IDField' => 'TopicId',
'StatusField' => Array ('Status'), // field, that is affected by Approve/Decline events
'TitleField' => 'TopicText', // field, used in bluebar when editing existing item
'TitlePhrase' => 'la_Text_Topic', // phrase used to specify item type in relationship list
'OwnerField' => 'OwnerId', // usually it is CreatedById
'TitlePresets' => Array (
'default' => Array (
'new_status_labels' => Array ('bb' => '!la_title_AddingTopic!'),
'edit_status_labels' => Array ('bb' => '!la_title_EditingTopic!'),
'new_titlefield' => Array ('bb' => '!la_title_NewTopic!'),
),
'topics_edit' => Array ('prefixes' => Array ('bb'), 'format' => "#bb_status# '#bb_titlefield#' - !la_title_General!"),
'topics_categories' => Array ('prefixes' => Array ('bb', 'bb-ci_List'), 'format' => "#bb_status# '#bb_titlefield#' - !la_title_Categories!"),
'topics_relations' => Array ('prefixes' => Array ('bb'), 'format' => "#bb_status# '#bb_titlefield#' - !la_title_Relations!"),
'topics_images' => Array ('prefixes' => Array ('bb'), 'format' => "#bb_status# '#bb_titlefield#' - !la_title_Images!"),
'topics_reviews' => Array ('prefixes' => Array ('bb'), 'format' => "#bb_status# '#bb_titlefield#' - !la_title_Reviews!"),
'topics_custom' => Array ('prefixes' => Array ('bb'), 'format' => "#bb_status# '#bb_titlefield#' - !la_title_Custom!"),
'images_edit' => Array (
'prefixes' => Array ('bb', 'bb-img'),
'new_status_labels' => Array ('bb-img' => '!la_title_Adding_Image!'),
'edit_status_labels' => Array ('bb-img' => '!la_title_Editing_Image!'),
'new_titlefield' => Array ('bb-img' => '!la_title_New_Image!'),
'format' => "#bb_status# '#bb_titlefield#' - #bb-img_status# '#bb-img_titlefield#'",
),
'reviews_edit' => Array (
'prefixes' => Array ('bb', 'bb-rev'),
'new_status_labels' => Array ('bb-rev' =>"!la_title_Adding_Review! '!la_title_New_Review!'"),
'edit_status_labels' => Array ('bb-rev' => '!la_title_Editing_Review!'),
'format' => "#bb_status# '#bb_titlefield#' - #bb-rev_status#",
),
'relations_edit' => Array (
'prefixes' => Array ('bb', 'bb-rel'),
'new_status_labels' => Array ('bb-rel' =>"!la_title_Adding_Relationship! '!la_title_New_Relationship!'"),
'edit_status_labels' => Array ('bb-rel' => '!la_title_Editing_Relationship!'),
'format' => "#bb_status# '#bb_titlefield#' - #bb-rel_status#",
),
'tree_in-bulletin' => Array ('format' => '!la_Text_Version! '.$this->Application->findModule('Name', 'In-Bulletin', 'Version')),
),
'EditTabPresets' => Array (
'Default' => Array (
'general' => Array ('title' => 'la_tab_General', 't' => 'in-bulletin/topics/topics_edit', 'priority' => 1),
'categories' => Array ('title' => 'la_tab_Categories', 't' => 'in-bulletin/topics/topics_categories', 'priority' => 2),
'relations' => Array ('title' => 'la_tab_Relations', 't' => 'in-bulletin/topics/topics_relations', 'priority' => 3),
'images' => Array ('title' => 'la_tab_Images', 't' => 'in-bulletin/topics/topics_images', 'priority' => 4),
'reviews' => Array ('title' => 'la_tab_Reviews', 't' => 'in-bulletin/topics/topics_reviews', 'priority' => 5),
'custom' => Array ('title' => 'la_tab_Custom', 't' => 'in-bulletin/topics/topics_custom', 'priority' => 6),
),
),
'PermItemPrefix' => 'TOPIC',
'PermTabText' => 'In-Bulletin',
'PermSection' => Array ('main' => 'CATEGORY:in-bulletin:topics_list', 'search' => 'in-bulletin:configuration_search', 'custom' => 'in-bulletin:configuration_custom'),
'Sections' => Array (
/*'in-bulletin' => Array (
'parent' => 'in-portal:root',
'icon' => 'settings_in-bulletin',
'label' => 'la_title_In-Bulletin',
'url' => Array ('t' => 'index', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view'),
'priority' => 3.3,
'container' => true,
'type' => stTREE,
),*/
'in-bulletin:topics' => Array (
'parent' => 'in-portal:site',
'icon' => 'topics',
'label' => 'la_tab_Topics',
'url' => Array ('t' => 'catalog/advanced_view', 'anchor' => 'tab-bb.showall', 'pass' => 'm'),
'onclick' => 'setCatalogTab(\'bb.showall\')',
'permissions' => Array ('view'),
'priority' => 3.4,
'type' => stTREE,
),
// topic settings
'in-bulletin:setting_folder' => Array (
'parent' => 'in-portal:system',
'icon' => 'conf_topics',
'label' => 'la_title_In-Bulletin',
'use_parent_header' => 1,
'url' => Array ('t' => 'index', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view'),
'priority' => 3.5,
'container' => true,
'type' => stTREE,
),
/*'in-bulletin:inbulletin_general' => Array (
'parent' => 'in-bulletin:setting_folder',
'icon' => 'core:settings_general',
'label' => 'la_tab_GeneralSettings',
'url' => Array ('t' => 'config/config_general', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view', 'add', 'edit'),
'priority' => 2.9,
'type' => stTREE,
),*/
'in-bulletin:configuration_output' => Array (
'parent' => 'in-bulletin:setting_folder',
'icon' => 'core:conf_output',
'label' => 'la_tab_ConfigOutput',
'url' => Array ('t' => 'config/config_general', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view', 'add', 'edit'),
'priority' => 3,
'type' => stTREE,
),
'in-bulletin:configuration_search' => Array (
'parent' => 'in-bulletin:setting_folder',
'icon' => 'core:conf_search',
'label' => 'la_tab_ConfigSearch',
'url' => Array ('t' => 'config/config_search', 'module_key' => 'topics', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array ('view', 'edit'),
'priority' => 4,
'type' => stTREE,
),
'in-bulletin:configuration_custom' => Array (
'parent' => 'in-bulletin:setting_folder',
'icon' => 'core:conf_customfields',
'label' => 'la_tab_ConfigCustom',
'url' => Array ('t' => 'custom_fields/custom_fields_list', 'cf_type' => 3, 'pass_section' => true, 'pass' => 'm,cf'),
'permissions' => Array ('view', 'add', 'edit', 'delete'),
'priority' => 5,
'type' => stTREE,
),
),
'FilterMenu' => Array (
'Groups' => Array (
Array ('mode' => 'AND', 'filters' => Array ('show_new'), 'type' => kDBList::HAVING_FILTER),
Array ('mode' => 'AND', 'filters' => Array ('show_hot'), 'type' => kDBList::HAVING_FILTER),
Array ('mode' => 'AND', 'filters' => Array ('show_pop'), 'type' => kDBList::HAVING_FILTER),
Array ('mode' => 'AND', 'filters' => Array ('show_pick'), 'type' => kDBList::WHERE_FILTER),
),
'Filters' => Array (
'show_new' => Array ('label' => 'la_Text_New', 'on_sql' => '', 'off_sql' => '`IsNew` != 1' ),
'show_hot' => Array ('label' => 'la_Text_Hot', 'on_sql' => '', 'off_sql' => '`IsHot` != 1' ),
'show_pop' => Array ('label' => 'la_Text_Pop', 'on_sql' => '', 'off_sql' => '`IsPop` != 1' ),
'show_pick' => Array ('label' => 'la_prompt_EditorsPick', 'on_sql' => '', 'off_sql' => '%1$s.`EditorsPick` != 1' ),
),
),
'CatalogSelectorName' => 'topiclist',
'ItemPropertyMappings' => Array (
'NewDays' => 'Topic_NewDays', // number of days item to be NEW
'MinPopVotes' => 'Topic_MinPopVotes', // minimum number of votes for an item to be POP
'MinPopRating' => 'Topic_MinPopRating', // minimum rating for an item to be POP
'MaxHotNumber' => 'Topic_MaxHotNumber', // maximum number of HOT items
'HotLimit' => 'Topic_HotLimit', // variable name in inp_Cache table
'ClickField' => 'Views', // item click count is stored here (in item table)
),
'ItemType' => 3, // this is used when relation to product is added from in-portal and via-versa
'ViewMenuPhrase' => 'la_title_Topics',
'CatalogTabIcon' => 'in-bulletin:icon16_topics.png',
'UsePendingEditing' => true, // item editing is controlled by TOPIC.ADD/EDIT, TOPIC.ADD/EDIT.PENDING permissions
'StatisticsInfo' => Array (
'pending' => Array (
'icon' => 'icon16_topic_pending.gif',
'label' => 'la_Text_Topics',
'js_url' => '#url#',
'url' => Array ('t' => 'catalog/advanced_view', 'SetTab' => 'bb', 'pass' => 'm,bb.showall', 'bb.showall_event' => 'OnSetFilterPattern', 'bb.showall_filters' => 'show_active=0,show_pending=1,show_disabled=0,show_new=1,show_hot=1,show_pop=1,show_pick=1'),
'status' => STATUS_PENDING,
),
),
'TableName' => TABLE_PREFIX.'Topic',
'CustomDataTableName' => TABLE_PREFIX . 'TopicCustomData',
'CalculatedFields' => Array (
'' => Array (
'UserName' => 'IF (ISNULL(u.Username), IF (%1$s.OwnerId = ' . USER_ROOT . ', "root", IF (%1$s.OwnerId = ' . USER_GUEST . ', "Guest", "n/a")), IF(u.Username = "", u.Email, u.Username))',
'CategoryId' => TABLE_PREFIX.'%3$sCategoryItems.CategoryId',
'Filename' => TABLE_PREFIX.'%3$sCategoryItems.Filename',
'CategoryFilename' => TABLE_PREFIX.'Categories.NamedParentPath',
'PrimaryCat' => TABLE_PREFIX.'%3$sCategoryItems.PrimaryCat',
'ParentPath' => TABLE_PREFIX.'Categories.ParentPath',
'AltName' => 'img.AltName',
'SameImages' => 'img.SameImages',
'LocalThumb' => 'img.LocalThumb',
'ThumbPath' => 'img.ThumbPath',
'ThumbUrl' => 'img.ThumbUrl',
'LocalImage' => 'img.LocalImage',
'LocalPath' => 'img.LocalPath',
'FullUrl' => 'img.Url',
'LastPoster' => 'IF (ISNULL(last_post.PosterAlias), "Guest", last_post.PosterAlias)',
'LastPosterId' => 'last_post.CreatedById',
),
),
'ListSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryItems ON '.TABLE_PREFIX.'%3$sCategoryItems.ItemResourceId = %1$s.ResourceId
{PERM_JOIN}
LEFT JOIN '.TABLE_PREFIX.'Categories ON '.TABLE_PREFIX.'Categories.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId
LEFT JOIN '.TABLE_PREFIX.'%3$sCatalogImages img ON img.ResourceId = %1$s.ResourceId AND img.DefaultImg = 1
LEFT JOIN '.TABLE_PREFIX.'Users u ON %1$s.OwnerId = u.PortalUserId
LEFT JOIN '.TABLE_PREFIX.'%3$sPosting last_post ON last_post.PostingId = %1$s.LastPostId
LEFT JOIN '.TABLE_PREFIX.'%3$sTopicCustomData cust ON %1$s.ResourceId = cust.ResourceId',
),
'ListSortings' => Array (
'' => Array (
'ForcedSorting' => Array ('EditorsPick' => 'desc', 'Priority' => 'desc'),
'Sorting' => Array ('TopicText' => 'asc'),
)
),
'ItemSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryItems ON '.TABLE_PREFIX.'%3$sCategoryItems.ItemResourceId = %1$s.ResourceId
LEFT JOIN '.TABLE_PREFIX.'Categories ON '.TABLE_PREFIX.'Categories.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId
LEFT JOIN '.TABLE_PREFIX.'%3$sCatalogImages img ON img.ResourceId = %1$s.ResourceId AND img.DefaultImg = 1
LEFT JOIN '.TABLE_PREFIX.'Users u ON %1$s.OwnerId = u.PortalUserId
LEFT JOIN '.TABLE_PREFIX.'%3$sPosting last_post ON last_post.PostingId = %1$s.LastPostId
LEFT JOIN '.TABLE_PREFIX.'%3$sTopicCustomData cust ON %1$s.ResourceId = cust.ResourceId'
),
'SubItems' => Array ('bb-rev', 'bb-ci', 'bb-rel', 'bb-img', 'bb-cdata', 'bb-fav', 'bb-post'),
'Fields' => Array (
'TopicId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0,),
'NotifyOwnerOnChanges' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (0 => 'lu_No', 1 => 'lu_Yes'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 0,
),
'Modified' => Array (
'type' => 'int',
'formatter' => 'kDateFormatter',
'required' => 1, 'default' => '#NOW#',
),
'TopicText' => Array (
'type' => 'string',
'required' => 1, 'default' => '', 'not_null' => 1,
),
'AutomaticFilename' => Array ('type' => 'int', 'not_null' => 1, 'default' => 1),
'Posts' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Views' => Array (
'type' => 'double',
'formatter' => 'kFormatter',
'format' => '%d',
'not_null' => 1, 'default' => 0,
),
'EditorsPick' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (0 => 'la_No', 1 => 'la_Yes', ), 'use_phrases' => 1,
'not_null' => 1, 'default' => 0,
),
'Status' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (
0 => 'la_Disabled',
1 => 'la_Active',
2 => 'la_Pending',
),
'use_phrases' => 1,
'not_null' => 1, 'default' => 2,
),
'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'OwnerId' => Array (
'type' => 'int',
'formatter' => 'kLEFTFormatter',
'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'),
'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s',
'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD,
'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'),
'sample_value' => 'Guest', 'required' => 1, 'default' => NULL,
),
'ModifiedById' => Array (
'type' => 'int',
'formatter' => 'kLEFTFormatter',
'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'),
'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s',
'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD,
'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'),
'default' => NULL,
),
'ResourceId' => Array ('type' => 'int', 'default' => null),
'TopicType' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (0 => 'la_Yes', 1 => 'la_No'), 'use_phrases' => 1,
'not_null' => 1, 'default' => 1,
),
'CreatedOn' => Array (
'type' => 'double',
'formatter' => 'kDateFormatter',
'required' => 1, 'default' => '#NOW#',
),
'CachedReviewsQty' => Array ('type' => 'int' , 'not_null' => 1, 'default' => 0),
'CachedRating' => Array ('type' => 'string', 'not_null' => 1, 'default' => 0),
'CachedVotesQty' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'NewItem' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'use_phrases' => 1,
'options' => Array (
2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never',
),
'default' => 2, 'not_null' => 1,
),
'PopItem' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'use_phrases' => 1,
'options' => Array (
2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never',
),
'default' => 2, 'not_null' => 1,
),
'HotItem' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'use_phrases' => 1,
'options' => Array (
2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never',
),
'default' => 2, 'not_null' => 1,
),
'PostedBy' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
'OrgId' => Array ('type' => 'int', 'default' => null),
'LastPostId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'LastPostDate' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => null),
'TodayDate' => Array ('type' => 'string', 'default' => null),
'TodayPosts' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'MetaKeywords' => Array ('type' => 'string', 'default' => null),
'MetaDescription' => Array (
'type' => 'string',
'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null
),
),
'VirtualFields' => Array (
'Relevance' => Array ('type' => 'float', 'default' => 0),
'UserName' => Array ('type' => 'string', 'default' => ''),
'CategoryId' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (),
'default' => 0,
),
'Filename' => Array ('type' => 'string', 'default' => ''),
'CategoryFilename' => Array ('type' => 'string', 'default' => ''),
'PrimaryCat' => Array ('type' => 'int', 'default' => 0),
'IsHot' => Array ('type' => 'int', 'default' => 0),
'IsNew' => Array ('type' => 'int', 'default' => 0),
'IsPop' => Array ('type' => 'int', 'default' => 0),
'CachedNavbar' => Array ('type' => 'string', 'default' => ''),
'ParentPath' => Array ('type' => 'string', 'default' => ''),
'LastPoster' => Array ('type' => 'string', 'default' => ''),
'LastPosterId' => Array ('type' => 'int', 'default' => USER_GUEST),
'PostingText' => Array (
'type' => 'string',
'formatter' => 'kFormatter', 'using_fck' => 1,
'required' => 1, 'allow_html' => 1, 'default' => '',
),
'DisableBBCodes' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (0 => 'la_No', 1 => 'la_Yes',), 'use_phrases' => 1,
'default' => 0,
),
'DisableSmileys' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (0 => 'la_No', 1 => 'la_Yes',), 'use_phrases' => 1,
'default' => 0,
),
'ShowSignatures' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter',
'options' => Array (0 => 'la_No', 1 => 'la_Yes',), 'use_phrases' => 1,
- 'default' => 1,
+ 'default' => 0,
),
// for primary image
'AltName' => Array ('type' => 'string', 'default' => ''),
'SameImages' => Array ('type' => 'string', 'default' => ''),
'LocalThumb' => Array ('type' => 'string', 'default' => ''),
'ThumbPath' => Array ('type' => 'string', 'default' => ''),
'ThumbUrl' => Array ('type' => 'string', 'default' => ''),
'LocalImage' => Array ('type' => 'string', 'default' => ''),
'LocalPath' => Array ('type' => 'string', 'default' => ''),
'FullUrl' => Array ('type' => 'string', 'default' => ''),
),
'Grids' => Array (
'Default' => Array (
'Icons' => Array (
'default' => 'icon16_topic.png',
0 => 'icon16_topic_disabled.png',
1 => 'icon16_topic.png',
2 => 'icon16_topic_pending.png',
'NEW' => 'icon16_topic_new.png',
),
'Fields' => Array (
'TopicId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
'TopicText' => Array ('title' => 'la_col_TopicText', 'data_block' => 'grid_catitem_td', 'filter_block' => 'grid_like_filter', 'width' => 300, 'first_chars' => 290, ),
'Priority' => Array ('filter_block' => 'grid_range_filter', 'width' => 65),
'UserName' => Array ('title' => 'column:la_fld_PostedBy', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
'CreatedOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145, ),
'Status' => Array ('filter_block' => 'grid_options_filter', 'width' => 70, ),
'LastPostDate' => Array ('title' => 'la_col_LastPostOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ),
'Posts' => Array ('title' => 'la_col_Posts', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
'Views' => Array ('filter_block' => 'grid_range_filter', 'width' => 70, ),
),
),
'Radio' => Array (
'Icons' => Array (
'default' => 'icon16_topic.png',
0 => 'icon16_topic_disabled.png',
1 => 'icon16_topic.png',
2 => 'icon16_topic_pending.png',
'NEW' => 'icon16_topic_new.png',
),
'Selector' => 'radio',
'Fields' => Array (
'TopicId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
'TopicText' => Array ('title' => 'la_col_TopicText', 'data_block' => 'grid_catitem_td', 'filter_block' => 'grid_like_filter', 'width' => 300, 'first_chars' => 290, ),
'Priority' => Array ('filter_block' => 'grid_range_filter', 'width' => 65),
'UserName' => Array ('title' => 'column:la_fld_PostedBy', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
'CreatedOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145, ),
'Status' => Array ('filter_block' => 'grid_options_filter', 'width' => 70, ),
'LastPostDate' => Array ('title' => 'la_col_LastPostOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ),
'Posts' => Array ('title' => 'la_col_Posts', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
'Views' => Array ('filter_block' => 'grid_range_filter', 'width' => 70, ),
),
),
),
'ConfigMapping' => Array (
'PerPage' => 'Perpage_Topics',
'ShortListPerPage' => 'Perpage_Topics_Short',
'ForceEditorPick' => 'Topic_EditorPicksAbove',
'DefaultSorting1Field' => 'Topic_SortField',
'DefaultSorting2Field' => 'Topic_SortField2',
'DefaultSorting1Dir' => 'Topic_SortOrder',
'DefaultSorting2Dir' => 'Topic_SortOrder2',
'RatingDelayValue' => 'topic_RatingDelay_Value',
'RatingDelayInterval' => 'topic_RatingDelay_Interval',
),
);
Index: branches/5.3.x/units/posts/posts_config.php
===================================================================
--- branches/5.3.x/units/posts/posts_config.php (revision 16396)
+++ branches/5.3.x/units/posts/posts_config.php (revision 16397)
@@ -1,111 +1,111 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
$config = Array (
'Prefix' => 'bb-post',
'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'PostEventHandler', 'file' => 'post_eh.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'PostTagProcessor', 'file' => 'post_tp.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'PerPage',
4 => 'event',
),
'IDField' => 'PostingId',
'StatusField' => Array ('Pending'),
'TitleField' => 'Subject',
'TableName' => TABLE_PREFIX.'Posting',
'ForeignKey' => 'TopicId',
'ParentTableKey' => 'TopicId',
'ParentPrefix' => 'bb',
'AutoDelete' => true,
'AutoClone' => true,
'ListSQLs' => Array (
'' => ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Users u ON %1$s.CreatedById = u.PortalUserId
LEFT JOIN '.TABLE_PREFIX.'CatalogImages img ON (img.ResourceId = u.ResourceId) AND (img.DefaultImg = 1 OR img.Name = "avatar")',
),
'ListSortings' => Array (
'' => Array (
'ForcedSorting' => Array ('CreatedOn' => 'asc',),
),
),
'CalculatedFields' => Array (
'' => Array (
'UserName' => 'IF (ISNULL(u.Username), IF (%1$s.CreatedById = ' . USER_ROOT . ', "root", IF (%1$s.CreatedById = ' . USER_GUEST . ', "Guest", "n/a")), IF(u.Username = "", u.Email, u.Username))',
'AltName' => 'img.AltName',
'SameImages' => 'img.SameImages',
'LocalThumb' => 'img.LocalThumb',
'ThumbPath' => 'img.ThumbPath',
'ThumbUrl' => 'img.ThumbUrl',
'LocalImage' => 'img.LocalImage',
'LocalPath' => 'img.LocalPath',
'FullUrl' => 'img.Url',
),
),
'Fields' => Array (
'PostingId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'IPAddress' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'PosterAlias' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
'Pending' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Subject' => Array ('type' => 'string', 'max_len' => 255, 'default' => NULL),
'PostingText' => Array ('type' => 'string', 'allow_html' => 1, 'default' => NULL),
'GraphicsUrl' => Array ('type' => 'string', 'max_len' => 255, 'default' => NULL),
'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
'Modified' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL),
'ModifiedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'default' => NULL),
'CreatedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'default' => NULL),
'TopicId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'ResourceId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'ReplyTo' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Options' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
),
'VirtualFields' => Array (
'DisableBBCodes' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'default' => 0),
'DisableSmileys' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'default' => 0),
- 'ShowSignatures' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'default' => 1),
+ 'ShowSignatures' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'default' => 0),
'UserName' => Array ('type' => 'string', 'default' => ''),
// for avatar image
'AltName' => Array ('type' => 'string', 'default' => ''),
'SameImages' => Array ('type' => 'string', 'default' => ''),
'LocalThumb' => Array ('type' => 'string', 'default' => ''),
'ThumbPath' => Array ('type' => 'string', 'default' => ''),
'ThumbUrl' => Array ('type' => 'string', 'default' => ''),
'LocalImage' => Array ('type' => 'string', 'default' => ''),
'LocalPath' => Array ('type' => 'string', 'default' => ''),
'FullUrl' => Array ('type' => 'string', 'default' => ''),
),
'ConfigMapping' => Array (
'PerPage' => 'Perpage_Postings',
),
-);
\ No newline at end of file
+);
Index: branches/5.3.x/units/posts/post_eh.php
===================================================================
--- branches/5.3.x/units/posts/post_eh.php (revision 16396)
+++ branches/5.3.x/units/posts/post_eh.php (revision 16397)
@@ -1,454 +1,460 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PostEventHandler extends kDBEventHandler {
/**
* Checks topic-post modify and delete permissions
*
* @param kEvent $event
* @return bool
* @access public
*/
public function CheckPermission(kEvent $event)
{
$events = Array ('OnUpdate', 'OnDelete');
if ( in_array($event->Name, $events) ) {
return true;
}
return parent::CheckPermission($event);
}
/**
* Sets default values
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemCreate(kEvent $event)
{
parent::OnBeforeItemCreate($event);
$object = $event->getObject();
/* @var $object kDBItem */
$user_id = $this->Application->RecallVar('user_id');
$now = time();
$object->SetDBField('CreatedById', $user_id);
$object->SetDBField('CreatedOn_date', $now);
$object->SetDBField('CreatedOn_time', $now);
$object->SetDBField('ModifiedById', $user_id);
$object->SetDBField('Modified_date', $now);
$object->SetDBField('Modified_time', $now);
$object->SetDBField('IPAddress', $this->Application->getClientIp());
$sql = 'SELECT Username
FROM ' . TABLE_PREFIX . 'Users
WHERE PortalUserId = ' . $user_id;
$object->SetDBField('PosterAlias', $this->Conn->GetOne($sql));
// set post options
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$options_map = $post_helper->getOptionsMap();
$post_options = $object->GetDBField('Options');
foreach ($options_map as $option_name => $field_name) {
$option_value = $object->GetDBField($field_name);
$post_helper->SetPostOption($option_name, $option_value, $post_options);
}
$object->SetDBField('Options', $post_options);
$table_info = $object->getLinkedInfo($event->Special, true);
$object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
}
/**
* Checks if user has permission on post
*
* @param kEvent $event
* @param string $permissions
*/
function checkPostPermission($event, $permissions)
{
$object = $event->getObject();
/* @var $object kDBItem */
$sql = 'SELECT ci.CategoryId, p.CreatedById
FROM '.$object->TableName.' p
LEFT JOIN '.TABLE_PREFIX.'Topic t ON t.TopicId = p.TopicId
LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = t.ResourceId AND ci.PrimaryCat = 1
WHERE p.'.$object->IDField.' = '.$object->GetID();
$post_info = $this->Conn->GetRow($sql);
$perm_helper = $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$is_owner = $post_info['CreatedById'] == $this->Application->RecallVar('user_id');
$params['permissions'] = 'TOPIC.REPLY.MODIFY|TOPIC.REPLY.OWNER.MODIFY';
$params['cat_id'] = $post_info['CategoryId'];
return $perm_helper->TagPermissionCheck($params, $is_owner);
}
/**
* Sets post options before post update
* Ensures, that only user with permission will update topic
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemUpdate(kEvent $event)
{
parent::OnBeforeItemUpdate($event);
$object = $event->getObject();
/* @var $object kDBItem */
$perm_status = $this->checkPostPermission($event, 'TOPIC.REPLY.MODIFY|TOPIC.REPLY.OWNER.MODIFY');
if ( !$perm_status ) {
$event->status = kEvent::erFAIL;
return;
}
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$options_map = $post_helper->getOptionsMap();
$post_options = $object->GetDBField('Options');
foreach ($options_map as $option_name => $field_name) {
$option_value = $object->GetDBField($field_name);
$post_helper->SetPostOption($option_name, $option_value, $post_options);
}
$object->SetDBField('Options', $post_options);
}
/**
* Notifies admin about post change
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemUpdate(kEvent $event)
{
parent::OnAfterItemUpdate($event);
$object = $event->getObject();
/* @var $object kDBItem */
$this->Application->emailAdmin('POST.MODIFY', null, $object->getEmailParams());
}
/**
* Checks, that user can delete post
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemDelete(kEvent $event)
{
parent::OnBeforeItemDelete($event);
$object = $event->getObject();
/* @var $object kDBItem */
if ( !$this->checkPostPermission($event, 'TOPIC.REPLY.OWNER.DELETE|TOPIC.REPLY.DELETE') ) {
$event->status = kEvent::erFAIL;
}
}
/**
* Sets post options to virtual fields
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemLoad(kEvent $event)
{
parent::OnAfterItemLoad($event);
$object = $event->getObject();
/* @var $object kDBItem */
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$options_map = $post_helper->getOptionsMap();
$post_options = $object->GetDBField('Options');
foreach ($options_map as $option_name => $field_name) {
$option_value = $post_helper->GetPostOption($option_name, $post_options);
$object->SetDBField($field_name, (int)$option_value);
}
}
/**
* Updates cached post counter in topic
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemCreate(kEvent $event)
{
parent::OnAfterItemCreate($event);
$object = $event->getObject();
/* @var $object kDBItem */
$parent_prefix = $event->getUnitConfig()->getParentPrefix();
$main_object = $this->Application->recallObject($parent_prefix);
/* @var $main_object kCatDBItem */
- // update user posts counter
- $user_posts = $this->Application->RecallPersistentVar('bb_posts');
- $this->Application->StorePersistentVar('bb_posts', $user_posts + 1);
+ if ( $this->Application->LoggedIn() ) {
+ // Update user posts counter.
+ $user_posts = $this->Application->RecallPersistentVar('bb_posts');
+ $this->Application->StorePersistentVar('bb_posts', $user_posts + 1);
+ }
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$category_id = $this->Application->GetVar('m_cat_id');
$post_helper->PropagateCategoryField($category_id, 'Modified', $object->GetDBField('CreatedOn'));
if ( !$this->Application->isAdmin && $main_object->GetDBField('Posts') ) {
// don't send any email events when in admin OR new topic just added (0 posts)
$user_notified = false; // don't send POST.ADD event twice to same user (in case if owner adds new post)
$send_params = $object->getEmailParams();
if ( $main_object->GetDBField('NotifyOwnerOnChanges') ) {
$user_notified = $main_object->GetDBField('OwnerId');
$this->Application->emailUser('POST.ADD', $user_notified, $send_params);
}
$post_owner_id = $object->GetDBField('CreatedById');
if ( ($post_owner_id > 0) && ($user_notified != $post_owner_id) ) {
$this->Application->emailUser('POST.ADD', $post_owner_id, $send_params);
}
$this->Application->emailAdmin('POST.ADD', null, $send_params);
}
$post_helper->updateTodayPostsCount($main_object, $object->GetDBField('CreatedOn'), +1);
$this->updateTopicInfo($event, $main_object);
$topic_id = $object->GetDBField('TopicId');
$posts_count = $post_helper->updatePostCount($topic_id, +1);
$main_object->SetDBField('Posts', $posts_count);
// auto-lock topic after N number of posts (if option enabled)
$auto_lock = $this->Application->ConfigValue('AutoTopicLockPosts');
if ( (int)$auto_lock > 0 ) {
if ( $posts_count >= $auto_lock ) {
// user has unlocked topic after $auto_lock and posts again -> ensure that topic will be locked again
$this->Application->HandleEvent(new kEvent($parent_prefix . ':OnTopicLockToggle'));
}
}
}
/**
* Update last post info in topic
*
* @param kEvent $event
* @param kCatDBItem $main_object
*/
function updateTopicInfo($event, &$main_object)
{
$object = $event->getObject();
/* @var $object kDBItem */
$main_object->SetDBField('Modified_date', $object->GetDBField('Modified'));
$main_object->SetDBField('Modified_time', $object->GetDBField('Modified'));
$main_object->SetDBField('LastPostId', $object->GetID());
$main_object->SetDBField('LastPostDate_date', $object->GetDBField('CreatedOn'));
$main_object->SetDBField('LastPostDate_time', $object->GetDBField('CreatedOn'));
$main_object->Update();
}
/**
* Goes to next_template after post creation
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnCreate(kEvent $event)
{
parent::OnCreate($event);
if ( $event->status == kEvent::erSUCCESS && !$this->Application->isAdmin ) {
$event->SetRedirectParam('opener', 's');
$event->redirect = $this->Application->GetVar('next_template');
}
}
/**
* Goes to next_template after post editing
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnUpdate(kEvent $event)
{
parent::OnUpdate($event);
if ($event->status == kEvent::erSUCCESS && !$this->Application->isAdmin) {
$event->SetRedirectParam('opener', 's');
$event->redirect = $this->Application->GetVar('next_template');
$event->SetRedirectParam('pass', 'm,bb');
}
}
/**
* Moves reference to last post in topic, when it is deleted
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemDelete(kEvent $event)
{
parent::OnAfterItemDelete($event);
$object = $event->getObject();
/* @var $object kDBItem */
$topic_id = $object->GetDBField('TopicId');
if ( !$topic_id ) {
// deleting post from non-existing topic
return;
}
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
// update posts count in topic
$post_helper->updatePostCount($topic_id, -1);
// update post owner posts counter
$sql = 'UPDATE ' . TABLE_PREFIX . 'UserPersistentSessionData
SET VariableValue = IF (VariableValue > 0, VariableValue - 1, 0)
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));
/* @var $main_object kCatDBItem */
$main_object->Load($topic_id);
if ( !$main_object->isLoaded() ) {
// this is topic deletion proccess, when all it's posts are deleted too
return;
}
$post_helper->updateTodayPostsCount($main_object, $object->GetDBField('CreatedOn'), -1);
if ( $main_object->GetDBField('LastPostId') == $object->GetID() ) {
$sql = 'SELECT PostingId, CreatedOn
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);
}
}
/**
* Sets default values to posting options based on persistent session
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterConfigRead(kEvent $event)
{
parent::OnAfterConfigRead($event);
+ if ( !$this->Application->LoggedIn() ) {
+ return;
+ }
+
$config = $event->getUnitConfig();
$virtual_fields = $config->getVirtualFields();
$virtual_fields['DisableBBCodes']['default'] = (int)!$this->Application->RecallPersistentVar('bbcode');
$virtual_fields['DisableSmileys']['default'] = (int)!$this->Application->RecallPersistentVar('smileys');
$virtual_fields['ShowSignatures']['default'] = (int)$this->Application->RecallPersistentVar('show_sig');
$config->setVirtualFields($virtual_fields);
}
/**
* Deletes items & preserves clean env
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnDelete(kEvent $event)
{
parent::OnDelete($event);
if ( $event->status == kEvent::erSUCCESS && !$this->Application->isAdmin ) {
$parent_prefix = $event->getUnitConfig()->getParentPrefix();
$event->SetRedirectParam('pass', 'm,' . $parent_prefix);
}
}
/**
* Prepares new reply form
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnNew(kEvent $event)
{
parent::OnNew($event);
$reply_to = $this->Application->GetVar('reply_to');
if ( $reply_to > 0 ) {
$object = $event->getObject();
/* @var $object kDBItem */
$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]');
}
}
- }
\ No newline at end of file
+ }
Index: branches/5.3.x/units/posts/post_tp.php
===================================================================
--- branches/5.3.x/units/posts/post_tp.php (revision 16396)
+++ branches/5.3.x/units/posts/post_tp.php (revision 16397)
@@ -1,313 +1,326 @@
<?php
/**
* @version $Id$
* @package In-Bulletin
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class PostTagProcessor extends kDBTagProcessor {
function ListPosts($params)
{
$parent_prefix = $this->getUnitConfig()->getParentPrefix();
$main_object = $this->Application->recallObject($parent_prefix);
/* @var $main_object kCatDBItem */
if ($main_object->isLoaded()) {
$main_object->RegisterHit();
}
return $this->PrintList2($params);
}
/**
* Returns link to post author public profile
*
* @param Array $params
* @return string
*/
function ProfileLink($params)
{
$object = $this->getObject($params);
$params['user_id'] = $object->GetDBField('CreatedById');
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function PosterField($params)
{
static $posters = null;
$object = $this->getObject($params);
/* @var $object kDBItem */
$poster = $this->Application->recallObject('u.poster', null, Array('skip_autoload' => true));
/* @var $poster UsersItem */
if ( !isset($posters) ) {
$poster_ids = array_unique( $object->GetCol('CreatedById') );
$sql = $poster->GetSelectSQL() . '
WHERE ' . $poster->TableName . '.' . $poster->IDField . ' IN (' . implode(',', $poster_ids) . ')';
$posters = $this->Conn->Query($sql, $poster->IDField);
}
$poster_id = $object->GetDBField('CreatedById');
if ($poster_id <= 0) {
// guest and root users
return '';
}
if ($poster->GetID() != $poster_id) {
// previous poster differs from requested
$poster->LoadFromHash( $posters[$poster_id] );
}
return $this->Application->ProcessParsedTag('u.poster', 'Field', $params);
}
/**
* Checks if post is made by real user (not Guest or root)
*
* @param Array $params
* @return bool
*/
function PosterFound($params)
{
$object = $this->getObject($params);
return $object->GetDBField('CreatedById') > 0;
}
/**
* Posts count created by current poster
*
* @param Array $params
* @return int
*/
function PosterPostsCount($params)
{
static $posts_count = null;
$object = $this->getObject($params);
if (!isset($posts_count)) {
$poster_ids = array_unique($object->GetCol('CreatedById'));
$sql = 'SELECT VariableValue, PortalUserId
FROM '.TABLE_PREFIX.'UserPersistentSessionData
WHERE PortalUserId IN ('.implode(',', $poster_ids).') AND VariableName = "bb_posts"';
$posts_count = $this->Conn->GetCol($sql, 'PortalUserId');
}
return $posts_count[$object->GetDBField('CreatedById')];
}
function PostSubject($params)
{
$object = $this->getObject($params);
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
return $post_helper->CensorText( $object->GetDBField('Subject') );
}
function PostBody($params)
{
$object = $this->getObject($params);
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$body = $object->GetDBField('PostingText');
// 2. parse post body
$sub_blocks = Array (
'smileys' => $params['smiley_render_as'],
'bbcode' => $params['bbcode_render_as'],
'quote' => $params['quote_render_as'],
);
$body = $post_helper->parsePostBody($body, $object->GetDBField('Options'), $sub_blocks);
return $body;
}
/**
- * Checks if poster signature needs to be shown together with post
+ * Checks if poster signature needs to be shown together with post.
*
- * @param Array $params
- * @return bool
+ * @param array $params Tag params.
+ *
+ * @return boolean
*/
- function ShowPostSignature($params)
+ protected function ShowPostSignature(array $params)
{
+ static $show_signatures;
+
+ if ( !isset($show_signatures) ) {
+ if ( $this->Application->LoggedIn() ) {
+ $show_signatures = $this->Application->RecallPersistentVar('bb_signatures');
+ }
+ else {
+ $show_signatures = false;
+ }
+ }
+
+ if ( !$show_signatures ) {
+ return false;
+ }
+
+ /** @var kDBItem $object */
$object = $this->getObject($params);
- $post_options = $object->GetDBField('Options');
+ /** @var PostHelper $post_helper */
$post_helper = $this->Application->recallObject('PostHelper');
- /* @var $post_helper PostHelper */
- // show poster signature in this post
- if ($post_helper->GetPostOption('show_sig', $post_options)) {
- // logged-in user wishes to view signatures in posts
- $show_other_signatures = $this->Application->RecallPersistentVar('bb_signatures');
- if ($show_other_signatures) {
- // don't show signature when it is empty
- $signature = $this->getUserSignature($object->GetDBField('CreatedById'));
- return strlen(trim($signature)) ? true : false;
- }
+ // Show poster signature in this post.
+ if ( $post_helper->GetPostOption('show_sig', $object->GetDBField('Options')) ) {
+ // Don't show signature when it is empty.
+ $signature = $this->getUserSignature($object->GetDBField('CreatedById'));
+
+ return strlen(trim($signature)) ? true : false;
}
return false;
}
/**
* Returns parsed poster (from current post) signature
*
* @param Array $params
* @return string
*/
function PostSignature($params)
{
$object = $this->getObject($params);
$post_helper = $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
$sub_blocks = Array (
'smileys' => $params['smiley_render_as'],
'bbcode' => $params['bbcode_render_as'],
);
$signature = $this->getUserSignature($object->GetDBField('CreatedById'));
return $post_helper->parsePostBody($signature, $object->GetDBField('Options'), $sub_blocks);
}
/**
* Returns user signature (cached for all viewed posts on page)
*
* @param int $user_id
* @return string
*/
function getUserSignature($user_id)
{
static $user_signatures = null;
$object = $this->getObject();
if (!isset($user_signatures)) {
$poster_ids = array_unique($object->GetCol('CreatedById'));
$sql = 'SELECT VariableValue, PortalUserId
FROM '.TABLE_PREFIX.'UserPersistentSessionData
WHERE PortalUserId IN ('.implode(',', $poster_ids).') AND VariableName = "my_signature"';
$user_signatures = $this->Conn->GetCol($sql, 'PortalUserId');
}
$poster_id = $object->GetDBField('CreatedById');
return isset($user_signatures[$poster_id]) ? $user_signatures[$poster_id] : '';
}
/**
* Creates link to individual post in topic
*
* @param Array $params
* @return string
*/
function PostLink($params)
{
$params['pass'] = 'm,bb,bb-post';
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
function ReplyQuotedLink($params)
{
$object = $this->getObject($params);
$params['pass'] = 'm,bb';
$params['reply_to'] = $object->GetID();
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
/**
* Checks if user have one of required permissions
*
* @param Array $params
* @return bool
*/
function HasPermission($params)
{
static $category_path = null;
if (!isset($category_path)) {
// get topic category
$parent_prefix = $this->getUnitConfig()->getParentPrefix();
$parent_item = $this->Application->recallObject($parent_prefix, null, Array ('raise_warnings' => 0));
$category_path = $parent_item->isLoaded() ? $parent_item->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id');
}
$perm_helper = $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
$params['raise_warnings'] = 0;
$object = $this->getObject($params);
/* @var $object kDBItem */
// 1. category restriction
$params['cat_id'] = $category_path;
// 2. owner restriction
$is_owner = $object->GetDBField('CreatedById') == $this->Application->RecallVar('user_id');
return $perm_helper->TagPermissionCheck($params, $is_owner);
}
function CategoryItemCount($params)
{
$count_helper = $this->Application->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
return $count_helper->CategoryItemCount('bb', $params, 'SUM(Posts)'); // - COUNT(TopicId)
}
function ItemCount($params)
{
$count_helper = $this->Application->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
$today_only = isset($params['today']) && $params['today'];
return $count_helper->ItemCount('bb', $today_only, 'SUM(Posts)'); // - COUNT(TopicId)
}
/**
* Preserve main item id in subitem pagination url
*
* @param Array $params
* @return string
*/
function PageLink($params)
{
$object = $this->getObject($params);
/* @var kDBList */
$parent_info = $object->getLinkedInfo();
if ($parent_info['ParentId'] > 0) {
$params['pass'] = 'm,'.$this->getPrefixSpecial().','.$parent_info['ParentPrefix'];
}
return parent::PageLink($params);
}
- }
\ No newline at end of file
+ }
Index: branches/5.3.x
===================================================================
--- branches/5.3.x (revision 16396)
+++ branches/5.3.x (revision 16397)
Property changes on: branches/5.3.x
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
Merged /modules/in-bulletin/branches/5.2.x:r16340,16349,16351,16384

Event Timeline