<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Take a look at how the Media module handles it:<br>
<br>
<br>
<a class="moz-txt-link-freetext" href="http://drupalcode.org/project/media.git/blob_plain/refs/heads/7.x-1.x:/media.installfunction">http://drupalcode.org/project/media.git/blob_plain/refs/heads/7.x-1.x:/media.installfunction</a>
media_uninstall() {<br>
<pre>function media_uninstall() {
foreach (media_variable_default() as $name => $value) {
media_variable_del($name);
}
}
</pre>
<a class="moz-txt-link-freetext" href="http://drupalcode.org/project/media.git/blob_plain/refs/heads/7.x-1.x:/includes/media.variables.inc">http://drupalcode.org/project/media.git/blob_plain/refs/heads/7.x-1.x:/includes/media.variables.inc</a><br>
<br>
<pre>define('MEDIA_VARIABLE_NAMESPACE', 'media__');</pre>
<br>
<pre>/**
* The default variables within the Media namespace.
*
* @param string $name
* Optional variable name to retrieve the default. Note that it has not yet
* been pre-pended with the MEDIA_VARIABLE_NAMESPACE namespace at this time.
* @return unknown
* The default value of this variable, if it's been set, or NULL, unless
* $name is NULL, in which case we return an array of all default values.
*
* @see media_variable_get()
* @see media_variable_set()
* @see media_variable_del()
*/
function media_variable_default($name = NULL) {
static $defaults;
if (!isset($defaults)) {
$defaults = array(
'wysiwyg_title' => 'Media browser',
'wysiwyg_icon_title' => 'Add media',
//@todo: We should do this per type actually. For "other" it should be a link.
'wysiwyg_default_view_mode' => 'media_large',
// Types which can be selected when embedding media vs wysiwyg.
'wysiwyg_allowed_types' => array('image', 'video'),
// Attributes which can be modified via the wysiwyg and persist.
'wysiwyg_allowed_attributes' => array('height', 'width', 'hspace', 'vspace', 'border', 'align', 'style', 'alt', 'title', 'class', 'id'),
'field_select_media_text' => 'Select media',
'field_remove_media_text' => 'Remove media',
// Name of the theme to use in media popup dialogs, defaults to admin_theme
'dialog_theme' => '',
// @TODO: Make a configuration form with this.
'file_extensions' => 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp mp3 mov m4v mp4 mpeg avi ogg wmv ico',
'max_filesize' => '',
'debug' => FALSE,
'file_list_size' => 10,
// Used in media.xml.inc: how long to cache retrieved remote data.
'xml_cache_expire' => 3600,
// Browser defaults in media.browser.inc.
'browser_viewtype_default' => 'thumbnails',
'browser_pager_limit' => 40,
'browser_library_empty_message' => 'There are currently no media in this library to select.',
'import_batch_size' => 20,
'fromurl_supported_schemes' => array('http', 'https', 'ftp', 'smb', 'ftps'),
'type_icon_directory' => drupal_get_path('module', 'media') . '/images/types',
'icon_base_directory' => drupal_get_path('module', 'media') . '/images/icons',
'icon_set' => 'default',
// This is set in media_enable(). It will show a persistant dsm on every page
// until the user runs the batch operation provided by media_admin_rebuild_types_form().
'show_file_type_rebuild_nag' => FALSE,
);
}
if (!isset($name)) {
return $defaults;
}
if (isset($defaults[$name])) {
return $defaults[$name];
}
}
</pre>
<br>
<br>
On 05/26/2011 06:58 PM, Peter Anderson wrote:
<blockquote cite="mid:4DDEDB31.8000805@panda.id.au" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<font face="sans-serif">Hi all,<br>
<br>
I have a module that uses quite a few variables</font> and would
like to remove them in my hook_uninstall() function, but I don't
want to have to list them all manually...<br>
<br>
I see three ways to do this:<br>
1 - Run variable_del() for each variable manually<br>
2 - List all variables then remove the ones that start with my
module's name<br>
3 - Delete variables directly from the database that start with my
module's name<br>
<br>
I'm obviously trying to avoid #1.<br>
I've used #2 before (<a moz-do-not-send="true"
class="moz-txt-link-freetext" href="http://drupalbin.com/18718">http://drupalbin.com/18718</a>)
but am worried about the possible performance implications of
running a foreach() on every variable in Drupal... Is this good or
not?<br>
I'd prefer not to resort to using SQL to delete variables from the
database directly as in #3, but this may be the only recommended
option...<br>
<br>
What is the recommended way to call variable_del() on a bunch of
variables? I'm using D7 if that helps.<br>
Thanks.<br>
<br>
<pre class="moz-signature" cols="72">--
Kind regards,
Peter Anderson.
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://panda.id.au">http://panda.id.au</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Aaron Winborn
Advomatic, LLC
<a class="moz-txt-link-freetext" href="http://advomatic.com/">http://advomatic.com/</a>
Drupal Multimedia available now!
<a class="moz-txt-link-freetext" href="http://www.packtpub.com/create-multimedia-website-with-drupal/book">http://www.packtpub.com/create-multimedia-website-with-drupal/book</a>
My blog:
<a class="moz-txt-link-freetext" href="http://aaronwinborn.com/">http://aaronwinborn.com/</a></pre>
</body>
</html>