AntonLV 10 лет назад
Родитель
Сommit
16bf522edd

+ 22 - 2
modules/boonex/forum/classes/BxForumCmts.php

@@ -11,7 +11,27 @@
 
 class BxForumCmts extends BxTemplCmts
 {
-    function getCommentsBlock($iParentId = 0, $iVParentId = 0, $bInDesignbox = true)
+	protected $MODULE;
+	protected $_oModule;
+
+	public function __construct($sSystem, $iId, $iInit = 1)
+    {
+    	$this->MODULE = 'bx_forum';
+    	$this->_oModule = BxDolModule::getInstance($this->MODULE);
+
+        parent::__construct($sSystem, $iId, $iInit);
+    }
+
+	public function isPostReplyAllowed($isPerformAction = false)
+    {
+    	$aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iId);
+        if(!$aContentInfo || (int)$aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_LOCK']] == 1)
+            return false;
+
+    	return parent::isPostReplyAllowed($isPerformAction);
+    }
+
+    public function getCommentsBlock($iParentId = 0, $iVParentId = 0, $bInDesignbox = true)
     {
         $mixedBlock = parent::getCommentsBlock($iParentId, $iVParentId, $bInDesignbox);
         if (is_array($mixedBlock) && isset($mixedBlock['title']))
@@ -19,7 +39,7 @@ class BxForumCmts extends BxTemplCmts
         return $mixedBlock;
     }
 
-    function getComment($mixedCmt, $aBp = array(), $aDp = array())
+    public function getComment($mixedCmt, $aBp = array(), $aDp = array())
     {
     	return parent::getComment($mixedCmt, $aBp, array_merge($aDp, array(
     		'class_comment' => ' bx-def-box bx-def-padding bx-def-round-corners bx-def-color-bg-box'

+ 15 - 2
modules/boonex/forum/classes/BxForumConfig.php

@@ -16,8 +16,14 @@ class BxForumConfig extends BxBaseModTextConfig
         parent::__construct($aModule);
 
         $aMenuItems2Methods = array (
-            'delete-discussion' => 'checkAllowedDelete',
-            'mark-unread-discussion' => 'checkAllowedView',
+        	'stick-discussion' => 'checkAllowedStickAnyEntry',
+        	'unstick-discussion' => 'checkAllowedUnstickAnyEntry',
+        	'lock-discussion' => 'checkAllowedLockAnyEntry',
+        	'unlock-discussion' => 'checkAllowedUnlockAnyEntry',
+        	'hide-discussion' => 'checkAllowedHideAnyEntry',
+        	'unhide-discussion' => 'checkAllowedUnhideAnyEntry',
+        	'edit-discussion' => 'checkAllowedEdit',
+            'delete-discussion' => 'checkAllowedDelete'
         );
 
         $this->CNF = array (
@@ -40,7 +46,10 @@ class BxForumConfig extends BxBaseModTextConfig
             'FIELD_PHOTO' => 'attachments',
             'FIELD_THUMB' => '',
             'FIELD_COMMENTS' => 'comments',
+        	'FIELD_STICK' => 'stick',
+        	'FIELD_LOCK' => 'lock',
         	'FIELD_STATUS' => 'status',
+        	'FIELD_STATUS_ADMIN' => 'status_admin',
 	        'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
 
             // page URIs
@@ -108,10 +117,14 @@ class BxForumConfig extends BxBaseModTextConfig
         );
 
         $this->_aJsClasses = array(
+        	'main' => 'BxForumMain',
+        	'entry' => 'BxForumEntry',
         	'manage_tools' => 'BxForumManageTools'
         );
 
         $this->_aJsObjects = array(
+        	'main' => 'oBxForumMain',
+        	'entry' => 'oBxForumEntry',
         	'manage_tools' => 'oBxForumManageTools'
         );
 

+ 23 - 16
modules/boonex/forum/classes/BxForumDb.php

@@ -19,9 +19,15 @@ class BxForumDb extends BxBaseModTextDb
         parent::__construct($oConfig);
     }
 
+	public function updateEntries($aSet, $aWhere)
+    {
+        $sQuery = "UPDATE `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` SET " . $this->arrayToSQL($aSet) . " WHERE " . (!empty($aWhere) ? $this->arrayToSQL($aWhere, ' AND ') : "1");
+        return (int)$this->query($sQuery) > 0;
+    }
+
     public function updateLastCommentTimeProfile($iConversationId, $iProfileId, $iCommentId, $iTimestamp)
     {
-        $sQuery = $this->prepare("UPDATE `" . $this->getPrefix() . "discussions` SET `last_reply_profile_id` = ?, `last_reply_timestamp` = ?, `last_reply_comment_id` = ? WHERE `id` = ?", $iProfileId, $iTimestamp, $iCommentId, $iConversationId);
+        $sQuery = $this->prepare("UPDATE `" . $this->getPrefix() . "discussions` SET `lr_profile_id` = ?, `lr_timestamp` = ?, `lr_comment_id` = ? WHERE `id` = ?", $iProfileId, $iTimestamp, $iCommentId, $iConversationId);
         return $this->query($sQuery);
     }
 
@@ -62,25 +68,26 @@ class BxForumDb extends BxBaseModTextDb
 
         $sQuery = $this->prepare("SELECT COUNT(`te`.`id`)
             FROM `" . $CNF['TABLE_ENTRIES'] . "` AS `te`
-            WHERE `te`.`author`=? AND `te`.`last_reply_profile_id`<>?", $iProfileId, $iProfileId);
+            WHERE `te`.`author`=? AND `te`.`lr_profile_id`<>?", $iProfileId, $iProfileId);
 
 		return $this->getOne($sQuery);
     }
 
-    public function getMessagesPreviews ($iProfileId, $iStart = 0, $iLimit = 4)
-    {
-    	/*
-        $sQuery = $this->prepare("SELECT `c`.`id`, `c`.`text`, `c`.`author`, `cmts`.`cmt_text`, `c`.`last_reply_profile_id`, `c`.`comments`, (`c`.`comments` - `f`.`read_comments`) AS `unread_messages`, `last_reply_timestamp`
-            FROM `" . $this->getPrefix() . "discussion2folder` as `f`
-            INNER JOIN `" . $this->getPrefix() . "discussions` AS `c` ON (`c`.`id` = `f`.`discussion_id`)
-            LEFT JOIN `" . $this->getPrefix() . "cmts` AS `cmts` ON (`cmts`.`cmt_id` = `c`.`last_reply_comment_id`)
-            WHERE `f`.`collaborator` = ? AND `f`.`folder_id` = ?
-            ORDER BY `c`.`last_reply_timestamp` DESC
-            LIMIT ?, ?", $iProfileId, $iFolderId, $iStart, $iLimit);
-        return $this->getAll($sQuery);
-        */
-    	return array();
-    }
+	public function updateStatus($sAction, $aContentInfo)
+	{
+		$CNF = &$this->_oConfig->CNF;
+
+		$aActions = array(
+			'stick' => array($CNF['FIELD_STICK'] => 1),
+			'unstick' => array($CNF['FIELD_STICK'] => 0),
+			'lock' =>  array($CNF['FIELD_LOCK'] => 1),
+			'unlock' =>  array($CNF['FIELD_LOCK'] => 0),
+			'hide' =>  array($CNF['FIELD_STATUS_ADMIN'] => 'hidden'),
+			'unhide' =>  array($CNF['FIELD_STATUS_ADMIN'] => 'active')
+		);
+
+		return $this->updateEntries($aActions[$sAction], array($CNF['FIELD_ID'] => $aContentInfo[$CNF['FIELD_ID']]));
+	}
 }
 
 /** @} */

+ 2 - 2
modules/boonex/forum/classes/BxForumFormEntry.php

@@ -31,8 +31,8 @@ class BxForumFormEntry extends BxBaseModTextFormEntry
     {
     	$CNF = $this->_oModule->_oConfig->CNF;
 
-        $aValsToAdd['last_reply_timestamp'] = time();
-        $aValsToAdd['last_reply_profile_id'] = bx_get_logged_profile_id();
+        $aValsToAdd['lr_timestamp'] = time();
+        $aValsToAdd['lr_profile_id'] = bx_get_logged_profile_id();
 
         $iDraftId = (int)bx_get('draft_id');
         $bDraftSave = (int)bx_get('draft_save') == 1; //--- draft is saved via ajax call only, upon successfull draft saving content id is returned

+ 31 - 3
modules/boonex/forum/classes/BxForumGrid.php

@@ -37,7 +37,7 @@ class BxForumGrid extends BxTemplGrid
                 break;
 
 			case 'latest':
-				$sField = 'last_reply_timestamp';
+				$sField = 'lr_timestamp';
                 break;
 
 			case 'top':
@@ -76,9 +76,9 @@ class BxForumGrid extends BxTemplGrid
         return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
     }
 
-    protected function _getCellLastReplyTimestamp($mixedValue, $sKey, $aField, $aRow)
+    protected function _getCellLrTimestamp($mixedValue, $sKey, $aField, $aRow)
     {
-        $mixedValue = $this->_oModule->_oTemplate->getEntryPreviewGrid($aRow);
+        $mixedValue = $this->_oModule->_oTemplate->getEntryPreview($aRow);
 
         return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
     }
@@ -97,6 +97,34 @@ class BxForumGrid extends BxTemplGrid
         $this->_oModule->_oTemplate->addJs('main.js');
         $this->_oModule->_oTemplate->addCss(array('main-media-tablet.css', 'main-media-desktop.css'));
     }
+
+    protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
+    {
+    	$sJoinClause = $sWhereClause = '';
+
+    	//--- Check status
+    	$sWhereClause .= " AND `" . $this->_oModule->_oConfig->CNF['FIELD_STATUS'] . "`='active'";
+    	$sWhereClause .= " AND `" . $this->_oModule->_oConfig->CNF['FIELD_STATUS_ADMIN'] . "`='active'";
+
+    	//--- Check privacy
+		$sPrivacy = $this->_oModule->_oConfig->CNF['OBJECT_PRIVACY_VIEW'];
+		$oPrivacy = BxDolPrivacy::getObjectInstance($sPrivacy);
+		$aCondition = $oPrivacy ? $oPrivacy->getContentPublicAsSQLPart() : array();
+		if(isset($aCondition['join']))
+			$sJoinClause .= $aCondition['join'];
+		if(isset($aCondition['where']))
+			$sWhereClause .= $aCondition['where'];
+
+		$this->_aOptions['source'] = sprintf($this->_aOptions['source'], $sJoinClause, $sWhereClause);
+		return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
+    }
+
+    protected function _getDataSqlOrderClause($sOrderByFilter, $sOrderField, $sOrderDir, $bFieldsOnly = false)
+    {
+    	$sOrder = parent::_getDataSqlOrderClause($sOrderByFilter, $sOrderField, $sOrderDir, true);
+
+    	return " ORDER BY `" . $this->_oModule->_oConfig->CNF['FIELD_STICK'] . "` DESC, " . $sOrder;
+    }
 }
 
 /** @} */

+ 4 - 0
modules/boonex/forum/classes/BxForumMenuView.php

@@ -18,6 +18,10 @@ class BxForumMenuView extends BxBaseModTextMenuView
     {
         $this->MODULE = 'bx_forum';
         parent::__construct($aObject, $oTemplate);
+
+        $this->addMarkers(array(
+        	'js_object' => $this->_oModule->_oConfig->getJsObject('entry') 
+        ));
     }
 }
 

+ 100 - 10
modules/boonex/forum/classes/BxForumModule.php

@@ -37,6 +37,31 @@ class BxForumModule extends BxBaseModTextModule
         return $aParticipants;
     }
 
+    /**
+     * Action methods
+     */
+    public function actionUpdateStatus($sAction = '', $iContentId = 0)
+    {
+    	if(empty($sAction) && bx_get('action') !== false)
+   			$sAction = bx_process_input(bx_get('action'));
+
+		if(empty($iContentId) && bx_get('id') !== false)
+    		$iContentId = (int)bx_get('id');
+
+    	$aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        if(empty($aContentInfo) || !is_array($aContentInfo))
+			return echoJson(array('code' => 1, 'message' => _t('_bx_forum_err_not_found')));
+
+		$sMethodCheck = 'checkAllowed' . bx_gen_method_name($sAction) . 'AnyEntry';
+		$sResult = $this->$sMethodCheck($aContentInfo);
+        if($sResult !== CHECK_ACTION_RESULT_ALLOWED)
+        	return echoJson(array('code' => 2, 'message' => $sResult));
+
+        if(!$this->_oDb->updateStatus($sAction, $aContentInfo))
+        	return echoJson(array('code' => 3, 'message' => _t('_error occured')));
+
+    	echoJson(array('code' => 0, 'id' => $iContentId, 'reload' => 1));
+    }
 
     /**
      * Service methods
@@ -71,16 +96,6 @@ class BxForumModule extends BxBaseModTextModule
 		return $this->_serviceBrowseTable($sType);
     }  
 
-    public function serviceMessagesPreviews ($iProfileId = 0)
-    {
-        if (!$iProfileId)
-            $iProfileId = bx_get_logged_profile_id();
-
-        $a = $this->_oDb->getMessagesPreviews($iProfileId, 0, (int)getParam('bx_forum_per_page_preview'));
-
-        return 'TODO: Need to know where to take previews from.'; //TODO: $this->_oTemplate->getMessagesPreviews($a);
-    }
-
     /**
      * Get number of unread messages for spme profile
      * @param $iProfileId - profile to get unread messages for, if omitted then currently logged is profile is used
@@ -161,6 +176,81 @@ class BxForumModule extends BxBaseModTextModule
         return _t('_sys_txt_access_denied');
     }
 
+    public function checkAllowedStickAnyEntry($aDataEntry, $isPerformAction = false)
+    {
+    	$CNF = $this->_oConfig->CNF;
+
+    	if((int)$aDataEntry[$CNF['FIELD_STICK']] != 0)
+    		return false;
+
+		return $this->_checkAllowedAction('stick any entry', $aDataEntry, $isPerformAction);
+    }
+
+    public function checkAllowedUnstickAnyEntry($aDataEntry, $isPerformAction = false)
+    {
+    	$CNF = $this->_oConfig->CNF;
+
+    	if((int)$aDataEntry[$CNF['FIELD_STICK']] != 1)
+			return false;
+
+    	return $this->_checkAllowedAction('stick any entry', $aDataEntry, $isPerformAction);
+    }
+
+    public function checkAllowedLockAnyEntry($aDataEntry, $isPerformAction = false)
+    {
+    	$CNF = $this->_oConfig->CNF;
+
+    	if((int)$aDataEntry[$CNF['FIELD_LOCK']] != 0)
+    		return false;
+
+		return $this->_checkAllowedAction('lock any entry', $aDataEntry, $isPerformAction);
+    }
+
+	public function checkAllowedUnlockAnyEntry($aDataEntry, $isPerformAction = false)
+    {
+    	$CNF = $this->_oConfig->CNF;
+
+    	if((int)$aDataEntry[$CNF['FIELD_LOCK']] != 1)
+    		return false;
+
+		return $this->_checkAllowedAction('lock any entry', $aDataEntry, $isPerformAction);
+    }
+
+    public function checkAllowedHideAnyEntry($aDataEntry, $isPerformAction = false)
+    {
+    	$CNF = $this->_oConfig->CNF;
+
+    	if($aDataEntry[$CNF['FIELD_STATUS_ADMIN']] == 'hidden')
+    		return false;
+
+		return $this->_checkAllowedAction('hide any entry', $aDataEntry, $isPerformAction);
+    }
+
+	public function checkAllowedUnhideAnyEntry($aDataEntry, $isPerformAction = false)
+    {
+    	$CNF = $this->_oConfig->CNF;
+
+    	if($aDataEntry[$CNF['FIELD_STATUS_ADMIN']] != 'hidden')
+    		return false;
+
+		return $this->_checkAllowedAction('hide any entry', $aDataEntry, $isPerformAction);
+    }
+
+	/**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    protected function _checkAllowedAction($sAction, $aDataEntry, $isPerformAction = false)
+    {
+        if($this->_isModerator($isPerformAction))
+			return CHECK_ACTION_RESULT_ALLOWED;
+
+		$aCheck = checkActionModule($this->_iProfileId, $sAction, $this->getName(), $isPerformAction);
+    	if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+    		return CHECK_ACTION_RESULT_ALLOWED;
+
+        return _t('_sys_txt_access_denied');
+    }
+
 	protected function _serviceBrowseTable($sType)
     {
         $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->CNF['OBJECT_GRID']);

+ 7 - 0
modules/boonex/forum/classes/BxForumPageBrowse.php

@@ -18,6 +18,13 @@ class BxForumPageBrowse extends BxBaseModTextPageBrowse
     {
         $this->MODULE = 'bx_forum';
         parent::__construct($aObject, $oTemplate);
+
+        $this->_oModule->_oTemplate->addJs(array('main.js'));
+    }
+
+	public function getCode()
+    {
+    	return $this->_oModule->_oTemplate->getJsCode('main') . parent::getCode();
     }
 }
 

+ 6 - 1
modules/boonex/forum/classes/BxForumPageEntry.php

@@ -21,9 +21,14 @@ class BxForumPageEntry extends BxBaseModTextPageEntry
 
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $this->_oModule->_oTemplate->addJs(array('main.js'));
+        $this->_oModule->_oTemplate->addJs(array('main.js', 'entry.js'));
         $this->_oModule->_oTemplate->addCss(array('main-media-tablet.css', 'main-media-desktop.css'));
     }
+
+    public function getCode()
+    {
+    	return $this->_oModule->_oTemplate->getJsCode('entry') . parent::getCode();
+    }
 }
 
 /** @} */

