? paranoia_for_6x.patch
Index: paranoia.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/paranoia/paranoia.info,v
retrieving revision 1.2
diff -u -p -r1.2 paranoia.info
--- paranoia.info	18 Jun 2007 22:53:53 -0000	1.2
+++ paranoia.info	21 Nov 2008 01:44:16 -0000
@@ -1,3 +1,4 @@
-; $Id: paranoia.info,v 1.2 2007/06/18 22:53:53 dww Exp $
 name = Paranoia
-description = "Disallows usage of PHP code from inside Drupal and tampering with the uid = 1 account. Remember to delete the PHP input filter from the default input format."
+description = Protects the website's administrator from his users
+version = .1
+core = 6.x
\ No newline at end of file
Index: paranoia.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/paranoia/paranoia.module,v
retrieving revision 1.6
diff -u -p -r1.6 paranoia.module
--- paranoia.module	22 May 2007 17:45:14 -0000	1.6
+++ paranoia.module	21 Nov 2008 01:44:16 -0000
@@ -1,42 +1,90 @@
 <?php
 // $Id: paranoia.module,v 1.6 2007/05/22 17:45:14 killes Exp $
-// A module that locks a site down to achieve more security from malicious end users.
 
-function paranoia_form_alter($form_id, &$form) {
+/**
+ * @file
+ * - Disables PHP blocks
+ * - Hides the paranoia module from the modules page
+ * - Disables access to the File System page
+ * - Disables FCKEditor's File Path settings
+ * - Sets restrictions on file types allowed to be uploaded (with IMCE)
+ * @todo
+ * ! Protect User #1
+ * - Add install to initialize, such as disable the PHP module if its enabled
+ * - Have central way to set the file types which are allowed to be uploaded
+ */
+
+function paranoia_has_access() {
+  global $user;
+
+  if($user->uid == 1) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+function paranoia_menu_alter(&$items) {
+  $items["admin/settings/file-system"]['access callback'] = 'paranoia_has_access';
+}
+
+
+function paranoia_form_alter(&$form, $form_state, $form_id) {
+  global $user;
+
+  if($user->uid == 1) return;
+
+  // (Not in use) Allowed extensions are being statically set
+  // $allowedExtensions = 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
+
   switch ($form_id) {
-    case 'user_admin_perm':
-      // Do not allow any user safe user #1 to enter PHP anywhere
+    case 'user_admin_perm': // Disable PHP Blocks
       unset($form['permission']['use PHP for block visibility']);
-      unset($form['permission']['execute php code']);
       foreach (element_children($form['checkboxes']) as $rid) {
-        unset($form['checkboxes'][$rid]['use PHP for block visibility']);
+        unset($form['checkboxes'][$rid]['#default_value']['use PHP for block visibility']);
         unset($form['checkboxes'][$rid]['#options']['use PHP for block visibility']);
-        unset($form['checkboxes'][$rid]['execute php code']);
-        unset($form['checkboxes'][$rid]['#options']['execute php code']);
       }
       break;
-    case 'filter_admin_format_form':
-      // Disable creation of input formats that use the PHP filter
-      // Note you should also delete the PHP filter from the default
-      // input format.
-      unset($form['filters']['filter/1']);
+
+    case 'system_modules': // (System - Modules) Hide Paranoia and PHP modules
+      // TODO: add hook so other modules could specify additional modules
+      $hiddenModules = array('paranoia', 'php');
+      for($i = 0; $i < count($hiddenModules); $i++){
+        paranoia_hide_module($form, $hiddenModules[$i]);
+      }
       break;
-    case 'system_modules':
-      // Disable disabling of this module
-      unset($form['name']['paranoia'], $form['version']['paranoia'], $form['description']['paranoia'], $form['throttle']['paranoia'], $form['throttle']['#options']['paranoia']);
-      $form['status']['paranoia'] = array('#type' => 'hidden', '#value' => 1);
+
+    case 'upload_admin_settings': // (Upload Module) Set Allowed Upload Extensions
+      if(isset($form['settings_general']['upload_extensions_default'])){
+        $form['settings_general']['upload_extensions_default']['#type'] = 'hidden';
+        //$form['settings_general']['upload_extensions_default']['#value'] = $allowedExtensions;
+      };
       break;
-    case 'user_edit':
-      if (arg(1) == 1) {
-        // disable deletion of the No. 1 user, also changing of
-        // password, status, or mail address.
-        unset($form['delete'], $form['account']['mail'], $form['account']['pass'], $form['account']['status']);
-      }
+
+    case 'fckeditor_profile_form_build': // (FCKEditor) Hide FCK Upload Settings
+      $form['fckeditor_upload_settings']['#description'] = t('Set file browser settings.');
+      $form['fckeditor_upload_settings']['imce']['#description'] = t('Use the IMCE module to manage file and image uploads.');
+      $form['fckeditor_upload_settings']['upload_advanced']['#type'] = 'hidden';     
+      //$form['fckeditor_upload_settings']['upload_advanced']['#value'] = 'f';     
+      $form['fckeditor_upload_settings']['upload_basic']['#type'] = 'hidden';
+      //$form['fckeditor_upload_settings']['upload_basic']['#value'] = 'f';
+      $form['fckeditor_upload_settings']['UserFilesPath']['#type'] = 'hidden';
+      //$form['fckeditor_upload_settings']['UserFilesPath']['#value'] = '%b%f';
+      $form['fckeditor_upload_settings']['UserFilesAbsolutePath']['#type'] = 'hidden';
+      //$form['fckeditor_upload_settings']['UserFilesAbsolutePath']['#value'] = getcwd(). '/%f';
       break;
-    case 'block_admin_configure':
-      unset($form['page_vis_settings']['visibility']['#options'][2]);
-      $form['page_vis_settings']['pages']['#description'] = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are <em>blog</em> for the blog page and <em>blog/*</em> for every personal blog. <em>&lt;front&gt;</em> is the front page.");
+
+    case 'imce_profile_form': // (IMCE) Restrict IMCE Upload Extensions
+      $form['profile']['extensions']['#type'] = 'hidden';
+      //$form['profile']['extensions']['#value'] = $allowedExtensions;
       break;
   }
+}
 
+function paranoia_hide_module(&$form, $module){
+  unset($form['validation_modules']['#value'][$module],
+   $form['name'][$module],
+   $form['version'][$module],
+   $form['description'][$module],
+   $form['throttle'][$module],
+   $form['status']['#options'][$module]);
 }
\ No newline at end of file
