pathfilter.install in Path Filter 6.2
Same filename and directory in other branches
Provides install and uninstall functions for pathfilter.
Credits: @author Tom Kirkpatrick (drupal.org user "mrfelton"), www.kirkdesigns.co.uk
File
pathfilter.installView source
<?php
/**
* @file
* Provides install and uninstall functions for pathfilter.
*
* Credits:
* @author Tom Kirkpatrick (drupal.org user "mrfelton"), www.kirkdesigns.co.uk
*/
/**
* Implementation of hook_install()
*/
function pathfilter_install() {
$allowed_protocols = _pathfilter_allowed_protocol_helper();
variable_set('filter_allowed_protocols', $allowed_protocols);
}
/**
* Implementation of hook_uninstall()
*/
function pathfilter_uninstall() {
// Delete all pathfilter variables
db_query("DELETE FROM {variable} WHERE name like 'pathfilter_%%'");
// Disable pathfilter from all formats
db_query("DELETE FROM {filters} WHERE module = '%s'", 'pathfilter');
// Remove internal and files from allowed protocols.
$allowed_protocols = array_flip(_pathfilter_allowed_protocol_helper());
unset($allowed_protocols['internal']);
unset($allowed_protocols['files']);
variable_set('filter_allowed_protocols', array_flip($allowed_protocols));
cache_clear_all('variables', 'cache');
watchdog('pathfilter', 'Path filter module removed');
}
/**
* Fix absolute/relative setting isn't input format-specific
*/
function pathfilter_update_6101() {
$ret = array();
// If old variable is different to default
// for each input format set new variable only if pathfilter is enabled
if (variable_get('pathfilter_link_type', 'absolute') != 'absolute') {
foreach (filter_formats() as $format) {
$filters = filter_list_format($format->format);
if (isset($filters['pathfilter/0'])) {
variable_set('pathfilter_link_absolute_' . $format->format, 0);
}
}
}
variable_del('pathfilter_link_type');
return $ret;
}
/**
* Add internal and files to allowed protocol variable.
*/
function pathfilter_update_6200() {
$ret = array();
$allowed_protocols = _pathfilter_allowed_protocol_helper();
variable_set('filter_allowed_protocols', $allowed_protocols);
return $ret;
}
/**
* Helper function returns allowed protocols with internal and files added.
*/
function _pathfilter_allowed_protocol_helper() {
$allowed_protocols = variable_get('filter_allowed_protocols', array(
'http',
'https',
'ftp',
'news',
'nntp',
'telnet',
'mailto',
'irc',
'ssh',
'sftp',
'webcal',
'rtsp',
));
return array_merge($allowed_protocols, array(
'internal',
'files',
));
}
Functions
Name | Description |
---|---|
pathfilter_install | Implementation of hook_install() |
pathfilter_uninstall | Implementation of hook_uninstall() |
pathfilter_update_6101 | Fix absolute/relative setting isn't input format-specific |
pathfilter_update_6200 | Add internal and files to allowed protocol variable. |
_pathfilter_allowed_protocol_helper | Helper function returns allowed protocols with internal and files added. |