+ 2 - 2
modules/boonex/forum/classes/BxForumSearchResult.php

@@ -21,7 +21,7 @@ class BxForumSearchResult extends BxBaseModTextSearchResult
             'object_metatags' => 'bx_forum',
             'title' => _t('_bx_forum_page_title_browse'),
             'table' => 'bx_forum_discussions',
-            'ownFields' => array('id', 'title', 'text', 'author', 'added', 'comments', 'last_reply_profile_id'),
+            'ownFields' => array('id', 'title', 'text', 'author', 'added', 'comments', 'lr_profile_id'),
             'searchFields' => array('title', 'text'),
             'restriction' => array(
                 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
@@ -130,7 +130,7 @@ class BxForumSearchResult extends BxBaseModTextSearchResult
                 $aSql['order'] = ' ORDER BY `bx_forum_discussions`.`changed` DESC';
                 break;
 			case 'latest':
-                $aSql['order'] = ' ORDER BY `bx_forum_discussions`.`last_reply_timestamp` DESC';
+                $aSql['order'] = ' ORDER BY `bx_forum_discussions`.`lr_timestamp` DESC';
                 break;
 			case 'top':
                 $aSql['order'] = ' ORDER BY `bx_forum_discussions`.`comments` DESC';

+ 25 - 68
modules/boonex/forum/classes/BxForumTemplate.php

@@ -31,7 +31,7 @@ class BxForumTemplate extends BxBaseModTextTemplate
         $aParticipants = $this->_oDb->getComments(array('type' => 'author_comments', 'object_id' => $aContentInfo[$CNF['FIELD_ID']]));
 
         // sort participants: first - current user, second - last replier, third - author, all others sorted by max number of posts
-        $aParticipants = $oModule->sortParticipants($aParticipants, $aContentInfo['last_reply_profile_id'], $aContentInfo[$CNF['FIELD_AUTHOR']]);
+        $aParticipants = $oModule->sortParticipants($aParticipants, $aContentInfo['lr_profile_id'], $aContentInfo[$CNF['FIELD_AUTHOR']]);
         $iParticipantsNum = count($aParticipants);
 
         // prepare template variables
@@ -65,7 +65,7 @@ class BxForumTemplate extends BxBaseModTextTemplate
             $sInfo = '';
             if ($aContentInfo[$CNF['FIELD_AUTHOR']] == $iProfileId)
                 $sInfo = _t('_bx_forum_participant_author');
-            if ($aContentInfo['last_reply_profile_id'] == $iProfileId)
+            if ($aContentInfo['lr_profile_id'] == $iProfileId)
                 $sInfo .= ', ' . _t('_bx_forum_participant_last_replier');
             $sInfo = trim($sInfo, ', ');
             $sInfo = $sInfo ? _t('_bx_forum_participant_info', $oProfile->getDisplayName(), $sInfo) : $oProfile->getDisplayName();
@@ -85,7 +85,7 @@ class BxForumTemplate extends BxBaseModTextTemplate
             		)
             	),
                 'bx_if:last_replier' => array (
-                    'condition' => ($aContentInfo['last_reply_profile_id'] == $iProfileId),
+                    'condition' => ($aContentInfo['lr_profile_id'] == $iProfileId),
                     'content' => array (
                         'id' => $oProfile->id(),
                     ),
@@ -113,56 +113,6 @@ class BxForumTemplate extends BxBaseModTextTemplate
         return $this->parseHtmlByName('participants.html', $aVars);
     }
 
-    function getMessagesPreviews ($a)
-    {
-        if (empty($a))
-            return MsgBox(_t('_Empty'));
-
-        $oModule = BxDolModule::getInstance($this->MODULE);
-
-        $aVars = array(
-            'see_all_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($oModule->_oConfig->CNF['URL_HOME']),
-            'bx_repeat:messages' => array(),
-        );
-        foreach ($a as $r) {
-
-            $oProfileAuthor = BxDolProfile::getInstance($r['author']);
-            if (!$oProfileAuthor)
-                $oProfileAuthor = BxDolProfileUndefined::getInstance();
-
-            $oProfileLast = BxDolProfile::getInstance($r['last_reply_profile_id']);
-            if (!$oProfileLast)
-                $oProfileLast = BxDolProfileUndefined::getInstance();
-
-            $sText = strmaxtextlen($r['text'], 90);
-            $sTextCmt = strmaxtextlen($r['cmt_text'], 50);
-
-            $aVars['bx_repeat:messages'][] = array (
-                'id' => $r['id'],
-                'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $oModule->_oConfig->CNF['URI_VIEW_ENTRY'] . '&id=' . $r['id']),
-                'text' => $sText ? $sText : $oProfileAuthor->getDisplayName(),
-                'cmt_text' => $sTextCmt,
-                'unread_messages' => $r['unread_messages'],
-                'last_reply_time_and_replier' => _t('_bx_forum_x_date_by_x_replier', bx_time_js($r['last_reply_timestamp'], BX_FORMAT_DATE), $oProfileLast->getDisplayName()),
-                'font_weight' => $r['unread_messages'] > 0 ? 'bold' : 'normal',
-                'label' => $this->getEntryLabel($r, array('show_count' => 0), $oProfileLast),
-
-                'author_id' => $oProfileAuthor->id(),
-                'author_url' => $oProfileAuthor->getUrl(),
-                'author_title' => $oProfileAuthor->getDisplayName(),
-                'author_title_attr' => bx_html_attribute($oProfileAuthor->getDisplayName()),
-                'author_thumb_url' => $oProfileAuthor->getThumb(),
-
-                'last_replier_id' => $oProfileLast->id(),
-                'last_replier_url' => $oProfileLast->getUrl(),
-                'last_replier_title' => $oProfileLast->getDisplayName(),
-                'last_replier_title_attr' => bx_html_attribute($oProfileLast->getDisplayName()),
-                'last_replier_thumb_url' => $oProfileLast->getThumb(),
-            );
-        }
-        return $this->parseHtmlByName('messages_previews.html', $aVars);
-    }
-
 	function getEntryAuthor($aRow)
     {
     	$oProfileAuthor = BxDolProfile::getInstance($aRow['author']);
@@ -178,15 +128,13 @@ class BxForumTemplate extends BxBaseModTextTemplate
     	));
     }
 
-	function getEntryLabel($aRow, $aParams = array(), $oProfileLast = null)
+	function getEntryLabel($aRow, $aParams = array())
     {
     	$bShowCount = isset($aParams['show_count']) ? (int)$aParams['show_count'] == 1 : false;
 
-        if(!$oProfileLast) {
-            $oProfileLast = BxDolProfile::getInstance($aRow['last_reply_profile_id']);
-            if(!$oProfileLast)
-				$oProfileLast = BxDolProfileUndefined::getInstance();
-        }
+		$oProfileLast = BxDolProfile::getInstance($aRow['lr_profile_id']);
+		if(!$oProfileLast)
+			$oProfileLast = BxDolProfileUndefined::getInstance();
 
         return $this->parseHtmlByName('entry-label.html', array(
         	'bx_if:show_count' => array(
@@ -202,22 +150,31 @@ class BxForumTemplate extends BxBaseModTextTemplate
         ));
     }
 
-    function getEntryPreviewGrid($aRow)
+    function getEntryPreview($aRow)
     {
         $oModule = BxDolModule::getInstance($this->MODULE);
+        $CNF = &$oModule->_oConfig->CNF;
 
-        $oProfileLast = BxDolProfile::getInstance($aRow['last_reply_profile_id']);
-        if (!$oProfileLast)
+        $oProfileLast = BxDolProfile::getInstance($aRow['lr_profile_id']);
+        if(!$oProfileLast)
             $oProfileLast = BxDolProfileUndefined::getInstance();
 
-        $sText = strmaxtextlen($aRow['text'], 100);
-        $sTextCmt = strmaxtextlen($aRow['cmt_text'], 100);
+		$sTitle = strmaxtextlen($aRow['title'], 100);
+        $sText = strmaxtextlen(!empty($aRow['cmt_text']) ? $aRow['cmt_text'] : $aRow['text'], 100);
 
-        return $this->parseHtmlByName('entry-preview-grid.html', array(
+        return $this->parseHtmlByName('entry-preview.html', array(
+        	'bx_if:show_stick' => array(
+        		'condition' => (int)$aRow[$CNF['FIELD_STICK']] == 1,
+        		'content' => array()
+        	),
+        	'bx_if:show_lock' => array(
+        		'condition' => (int)$aRow[$CNF['FIELD_LOCK']] == 1,
+        		'content' => array()
+        	),
             'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $oModule->_oConfig->CNF['URI_VIEW_ENTRY'] . '&id=' . $aRow['id']),
-            'text' => $sText ? $sText : _t('_Empty'),
-            'cmt_text' => $sTextCmt,
-            'last_reply_time_and_replier' => _t('_bx_forum_x_date_by_x_replier', bx_time_js($aRow['last_reply_timestamp'], BX_FORMAT_DATE), $oProfileLast->getDisplayName()),
+            'title' => $sTitle ? $sTitle : _t('_Empty'),
+            'text' => $sText,
+            'lr_time_and_replier' => _t('_bx_forum_x_date_by_x_replier', bx_time_js($aRow['lr_timestamp'], BX_FORMAT_DATE), $oProfileLast->getDisplayName()),
         ));
     }
 

+ 19 - 33
modules/boonex/forum/install/langs/en.xml

@@ -40,6 +40,9 @@
 	<string name="_bx_forum_acl_action_delete_entry"><![CDATA[Delete discussion]]></string>
 	<string name="_bx_forum_acl_action_view_entry"><![CDATA[View discussion]]></string>
 	<string name="_bx_forum_acl_action_edit_any_entry"><![CDATA[Edit any discussion]]></string>
+	<string name="_bx_forum_acl_action_stick_any_entry"><![CDATA[Stick any discussion]]></string>
+	<string name="_bx_forum_acl_action_lock_any_entry"><![CDATA[Lock any discussion]]></string>
+	<string name="_bx_forum_acl_action_hide_any_entry"><![CDATA[Hide any discussion]]></string>
 
 	<string name="_bx_forum_page_title_sys_create_entry"><![CDATA[New discussion]]></string>
 	<string name="_bx_forum_page_title_create_entry"><![CDATA[New discussion]]></string>
@@ -58,7 +61,6 @@
     <string name="_bx_forum_page_block_title_entry_actions"><![CDATA[Actions]]></string>
     <string name="_bx_forum_page_block_title_entry_comments"><![CDATA[Replies ({0})]]></string>
     <string name="_bx_forum_page_block_title_entry_participants"><![CDATA[Participants]]></string>
-    <string name="_bx_forum_page_block_title_forum"><![CDATA[Forum]]></string>
     <string name="_bx_forum_page_title_browse"><![CDATA[Forum]]></string>
 	<string name="_bx_forum_page_title_search_results"><![CDATA[Discussions matching "{0}"]]></string>
 	<string name="_bx_forum_page_title_browse_by_author"><![CDATA[Discussions of {display_name}]]></string>
@@ -119,6 +121,18 @@
     <string name="_bx_forum_menu_item_title_edit_entry"><![CDATA[Edit]]></string>
     <string name="_bx_forum_menu_item_title_system_delete_entry"><![CDATA[Delete]]></string>
     <string name="_bx_forum_menu_item_title_delete_entry"><![CDATA[Delete]]></string>
+    <string name="_bx_forum_menu_item_title_system_stick_entry"><![CDATA[Stick]]></string>
+    <string name="_bx_forum_menu_item_title_stick_entry"><![CDATA[Stick]]></string>
+    <string name="_bx_forum_menu_item_title_system_unstick_entry"><![CDATA[Unstick]]></string>
+    <string name="_bx_forum_menu_item_title_unstick_entry"><![CDATA[Unstick]]></string>
+    <string name="_bx_forum_menu_item_title_system_lock_entry"><![CDATA[Lock]]></string>
+    <string name="_bx_forum_menu_item_title_lock_entry"><![CDATA[Lock]]></string>
+    <string name="_bx_forum_menu_item_title_system_unlock_entry"><![CDATA[Unlock]]></string>
+    <string name="_bx_forum_menu_item_title_unlock_entry"><![CDATA[Unlock]]></string>
+    <string name="_bx_forum_menu_item_title_system_hide_entry"><![CDATA[Hide]]></string>
+    <string name="_bx_forum_menu_item_title_hide_entry"><![CDATA[Hide]]></string>
+    <string name="_bx_forum_menu_item_title_system_unhide_entry"><![CDATA[Unhide]]></string>
+    <string name="_bx_forum_menu_item_title_unhide_entry"><![CDATA[Unhide]]></string>
     <string name="_bx_forum_menu_item_title_system_entries_home"><![CDATA[Discussions]]></string>
     <string name="_bx_forum_menu_item_title_entries_home"><![CDATA[Discussions]]></string>
     <string name="_bx_forum_menu_item_title_system_entries_public"><![CDATA[Latest]]></string>
@@ -165,42 +179,14 @@
     <string name="_bx_forum_grid_action_title_add"><![CDATA[New discussion]]></string>
 
 	<string name="_bx_forum_pre_lists_cats"><![CDATA[Forum categories]]></string>
-    <string name="_bx_forum_cat_Animals_Pets"><![CDATA[Animals & Pets]]></string>
-    <string name="_bx_forum_cat_Architecture"><![CDATA[Architecture]]></string>
-    <string name="_bx_forum_cat_Art"><![CDATA[Art]]></string>
-    <string name="_bx_forum_cat_Cars_Motorcycles"><![CDATA[Cars & Motorcycles]]></string>
-    <string name="_bx_forum_cat_Celebrities"><![CDATA[Celebrities]]></string>
-    <string name="_bx_forum_cat_Design"><![CDATA[Design]]></string>
-    <string name="_bx_forum_cat_DIY_Crafts"><![CDATA[DIY & Crafts]]></string>
-    <string name="_bx_forum_cat_Education"><![CDATA[Education]]></string>
-    <string name="_bx_forum_cat_Film_Music_Books"><![CDATA[Film, Music & Books]]></string>
-    <string name="_bx_forum_cat_Food_Drink"><![CDATA[Food & Drink]]></string>
-    <string name="_bx_forum_cat_Gardening"><![CDATA[Gardening]]></string>
-    <string name="_bx_forum_cat_Geek"><![CDATA[Geek]]></string>
-    <string name="_bx_forum_cat_Hair_Beauty"><![CDATA[Hair & Beauty]]></string>
-    <string name="_bx_forum_cat_Health_Fitness"><![CDATA[Health & Fitness]]></string>
-    <string name="_bx_forum_cat_History"><![CDATA[History]]></string>
-    <string name="_bx_forum_cat_Holidays_Events"><![CDATA[Holidays & Events]]></string>
-    <string name="_bx_forum_cat_Home_Decor"><![CDATA[Home Decor]]></string>
-    <string name="_bx_forum_cat_Humor"><![CDATA[Humor]]></string>
-    <string name="_bx_forum_cat_Illustrations_Posters"><![CDATA[Illustrations & Posters]]></string>
-    <string name="_bx_forum_cat_Kids_Parenting"><![CDATA[Kids & Parenting]]></string>
-    <string name="_bx_forum_cat_Mens_Fashion"><![CDATA[Men's Fashion]]></string>
-    <string name="_bx_forum_cat_Outdoors"><![CDATA[Outdoors]]></string>
-    <string name="_bx_forum_cat_Photography"><![CDATA[Photography]]></string>
-    <string name="_bx_forum_cat_Products"><![CDATA[Products]]></string>
-    <string name="_bx_forum_cat_Quotes"><![CDATA[Quotes]]></string>
-    <string name="_bx_forum_cat_Science_Nature"><![CDATA[Science & Nature]]></string>
-    <string name="_bx_forum_cat_Sports"><![CDATA[Sports]]></string>
-    <string name="_bx_forum_cat_Tattoos"><![CDATA[Tattoos]]></string>
-    <string name="_bx_forum_cat_Technology"><![CDATA[Technology]]></string>
-    <string name="_bx_forum_cat_Travel"><![CDATA[Travel]]></string>
-    <string name="_bx_forum_cat_Weddings"><![CDATA[Weddings]]></string>
-    <string name="_bx_forum_cat_Womens_Fashion"><![CDATA[Women's Fashion]]></string>
+    <string name="_bx_forum_cat_General"><![CDATA[General]]></string>
 
+	<string name="_bx_forum_txt_entry_locked"><![CDATA[Locked discussion]]></string>
+	<string name="_bx_forum_txt_entry_sticked"><![CDATA[Sticked discussion]]></string>
     <string name="_bx_forum_txt_sample_single"><![CDATA[discussion]]></string>
     <string name="_bx_forum_draft_saving_error"><![CDATA[Draft saving error!]]></string>
     <string name="_bx_forum_draft_saved_success"><![CDATA[Draft saved.]]></string>
+    <string name="_bx_forum_err_not_found"><![CDATA[Discussion wasn't found.]]></string>
     <string name="_bx_forum_participant_info"><![CDATA[{0} ({1})]]></string>
     <string name="_bx_forum_participant_author"><![CDATA[author]]></string>
     <string name="_bx_forum_participant_last_replier"><![CDATA[last replier]]></string>

+ 38 - 12
modules/boonex/forum/install/sql/enable.sql

@@ -19,10 +19,6 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_forum_rss_num', '10', @iCategId, '_bx_forum_option_rss_num', 'digit', '', '', '', 20);
 
 
--- PAGE: Dashboard
-INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
-('sys_dashboard', 3, @sName, '_bx_forum_page_block_title_forum', 11, 2147483646, 'service', 'a:2:{s:6:"module";s:8:"bx_forum";s:6:"method";s:17:"messages_previews";}', 0, 1, 1, 0);
-
 -- PAGE: create entry
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_forum_create_entry', '_bx_forum_page_title_sys_create_entry', '_bx_forum_page_title_create_entry', @sName, 5, 2147483647, 1, 'create-discussion', 'page.php?i=create-discussion', '', '', '', 0, 1, 0, 'BxForumPageBrowse', 'modules/boonex/forum/classes/BxForumPageBrowse.php');
@@ -168,8 +164,14 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 ('bx_forum_view', @sName, '_bx_forum_menu_set_title_view_entry', 0);
 
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES
-('bx_forum_view', @sName, 'edit-discussion', '_bx_forum_menu_item_title_system_edit_entry', '_bx_forum_menu_item_title_edit_entry', 'page.php?i=edit-discussion&id={content_id}', '', '', 'pencil', '', 2147483647, 1, 0, 1),
-('bx_forum_view', @sName, 'delete-discussion', '_bx_forum_menu_item_title_system_delete_entry', '_bx_forum_menu_item_title_delete_entry', 'page.php?i=delete-discussion&id={content_id}', '', '', 'remove', '', 2147483647, 1, 0, 2);
+('bx_forum_view', @sName, 'stick-discussion', '_bx_forum_menu_item_title_system_stick_entry', '_bx_forum_menu_item_title_stick_entry', 'javascript:void(0);', '{js_object}.updateStatus(this, \'stick\', {content_id});', '', 'thumb-tack', '', 2147483647, 1, 0, 1),
+('bx_forum_view', @sName, 'unstick-discussion', '_bx_forum_menu_item_title_system_unstick_entry', '_bx_forum_menu_item_title_unstick_entry', 'javascript:void(0);', '{js_object}.updateStatus(this, \'unstick\', {content_id});', '', 'thumb-tack', '', 2147483647, 1, 0, 2),
+('bx_forum_view', @sName, 'lock-discussion', '_bx_forum_menu_item_title_system_lock_entry', '_bx_forum_menu_item_title_lock_entry', 'javascript:void(0);', '{js_object}.updateStatus(this, \'lock\', {content_id});', '', 'lock', '', 2147483647, 1, 0, 3),
+('bx_forum_view', @sName, 'unlock-discussion', '_bx_forum_menu_item_title_system_unlock_entry', '_bx_forum_menu_item_title_unlock_entry', 'javascript:void(0);', '{js_object}.updateStatus(this, \'unlock\', {content_id});', '', 'unlock', '', 2147483647, 1, 0, 4),
+('bx_forum_view', @sName, 'hide-discussion', '_bx_forum_menu_item_title_system_hide_entry', '_bx_forum_menu_item_title_hide_entry', 'javascript:void(0);', '{js_object}.updateStatus(this, \'hide\', {content_id});', '', 'eye-slash', '', 2147483647, 1, 0, 5),
+('bx_forum_view', @sName, 'unhide-discussion', '_bx_forum_menu_item_title_system_unhide_entry', '_bx_forum_menu_item_title_unhide_entry', 'javascript:void(0);', '{js_object}.updateStatus(this, \'unhide\', {content_id});', '', 'eye', '', 2147483647, 1, 0, 6),
+('bx_forum_view', @sName, 'edit-discussion', '_bx_forum_menu_item_title_system_edit_entry', '_bx_forum_menu_item_title_edit_entry', 'page.php?i=edit-discussion&id={content_id}', '', '', 'pencil', '', 2147483647, 1, 0, 7),
+('bx_forum_view', @sName, 'delete-discussion', '_bx_forum_menu_item_title_system_delete_entry', '_bx_forum_menu_item_title_delete_entry', 'page.php?i=delete-discussion&id={content_id}', '', '', 'remove', '', 2147483647, 1, 0, 8);
 
 -- MENU: actions menu for my entries
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
@@ -226,20 +228,20 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 
 -- GRIDS: main
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_mode`, `sorting_fields`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
-(@sName, 'Sql', 'SELECT `c`.`id`, `c`.`author`, `c`.`text`, `c`.`added`, `c`.`comments`, `c`.`last_reply_timestamp`, `c`.`last_reply_profile_id`, `cmt`.`cmt_text` FROM `bx_forum_discussions` AS `c` LEFT JOIN `bx_forum_cmts` AS `cmt` ON (`cmt`.`cmt_id` = `c`.`last_reply_comment_id`)', 'bx_forum_discussions', 'id', 'last_reply_timestamp', '', 10, NULL, 'start', '', 'text', 'auto', '', 2147483646, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php');
+(@sName, 'Sql', 'SELECT `bx_forum_discussions`.*, `bx_forum_cmts`.`cmt_text` FROM `bx_forum_discussions` LEFT JOIN `bx_forum_cmts` ON (`bx_forum_cmts`.`cmt_id` = `bx_forum_discussions`.`lr_comment_id`) %s WHERE 1 %s', 'bx_forum_discussions', 'id', 'lr_timestamp', '', 10, NULL, 'start', '', 'text', 'auto', '', 2147483647, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php');
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `params`, `order`) VALUES
 (@sName, 'author', '', '10%', '', 1),
-(@sName, 'last_reply_timestamp', '', '85%', '', 2),
+(@sName, 'lr_timestamp', '', '85%', '', 2),
 (@sName, 'comments', '', '5%', '', 3);
 
 INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `confirm`, `order`) VALUES
 (@sName, 'independent', 'add', '_bx_forum_grid_action_title_add', '', 0, 1);
 
 -- GRIDS: moderation tools
-INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `override_class_name`, `override_class_file`) VALUES
-('bx_forum_administration', 'Sql', 'SELECT * FROM `bx_forum_discussions` WHERE 1 ', 'bx_forum_discussions', 'id', 'added', 'status', '', 20, NULL, 'start', '', 'title,text', '', 'like', '', '', 'BxForumGridAdministration', 'modules/boonex/forum/classes/BxForumGridAdministration.php'),
-('bx_forum_common', 'Sql', 'SELECT * FROM `bx_forum_discussions` WHERE 1 ', 'bx_forum_discussions', 'id', 'added', 'status', '', 20, NULL, 'start', '', 'title,text', '', 'like', '', '', 'BxForumGridCommon', 'modules/boonex/forum/classes/BxForumGridCommon.php');
+INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
+('bx_forum_administration', 'Sql', 'SELECT * FROM `bx_forum_discussions` WHERE 1 ', 'bx_forum_discussions', 'id', 'added', 'status_admin', '', 20, NULL, 'start', '', 'title,text', '', 'like', '', '', 192, 'BxForumGridAdministration', 'modules/boonex/forum/classes/BxForumGridAdministration.php'),
+('bx_forum_common', 'Sql', 'SELECT * FROM `bx_forum_discussions` WHERE 1 ', 'bx_forum_discussions', 'id', 'added', 'status', '', 20, NULL, 'start', '', 'title,text', '', 'like', '', '', 2147483647, 'BxForumGridCommon', 'modules/boonex/forum/classes/BxForumGridCommon.php');
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
 ('bx_forum_administration', 'checkbox', '_sys_select', '2%', 0, '', '', 1),
@@ -282,6 +284,18 @@ INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`,
 (@sName, 'edit any entry', NULL, '_bx_forum_acl_action_edit_any_entry', '', 1, 3);
 SET @iIdActionEntryEditAny = LAST_INSERT_ID();
 
+INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
+(@sName, 'stick any entry', NULL, '_bx_forum_acl_action_stick_any_entry', '', 1, 3);
+SET @iIdActionEntryStickAny = LAST_INSERT_ID();
+
+INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
+(@sName, 'lock any entry', NULL, '_bx_forum_acl_action_lock_any_entry', '', 1, 3);
+SET @iIdActionEntryLockAny = LAST_INSERT_ID();
+
+INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
+(@sName, 'hide any entry', NULL, '_bx_forum_acl_action_hide_any_entry', '', 1, 3);
+SET @iIdActionEntryHideAny = LAST_INSERT_ID();
+
 SET @iUnauthenticated = 1;
 SET @iAccount = 2;
 SET @iStandard = 3;
@@ -318,7 +332,19 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 
 -- edit any entry
 (@iModerator, @iIdActionEntryEditAny),
-(@iAdministrator, @iIdActionEntryEditAny);
+(@iAdministrator, @iIdActionEntryEditAny),
+
+-- stick any entry
+(@iModerator, @iIdActionEntryStickAny),
+(@iAdministrator, @iIdActionEntryStickAny),
+
+-- lock any entry
+(@iModerator, @iIdActionEntryLockAny),
+(@iAdministrator, @iIdActionEntryLockAny),
+
+-- hide any entry
+(@iModerator, @iIdActionEntryHideAny),
+(@iAdministrator, @iIdActionEntryHideAny);
 
 
 -- PRIVACY 

+ 9 - 36
modules/boonex/forum/install/sql/install.sql

@@ -10,16 +10,19 @@ CREATE TABLE IF NOT EXISTS `bx_forum_discussions` (
   `title` varchar(255) NOT NULL,
   `cat` int(11) NOT NULL,
   `text` text NOT NULL,
+  `lr_timestamp` int(11) NOT NULL,
+  `lr_profile_id` int(10) unsigned NOT NULL,
+  `lr_comment_id` int(11) NOT NULL,
   `views` int(11) NOT NULL default '0',
   `comments` int(11) NOT NULL default '0',
   `reports` int(11) NOT NULL default '0',
+  `stick` tinyint(4) NOT NULL DEFAULT '0',
+  `lock` tinyint(4) NOT NULL DEFAULT '0',
   `allow_view_to` int(11) NOT NULL DEFAULT '3',
   `status` enum('active','draft','hidden') NOT NULL DEFAULT 'active',
-  `last_reply_timestamp` int(11) NOT NULL,
-  `last_reply_profile_id` int(10) unsigned NOT NULL,
-  `last_reply_comment_id` int(11) NOT NULL,
+  `status_admin` enum('active','hidden') NOT NULL DEFAULT 'active',
   PRIMARY KEY (`id`),
-  KEY `last_reply_timestamp` (`last_reply_timestamp`)
+  KEY `lr_timestamp` (`lr_timestamp`)
 );
 
 -- TABLE: storages & transcoders
@@ -179,38 +182,8 @@ INSERT INTO `sys_form_pre_lists`(`key`, `title`, `module`, `use_for_sets`) VALUE
 
 INSERT INTO `sys_form_pre_values`(`Key`, `Value`, `Order`, `LKey`, `LKey2`) VALUES
 ('bx_forum_cats', '', 0, '_sys_please_select', ''),
-('bx_forum_cats', '1', 1, '_bx_forum_cat_Animals_Pets', ''),
-('bx_forum_cats', '2', 2, '_bx_forum_cat_Architecture', ''),
-('bx_forum_cats', '3', 3, '_bx_forum_cat_Art', ''),
-('bx_forum_cats', '4', 4, '_bx_forum_cat_Cars_Motorcycles', ''),
-('bx_forum_cats', '5', 5, '_bx_forum_cat_Celebrities', ''),
-('bx_forum_cats', '6', 6, '_bx_forum_cat_Design', ''),
-('bx_forum_cats', '7', 7, '_bx_forum_cat_DIY_Crafts', ''),
-('bx_forum_cats', '8', 8, '_bx_forum_cat_Education', ''),
-('bx_forum_cats', '9', 9, '_bx_forum_cat_Film_Music_Books', ''),
-('bx_forum_cats', '10', 10, '_bx_forum_cat_Food_Drink', ''),
-('bx_forum_cats', '11', 11, '_bx_forum_cat_Gardening', ''),
-('bx_forum_cats', '12', 12, '_bx_forum_cat_Geek', ''),
-('bx_forum_cats', '13', 13, '_bx_forum_cat_Hair_Beauty', ''),
-('bx_forum_cats', '14', 14, '_bx_forum_cat_Health_Fitness', ''),
-('bx_forum_cats', '15', 15, '_bx_forum_cat_History', ''),
-('bx_forum_cats', '16', 16, '_bx_forum_cat_Holidays_Events', ''),
-('bx_forum_cats', '17', 17, '_bx_forum_cat_Home_Decor', ''),
-('bx_forum_cats', '18', 18, '_bx_forum_cat_Humor', ''),
-('bx_forum_cats', '19', 19, '_bx_forum_cat_Illustrations_Posters', ''),
-('bx_forum_cats', '20', 20, '_bx_forum_cat_Kids_Parenting', ''),
-('bx_forum_cats', '21', 21, '_bx_forum_cat_Mens_Fashion', ''),
-('bx_forum_cats', '22', 22, '_bx_forum_cat_Outdoors', ''),
-('bx_forum_cats', '23', 23, '_bx_forum_cat_Photography', ''),
-('bx_forum_cats', '24', 24, '_bx_forum_cat_Products', ''),
-('bx_forum_cats', '25', 25, '_bx_forum_cat_Quotes', ''),
-('bx_forum_cats', '26', 26, '_bx_forum_cat_Science_Nature', ''),
-('bx_forum_cats', '27', 27, '_bx_forum_cat_Sports', ''),
-('bx_forum_cats', '28', 28, '_bx_forum_cat_Tattoos', ''),
-('bx_forum_cats', '29', 29, '_bx_forum_cat_Technology', ''),
-('bx_forum_cats', '30', 30, '_bx_forum_cat_Travel', ''),
-('bx_forum_cats', '31', 31, '_bx_forum_cat_Weddings', ''),
-('bx_forum_cats', '32', 32, '_bx_forum_cat_Womens_Fashion', '');
+('bx_forum_cats', '1', 1, '_bx_forum_cat_General', '');
+
 
 -- STUDIO: page & widget
 INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES

+ 40 - 0
modules/boonex/forum/js/entry.js

@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Forum Forum
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+function BxForumEntry(oOptions) {
+	this._sActionsUrl = oOptions.sActionUrl;
+    this._sObjName = oOptions.sObjName == undefined ? 'oFormEntry' : oOptions.sObjName;
+    this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
+    this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
+}
+
+BxForumEntry.prototype.updateStatus = function(oButton, sAction, iId) {
+	this._performAction(oButton, sAction, iId);
+};
+
+BxForumEntry.prototype._performAction = function(oButton, sAction, iId) {
+    var $this = this;
+    var oDate = new Date();
+
+    var oParams = {
+    	action: sAction,
+    	id: iId,
+    	_t: oDate.getTime()
+    };
+
+    $.get(
+        this._sActionsUrl + 'update_status/',
+        oParams,
+        function(oData){
+        	processJsonData(oData);
+        },
+        'json'
+    );
+};

+ 30 - 10
modules/boonex/forum/js/main.js

@@ -1,9 +1,31 @@
-$(document).ready(function () {
-    var ePreviews = $('.bx-forum-grid-preview');
-    if (!ePreviews.length)
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Forum Forum
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+function BxForumMain(oOptions) {
+	this._sActionsUrl = oOptions.sActionUrl;
+    this._sObjName = oOptions.sObjName == undefined ? 'oFormMain' : oOptions.sObjName;
+    this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
+    this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
+
+	var $this = this;
+	$(document).ready(function () {
+		$this.init();
+	});
+}
+
+BxForumMain.prototype.init = function() {
+	var ePreviews = $('.bx-forum-grid-preview');
+    if(!ePreviews.length)
         return;
 
-    var f = function () {
+    var oFunction = function () {
 
         // calculate width of all table rows, except the one which contains messages preview
         var iInnerWidth = $('.bx-grid-table').parent().innerWidth();
@@ -22,14 +44,12 @@ $(document).ready(function () {
     };
 
     $(window).resize(function() {
-        f();
+    	oFunction();
     });
 
     BxDolGrid.prototype.onDataReloaded = function (isSkipSearchInput) {
-        f();
+    	oFunction();
     };
 
-    f();
-});
-
-
+    oFunction();
+};

+ 1 - 1
modules/boonex/forum/js/manage_tools.js

@@ -2,7 +2,7 @@
  * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  *
- * @defgroup    Posts Posts
+ * @defgroup    Forum Forum
  * @ingroup     TridentModules
  *
  * @{

+ 0 - 5
modules/boonex/forum/template/entry-preview-grid.html

@@ -1,5 +0,0 @@
-<div class="bx-forum-grid-preview">
-    <div class="bx-def-font"><a href="__url__">__text__</a></div>
-    <div class="bx-def-font-middle">__cmt_text__</div>
-    <div class="bx-def-font-small bx-def-font-grayed">__last_reply_time_and_replier__</div>
-</div>

+ 9 - 0
modules/boonex/forum/template/entry-preview.html

@@ -0,0 +1,9 @@
+<div class="bx-forum-grid-preview">
+    <div class="bx-def-font">
+    	<bx_if:show_stick><i class="sys-icon thumb-tack" title="<bx_text_attribute:_bx_forum_txt_entry_sticked />"></i></bx_if:show_stick>
+    	<bx_if:show_lock><i class="sys-icon lock" title="<bx_text_attribute:_bx_forum_txt_entry_locked />"></i></bx_if:show_lock>
+    	<a href="__url__">__title__</a>
+    </div>
+    <div class="bx-def-font-middle">__text__</div>
+    <div class="bx-def-font-small bx-def-font-grayed">__lr_time_and_replier__</div>
+</div>

+ 0 - 16
modules/boonex/forum/template/messages_previews.html

@@ -1,16 +0,0 @@
-
-<bx_repeat:messages>
-
-<div class="bx-forum-preview bx-def-margin-top-auto">
-    <div class="bx-forum-title bx-def-font-h3"><a href="__url__" style="font-weight:__font_weight__;">__text__</a></div>
-    __label__
-
-    <div class="bx-def-unit bx-def-margin-thd-top">
-        <a href="__last_replier_url__" title="__last_replier_title_attr__"><img class="bx-def-icon bx-def-icon-size" src="__last_replier_thumb_url__" /></a><div class="bx-def-unit-info bx-def-thumb-size-max-height bx-def-padding-sec-left bx-def-font-middle">__cmt_text__<div class="bx-def-font-grayed bx-def-font-small">__last_reply_time_and_replier__</div></div>
-    </div>
-</div>
-
-</bx_repeat:messages>
-
-<div class="bx-def-margin-top"><b><a href="__see_all_url__"><bx_text:_bx_forum_see_all /></a></b></div>
-

+ 19 - 33
modules/boonex/russian/data/langs/bx_forum/ru.xml

@@ -40,6 +40,9 @@
 	<string name="_bx_forum_acl_action_delete_entry"><![CDATA[Удалить обсуждение]]></string>
 	<string name="_bx_forum_acl_action_view_entry"><![CDATA[Просмотреть обсуждение]]></string>
 	<string name="_bx_forum_acl_action_edit_any_entry"><![CDATA[Редактировать любое обсуждение]]></string>
+	<string name="_bx_forum_acl_action_stick_any_entry"><![CDATA[Закреплять любое обсуждение]]></string>
+	<string name="_bx_forum_acl_action_lock_any_entry"><![CDATA[Блокировать любое обсуждение]]></string>
+	<string name="_bx_forum_acl_action_hide_any_entry"><![CDATA[Скрывать любое обсуждение]]></string>
 
 	<string name="_bx_forum_page_title_sys_create_entry"><![CDATA[Новое обсуждение]]></string>
 	<string name="_bx_forum_page_title_create_entry"><![CDATA[Новое обсуждение]]></string>
@@ -58,7 +61,6 @@
     <string name="_bx_forum_page_block_title_entry_actions"><![CDATA[Действия]]></string>
     <string name="_bx_forum_page_block_title_entry_comments"><![CDATA[Ответов ({0})]]></string>
     <string name="_bx_forum_page_block_title_entry_participants"><![CDATA[Участники]]></string>
-    <string name="_bx_forum_page_block_title_forum"><![CDATA[Обсуждения]]></string>
     <string name="_bx_forum_page_title_browse"><![CDATA[Форум]]></string>
 	<string name="_bx_forum_page_title_search_results"><![CDATA[Обсуждения, соответствующие "{0}"]]></string>
 	<string name="_bx_forum_page_title_browse_by_author"><![CDATA[Обсуждения {display_name}]]></string>
@@ -119,6 +121,18 @@
     <string name="_bx_forum_menu_item_title_edit_entry"><![CDATA[Редактировать обсуждение]]></string>
     <string name="_bx_forum_menu_item_title_system_delete_entry"><![CDATA[Удалить обсуждение]]></string>
     <string name="_bx_forum_menu_item_title_delete_entry"><![CDATA[Удалить обсуждение]]></string>
+	<string name="_bx_forum_menu_item_title_system_stick_entry"><![CDATA[Закрепить]]></string>
+    <string name="_bx_forum_menu_item_title_stick_entry"><![CDATA[Закрепить]]></string>
+    <string name="_bx_forum_menu_item_title_system_unstick_entry"><![CDATA[Открепить]]></string>
+    <string name="_bx_forum_menu_item_title_unstick_entry"><![CDATA[Открепить]]></string>
+    <string name="_bx_forum_menu_item_title_system_lock_entry"><![CDATA[Заблокировать]]></string>
+    <string name="_bx_forum_menu_item_title_lock_entry"><![CDATA[Заблокировать]]></string>
+    <string name="_bx_forum_menu_item_title_system_unlock_entry"><![CDATA[Разблокировать]]></string>
+    <string name="_bx_forum_menu_item_title_unlock_entry"><![CDATA[Разблокировать]]></string>
+    <string name="_bx_forum_menu_item_title_system_hide_entry"><![CDATA[Скрыть]]></string>
+    <string name="_bx_forum_menu_item_title_hide_entry"><![CDATA[Скрыть]]></string>
+    <string name="_bx_forum_menu_item_title_system_unhide_entry"><![CDATA[Показать]]></string>
+    <string name="_bx_forum_menu_item_title_unhide_entry"><![CDATA[Показать]]></string>
     <string name="_bx_forum_menu_item_title_system_entries_home"><![CDATA[Обсуждения]]></string>
     <string name="_bx_forum_menu_item_title_entries_home"><![CDATA[Обсуждения]]></string>
     <string name="_bx_forum_menu_item_title_system_entries_public"><![CDATA[Новые обсуждения]]></string>
@@ -165,42 +179,14 @@
     <string name="_bx_forum_grid_action_title_add"><![CDATA[Новое сообщение]]></string>
 
     <string name="_bx_forum_pre_lists_cats"><![CDATA[Категории обсуждений]]></string>
-    <string name="_bx_forum_cat_Animals_Pets"><![CDATA[Животные]]></string>
-    <string name="_bx_forum_cat_Architecture"><![CDATA[Архитектура]]></string>
-    <string name="_bx_forum_cat_Art"><![CDATA[Искусство]]></string>
-    <string name="_bx_forum_cat_Cars_Motorcycles"><![CDATA[Авто & мото]]></string>
-    <string name="_bx_forum_cat_Celebrities"><![CDATA[Знаменитости]]></string>
-    <string name="_bx_forum_cat_Design"><![CDATA[Дизайн]]></string>
-    <string name="_bx_forum_cat_DIY_Crafts"><![CDATA[Сделай сам]]></string>
-    <string name="_bx_forum_cat_Education"><![CDATA[Образование]]></string>
-    <string name="_bx_forum_cat_Film_Music_Books"><![CDATA[Фильмы, музыка & книги]]></string>
-    <string name="_bx_forum_cat_Food_Drink"><![CDATA[Еда & напитки]]></string>
-    <string name="_bx_forum_cat_Gardening"><![CDATA[Сад & огород]]></string>
-    <string name="_bx_forum_cat_Geek"><![CDATA[Гик]]></string>
-    <string name="_bx_forum_cat_Hair_Beauty"><![CDATA[Причёски & макияж]]></string>
-    <string name="_bx_forum_cat_Health_Fitness"><![CDATA[Здоровье & фитнесс]]></string>
-    <string name="_bx_forum_cat_History"><![CDATA[История]]></string>
-    <string name="_bx_forum_cat_Holidays_Events"><![CDATA[Праздники & события]]></string>
-    <string name="_bx_forum_cat_Home_Decor"><![CDATA[Интерьер]]></string>
-    <string name="_bx_forum_cat_Humor"><![CDATA[Юмор]]></string>
-    <string name="_bx_forum_cat_Illustrations_Posters"><![CDATA[Иллюстрации & постеры]]></string>
-    <string name="_bx_forum_cat_Kids_Parenting"><![CDATA[Дети & родители]]></string>
-    <string name="_bx_forum_cat_Mens_Fashion"><![CDATA[Мужская мода]]></string>
-    <string name="_bx_forum_cat_Outdoors"><![CDATA[Туризм]]></string>
-    <string name="_bx_forum_cat_Photography"><![CDATA[Фотография]]></string>
-    <string name="_bx_forum_cat_Products"><![CDATA[Продукты]]></string>
-    <string name="_bx_forum_cat_Quotes"><![CDATA[Цитаты]]></string>
-    <string name="_bx_forum_cat_Science_Nature"><![CDATA[Наука & природа]]></string>
-    <string name="_bx_forum_cat_Sports"><![CDATA[Спорт]]></string>
-    <string name="_bx_forum_cat_Tattoos"><![CDATA[Татуеровки]]></string>
-    <string name="_bx_forum_cat_Technology"><![CDATA[Технологии]]></string>
-    <string name="_bx_forum_cat_Travel"><![CDATA[Путешествия]]></string>
-    <string name="_bx_forum_cat_Weddings"><![CDATA[Свадьба]]></string>
-    <string name="_bx_forum_cat_Womens_Fashion"><![CDATA[Женская мода]]></string>
+    <string name="_bx_forum_cat_General"><![CDATA[Общие]]></string>
 
+	<string name="_bx_forum_txt_entry_locked"><![CDATA[Заблокированное обсуждение]]></string>
+	<string name="_bx_forum_txt_entry_sticked"><![CDATA[Закрепленное обсуждение]]></string>
 	<string name="_bx_forum_txt_sample_single"><![CDATA[обсуждение]]></string>
     <string name="_bx_forum_draft_saving_error"><![CDATA[Ошибка сохранения черновика!]]></string>
     <string name="_bx_forum_draft_saved_success"><![CDATA[Черновик сохранён.]]></string>
+    <string name="_bx_forum_err_not_found"><![CDATA[Обсуждение не найдено.]]></string>
     <string name="_bx_forum_participant_info"><![CDATA[{0} ({1})]]></string>
     <string name="_bx_forum_participant_author"><![CDATA[автор]]></string>
     <string name="_bx_forum_participant_last_replier"><![CDATA[последний ответивший]]></string>