Skip to content

Commit

Permalink
Version 2.3.4 released
Browse files Browse the repository at this point in the history
- Fix editors checker
- Fix nested Bb Codes permissions
  • Loading branch information
cclaerhout committed Dec 10, 2013
1 parent f2b4506 commit 3c45300
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 11 deletions.
2 changes: 1 addition & 1 deletion addon-BBM.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<addon addon_id="BBM" title="Bb Codes &amp; Buttons Manager" version_string="2.3.3" version_id="33" url="http://xenforo.com/community/resources/bbcodes-buttons-manager.1731/" install_callback_class="BBM_Installer" install_callback_method="install" uninstall_callback_class="BBM_Installer" uninstall_callback_method="uninstall">
<addon addon_id="BBM" title="Bb Codes &amp; Buttons Manager" version_string="2.3.4" version_id="34" url="http://xenforo.com/community/resources/bbcodes-buttons-manager.1731/" install_callback_class="BBM_Installer" install_callback_method="install" uninstall_callback_class="BBM_Installer" uninstall_callback_method="uninstall">
<admin_navigation>
<navigation navigation_id="bbm_bbcodeManager" parent_navigation_id="sedo_bbm" display_order="100" link="bbm-bbcodes" admin_permission_id="bbm_BbCodesAndButtons" debug_only="0" hide_no_children="0"/>
<navigation navigation_id="bbm_buttonsManager" parent_navigation_id="sedo_bbm" display_order="110" link="bbm-buttons" admin_permission_id="bbm_BbCodesAndButtons" debug_only="0" hide_no_children="0"/>
Expand Down
52 changes: 46 additions & 6 deletions upload/library/BBM/BbCode/Formatter/Base.php
Expand Up @@ -434,18 +434,34 @@ public function TemplateMethodRenderer(array $tag, array $rendererStates, $incre
$rendererStates['isPost'] = ($this->getPostParams() !== NULL) ? true : false;
$rendererStates['canUseBbCode'] = true;
}
elseif($rendererStates['canUseBbCode'] && $this->checkBbCodeParsingPerms($tag, $rendererStates, true) !== true)
{
//For nested BB Codes
$rendererStates['canUseBbCode'] = false;
$parserPermissionsReturn = $this->checkBbCodeParsingPerms($tag, $rendererStates);

return $parserPermissionsReturn;
}

if(!isset($rendererStates['canViewBbCode']))
{
$viewPermissionsReturn = $this->checkBbCodeViewPerms($tag, $rendererStates);

if($viewPermissionsReturn !== true)
{
return $viewPermissionsReturn;
}

$rendererStates['canViewBbCode'] = true;
}
elseif($rendererStates['canViewBbCode'] && $this->checkBbCodeViewPerms($tag, $rendererStates, true) !== true)
{
//For nested BB Codes
$rendererStates['canViewBbCode'] = false;
$viewPermissionsReturn = $this->checkBbCodeViewPerms($tag, $rendererStates);

return $viewPermissionsReturn;
}

$content = $this->renderSubTree($tag['children'], $rendererStates);
$options = array();
Expand Down Expand Up @@ -512,6 +528,14 @@ public function PhpMethodRenderer(array $tag, array $rendererStates, $increment
$rendererStates['isPost'] = ($this->getPostParams() !== NULL) ? true : false;
$rendererStates['canUseBbCode'] = true;
}
elseif($rendererStates['canUseBbCode'] && $this->checkBbCodeParsingPerms($tag, $rendererStates, true) !== true)
{
//For nested BB Codes
$rendererStates['canUseBbCode'] = false;
$parserPermissionsReturn = $this->checkBbCodeParsingPerms($tag, $rendererStates);

return $parserPermissionsReturn;
}

