Commit 4975a236 authored by dragonwize's avatar dragonwize
Browse files

Added #376207 by dragonwize: Split show format selection permmission.

parent 9de25c78
......@@ -78,13 +78,13 @@ function better_formats_install() {
}
// Set default perms to be like core defaults.
$default_perms = ', show format selection, show format tips, show more format tips link, collapsible format selection, collapse format fieldset by default';
$default_perms = ', show format selection for nodes, show format selection for comments, show format selection for blocks, show format tips, show more format tips link, collapsible format selection, collapse format fieldset by default';
// Get current core perms.
$sql = "SELECT *
FROM {permission}
WHERE rid IN (1,2)";
$result = db_query($sql);
$row_perms = array();
$role_perms = array();
while ($row = db_fetch_object($result)) {
$role_perms[$row->rid] = $row;
}
......@@ -98,7 +98,7 @@ function better_formats_install() {
WHERE pid = %d";
db_query($sql, $perms->perm . $default_perms, $perms->pid);
}
// Clear the cached pages
// Clear the cache.
cache_clear_all();
}
}
......@@ -131,5 +131,30 @@ function better_formats_update_6110() {
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
}
// Split show format selection permission.
// Get permissions by role.
$sql = "SELECT *
FROM {permission}";
$result = db_query($sql);
$row_perms = array();
while ($row = db_fetch_object($result)) {
$role_perms[$row->rid] = $row;
}
if (!empty($role_perms)) {
// Add perms to core roles (anonymous user, authenticated user).
foreach ($role_perms as $perms) {
// Only enable spit permissions if previous was enabled.
$replace = ', show format selection for nodes, show format selection for comments, show format selection for blocks,';
$perms->perm = str_replace(', show format selection,', $replace, $perms->perm);
$sql = "UPDATE {permission}
SET perm = '%s'
WHERE pid = %d";
$result = db_query($sql, $perms->perm, $perms->pid);
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
}
// Clear the cache.
cache_clear_all();
}
return $ret;
}
......@@ -34,7 +34,9 @@ function better_formats_help($path, $arg) {
*/
function better_formats_perm() {
return array(
'show format selection',
'show format selection for nodes',
'show format selection for comments',
'show format selection for blocks',
'show format tips',
'show more format tips link',
'collapse format fieldset by default',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment