vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Usergroup Permissions not working properly (https://vborg.vbsupport.ru/showthread.php?t=232482)

Mythotical 01-07-2010 08:35 PM

Usergroup Permissions not working properly
 
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
PHP Code:

$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
PHP Code:

$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&amp;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)
HTML Code:

<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:
PHP Code:

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:
PHP Code:

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.

PHP Code:

$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&amp;userid=$userid">Add New</a></td></tr>";');


Error:
Code:

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
PHP Code:

$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($vbulletinfetch_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'] ,falsetruetruetruetruefalse);
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.
PHP Code:

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

Quote:

Originally Posted by Steve M (Post 1949934)
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
PHP Code:

$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
PHP Code:

$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&amp;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)
HTML Code:

<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:
Code:

<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.


All times are GMT. The time now is 12:34 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01229 seconds
  • Memory Usage 1,793KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_html_printable
  • (9)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete