Changeset 9511


Ignore:
Timestamp:
Mar 4, 2011, 9:45:23 AM (9 years ago)
Author:
plg
Message:

smart detection of implicit edition of an existing permission

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/admin_permissions.php

    r9510 r9511  
    8383    'moderated' => $_POST['moderated'],
    8484    );
     85
     86  // does this permission already exist?
     87  //
     88  // a permission is identified by a who+where
     89  $query = '
     90SELECT
     91    id
     92  FROM '.COMMUNITY_PERMISSIONS_TABLE.'
     93  WHERE type = \''.$insert['type'].'\'
     94    AND user_id '.(isset($insert['user_id']) ? '= '.$insert['user_id'] : 'is null').'
     95    AND group_id '.(isset($insert['group_id']) ? '= '.$insert['group_id'] : 'is null').'
     96;';
     97  $result = pwg_query($query);
     98  $row = pwg_db_fetch_assoc($result);
     99  if (isset($row['id']))
     100  {
     101    if (isset($_POST['edit']))
     102    {
     103      check_input_parameter('edit', $_POST, false, PATTERN_ID);
     104     
     105      if ($_POST['edit'] != $row['id'])
     106      {
     107        // we have to delete the edited permission
     108        $query = '
     109DELETE
     110  FROM '.COMMUNITY_PERMISSIONS_TABLE.'
     111  WHERE id = '.$_POST['edit'].'
     112;';
     113        pwg_query($query);
     114      }
     115    }
     116
     117    $_POST['edit'] = $row['id'];
     118  }
    85119
    86120  if (isset($_POST['edit']))
Note: See TracChangeset for help on using the changeset viewer.