Skip to content

Commit

Permalink
Ticket #463
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Oct 19, 2016
1 parent b85333e commit 51f6858
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 30 deletions.
11 changes: 11 additions & 0 deletions modules/boonex/forum/classes/BxForumCmts.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public function isPostReplyAllowed($isPerformAction = false)
return parent::isPostReplyAllowed($isPerformAction);
}

public function onPostAfter($iId)
{
$CNF = &$this->_oModule->_oConfig->CNF;

if(!parent::onPostAfter($iId))
return false;

if(getParam($CNF['PARAM_AUTOSUBSCRIBE_REPLIED']) == 'on')
BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION_SUBSCRIBERS'])->actionAdd((int)$this->getId(), (int)$this->_getAuthorId());
}

public function getCommentsBlock($iParentId = 0, $iVParentId = 0, $bInDesignbox = true)
{
$mixedBlock = parent::getCommentsBlock($iParentId, $iVParentId, $bInDesignbox);
Expand Down
7 changes: 7 additions & 0 deletions modules/boonex/forum/classes/BxForumConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function __construct($aModule)
parent::__construct($aModule);

$aMenuItems2Methods = array (
'subscribe-discussion' => 'checkAllowedSubscribe',
'unsubscribe-discussion' => 'checkAllowedUnsubscribe',
'stick-discussion' => 'checkAllowedStickAnyEntry',
'unstick-discussion' => 'checkAllowedUnstickAnyEntry',
'lock-discussion' => 'checkAllowedLockAnyEntry',
Expand Down Expand Up @@ -76,6 +78,8 @@ function __construct($aModule)
'PARAM_CHARS_SUMMARY_PLAIN' => 'bx_forum_plain_summary_chars',
'PARAM_NUM_RSS' => 'bx_forum_rss_num',
'PARAM_SEARCHABLE_FIELDS' => 'bx_forum_searchable_fields',
'PARAM_AUTOSUBSCRIBE_CREATED' => 'bx_forum_autosubscribe_created',
'PARAM_AUTOSUBSCRIBE_REPLIED' => 'bx_forum_autosubscribe_replied',

// objects
'OBJECT_GRID' => 'bx_forum',
Expand Down Expand Up @@ -104,16 +108,19 @@ function __construct($aModule)
'OBJECT_FORM_SEARCH' => 'bx_forum_search',
'OBJECT_FORM_SEARCH_DISPLAY_FULL' => 'bx_forum_search_full',
'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_forum_view', // actions menu on view entry page
'OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE' => 'bx_forum_view_more', // more actions menu on view entry page
'OBJECT_MENU_ACTIONS_MY_ENTRIES' => 'bx_forum_my', // actions menu on my entries page
'OBJECT_MENU_MANAGE_TOOLS' => 'bx_forum_menu_manage_tools', //manage menu in content administration tools
'OBJECT_MENU_SUBMENU' => 'bx_forum_submenu', // main module submenu
'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => '', // view entry submenu
'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'forum', // first item in view entry submenu from main module submenu
'OBJECT_UPLOADERS' => array('sys_simple', 'sys_html5'),
'OBJECT_CONNECTION_SUBSCRIBERS' => 'bx_forum_subscribers',

// menu items which visibility depends on custom visibility checking
'MENU_ITEM_TO_METHOD' => array (
'bx_forum_view' => $aMenuItems2Methods,
'bx_forum_view_more' => $aMenuItems2Methods,
),

// some language keys
Expand Down
13 changes: 13 additions & 0 deletions modules/boonex/forum/classes/BxForumFormsEntryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ public function __construct($oModule)
{
parent::__construct($oModule);
}

public function onDataAddAfter ($iAccountId, $iContentId)
{
$CNF = &$this->_oModule->_oConfig->CNF;

if($s = parent::onDataAddAfter($iAccountId, $iContentId))
return $s;

if(getParam($CNF['PARAM_AUTOSUBSCRIBE_CREATED']) == 'on')
BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION_SUBSCRIBERS'])->actionAdd($iContentId, $this->_iProfileId);

return '';
}
}

/** @} */
53 changes: 49 additions & 4 deletions modules/boonex/forum/classes/BxForumModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,22 @@ public function serviceBrowseSearchResults($sUnitView = false, $bEmptyMessage =
return $this->_serviceBrowseTable(array('type' => $sType, 'where' => $aWhereGroupAnd), false);
}

/**
* Get number of discussions for some profile
* @param $iProfileId - profile to get discussions for, if omitted then currently logged in profile is used
* @return integer
*/
public function serviceGetDiscussionsNum ($iProfileId = 0)
{
if (!$iProfileId)
$iProfileId = bx_get_logged_profile_id();

return $this->_oDb->getEntriesNumByAuthor((int)$iProfileId);
}

/**
* 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
* Get number of unreplied discussions for some profile
* @param $iProfileId - profile to get unreplied discussions for, if omitted then currently logged is profile is used
* @return integer
*/
public function serviceGetUnrepliedDiscussionsNum ($iProfileId = 0)
Expand Down Expand Up @@ -322,9 +335,27 @@ public function checkAllowedSetThumb()
return _t('_sys_txt_access_denied');
}

public function checkAllowedSubscribe(&$aDataEntry, $isPerformAction = false)
{
$CNF = &$this->_oConfig->CNF;

$sMsg = $this->checkAllowedView($aDataEntry);
if($sMsg !== CHECK_ACTION_RESULT_ALLOWED)
return $sMsg;

return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, $CNF['OBJECT_CONNECTION_SUBSCRIBERS'], false, false);
}

public function checkAllowedUnsubscribe(&$aDataEntry, $isPerformAction = false)
{
$CNF = &$this->_oConfig->CNF;

return $this->_checkAllowedConnect ($aDataEntry, $isPerformAction, $CNF['OBJECT_CONNECTION_SUBSCRIBERS'], false, true);
}

public function checkAllowedStickAnyEntry($aDataEntry, $isPerformAction = false)
{
$CNF = $this->_oConfig->CNF;
$CNF = &$this->_oConfig->CNF;

if((int)$aDataEntry[$CNF['FIELD_STICK']] != 0)
return false;
Expand Down Expand Up @@ -374,14 +405,28 @@ public function checkAllowedHideAnyEntry($aDataEntry, $isPerformAction = false)

public function checkAllowedUnhideAnyEntry($aDataEntry, $isPerformAction = false)
{
$CNF = $this->_oConfig->CNF;
$CNF = &$this->_oConfig->CNF;

if($aDataEntry[$CNF['FIELD_STATUS_ADMIN']] != 'hidden')
return false;

return $this->_checkAllowedAction('hide any entry', $aDataEntry, $isPerformAction);
}

protected function _checkAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult)
{
$CNF = &$this->_oConfig->CNF;

if(!$this->_iProfileId)
return _t('_sys_txt_access_denied');

$isConnected = BxDolConnection::getObjectInstance($sObjConnection)->isConnected($this->_iProfileId, $aDataEntry[$CNF['FIELD_ID']], $isMutual);
if($isInvertResult)
$isConnected = !$isConnected;

return $isConnected ? _t('_sys_txt_access_denied') : CHECK_ACTION_RESULT_ALLOWED;
}

/**
* @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
*/
Expand Down
16 changes: 12 additions & 4 deletions modules/boonex/forum/install/langs/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<string name="_bx_forum_option_per_page_profile"><![CDATA[Number of items per page on profile page]]></string>
<string name="_bx_forum_option_rss_num"><![CDATA[Number of items in RSS feed]]></string>
<string name="_bx_forum_option_searchable_fields"><![CDATA[Searchable fields]]></string>
<string name="_bx_forum_option_autosubscribe_created"><![CDATA[Autosubscribe to newly created discussions]]></string>
<string name="_bx_forum_option_autosubscribe_replied"><![CDATA[Autosubscribe to replied discussions]]></string>

