Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2010, 08:35 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 01-07-2010, 09:25 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #3  
Old 01-07-2010, 10:38 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 01-07-2010, 11:41 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>";'); 
Reply With Quote
  #5  
Old 01-08-2010, 03:45 AM
MaryTheG(r)eek MaryTheG(r)eek is offline
 
Join Date: Sep 2006
Location: Greece
Posts: 1,340
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Steve M View Post
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
Reply With Quote
  #6  
Old 01-08-2010, 04:35 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #7  
Old 01-08-2010, 02:05 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the other issue? The member blocks? What is the exact issue with that?
Reply With Quote
  #8  
Old 01-08-2010, 02:48 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 01-08-2010, 04:10 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #10  
Old 01-08-2010, 04:56 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:26 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.04420 seconds
  • Memory Usage 2,306KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_html
  • (9)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete