function system_update_7000

Rename blog and forum permissions to be consistent with other content types.

Related topics

File

modules/system/system.install, line 1875

Code

function system_update_7000() {
    $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
    foreach ($result as $role) {
        $renamed_permission = $role->perm;
        $renamed_permission = preg_replace('/(?<=^|,\\ )create\\ blog\\ entries(?=,|$)/', 'create blog content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )edit\\ own\\ blog\\ entries(?=,|$)/', 'edit own blog content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )edit\\ any\\ blog\\ entry(?=,|$)/', 'edit any blog content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )delete\\ own\\ blog\\ entries(?=,|$)/', 'delete own blog content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )delete\\ any\\ blog\\ entry(?=,|$)/', 'delete any blog content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )create\\ forum\\ topics(?=,|$)/', 'create forum content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )delete\\ any\\ forum\\ topic(?=,|$)/', 'delete any forum content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )delete\\ own\\ forum\\ topics(?=,|$)/', 'delete own forum content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )edit\\ any\\ forum\\ topic(?=,|$)/', 'edit any forum content', $renamed_permission);
        $renamed_permission = preg_replace('/(?<=^|,\\ )edit\\ own\\ forum\\ topics(?=,|$)/', 'edit own forum content', $renamed_permission);
        if ($renamed_permission != $role->perm) {
            db_update('permission')->fields(array(
                'perm' => $renamed_permission,
            ))
                ->condition('rid', $role->rid)
                ->execute();
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.