View Full Version : Usergroup Permissions not working properly
Mythotical
01-07-2010, 08:35 PM
I have usergroup perms setup to allow each person of the usergroup to:
View Quote
Add Quote
Delete Own Quotes
Delete Others Quote
For the life of me the vars I use won't work.
So here it is.
Plugin: global_start - Usergroup Permissions
$canaddquote = $permissions['bfc_quote'] & $vbulletin->bf_ugp['bfc_quote']['canaddquote'];
$candeleteown = $permissions['bfc_quote'] & $vbulletin->bf_ugp_bfc_quote['candeleteown'];
$candeleteothers = $permissions['bfc_quote'] & $vbulletin->bf_ugp_bfc_quote['candeleteothers'];
$canviewquote = $permissions['bfc_quote'] & $vbulletin->bf_ugp_bfc_quote['canviewquote'];
Next plugin: usercp_complete - Template Edit
$find = '$template_hook[usercp_navbar_bottom]';
$usersid = $vbulletin->userinfo['userid'];
$replace = '<if condition=\"$canaddquote\"><tr><td class=\"thead\">Quotes</td></tr><tr><td class=\"alt2\" nowrap=\"nowrap\"><a class=\"smallfont\" href=\"quote.php?$session[sessionurl]do=addquote&userid=$usersid\">Add New</a></td></tr></if>';
$vbulletin->templatecache['USERCP_SHELL'] = str_replace($find, $replace . $find, $vbulletin->templatecache['USERCP_SHELL']);
Next is template: memberinfo_block_bfc_quote (part of MEMBERINFO templates)
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" width="25%">Quoted Who</td>
<td class="thead" width="<if condition="$candeleteown OR $candeleteothers">65%<else />75%</if>">Quote</td>
<if condition="$candeleteown OR $candeleteothers">
<td class="thead" width="10%">Options</td>
</if>
</tr>
<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[bfc_quote]
</ul>
</div>
</table>
Now anytime I try to use the variables nothing happens and the if condition's I'm sure are correct.
So any help much appreciated. This is the last step then I can update the mod on here.
Thanks
Steve
Lynne
01-07-2010, 09:25 PM
Two things, if you want to use a template hook, you eval it this way - you don't use str_replace:
eval('$template_hook[usercp_navbar_bottom] .= "Your HTML here";');Second thing, I am pretty sure you will need to take the <if> out of the html you want to add in there because when that is evaled, the if will not be eval. Use the if as the condition to do the eval:
if($canaddquote)
{
eval('$template_hook[usercp_navbar_bottom] .= "Your HTML here";');
}
It's not clear to me how memberinfo_block_bfc_quote is supposed to tie in here (there is no mention of $block_data[bfc_quote] in your code).
Mythotical
01-07-2010, 10:38 PM
Ok I did it the way you suggested and I get an error. Honestly I made that back before I knew how to use template hook's.
$userid = $vbulletin->userinfo['userid'];
if($canaddquote)
{
eval('$template_hook[usercp_navbar_bottom] .= "<tr><td class="thead">Quotes</td></tr><tr><td class="alt2" nowrap="nowrap"><a class="smallfont" href="quote.php?$session[sessionurl]do=addquote&userid=$userid">Add New</a></td></tr>";');
}
Error:
Parse error: syntax error, unexpected T_STRING in /usercp.php(949) : eval()'d code(4) : eval()'d code on line 1
I tried a few things to change it around but it still wouldn't go away.
Now memberinfo_block_bfc_quote is pulled in another plugin which I will show below.
member_build_blocks_start - BFC-Quote Profile Block
$blocklist = array_merge($blocklist, array(
'mybfc_quote' => array(
'class' => 'BFC_Quote',
'title' => 'Quotes',
'hook_location' => 'profile_left_last'
)
));
class vB_ProfileBlock_BFC_Quote extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_bfc_quote';
function confirm_empty_wrap()
{
return false;
}
function confirm_display()
{
return ($this->block_data['bfc_quote'] != '');
}
function prepare_output($id = '', $options = array())
{
global $vbulletin, $db, $prepared;
$quote_sql = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "bfc_quotes WHERE username = '".$prepared['username']."' ");
require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
while($quotes = $db->fetch_array($quote_sql))
{
$id = $quotes['id'];
$uname = $quotes['username'];
$original = $quotes['original'];
$quote_text = $parser->do_parse($quotes['quote'] ,false, true, true, true, true, false);
eval('$quote .= "' . fetch_template('bfc_quote_memberbit') . '";');
}
if (empty($quote))
{
$show = 0;
$this->block_data['bfc_quote'] = 'This user has no submitted quotes.';
}
else
{
$show = 1;
$this->block_data['bfc_quote'] = $quote;
}
}
}
If we can figure out the first part of this post then I can probably just use PHP if condition instead of the html if condition to show the delete link.
Lynne
01-07-2010, 11:41 PM
You forgot to escape your quotes in the template_hook.
eval('$template_hook[forumdisplay_notice] .= "<table><tr><td>Your HTML here - remember if you have link you need to escape it <a href=\"yourlink.php\">Your Link</a></td></tr></table>";');
MaryTheG(r)eek
01-08-2010, 03:45 AM
I have usergroup perms setup to allow each person of the usergroup to:
View Quote
Add Quote
Delete Own Quotes
Delete Others Quote
For the life of me the vars I use won't work.
So here it is.
Plugin: global_start - Usergroup Permissions
$canaddquote = $permissions['bfc_quote'] & $vbulletin->bf_ugp['bfc_quote']['canaddquote'];
$candeleteown = $permissions['bfc_quote'] & $vbulletin->bf_ugp_bfc_quote['candeleteown'];
$candeleteothers = $permissions['bfc_quote'] & $vbulletin->bf_ugp_bfc_quote['candeleteothers'];
$canviewquote = $permissions['bfc_quote'] & $vbulletin->bf_ugp_bfc_quote['canviewquote'];
Next plugin: usercp_complete - Template Edit
$find = '$template_hook[usercp_navbar_bottom]';
$usersid = $vbulletin->userinfo['userid'];
$replace = '<if condition=\"$canaddquote\"><tr><td class=\"thead\">Quotes</td></tr><tr><td class=\"alt2\" nowrap=\"nowrap\"><a class=\"smallfont\" href=\"quote.php?$session[sessionurl]do=addquote&userid=$usersid\">Add New</a></td></tr></if>';
$vbulletin->templatecache['USERCP_SHELL'] = str_replace($find, $replace . $find, $vbulletin->templatecache['USERCP_SHELL']);
Next is template: memberinfo_block_bfc_quote (part of MEMBERINFO templates)
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" width="25%">Quoted Who</td>
<td class="thead" width="<if condition="$candeleteown OR $candeleteothers">65%<else />75%</if>">Quote</td>
<if condition="$candeleteown OR $candeleteothers">
<td class="thead" width="10%">Options</td>
</if>
</tr>
<div class="alt1 block_row">
<ul class="list_no_decoration">
$block_data[bfc_quote]
</ul>
</div>
</table>
Now anytime I try to use the variables nothing happens and the if condition's I'm sure are correct.
So any help much appreciated. This is the last step then I can update the mod on here.
Thanks
Steve
Forget the old "<if, <else /> </if>". Now the correct are:
<vb:if condition.......>
<vb:else />
......
</vb:if>
Maria
Mythotical
01-08-2010, 04:35 AM
Maria, this is vB3 not vB4 LOL.
Lynne, yeah forgetting that always happens to me. Its fixed. Now to figure out the other issue. I can't use PHP with those as they only apply to a minor part of the template. Any suggestions for those?
Lynne
01-08-2010, 02:05 PM
What is the other issue? The member blocks? What is the exact issue with that?
Mythotical
01-08-2010, 02:48 PM
Yeah the member_block_bfc_quote template in my first post, the usergroup variables are not working. I can still see the delete option even though I have that turned off.
Lynne
01-08-2010, 04:10 PM
You are defining the permissions all in global_start. Have you tried putting that code at the beginning of your memberinfo_block plugin and seeing if it works? Or tried spitting out the variables instead of using them in the condition?
Mythotical
01-08-2010, 04:56 PM
I'm idiot Lynne, I didn't have the if condition in my other template as well that displays the delete link. Fixed and working, thanks for all the help.
Lynne
01-08-2010, 05:43 PM
Glad you got it working.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.