DrupalBin
Submit Code
About
Recent Posts
admin settings not saving
9 min 44 sec
ago
Code
52 min 51 sec
ago
Code
1 hour 8 min
ago
css path
2 hours 52 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for user module causes warning while calling user_access()
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
function user_is_queue_member($account) { global $user; /* * if I omit the following check it creates * following error: * ========================================================== * warning: array_fill() [function.array-fill]: Number of elements must be positive in /data/projects/voip_support/trunk/control_interface/includes/database.inc on line 235. * warning: implode() [function.implode]: Bad arguments. in /data/projects/voip_support/trunk/control_interface/includes/database.inc on line 235. * warning: array_keys() [function.array-keys]: The first argument should be an array in /data/projects/voip_support/trunk/control_interface/modules/user/user.module on line 500. * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT p.perm FROM web_role r INNER JOIN web_permission p ON p.rid = r.rid WHERE r.rid IN () in /data/projects/voip_support/trunk/control_interface/modules/user/user.module on line 500. * ========================================================== * The probable reason is $account->role is not assigned when user_access() is called. Note that I called this in hook_user implementation which is called before all the node elements are loaded. */ if(!is_array($account->roles)) { return FALSE; } if($account->uid == 1) { return FALSE; /* forbid the admin user.. */ } if(!user_access("can be queue member", $account)) { return FALSE; } if($account->uid == $user->uid || user_access("administer users", $user)) { return TRUE; } return FALSE; }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.