diff --git a/sites/all/modules/unl/unl.module b/sites/all/modules/unl/unl.module index cab17c5e937d171dab8b568dc4a60a03a20c4686..d951ccb069b0bc01130915f959fa03d1ca658a8f 100644 --- a/sites/all/modules/unl/unl.module +++ b/sites/all/modules/unl/unl.module @@ -87,7 +87,11 @@ function unl_permission() { 'unl theme settings' => array( 'title' => t('Change Theme Settings'), 'description' => t('Allow this role to change the current theme settings.'), - ) + ), + + 'unl imce javascript upload' => array( + 'title' => t('Upload Javascript Files Through IMCE'), + ), ); } @@ -164,6 +168,20 @@ function unl_menu_alter(&$items) { return $items; } +/** + * Implementation of hook_file_validate() + * Fires when files are uploaded after Drupal Core sanitization but before saving to file system or db + */ +function unl_file_validate($file) { + // For IMCE uploads only, check if Drupal core just altered a *.js upload to *.js.txt and correct if permitted + if ($file->source == 'imce' && substr($file->filename, -7) == '.js.txt' && user_access('unl imce javascript upload')) { + // Chop off the .txt extesnsion that's been added + $file->destination = substr($file->destination, 0, -4); + $file->filename = substr($file->filename, 0, -4); + } + return; +} + function unl_form_alter(&$form, $form_state, $form_id) { // Make new menu items expanded by default. if ($form_id == 'menu_edit_item' && $form['mlid']['#value'] == 0) {