<string name="_bx_forum_form_entry"><![CDATA[Forum]]></string>
<string name="_bx_forum_form_entry_display_add"><![CDATA[New discussion]]></string>
Expand Down Expand Up @@ -161,6 +163,12 @@
<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_subscribe"><![CDATA[Subscribe]]></string>
<string name="_bx_forum_menu_item_title_subscribe"><![CDATA[Subscribe]]></string>
<string name="_bx_forum_menu_item_title_system_unsubscribe"><![CDATA[Unsubscribe]]></string>
<string name="_bx_forum_menu_item_title_unsubscribe"><![CDATA[Unsubscribe]]></string>
<string name="_bx_forum_menu_item_title_system_more"><![CDATA[More Actions]]></string>
<string name="_bx_forum_menu_item_title_more"><![CDATA[]]></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>
Expand All @@ -177,6 +185,8 @@
<string name="_bx_forum_menu_item_title_entries_search"><![CDATA[Search]]></string>
<string name="_bx_forum_menu_set_title_view_entry"><![CDATA[Discussion Actions]]></string>
<string name="_bx_forum_menu_title_view_entry"><![CDATA[Discussion Actions]]></string>
<string name="_bx_forum_menu_set_title_view_more"><![CDATA[Discussion More Actions]]></string>
<string name="_bx_forum_menu_title_view_more"><![CDATA[Discussion More Actions]]></string>
<string name="_bx_forum_menu_item_title_system_view_entries_author"><![CDATA[Discussions]]></string>
<string name="_bx_forum_menu_item_title_view_entries_author"><![CDATA[Discussions]]></string>
<string name="_bx_forum_menu_title_entries_my"><![CDATA[My Discussions Action Menu]]></string>
Expand All @@ -189,10 +199,8 @@
<string name="_bx_forum_menu_item_title_admt_discussions"><![CDATA[Discussions - {addon} hidden]]></string>
<string name="_bx_forum_menu_item_title_manage_my"><![CDATA[My Discussions]]></string>
<string name="_bx_forum_menu_item_title_manage_all"><![CDATA[All Discussions]]></string>
<string name="_bx_forum_menu_item_title_system_forum"><![CDATA[Forum]]></string>
<string name="_bx_forum_menu_item_title_forum"><![CDATA[Forum]]></string>
<string name="_bx_forum_menu_item_title_system_unreplied_discussions"><![CDATA[Unreplied discussions number]]></string>
<string name="_bx_forum_menu_item_title_unreplied_discussions"><![CDATA[{addon} unreplied discussions]]></string>
<string name="_bx_forum_menu_item_title_system_discussions"><![CDATA[Discussions number]]></string>
<string name="_bx_forum_menu_item_title_discussions"><![CDATA[{addon} discussions]]></string>
<string name="_bx_forum_lmi_cpt_categories"><![CDATA[Categories]]></string>

<string name="_bx_forum_grid_filter_item_title_adm_select_one_filter1"><![CDATA[All Statuses]]></string>
Expand Down
6 changes: 5 additions & 1 deletion modules/boonex/forum/install/sql/disable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DELETE FROM `sys_pages_blocks` WHERE `module` = @sName OR `object` LIKE 'bx_foru
-- MENU
DELETE FROM `sys_objects_menu` WHERE `module` = @sName;
DELETE FROM `sys_menu_sets` WHERE `module` = @sName;
DELETE FROM `sys_menu_items` WHERE `module` = @sName OR `set_name` IN('bx_forum_view', 'bx_forum_submenu', 'bx_forum_my');
DELETE FROM `sys_menu_items` WHERE `module` = @sName OR `set_name` IN('bx_forum_view', 'bx_forum_view_more', 'bx_forum_submenu', 'bx_forum_my');


-- GRID
Expand All @@ -39,6 +39,10 @@ DELETE FROM `sys_objects_privacy` WHERE `object` IN ('bx_forum_allow_view_to');
DELETE FROM `sys_objects_search` WHERE `ObjectName` IN ('bx_forum', 'bx_forum_cmts');


-- CONNECTIONS
DELETE FROM `sys_objects_connection` WHERE `object` = 'bx_forum_subscribers';


-- METATAGS
DELETE FROM `sys_objects_metatags` WHERE `object` = @sName;

Expand Down
Loading

0 comments on commit 51f6858

Please sign in to comment.