summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.txt7
-rw-r--r--better_formats.install19
-rw-r--r--better_formats.module31
-rw-r--r--better_formats_settings.admin.inc27
4 files changed, 44 insertions, 40 deletions
diff --git a/README.txt b/README.txt
index 10d2ca0..a317999 100644
--- a/README.txt
+++ b/README.txt
@@ -20,11 +20,12 @@ Installation:
2. Enable the module via the modules page.
Use:
-1. Navigate to Site Configuration > Input formats (/admin/settings/filters)
-2. There you will find 2 tabs where you can change your settings.
+1. Go to user permissions (/admin/user/permissions) and set your permissions.
+2. Navigate to Site Configuration > Input formats (/admin/settings/filters)
+3. There you will find 2 tabs where you can change your settings.
Defaults (/admin/settings/filters/defauts)
Settings (/admin/settings/filters/settings)
-3. If you enable the "Control formats per node type" option. Go to your content
+4. If you enable the "Control formats per node type" option. Go to your content
type admin page to set those settings (example /admin/content/node-type/page).
The settings are under the Input format settings fieldset.
diff --git a/better_formats.install b/better_formats.install
index 50ba685..62fa7a5 100644
--- a/better_formats.install
+++ b/better_formats.install
@@ -59,6 +59,21 @@ function better_formats_install() {
db_query($sql, $rid, 'node', 0, 1, 0);
db_query($sql, $rid, 'comment', 0, 1, 0);
}
+
+ // default perms to be like core defaults
+ $default_perms = ',show format selection,show format tips,collapsible format selection,collapse format fieldset by default';
+ // get current perms
+ $sql = "SELECT * FROM {permission}";
+ $result = db_query($sql);
+ $row_perms = array();
+ while ($row = db_fetch_object($result)) {
+ $role_perms[] = $row;
+ }
+ // add perms to all roles
+ foreach ($role_perms as $perms) {
+ $sql = "UPDATE {permission} SET perm = '%s' WHERE pid = %d";
+ db_query($sql, $perms->perm . $default_perms, $perms->pid);
+ }
}
/**
@@ -66,5 +81,7 @@ function better_formats_install() {
*/
function better_formats_uninstall(){
drupal_uninstall_schema('better_formats');
- // need to delete settings variables from varible table
+ // delete settings variables from varible table
+ $sql = "DELETE FROM {variable} WHERE name LIKE 'better_formats%'";
+ db_query($sql);
}
diff --git a/better_formats.module b/better_formats.module
index 4d4d39d..7e2ce75 100644
--- a/better_formats.module
+++ b/better_formats.module
@@ -15,6 +15,16 @@ function better_formats_help($path, $arg) {
return $output;
}
+
+function better_formats_perm() {
+ return array(
+ 'show format selection',
+ 'show format tips',
+ 'collapse format fieldset by default',
+ 'collapsible format selection',
+ );
+}
+
/**
* Implementation of hook_menu()
* @return array array of menu items
@@ -350,18 +360,19 @@ function better_formats_filter_form($value = FILTER_FORMAT_DEFAULT, $weight = 1,
// else we fall back to the site default format
$default = isset($formats[$value]) ? $formats[$value]->format : filter_resolve_format(FILTER_FORMAT_DEFAULT);
- $hide_selection = variable_get('better_formats_hide_format_selection', FALSE);
- $hide_tips = variable_get('better_formats_hide_format_tips', FALSE);
- $expanded = variable_get('better_formats_default_expanded', FALSE);
- $noncollapse = variable_get('better_formats_noncollapse', FALSE);
- $fieldset_title = variable_get('better_formats_fieldset_title', 'Input format');
+ $show_selection = user_access('show format selection');
+ $show_tips = user_access('show format tips');
- if (count($formats) > 1 && ! $hide_selection) {
+ if (count($formats) > 1 && $show_selection) {
+ $collapsed = user_access('collapse format fieldset by default');
+ $collapsible = user_access('collapsible format selection');
+ $fieldset_title = variable_get('better_formats_fieldset_title', 'Input format');
+
$form = array(
'#type' => 'fieldset',
'#title' => t('@title', array('@title' => $fieldset_title ? $fieldset_title : 'Input format')),
- '#collapsible' => ! $noncollapse,
- '#collapsed' => ! $expanded,
+ '#collapsible' => $collapsible,
+ '#collapsed' => $collapsed,
'#weight' => $weight,
'#element_validate' => array('filter_form_validate'),
);
@@ -379,7 +390,7 @@ function better_formats_filter_form($value = FILTER_FORMAT_DEFAULT, $weight = 1,
'#parents' => $parents,
'#id' => form_clean_id('edit-'. implode('-', $parents_for_id)),
);
- if ( ! $hide_tips) {
+ if ($show_tips) {
$extra = theme('filter_tips_more_info');
$form[$format->format]['#description'] = theme('filter_tips', _filter_tips($format->format, FALSE));
$form[] = array('#value' => $extra);
@@ -393,7 +404,7 @@ function better_formats_filter_form($value = FILTER_FORMAT_DEFAULT, $weight = 1,
'#value' => $format->format,
'#parents' => $parents
);
- if ( ! $hide_tips) {
+ if ($show_tips) {
$extra = theme('filter_tips_more_info');
$tips = _filter_tips($format->format, FALSE);
$form['format']['guidelines'] = array(
diff --git a/better_formats_settings.admin.inc b/better_formats_settings.admin.inc
index 286e3a4..253296f 100644
--- a/better_formats_settings.admin.inc
+++ b/better_formats_settings.admin.inc
@@ -8,36 +8,11 @@ function better_formats_settings_admin_form() {
'#type' => 'fieldset',
'#title' => t('Display'),
);
-
- $form[$key]['better_formats_hide_format_selection'] = array(
- '#type' => 'checkbox',
- '#default_value' => variable_get('better_formats_hide_format_selection', 0),
- '#title' => t('Hide format selection'),
- '#description' => t('Hides the format selection fieldset leaving only the default format tips.'),
- );
- $form[$key]['better_formats_hide_format_tips'] = array(
- '#type' => 'checkbox',
- '#default_value' => variable_get('better_formats_hide_format_tips', 0),
- '#title' => t('Hide format tips'),
- '#description' => t('Hides the format tips leaving only the format selection or nothing if the "Hide format selection" option is checked.'),
- );
- $form[$key]['better_formats_default_expanded'] = array(
- '#type' => 'checkbox',
- '#default_value' => variable_get('better_formats_default_expanded', 0),
- '#title' => t('Expand fieldset by default'),
- '#description' => t('Expands the Input formats fieldset by default.'),
- );
- $form[$key]['better_formats_noncollapse'] = array(
- '#type' => 'checkbox',
- '#default_value' => variable_get('better_formats_noncollapse', 0),
- '#title' => t('Disable fieldset collapse'),
- '#description' => t('Removes the ability for the user to collapse the fieldset.'),
- );
$form[$key]['better_formats_fieldset_title'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('better_formats_fieldset_title', ''),
'#title' => t('Selection title'),
- '#description' => t('Change the format selection fieldset title. Defaults to "Input format"'),
+ '#description' => t('Change the format selection title. Defaults to "Input format"'),
);