Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 03-15-2005, 02:41 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What the code should do is:
If they are NOT original_poster OR are NOT a_moderator: Error message
(that's simplified cos i left out the check to make sure they have permission to edit their own posts)
Reply With Quote
  #12  
Old 03-15-2005, 02:42 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Let's do this again
PHP Code:
if (!$allow_edit and !$allow_edit2
is wrong, should be:
PHP Code:
if (!($allow_edit and $allow_edit2)) 
What you want is that both conditions are true, must be the poster and must have permissions to edit. If this combination is not true (as opposed to the 2 seperate conditions being not true) then you want an error.
Reply With Quote
  #13  
Old 03-15-2005, 02:50 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

that didn't work so let's simplify the original code
PHP Code:
if (($postinfo['userid'] != $bbuserinfo[userid] AND !$grps_permissions['groupspostedit']) OR (!grps_permissions['groupsmoderater']) 
simplified that would be

PHP Code:
if ($clause_one OR $clause_two
so basically i want if either of clause_one or clause_two = true then let the person edit the post, else show a no permission screen.
Reply With Quote
  #14  
Old 03-15-2005, 02:51 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Now let's add the moderator part. Let's simplify by making the above into 1 condition, so:
PHP Code:
if ( !(canedit) ) {error
Now let's add the moderator with an OR statement:
PHP Code:
if ( !(canedit) OR !(moderator) ) {error
Possible combinations:
1. Can NOT edit, is NOT moderator, this will give:
PHP Code:
if ( TRUE OR TRUE) {error
Error is shown, this is correct.

2. Can edit, is NOT moderator, this will give:
PHP Code:
if ( FALSE OR TRUE) {error
Since you are using an OR statement only 1 of the conditions need to be TRUE. This is the case, so an error. This is not what you want.

3. Can NOT edit, is moderator, this will give:
PHP Code:
if ( TRUE OR FALSE) {error
Since you are using an OR statement only 1 of the conditions need to be TRUE. This is the case, so an error. This is not what you want.

Now let's see the same with an AND:
PHP Code:
if ( !(canedit) AND !(moderator) ) {error

1. Can NOT edit, is NOT moderator, this will give:
PHP Code:
if ( TRUE AND TRUE) {error
Error is shown, this is correct.

2. Can edit, is NOT moderator, this will give:
PHP Code:
if ( FALSE AND TRUE) {error
Since you are using an AND statement, both of the conditions need to be TRUE. This is NOT the case, so NO error. This is what you want.

3. Can NOT edit, is moderator, this will give:
PHP Code:
if ( TRUE AND FALSE) {error
Since you are using an AND statement, both of the conditions need to be TRUE. This is NOT the case, so NO error. This is what you want.

Quote:
Originally Posted by sabret00the
so basically i want if either of clause_one or clause_two = true then let the person edit the post, else show a no permission screen.
This is not what you are doing: You are showing an error if either of them is true
Reply With Quote
  #15  
Old 03-15-2005, 02:59 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok so how do i get it to show

PHP Code:
if ((canedit) AND !(moderator)) {no_error
then have
PHP Code:
if (!(canedit) AND (moderator)) {no_error
but if
PHP Code:
if (!(canedit) OR !(moderator)) {error
Reply With Quote
  #16  
Old 03-15-2005, 03:18 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lol now you are confusing me.

What you will want is:
PHP Code:
if (!(canedit) AND !(moderator)) {error
Or you can turn the whole game upside down:
PHP Code:
if ((canedit) OR (moderator)) {DO EDIT
Reply With Quote
  #17  
Old 03-15-2005, 03:35 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Talk about over-thinking things

PHP Code:
if ((($postinfo['userid'] != $bbuserinfo[userid]) AND !$grps_permissions['groupspostedit']) AND !$grps_permissions['groupsmoderater']) 

    
print_no_permission(); 

(((user does not equal poster) AND not in allowed to edit group) AND is not moderator)
Reply With Quote
  #18  
Old 03-15-2005, 03:59 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jolten
Talk about over-thinking things

PHP Code:
if ((($postinfo['userid'] != $bbuserinfo[userid]) AND !$grps_permissions['groupspostedit']) AND !$grps_permissions['groupsmoderater']) 

    
print_no_permission(); 

(((user does not equal poster) AND not in allowed to edit group) AND is not moderator)
I gree, but he just didn't want to get it
Reply With Quote
  #19  
Old 03-15-2005, 06:08 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

win for the overthinking your code never worked

but

PHP Code:
if (!$grps_permissions['groupsmoderater'])
{
    
//they'll only get in here if they're not a mod
    
if ($postinfo['userid'] != $bbuserinfo[userid] AND !$grps_permissions['groupspostedit'])
    {
        
print_no_permission();
    }

is the working code
Reply With Quote
  #20  
Old 03-15-2005, 06:58 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So you give up? I am sure one of my codes worked
Reply With Quote
Reply


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 06:02 AM.


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.04335 seconds
  • Memory Usage 2,294KB
  • 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
  • (21)bbcode_php
  • (2)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
  • (2)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