d3f822f76b71b3b45eb5c3954d4345234a8c89fc
6 * Installs the better_formats module.
8 * Creates a database for use of multi-layered default formats and sets
14 * Implementation of hook_schema().
16 function better_formats_schema() {
17 $schema['better_formats_defaults'] = array(
36 'type_weight' => array(
51 'primary key' => array('rid', 'type'),
58 * Implementation of hook_install().
60 function better_formats_install() {
62 drupal_install_schema('better_formats');
64 // Increase module weight to prevent compatibility issues.
65 $sql = "UPDATE {system}
67 WHERE name = 'better_formats'";
70 // Insert format defaults.
71 $roles = user_roles();
72 $sql = "INSERT INTO {better_formats_defaults}
73 VALUES (%d, '%s', %d, %d, %d)";
74 foreach ($roles as
$rid => $role) {
75 db_query($sql, $rid, 'node', 0, 1, 0);
76 db_query($sql, $rid, 'comment', 0, 1, 0);
79 // Set default perms to be like core defaults.
80 $default_perms = ', show format selection, show format tips, show more format tips link, collapsible format selection, collapse format fieldset by default';
81 // Get current core perms.
85 $result = db_query($sql);
87 while ($row = db_fetch_object($result)) {
90 // Add perms to core roles (anonymous user, authenticated user).
91 foreach ($role_perms as
$perms) {
92 $sql = "UPDATE {permission}
95 db_query($sql, $perms->perm .
$default_perms, $perms->pid
);
98 // Clear the cached pages
103 * Implementation of hook_uninstall().
105 function better_formats_uninstall() {
107 drupal_uninstall_schema('better_formats');
109 // Delete settings from varible table.
110 $sql = "DELETE FROM {variable}
111 WHERE name LIKE 'better_formats%'";