Ignore:
Timestamp:
Mar 19, 2010, 11:25:39 PM (14 years ago)
Author:
plg
Message:

bug 1328: backport the pwg_token on trunk

bug 1329: backport the check_input_parameter on trunk

feature 1026: add pwg_token feature for edit/delete comment. Heavy refactoring
on this feature to make the code simpler and easier to maintain (I hope).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_user.inc.php

    r5123 r5195  
    12471247
    12481248/*
    1249  * Return if current user can edit/delete a comment
    1250  * @param action edit/delete
     1249 * Return if current user can edit/delete/validate a comment
     1250 * @param action edit/delete/validate
    12511251 * @return bool
    12521252 */
    12531253function can_manage_comment($action, $comment_author_id)
    12541254{
    1255   if (!in_array($action, array('delete','edit'))) {
     1255  global $user, $conf;
     1256 
     1257  if (is_a_guest())
     1258  {
    12561259    return false;
    12571260  }
    1258   return (is_admin() ||
    1259           (($GLOBALS['user']['id'] == $comment_author_id)
    1260            && !is_a_guest()
    1261            && $GLOBALS['conf'][sprintf('user_can_%s_comment', $action)]));
     1261 
     1262  if (!in_array($action, array('delete','edit', 'validate')))
     1263  {
     1264    return false;
     1265  }
     1266
     1267  if (is_admin())
     1268  {
     1269    return true;
     1270  }
     1271
     1272  if ('edit' == $action and $conf['user_can_edit_comment'])
     1273  {
     1274    if ($comment_author_id == $user['id']) {
     1275      return true;
     1276    }
     1277  }
     1278
     1279  if ('delete' == $action and $conf['user_can_delete_comment'])
     1280  {
     1281    if ($comment_author_id == $user['id']) {
     1282      return true;
     1283    }
     1284  }
     1285
     1286  return false;
    12621287}
    12631288
Note: See TracChangeset for help on using the changeset viewer.