Easy fix: no "admin phpfreechat" permission

bibo - May 31, 2008 - 19:57
Project:phpfreechat
Version:5.x-1.3
Component:Code
Category:feature request
Priority:minor
Assigned:permutations
Status:needs review
Description

With the current code only uid 1 (first user) can access the module settings at "www.mysite.com/settings/phpfreechat".

'access' => user_access('admin phpfreechat'); is set in hook menu twice:

/**
* Implementation of hook_menu().
*/
function phpfreechat_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'phpfreechat/nuke',
      'title' => t('Clear chats!'),
      'callback' => 'phpfreechat_nuke',
      'callback arguments' => array(arg(2)),
      'access' => user_access('admin phpfreechat'),
      'type' => MENU_CALLBACK);
    $items[] = array(
      'path' => 'admin/settings/phpfreechat',
      'title' => t('phpFreeChat'),
      'description' => t('Settings to configure phpFreeChat.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array('phpfreechat_settings'),
      'access' => user_access('admin phpfreechat'),
      'type' => MENU_NORMAL_ITEM);
  }
  return $items;
}

but there is no such item as 'admin phpfreechat' in the access-array of hook_perm():

/**
* Implementation of hook_perm().
*/
function phpfreechat_perm() {
  return array('talk on chat channels', 'create nodes with chatrooms', 'moderate chat channels');
}

So, please fix it by adding "admin phpfreechat" added to the array, like this:

return array('talk on chat channels', 'create nodes with chatrooms', 'admin phpfreechat');

After this possible "admin"-users that are not uid 1 can access the settings.

Im not making a patch for this, but I have to wonder how this can go unnoticed in such a good module. I'm using the http://permutations.com/drupal/phpfreechat.php - version which I understand is soon going to be fused with the official module.. but this bug exists in both current versions.

#1

bibo - June 1, 2008 - 07:19

Wow, I managed to fail on that one-line-fix. The correct line would be:

return array('talk on chat channels', 'create nodes with chatrooms', 'moderate chat channels', 'admin phpfreechat');

#2

coming - June 11, 2008 - 22:17

thanks to bibo

#3

permutations - December 1, 2008 - 04:12

Thanks. I just uploaded the latest version of the code to the Drupal site as release version 1.2. I'll take a look at this and fold it in later in the week.

#4

permutations - December 1, 2008 - 05:04
Version:5.x-1.0-rc4» 5.x-1.2
Assigned to:Anonymous» permutations

#5

permutations - January 23, 2009 - 16:37
Version:5.x-1.2» 5.x-1.3
Category:task» feature request
Priority:critical» minor
 
 

Drupal is a registered trademark of Dries Buytaert.