if(!isset($rendererStates['canViewBbCode']))
{
Expand All @@ -524,6 +548,14 @@ public function PhpMethodRenderer(array $tag, array $rendererStates, $increment

$rendererStates['canViewBbCode'] = true;
}
elseif($rendererStates['canViewBbCode'] && $this->checkBbCodeViewPerms($tag, $rendererStates, true) !== true)
{
//For nested BB Codes
$rendererStates['canViewBbCode'] = false;
$viewPermissionsReturn = $this->checkBbCodeViewPerms($tag, $rendererStates);

return $viewPermissionsReturn;
}

$phpcallback_class = $tagInfo['phpcallback_class'];
$phpcallback_method = $tagInfo['phpcallback_method'];
Expand All @@ -532,7 +564,6 @@ public function PhpMethodRenderer(array $tag, array $rendererStates, $increment
return call_user_func_array(array($phpcallback_class, $phpcallback_method), array($tag, $rendererStates, &$this));
}


/****
* Current tag datas (easy access in this class or in callbacks to tag datas)
***/
Expand Down Expand Up @@ -838,7 +869,7 @@ public function getAttachmentParams($id, array $validExtensions = null, array $f
/****
* PERMISSIONS TOOLS
***/
public function checkBbCodeParsingPerms(array $tag, array $rendererStates)
public function checkBbCodeParsingPerms(array $tag, array $rendererStates, $preventLoop = false)
{
if( !isset($this->_tags[$tag['tag']]['parser_perms']) || !isset($this->_tags[$tag['tag']]['parser_perms']['parser_has_usr']) )
{
Expand Down Expand Up @@ -877,7 +908,13 @@ public function checkBbCodeParsingPerms(array $tag, array $rendererStates)
}
}
}

if($preventLoop == true)
{
return false;
}

$rendererStates['canUseBbCode'] = false; //Default: if is not a post, no way to get this value anyway
$output = '';

if($perms['parser_return'] == 'content')
Expand All @@ -891,22 +928,20 @@ public function checkBbCodeParsingPerms(array $tag, array $rendererStates)
elseif($perms['parser_return'] == 'callback')
{
$rendererStates['isPost'] = ($postParams !== NULL) ? true : false;
$rendererStates['canUseBbCode'] = false; //Default: if is not a post, no way to get this value anyway
return $this->PhpMethodRenderer($tag, $rendererStates, false);

}
elseif($perms['parser_return'] == 'template')
{
$rendererStates['isPost'] = ($postParams !== NULL) ? true : false;
$rendererStates['canUseBbCode'] = false;
return $this->TemplateMethodRenderer($tag, $rendererStates, false);
}

return $output;
}


public function checkBbCodeViewPerms(array $tag, array $rendererStates)
public function checkBbCodeViewPerms(array $tag, array $rendererStates, $preventLoop = false)
{
if( !isset($this->_tags[$tag['tag']]['view_perms']) )
{
Expand Down Expand Up @@ -938,6 +973,11 @@ public function checkBbCodeViewPerms(array $tag, array $rendererStates)
}
}

if($preventLoop == true)
{
return false;
}

$rendererStates['canViewBbCode'] = false;

$output = '';
Expand Down
9 changes: 5 additions & 4 deletions upload/library/BBM/Helper/Editors.php
Expand Up @@ -5,13 +5,14 @@ class BBM_Helper_Editors
public static function getCompatibility()
{
$redactorSupport = (XenForo_Application::get('options')->get('currentVersionId') >= 1020031);
$mceSupport = true;
$mceSupport = !$redactorSupport;

if (method_exists('Sedo_TinyQuattro_Helper_Quattro', 'isEnabled') && $redactorSupport)
if (method_exists('Sedo_TinyQuattro_Helper_Quattro', 'isEnabled'))
{
$mceSupport = Sedo_TinyQuattro_Helper_Quattro::isEnabled();
$activeAddons = XenForo_Application::get('addOns');
$mceSupport = (!empty($activeAddons['sedo_tinymce_quattro'])) ? true : false;
}

return array($mceSupport, $redactorSupport);
}
}

0 comments on commit 3c45300

Please sign in to comment.