Easy fix: no "admin phpfreechat" permission
| Project: | phpfreechat |
| Version: | 5.x-1.3 |
| Component: | Code |
| Category: | feature request |
| Priority: | minor |
| Assigned: | permutations |
| Status: | needs review |
Jump to:
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
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
thanks to bibo
#3
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
#5