function content_theme_update_6102 in Content Theme 6
Same name and namespace in other branches
- 7.2 content_theme.install \content_theme_update_6102()
- 7 content_theme.install \content_theme_update_6102()
Implementation of hook_update_N().
Updates content theme permissions.
File
- ./
content_theme.install, line 119 - Install, update and uninstall functions for the content_theme module.
Code
function content_theme_update_6102() {
$ret = array();
$result = db_query('SELECT p.rid, r.name, p.perm FROM {permission} p LEFT JOIN {role} r ON r.rid = p.rid');
while ($row = db_fetch_object($result)) {
$perms = array_flip(explode(', ', $row->perm));
if (isset($perms['create content theme'])) {
unset($perms['create content theme']);
$perms = array_flip($perms);
foreach (node_get_types('names') as $type => $name) {
$perms[] = "select {$type} content editing theme";
$perms[] = "select {$type} content viewing theme";
}
db_query('UPDATE {permission} SET perm = "%s" WHERE rid = %d', implode(', ', $perms), $row->rid);
$ret[] = array(
'success' => TRUE,
'query' => t('Updated content theme permissions of @role', array(
'@role' => $row->name,
)),
);
}
}
cache_clear_all();
return $ret;
}