]> git.p6c8.net - devedit.git/blobdiff - modules/Config/DevEdit.pm
Small changes to README
[devedit.git] / modules / Config / DevEdit.pm
index 8d9d50398f6eb7d19a388e25c66ea984edb608d1..9b535c2649c16f19661e002ecc1132afa436de2b 100644 (file)
@@ -6,7 +6,15 @@ package Config::DevEdit;
 # Read and parse the configuration files
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-09-30
+# Last modified: 2010-12-24
+#
+# Copyright (C) 1999-2000 Roland Bluethgen, Frank Schoenmann
+# Copyright (C) 2003-2009 Patrick Canterino
+# All Rights Reserved.
+#
+# This file can be distributed and/or modified under the terms of
+# of the Artistic License 1.0 (see also the LICENSE file found at
+# the top level of the Dev-Editor distribution).
 #
 
 use strict;
@@ -22,6 +30,15 @@ use base qw(Exporter);
 
 @EXPORT = qw(read_config);
 
+# This variable contains some dependencies for the "disable_commands"
+# configuration option.
+# The Hash key defines a command, the value is an Array Reference or String
+# defining the commands that will also be disabled.
+
+my %disable_dependency = ('beginedit' => 'endedit',
+                          'remove' => 'remove_multi',
+                          '@write' => ['beginedit','endedit','copy','rename','remove','remove_multi','mkdir','mkfile','upload','chprop']);
+
 # read_config()
 #
 # Read the configuration files of Dev-Editor
@@ -66,14 +83,16 @@ sub read_config($)
 
    my $new_conf = $userconf->{$ENV{'REMOTE_USER'}};
 
-   $config->{'fileroot'}       = $new_conf->{'fileroot'}  if($new_conf->{'fileroot'});
-   $config->{'httproot'}       = $new_conf->{'httproot'}  if($new_conf->{'httproot'});
+   $config->{'fileroot'}         = $new_conf->{'fileroot'}  if($new_conf->{'fileroot'});
+   $config->{'httproot'}         = $new_conf->{'httproot'}  if($new_conf->{'httproot'});
+   $config->{'startdir'}         = $new_conf->{'startdir'}  if($new_conf->{'startdir'});
 
-   $config->{'forbidden'}      = $new_conf->{'forbidden'} if(defined $new_conf->{'forbidden'});
+   $config->{'forbidden'}        = $new_conf->{'forbidden'} if(defined $new_conf->{'forbidden'});
+   $config->{'disable_commands'} = $new_conf->{'disable_commands'} if(defined $new_conf->{'disable_commands'});
 
-   $config->{'hide_dot_files'} = $new_conf->{'hide_dot_files'} if(defined $new_conf->{'hide_dot_files'});
+   $config->{'hide_dot_files'}   = $new_conf->{'hide_dot_files'} if(defined $new_conf->{'hide_dot_files'});
 
-   $config->{'user_config'}    = 1;
+   $config->{'user_config'}      = 1;
   }
  }
 
@@ -100,6 +119,36 @@ sub read_config($)
   $config->{'forbidden'} = [];
  }
 
+ # Parse list of disabled commands (we need some universal code!)
+
+ if($config->{'disable_commands'})
+ {
+  my @commands;
+
+  foreach my $command(parse_line('\s+',0,$config->{'disable_commands'}))
+  {
+   push(@commands,$command) unless(substr($command,0,1) eq '@');
+
+   if(exists($disable_dependency{$command}) && $disable_dependency{$command})
+   {
+    if(ref($disable_dependency{$command}) eq 'ARRAY')
+    {
+     push(@commands,@{$disable_dependency{$command}});
+    }
+    else
+    {
+     push(@commands,$disable_dependency{$command});
+    }
+   }
+  }
+
+  $config->{'disable_commands'} = \@commands;
+ }
+ else
+ {
+  $config->{'disable_commands'} = [];
+ }
+
  return $config;
 }
 

patrick-canterino.de