DrupalBin
Submit Code
About
Recent Posts
What is this?
display suite field group
Code
Code
Code
Code
Fix for UC Node Checkout - Base Product Title into Token
Code
Import a content type from a file.
Alteration to Trying to alter contact form to allow pre-selecting of cid
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
test
theme
user
views
more tags
Home
Fix for Fix for Code
View
Fix
July 29, 2010 - 2:32pm — Anonymous
$query
=
db_query
(
"SELECT r.rid, r.name, p.perm FROM {role} r INNER JOIN {permission} p ON r.rid = p.rid"
)
;
while
(
$row
=
db_fetch_object
(
$query
)
)
{
$names
[
$row
-
>
rid
]
=
"'"
.
$row
-
>
name
.
"'"
;
$perms
[
$row
-
>
rid
]
=
explode
(
', '
,
$row
-
>
perm
)
;
}
$create_str
=
'central_user_add_user_roles(array('
;
$create_str
.=
implode
(
', '
,
$names
)
;
$create_str
.=
"));
\n
\n
"
;
foreach
(
$names
as
$rid
=
>
$name
)
{
$role_str
.=
"central_user_add_permissions_to_role(
\n
"
;
$role_str
.=
" aim_central_user_get_role_id($name),
\n
"
;
$role_str
.=
" array(
\n
"
;
array_walk
(
$perms
[
$rid
]
,
create_function
(
'&$a'
,
'$a = "
\'
$a
\'
";'
)
)
;
$role_str
.=
implode
(
",
\n
"
,
$perms
[
$rid
]
)
;
$role_str
.=
"
\n
)
\n
"
;
$role_str
.=
");
\n
\n
"
;
}
return
'<textarea rows="50" cols="90">'
.
$create_str
.
$role_str
.
'</textarea>'
;
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
$query = db_query("SELECT r.rid, r.name, p.perm FROM {role} r INNER JOIN {permission} p ON r.rid = p.rid"); while ($row = db_fetch_object($query)) { $names[$row->rid] = "'" . $row->name . "'"; $perms[$row->rid] = explode(', ', $row->perm); } $create_str = 'central_user_add_user_roles(array('; $create_str .= implode(', ', $names); $create_str .= "));\n\n"; foreach ($names as $rid => $name) { $role_str .= "central_user_add_permissions_to_role(\n"; $role_str .= " aim_central_user_get_role_id($name),\n"; $role_str .= " array(\n"; array_walk($perms[$rid], create_function('&$a', '$a = " \'$a\'";')); $role_str .= implode(",\n", $perms[$rid]); $role_str .= "\n )\n"; $role_str .= ");\n\n"; } return '<textarea rows="50" cols="90">' . $create_str . $role_str . '</textarea>';
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.