I've found it useful to have swf replacement disabled when i'm editing and adding nodes - this makes it easier to stay in the admin section and work as a moderator for the site. I've modified the module as below to do this - if anyone finds this useful then perhaps it could be good to stick it in the module.
Added a tickbox and variable in this function - swfaddress_admin_form():
$form['swfaddress_admin_disable'] = array(
'#type' => 'checkbox',
'#title' => t('Disable if logged in as a node administrator'),
'#description' => t('If checked this will turn off Flash replacement if logged in with administer node permissions'),
'#default_value' => variable_get('swfaddress_admin_disable', FALSE)
);
Changed the logic in this function - swfaddress_init() where the javascript gets added:
// Converted from the old hook_menu($may_cache) by chok.
//&& (variable_get('swfaddress_replacement_enabled', FALSE) && !user_access('administer nodes'))
if (variable_get('swfaddress_replacement_enabled', FALSE)
&& variable_get('clean_url', 0) == 1
&& _swfaddress_path_permitted()
// I've added the line below...
&& (!variable_get('swfaddress_admin_disable', FALSE) || !user_access('administer nodes'))
) {
// It is vitally important that swfobject.js be included before SWFAddress!
Comments
Comment #1
mllr commentedGreat improvement of usability! Thanks, I’ve been looking exactly for this :-)
Comment #2
idflood commentedI'm wondering if it would be better to add a new permission "swfaddress enabled". It would give the ability to enable/disable swfaddress by role. I also added the setting provided above, but made it only affect user 1 ( the super admin ).
add the option to disable replacement for user 1 in swfaddress_admin_form():
add the new permission:
get the global user variable and check the option, the user and the permission before adding the javascripts.
Comment #3
idflood commentedforgot to remove unneeded stuff from the patch file. Here is the corrected version