Index: branches/5.0.x/in-bulletin/constants.php
===================================================================
--- branches/5.0.x/in-bulletin/constants.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/constants.php	(revision 12740)
@@ -1,23 +1,23 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	// Private Message Statuses: 0 - Unread, 1 - Viewed', 2 - Read, 3 - Replyed, 4 - Sent
 	define('PM_STATUS_UNREAD', 0);
 	define('PM_STATUS_READ', 2);
 
 	// Private Message Folders
 	define('PM_FOLDER_INBOX', 0);
 	define('PM_FOLDER_SENT', -1);
 
 	define('SMILEYS_PATH', IMAGES_PATH.'emoticons/');
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/emoticons/emoticon_eh.php
===================================================================
--- branches/5.0.x/in-bulletin/units/emoticons/emoticon_eh.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/emoticons/emoticon_eh.php	(revision 12740)
@@ -1,37 +1,37 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class EmoticonEventHandler extends kDBEventHandler {
 
 
 		/**
 		 * Deletes image file
 		 *
 		 * @param kEvent $event
 		 */
 		function OnAfterItemDelete(&$event)
 		{
 			parent::OnAfterItemDelete($event);
 
 			$object =& $event->getObject();
 
 			$emoticon_file = $object->GetField('EmotionImage', 'full_path');
 			if ($emoticon_file) {
 				@unlink($emoticon_file);
 			}
 		}
 
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/emoticons/emoticons_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/emoticons/emoticons_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/emoticons/emoticons_config.php	(revision 12740)
@@ -1,102 +1,102 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config = Array (
 		'Prefix' => 'emoticon',
 		'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
 		'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
 		'EventHandlerClass' => Array ('class' => 'EmoticonEventHandler', 'file' => 'emoticon_eh.php', 'build_event' => 'OnBuild'),
 		'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
 
 		'AutoLoad' => true,
 
 		'QueryString' => Array (
 			1 => 'id',
 			2 => 'Page',
 			3 => 'event',
 			4 => 'mode',
 		),
 
 		'IDField' => 'EmoticonId',
 
 		'TableName' => TABLE_PREFIX.'Emoticon',
 
 		'TitleField' => 'Name',
 
 		'TitlePresets' => Array (
 			'default' => Array (
 				'new_status_labels' => Array ('emoticon' => '!la_title_AddingSmiley!'),
 				'edit_status_labels' => Array ('emoticon' => '!la_title_EditingSmiley!'),
 			),
 
 			'emoticon_list' => Array ('prefixes' => Array ('emoticon_List'), 'format' => "!la_tab_ConfigSmileys!"),
 			'emoticon_edit' => Array ('prefixes' => Array ('emoticon'), 'format' => "#emoticon_status# '#emoticon_titlefield#'"),
 		),
 
 		'PermSection' => Array('main' => 'in-bulletin:configuration_emoticon'),
 
 		'Sections' => Array (
 			'in-bulletin:configuration_emoticon' => Array (
 				'parent'		=>	'in-bulletin:setting_folder',
 				'icon'			=>	'conf_smileys',
 				'label'			=>	'la_tab_ConfigSmileys',
 				'url'			=>	Array('t' => 'in-bulletin/emoticons/emoticon_list', 'pass' => 'm'),
 				'permissions'	=>	Array('view', 'add', 'edit'),
 				'priority'		=>	2,
 				'type'			=>	stTREE,
 			),
 		),
 
 		'ListSQLs' => Array (
 			'' => '	SELECT %1$s.* %2$s FROM %1$s',
 		),
 
 		'ListSortings' => Array (
 			'' => Array (
 				'Sorting' => Array ('Name' => 'desc'),
 			)
 		),
 
 		'Fields' => Array (
 			'EmoticonId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 			'Name' => Array ('type' => 'string', 'max_len' => 20, 'not_null' => 1, 'required' => 1, 'default' => ''),
 			'KeyStroke' => Array ('type' => 'string', 'max_len' => 20, 'not_null' => 1, 'required' => 1, 'default' => ''),
 			'Enabled' => Array ('type' => 'int', 'not_null' => 1, 'default' => 1),
 			'EmotionImage' => Array (
 				'type' => 'string', 'max_len' => 255,
 				'formatter' => 'kUploadFormatter', 'allowed_types' => Array ('image/jpeg', 'image/jpg', 'image/gif', 'image/png', 'image/pjpeg'),
 				'upload_dir' => SMILEYS_PATH,
 				'not_null' => 1, 'required' => 1, 'default' => '',
 			),
 		),
 
 		'Grids' => Array (
 			'Default' => Array (
 				'Icons' => Array (
 					'default' => 'icon16_item.png',
 					0 => 'icon16_disabled.png',
 					1 => 'icon16_item.png',
 					'module' => 'core',
 				),
 				'Fields' => Array (
 					'EmoticonId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 50, ),
 					'Name' => Array ('title' => 'la_col_Name', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
 					'KeyStroke' => Array ('title' => 'la_col_KeyStroke', 'filter_block' => 'grid_like_filter', 'width' => 100, ),
 					'EmotionImage' => Array ('title' => 'la_col_Image', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
 				),
 			),
 		),
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/private_messages/private_message_eh.php
===================================================================
--- branches/5.0.x/in-bulletin/units/private_messages/private_message_eh.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/private_messages/private_message_eh.php	(revision 12740)
@@ -1,251 +1,251 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class PrivateMessageEventHandler extends kDBEventHandler {
 
 		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
 		 */
 		function 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
 		 */
 		function 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
 		 */
 		function OnAfterItemCreate(&$event)
 		{
 			parent::OnAfterItemCreate($event);
 
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$this->Application->EmailEventUser('PM.ADD', $object->GetDBField('ToId'));
 
 			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
 		 */
 		function 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
 		 */
 		function OnCreate(&$event)
 		{
 			parent::OnCreate($event);
 
 			if ($event->status == 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
 		 */
 		function 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 = erFAIL;
 	    	}
 		}
 
 		/**
 		 * Updates reference counter in message body record
 		 *
 		 * @param kEvent $event
 		 */
 		function OnAfterItemDelete(&$event)
 		{
 	    	$object =& $event->getObject();
 	    	/* @var $object kDBItem */
 
 	    	$body_idfield = $this->Application->getUnitOption($event->Prefix.'-body', 'IDField');
 	    	$body_table = $this->Application->getUnitOption($event->Prefix.'-body', 'TableName');
 	    	$sql = 'UPDATE '.$body_table.'
 	    			SET ReferenceCount = ReferenceCount - 1
 	    			WHERE '.$body_idfield.' = '.$object->GetDBField('PMBodyId');
 	    	$this->Conn->Query($sql);
 		}
 
 		/**
 		 * Sets default values to posting options based on persistent session
 		 *
 		 * @param kEvent $event
 		 */
 		function OnAfterConfigRead(&$event)
 		{
 			$virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
 			$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');
 			$this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields);
 		}
 
 		/**
 		 * Checks, that current user is recipient or sender of viewed message
 		 *
 		 * @param kEvent $event
 		 * @return bool
 		 */
 		function checkItemStatus(&$event)
 		{
 			$object =& $event->getObject();
 			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
 		 */
 		function OnNew(&$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);
 			}
 		}
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/private_messages/private_message_tp.php
===================================================================
--- branches/5.0.x/in-bulletin/units/private_messages/private_message_tp.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/private_messages/private_message_tp.php	(revision 12740)
@@ -1,164 +1,164 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class PrivateMessageTagProcessor extends kDBTagProcessor {
 
 		/**
 		 * Checks if private message is unread
 		 *
 		 * @param Array $params
 		 * @return bool
 		 */
 		function IsNew($params)
 		{
 			$object =& $this->getObject();
 			/* @var $object kDBItem */
 
 			return $object->GetDBField('Status') < PM_STATUS_READ;
 		}
 
 		/**
 		 * Allows to check what folder is currently active
 		 *
 		 * @param Array $params
 		 * @return bool
 		 */
 		function FolderSelected($params)
 		{
 			$folder_mapping = Array ('inbox' => PM_FOLDER_INBOX, 'sent' => PM_FOLDER_SENT);
 
 			return (int)$this->Application->GetVar('folder_id') == $folder_mapping[ strtolower($params['folder']) ];
 		}
 
 		/**
 		 * Creates link to specific private message folder
 		 *
 		 * @param Array $params
 		 * @return string
 		 */
 		function FolderLink($params)
 		{
 			$folder_mapping = Array ('inbox' => PM_FOLDER_INBOX, 'sent' => PM_FOLDER_SENT);
 			$params['folder_id'] = $folder_mapping[ strtolower($params['folder']) ];
 			unset($params['folder']);
 
 			return $this->Application->ProcessParsedTag('m', 'Link', $params);
 		}
 
 		function MessageSubject($params)
 		{
 			$object =& $this->getObject();
 			/* @var $object kDBItem */
 
 			$params['field'] = 'Subject';
 			$value = $this->Field($params);
 
 			if (!$value && isset($params['empty_title'])) {
 				return '['.$this->Application->Phrase($params['empty_title']).']';
 			}
 
 			return $value;
 		}
 
 		function MessageBody($params)
 		{
 			$object =& $this->getObject($params);
 
 			$post_helper =& $this->Application->recallObject('PostHelper');
 			/* @var $post_helper PostHelper */
 
 			// 2. parse post body
 			$sub_blocks = Array (
 				'smileys' => $params['smiley_render_as'],
 				'bbcode' => $params['bbcode_render_as'],
 			);
 
 			return $post_helper->parsePostBody($object->GetDBField('Body'), $object->GetDBField('Options'), $sub_blocks);
 		}
 
 		function DeleteLink($params)
 		{
 			$params['pass'] = 'm,'.$this->getPrefixSpecial();
 			$params[$this->getPrefixSpecial().'_event'] = 'OnDelete';
 			return $this->Application->ProcessParsedTag('m', 'Link', $params);
 		}
 
 		function ReplyLink($params)
 		{
 			$params['reply_to'] = $this->Application->GetVar($this->getPrefixSpecial().'_id');
 			return $this->Application->ProcessParsedTag('m', 'Link', $params);
 		}
 
 		/**
 		 * User can reply message only in case, when it is not it's own message
 		 *
 		 * @param Array $params
 		 * @return bool
 		 */
 		function CanReplyMessage($params)
 		{
 			$object =& $this->getObject();
 			/* @var $object kDBItem */
 
 			return $object->GetDBField('FromId') != $this->Application->RecallVar('user_id');
 		}
 
 		/**
 		 * Marks private message as read
 		 *
 		 * @param Array $params
 		 */
 		function MarkAsRead($params)
 		{
 			$object =& $this->getObject();
 			/* @var $object kDBItem */
 
 			if ($object->GetDBField('Status') < PM_STATUS_READ) {
 				$object->SetDBField('Status', PM_STATUS_READ);
 				$object->Update();
 			}
 		}
 
 		/**
 		 * Returns link to private message sender/recipient public profile
 		 *
 		 * @param Array $params
 		 * @return string
 		 */
 		function ProfileLink($params)
 		{
 			$user_field = strtolower($params['type']) == 'from' ? 'FromId' : 'ToId';
 			unset($params['type']);
 
 			$object =& $this->getObject($params);
 			$params['user_id'] = $object->GetDBField($user_field);
 
 			return $this->Application->ProcessParsedTag('m', 'Link', $params);
 		}
 
 		/**
 		 * Returns link for sending private message from user's public profile page
 		 *
 		 * @param Array $params
 		 * @return string
 		 */
 		function SendMessageLink($params)
 		{
 			$params['user_id'] = $this->Application->GetVar('user_id');
 			return $this->Application->ProcessParsedTag('m', 'Link', $params);
 		}
 
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/private_messages/private_messages_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/private_messages/private_messages_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/private_messages/private_messages_config.php	(revision 12740)
@@ -1,109 +1,109 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config = Array (
 		'Prefix' => 'private-message',
 		'ItemClass'			=>	Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
 		'ListClass'			=>	Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
 		'EventHandlerClass'	=>	Array('class' => 'PrivateMessageEventHandler', 'file' => 'private_message_eh.php', 'build_event' => 'OnBuild'),
 		'TagProcessorClass' =>	Array('class' => 'PrivateMessageTagProcessor', 'file' => 'private_message_tp.php', 'build_event' => 'OnBuild'),
 
 		'AutoLoad' => true,
 
 		'QueryString' => Array (
 			1 => 'id',
 			2 => 'Page',
 			3 => 'event',
 			4 => 'mode',
 		),
 
 		'IDField' => 'PmId',
 		'StatusField' => Array ('Status'),
 		'TitleField' => 'Subject',
 
    		'PermSection' => Array('main' => 'in-bulletin:private_messages',),
 
 		'TableName' => TABLE_PREFIX.'PrivateMessages',
 
 		'CalculatedFields' => Array (
 			'' => Array (
 				'Subject' => 'pmb.Subject',
 				'Body' => 'pmb.Body',
 			),
 		),
 
 		'ListSQLs' => Array (
 			'' => ' SELECT %1$s.* %2$s
 					FROM %1$s
 					LEFT JOIN '.TABLE_PREFIX.'%3$sPrivateMessageBody pmb ON pmb.PMBodyId = %1$s.PMBodyId
 					LEFT JOIN '.TABLE_PREFIX.'PortalUser from_user ON from_user.PortalUserId = %1$s.FromId
 					LEFT JOIN '.TABLE_PREFIX.'PortalUser to_user ON to_user.PortalUserId = %1$s.ToId',
 		),
 
 		'ListSortings' => Array (
 			'' => Array(
 				'ForcedSorting' => Array('CreatedOn' => 'desc'),
 			),
 		),
 
 		'ItemSQLs' => Array (
 			'' => ' SELECT %1$s.* %2$s
 					FROM %1$s
 					LEFT JOIN '.TABLE_PREFIX.'%3$sPrivateMessageBody pmb ON pmb.PMBodyId = %1$s.PMBodyId
 					LEFT JOIN '.TABLE_PREFIX.'PortalUser from_user ON from_user.PortalUserId = %1$s.FromId
 					LEFT JOIN '.TABLE_PREFIX.'PortalUser to_user ON to_user.PortalUserId = %1$s.ToId',
 		),
 
 		'SubItems' => Array('private-message-body'),
 
 		'CalculatedFields' => Array (
 			'' => Array (
 				'Subject' => 'pmb.Subject',
 				'Body' => 'pmb.Body',
 				'Options' => 'pmb.Options',
 
 				'FromName' => 'IF (ISNULL(from_user.Login), IF (%1$s.FromId = -1, "root", IF (%1$s.FromId = -2, "Guest", "n/a")), from_user.Login)',
 				'ToName' => 'IF (ISNULL(to_user.Login), IF (%1$s.ToId = -1, "root", IF (%1$s.ToId = -2, "Guest", "n/a")), to_user.Login)',
 
 				'FromFullName' => 'TRIM(CONCAT(from_user.FirstName, " ", from_user.LastName))',
 				'ToFullName' => 'TRIM(CONCAT(to_user.FirstName, " ", to_user.LastName))',
 			),
 		),
 
 		'Fields' => Array (
 			'PmId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'FromId' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!lu_error_UserNotFound!'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'required' => 1, 'default' => null),
 		    'ToId' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!lu_error_UserNotFound!'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'required' => 1, 'default' => null),
 		    'FolderId' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'lu_Inbox', 1 => 'lu_Sent'), 'use_phrases' => 1, 'not_null' => 1, 'default' => PM_FOLDER_SENT),
 		    'Status' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'lu_opt_MessageUnread', 1 => 'lu_opt_MessageViewed', 2 => 'lu_opt_MessageRead', 3 => 'lu_opt_MessageReplied', 4 => 'lu_opt_MessageSent'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
 		    'PMBodyId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
 		),
 
 		'VirtualFields' => Array (
 			'FromName' => Array ('type' => 'string', 'default' => ''),
 			'ToName' => Array ('type' => 'string', 'default' => ''),
 			'Subject' => Array ('type' => 'string', 'default' => ''),
 			'Body' => Array ('type' => 'string',  'required' => 1, 'default' => ''),
 			'Options' => Array ('type' => 'string', 'default' => 0),
 
 			'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),
 		),
 
 
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/topics/topics_tag_processor.php
===================================================================
--- branches/5.0.x/in-bulletin/units/topics/topics_tag_processor.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/topics/topics_tag_processor.php	(revision 12740)
@@ -1,79 +1,79 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class TopicsTagProcessor extends kCatDBTagProcessor {
 
 		function TopicLink($params)
 		{
 			return $this->ItemLink($params, 'topic');
 		}
 
 		function ListTopics($params)
 		{
 			return $this->PrintList2($params);
 		}
 
 		function PostingLink($params)
 		{
 			$item_id = getArrayValue($params, 'posting_id');
 			if (!$item_id) {
 				$item_id = $this->Application->GetVar($this->Prefix.'_post_id');
 			}
 			$params[$this->Prefix.'_post_id'] = $item_id;
 			return $this->TopicLink($params);
 		}
 
 		function PostingDeleteLink($params)
 		{
 			$params['Action'] = 'bb_post_delete';
 			return $this->PostingLink($params);
 		}
 
 		/**
 		 * Returns topic replies count
 		 *
 		 * @param Array $params
 		 * @return int
 		 */
 		function TopicReplies($params)
 		{
 			$object =& $this->getObject($params);
 
 			// -1 - don't count post created together with topic
 			return $object->GetDBField('Posts') ? $object->GetDBField('Posts') - 1 : 0;
 		}
 
 		/**
 		 * Returns topic lock statis
 		 *
 		 * @param Array $params
 		 * @return bool
 		 */
 		function IsLocked($params)
 		{
 			$object =& $this->getObject($params);
 
 			return $object->GetDBField('TopicType') == 0;
 		}
 
 		function LockToggleLink($params)
 		{
 			$params[$this->Prefix.'_event'] = 'OnTopicLockToggle';
 			$params['pass'] = 'm,'.$this->Prefix;
 
 			return $this->Application->ProcessParsedTag('m', 'Link', $params);
 		}
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/topics/topics_event_handler.php
===================================================================
--- branches/5.0.x/in-bulletin/units/topics/topics_event_handler.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/topics/topics_event_handler.php	(revision 12740)
@@ -1,210 +1,210 @@
 <?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.net/license/ for copyright notices and details.
+* 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
 		 */
 		function CheckPermission(&$event)
 		{
 			if ($event->Name == 'OnTopicLockToggle') {
 				$object =& $event->getObject();
 				/* @var $object kCatDBItem */
 
 				if (!$object->isLoaded()) {
 					$event->status = erPERM_FAIL;
 					return false;
 				}
 
 				$category_id = $object->GetDBField('CategoryId');
 				$perm_status = $this->Application->CheckPermission('TOPIC.LOCK', 0, $category_id);
 
 				if (!$perm_status) {
 					$event->status = erPERM_FAIL;
 				}
 
 				return $perm_status;
 			}
 
 			return parent::CheckPermission($event);
 		}
 
 		/**
 		 * Lock or unlock topic
 		 *
 		 * @param kEvent $event
 		 */
 		function OnToggleLock(&$event)
 		{
 			$object =& $event->getObject();
 
 			$new_type = $object->GetDBField('TopicType') ? 0 : 1;
 			$object->SetDBField('TopicType', $new_type);
 			$object->Update();
 		}
 
 		/**
 		 * Cache topic owner
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemUpdate(&$event)
 		{
 			parent::OnBeforeItemUpdate($event);
 
 			$this->cacheItemOwner($event, 'OwnerId', 'PostedBy');
 		}
 
 		/**
 		 * Cache topic owner
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemCreate(&$event)
 		{
 			parent::OnBeforeItemCreate($event);
 
 			$this->cacheItemOwner($event, 'OwnerId', 'PostedBy');
 
 			$object =& $event->getObject();
 			/* @var $object kCatDBItem */
 
 			if (!$object->GetDBField('TodayDate')) {
 				$object->SetDBField('TodayDate', adodb_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
 		 */
 		function OnAfterItemCreate(&$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
 		 */
 		function 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-requered when topic has posts already
 		 *
 		 * @param kEvent $event
 		 */
 		function OnAfterItemLoad(&$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
 		 */
 		function OnAfterConfigRead(&$event)
 		{
 			parent::OnAfterConfigRead($event);
 
 			$fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
 			$fields['NotifyOwnerOnChanges']['default'] = (int)$this->Application->RecallPersistentVar('owner_notify');
 			$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
 
 			$virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
 			$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');
 			$this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields);
 		}
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/topics/topics_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/topics/topics_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/topics/topics_config.php	(revision 12740)
@@ -1,407 +1,407 @@
 <?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.net/license/ for copyright notices and details.
+* 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', 'require_classes' => Array('kCatDBEventHandler'), 'build_event' => 'OnBuild'),
 					'TagProcessorClass' =>	Array('class' => 'TopicsTagProcessor', 'file' => 'topics_tag_processor.php', 'require_classes' => Array('kCatDBTagProcessor'), 'build_event' => 'OnBuild'),
 					'AutoLoad'			=>	true,
 					'QueryString'		=>	Array(
 												1 => 'id',
 												2 => 'Page',
 												3 => 'event',
 												4 => 'mode',
 											),
 
 					'ConfigPriority' => 0,
 
 					'RewritePriority' => 103,
 					'RewriteListener' => 'ModRewriteHelper:CategoryItemRewriteListener',
 
 					'Hooks' => Array (
 						Array (
 							'Mode' => hBEFORE,
 							'Conditional' => false,
 							'HookToPrefix' => '',
 							'HookToSpecial' => '*',
 							'HookToEvent' => Array('OnAfterConfigRead'),
 							'DoPrefix' => 'cdata',
 							'DoSpecial' => '*',
 							'DoEvent' => 'OnDefineCustomFields',
 						),
 					),
 
 					'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', 'email' => 'in-bulletin:configuration_email', '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',
 							'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', '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', '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_email'	=>	Array(
 							'parent'		=>	'in-bulletin:setting_folder',
 							'icon'			=>	'core:conf_email',
 							'label'			=>	'la_tab_ConfigE-mail',
 							'url'			=>	Array('t' => 'config/config_email', 'pass_section' => true, 'pass' => 'm'),
 							'permissions'	=>	Array('view', 'edit'),
 							'priority'		=>	5,
 							'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'		=>	6,
 							'type'			=>	stTREE,
 						),
 					),
 
 					'FilterMenu'		=>	Array(
 												'Groups' => Array(
 													Array('mode' => 'AND', 'filters' => Array('show_active','show_pending','show_disabled'), 'type' => WHERE_FILTER),
 													Array('mode' => 'AND', 'filters' => Array('show_new'), 'type' => HAVING_FILTER),
 													Array('mode' => 'AND', 'filters' => Array('show_hot'), 'type' => HAVING_FILTER),
 													Array('mode' => 'AND', 'filters' => Array('show_pop'), 'type' => HAVING_FILTER),
 													Array('mode' => 'AND', 'filters' => Array('show_pick'), 'type' => WHERE_FILTER),
 												),
 												'Filters' => Array(
 													'show_active'	=>	Array('label' =>'la_Active', 'on_sql' => '', 'off_sql' => '%1$s.Status != 1' ),
 													'show_pending'	=>	Array('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => '%1$s.Status != 2'  ),
 													'show_disabled'	=>	Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => '%1$s.Status != 0'  ),
 													's1'	=>	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',
 
 					'CalculatedFields' => Array (
 						'' => Array (
 							'UserName' 		=> 'IF (ISNULL(u.Login), IF (%1$s.OwnerId = -1, "root", IF (%1$s.OwnerId = -2, "Guest", "n/a")), u.Login)',
 							'CategoryId'	=>	TABLE_PREFIX.'%3$sCategoryItems.CategoryId',
 							'Filename' => TABLE_PREFIX.'%3$sCategoryItems.Filename',
 							'PrimaryCat'	=> TABLE_PREFIX.'%3$sCategoryItems.PrimaryCat',
 							'ParentPath' => TABLE_PREFIX.'Category.ParentPath',
 
 							'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
 															LEFT JOIN '.TABLE_PREFIX.'Category ON '.TABLE_PREFIX.'Category.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId
 															LEFT JOIN '.TABLE_PREFIX.'Images img ON img.ResourceId = %1$s.ResourceId AND img.DefaultImg = 1
 															LEFT JOIN '.TABLE_PREFIX.'PermCache perm ON perm.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId
 															LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.OwnerId = u.PortalUserId
 															LEFT JOIN '.TABLE_PREFIX.'Posting last_post ON last_post.PostingId = %1$s.LastPostId
 															LEFT JOIN '.TABLE_PREFIX.'%3$sTopicCustomData cust ON %1$s.ResourceId = cust.ResourceId',
 											), // key - special, value - list select sql
 
 					'ListSortings'	=> 	Array(
 												'' => Array(
 															'ForcedSorting' => Array('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.'Category ON '.TABLE_PREFIX.'Category.CategoryId = '.TABLE_PREFIX.'%3$sCategoryItems.CategoryId
 															LEFT JOIN '.TABLE_PREFIX.'Images img ON img.ResourceId = %1$s.ResourceId AND img.DefaultImg = 1
 															LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.OwnerId = u.PortalUserId
 															LEFT JOIN '.TABLE_PREFIX.'Posting 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', 'not_null' => 1, 'required' => 1, 'default' => ''),
 							            '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(1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
 							            'Status'				=>	Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
 							            'Priority'				=>	Array('type' => 'int', 'not_null' => 1, 'default' => 0),
 							            'OwnerId'				=>	Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1, 'required' => 1, 'default' => -1),
 							            'ModifiedById'			=>	Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1, 'default' => 0),
 							            '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', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1,  'not_null' => 1,'default' => 2),
 							            'PopItem'				=>	Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1,  'not_null' => 1,'default' => 2),
 							            'HotItem'				=>	Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1,  'not_null' => 1,'default' => 2),
 							            '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 (
 						'UserName' => Array ('type'=>'string', 'default' => ''),
 						'CategoryId' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (), 'default' => 0),
 						'Filename' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
 						'CachedNavbar' => Array ('type' => 'string', 'default' => ''),
 
 						'LastPoster' => Array ('type' => 'string', 'default' => ''),
 						'LastPosterId' => Array ('type' => 'int', 'default' => -2),
 						'PostingText' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'required' => 1, 'using_fck' => 1, 'allow_html' => 1, 'default' => ''),
 						'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),
 
 						// for primary image
 						'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' => 'la_col_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, ),
 								'UserName' => Array('title' => 'la_col_PostedBy', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
 								'CreatedOn' => Array('title' => 'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ),
 								'Status' =>	Array('title' => 'la_col_Status', '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('title' => 'la_col_Views', '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' => 'la_col_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, ),
 								'UserName' => Array('title' => 'la_col_PostedBy', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
 								'CreatedOn' => Array('title' => 'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ),
 								'Status' =>	Array('title' => 'la_col_Status', '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('title' => 'la_col_Views', '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',
 										),
 			);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/helpers/post_helper.php
===================================================================
--- branches/5.0.x/in-bulletin/units/helpers/post_helper.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/helpers/post_helper.php	(revision 12740)
@@ -1,418 +1,418 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class PostHelper extends kHelper {
 
 		var $postOptionBits = Array (
 			'show_sig' => 128,
 			'disable_bbcode' => 64,
 			'disable_smileys' => 32,
 		);
 
 		/**
 		 * Checks if specific option is set for post
 		 *
 		 * @param string $option_name
 		 * @param Array $options
 		 * @return bool
 		 */
 		function GetPostOption($option_name, $options)
 		{
 			if (!isset($this->postOptionBits[$option_name])) {
 				return false;
 			}
 
 			$option_bit = $this->postOptionBits[$option_name];
 			return ($options & $option_bit) == $option_bit;
 		}
 
 		/**
 		 * Sets given option bit (by name) to post options
 		 *
 		 * @param string $option_name
 		 * @param int $option_value
 		 * @param Array $options
 		 * @return bool
 		 */
 		function SetPostOption($option_name, $option_value, &$options)
 		{
 			if (!isset($this->postOptionBits[$option_name])) {
 				return false;
 			}
 
 			$option_bit = $this->postOptionBits[$option_name];
 			if ($option_value) {
 				$options |= $option_bit;
 			}
 			else {
 				$options = $options &~ $option_bit;
 			}
 
 			return true;
 		}
 
 		/**
 		 * Returns post options map to virtual field names
 		 *
 		 * @return Array
 		 */
 		function getOptionsMap()
 		{
 			$options_map = Array (
 				'show_sig' => 'ShowSignatures',
 				'disable_smileys' => 'DisableSmileys',
 				'disable_bbcode' => 'DisableBBCodes',
 			);
 
 			return $options_map;
 		}
 
 		/**
 	     * @return void
 	     * @param int $date
 	     * @desc Set any field to category & all it's parent categories
 	     */
 		 function PropagateCategoryField($category_id, $field_name, $field_value)
 		 {
 		 	$id_field = $this->Application->getUnitOption('c', 'IDField');
 		 	$table_name = $this->Application->getUnitOption('c', 'TableName');
 
 		 	$sql = 'SELECT ParentPath
 		 			FROM '.$table_name.'
 		 			WHERE '.$id_field.' = '.$category_id;
 		 	$parent_path = $this->Conn->GetOne($sql);
 
 		 	$parent_categories = explode('|', substr($parent_path, 1, -1));
 			if (!$parent_categories) {
 				return false;
 			}
 
 			$fields_hash = Array (
 				$field_name => $field_value,
 			);
 
 			$this->Conn->doUpdate($fields_hash, $table_name, $id_field.' IN ('.implode(',', $parent_categories).')');
 		 }
 
 		 /**
 		 * Sets today posts count & today date for topic
 		 *
 		 * @param kCatDBItem $object
 		 * @param int $increment_by
 		 */
 		function updateTodayPostsCount(&$object, $post_date, $increment_by = 1)
 		{
 			$date_now = adodb_date('Y-m-d');
 
 			if (adodb_date('Y-m-d', $post_date) != $date_now) {
 				return ;
 			}
 
 			// last post update date was today or not
 			$today_posts = ($date_now == $object->GetDBField('TodayDate')) ? $object->GetDBField('TodayPosts') : 0;
 
 			$object->SetDBField('TodayDate', $date_now);
 			$object->SetDBField('TodayPosts', $today_posts + $increment_by);
 
 			return $object->Update();
 		}
 
 		function updatePostCount($topic_id, $increment = 1)
 		{
 			$id_field = $this->Application->getUnitOption('bb', 'IDField');
 			$table_name = $this->Application->getUnitOption('bb', 'TableName');
 
 			// helps in case, when 2 (or more) users tries to post in same topic at same time
 			$sql = 'UPDATE '.$table_name.'
 					SET Posts = Posts '.($increment > 0 ? '+' : '-').' '.abs($increment).'
 					WHERE '.$id_field.' = '.$topic_id;
 			$this->Conn->Query($sql);
 
 			// returns new value
 			$sql = 'SELECT Posts
 					FROM '.$table_name.'
 					WHERE '.$id_field.' = '.$topic_id;
 			return $this->Conn->GetOne($sql);
 		}
 		/**
 		 * Replaces all special formatting in post before displaing it to user
 		 *
 		 * @param string $post_body
 		 * @param int $post_options bit array of post options
 		 * @param Array $sub_blocks block names for rendering smileys & bbcodes
 		 * @return string
 		 */
 		function parsePostBody($post_body, $post_options, $sub_blocks)
 		{
 			// 1. escape all html sequences
 			$post_body = htmlspecialchars($post_body, ENT_NOQUOTES); // don't touch quotes in bbcode attribute values
 
 			// 2. replace censored words
 			$post_body = $this->CensorText($post_body);
 
 			// 3. replace bb codes
         	if (!$this->GetPostOption('disable_bbcode', $post_options)) {
         		$post_body = $this->replaceBBCodes($post_body, $sub_blocks['bbcode']);
         	}
 
 			// 4. replace smileys
         	if (!$this->GetPostOption('disable_smileys', $post_options)) {
         		$post_body = $this->replaceSmileys($post_body, $sub_blocks['smileys']);
         	}
 
         	// 5. add enters (because we don't use HTML in post body)
         	$post_body = nl2br($post_body);
 
         	// 6. replace quoted text
 			return $this->replacePostQuote($post_body, $sub_blocks['quote']);
 		}
 
 		function replacePostQuote($text, $render_as)
 		{
 			if (preg_match('/\[quote id=([\d]+)\](.*)\[\/quote\]/s', $text, $regs)) {
 				$post =& $this->Application->recallObject('bb-post.-item', null, Array ('skip_autoload' => true));
 				/* @var $post kDBItem */
 
 				$post->Load($regs[1]);
 
 				$block_params = Array ('name' => $render_as, 'PrefixSpecial' => 'bb-post.-item', 'Prefix' => 'bb-post', 'Special' => '-item', 'strip_nl' => 2);
 				$parsed_quote = $this->Application->ParseBlock($block_params);
 				return str_replace($regs[0], $parsed_quote, $text);
 			}
 
 			return $text;
 		}
 
 		/**
 		 * Replaces bad words with good words (censorship process)
 		 *
 		 * @param string $text
 		 * @return string
 		 */
 		function CensorText($text)
 		{
 			static $censor_words = null;
 
 			if (!isset($censor_words)) {
 				$sql = 'SELECT Replacement, BadWord
 						FROM '.TABLE_PREFIX.'Censorship';
 				$censor_words = $this->Conn->GetCol($sql, 'BadWord');
 			}
 
 			foreach ($censor_words as $replace_from => $replace_to) {
 				$text = str_replace($replace_from, $replace_to, $text);
 			}
 
 			return $text;
 		}
 
 		function replaceSmileys($text, $smiley_element)
 		{
 			static $smileys = null;
 
 			if (!isset($smileys)) {
 				$sql = 'SELECT em.EmotionImage, em.KeyStroke
 						FROM '.TABLE_PREFIX.'Emoticon em
 						WHERE em.Enabled = 1
 						ORDER BY CHAR_LENGTH(em.KeyStroke) DESC';
 				$smileys = $this->Conn->GetCol($sql, 'KeyStroke');
 			}
 
 			$block_params = Array ('name' => $smiley_element, 'smiley_url' => '#SMILEY_URL#');
 			$smiley_mask = trim($this->Application->ParseBlock($block_params));
 
 			$base_url = rtrim($this->Application->BaseURL(),'/');
 			foreach ($smileys as $key_stoke => $image_url) {
 				if (strpos($text, $key_stoke) === false) {
 					continue;
 				}
 
 				$smiley_html = str_replace('#SMILEY_URL#', $base_url.SMILEYS_PATH.$image_url, $smiley_mask);
 				$text = str_replace($key_stoke, $smiley_html, $text);
 			}
 
 			return $text;
 		}
 
 		/**
 		 * Sort params by name and then by length
 		 *
 		 * @param string $a
 		 * @param string $b
 		 * @return int
 		 * @access private
 		 */
 		function CmpParams($a, $b)
 		{
 			list ($a, ) = explode(':', $a);
 			list ($b, ) = explode(':', $b);
 
 			$a_len = strlen($a);
 			$b_len = strlen($b);
 			if ($a_len == $b_len) return 0;
 			return $a_len > $b_len ? -1 : 1;
 		}
 
 		function replaceBBCodes($text, $bbcode_element)
 		{
 		  	// convert phpbb bbcodes to in-bulletin bbcodes
 		  	$text = $this->preformatBBCodes($text);
 
 		  	$tags_defs = explode(';', $this->Application->ConfigValue('BBTags')); // 'b:;i:;u:;ul:type|align;font:color|face|size;url:href;img:src|border';
 
 		  	usort($tags_defs, Array (&$this, 'CmpParams'));
 
 		  	foreach($tags_defs as $tag) {
 		  		list ($tag_name, $tag_params) = explode(':', $tag);
 		  		$tag_params = $tag_params ? array_flip(explode('|', $tag_params)) : 0;
 
 				$text = preg_replace('/\['.$tag_name.'(.*)\](.*)\[\/'.$tag_name.' *\]/Uise','$this->checkBBCodeAttribs("'.$tag_name.'",\'$1\',\'$2\',$tag_params);', $text);
 		  	}
 
 		  	// additional processing for [url], [*], [img] bbcode
 			$text = preg_replace('/<url>(.*)<\/url>/Usi','<url href="$1">$1</url>',$text);
 			$text = preg_replace('/<font>(.*)<\/font>/Usi','$1',$text); // skip empty fonts
 		  	$text = str_replace(	Array('<url','</url>','[*]'),
 		  							Array('<a target="_blank"','</a>','<li>'),
 		  							$text);
 
 		  	// bbcode [code]xxx[/code] processing
 		  	$text = preg_replace('/\[code\](.*)\[\/code\]/Uise', "\$this->replaceCodeBBCode('$1', '".$bbcode_element."')", $text);
 		  	return $text;
 		}
 
 		/**
 		 * Convert phpbb url bbcode to valid in-bulletin's format
 		 *
 		 * @param string $text
 		 * @return string
 		 */
 		function preformatBBCodes($text)
 		{
 			// 1. urls
 			$text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Ui','[url href="$1"]$2[/url]',$text);
 			$text = preg_replace('/\[url\](.*)\[\/url\]/Ui','[url href="$1"]$1[/url]',$text);
 
 			// 2. images
 			$text = preg_replace('/\[img\](.*)\[\/img\]/Ui','[img src="$1" border="0"][/img]',$text);
 
 			// 3. color
 			$text = preg_replace('/\[color=(.*)\](.*)\[\/color\]/Ui','[font color="$1"]$2[/font]',$text);
 
 			// 4. size
 			$text = preg_replace('/\[size=(.*)\](.*)\[\/size\]/Ui','[font size="$1"]$2[/font]',$text);
 
 			// 5. lists
 			$text = preg_replace('/\[list(.*)\](.*)\[\/list\]/Uis','[ul]$2[/ul]',$text);
 
 			// 6. email to link
 			$text = preg_replace('/\[email\](.*)\[\/email\]/Ui','[url href="mailto:$1"]$1[/url]',$text);
 
 			//7. b tag
 			$text = preg_replace('/\[(b|i|u):(.*)\](.*)\[\/(b|i|u):(.*)\]/Ui','[$1]$3[/$4]',$text);
 
 			//8. code tag
 			$text = preg_replace('/\[code:(.*)\](.*)\[\/code:(.*)\]/Uis','[code]$2[/code]',$text);
 
 			return $text;
 		}
 
 		/**
 		 * Removes not allowed params from tag and returns result
 		 *
 		 * @param string $BBCode bbcode to check
 		 * @param string $TagParams params string entered by user
 		 * @param string $TextInside text between opening and closing bbcode tag
 		 * @param string $ParamsAllowed list of allowed parameter names ("|" separated)
 		 * @return string
 		 */
 		function checkBBCodeAttribs($BBCode, $TagParams, $TextInside, $ParamsAllowed)
 		{
 			// unescape escaped quotes in tag
 			$TagParams = str_replace('\"', '"', $TagParams);
 			$TextInside = str_replace('\"', '"', $TextInside);
 
 			$params_extracted = preg_match_all('/ +([^=]*)=["\']?([^ "\']*)["\']?/is', $TagParams, $extracted_params, PREG_SET_ORDER);
 
 			if ($ParamsAllowed && $params_extracted) {
 				$ret = Array();
 				foreach ($extracted_params as $param) {
 					$param_name = strtolower(trim( $param[1] ));
 					$param_value = trim($param[2]);
 
 					// 1. prevent hacking
 					if ($BBCode == 'url' && $param_name == 'href') {
 						if (strpos(strtolower($param_value), 'script:') !== false) {
 							// script tag found in "href" parameter of "url" bbcode (equals to hacking) -> remove bbcode
 							return $TextInside;
 						}
 					}
 
 					// 2. leave only allowed params & remove all not allowed
 					if (isset($ParamsAllowed[$param_name])) {
 						$ret[] = $param_name.'="'.$param_value.'"';
 					}
 				}
 
 				$ret = count($ret) ? ' '.implode(' ', $ret) : '';
 				return '<'.$BBCode.$ret.'>'.$TextInside.'</'.$BBCode.'>';
 			}
 
 			return '<'.$BBCode.'>'.$TextInside.'</'.$BBCode.'>';
 		}
 
 		function highlightCode($code, $strip_tabs = 0)
 		{
 			if ($strip_tabs) {
 				$code = preg_replace('/(\t){'.$strip_tabs.'}(.*)/', '\\2', $code);
 			}
 
 			$code = str_replace( Array('\\', '/') , Array('_no_match_string_', '_n_m_s_'), $code);
 			$code = highlight_string('<?php'.$code.'?>', true);
 			$code = str_replace( Array('_no_match_string_', '_n_m_s_'), Array('\\', '/'), $code);
 			$code = preg_replace('/&lt;\?(.*)php(.*)\?&gt;/Us', '\\2', $code);
 
 			$code = preg_replace('/<code><font color="(.*)">([\r\n]+)/si', '<code><font color="\\1">', $code);
 			$code = preg_replace('/([\r\n]+)<\/font>([\r\n]+)<\/code>/si', '</font></code>', $code);
 
 			return $code;
 		}
 
 		/**
 		 * Replaces [code]php code[/code] bbcode in post
 		 *
 		 * @param string $input_string code line to highlight
 		 * @param string $bbcode_element block name used for bbcode descoration
 		 * @return string
 		 */
 		function replaceCodeBBCode($input_string, $bbcode_element)
 		{
 			static $bbcode_mask = null;
 
 			if (!isset($bbcode_mask)) {
 				$block_params = Array ('name' => $bbcode_element, 'bb_code' => '#BB_CODE#');
 				$bbcode_mask = trim($this->Application->ParseBlock($block_params));
 			}
 
 			$input_string = trim( str_replace('\"','"', unhtmlentities($input_string)) );
 			$input_string = $this->highlightCode($input_string);
 			$input_string = preg_replace("/\r<br \/>/s", "\r", $input_string); // undo nl2br added in highlighting
 			$input_string = str_replace('#BB_CODE#', $input_string, $bbcode_mask);
 
 			return $input_string;
 		}
 
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/helpers/helpers_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/helpers/helpers_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/helpers/helpers_config.php	(revision 12740)
@@ -1,24 +1,24 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config = Array (
 		'Prefix' => 'in-bulletin-helpers',
 		'EventHandlerClass'	=>	Array('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
 
 		'RegisterClasses' => Array (
 			Array('pseudo' => 'PostHelper', 'class' => 'PostHelper','file' => 'post_helper.php', 'build_event' => '', 'require_classes' => Array('kHelper')),
 		),
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/poll_answers/poll_answers_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/poll_answers/poll_answers_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/poll_answers/poll_answers_config.php	(revision 12740)
@@ -1,85 +1,85 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config = Array ( 'Prefix' => 'poll-answer',
 
 		'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
 		'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
 		'EventHandlerClass' => Array ('class' => 'kDBEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
 		'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
 		'AutoLoad' => true,
 
 		'QueryString' => Array (
 			1 => 'id',
 			2 => 'Page',
 			3 => 'event'
 		),
 		'IDField' => 'AnswerId',
 		'TableName' => TABLE_PREFIX . 'PollsAnswers',
 
 		'ParentPrefix' => 'poll',
 		'ForeignKey'  => 'PollId',
 		'ParentTableKey' => 'PollId',
 		'AutoDelete' => true,
 		'AutoClone' => true,
 
 		'StatusField'	=>	Array('Status'),
 
 		// key - special, value - list select sql
 		'ListSQLs' => Array (
 			'' => '	SELECT %1$s.* %2$s
 					FROM %1$s
 					',
 				),
 
 		'ItemSQLs' => Array ('' => 'SELECT * FROM %s'),
 
 		'ListSortings' => Array (
 			'' => Array(
 				'ForcedSorting' => Array('Priority' => 'desc'),
 				'Sorting' => Array('Answer' => 'ASC'),
 			)
 		),
 
 		'Fields' => Array (
 		    'AnswerId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'PollId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'Answer'	=>	Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'using_fck' => 1, 'default' => '', 'required' => 1),
 		    'VotesQty' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		  	'Status' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_Active', 0 => 'la_opt_Disabled'), 'use_phrases' => 1, 'required' => 1, 'not_null' => 1, 'default' => 1),
 		),
 
 		'Grids' => Array (
 						'Default' => Array (
 							'Icons' => Array (
 								'default' => 'icon16_item.png',
 								0 => 'icon16_disabled.png',
 								1 => 'icon16_item.png',
 								2 => 'icon16_pending.png',
 								'module' => 'core',
 							),
 							'Fields' => Array (
 								'AnswerId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
 								'Answer' => Array ('title' => 'la_col_Name', 'data_block' => 'grid_priority_td', 'filter_block' => 'grid_like_filter', 'width' => 300, ),
 								'Status' => Array ('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter', 'width' => 100, ),
 								'VotesQty' => Array ('title' => 'la_col_VoteCount', 'filter_block' => 'grid_like_filter', 'width' => 100, ),
 
 							),
 						),
 		),
 
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/posts/posts_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/posts/posts_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/posts/posts_config.php	(revision 12740)
@@ -1,110 +1,110 @@
 <?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.net/license/ for copyright notices and details.
+* 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 => '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.'PortalUser u ON %1$s.CreatedById = u.PortalUserId
 					LEFT JOIN '.TABLE_PREFIX.'Images img ON (img.ResourceId = u.ResourceId) AND (img.DefaultImg = 1 OR img.Name = "avatar")',
 		),
 
 		'ItemSQLs' => Array (
 			'' => ' SELECT %1$s.* %2$s
 					FROM %1$s
 					LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.CreatedById = u.PortalUserId
 					LEFT JOIN '.TABLE_PREFIX.'Images 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.Login), IF (%1$s.CreatedById = -1, "root", IF (%1$s.CreatedById = -2, "Guest", "n/a")), u.Login)',
 
 				'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(-1 => 'root', -2 => 'Guest'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'default' => NULL),
 		    'CreatedById' => Array ('type' => 'int', 'formatter' => 'kLEFTFormatter', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'options' => Array(-1 => 'root', -2 => 'Guest'), 'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', '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),
 
 			// for avatar image
 			'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' => ''),
 		),
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/posts/post_eh.php
===================================================================
--- branches/5.0.x/in-bulletin/units/posts/post_eh.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/posts/post_eh.php	(revision 12740)
@@ -1,400 +1,400 @@
 <?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.net/license/ for copyright notices and details.
+* 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
 		 */
 		function CheckPermission(&$event)
 		{
 			$events = Array('OnUpdate', 'OnDelete');
 			if (in_array($event->Name, $events)) {
 				return true;
 			}
 
 			return parent::CheckPermission($event);
 		}
 
 		/**
 		 * Sets default values
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemCreate(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$user_id = $this->Application->RecallVar('user_id');
 
 			$now = adodb_mktime();
 
 			$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', $_SERVER['REMOTE_ADDR']);
 
 			$sql = 'SELECT Login
 					FROM '.TABLE_PREFIX.'PortalUser
 					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
 		 */
 		function 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 = 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
 		 */
 		function OnAfterItemUpdate(&$event)
 		{
 			parent::OnAfterItemUpdate($event);
 
 			$this->Application->EmailEventAdmin('POST.MODIFY');
 		}
 
 		/**
 		 * Checks, that user can delete post
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemDelete(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$perm_status = $this->checkPostPermission($event, 'TOPIC.REPLY.OWNER.DELETE|TOPIC.REPLY.DELETE');
 			if (!$perm_status) {
 				$event->status = erFAIL;
 			}
 		}
 
 		/**
 		 * Sets post options to virtual fields
 		 *
 		 * @param kEvent $event
 		 */
 		function 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
 		 */
 		function OnAfterItemCreate(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
 
 			$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);
 
 			$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)
 				if ($main_object->GetDBField('NotifyOwnerOnChanges')) {
 					$user_notified = $main_object->GetDBField('OwnerId');
 					$this->Application->EmailEventUser('POST.ADD', $user_notified);
 				}
 
 				$post_owner_id = $object->GetDBField('CreatedById');
 				if (($post_owner_id > 0) && ($user_notified != $post_owner_id)) {
 					$this->Application->EmailEventUser('POST.ADD', $post_owner_id);
 				}
 
 				$this->Application->EmailEventAdmin('POST.ADD');
 			}
 
 			$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);
 
 			// autolock 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($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
 		 */
 		function OnCreate(&$event)
 		{
 			parent::OnCreate($event);
 
 			if ($event->status == 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
 		 */
 		function OnUpdate(&$event)
 		{
 			parent::OnUpdate($event);
 
 			if ($event->status == 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
 		 */
 		function OnAfterItemDelete(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$topic_id = $object->GetDBField('TopicId');
 			if (!$topic_id) {
 				// deleting non-existing post
 				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.'PersistantSessionData
 					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);
 
 			$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
 		 */
 		function OnAfterConfigRead(&$event)
 		{
 			$virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
 			$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');
 			$this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields);
 		}
 
 		/**
 		 * Deletes items & preserves clean env
 		 *
 		 * @param kEvent $event
 		 */
 		function OnDelete(&$event)
 		{
 			parent::OnDelete($event);
 
 			if ($event->status == erSUCCESS && !$this->Application->isAdmin) {
 				$parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
 				$event->SetRedirectParam('pass', 'm,'.$parent_prefix);
 			}
 		}
 
 		/**
 		 * Prepares new reply form
 		 *
 		 * @param kEvent $event
 		 */
 		function OnNew(&$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.0.x/in-bulletin/units/posts/post_tp.php
===================================================================
--- branches/5.0.x/in-bulletin/units/posts/post_tp.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/posts/post_tp.php	(revision 12740)
@@ -1,315 +1,315 @@
 <?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.net/license/ for copyright notices and details.
+* 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->Application->getUnitOption($this->Prefix, 'ParentPrefix');
 			$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);
 
 			if (!isset($posters)) {
 				$poster_ids = array_unique($object->GetCol('CreatedById'));
 
 				$user_idfield = $this->Application->getUnitOption('u', 'IDField');
 				$user_table = $this->Application->getUnitOption('u', 'TableName');
 
 				$sql = 'SELECT u.*, g.Name AS PrimaryGroup
 						FROM '.$user_table.' u
 						LEFT JOIN '.TABLE_PREFIX.'UserGroup ug ON ug.PortalUserId = u.PortalUserId AND ug.PrimaryGroup = 1
 						LEFT JOIN '.TABLE_PREFIX.'PortalGroup g ON g.GroupId = ug.GroupId
 						WHERE u.'.$user_idfield.' IN ('.implode(',', $poster_ids).')';
 				$posters = $this->Conn->Query($sql, $user_idfield);
 			}
 
 			$poster =& $this->Application->recallObject('u.poster', null, Array('skip_autoload' => true));
 			/* @var $poster UsersItem */
 
 			$poster_id = $object->GetDBField('CreatedById');
 			if ($poster_id > 0) {
 				// not Guest & root
 				if ($poster->GetID() != $poster_id) {
 					// previous poster differs from requested
 					$poster->SetDBFieldsFromHash($posters[$poster_id]);
 					$poster->setID($poster_id);
 				}
 				return $this->Application->ProcessParsedTag('u.poster', 'Field', $params);
 			}
 
 			return '';
 		}
 
 		/**
 		 * 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.'PersistantSessionData
 						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
 		 *
 		 * @param Array $params
 		 * @return bool
 		 */
 		function ShowPostSignature($params)
 		{
 			$object =& $this->getObject($params);
 			$post_options = $object->GetDBField('Options');
 
 			$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;
                 }
 			}
 
 			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.'PersistantSessionData
 						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->Application->getUnitOption($this->Prefix, 'ParentPrefix');
 				$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.0.x/in-bulletin/units/polls/poll_tp.php
===================================================================
--- branches/5.0.x/in-bulletin/units/polls/poll_tp.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/polls/poll_tp.php	(revision 12740)
@@ -1,118 +1,118 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class PollTagProcessor extends kDBTagProcessor {
 
 		/**
 		 * Allows to tell if user from current ip has voted already for current poll
 		 *
 		 * @param Array $params
 		 * @return bool
 		 */
 		function HasVoted($params)
 		{
 			$object =& $this->getObject($params);
 			/* @var $object kDBItem */
 
 			if (!$object->GetDBField('AllowMultipleVotings')) {
 				$sql = 'SELECT StatisticsId
 						FROM '.TABLE_PREFIX.'PollsStatistics
 						WHERE PollId = '.$object->GetID().' AND CreatedById = '.$this->Application->RecallVar('user_id').' AND UserIP = '.$this->Conn->qstr(getenv('REMOTE_ADDR'));
 				return $this->Conn->GetOne($sql) > 0;
 			}
 
 			return false;
 		}
 
 		/**
 		 * Allows to tell if user from current ip has voted already for current poll
 		 *
 		 * @param Array $params
 		 * @return bool
 		 */
 		function HasCommented($params)
 		{
 			$object =& $this->getObject($params);
 			/* @var $object kDBItem */
 
 			$spam_helper =& $this->Application->recallObject('SpamHelper');
 			/* @var $spam_helper SpamHelper */
 
 			$spam_helper->InitHelper($object->GetID(), 'PollComment', 0); // PollId used for SpamControl only
 			return $spam_helper->InSpamControl();
 		}
 
 		/**
 		 * Prints out only filled in answers of current poll
 		 *
 		 * @param Array $params
 		 * @return string
 		 */
 		function PrintPoll($params)
 		{
 			$object =& $this->getObject($params);
 
 			$sql = 'SELECT COUNT(AnswerNum), AnswerNum
 					FROM '.TABLE_PREFIX.'PollsStatistics
 					WHERE PollId = '.$object->GetID().'
 					GROUP BY AnswerNum';
 			$statistics = $this->Conn->GetCol($sql, 'AnswerNum');
 
 			$total_votes = array_sum($statistics);
 
 			$block_params = $this->prepareTagParams($params);
 			$block_params['name'] = $params['render_as'];
 
 			$i = 1;
 			$ret = '';
 			while ($i < 8) {
 				$answer = $object->GetDBField('Answer'.$i);
 				if ($answer) {
 					$answer_votes = isset($statistics[$i]) ? $statistics[$i] : 0;
 					if ($total_votes > 0) {
 						$block_params['percent'] = round((100 * $answer_votes) / $total_votes, 0);
 					}
 					else {
 						$block_params['percent'] = 0;
 					}
 
 					$block_params['answer'] = $answer;
 					$block_params['answer_num'] = $i;
 
 					$ret .= $this->Application->ParseBlock($block_params);
 				}
 				$i++;
 			}
 
 			return $ret;
 		}
 
 		/**
 		 * Prints link to comments of of current poll
 		 *
 		 * @param Array $params
 		 * @return string
 		 */
 		function CommentsLink($params)
 		{
 			$object =& $this->getObject($params);
 
 			$params['pass'] = 'm,poll';
 			$params['poll_id']	= $object->GetID();
 
 		 	return $this->Application->ProcessParsedTag('m', 'Link', $params);
 		}
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/polls/polls_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/polls/polls_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/polls/polls_config.php	(revision 12740)
@@ -1,167 +1,167 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config =	Array(
 					'Prefix'			=>	'poll',
 					'ItemClass'			=>	Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
 					'ListClass'			=>	Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
 					'EventHandlerClass'	=>	Array('class' => 'PollEventHandler', 'file' => 'poll_eh.php', 'build_event' => 'OnBuild'),
 					'TagProcessorClass' =>	Array('class' => 'PollTagProcessor', 'file' => 'poll_tp.php', 'build_event' => 'OnBuild'),
 					'AutoLoad'			=>	true,
 
 					'QueryString'		=>	Array(
 												1	=>	'id',
 												2	=>	'page',
 												3	=>	'event',
 												4 	=>	'mode',
 											),
 
 					'IDField'			=>	'PollId',
 
 					'TitleField'		=>	'Name',
 					'StatusField'		=>	Array('Status'),
 
 
 					'TitlePresets'		=>	Array(
 										'default'	=>	Array(
 											'new_status_labels'		=> Array('poll' => '!la_title_Adding_Poll!'),
 											'edit_status_labels'	=> Array('poll' => '!la_title_Editing_Poll!'),
 											'new_titlefield'		=> Array('poll' => '!la_title_NewPoll!'),
 										),
 
 										'poll_list' => Array('prefixes' => Array('poll_List'), 'format' => "!la_title_Polls!",	),
 										'poll_edit' => Array('prefixes' => Array('poll'), 'format' => "#poll_status# '#poll_titlefield#' - !la_title_General!",	),
 										'poll_edit_answers' => Array ('prefixes' => Array ('poll', 'poll-answer_List'), 'format' => "#poll_status# '#poll_titlefield#' - !la_title_PollAnswers!"),
 
 										'poll_edit_comments' => Array ('prefixes' => Array ('poll', 'poll-comment_List'), 'format' => "#poll_status# '#poll_titlefield#' - !la_title_PollComments!"),
 
 
 										'answer_edit' => Array (
 											'prefixes' => Array ('poll', 'poll-answer'),
 											'new_status_labels' => Array ('poll-answer' => '!la_title_Adding_Answer!'),
 											'edit_status_labels' => Array ('poll-answer' => '!la_title_Editing_Answer!'),
 											'new_titlefield' => Array ('poll-answer' => '!la_title_New_Answer!'),
 											'format' => "#poll_status# '#poll_titlefield#' - #poll-answer_status# '#poll-answer_titlefield#'"
 											),
 
 										'comment_edit' => Array (
 											'prefixes' => Array ('poll', 'poll-comment'),
 											'new_status_labels' => Array ('poll-comment' => '!la_title_Adding_Comment!'),
 											'edit_status_labels' => Array ('poll-comment' => '!la_title_Editing_Comment!'),
 											'new_titlefield' => Array ('poll-comment' => '!la_title_NewComment!'),
 											'format' => "#poll_status# '#poll_titlefield#' - #poll-comment_status#",
 											),
 
 									),
 
 					'PermSection'		=>	Array('main' => 'in-bulletin:polls'),
 
 					'Sections' => Array (
 						'in-bulletin:polls' => Array (
 							'parent'		=>	'in-portal:site',
 							'icon'			=>	'polls',
 							'label'			=>	'la_title_Polls',
 							'url'			=>	Array('t' => 'in-bulletin/polls/poll_list', 'pass' => 'm'),
 							'permissions'	=>	Array('view', 'add', 'edit', 'delete'),
 							'priority'		=>	3.6,
 							'type'			=>	stTREE,
 						),
 					),
 
 					'TableName'			=>	TABLE_PREFIX.'Polls',
 
 					'ListSQLs'			=>	Array(''	=> 'SELECT %1$s.* %2$s
 															FROM %1$s',
 
 											),
 
 					'ItemSQLs'			=>	Array(''	=> 'SELECT %1$s.* %2$s
 															FROM %1$s',
 
 											),
 
 					'ListSortings'	=> 	Array(
 												'' => 	Array (
 																'Sorting' => Array('PollId' => 'asc'),
 														)
 										),
 
 					'Fields' 		=> Array (
 										'PollId'	 	=> Array('type' => 'int', 'not_null' => 1, 'default' => 0,),
 			           					'Name' 			=> Array('type' => 'string', 'not_null' => '1','default' => '', 'required'=> 1, 'max_len' => 255),
 										'Question'		=> Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'using_fck' => 1, 'default' => null, 'required' => 1),
 										'CreatedOn' 	=> Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'required' => 1, 'default' => '#NOW#'),
 										'StartDate'		=> Array('type' => 'int', 'formatter' => 'kDateFormatter', 'required' => 1, 'default' => '#NOW#'),
 										'EndDate'		=> Array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => null),
 										'Image' => Array (
 							            	'type' => 'string',
 							            	'formatter' => 'kPictureFormatter',
 							            	'max_size' => MAX_UPLOAD_SIZE, 'upload_dir' => IMAGES_PATH . 'polls/',
 							            	'file_types' => '*.jpg;*.gif;*.png', 'files_description' => '!la_hint_ImageFiles!',
 							            	'multiple' => false,
 							            	'max_len' => 255, 'not_null' => 1, 'default' => ''
 							            ),
 							            'Priority' 		=> Array('type' => 'int', 'not_null' => 1, 'default' => 0),
 							            'RequireLogin' 	=> Array('type' => 'int', 'not_null' => 1, 'default' => 0,),
 							            'AllowComments' 	=> Array('type' => 'int', 'not_null' => 1, 'default' => 1,),
 										'AllowMultipleVotings' => Array('type' => 'int', 'not_null' => 1, 'default' => 1,),
 							            'CachedVotesQty'=> Array('type' => 'int', 'not_null' => 1, 'default' => 0),
 							            'Status' 		=> Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_Active', 0 => 'la_opt_Disabled'), 'use_phrases' => 1, 'required' => 1, 'not_null' => 1, 'default' => 1),
 
 							           ),
 
 					'SubItems'			=>	Array ('poll-answer', 'poll-comment'),
 
 					'VirtualFields'		=> 	Array (
 //									'PollId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0,),
 										),
 
 					'CalculatedFields' => Array (
 							'' => Array (
 //								'DaysLeft' => 'IF( ISNULL(%1$s.EndDate), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, %1$s.PosterAlias, \'n/a\')), \'Never\' )',
 								),
 							),
 
 					'EditTabPresets' => Array (
 								'Default' => Array (
 									Array ('title' => 'la_tab_General', 't' => 'in-bulletin/polls/poll_edit', 'priority' => 1),
 									Array ('title' => 'la_tab_PollAnswers', 't' => 'in-bulletin/polls/poll_edit_answers', 'priority' => 2),
 									Array ('title' => 'la_tab_PollUserComments', 't' => 'in-bulletin/polls/poll_edit_comments', 'priority' => 3),
 								),
 							),
 
 					'Grids' => Array (
 						'Default' => Array (
 							'Icons' => Array (
 								'default' => 'icon16_item.png',
 								0 => 'icon16_disabled.png',
 								1 => 'icon16_item.png',
 								2 => 'icon16_pending.png',
 								'module' => 'core',
 							),
 							'Fields' => Array (
 								'PollId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
 								'Name' => Array ('title' => 'la_col_Name', 'data_block' => 'grid_priority_td', 'filter_block' => 'grid_like_filter', 'width' => 200, ),
 								'StartDate' => Array ('title' => 'la_col_StartDate', 'filter_block' => 'grid_date_range_filter', 'width' => 145,  ),
 								'EndDate' => Array ('title' => 'la_col_EndDate', 'data_block' => 'poll_expire_td', 'filter_block' => 'grid_date_range_filter', 'width' => 145, ),
 								'CachedVotesQty' => Array ('title' => 'la_col_VoteCount', 'filter_block' => 'grid_like_filter', 'width' => 100, ),
 								'Status' => Array ('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter', 'width' => 100, ),
 //								'DaysActive' => Array ('title' => 'la_col_NumberOfDaysActive', 'filter_block' => 'grid_range_filter',),
 							),
 						),
 					),
 
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/polls/poll_eh.php
===================================================================
--- branches/5.0.x/in-bulletin/units/polls/poll_eh.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/polls/poll_eh.php	(revision 12740)
@@ -1,154 +1,154 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class PollEventHandler extends kDBEventHandler {
 
 		/**
 		 * Allows to override standart permission mapping
 		 *
 		 */
 		function mapPermissions()
 		{
 			parent::mapPermissions();
 			$permissions = Array(
 									'OnResetVotes'	=>	Array('self' => 'edit'),
 									'OnMakeVote'	=>	Array('self' => true),
 									'OnItemBuild'	=>	Array('self' => true),
 							);
 			$this->permMapping = array_merge($this->permMapping, $permissions);
 		}
 
 		/**
 		 * Applies special filter, that allows to select all poll from given date range
 		 *
 		 * @param kEvent $event
 		 */
 		function SetCustomQuery(&$event)
 		{
 			if ($this->Application->isAdminUser) {
 				return ;
 			}
 
 			$object =& $event->getObject();
 			/* @var $object kDBList */
 
 			$object->addFilter('poll_range_filter', '(%1$s.StartDate <= ' .adodb_mktime(). ') AND (%1$s.EndDate >= ' .adodb_mktime(). ' OR EndDate IS NULL)');
 			$object->addFilter('poll_status', '(%1$s.Status = ' .STATUS_ACTIVE. ')');
 		}
 
 		/**
 		 * Reset votes statistics for current poll
 		 *
 		 * @param kEvent $event
 		 */
 		function OnResetVotes(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$sql = 'DELETE FROM '.TABLE_PREFIX.'PollsStatistics
 					WHERE '.$object->IDField.' = '.$object->GetID();
 			$this->Conn->Query($sql);
 
 
 			$poll_answers_table = $this->Application->getUnitOption('poll-answer', 'TableName');
 			$poll_answers_table = $this->Application->GetTempName($poll_answers_table);
 
 			$sql = 'UPDATE '.$poll_answers_table.' SET VotesQty = 0
 						WHERE '.$object->IDField.' = '.$object->GetID();
 			$this->Conn->Query($sql);
 		}
 
 		/**
 		 * Reset votes statistics for current poll
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemCreate(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$object->SetDBField('ResourceId', $this->Application->NextResourceId());
 		}
 
 		/**
 		 * Make vote to current poll
 		 *
 		 * @param kEvent $event
 		 */
 		function OnMakeVote(&$event)
 		{
 			$object =& $event->getObject($this->Application->GetVar('poll_id'));
 			/* @var $object kDBItem */
 
 			$poll_answer_id = $this->Application->GetVar('option_id');
 
 			if (!$poll_answer_id) {
 				$event->redirect = false;
 				return ;
 			}
 
 			$ip_address = $_SERVER['REMOTE_ADDR'];
 
 			if (!$object->GetDBField('AllowMultipleVotings')) {
 				$sql = 'SELECT StatisticsId
 						FROM '.TABLE_PREFIX.'PollsStatistics
 						WHERE PollId = '.$object->GetID().' AND UserIP = '.$this->Conn->qstr($ip_address);
 				$voted = $this->Conn->GetOne($sql) > 0;
 			}
 
 			if (!$voted) {
 				$user_id = $this->Application->LoggedIn()? $this->Application->RecallVar('user_id') : '-2';
 				$fields_hash = 	Array (
 										'PollId'		=>	$object->GetID(),
 										'AnswerId'		=>	$poll_answer_id,
 										'UserIP'		=>	$ip_address,
 										'CreatedById'	=>	$user_id,
 										'AnswerDate'	=>	adodb_mktime(),
 								);
 
 				$this->Conn->doInsert($fields_hash, TABLE_PREFIX.'PollsStatistics');
 
 				$poll_table = $this->Application->getUnitOption('poll', 'TableName');
 				$this->Conn->Query('UPDATE '.$poll_table.' SET CachedVotesQty = CachedVotesQty + 1
 										WHERE PollId = '.$object->GetID());
 
 				// update table with answers
 				$poll_answers_table = $this->Application->getUnitOption('poll-answer', 'TableName');
 				$this->Conn->Query('UPDATE '.$poll_answers_table.' SET VotesQty = VotesQty + 1
 										WHERE PollId = '.$object->GetID().' AND AnswerId = '.$poll_answer_id);
 			}
 			$event->setEventParam('PollId', $this->Application->GetVar('poll_id'));
 			$event->redirect = false;
 		}
 
 
 		/**
 		 * Cleanup by removing items from PollStatistics before Poll is deleted
 		 *
 		 * @param kEvent $event
 		 */
 		function OnAfterItemDelete(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			$sql = 'DELETE FROM '.TABLE_PREFIX.'PollsStatistics
 						WHERE PollId = '.$object->GetID();
 			$this->Conn->Query($sql);
 		}
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/poll_comments/poll_comments_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/poll_comments/poll_comments_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/poll_comments/poll_comments_config.php	(revision 12740)
@@ -1,114 +1,114 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config = Array ( 'Prefix' => 'poll-comment',
 
 		'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
 		'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
 		'EventHandlerClass' => Array ('class' => 'PollCommentEventHandler', 'file' => 'poll_comment_eh.php', 'build_event' => 'OnBuild'),
 		'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
 		'AutoLoad' => true,
 
 		'QueryString' => Array (
 			1 => 'id',
 			2 => 'Page',
 			3 => 'event'
 		),
 		'IDField' => 'CommentId',
 		'TableName' => TABLE_PREFIX . 'PollsComments',
 
 		'ParentPrefix' => 'poll',
 		'ForeignKey'  => 'PollId',
 		'ParentTableKey' => 'PollId',
 		'AutoDelete' => true,
 		'AutoClone' => true,
 
 		'StatusField' =>	Array('Status'),
 
 		// key - special, value - list select sql
 		'ListSQLs' => Array (
 			'' => '	SELECT %1$s.* %2$s
 					FROM %1$s
 					LEFT JOIN '.TABLE_PREFIX.'PortalUser pu ON pu.PortalUserId = %1$s.CreatedById',
 				),
 
 		'ItemSQLs' => Array ('' => 'SELECT * FROM %s'),
 
 		'ListSortings' => Array (
 			'' => Array(
 				'ForcedSorting' => Array('Priority' => 'desc'),
 				'Sorting' => Array('CreatedOn' => 'desc'),
 			)
 		),
 
 		'Fields' => Array (
 		   	'CommentId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'PollId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'AnswerId' => Array ('type' => 'int', 'default' => NULL),
 		    'CreatedById' => Array ('type' => 'int', 'formatter'=>'kLEFTFormatter',
 		    						'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'),
 		    						'options' => Array(-1 => 'root', -2 => 'Guest'),
 		    						'left_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'',
 		    						'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login',
 		    						'required' => 1, 'not_null' => 1, 'default' => -2),
 		    'GuestName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
 		    'GuestEmail' => Array('type' => 'string', 'max_len' => 255, 'formatter'=>'kFormatter', 'regexp'=>'/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i', 'sample_value' => 'email@domain.com', 'not_null' => '1', 'default' => '', 'error_msgs' => Array('invalid_format'=>'!la_invalid_email!', 'unique'=>'!lu_email_already_exist!'),'required' => 0 ),
 		    'CommentBody' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => NULL, 'required' => 1),
 		    'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'required' => 1, 'default' => '#NOW#'),
 		    'UserIP' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
 		    'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'Status' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_Active', 0 => 'la_opt_Disabled', 2 => 'la_opt_Pending'), 'use_phrases' => 1, 'required' => 1, 'not_null' => 1, 'default' => 1),
 		),
 
 		'VirtualFields' => Array (
 			'CommentedByUser' => Array('type' => 'string', 'default' => ''),
 			'CommentedByEmail' => Array ('type' => 'string', 'default' => ''),
 		),
 
 		'CalculatedFields' => Array (
 			'' => Array (
 					'CommentedByUser' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
 			),
 		),
 
 		'ConfigMapping' => Array (
 			'PerPage'				=>	'poll_Perpage_Comments',
 			'CommentDelayInterval'	=>	'poll_CommentDelay_Value',
 			'CommentDelayValue'		=>	'poll_CommentDelay_Interval',
 		),
 
 		'Grids' => Array (
 						'Default' => Array (
 							'Icons' => Array (
 								'default' => 'icon16_item.png',
 								0 => 'icon16_disabled.png',
 								1 => 'icon16_item.png',
 								2 => 'icon16_pending.png',
 								'module' => 'core',
 							),
 							'Fields' => Array (
 								'CommentId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
 								'CommentBody' => Array ('title' => 'la_col_PollComment', 'data_block' => 'grid_priority_td', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
 
 								'CommentedByUser' => Array( 'title'=>'la_col_CommentedByUser', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
 
 								'CreatedOn' => Array ('title' => 'la_col_CreatedOn', 'filter_block' => 'grid_date_range_filter', 'width' => 145,  ),
 								'Status' => Array ('title' => 'la_col_Status', 'filter_block' => 'grid_options_filter', 'width' => 100, ),
 							),
 						),
 		),
 
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/poll_comments/poll_comment_eh.php
===================================================================
--- branches/5.0.x/in-bulletin/units/poll_comments/poll_comment_eh.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/poll_comments/poll_comment_eh.php	(revision 12740)
@@ -1,149 +1,149 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class PollCommentEventHandler extends kDBEventHandler {
 
 		/**
 		 * Allows to override standart permission mapping
 		 *
 		 */
 		function mapPermissions()
 		{
 			parent::mapPermissions();
 			$permissions = Array(
 									'OnCreate'		=>	Array('self' => true, 'subitem' => true,),
 									'OnItemBuild'	=>	Array('self' => true, 'subitem' => true,),
 							);
 			$this->permMapping = array_merge($this->permMapping, $permissions);
 		}
 
 		function OnAfterConfigRead(&$event)
 		{
 			if ($this->Application->RecallVar('user_id') == '-2') { // Guest
 				// make Guest Name and Email required for guests
 				$fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
 				$fields['GuestName']['required'] = 1;
 				$fields['GuestEmail']['required'] = 1;
 				$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
 			}
 		}
 
 		/**
 		 * Applies special filter, that allows to select all commented from current poll
 		 *
 		 * @param kEvent $event
 		 */
 		function SetCustomQuery(&$event)
 		{
 			if ($this->Application->isAdminUser) {
 				return ;
 			}
 
 			$object =& $event->getObject();
 			/* @var $object kDBList */
 
 			$object->addFilter('comment_status', '(%1$s.Status = ' .STATUS_ACTIVE. ')');
 		}
 
 		/**
 		 * Before New PollComment created
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemCreate(&$event)
 		{
 			if ($this->Application->isAdminUser) {
 				return ;
 			}
 
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			// get Poll info
 			$parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
 			if($parent_prefix) {
 				$main_object =& $this->Application->recallObject($parent_prefix.'.'.$special, null,Array('raise_warnings' => 0));
 				/* @var $main_object kDBItem */
 
 				if (!$main_object->isLoaded()) {
 					$main_object =& $this->Application->recallObject($parent_prefix);
 				}
 
 				$poll_id = $main_object->GetDBField($this->Application->getUnitOption($event->Prefix, 'ForeignKey'));
 			}
 
 			if ($poll_id) {
 				$spam_helper =& $this->Application->recallObject('SpamHelper');
 				/* @var $spam_helper SpamHelper */
 
 				$spam_helper->InitHelper($poll_id, 'PollComment', 0); // ResourceId used for SpamControl only
 
 				if ($spam_helper->InSpamControl()) {
 					$event->status = erFAIL;
 					$object->SetError('CommentText', 'too_frequent', 'lu_error_AlreadyCommented');
 					return ;
 				}
 			}
 
 			$object->SetDBField('CreatedById', $this->Application->RecallVar('user_id'));
 			$object->SetDBField('UserIP', $_SERVER['REMOTE_ADDR']);
 			$object->SetDBField('PollId', $poll_id); // PollId
 			$object->SetDBField('Status', STATUS_ACTIVE);
 
 			parent::OnBeforeItemCreate($event);
 		}
 
 		/**
 		 * Updates item review counter
 		 *
 		 * @param kEvent $event
 		 */
 		function OnCreate(&$event)
 		{
 			parent::OnCreate($event);
 
 			if ($this->Application->isAdminUser) {
 				return;
 			}
 
 			if ($event->status == erSUCCESS) {
 				$event->setRedirectParam('opener', 's');
 				$event->setRedirectParam('pass', 'm,poll');
 				$event->redirect = $this->Application->GetVar('success_template');
 			}
 		}
 
 		/**
 		 * Updates item review counter
 		 *
 		 * @param kEvent $event
 		 */
 		function OnAfterItemCreate(&$event)
 		{
 			if (!$this->Application->isAdminUser) {
 				$spam_helper =& $this->Application->recallObject('SpamHelper');
 				/* @var $spam_helper SpamHelper */
 
 				$object =& $event->getObject();
 
 				$config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
 				$comment_settings = $config_mapping['CommentDelayValue'].':'.$config_mapping['CommentDelayInterval'];
 				$spam_helper->InitHelper($object->GetDBField('PollId'), 'PollComment', $comment_settings);
 				$spam_helper->AddToSpamControl();
 			}
 		}
 
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/private_message_body/private_message_body_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/private_message_body/private_message_body_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/private_message_body/private_message_body_config.php	(revision 12740)
@@ -1,59 +1,59 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config = Array (
 		'Prefix' => 'private-message-body',
 		'ItemClass'			=>	Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
 		'ListClass'			=>	Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
 		'EventHandlerClass'	=>	Array('class' => 'PrivateMessageBodyEventHandler', 'file' => 'private_message_body_eh.php', 'build_event' => 'OnBuild'),
 		'TagProcessorClass' =>	Array('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
 		'AutoLoad'			=>	true,
 
 		'QueryString' => Array (
 			1 => 'id',
 			2 => 'Page',
 			3 => 'event',
 		),
 
 		'IDField' => 'PMBodyId',
 
 		'TitleField' => 'Subject',
 
 		'TableName' => TABLE_PREFIX.'PrivateMessageBody',
 
 		'ForeignKey' => 'PMBodyId',
 		'ParentTableKey' => 'PMBodyId',
 		'ParentPrefix' => 'private-message',
 		'AutoDelete' => true,
 		'AutoClone' => true,
 
 		'ListSQLs' => Array ('' => ' SELECT %1$s.* %2$s FROM %1$s',),
 		'ItemSQLs' => Array ('' => ' SELECT %1$s.* %2$s FROM %1$s',),
 
 		'Fields' => Array (
 		    'PMBodyId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'Subject' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''),
 		    'Body' => Array ('type' => 'string', 'default' => NULL),
 		    'Options' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'ReferenceCount' => Array ('type' => 'int', 'not_null' => 1, 'default' => 2),
 		),
 
 		'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),
 		),
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/private_message_body/private_message_body_eh.php
===================================================================
--- branches/5.0.x/in-bulletin/units/private_message_body/private_message_body_eh.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/private_message_body/private_message_body_eh.php	(revision 12740)
@@ -1,56 +1,56 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	class PrivateMessageBodyEventHandler extends kDBEventHandler {
 
 		/**
 		 * Sets default values
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemCreate(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			// 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);
 		}
 
 		/**
 		 * Deletes message body only when no message is using it
 		 *
 		 * @param kEvent $event
 		 */
 		function OnBeforeItemDelete(&$event)
 		{
 			$object =& $event->getObject();
 			/* @var $object kDBItem */
 
 			if ($object->GetDBField('ReferenceCount') > 0) {
 				$event->status = erFAIL;
 			}
 		}
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/units/censorship/censorship_config.php
===================================================================
--- branches/5.0.x/in-bulletin/units/censorship/censorship_config.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/units/censorship/censorship_config.php	(revision 12740)
@@ -1,95 +1,95 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 
 	defined('FULL_PATH') or die('restricted access!');
 
 	$config = Array (
 		'Prefix' => 'censorship',
 		'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
 		'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
 		'EventHandlerClass' => Array ('class' => 'kDBEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
 		'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
 
 		'AutoLoad' => true,
 
 		'QueryString' => Array (
 			1 => 'id',
 			2 => 'Page',
 			3 => 'event',
 			4 => 'mode',
 		),
 
 		'IDField' => 'CensorshipId',
 
 		'TableName' => TABLE_PREFIX.'Censorship',
 
 		'TitleField' => 'BadWord',
 
 		'TitlePresets' => Array (
 			'default' => Array (
 				'new_status_labels' => Array ('censorship' => '!la_title_AddingCensorship!'),
 				'edit_status_labels' => Array ('censorship' => '!la_title_EditingCensorship!'),
 			),
 
 			'censorship_list' => Array ('prefixes' => Array ('censorship_List'), 'format' => "!la_tab_ConfigCensorship!"),
 			'censorship_edit' => Array ('prefixes'	=> Array ('censorship'), 'format' => "#censorship_status# '#censorship_titlefield#'"),
 		),
 
 		'PermSection' => Array('main' => 'in-bulletin:configuration_censorship'),
 
 		'Sections' => Array (
 			'in-bulletin:configuration_censorship' => Array (
 				'parent'		=>	'in-bulletin:setting_folder',
 				'icon'			=>	'conf_censorship',
 				'label'			=>	'la_tab_ConfigCensorship',
 				'url'			=>	Array('t' => 'in-bulletin/censorship/censorship_list', 'pass' => 'm'),
 				'permissions'	=>	Array('view', 'add', 'edit', 'delete'),
 				'priority'		=>	1,
 				'type'			=>	stTREE,
 			),
 		),
 
 
 		'ListSQLs' => Array (
 			'' => '	SELECT %1$s.* %2$s FROM %1$s',
 		),
 
 		'ListSortings' => Array (
 			'' => Array (
 				'Sorting' => Array ('BadWord' => 'asc'),
 			)
 		),
 
 		'Fields' => Array (
 			'CensorshipId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
 		    'BadWord' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'required' => 1, 'default' => ''),
 		    'Replacement' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'required' => 1, 'default' => ''),
 		),
 
 		'Grids' => Array (
 			'Default' => Array (
 				'Icons' => Array (
 					'default' => 'icon16_item.png',
 					0 => 'icon16_disabled.png',
 					1 => 'icon16_item.png',
 					'module' => 'core',
 				),
 				'Fields' => Array (
 					'CensorshipId' => Array ('title' => 'la_col_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter',  'width' => 50),
 					'BadWord' => Array ('title' => 'la_col_BadWord', 'filter_block' => 'grid_like_filter', 'width' => 250),
 					'Replacement' => Array ('title' => 'la_col_Replacement', 'filter_block' => 'grid_like_filter', 'width' => 250),
 				),
 			),
 		),
 	);
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/install/upgrades.php
===================================================================
--- branches/5.0.x/in-bulletin/install/upgrades.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/install/upgrades.php	(revision 12740)
@@ -1,96 +1,96 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 	defined('FULL_PATH') or die('restricted access!');
 
 	$upgrade_class = 'InBulletinUpgrades';
 
 	/**
 	 * Class, that holds all upgrade scripts for "Core" module
 	 *
 	 */
 	class InBulletinUpgrades extends kHelper {
 
 		/**
 		 * Install toolkit instance
 		 *
 		 * @var kInstallToolkit
 		 */
 		var $_toolkit = null;
 
 		/**
 		 * Sets common instance of installator toolkit
 		 *
 		 * @param kInstallToolkit $instance
 		 */
 		function setToolkit(&$instance)
 		{
 			$this->_toolkit =& $instance;
 		}
 
 		/**
 		 * Changes table structure, where multilingual fields of TEXT type are present
 		 *
 		 * @param string $mode when called mode {before, after)
 		 */
 		function Upgrade_5_0_0($mode)
 		{
 			if ($mode == 'after') {
 				$root_category = $this->Application->findModule('Name', 'In-Bulletin', 'RootCat');
 
 				$sql = 'UPDATE ' . $this->Application->getUnitOption('c', 'TableName') . '
 						SET UseMenuIconUrl = 1, MenuIconUrl = "in-bulletin/img/menu_topics.gif"
 						WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . $root_category;
 				$this->Conn->Query($sql);
 
 				$this->_updateDetailTemplate('bb', 'inbulletin/post_list', 'in-bulletin/designs/detail');
 			}
 		}
 
 		/**
 		 * Replaces deprecated detail template design with new one
 		 *
 		 * @param string $prefix
 		 * @param string $from_template
 		 * @param string $to_template
 		 */
 		function _updateDetailTemplate($prefix, $from_template, $to_template)
 		{
 			$sql = 'SELECT CustomFieldId
 					FROM ' . TABLE_PREFIX . 'CustomField
 					WHERE FieldName = "' . $prefix . '_ItemTemplate"';
 			$custom_field_id = $this->Conn->GetOne($sql);
 
 			$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
 			/* @var $ml_formatter kMultiLanguage */
 
 			$field = $ml_formatter->LangFieldName('cust_' . $custom_field_id, true);
 
 			$sql = 'UPDATE ' . TABLE_PREFIX . 'CategoryCustomData
 					SET ' . $field . ' = "' . $to_template . '"
 					WHERE ' . $field . ' = "' . $from_template . '"';
 			$this->Conn->Query($sql);
 		}
 
 		/**
 		 * Update to 5.0.1, update details template
 		 *
 		 * @param string $mode when called mode {before, after)
 		 */
 		function Upgrade_5_0_1($mode)
 		{
 			if ($mode == 'after') {
 				$this->_updateDetailTemplate('bb', 'in-bulletin/designs/detail', 'in-bulletin/topics/topic_detail');
 			}
 		}
 	}
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/install/prerequisites.php
===================================================================
--- branches/5.0.x/in-bulletin/install/prerequisites.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/install/prerequisites.php	(revision 12740)
@@ -1,80 +1,80 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 	defined('FULL_PATH') or die('restricted access!');
 
 	$prerequisite_class = 'InBulletinPrerequisites';
 
 	/**
 	 * Class, that holds all prerequisite scripts for "In-Bulletin" module
 	 *
 	 */
 	class InBulletinPrerequisites extends kHelper {
 
 		/**
 		 * Install toolkit instance
 		 *
 		 * @var kInstallToolkit
 		 */
 		var $_toolkit = null;
 
 		/**
 		 * Sets common instance of installator toolkit
 		 *
 		 * @param kInstallToolkit $instance
 		 */
 		function setToolkit(&$instance)
 		{
 			$this->_toolkit =& $instance;
 		}
 
 		/**
 		 * Checks minimal version, that could be upgradeable
 		 *
 		 * @param string $mode when called mode {install, standalone, upgrade)
 		 */
 		function CheckPrerequisites($versions, $mode)
 		{
 			$errors = Array ();
 
 			if ($mode == 'standalone') {
 				if (!$this->Application->isModuleEnabled('In-Portal')) {
 					$errors[] = 'Please install or enable "In-Portal" module first';
 				}
 			}
 
 			if ($mode == 'upgrade') {
 				$sql = 'SELECT Version
 						FROM ' . TABLE_PREFIX . 'Modules
 						WHERE Name = "In-Portal"';
 				$inportal_version = $this->Conn->GetOne($sql);
 
 				if ($inportal_version === false) {
 					// only, when In-Portal was installed
 					return $errors;
 				}
 
 				$min_version = '4.3.1';
 
 				$current_version = $this->_toolkit->ConvertModuleVersion($inportal_version);
 				$needed_version = $this->_toolkit->ConvertModuleVersion($min_version);
 				if ($current_version < $needed_version) {
 					$errors[] = 'Please upgrade "In-Portal" to version ' . $min_version;
 				}
 			}
 
 			return $errors;
 		}
 	}
 
 ?>
\ No newline at end of file
Index: branches/5.0.x/in-bulletin/install.php
===================================================================
--- branches/5.0.x/in-bulletin/install.php	(revision 12739)
+++ branches/5.0.x/in-bulletin/install.php	(revision 12740)
@@ -1,53 +1,53 @@
 <?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.net/license/ for copyright notices and details.
+* See http://www.in-portal.org/license for copyright notices and details.
 */
 	$module_folder = 'in-bulletin';
 
 	if (!defined('IS_INSTALL')) {
 		// separate module install
 		define('IS_INSTALL', 1);
 		define('ADMIN', 1);
 		define('REL_PATH', $module_folder);
 		define('FULL_PATH', realpath(dirname(__FILE__) . '/..') );
 
 		include_once(FULL_PATH . '/core/kernel/startup.php');
 		require_once FULL_PATH . '/core/install/install_toolkit.php';
 
 		$toolkit = new kInstallToolkit();
 	}
 	else {
 		// install, using installation wizard
 		$toolkit =& $this->toolkit;
 		/* @var $toolkit kInstallToolkit */
 	}
 
 	$application =& kApplication::Instance();
 	$application->Init();
 
 	if ($application->RecallVar('user_id') != -1) {
 		die('restricted access!');
 	}
 
 	$category =& $toolkit->createModuleCategory('Forums', 'Discussion Forums', '/in-bulletin/designs/section', 'in-bulletin/img/menu_topics.gif');
 
 	$toolkit->RunSQL('/' . $module_folder . '/install/install_schema.sql');
 	$toolkit->RunSQL('/' . $module_folder . '/install/install_data.sql', '{TopicCatId}', $category->GetID());
 	$toolkit->ImportLanguage('/' . $module_folder . '/install/english');
 
 	$toolkit->SetModuleRootCategory($module_folder, $category->GetID());
 
 //	$toolkit->linkCustomFields($module_folder, 'bb', 3); // to create Custom Fields for Topics
 	$toolkit->linkCustomFields('KERNEL', 'c', 1); // to create ItemTemplate custom field
 	$toolkit->setModuleItemTemplate($category, 'bb', 'in-bulletin/topics/topic_detail');
 
 	$toolkit->finalizeModuleInstall($module_folder, true);
\ No newline at end of file