Changes to support "shared admin topics" 3/21/2001: In wiki.pm: in qw vars (line 112 approx) $adminTopicDir @sharedTopicList at end of initialize: ## SGK 3-21-01: handle shared topics my $sharedTopicDir = "$dataDir/$adminTopicDir"; @sharedTopicList = (); if( opendir( DIR, $sharedTopicDir ) ) { # for performance use readdir, not a row of ( -e file ) @sharedTopicList = grep /\.*txt$/, readdir DIR; closedir DIR; } new/replace subroutines: # ========================= # pass topic name, returns true if it is a shared topic sub isSharedTopic { my ($topic) = @_; my $found = grep { /^$topic.txt$/ } @sharedTopicList ; return $found; } # ========================= # NOTE: We assume the admin topics always exist sub topicExists { my( $web, $name ) = @_; return ( -e "$dataDir/$web/$name.txt" ) || # ========================= # pass topic name, returns true if it is a shared topic sub isSharedTopic { my ($topic) = @_; my $found = grep { /^$topic.txt$/ } @sharedTopicList ; return $found; } # ========================= # NOTE: We assume the admin topics always exist sub topicExists { my( $web, $name ) = @_; return ( -e "$dataDir/$web/$name.txt" ) || ( isSharedTopic ($name) ); } # ========================= sub readTopic { my( $name ) = @_; # SGK 3/21/01: add support for admin topics # currently from TWiki web if ( -e "$dataDir/$webPath/$name.txt" ) { # SGK 1/15/01: use webPath for multilevel web support return &readFile( "$dataDir/$webPath/$name.txt" ); } if (isSharedTopic ($name)) { return &readFile( "$dataDir/$adminTopicDir/$name.txt" ); } return "ERROR: directory $webPath topic $name not found (file $dataDir/$adminTopicDir/$name.txt)"; } # ========================= # pass topic name, returns true if it is a shared topic sub isSharedTopic { my ($topic) = @_; my $found = grep { /^$topic.txt$/ } @sharedTopicList ; return $found; } # ========================= # NOTE: We assume the admin topics always exist sub topicExists { my( $web, $name ) = @_; return ( -e "$dataDir/$web/$name.txt" ) || ( isSharedTopic ($name) ); } # ========================= sub readTopic { my( $name ) = @_; # SGK 3/21/01: add support for admin topics # currently from TWiki web if ( -e "$dataDir/$webPath/$name.txt" ) { # SGK 1/15/01: use webPath for multilevel web support return &readFile( "$dataDir/$webPath/$name.txt" ); } if (isSharedTopic ($name)) { return &readFile( "$dataDir/$adminTopicDir/$name.txt" ); } return "ERROR: directory $webPath topic $name not found (file $dataDir/$adminTopicDir/$name.txt)"; } # ========================= # pass topic name, returns true if it is a shared topic sub isSharedTopic { my ($topic) = @_; my $found = grep { /^$topic.txt$/ } @sharedTopicList ; return $found; } # ========================= # NOTE: We assume the admin topics always exist sub topicExists { my( $web, $name ) = @_; return ( -e "$dataDir/$web/$name.txt" ) || ( isSharedTopic ($name) ); } # ========================= sub readTopic { my( $name ) = @_; # SGK 3/21/01: add support for admin topics # currently from TWiki web if ( -e "$dataDir/$webPath/$name.txt" ) { # SGK 1/15/01: use webPath for multilevel web support return &readFile( "$dataDir/$webPath/$name.txt" ); } if (isSharedTopic ($name)) { return &readFile( "$dataDir/$adminTopicDir/$name.txt" ); } return "ERROR: directory $webPath topic $name not found (file $dataDir/$adminTopicDir/$name.txt)"; } ( isSharedTopic ($name) ); } # ========================= sub readTopic { my( $name ) = @_; # SGK 3/21/01: add support for admin/shared topics # currently from TWiki web if ( -e "$dataDir/$webPath/$name.txt" ) { # SGK 1/15/01: use webPath for multilevel web support return &readFile( "$dataDir/$webPath/$name.txt" ); } if (isSharedTopic ($name)) { return &readFile( "$dataDir/$adminTopicDir/$name.txt" ); } return "ERROR: directory $webPath topic $name not found (file $dataDir/$adminTopicDir/$name.txt)"; } ****************************************************************************** in wikicfg.pm: add new setting: # SGK 21-mar-01: for "shared admin topics", see wiki::readTopic, topicExists $adminTopicDir = "Admin/Sharedtopics";