Skip to content
Snippets Groups Projects
Commit 84dc08fb authored by Chris Burschka's avatar Chris Burschka
Browse files

#1917818: 2/3 Convert xbbcode format to new configuration system.

parent 124c3f4e
Branches
No related tags found
No related merge requests found
format: xbbcode
name: 'BBCode'
status: '1'
weight: '-1'
roles:
- anonymous
- authenticated
cache: '1'
filters:
filter_html_escape:
module: filter
status: '1'
xbbcode:
module: xbbcode
status: '1'
filter_url:
module: filter
status: '1'
filter_autop:
module: filter
status: '1'
filter_htmlcorrector:
module: filter
status: '1'
langcode: und
......@@ -62,7 +62,7 @@ function xbbcode_schema() {
'length' => 255,
'not null' => TRUE,
'default' => 'GLOBAL',
'description' => 'Foreign key: The {filter_format}.format to which the handler settings belong. GLOBAL for the global settings.',
'description' => 'Foreign key: The format to which the handler settings belong. GLOBAL for the global settings.',
),
// Options
'module' => array(
......@@ -85,47 +85,3 @@ function xbbcode_schema() {
return $schema;
}
/**
* Implements hook_enable().
*/
function xbbcode_enable() {
// Check if a format with a different internal name is already called BBCode.
$bbcode_exists = db_query_range('SELECT 1 FROM {filter_format} WHERE name = :name AND format != :format', 0, 1, array(':name' => 'BBCode', ':format' => 'xbbcode'))->fetchField();
$format = (object) array(
'format' => 'xbbcode',
'name' => $bbcode_exists ? 'Extensible BBCode' : 'BBCode',
'weight' => -10,
'filters' => array(
'filter_html_escape' => array(
'weight' => 0,
'status' => 1,
),
'xbbcode' => array(
'weight' => 1,
'status' => 1,
),
'filter_autop' => array(
'weight' => 2,
'status' => 1,
),
),
);
filter_format_save($format);
$permission = filter_permission_name($format);
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array($permission));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array($permission));
drupal_set_message(t('A <a href="@url">BBCode</a> text format has been created. All users have access to it.', array('@url' => url('admin/config/content/formats/' . $format->format))));
}
/**
* Implements hook_disable().
*/
function xbbcode_disable() {
$bbcode = filter_format_load('xbbcode');
if ($bbcode) {
filter_format_disable($bbcode);
drupal_set_message(t('The <a href="@url">BBCode</a> text format has been disabled.', array('@url' => url('admin/config/content/formats/' . $bbcode->format))), 'warning');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment