Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Settings switch to NO (EDITED)  (Read 3681 times)

lilspen

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 57
Settings switch to NO (EDITED)
« on: January 02, 2008, 06:50:09 am »

I have done some more testing of the Settings that switch to NO or NULL and I think I know what the problem is.

When someone edits their account and a setting isn't there (like edit comments, file upload or site owner) it will revert to NO.

after a bit more screwing around with accounts it seems that if a non-site owner edits a site owners account it won't actually switch that setting to NO but if they go to the user list just after editing the account it will show the delete link (to delete the account) but when it's clicked it won't let them do it.

but when a site owner edits their own account they will lose their "site owner" status.

and if a super editor edits their own account their edit comments/file upload settings will be set to NO.


It's really annoying me. I have checked it over and over. I don't see what the problem is though. (don't know PHP but I get some of it).


||||||||||||||||||||||||||||||
okay. I noticed this problem when I made that little fix for the other settings switching to NO (see [RESOLVED] Approval of comments is not working on snewsMU 1.6.2)

After I made a heap of edits myself (see [PATCH]Admin account settings switch to NO (EDITED)) I found that when an admin that isn't a site owner edits a site owners profile it changes the site_owner field to blank.

I have tried this:
Code: [Select]
   if ($level == '1' || $level == '2' || $level == '3'){
    echo html_input('checkbox', 'edit_comments', 'edcom', 'YES', l('mu_edit_comments'), '', '', '', '', $edit_comments, '', '', '', '', '', '');
    echo html_input('checkbox', 'permit_upload', 'pfiles', 'YES', l('mu_permit_upload'), '', '', '', '', $permit_upload, '', '', '', '', '');
    if (get_identity($_SESSION['id'], 'site_owner') == 'YES' && $level == '1'){
     echo html_input('checkbox', 'site_owner', 'sowner', 'YES', l('mu_site_owner'), '', '', '', '', $site_owner, '', '', '', '', '');
    }
    else {if ($level == '1'){
     echo html_input('hidden', 'site_owner', 'sowner', 'YES', l('mu_site_owner'), '', '', '', '', $site_owner, '', '', '', '', '');
    }
    }
   }
But it doesn't help much at all.
« Last Edit: January 03, 2008, 05:47:29 am by nodnarb »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Settings switch to NO (EDITED)
« Reply #1 on: January 04, 2008, 05:47:09 pm »

I'm in the process of going through some of the permission stuff and found this as well.  I've taken down the link on the download page and will replace it with a patched release as soon as I'm done with patching.
If you don't mind, could you also note the actual changes here (or note them in the revised snewsMU.php file) for those of us who need to patch heavily-modded MU projects fix-by-fix? Thanks in advance.  ;)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Settings switch to NO (EDITED)
« Reply #2 on: January 04, 2008, 06:09:35 pm »

No way! :)
Actually, I'm commenting every change, including the reason for fixing it....with dates too!
Cool... excellente! ;D
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

lilspen

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 57
Re: Settings switch to NO (EDITED)
« Reply #3 on: January 05, 2008, 04:33:20 am »

well, since this concerns this problem...

When you update any account when any account isn't a site owner it inputs NULL instead of "NO".
I know that the problem is with this code:
Code: [Select]
if (get_identity($_GET['id'], 'site_owner') == 'YES'){
  $site_owner = $_POST['site_owner'] == 'on' ? 'YES' : 'NO';
 }
in the
Quote
function processing()
place, under
Quote
case 'profile':

Theres no reason (I don't think) as to why the if statement should be there.
With the if statement removed it will input "NO" instead of NULL. (does that because of the problem I said in my first post).
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Re: Settings switch to NO (EDITED)
« Reply #4 on: January 05, 2008, 01:51:02 pm »

Lats code quoted with $_POST and $_GET used at the same time is plain wrong - it's either POST or GET, but not both at the same time.
Logged

lilspen

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 57
Re: Settings switch to NO (EDITED)
« Reply #5 on: January 05, 2008, 02:31:35 pm »

doesn't the $_GET grab the db details and the $_POST grab the form info?

oh i don't know PHP so i just wanna understand...
why is it wrong? other than the fact that with that IF in place it basically removes the code so site_owner isn't defined...
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Re: Settings switch to NO (EDITED)
« Reply #6 on: January 05, 2008, 04:51:42 pm »

For example, You can send HTTP GET request or You can send HTTP POST request; in one case there will be something that's making sense in $_GET and in another case in $_POST variables. Same variables are accessible from common $_REQUEST array as well, that's right.
But You never can send GET and POST both at the same time. So, whatever logic (if in $_GET is this then on the base of $_POST do this or that) is behind quoted code snippet - it is faulty IMHO.

P.S. And thus of course it is helping to get rid of proper $site_owner value.
« Last Edit: January 05, 2008, 05:07:51 pm by codetwist »
Logged