1 |
--- smeserver-trac-0.4/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/trac.pm.add2general 2007-04-27 08:54:46.000000000 +0200 |
--- smeserver-trac-0.4/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/trac.pm.add2general 2008-04-26 09:18:47.000000000 -0600 |
2 |
+++ smeserver-trac-0.4/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/trac.pm 2008-04-26 16:38:42.000000000 +0200 |
+++ smeserver-trac-0.4/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/trac.pm 2008-04-26 09:14:48.000000000 -0600 |
3 |
@@ -1,954 +1,954 @@ |
@@ -129,18 +129,18 @@ |
4 |
-#!/usr/bin/perl -w |
my $q = $fm->{cgi}; |
5 |
-#---------------------------------------------------------------------- |
|
6 |
-# $Id: trac.pm 69 2007-03-25 13:20:24Z marco $ |
# Setup the various localised text field for the trac project table |
7 |
-# vim: ft=perl ts=4 sw=4 et: |
- my $name = $fm->localise('TRAC_TABLE_HEADER_NAME'); |
8 |
-#---------------------------------------------------------------------- |
- my $description = $fm->localise('TRAC_TABLE_HEADER_DESCRIPTION'); |
9 |
-# Copyright (C) 2007 Marco Hess |
- my $domains = $fm->localise('TRAC_TABLE_HEADER_DOMAINS'); |
10 |
-# |
- my $repository = $fm->localise('TRAC_TABLE_HEADER_REPOSITORY'); |
11 |
-# This program is free software; you can redistribute it and/or modify |
- my $path = $fm->localise('TRAC_TABLE_HEADER_PATH'); |
12 |
-# it under the terms of the GNU General Public License as published by |
- my $access = $fm->localise('TRAC_TABLE_HEADER_ACCESS'); |
13 |
-# the Free Software Foundation; either version 2 of the License, or |
- my $action_h = $fm->localise('TRAC_TABLE_HEADER_ACTION'); |
14 |
-# (at your option) any later version. |
- my $view = $fm->localise('TRAC_ACTION_VIEW'); |
15 |
-# |
- my $modify = $fm->localise('TRAC_ACTION_MODIFY'); |
16 |
-# This program is distributed in the hope that it will be useful, |
- my $remove = $fm->localise('TRAC_ACTION_REMOVE'); |
17 |
-# but WITHOUT ANY WARRANTY; without even the implied warranty of |
- my $backup = $fm->localise('TRAC_ACTION_BACKUP'); |
18 |
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- my $restore = $fm->localise('TRAC_ACTION_RESTORE'); |
|
-# GNU General Public License for more details. |
|
|
-# |
|
|
-# You should have received a copy of the GNU General Public License |
|
|
-# along with this program; if not, write to the Free Software |
|
|
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
-#---------------------------------------------------------------------- |
|
|
- |
|
|
-package esmith::FormMagick::Panel::trac; |
|
|
- |
|
|
-use strict; |
|
|
-use warnings; |
|
|
- |
|
|
-use esmith::FormMagick; |
|
|
-use esmith::AccountsDB; |
|
|
-use esmith::ConfigDB; |
|
|
-use esmith::DomainsDB; |
|
|
-use esmith::cgi; |
|
|
-use esmith::util; |
|
|
-use File::Basename; |
|
|
-use Exporter; |
|
|
-use Carp; |
|
|
-use Sys::Syslog; |
|
|
- |
|
|
-use constant TRUE => 1; |
|
|
-use constant FALSE => 0; |
|
|
- |
|
|
-our @ISA = qw(esmith::FormMagick Exporter); |
|
|
- |
|
|
-our @EXPORT = qw( |
|
|
- show_trac_projects |
|
|
- print_trac_field_name |
|
|
- repositories_list |
|
|
- group_list |
|
|
- user_list |
|
|
- max_trac_project_name_length |
|
|
- handle_trac_projects |
|
|
- create_trac_project |
|
|
- remove_trac_project |
|
|
- getExtraParams |
|
|
- print_save_or_add_button |
|
|
- validate_name |
|
|
- validate_radio |
|
|
- wherenext |
|
|
- maxLength |
|
|
-); |
|
|
- |
|
|
-our $ConfigDB = esmith::ConfigDB->open |
|
|
- or die "Can't open the Config database : $!\n" ; |
|
|
- |
|
|
-our $AccountsDB = esmith::AccountsDB->open |
|
|
- or die "Can't open the Account database : $!\n" ; |
|
|
- |
|
|
-our $DomainsDB = esmith::DomainsDB->open |
|
|
- or die "Can't open the Domains database : $!\n" ; |
|
|
- |
|
|
- |
|
|
-# fields and records separator for sub records |
|
|
-use constant FS => "," ; |
|
|
-use constant RS => ";" ; |
|
|
- |
|
|
-=pod |
|
|
- |
|
|
-=head1 NAME |
|
|
- |
|
|
-esmith::FormMagick::Panels::trac - Trac |
|
|
- |
|
|
-=head1 SYNOPSIS |
|
|
- |
|
|
-use esmith::FormMagick::Panels::trac |
|
|
- |
|
|
-my $panel = esmith::FormMagick::Panel::trac->new(); |
|
|
-$panel->display(); |
|
|
- |
|
|
-=head1 DESCRIPTION |
|
|
- |
|
|
-This module is the backend to the Trac panel, responsible |
|
|
-for supplying all functions used by that panel. It is a subclass |
|
|
-of esmith::FormMagick itself, so it inherits the functionality |
|
|
-of a FormMagick object. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-=head2 new() |
|
|
- |
|
|
-Exactly as for esmith::FormMagick |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub new |
|
|
-{ |
|
|
- my $proto = shift; |
|
|
- my $class = ref($proto) || $proto; |
|
|
- my $self = esmith::FormMagick::new($class); |
|
|
- $self->{calling_package} = (caller)[0]; |
|
|
- |
|
|
- return $self; |
|
|
-} |
|
|
- |
|
|
-=head1 HTML GENERATION ROUTINES |
|
|
- |
|
|
-Routines for generating chunks of HTML needed by the panel. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-=head2 show_trac_projects() |
|
|
- |
|
|
-This function displays a table of trac project environments on the system |
|
|
-including the links to modify and remove the trac project environment. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub show_trac_projects { |
|
|
- my $fm = shift; |
|
|
- my $q = $fm->{cgi}; |
|
|
- |
|
|
- # Setup the various localised text field for the trac project table |
|
|
- my $name = $fm->localise('TRAC_TABLE_HEADER_NAME'); |
|
|
- my $description = $fm->localise('TRAC_TABLE_HEADER_DESCRIPTION'); |
|
|
- my $domains = $fm->localise('TRAC_TABLE_HEADER_DOMAINS'); |
|
|
- my $repository = $fm->localise('TRAC_TABLE_HEADER_REPOSITORY'); |
|
|
- my $path = $fm->localise('TRAC_TABLE_HEADER_PATH'); |
|
|
- my $access = $fm->localise('TRAC_TABLE_HEADER_ACCESS'); |
|
|
- my $action_h = $fm->localise('TRAC_TABLE_HEADER_ACTION'); |
|
|
- my $view = $fm->localise('TRAC_ACTION_VIEW'); |
|
|
- my $modify = $fm->localise('TRAC_ACTION_MODIFY'); |
|
|
- my $remove = $fm->localise('TRAC_ACTION_REMOVE'); |
|
|
- my $backup = $fm->localise('TRAC_ACTION_BACKUP'); |
|
|
- my $restore = $fm->localise('TRAC_ACTION_RESTORE'); |
|
|
- |
|
|
- print $q->start_table({-class => 'sme-noborder'}), "\n"; |
|
|
- |
|
|
- # Check if any repositories exist |
|
|
- my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository'); |
|
|
- unless ( scalar @repositories ) |
|
|
- { |
|
|
- print $q->Tr($q->td($q->h2($fm->localise('NO_REPOSITORIES')))); |
|
|
- return ""; |
|
|
- } |
|
|
- |
|
|
- # TODO what about the case that all repositories have been deleted |
|
|
- # but the Trac project environments are still there? Can we remove the |
|
|
- # trac projects or do we need to reassign the projects to |
|
|
- # another repository? The code above prevents us from accessing the |
|
|
- # trac projects when there are no more repositories. |
|
|
- |
|
|
- print $q->Tr($q->td($q->a({-class => "button-like", |
|
|
- href => "trac?page=0&page_stack=&Next=Next&wherenext=Create"}, |
|
|
- $fm->localise('TRAC_ADD_BUTTON')))); |
|
|
- |
|
|
- # Check if any trac projects exist |
|
|
- my @TracProjects = $AccountsDB->get_all_by_prop('type' => 'trac'); |
|
|
- unless ( scalar @TracProjects ) |
|
|
- { |
|
|
- print $q->Tr($q->td($q->h2($fm->localise('NO_TRAC_PROJECTS')))); |
|
|
- return ""; |
|
|
- } |
|
|
- |
|
|
- # Show the list of configures trac projects |
|
|
- print $q->Tr($q->td($q->h2($fm->localise('CURRENT_TRAC_PROJECTS')))); |
|
|
- |
|
|
- print $q->Tr($q->td($fm->localise('TRAC_MODIFY_REMOVE_BUTTON_DESCRIPTION'))); |
|
|
- |
|
|
- print $q->start_table({-CLASS => "sme-border"}),"\n"; |
|
|
- print $q->Tr ( |
|
|
- esmith::cgi::genSmallCell($q, $name, "header"), |
|
|
- esmith::cgi::genSmallCell($q, $description,"header"), |
|
|
- esmith::cgi::genSmallCell($q, $domains, "header"), |
|
|
- esmith::cgi::genSmallCell($q, $repository, "header"), |
|
|
- esmith::cgi::genSmallCell($q, $path, "header"), |
|
|
- esmith::cgi::genSmallCell($q, $access, "header"), |
|
|
- esmith::cgi::genSmallCell($q, $action_h, "header", 3)),"\n"; |
|
|
- |
|
|
- my $scriptname = basename($0); |
|
|
- |
|
|
- foreach my $TracProject (@TracProjects) |
|
|
- { |
|
|
- my $trac_name = $TracProject->key(); |
|
|
- my $trac_desc = $TracProject->prop('Description'); |
|
|
- my $trac_domains = join("<br>", split(FS, $TracProject->prop('Domains'))); |
|
|
- my $trac_repo = $TracProject->prop('Repository'); |
|
|
- my $trac_path = $TracProject->prop('RepositoryPath'); |
|
|
- my $trac_access = $TracProject->prop('Access') || 'local'; |
|
|
- my $modifiable = $TracProject->prop('Modifiable') || 'yes'; |
|
|
- my $removable = $TracProject->prop('Removable') || 'yes'; |
|
|
- |
|
|
- my $params = $fm->build_trac_project_cgi_params($trac_name, $TracProject->props()); |
|
|
- |
|
|
- my $href = "$scriptname?$params&action=modify&wherenext="; |
|
|
- |
|
|
- my $actionView = ' '; |
|
|
- $actionView .= $q->a({href => '/' . $TracProject->key(), |
|
|
- target => '_blank'}, $view ) . ' '; |
|
|
- |
|
|
- my $actionModify = ' '; |
|
|
- if ($modifiable eq 'yes') |
|
|
- { |
|
|
- $actionModify .= $q->a({href => "${href}Modify"}, $modify) . ' '; |
|
|
- } |
|
|
- |
|
|
- my $actionRemove = ' '; |
|
|
- if ($removable eq 'yes') |
|
|
- { |
|
|
- $actionRemove .= $q->a({href => "${href}Remove"}, $remove) . ' '; |
|
|
- } |
|
|
- |
|
|
- my $actionBackup = ' '; |
|
|
- $actionBackup .= $q->a({href => "${href}Backup"}, $backup) . ' '; |
|
|
- |
|
|
- my $actionRestore = ' '; |
|
|
- $actionRestore .= $q->a({href => "${href}Restore"}, $restore) . ' '; |
|
|
- |
|
|
- print $q->Tr( |
|
|
- esmith::cgi::genSmallCell($q, $trac_name, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $trac_desc, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $trac_domains, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $trac_repo, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $trac_path, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $trac_access, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $actionView, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $actionModify, "normal"), |
|
|
- esmith::cgi::genSmallCell($q, $actionRemove, "normal") |
|
|
- ); |
|
|
- } |
|
|
- |
|
|
- print $q->end_table,"\n"; |
|
|
- |
|
|
- print $q->end_table,"\n"; |
|
|
- |
|
|
- return ""; |
|
|
-} |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-=head2 print_save_or_add_button() |
|
|
- |
|
|
-Prints the ADD button when a new trac project environment is addded and the SAVE buttom |
|
|
-whem modifications are made. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub print_save_or_add_button { |
|
|
- |
|
|
- my ($fm) = @_; |
|
|
- |
|
|
- my $cgi = $fm->{cgi}; |
|
|
- |
|
|
- if (($cgi->param("action") || '') eq "modify") { |
|
|
- $fm->print_button("SAVE"); |
|
|
- } else { |
|
|
- $fm->print_button("ADD"); |
|
|
- } |
|
|
-} |
|
|
- |
|
|
-=head1 HELPER FUNCTIONS FOR THE PANEL |
|
|
- |
|
|
-Routines for modifying the database and signaling events |
|
|
-from the server-manager panel |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-=head2 build_trac_project_cgi_params($fm, $tracprojectname, %oldprops) |
|
|
- |
|
|
-Constructs the parameters for the links in the trac project environments table |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub build_trac_project_cgi_params { |
|
|
- my ($self, $tracprojectname, %oldprops) = @_; |
|
|
- |
|
|
- my %props = ( |
|
|
- page => 0, |
|
|
- page_stack => "", |
|
|
- tracName => $tracprojectname, |
|
|
- ); |
|
|
- |
|
|
- return $self->props_to_query_string(\%props); |
|
|
-} |
|
|
- |
|
|
-*wherenext = \&CGI::FormMagick::wherenext; |
|
|
- |
|
|
-=head2 print_trac_field_name() |
|
|
- |
|
|
-Helper function to print the field NAME so that it becomes |
|
|
-an edit field upon ADD and a fixed field upon MODIFY. |
|
|
- |
|
|
-Also read all the account db values so the other fields |
|
|
-can show the existing values. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub print_trac_field_name { |
|
|
- my $fm = shift; |
|
|
- my $in = $fm->{cgi}->param('tracName') || ''; |
|
|
- my $action = $fm->{cgi}->param('action') || ''; |
|
|
- |
|
|
- print qq(<tr><td class="sme-noborders-label">) . |
|
|
- $fm->localise('TRAC_FIELD_PROJECT_NAME') . qq(</td>\n); |
|
|
- |
|
|
- if ($action eq 'modify' and $in) { |
|
|
- #------------------------------------------------------- |
|
|
- # Updating an existing record. |
|
|
- #-------------------------------------------------------- |
|
|
- |
|
|
- my $rec = $AccountsDB->get($in); |
|
|
- my $modifiable = $rec->prop('Modifiable') || 'yes'; |
|
|
- my $removable = $rec->prop('Removable') || 'yes'; |
|
|
- |
|
|
- print qq( |
|
|
- <td class="sme-noborders-content">$in |
|
|
- <input type="hidden" name="tracName" value="$in"> |
|
|
- <input type="hidden" name="action" value="modify"> |
|
|
- </td> |
|
|
- ); |
|
|
- |
|
|
- # Read the values for each field from the accounts db and store |
|
|
- # them in the cgi object so our form will have the correct |
|
|
- # info displayed. |
|
|
- my $q = $fm->{cgi}; |
|
|
- if ($rec) |
|
|
- { |
|
|
- $q->param(-name=>'tracDescription',-value=> |
|
|
- $rec->prop('Description')); |
|
|
- |
|
|
- $q->param(-name=>'tracRepository',-value=> |
|
|
- $rec->prop('Repository')); |
|
|
- |
|
|
- $q->param(-name=>'tracRepositoryPath',-value=> |
|
|
- $rec->prop('RepositoryPath')); |
|
|
- |
|
|
- # domain list is handled separately |
|
|
- |
|
|
- $q->param(-name=>'tracGroups',-value=> |
|
|
- join(FS, split(FS, $rec->prop('Groups')))); |
|
|
- |
|
|
- $q->param(-name=>'tracUsers',-value=> |
|
|
- join(FS, split(FS, $rec->prop('Users')))); |
|
|
- |
|
|
- $q->param(-name=>'tracAccess',-value=> |
|
|
- $rec->prop('Access')), |
|
|
- } |
|
|
- } else { |
|
|
- #------------------------------------------------------- |
|
|
- # Adding a new record so allow an entry field for the |
|
|
- # name. |
|
|
- #-------------------------------------------------------- |
|
|
- print qq( |
|
|
- <td><input type="text" name="tracName" value="$in"> |
|
|
- <input type="hidden" name="action" value="create"> |
|
|
- </td> |
|
|
- ); |
|
|
- } |
|
|
- |
|
|
- print qq(</tr>\n); |
|
|
- return undef; |
|
|
-} |
|
|
- |
|
|
- |
|
|
-=head2 print_trac_domains() |
|
|
- |
|
|
-When this server has more than one domain this function takes |
|
|
-the list of domains and returns a string of html checkboxes |
|
|
-for all these domains. |
|
|
- |
|
|
-Those domains that are listed with this Trac environment |
|
|
-will have their checkbox checked. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub print_trac_domains() { |
|
|
- |
|
|
- # Retrieve the Trac account name from the CGI parameters |
|
|
- my $fm = shift; |
|
|
- my $name = $fm->{'cgi'}->param('tracName'); |
|
|
- my $action = $fm->{'cgi'}->param("action") || ''; |
|
|
- my $out = ""; |
|
|
- |
|
|
- # Get a full list of all the domains on this server. |
|
|
- my @domains = $DomainsDB->get_all_by_prop( type => 'domain' ); |
|
|
- my $numdomains = @domains; |
|
|
- |
|
|
- # If there is more than one domain, we generate a list |
|
|
- # of checkboxes. Otherwise we just show the primary domain. |
|
|
- if ($numdomains > 1) { |
|
|
- |
|
|
- # With the Trac account name, get the list of the Domains for which |
|
|
- # this Trac account is active. |
|
|
- my $trac_domains_list = ""; |
|
|
- if ($AccountsDB->get($name)) { |
|
|
- $trac_domains_list = $AccountsDB->get($name)->prop('Domains'); |
|
|
- } |
|
|
- |
|
|
- # Split the comma separated list into the individual bits. |
|
|
- my %trac_domains; |
|
|
- foreach my $trac_domain ( split ( /,/, $trac_domains_list ) ) { |
|
|
- $trac_domains{$trac_domain} = 1; |
|
|
- } |
|
|
- |
|
|
- # Now generate the table of domains with a checkbox in front of it. |
|
|
- # If the domain is in our listed domains for the Trac environment, the |
|
|
- # checkbox will show checked. |
|
|
- $out = " <tr>\n"; |
|
|
- $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAINS_DESCRIPTION') . "</td>"; |
|
|
- $out .= " </tr>\n"; |
|
|
- $out .= " <tr>\n"; |
|
|
- $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAINS') . "</td>\n"; |
|
|
- $out .= " <td>\n"; |
|
|
- $out .= " <table border='0' cellspacing='0' cellpadding='0'>\n"; |
|
|
- $out .= " <tr>\n"; |
|
|
- |
|
|
- foreach my $domain (sort @domains) { |
|
|
- |
|
|
- # If this is a ADD form, we default check all domains, otherwise only |
|
|
- # those that are in our Trac project list. |
|
|
- my $checked = ""; |
|
|
- if ( $action eq 'modify' ) { |
|
|
- if ( $trac_domains{ $domain->key() } ) { |
|
|
- $checked = "checked"; |
|
|
- } |
|
|
- } else { |
|
|
- $checked = "checked"; |
|
|
- } |
|
|
- |
|
|
- $out .= " <tr>\n"; |
|
|
- $out .= " <td><input type=\"checkbox\" name=\"tracDomains\" $checked value=\"" . $domain->key . "\"></td>\n"; |
|
|
- $out .= " <td>" . $domain->key . "</td>\n"; |
|
|
- $out .= " </tr>\n"; |
|
|
- } |
|
|
- |
|
|
- $out .= " </table>\n"; |
|
|
- $out .= " </td>\n"; |
|
|
- $out .= " </tr>\n"; |
|
|
- } |
|
|
- else |
|
|
- { |
|
|
- # We only have a single domain, so we just show this domain but without the |
|
|
- # checkbox (so it can't be unchecked). |
|
|
- my $domainname = $ConfigDB->get('DomainName')->value(); |
|
|
- $out = " <tr>\n"; |
|
|
- $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAIN_DESCRIPTION') . "</td>"; |
|
|
- $out .= " </tr>\n"; |
|
|
- $out .= " <tr>\n"; |
|
|
- $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAIN') . "</td>\n"; |
|
|
- $out .= " <td><input type=\"hidden\" name=\"tracDomains\" value=\"" . $domainname . "\">"; |
|
|
- $out .= $domainname . "</td>\n"; |
|
|
- $out .= " </tr>\n"; |
|
|
- } |
|
|
- |
|
|
- return $out; |
|
|
-} |
|
|
- |
|
|
- |
|
|
-=pod |
|
|
- |
|
|
-=head2 repositories_list() |
|
|
- |
|
|
-Returns a hash of repositories for the Create/Modify screen's repository |
|
|
-field's drop down list. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub repositories_list |
|
|
-{ |
|
|
- my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository'); |
|
|
- my %repositories = (); |
|
|
- foreach my $repository (@repositories) { |
|
|
- $repositories{$repository->key()} = $repository->prop('Description') . " (" . $repository->key . ")"; |
|
|
- } |
|
|
- return \%repositories; |
|
|
-} |
|
|
- |
|
|
-=head2 group_list() |
|
|
- |
|
|
-Returns a hash of groups for the Create/Modify screen's group |
|
|
-field's drop down list. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub group_list |
|
|
-{ |
|
|
- my @groups = $AccountsDB->groups(); |
|
|
- my %groups = (); |
|
|
- foreach my $group (@groups) { |
|
|
- $groups{$group->key()} = $group->prop('Description')." (".$group->key.")"; |
|
|
- } |
|
|
- return \%groups; |
|
|
-} |
|
|
- |
|
|
-=head2 user_list() |
|
|
- |
|
|
-Returns a hash of users for the Create/Modify screen's user field's |
|
|
-drop down list. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub user_list |
|
|
-{ |
|
|
- my @users = $AccountsDB->users(); |
|
|
- my %users = (); |
|
|
- foreach my $user (@users) { |
|
|
- $users{$user->key()} = $user->prop('LastName').", ". $user->prop('FirstName')." (". $user->key.")"; |
|
|
- } |
|
|
- return \%users; |
|
|
-} |
|
|
- |
|
|
-=head1 THE ROUTINES THAT ACTUALLY DO THE WORK |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-=head2 handle_trac_projects() |
|
|
- |
|
|
-Determine whether to modify or add the trac project environment |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub handle_trac_projects { |
|
|
- |
|
|
- my ($fm) = @_; |
|
|
- |
|
|
- if ($fm->cgi->param("action") eq "create") { |
|
|
- $fm->create_trac_project(); |
|
|
- } else { |
|
|
- $fm->modify_trac_project(); |
|
|
- } |
|
|
- |
|
|
-} |
|
|
- |
|
|
-=head2 create_trac_project() |
|
|
- |
|
|
-Handle the create event for the trac project environment |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub create_trac_project { |
|
|
- |
|
|
- my ($fm) = @_; |
|
|
- |
|
|
- # Validate Name |
|
|
- # ============= |
|
|
- |
|
|
- my $name = $fm->cgi->param('tracName'); |
|
|
- my $msg; |
|
|
- |
|
|
- $msg = $fm->validate_name($name); |
|
|
- unless ($msg eq "OK") |
|
|
- { |
|
|
- return $fm->error($msg); |
|
|
- } |
|
|
- |
|
|
- $msg = $fm->max_trac_project_name_length($name); |
|
|
- unless ($msg eq "OK") |
|
|
- { |
|
|
- return $fm->error($msg); |
|
|
- } |
|
|
- |
|
|
- $msg = $fm->conflict_check($name); |
|
|
- unless ($msg eq "OK") |
|
|
- { |
|
|
- return $fm->error($msg); |
|
|
- } |
|
|
- |
|
|
- # Validate & Setup Domain List |
|
|
- # ============================ |
|
|
- |
|
|
- my @active_trac_domains = $fm->cgi->param('tracDomains'); |
|
|
- |
|
|
- $msg = $fm->validate_trac_has_domains(@active_trac_domains); |
|
|
- unless ($msg eq "OK") |
|
|
- { |
|
|
- return $fm->error($msg); |
|
|
- } |
|
|
- |
|
|
- my $domain_list = ""; |
|
|
- foreach my $domain (@active_trac_domains) { |
|
|
- if ($domain_list) { |
|
|
- $domain_list .= "," . $domain; |
|
|
- } else { |
|
|
- $domain_list = $domain; |
|
|
- } |
|
|
- } |
|
|
- |
|
|
- # Setup Group List |
|
|
- # ================ |
|
|
- |
|
|
- my @groups = $fm->cgi->param('tracGroups'); |
|
|
- |
|
|
- my $group_list = ""; |
|
|
- foreach my $group (@groups) { |
|
|
- if ($group_list) { |
|
|
- $group_list .= "," . $group; |
|
|
- } else { |
|
|
- $group_list = $group; |
|
|
- } |
|
|
- } |
|
|
- |
|
|
- # Setup User List |
|
|
- # =============== |
|
|
- |
|
|
- my @users = $fm->cgi->param('tracUsers'); |
|
|
- |
|
|
- my $user_list = ""; |
|
|
- foreach my $user (@users) { |
|
|
- if ($user_list) { |
|
|
- $user_list .= "," . $user; |
|
|
- } else { |
|
|
- $user_list = $user; |
|
|
- } |
|
|
- } |
|
|
- |
|
|
- # Update Database |
|
|
- # =============== |
|
|
- |
|
|
- my $uid = $AccountsDB->get_next_uid(); |
|
|
- if (my $acct = $AccountsDB->new_record($name, { |
|
|
- Description => $fm->cgi->param('tracDescription'), |
|
|
- Repository => $fm->cgi->param('tracRepository'), |
|
|
- RepositoryPath => $fm->cgi->param('tracRepositoryPath'), |
|
|
- Domains => "$domain_list", |
|
|
- Groups => "$group_list", |
|
|
- Users => "$user_list", |
|
|
- Modifiable => 'yes', |
|
|
- Removable => 'yes', |
|
|
- Access => $fm->cgi->param('tracAccess'), |
|
|
- type => 'trac', |
|
|
- }) ) |
|
|
- { |
|
|
- # Untaint $name before use in system() |
|
|
- $name =~ /(.+)/; $name = $1; |
|
|
- |
|
|
- $fm->clear_params(); |
|
|
- |
|
|
- if (system ("/sbin/e-smith/signal-event", "trac-project-create", $name) == 0) { |
|
|
- $fm->success("SUCCESSFULLY_CREATED_TRAC_PROJECT"); |
|
|
- } else { |
|
|
- $fm->error("ERROR_WHILE_CREATING_TRAC_PROJECT"); |
|
|
- } |
|
|
- } else { |
|
|
- $fm->error('CANT_CREATE_TRAC_PROJECT'); |
|
|
- } |
|
|
-} |
|
|
- |
|
|
-=head2 modify_trac_project() |
|
|
- |
|
|
-Handle the modify event for the trac project environment |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub modify_trac_project { |
|
|
- |
|
|
- my ($fm) = @_; |
|
|
- my $name = $fm->cgi->param('tracName'); |
|
|
- |
|
|
- # Validate Name |
|
|
- # ============= |
|
|
- |
|
|
- my $msg = $fm->validate_name($name); |
|
|
- unless ($msg eq "OK") |
|
|
- { |
|
|
- return $fm->error($msg); |
|
|
- } |
|
|
- |
|
|
- # Validate & Setup Domain List |
|
|
- # ============================ |
|
|
- |
|
|
- my @active_trac_domains = $fm->cgi->param('tracDomains'); |
|
|
- |
|
|
- $msg = $fm->validate_trac_has_domains(@active_trac_domains); |
|
|
- unless ($msg eq "OK") |
|
|
- { |
|
|
- return $fm->error($msg); |
|
|
- } |
|
|
- |
|
|
- my $domain_list; |
|
|
- foreach my $domain (@active_trac_domains) { |
|
|
- if ($domain_list) { |
|
|
- $domain_list .= "," . $domain; |
|
|
- } else { |
|
|
- $domain_list = $domain; |
|
|
- } |
|
|
- } |
|
|
- |
|
|
- # Setup Group List |
|
|
- # ================ |
|
|
- |
|
|
- my @groups = $fm->cgi->param('tracGroups'); |
|
|
- |
|
|
- my $group_list; |
|
|
- foreach my $group (@groups) { |
|
|
- if ($group_list) { |
|
|
- $group_list .= "," . $group; |
|
|
- } else { |
|
|
- $group_list = $group; |
|
|
- } |
|
|
- } |
|
|
- |
|
|
- # Setup User List |
|
|
- # =============== |
|
|
- |
|
|
- my @users = $fm->cgi->param('tracUsers'); |
|
|
- |
|
|
- my $user_list; |
|
|
- foreach my $user (@users) { |
|
|
- if ($user_list) { |
|
|
- $user_list .= "," . $user; |
|
|
- } else { |
|
|
- $user_list = $user; |
|
|
- } |
|
|
- } |
|
|
- |
|
|
- # Update Database |
|
|
- # =============== |
|
|
- |
|
|
- if (my $acct = $AccountsDB->get($name)) { |
|
|
- if ($acct->prop('type') eq 'trac') { |
|
|
- |
|
|
- $acct->merge_props( |
|
|
- Description => $fm->cgi->param('tracDescription'), |
|
|
- Repository => $fm->cgi->param('tracRepository'), |
|
|
- RepositoryPath => $fm->cgi->param('tracRepositoryPath'), |
|
|
- Domains => $domain_list, |
|
|
- Groups => $group_list, |
|
|
- Users => $user_list, |
|
|
- Access => $fm->cgi->param('tracAccess'), |
|
|
- type => 'trac', |
|
|
- ); |
|
|
- |
|
|
- # Untaint $name before use in system() |
|
|
- $name =~ /(.+)/; $name = $1; |
|
|
- |
|
|
- $fm->clear_params(); |
|
|
- |
|
|
- if (system ("/sbin/e-smith/signal-event", "trac-project-modify", $name) == 0) |
|
|
- { |
|
|
- $fm->success("SUCCESSFULLY_MODIFIED_TRAC_PROJECT"); |
|
|
- } else { |
|
|
- $fm->error("ERROR_WHILE_MODIFYING_TRAC_PROJECT"); |
|
|
- } |
|
|
- } else { |
|
|
- $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
- } |
|
|
- } else { |
|
|
- $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
- } |
|
|
-} |
|
|
- |
|
|
-=head2 remove_trac_project() |
|
|
- |
|
|
-Handle the remove event for the trac project environment |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub remove_trac_project { |
|
|
- |
|
|
- my $fm = shift; |
|
|
- |
|
|
- my $name = $fm->cgi->param('tracName'); |
|
|
- if (my $acct = $AccountsDB->get($name)) { |
|
|
- if ($acct->prop('type') eq 'trac') { |
|
|
- $acct->set_prop('type', 'trac-deleted'); |
|
|
- |
|
|
- # Untaint $name before use in system() |
|
|
- $name =~ /(.+)/; $name = $1; |
|
|
- if (system ("/sbin/e-smith/signal-event", "trac-project-delete", $name) == 0) { |
|
|
- $fm ->success("SUCCESSFULLY_DELETED_TRAC_PROJECT"); |
|
|
- $acct->delete(); |
|
|
- } else { |
|
|
- $fm ->error("ERROR_WHILE_DELETING_TRAC_PROJECT"); |
|
|
- } |
|
|
- } else { |
|
|
- $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
- } |
|
|
- |
|
|
- } else { |
|
|
- $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
- } |
|
|
- $fm->wherenext('First'); |
|
|
-} |
|
|
- |
|
|
-=head1 VALIDATION ROUTINES |
|
|
- |
|
|
-=head2 max_trac_project_name_length() |
|
|
- |
|
|
-Checks the length of a given trac project environment name against the |
|
|
-maximum set in the maxTracNameLength record of the configuration database. |
|
|
-Defaults to a maximum length of $self->{defaultMaxLength} if nothing is |
|
|
-set in the config db. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub max_trac_project_name_length { |
|
|
- my ($fm, $data) = @_; |
|
|
- |
|
|
- $ConfigDB->reload(); |
|
|
- my $max; |
|
|
- if (my $max_record = $ConfigDB->get('maxTracNameLength')) { |
|
|
- $max = $max_record->value(); |
|
|
- } |
|
|
- |
|
|
- if (length($data) <= $max) { |
|
|
- return "OK"; |
|
|
- } else { |
|
|
- return $fm->localise("MAX_TRAC_NAME_LENGTH_ERROR", |
|
|
- {acctName => $data, |
|
|
- maxRepositoryNameLength => $max, |
|
|
- maxLength => $max}); |
|
|
- } |
|
|
-} |
|
|
- |
|
|
-=head2 getExtraParams() |
|
|
- |
|
|
-Sets variables used in the lexicon to their required values. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub getExtraParams { |
|
|
- |
|
|
- my $fm = shift; |
|
|
- my $TracProjectName = $fm->cgi->param('tracName'); |
|
|
- my $TracProjectDescription = ''; |
|
|
- my $maxLength = $ConfigDB->get('maxTracNameLength'); |
|
|
- |
|
|
- if ($TracProjectName) |
|
|
- { |
|
|
- my $TracAccount = $AccountsDB->get($TracProjectName); |
|
|
- if ($TracAccount) |
|
|
- { |
|
|
- $TracProjectDescription = $TracAccount->prop('Description'); |
|
|
- } |
|
|
- } |
|
|
- |
|
|
- return (name => $TracProjectName, |
|
|
- description => $TracProjectDescription, |
|
|
- maxLength => $maxLength); |
|
|
-} |
|
|
- |
|
|
-=head2 validate_name() |
|
|
- |
|
|
-Checks that the name supplied does not contain any unacceptable chars. |
|
|
-Returns OK on success or a localised error message otherwise. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub validate_name { |
|
|
- |
|
|
- my ($fm, $tracName) = @_; |
|
|
- |
|
|
- unless ($tracName =~ /^([a-z][\_\.\-a-z0-9]*)$/) |
|
|
- { |
|
|
- return $fm->localise('TRAC_PROJECT_NAME_HAS_INVALID_CHARS', {tracName => $tracName}); |
|
|
- } |
|
|
- |
|
|
- return "OK"; |
|
|
-} |
|
|
- |
|
|
-=head2 conflict_check() |
|
|
- |
|
|
-Check the proposed name for clashes with existing pseudonyms or other |
|
|
-accounts of any type. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub conflict_check { |
|
|
- |
|
|
- my ($fm, $name) = @_; |
|
|
- my $rec = $AccountsDB->get($name); |
|
|
- |
|
|
- my $type; |
|
|
- if (defined $rec) |
|
|
- { |
|
|
- my $type = $rec->prop('type'); |
|
|
- if ($type eq "pseudonym") |
|
|
- { |
|
|
- my $acct = $rec->prop("Account"); |
|
|
- my $acct_type = $AccountsDB->get($acct)->prop('type'); |
|
|
- |
|
|
- return $fm->localise('ACCT_CLASHES_WITH_PSEUDONYM', |
|
|
- {acctName => $name, acctType => $acct_type, acct => $acct}); |
|
|
- } |
|
|
- } |
|
|
- elsif (defined getpwnam($name) || defined getgrnam($name)) |
|
|
- { |
|
|
- $type = 'system'; |
|
|
- } |
|
|
- else |
|
|
- { |
|
|
- # No account record and no account |
|
|
- return 'OK'; |
|
|
- } |
|
|
- return $fm->localise('ACCOUNT_EXISTS', |
|
|
- {acctName => $name, acctType => $type}); |
|
|
-} |
|
|
- |
|
|
-=head2 validate_trac_has_domains() |
|
|
- |
|
|
-Validates that the cgi parameter DOMAINS is an array with at least one entry |
|
|
-Returns OK if true. Otherwise, returns NO_DOMAINS |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub validate_trac_has_domains { |
|
|
- |
|
|
- my $fm = shift; |
|
|
- my @domains = @_; |
|
|
- |
|
|
- my $count = @domains; |
|
|
- |
|
|
- if ( $count == 0 ) { |
|
|
- return ('NO_DOMAINS'); |
|
|
- } |
|
|
- else { |
|
|
- return ('OK'); |
|
|
- } |
|
|
-} |
|
|
- |
|
|
-=head2 clear_params() |
|
|
- |
|
|
-This method clears-out the parameters used in form submission so that they are |
|
|
-not inadvertenly picked-up where they should not be. |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-sub clear_params { |
|
|
- |
|
|
- my $fm = shift; |
|
|
- my $q = $fm->{cgi}; |
|
|
- |
|
|
- # Don't delete tracName here as we need in the next page for |
|
|
- # status messages. |
|
|
- |
|
|
- $q->delete('tracDescription'); |
|
|
- $q->delete('tracRepository'); |
|
|
- $q->delete('tracRepositoryPath'); |
|
|
- $q->delete('tracDomains'); |
|
|
- $q->delete('tracGroups'); |
|
|
- $q->delete('tracUsers'); |
|
|
- $q->delete('tracAccess'); |
|
|
- |
|
|
-} |
|
|
- |
|
|
-1; |
|
|
+#!/usr/bin/perl -w |
|
|
+#---------------------------------------------------------------------- |
|
|
+# $Id: trac.pm 69 2007-03-25 13:20:24Z marco $ |
|
|
+# vim: ft=perl ts=4 sw=4 et: |
|
|
+#---------------------------------------------------------------------- |
|
|
+# Copyright (C) 2007 Marco Hess |
|
|
+# |
|
|
+# This program is free software; you can redistribute it and/or modify |
|
|
+# it under the terms of the GNU General Public License as published by |
|
|
+# the Free Software Foundation; either version 2 of the License, or |
|
|
+# (at your option) any later version. |
|
|
+# |
|
|
+# This program is distributed in the hope that it will be useful, |
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
+# GNU General Public License for more details. |
|
|
+# |
|
|
+# You should have received a copy of the GNU General Public License |
|
|
+# along with this program; if not, write to the Free Software |
|
|
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
+#---------------------------------------------------------------------- |
|
|
+ |
|
|
+package esmith::FormMagick::Panel::trac; |
|
|
+ |
|
|
+use strict; |
|
|
+use warnings; |
|
|
+ |
|
|
+use esmith::FormMagick; |
|
|
+use esmith::AccountsDB; |
|
|
+use esmith::ConfigDB; |
|
|
+use esmith::DomainsDB; |
|
|
+use esmith::cgi; |
|
|
+use esmith::util; |
|
|
+use File::Basename; |
|
|
+use Exporter; |
|
|
+use Carp; |
|
|
+use Sys::Syslog; |
|
|
+ |
|
|
+use constant TRUE => 1; |
|
|
+use constant FALSE => 0; |
|
|
+ |
|
|
+our @ISA = qw(esmith::FormMagick Exporter); |
|
|
+ |
|
|
+our @EXPORT = qw( |
|
|
+ show_trac_projects |
|
|
+ print_trac_field_name |
|
|
+ repositories_list |
|
|
+ group_list |
|
|
+ user_list |
|
|
+ max_trac_project_name_length |
|
|
+ handle_trac_projects |
|
|
+ create_trac_project |
|
|
+ remove_trac_project |
|
|
+ getExtraParams |
|
|
+ print_save_or_add_button |
|
|
+ validate_name |
|
|
+ validate_radio |
|
|
+ wherenext |
|
|
+ maxLength |
|
|
+); |
|
|
+ |
|
|
+our $ConfigDB = esmith::ConfigDB->open |
|
|
+ or die "Can't open the Config database : $!\n" ; |
|
|
+ |
|
|
+our $AccountsDB = esmith::AccountsDB->open |
|
|
+ or die "Can't open the Account database : $!\n" ; |
|
|
+ |
|
|
+our $DomainsDB = esmith::DomainsDB->open |
|
|
+ or die "Can't open the Domains database : $!\n" ; |
|
|
+ |
|
|
+ |
|
|
+# fields and records separator for sub records |
|
|
+use constant FS => "," ; |
|
|
+use constant RS => ";" ; |
|
|
+ |
|
|
+=pod |
|
|
+ |
|
|
+=head1 NAME |
|
|
+ |
|
|
+esmith::FormMagick::Panels::trac - Trac |
|
|
+ |
|
|
+=head1 SYNOPSIS |
|
|
+ |
|
|
+use esmith::FormMagick::Panels::trac |
|
|
+ |
|
|
+my $panel = esmith::FormMagick::Panel::trac->new(); |
|
|
+$panel->display(); |
|
|
+ |
|
|
+=head1 DESCRIPTION |
|
|
+ |
|
|
+This module is the backend to the Trac panel, responsible |
|
|
+for supplying all functions used by that panel. It is a subclass |
|
|
+of esmith::FormMagick itself, so it inherits the functionality |
|
|
+of a FormMagick object. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+=head2 new() |
|
|
+ |
|
|
+Exactly as for esmith::FormMagick |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub new |
|
|
+{ |
|
|
+ my $proto = shift; |
|
|
+ my $class = ref($proto) || $proto; |
|
|
+ my $self = esmith::FormMagick::new($class); |
|
|
+ $self->{calling_package} = (caller)[0]; |
|
|
+ |
|
|
+ return $self; |
|
|
+} |
|
|
+ |
|
|
+=head1 HTML GENERATION ROUTINES |
|
|
+ |
|
|
+Routines for generating chunks of HTML needed by the panel. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+=head2 show_trac_projects() |
|
|
+ |
|
|
+This function displays a table of trac project environments on the system |
|
|
+including the links to modify and remove the trac project environment. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub show_trac_projects { |
|
|
+ my $fm = shift; |
|
|
+ my $q = $fm->{cgi}; |
|
|
+ |
|
|
+ # Setup the various localised text field for the trac project table |
|
19 |
+ my $name = $fm->localise('NAME'); |
+ my $name = $fm->localise('NAME'); |
20 |
+ my $description = $fm->localise('DESCRIPTION'); |
+ my $description = $fm->localise('DESCRIPTION'); |
21 |
+ my $domains = $fm->localise('DOMAINS'); |
+ my $domains = $fm->localise('DOMAINS'); |
28 |
+ my $remove = $fm->localise('REMOVE'); |
+ my $remove = $fm->localise('REMOVE'); |
29 |
+ my $backup = $fm->localise('BACKUP'); |
+ my $backup = $fm->localise('BACKUP'); |
30 |
+ my $restore = $fm->localise('RESTORE'); |
+ my $restore = $fm->localise('RESTORE'); |
|
+ |
|
|
+ print $q->start_table({-class => 'sme-noborder'}), "\n"; |
|
|
+ |
|
|
+ # Check if any repositories exist |
|
|
+ my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository'); |
|
|
+ unless ( scalar @repositories ) |
|
|
+ { |
|
|
+ print $q->Tr($q->td($q->h2($fm->localise('NO_REPOSITORIES')))); |
|
|
+ return ""; |
|
|
+ } |
|
|
+ |
|
|
+ # TODO what about the case that all repositories have been deleted |
|
|
+ # but the Trac project environments are still there? Can we remove the |
|
|
+ # trac projects or do we need to reassign the projects to |
|
|
+ # another repository? The code above prevents us from accessing the |
|
|
+ # trac projects when there are no more repositories. |
|
|
+ |
|
|
+ print $q->Tr($q->td($q->a({-class => "button-like", |
|
|
+ href => "trac?page=0&page_stack=&Next=Next&wherenext=Create"}, |
|
|
+ $fm->localise('TRAC_ADD_BUTTON')))); |
|
|
+ |
|
|
+ # Check if any trac projects exist |
|
|
+ my @TracProjects = $AccountsDB->get_all_by_prop('type' => 'trac'); |
|
|
+ unless ( scalar @TracProjects ) |
|
|
+ { |
|
|
+ print $q->Tr($q->td($q->h2($fm->localise('NO_TRAC_PROJECTS')))); |
|
|
+ return ""; |
|
|
+ } |
|
|
+ |
|
|
+ # Show the list of configures trac projects |
|
|
+ print $q->Tr($q->td($q->h2($fm->localise('CURRENT_TRAC_PROJECTS')))); |
|
|
+ |
|
|
+ print $q->Tr($q->td($fm->localise('TRAC_MODIFY_REMOVE_BUTTON_DESCRIPTION'))); |
|
|
+ |
|
|
+ print $q->start_table({-CLASS => "sme-border"}),"\n"; |
|
|
+ print $q->Tr ( |
|
|
+ esmith::cgi::genSmallCell($q, $name, "header"), |
|
|
+ esmith::cgi::genSmallCell($q, $description,"header"), |
|
|
+ esmith::cgi::genSmallCell($q, $domains, "header"), |
|
|
+ esmith::cgi::genSmallCell($q, $repository, "header"), |
|
|
+ esmith::cgi::genSmallCell($q, $path, "header"), |
|
|
+ esmith::cgi::genSmallCell($q, $access, "header"), |
|
|
+ esmith::cgi::genSmallCell($q, $action_h, "header", 3)),"\n"; |
|
|
+ |
|
|
+ my $scriptname = basename($0); |
|
|
+ |
|
|
+ foreach my $TracProject (@TracProjects) |
|
|
+ { |
|
|
+ my $trac_name = $TracProject->key(); |
|
|
+ my $trac_desc = $TracProject->prop('Description'); |
|
|
+ my $trac_domains = join("<br>", split(FS, $TracProject->prop('Domains'))); |
|
|
+ my $trac_repo = $TracProject->prop('Repository'); |
|
|
+ my $trac_path = $TracProject->prop('RepositoryPath'); |
|
|
+ my $trac_access = $TracProject->prop('Access') || 'local'; |
|
|
+ my $modifiable = $TracProject->prop('Modifiable') || 'yes'; |
|
|
+ my $removable = $TracProject->prop('Removable') || 'yes'; |
|
|
+ |
|
|
+ my $params = $fm->build_trac_project_cgi_params($trac_name, $TracProject->props()); |
|
|
+ |
|
|
+ my $href = "$scriptname?$params&action=modify&wherenext="; |
|
|
+ |
|
|
+ my $actionView = ' '; |
|
|
+ $actionView .= $q->a({href => '/' . $TracProject->key(), |
|
|
+ target => '_blank'}, $view ) . ' '; |
|
|
+ |
|
|
+ my $actionModify = ' '; |
|
|
+ if ($modifiable eq 'yes') |
|
|
+ { |
|
|
+ $actionModify .= $q->a({href => "${href}Modify"}, $modify) . ' '; |
|
|
+ } |
|
|
+ |
|
|
+ my $actionRemove = ' '; |
|
|
+ if ($removable eq 'yes') |
|
|
+ { |
|
|
+ $actionRemove .= $q->a({href => "${href}Remove"}, $remove) . ' '; |
|
|
+ } |
|
|
+ |
|
|
+ my $actionBackup = ' '; |
|
|
+ $actionBackup .= $q->a({href => "${href}Backup"}, $backup) . ' '; |
|
|
+ |
|
|
+ my $actionRestore = ' '; |
|
|
+ $actionRestore .= $q->a({href => "${href}Restore"}, $restore) . ' '; |
|
|
+ |
|
|
+ print $q->Tr( |
|
|
+ esmith::cgi::genSmallCell($q, $trac_name, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $trac_desc, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $trac_domains, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $trac_repo, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $trac_path, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $trac_access, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $actionView, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $actionModify, "normal"), |
|
|
+ esmith::cgi::genSmallCell($q, $actionRemove, "normal") |
|
|
+ ); |
|
|
+ } |
|
|
+ |
|
|
+ print $q->end_table,"\n"; |
|
|
+ |
|
|
+ print $q->end_table,"\n"; |
|
|
+ |
|
|
+ return ""; |
|
|
+} |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+=head2 print_save_or_add_button() |
|
|
+ |
|
|
+Prints the ADD button when a new trac project environment is addded and the SAVE buttom |
|
|
+whem modifications are made. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub print_save_or_add_button { |
|
|
+ |
|
|
+ my ($fm) = @_; |
|
|
+ |
|
|
+ my $cgi = $fm->{cgi}; |
|
|
+ |
|
|
+ if (($cgi->param("action") || '') eq "modify") { |
|
|
+ $fm->print_button("SAVE"); |
|
|
+ } else { |
|
|
+ $fm->print_button("ADD"); |
|
|
+ } |
|
|
+} |
|
|
+ |
|
|
+=head1 HELPER FUNCTIONS FOR THE PANEL |
|
|
+ |
|
|
+Routines for modifying the database and signaling events |
|
|
+from the server-manager panel |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+=head2 build_trac_project_cgi_params($fm, $tracprojectname, %oldprops) |
|
|
+ |
|
|
+Constructs the parameters for the links in the trac project environments table |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub build_trac_project_cgi_params { |
|
|
+ my ($self, $tracprojectname, %oldprops) = @_; |
|
|
+ |
|
|
+ my %props = ( |
|
|
+ page => 0, |
|
|
+ page_stack => "", |
|
|
+ tracName => $tracprojectname, |
|
|
+ ); |
|
|
+ |
|
|
+ return $self->props_to_query_string(\%props); |
|
|
+} |
|
|
+ |
|
|
+*wherenext = \&CGI::FormMagick::wherenext; |
|
|
+ |
|
|
+=head2 print_trac_field_name() |
|
|
+ |
|
|
+Helper function to print the field NAME so that it becomes |
|
|
+an edit field upon ADD and a fixed field upon MODIFY. |
|
|
+ |
|
|
+Also read all the account db values so the other fields |
|
|
+can show the existing values. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub print_trac_field_name { |
|
|
+ my $fm = shift; |
|
|
+ my $in = $fm->{cgi}->param('tracName') || ''; |
|
|
+ my $action = $fm->{cgi}->param('action') || ''; |
|
|
+ |
|
|
+ print qq(<tr><td class="sme-noborders-label">) . |
|
|
+ $fm->localise('TRAC_FIELD_PROJECT_NAME') . qq(</td>\n); |
|
|
+ |
|
|
+ if ($action eq 'modify' and $in) { |
|
|
+ #------------------------------------------------------- |
|
|
+ # Updating an existing record. |
|
|
+ #-------------------------------------------------------- |
|
|
+ |
|
|
+ my $rec = $AccountsDB->get($in); |
|
|
+ my $modifiable = $rec->prop('Modifiable') || 'yes'; |
|
|
+ my $removable = $rec->prop('Removable') || 'yes'; |
|
|
+ |
|
|
+ print qq( |
|
|
+ <td class="sme-noborders-content">$in |
|
|
+ <input type="hidden" name="tracName" value="$in"> |
|
|
+ <input type="hidden" name="action" value="modify"> |
|
|
+ </td> |
|
|
+ ); |
|
|
+ |
|
|
+ # Read the values for each field from the accounts db and store |
|
|
+ # them in the cgi object so our form will have the correct |
|
|
+ # info displayed. |
|
|
+ my $q = $fm->{cgi}; |
|
|
+ if ($rec) |
|
|
+ { |
|
|
+ $q->param(-name=>'tracDescription',-value=> |
|
|
+ $rec->prop('Description')); |
|
|
+ |
|
|
+ $q->param(-name=>'tracRepository',-value=> |
|
|
+ $rec->prop('Repository')); |
|
|
+ |
|
|
+ $q->param(-name=>'tracRepositoryPath',-value=> |
|
|
+ $rec->prop('RepositoryPath')); |
|
|
+ |
|
|
+ # domain list is handled separately |
|
|
+ |
|
|
+ $q->param(-name=>'tracGroups',-value=> |
|
|
+ join(FS, split(FS, $rec->prop('Groups')))); |
|
|
+ |
|
|
+ $q->param(-name=>'tracUsers',-value=> |
|
|
+ join(FS, split(FS, $rec->prop('Users')))); |
|
|
+ |
|
|
+ $q->param(-name=>'tracAccess',-value=> |
|
|
+ $rec->prop('Access')), |
|
|
+ } |
|
|
+ } else { |
|
|
+ #------------------------------------------------------- |
|
|
+ # Adding a new record so allow an entry field for the |
|
|
+ # name. |
|
|
+ #-------------------------------------------------------- |
|
|
+ print qq( |
|
|
+ <td><input type="text" name="tracName" value="$in"> |
|
|
+ <input type="hidden" name="action" value="create"> |
|
|
+ </td> |
|
|
+ ); |
|
|
+ } |
|
|
+ |
|
|
+ print qq(</tr>\n); |
|
|
+ return undef; |
|
|
+} |
|
|
+ |
|
|
+ |
|
|
+=head2 print_trac_domains() |
|
|
+ |
|
|
+When this server has more than one domain this function takes |
|
|
+the list of domains and returns a string of html checkboxes |
|
|
+for all these domains. |
|
|
+ |
|
|
+Those domains that are listed with this Trac environment |
|
|
+will have their checkbox checked. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub print_trac_domains() { |
|
|
+ |
|
|
+ # Retrieve the Trac account name from the CGI parameters |
|
|
+ my $fm = shift; |
|
|
+ my $name = $fm->{'cgi'}->param('tracName'); |
|
|
+ my $action = $fm->{'cgi'}->param("action") || ''; |
|
|
+ my $out = ""; |
|
|
+ |
|
|
+ # Get a full list of all the domains on this server. |
|
|
+ my @domains = $DomainsDB->get_all_by_prop( type => 'domain' ); |
|
|
+ my $numdomains = @domains; |
|
|
+ |
|
|
+ # If there is more than one domain, we generate a list |
|
|
+ # of checkboxes. Otherwise we just show the primary domain. |
|
|
+ if ($numdomains > 1) { |
|
|
+ |
|
|
+ # With the Trac account name, get the list of the Domains for which |
|
|
+ # this Trac account is active. |
|
|
+ my $trac_domains_list = ""; |
|
|
+ if ($AccountsDB->get($name)) { |
|
|
+ $trac_domains_list = $AccountsDB->get($name)->prop('Domains'); |
|
|
+ } |
|
|
+ |
|
|
+ # Split the comma separated list into the individual bits. |
|
|
+ my %trac_domains; |
|
|
+ foreach my $trac_domain ( split ( /,/, $trac_domains_list ) ) { |
|
|
+ $trac_domains{$trac_domain} = 1; |
|
|
+ } |
|
|
+ |
|
|
+ # Now generate the table of domains with a checkbox in front of it. |
|
|
+ # If the domain is in our listed domains for the Trac environment, the |
|
|
+ # checkbox will show checked. |
|
|
+ $out = " <tr>\n"; |
|
|
+ $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAINS_DESCRIPTION') . "</td>"; |
|
|
+ $out .= " </tr>\n"; |
|
|
+ $out .= " <tr>\n"; |
|
|
+ $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('DOMAINS') . "</td>\n"; |
|
|
+ $out .= " <td>\n"; |
|
|
+ $out .= " <table border='0' cellspacing='0' cellpadding='0'>\n"; |
|
|
+ $out .= " <tr>\n"; |
|
|
+ |
|
|
+ foreach my $domain (sort @domains) { |
|
|
+ |
|
|
+ # If this is a ADD form, we default check all domains, otherwise only |
|
|
+ # those that are in our Trac project list. |
|
|
+ my $checked = ""; |
|
|
+ if ( $action eq 'modify' ) { |
|
|
+ if ( $trac_domains{ $domain->key() } ) { |
|
|
+ $checked = "checked"; |
|
|
+ } |
|
|
+ } else { |
|
|
+ $checked = "checked"; |
|
|
+ } |
|
|
+ |
|
|
+ $out .= " <tr>\n"; |
|
|
+ $out .= " <td><input type=\"checkbox\" name=\"tracDomains\" $checked value=\"" . $domain->key . "\"></td>\n"; |
|
|
+ $out .= " <td>" . $domain->key . "</td>\n"; |
|
|
+ $out .= " </tr>\n"; |
|
|
+ } |
|
|
+ |
|
|
+ $out .= " </table>\n"; |
|
|
+ $out .= " </td>\n"; |
|
|
+ $out .= " </tr>\n"; |
|
|
+ } |
|
|
+ else |
|
|
+ { |
|
|
+ # We only have a single domain, so we just show this domain but without the |
|
|
+ # checkbox (so it can't be unchecked). |
|
|
+ my $domainname = $ConfigDB->get('DomainName')->value(); |
|
|
+ $out = " <tr>\n"; |
|
|
+ $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAIN_DESCRIPTION') . "</td>"; |
|
|
+ $out .= " </tr>\n"; |
|
|
+ $out .= " <tr>\n"; |
|
|
+ $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('DOMAIN') . "</td>\n"; |
|
|
+ $out .= " <td><input type=\"hidden\" name=\"tracDomains\" value=\"" . $domainname . "\">"; |
|
|
+ $out .= $domainname . "</td>\n"; |
|
|
+ $out .= " </tr>\n"; |
|
|
+ } |
|
|
+ |
|
|
+ return $out; |
|
|
+} |
|
|
+ |
|
|
+ |
|
|
+=pod |
|
|
+ |
|
|
+=head2 repositories_list() |
|
|
+ |
|
|
+Returns a hash of repositories for the Create/Modify screen's repository |
|
|
+field's drop down list. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub repositories_list |
|
|
+{ |
|
|
+ my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository'); |
|
|
+ my %repositories = (); |
|
|
+ foreach my $repository (@repositories) { |
|
|
+ $repositories{$repository->key()} = $repository->prop('Description') . " (" . $repository->key . ")"; |
|
|
+ } |
|
|
+ return \%repositories; |
|
|
+} |
|
|
+ |
|
|
+=head2 group_list() |
|
|
+ |
|
|
+Returns a hash of groups for the Create/Modify screen's group |
|
|
+field's drop down list. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub group_list |
|
|
+{ |
|
|
+ my @groups = $AccountsDB->groups(); |
|
|
+ my %groups = (); |
|
|
+ foreach my $group (@groups) { |
|
|
+ $groups{$group->key()} = $group->prop('Description')." (".$group->key.")"; |
|
|
+ } |
|
|
+ return \%groups; |
|
|
+} |
|
|
+ |
|
|
+=head2 user_list() |
|
|
+ |
|
|
+Returns a hash of users for the Create/Modify screen's user field's |
|
|
+drop down list. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub user_list |
|
|
+{ |
|
|
+ my @users = $AccountsDB->users(); |
|
|
+ my %users = (); |
|
|
+ foreach my $user (@users) { |
|
|
+ $users{$user->key()} = $user->prop('LastName').", ". $user->prop('FirstName')." (". $user->key.")"; |
|
|
+ } |
|
|
+ return \%users; |
|
|
+} |
|
|
+ |
|
|
+=head1 THE ROUTINES THAT ACTUALLY DO THE WORK |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+=head2 handle_trac_projects() |
|
|
+ |
|
|
+Determine whether to modify or add the trac project environment |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub handle_trac_projects { |
|
|
+ |
|
|
+ my ($fm) = @_; |
|
|
+ |
|
|
+ if ($fm->cgi->param("action") eq "create") { |
|
|
+ $fm->create_trac_project(); |
|
|
+ } else { |
|
|
+ $fm->modify_trac_project(); |
|
|
+ } |
|
|
+ |
|
|
+} |
|
|
+ |
|
|
+=head2 create_trac_project() |
|
|
+ |
|
|
+Handle the create event for the trac project environment |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub create_trac_project { |
|
|
+ |
|
|
+ my ($fm) = @_; |
|
|
+ |
|
|
+ # Validate Name |
|
|
+ # ============= |
|
|
+ |
|
|
+ my $name = $fm->cgi->param('tracName'); |
|
|
+ my $msg; |
|
|
+ |
|
|
+ $msg = $fm->validate_name($name); |
|
|
+ unless ($msg eq "OK") |
|
|
+ { |
|
|
+ return $fm->error($msg); |
|
|
+ } |
|
|
+ |
|
|
+ $msg = $fm->max_trac_project_name_length($name); |
|
|
+ unless ($msg eq "OK") |
|
|
+ { |
|
|
+ return $fm->error($msg); |
|
|
+ } |
|
|
+ |
|
|
+ $msg = $fm->conflict_check($name); |
|
|
+ unless ($msg eq "OK") |
|
|
+ { |
|
|
+ return $fm->error($msg); |
|
|
+ } |
|
|
+ |
|
|
+ # Validate & Setup Domain List |
|
|
+ # ============================ |
|
|
+ |
|
|
+ my @active_trac_domains = $fm->cgi->param('tracDomains'); |
|
|
+ |
|
|
+ $msg = $fm->validate_trac_has_domains(@active_trac_domains); |
|
|
+ unless ($msg eq "OK") |
|
|
+ { |
|
|
+ return $fm->error($msg); |
|
|
+ } |
|
|
+ |
|
|
+ my $domain_list = ""; |
|
|
+ foreach my $domain (@active_trac_domains) { |
|
|
+ if ($domain_list) { |
|
|
+ $domain_list .= "," . $domain; |
|
|
+ } else { |
|
|
+ $domain_list = $domain; |
|
|
+ } |
|
|
+ } |
|
|
+ |
|
|
+ # Setup Group List |
|
|
+ # ================ |
|
|
+ |
|
|
+ my @groups = $fm->cgi->param('tracGroups'); |
|
|
+ |
|
|
+ my $group_list = ""; |
|
|
+ foreach my $group (@groups) { |
|
|
+ if ($group_list) { |
|
|
+ $group_list .= "," . $group; |
|
|
+ } else { |
|
|
+ $group_list = $group; |
|
|
+ } |
|
|
+ } |
|
|
+ |
|
|
+ # Setup User List |
|
|
+ # =============== |
|
|
+ |
|
|
+ my @users = $fm->cgi->param('tracUsers'); |
|
|
+ |
|
|
+ my $user_list = ""; |
|
|
+ foreach my $user (@users) { |
|
|
+ if ($user_list) { |
|
|
+ $user_list .= "," . $user; |
|
|
+ } else { |
|
|
+ $user_list = $user; |
|
|
+ } |
|
|
+ } |
|
|
+ |
|
|
+ # Update Database |
|
|
+ # =============== |
|
|
+ |
|
|
+ my $uid = $AccountsDB->get_next_uid(); |
|
|
+ if (my $acct = $AccountsDB->new_record($name, { |
|
|
+ Description => $fm->cgi->param('tracDescription'), |
|
|
+ Repository => $fm->cgi->param('tracRepository'), |
|
|
+ RepositoryPath => $fm->cgi->param('tracRepositoryPath'), |
|
|
+ Domains => "$domain_list", |
|
|
+ Groups => "$group_list", |
|
|
+ Users => "$user_list", |
|
|
+ Modifiable => 'yes', |
|
|
+ Removable => 'yes', |
|
|
+ Access => $fm->cgi->param('tracAccess'), |
|
|
+ type => 'trac', |
|
|
+ }) ) |
|
|
+ { |
|
|
+ # Untaint $name before use in system() |
|
|
+ $name =~ /(.+)/; $name = $1; |
|
|
+ |
|
|
+ $fm->clear_params(); |
|
|
+ |
|
|
+ if (system ("/sbin/e-smith/signal-event", "trac-project-create", $name) == 0) { |
|
|
+ $fm->success("SUCCESSFULLY_CREATED_TRAC_PROJECT"); |
|
|
+ } else { |
|
|
+ $fm->error("ERROR_WHILE_CREATING_TRAC_PROJECT"); |
|
|
+ } |
|
|
+ } else { |
|
|
+ $fm->error('CANT_CREATE_TRAC_PROJECT'); |
|
|
+ } |
|
|
+} |
|
|
+ |
|
|
+=head2 modify_trac_project() |
|
|
+ |
|
|
+Handle the modify event for the trac project environment |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub modify_trac_project { |
|
|
+ |
|
|
+ my ($fm) = @_; |
|
|
+ my $name = $fm->cgi->param('tracName'); |
|
|
+ |
|
|
+ # Validate Name |
|
|
+ # ============= |
|
|
+ |
|
|
+ my $msg = $fm->validate_name($name); |
|
|
+ unless ($msg eq "OK") |
|
|
+ { |
|
|
+ return $fm->error($msg); |
|
|
+ } |
|
|
+ |
|
|
+ # Validate & Setup Domain List |
|
|
+ # ============================ |
|
|
+ |
|
|
+ my @active_trac_domains = $fm->cgi->param('tracDomains'); |
|
|
+ |
|
|
+ $msg = $fm->validate_trac_has_domains(@active_trac_domains); |
|
|
+ unless ($msg eq "OK") |
|
|
+ { |
|
|
+ return $fm->error($msg); |
|
|
+ } |
|
|
+ |
|
|
+ my $domain_list; |
|
|
+ foreach my $domain (@active_trac_domains) { |
|
|
+ if ($domain_list) { |
|
|
+ $domain_list .= "," . $domain; |
|
|
+ } else { |
|
|
+ $domain_list = $domain; |
|
|
+ } |
|
|
+ } |
|
|
+ |
|
|
+ # Setup Group List |
|
|
+ # ================ |
|
|
+ |
|
|
+ my @groups = $fm->cgi->param('tracGroups'); |
|
|
+ |
|
|
+ my $group_list; |
|
|
+ foreach my $group (@groups) { |
|
|
+ if ($group_list) { |
|
|
+ $group_list .= "," . $group; |
|
|
+ } else { |
|
|
+ $group_list = $group; |
|
|
+ } |
|
|
+ } |
|
|
+ |
|
|
+ # Setup User List |
|
|
+ # =============== |
|
|
+ |
|
|
+ my @users = $fm->cgi->param('tracUsers'); |
|
|
+ |
|
|
+ my $user_list; |
|
|
+ foreach my $user (@users) { |
|
|
+ if ($user_list) { |
|
|
+ $user_list .= "," . $user; |
|
|
+ } else { |
|
|
+ $user_list = $user; |
|
|
+ } |
|
|
+ } |
|
|
+ |
|
|
+ # Update Database |
|
|
+ # =============== |
|
|
+ |
|
|
+ if (my $acct = $AccountsDB->get($name)) { |
|
|
+ if ($acct->prop('type') eq 'trac') { |
|
|
+ |
|
|
+ $acct->merge_props( |
|
|
+ Description => $fm->cgi->param('tracDescription'), |
|
|
+ Repository => $fm->cgi->param('tracRepository'), |
|
|
+ RepositoryPath => $fm->cgi->param('tracRepositoryPath'), |
|
|
+ Domains => $domain_list, |
|
|
+ Groups => $group_list, |
|
|
+ Users => $user_list, |
|
|
+ Access => $fm->cgi->param('tracAccess'), |
|
|
+ type => 'trac', |
|
|
+ ); |
|
|
+ |
|
|
+ # Untaint $name before use in system() |
|
|
+ $name =~ /(.+)/; $name = $1; |
|
|
+ |
|
|
+ $fm->clear_params(); |
|
|
+ |
|
|
+ if (system ("/sbin/e-smith/signal-event", "trac-project-modify", $name) == 0) |
|
|
+ { |
|
|
+ $fm->success("SUCCESSFULLY_MODIFIED_TRAC_PROJECT"); |
|
|
+ } else { |
|
|
+ $fm->error("ERROR_WHILE_MODIFYING_TRAC_PROJECT"); |
|
|
+ } |
|
|
+ } else { |
|
|
+ $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
+ } |
|
|
+ } else { |
|
|
+ $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
+ } |
|
|
+} |
|
|
+ |
|
|
+=head2 remove_trac_project() |
|
|
+ |
|
|
+Handle the remove event for the trac project environment |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub remove_trac_project { |
|
|
+ |
|
|
+ my $fm = shift; |
|
|
+ |
|
|
+ my $name = $fm->cgi->param('tracName'); |
|
|
+ if (my $acct = $AccountsDB->get($name)) { |
|
|
+ if ($acct->prop('type') eq 'trac') { |
|
|
+ $acct->set_prop('type', 'trac-deleted'); |
|
|
+ |
|
|
+ # Untaint $name before use in system() |
|
|
+ $name =~ /(.+)/; $name = $1; |
|
|
+ if (system ("/sbin/e-smith/signal-event", "trac-project-delete", $name) == 0) { |
|
|
+ $fm ->success("SUCCESSFULLY_DELETED_TRAC_PROJECT"); |
|
|
+ $acct->delete(); |
|
|
+ } else { |
|
|
+ $fm ->error("ERROR_WHILE_DELETING_TRAC_PROJECT"); |
|
|
+ } |
|
|
+ } else { |
|
|
+ $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
+ } |
|
|
+ |
|
|
+ } else { |
|
|
+ $fm->error('CANT_FIND_TRAC_PROJECT'); |
|
|
+ } |
|
|
+ $fm->wherenext('First'); |
|
|
+} |
|
|
+ |
|
|
+=head1 VALIDATION ROUTINES |
|
|
+ |
|
|
+=head2 max_trac_project_name_length() |
|
|
+ |
|
|
+Checks the length of a given trac project environment name against the |
|
|
+maximum set in the maxTracNameLength record of the configuration database. |
|
|
+Defaults to a maximum length of $self->{defaultMaxLength} if nothing is |
|
|
+set in the config db. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub max_trac_project_name_length { |
|
|
+ my ($fm, $data) = @_; |
|
|
+ |
|
|
+ $ConfigDB->reload(); |
|
|
+ my $max; |
|
|
+ if (my $max_record = $ConfigDB->get('maxTracNameLength')) { |
|
|
+ $max = $max_record->value(); |
|
|
+ } |
|
|
+ |
|
|
+ if (length($data) <= $max) { |
|
|
+ return "OK"; |
|
|
+ } else { |
|
|
+ return $fm->localise("MAX_TRAC_NAME_LENGTH_ERROR", |
|
|
+ {acctName => $data, |
|
|
+ maxRepositoryNameLength => $max, |
|
|
+ maxLength => $max}); |
|
|
+ } |
|
|
+} |
|
|
+ |
|
|
+=head2 getExtraParams() |
|
|
+ |
|
|
+Sets variables used in the lexicon to their required values. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub getExtraParams { |
|
|
+ |
|
|
+ my $fm = shift; |
|
|
+ my $TracProjectName = $fm->cgi->param('tracName'); |
|
|
+ my $TracProjectDescription = ''; |
|
|
+ my $maxLength = $ConfigDB->get('maxTracNameLength'); |
|
|
+ |
|
|
+ if ($TracProjectName) |
|
|
+ { |
|
|
+ my $TracAccount = $AccountsDB->get($TracProjectName); |
|
|
+ if ($TracAccount) |
|
|
+ { |
|
|
+ $TracProjectDescription = $TracAccount->prop('Description'); |
|
|
+ } |
|
|
+ } |
|
|
+ |
|
|
+ return (name => $TracProjectName, |
|
|
+ description => $TracProjectDescription, |
|
|
+ maxLength => $maxLength); |
|
|
+} |
|
|
+ |
|
|
+=head2 validate_name() |
|
|
+ |
|
|
+Checks that the name supplied does not contain any unacceptable chars. |
|
|
+Returns OK on success or a localised error message otherwise. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub validate_name { |
|
|
+ |
|
|
+ my ($fm, $tracName) = @_; |
|
|
+ |
|
|
+ unless ($tracName =~ /^([a-z][\_\.\-a-z0-9]*)$/) |
|
|
+ { |
|
|
+ return $fm->localise('TRAC_PROJECT_NAME_HAS_INVALID_CHARS', {tracName => $tracName}); |
|
|
+ } |
|
|
+ |
|
|
+ return "OK"; |
|
|
+} |
|
|
+ |
|
|
+=head2 conflict_check() |
|
|
+ |
|
|
+Check the proposed name for clashes with existing pseudonyms or other |
|
|
+accounts of any type. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub conflict_check { |
|
|
+ |
|
|
+ my ($fm, $name) = @_; |
|
|
+ my $rec = $AccountsDB->get($name); |
|
|
+ |
|
|
+ my $type; |
|
|
+ if (defined $rec) |
|
|
+ { |
|
|
+ my $type = $rec->prop('type'); |
|
|
+ if ($type eq "pseudonym") |
|
|
+ { |
|
|
+ my $acct = $rec->prop("Account"); |
|
|
+ my $acct_type = $AccountsDB->get($acct)->prop('type'); |
|
|
+ |
|
|
+ return $fm->localise('ACCT_CLASHES_WITH_PSEUDONYM', |
|
|
+ {acctName => $name, acctType => $acct_type, acct => $acct}); |
|
|
+ } |
|
|
+ } |
|
|
+ elsif (defined getpwnam($name) || defined getgrnam($name)) |
|
|
+ { |
|
|
+ $type = 'system'; |
|
|
+ } |
|
|
+ else |
|
|
+ { |
|
|
+ # No account record and no account |
|
|
+ return 'OK'; |
|
|
+ } |
|
|
+ return $fm->localise('ACCOUNT_EXISTS', |
|
|
+ {acctName => $name, acctType => $type}); |
|
|
+} |
|
|
+ |
|
|
+=head2 validate_trac_has_domains() |
|
|
+ |
|
|
+Validates that the cgi parameter DOMAINS is an array with at least one entry |
|
|
+Returns OK if true. Otherwise, returns NO_DOMAINS |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub validate_trac_has_domains { |
|
|
+ |
|
|
+ my $fm = shift; |
|
|
+ my @domains = @_; |
|
|
+ |
|
|
+ my $count = @domains; |
|
|
+ |
|
|
+ if ( $count == 0 ) { |
|
|
+ return ('NO_DOMAINS'); |
|
|
+ } |
|
|
+ else { |
|
|
+ return ('OK'); |
|
|
+ } |
|
|
+} |
|
|
+ |
|
|
+=head2 clear_params() |
|
|
+ |
|
|
+This method clears-out the parameters used in form submission so that they are |
|
|
+not inadvertenly picked-up where they should not be. |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+sub clear_params { |
|
|
+ |
|
|
+ my $fm = shift; |
|
|
+ my $q = $fm->{cgi}; |
|
|
+ |
|
|
+ # Don't delete tracName here as we need in the next page for |
|
|
+ # status messages. |
|
|
+ |
|
|
+ $q->delete('tracDescription'); |
|
|
+ $q->delete('tracRepository'); |
|
|
+ $q->delete('tracRepositoryPath'); |
|
|
+ $q->delete('tracDomains'); |
|
|
+ $q->delete('tracGroups'); |
|
|
+ $q->delete('tracUsers'); |
|
|
+ $q->delete('tracAccess'); |
|
|
+ |
|
|
+} |
|
|
+ |
|
|
+1; |
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/es/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/es/etc/e-smith/web/functions/trac 2008-04-26 16:43:13.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Repositorio</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Ruta</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>Ver Proyecto Trac</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/sv/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/sv/etc/e-smith/web/functions/trac 2008-04-26 16:46:30.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Förråd</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Sökväg</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>Visa Trac-projekt</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/de/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/de/etc/e-smith/web/functions/trac 2008-04-26 16:42:09.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Repository</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Pfad</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>Trac Projekt ansehen</trans> |
|
|
</entry> |
|
31 |
|
|
32 |
--- smeserver-trac-0.4/root/etc/e-smith/locale/id/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
print $q->start_table({-class => 'sme-noborder'}), "\n"; |
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/id/etc/e-smith/web/functions/trac 2008-04-26 16:44:24.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Repository</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Path</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>View Trac Project</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/pt_BR/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/pt_BR/etc/e-smith/web/functions/trac 2008-04-26 16:45:37.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Repositório</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Caminho</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>Ver Projeto Trac</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/sl/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/sl/etc/e-smith/web/functions/trac 2008-04-26 16:46:07.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Repository</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Path</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>View Trac Project</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/trac 2008-04-26 16:43:34.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
33 |
|
|
34 |
<entry> |
@@ -417,7 +417,7 @@ |
35 |
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
$out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAINS_DESCRIPTION') . "</td>"; |
36 |
+ <base>REPOSITORY</base> |
$out .= " </tr>\n"; |
37 |
<trans>Entrepôt</trans> |
$out .= " <tr>\n"; |
38 |
</entry> |
- $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAINS') . "</td>\n"; |
39 |
|
+ $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('DOMAINS') . "</td>\n"; |
40 |
<entry> |
$out .= " <td>\n"; |
41 |
- <base>TRAC_TABLE_HEADER_PATH</base> |
$out .= " <table border='0' cellspacing='0' cellpadding='0'>\n"; |
42 |
+ <base>PATH</base> |
$out .= " <tr>\n"; |
43 |
<trans>Sentier</trans> |
@@ -454,7 +454,7 @@ |
44 |
</entry> |
$out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAIN_DESCRIPTION') . "</td>"; |
45 |
|
$out .= " </tr>\n"; |
46 |
@@ -181,7 +181,7 @@ |
$out .= " <tr>\n"; |
47 |
</entry> |
- $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAIN') . "</td>\n"; |
48 |
|
+ $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('DOMAIN') . "</td>\n"; |
49 |
<entry> |
$out .= " <td><input type=\"hidden\" name=\"tracDomains\" value=\"" . $domainname . "\">"; |
50 |
- <base>TRAC_ACTION_VIEW</base> |
$out .= $domainname . "</td>\n"; |
51 |
+ <base>VIEW</base> |
$out .= " </tr>\n"; |
52 |
<trans>Vue</trans> |
--- smeserver-trac-0.4/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/trac.add2general 2008-04-26 09:18:47.000000000 -0600 |
53 |
</entry> |
+++ smeserver-trac-0.4/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/trac 2008-04-26 09:14:48.000000000 -0600 |
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/nl/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/nl/etc/e-smith/web/functions/trac 2008-04-26 16:45:14.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Subversion bewaarplaats</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Pad</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>Bekijk Trac project</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/hu/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/hu/etc/e-smith/web/functions/trac 2008-04-26 16:43:59.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Repository</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Path</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>View Trac Project</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/el/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/el/etc/e-smith/web/functions/trac 2008-04-26 16:42:47.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Repository</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Path</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>View Trac Project</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/trac 2008-04-26 16:39:18.000000000 +0200 |
|
54 |
@@ -129,20 +129,6 @@ |
@@ -129,20 +129,6 @@ |
55 |
</entry> |
</entry> |
56 |
|
|
210 |
- |
- |
211 |
</lexicon> |
</lexicon> |
212 |
|
|
213 |
--- smeserver-trac-0.4/root/etc/e-smith/locale/it/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
--- smeserver-trac-0.4/root/etc/e-smith/web/functions/trac.add2general 2008-04-26 09:18:47.000000000 -0600 |
214 |
+++ smeserver-trac-0.4/root/etc/e-smith/locale/it/etc/e-smith/web/functions/trac 2008-04-26 16:44:51.000000000 +0200 |
+++ smeserver-trac-0.4/root/etc/e-smith/web/functions/trac 2008-04-26 09:14:48.000000000 -0600 |
215 |
@@ -161,12 +161,12 @@ |
@@ -103,7 +103,7 @@ |
216 |
</entry> |
type="text" |
217 |
|
id="tracDescription" |
218 |
<entry> |
validation="validate_description"> |
219 |
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
- <label>TRAC_FIELD_PROJECT_DESCRIPTION</label> |
220 |
+ <base>REPOSITORY</base> |
+ <label>DESCRIPTION</label> |
221 |
<trans>Repository</trans> |
</field> |
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Path</trans> |
|
|
</entry> |
|
|
|
|
|
@@ -181,7 +181,7 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>View Trac Project</trans> |
|
|
</entry> |
|
|
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/locale/da/etc/e-smith/web/functions/trac.add2general 2008-04-26 16:17:44.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/locale/da/etc/e-smith/web/functions/trac 2008-04-26 16:40:46.000000000 +0200 |
|
|
@@ -161,12 +161,12 @@ |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_REPOSITORY</base> |
|
|
+ <base>REPOSITORY</base> |
|
|
<trans>Lager(repository)</trans> |
|
|
</entry> |
|
|
|
|
|
<entry> |
|
|
- <base>TRAC_TABLE_HEADER_PATH</base> |
|
|
+ <base>PATH</base> |
|
|
<trans>Sti</trans> |
|
|
</entry> |
|
222 |
|
|
223 |
@@ -181,7 +181,7 @@ |
<field |
224 |
</entry> |
@@ -168,7 +168,7 @@ |
225 |
|
type="text" |
226 |
|
id="tracDescription" |
227 |
|
validation="validate_description"> |
228 |
|
- <label>TRAC_FIELD_PROJECT_DESCRIPTION</label> |
229 |
|
+ <label>DESCRIPTION</label> |
230 |
|
</field> |
231 |
|
|
|
<entry> |
|
|
- <base>TRAC_ACTION_VIEW</base> |
|
|
+ <base>VIEW</base> |
|
|
<trans>Vis Trac projekt</trans> |
|
|
</entry> |
|
232 |
|
|
|
--- smeserver-trac-0.4/root/etc/e-smith/web/functions/trac.add2general 2007-04-27 04:42:10.000000000 +0200 |
|
|
+++ smeserver-trac-0.4/root/etc/e-smith/web/functions/trac 2008-04-26 16:30:23.000000000 +0200 |
|
|
@@ -1,235 +1,235 @@ |
|
|
-#!/usr/bin/perl -wT |
|
|
-# vim: ft=xml: |
|
|
-# $Id: trac 69 2007-03-25 13:20:24Z marco $ |
|
|
- |
|
|
-#---------------------------------------------------------------------- |
|
|
-# heading : Collaboration |
|
|
-# description : TRAC_NAVIGATION_DESCRIPTION |
|
|
-# navigation : 2650 2650 |
|
|
-#---------------------------------------------------------------------- |
|
|
- |
|
|
-use strict; |
|
|
-use warnings; |
|
|
-use esmith::FormMagick::Panel::trac; |
|
|
-my $f = esmith::FormMagick::Panel::trac->new(); |
|
|
-$f->display(); |
|
|
- |
|
|
-=pod |
|
|
- |
|
|
-=head1 NAME |
|
|
- |
|
|
-Trac project environment -- add/remove/manage trac project environments |
|
|
- |
|
|
-=head2 DESCRIPTION |
|
|
- |
|
|
-This screen allows the administrator to manage Trac environments for the subversion repositories. |
|
|
- |
|
|
-=begin testing |
|
|
- |
|
|
-use esmith::FormMagick::Tester; |
|
|
-use esmith::TestUtils; |
|
|
-use esmith::TestUtils; |
|
|
-use esmith::ConfigDB; |
|
|
-use esmith::AccountsDB; |
|
|
-my $panel = $Original_File; |
|
|
-my $ua = esmith::FormMagick::Tester->new(); |
|
|
- |
|
|
-my $c = esmith::ConfigDB->open(); |
|
|
-my $a = esmith::AccountsDB->open(); |
|
|
- |
|
|
-is (mode($panel), '4750', "Check permissions on script"); |
|
|
-ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS"); |
|
|
-is ($ua->{status}, 200, "200 OK"); |
|
|
-like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title"); |
|
|
-ok ($ua->set_language("en"), "Set language to English"); |
|
|
-ok ($ua->get_panel($panel), "Get panel"); |
|
|
-is ($ua->{status}, 200, "200 OK"); |
|
|
- |
|
|
-ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING TRAC ENVIRONMENT"); |
|
|
-ok ($ua->follow("Click here"), "Follow 'create repository' link"); |
|
|
-is ($ua->{status}, 200, "200 OK"); |
|
|
-like($ua->{content}, qr/Create a new Trac environment/, "Saw page title"); |
|
|
-like($ua->{content}, qr/Brief description/, "Saw description field"); |
|
|
-like($ua->{content}, qr/Add/, "Saw add button"); |
|
|
- |
|
|
-SKIP: { |
|
|
- |
|
|
- skip 10, "Unsafe!" unless destruction_ok(); |
|
|
- |
|
|
- ok ($ua->follow("Click here"), "ACTUALLY ADDING A TRAC ENVIRONMENT"); |
|
|
- $ua->field(); |
|
|
- $ua->click("Add"); |
|
|
- like($ua->{content}, qr/Successfully added Trac environment/, "Saw success message"); |
|
|
- |
|
|
- ok ($ua->follow("Remove"), "REMOVING TRAC ENVIRONMENT"); |
|
|
- like($ua->{content}, qr/Are you sure/, "Saw confirmation message"); |
|
|
- $ua->click("Remove"); |
|
|
- like($ua->{content}, qr/Successfully deleted/, "Saw success message"); |
|
|
-} |
|
|
- |
|
|
-=end testing |
|
|
- |
|
|
-=cut |
|
|
- |
|
|
-__DATA__ |
|
|
-<form |
|
|
- title="TRAC_FORM_TITLE" |
|
|
- header="/etc/e-smith/web/common/head.tmpl" |
|
|
- footer="/etc/e-smith/web/common/foot.tmpl"> |
|
|
- |
|
|
- <!-- page 0 --> |
|
|
- <page |
|
|
- name="First" |
|
|
- pre-event="print_status_message()"> |
|
|
- |
|
|
- <description>TRAC_FORM_DESCRIPTION</description> |
|
|
- |
|
|
- <subroutine src="show_trac_projects()" /> |
|
|
- </page> |
|
|
- |
|
|
- <!-- page 1 --> |
|
|
- <page |
|
|
- name="Create" |
|
|
- pre-event="turn_off_buttons()" |
|
|
- post-event="handle_trac_projects()"> |
|
|
- |
|
|
- <title>TRAC_FORM_ADD_TITLE</title> |
|
|
- |
|
|
- <description>TRAC_FORM_ADD_DESCRIPTION</description> |
|
|
- |
|
|
- <subroutine src="print_trac_field_name()" /> |
|
|
- |
|
|
- <field |
|
|
- type="text" |
|
|
- id="tracDescription" |
|
|
- validation="validate_description"> |
|
|
- <label>TRAC_FIELD_PROJECT_DESCRIPTION</label> |
|
|
- </field> |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracRepository" |
|
|
- options="repositories_list()"> |
|
|
- <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_REPOSITORY_NAME</label> |
|
|
- </field> |
|
|
- |
|
|
- <field |
|
|
- type="text" |
|
|
- id="tracRepositoryPath"> |
|
|
- <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_REPOSITORY_PATH</label> |
|
|
- </field> |
|
|
- |
|
|
- <subroutine src="print_trac_domains()" /> |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracAccess" |
|
|
- options="'local' => 'LOCAL', |
|
|
- 'global' => 'GLOBAL'" |
|
|
- value='local'> |
|
|
- <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_ACCESS_TYPE</label> |
|
|
- </field> |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracGroups" |
|
|
- options="group_list()" |
|
|
- multiple="1" size="5"> |
|
|
- <description>TRAC_FIELD_GROUPS_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_GROUPS</label> |
|
|
- </field> |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracUsers" |
|
|
- options="user_list()" |
|
|
- multiple="1" size="5"> |
|
|
- <label>TRAC_FIELD_USERS</label> |
|
|
- </field> |
|
|
- |
|
|
- <subroutine src="print_save_or_add_button()" /> |
|
|
- </page> |
|
|
- |
|
|
- <!-- page 2 --> |
|
|
- <page |
|
|
- name="Modify" |
|
|
- pre-event="turn_off_buttons()" |
|
|
- post-event="handle_trac_projects()"> |
|
|
- |
|
|
- <title>TRAC_FORM_MODIFY_TITLE</title> |
|
|
- <description>TRAC_FORM_MODIFY_DESCRIPTION</description> |
|
|
- |
|
|
- <subroutine src="print_trac_field_name()" /> |
|
|
- |
|
|
- <field |
|
|
- type="text" |
|
|
- id="tracDescription" |
|
|
- validation="validate_description"> |
|
|
- <label>TRAC_FIELD_PROJECT_DESCRIPTION</label> |
|
|
- </field> |
|
|
- |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracRepository" |
|
|
- options="repositories_list()"> |
|
|
- <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_REPOSITORY_NAME</label> |
|
|
- </field> |
|
|
- |
|
|
- <field |
|
|
- type="text" |
|
|
- id="tracRepositoryPath"> |
|
|
- <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_REPOSITORY_PATH</label> |
|
|
- </field> |
|
|
- |
|
|
- <subroutine src="print_trac_domains()" /> |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracAccess" |
|
|
- options="'local' => 'LOCAL', |
|
|
- 'global' => 'GLOBAL'"> |
|
|
- <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_ACCESS_TYPE</label> |
|
|
- </field> |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracGroups" |
|
|
- options="group_list()" |
|
|
- multiple="1" size="5"> |
|
|
- <description>TRAC_FIELD_GROUPS_DESCRIPTION</description> |
|
|
- <label>TRAC_FIELD_GROUPS</label> |
|
|
- </field> |
|
|
- |
|
|
- <field |
|
|
- type="select" |
|
|
- id="tracUsers" |
|
|
- options="user_list()" |
|
|
- multiple="1" size="5"> |
|
|
- <label>TRAC_FIELD_USERS</label> |
|
|
- </field> |
|
|
- |
|
|
- <subroutine src="print_save_or_add_button()" /> |
|
|
- |
|
|
- </page> |
|
|
- |
|
|
- <!-- page 3 --> |
|
|
- <page |
|
|
- name="Remove" |
|
|
- pre-event="turn_off_buttons()" |
|
|
- post-event="remove_trac_project()"> |
|
|
- |
|
|
- <title>TRAC_FORM_REMOVE_TITLE</title> |
|
|
- <description>TRAC_FORM_REMOVE_DESCRIPTION</description> |
|
|
- |
|
|
- <subroutine src="print_button('REMOVE')" /> |
|
|
- |
|
|
- </page> |
|
|
- |
|
|
-</form> |
|
|
+#!/usr/bin/perl -wT |
|
|
+# vim: ft=xml: |
|
|
+# $Id: trac 69 2007-03-25 13:20:24Z marco $ |
|
|
+ |
|
|
+#---------------------------------------------------------------------- |
|
|
+# heading : Collaboration |
|
|
+# description : TRAC_NAVIGATION_DESCRIPTION |
|
|
+# navigation : 2650 2650 |
|
|
+#---------------------------------------------------------------------- |
|
|
+ |
|
|
+use strict; |
|
|
+use warnings; |
|
|
+use esmith::FormMagick::Panel::trac; |
|
|
+my $f = esmith::FormMagick::Panel::trac->new(); |
|
|
+$f->display(); |
|
|
+ |
|
|
+=pod |
|
|
+ |
|
|
+=head1 NAME |
|
|
+ |
|
|
+Trac project environment -- add/remove/manage trac project environments |
|
|
+ |
|
|
+=head2 DESCRIPTION |
|
|
+ |
|
|
+This screen allows the administrator to manage Trac environments for the subversion repositories. |
|
|
+ |
|
|
+=begin testing |
|
|
+ |
|
|
+use esmith::FormMagick::Tester; |
|
|
+use esmith::TestUtils; |
|
|
+use esmith::TestUtils; |
|
|
+use esmith::ConfigDB; |
|
|
+use esmith::AccountsDB; |
|
|
+my $panel = $Original_File; |
|
|
+my $ua = esmith::FormMagick::Tester->new(); |
|
|
+ |
|
|
+my $c = esmith::ConfigDB->open(); |
|
|
+my $a = esmith::AccountsDB->open(); |
|
|
+ |
|
|
+is (mode($panel), '4750', "Check permissions on script"); |
|
|
+ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS"); |
|
|
+is ($ua->{status}, 200, "200 OK"); |
|
|
+like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title"); |
|
|
+ok ($ua->set_language("en"), "Set language to English"); |
|
|
+ok ($ua->get_panel($panel), "Get panel"); |
|
|
+is ($ua->{status}, 200, "200 OK"); |
|
|
+ |
|
|
+ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING TRAC ENVIRONMENT"); |
|
|
+ok ($ua->follow("Click here"), "Follow 'create repository' link"); |
|
|
+is ($ua->{status}, 200, "200 OK"); |
|
|
+like($ua->{content}, qr/Create a new Trac environment/, "Saw page title"); |
|
|
+like($ua->{content}, qr/Brief description/, "Saw description field"); |
|
|
+like($ua->{content}, qr/Add/, "Saw add button"); |
|
|
+ |
|
|
+SKIP: { |
|
|
+ |
|
|
+ skip 10, "Unsafe!" unless destruction_ok(); |
|
|
+ |
|
|
+ ok ($ua->follow("Click here"), "ACTUALLY ADDING A TRAC ENVIRONMENT"); |
|
|
+ $ua->field(); |
|
|
+ $ua->click("Add"); |
|
|
+ like($ua->{content}, qr/Successfully added Trac environment/, "Saw success message"); |
|
|
+ |
|
|
+ ok ($ua->follow("Remove"), "REMOVING TRAC ENVIRONMENT"); |
|
|
+ like($ua->{content}, qr/Are you sure/, "Saw confirmation message"); |
|
|
+ $ua->click("Remove"); |
|
|
+ like($ua->{content}, qr/Successfully deleted/, "Saw success message"); |
|
|
+} |
|
|
+ |
|
|
+=end testing |
|
|
+ |
|
|
+=cut |
|
|
+ |
|
|
+__DATA__ |
|
|
+<form |
|
|
+ title="TRAC_FORM_TITLE" |
|
|
+ header="/etc/e-smith/web/common/head.tmpl" |
|
|
+ footer="/etc/e-smith/web/common/foot.tmpl"> |
|
|
+ |
|
|
+ <!-- page 0 --> |
|
|
+ <page |
|
|
+ name="First" |
|
|
+ pre-event="print_status_message()"> |
|
|
+ |
|
|
+ <description>TRAC_FORM_DESCRIPTION</description> |
|
|
+ |
|
|
+ <subroutine src="show_trac_projects()" /> |
|
|
+ </page> |
|
|
+ |
|
|
+ <!-- page 1 --> |
|
|
+ <page |
|
|
+ name="Create" |
|
|
+ pre-event="turn_off_buttons()" |
|
|
+ post-event="handle_trac_projects()"> |
|
|
+ |
|
|
+ <title>TRAC_FORM_ADD_TITLE</title> |
|
|
+ |
|
|
+ <description>TRAC_FORM_ADD_DESCRIPTION</description> |
|
|
+ |
|
|
+ <subroutine src="print_trac_field_name()" /> |
|
|
+ |
|
|
+ <field |
|
|
+ type="text" |
|
|
+ id="tracDescription" |
|
|
+ validation="validate_description"> |
|
|
+ <label>DESCRIPTION</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracRepository" |
|
|
+ options="repositories_list()"> |
|
|
+ <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_REPOSITORY_NAME</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="text" |
|
|
+ id="tracRepositoryPath"> |
|
|
+ <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_REPOSITORY_PATH</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <subroutine src="print_trac_domains()" /> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracAccess" |
|
|
+ options="'local' => 'LOCAL', |
|
|
+ 'global' => 'GLOBAL'" |
|
|
+ value='local'> |
|
|
+ <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_ACCESS_TYPE</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracGroups" |
|
|
+ options="group_list()" |
|
|
+ multiple="1" size="5"> |
|
|
+ <description>TRAC_FIELD_GROUPS_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_GROUPS</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracUsers" |
|
|
+ options="user_list()" |
|
|
+ multiple="1" size="5"> |
|
|
+ <label>TRAC_FIELD_USERS</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <subroutine src="print_save_or_add_button()" /> |
|
|
+ </page> |
|
|
+ |
|
|
+ <!-- page 2 --> |
|
|
+ <page |
|
|
+ name="Modify" |
|
|
+ pre-event="turn_off_buttons()" |
|
|
+ post-event="handle_trac_projects()"> |
|
|
+ |
|
|
+ <title>TRAC_FORM_MODIFY_TITLE</title> |
|
|
+ <description>TRAC_FORM_MODIFY_DESCRIPTION</description> |
|
|
+ |
|
|
+ <subroutine src="print_trac_field_name()" /> |
|
|
+ |
|
|
+ <field |
|
|
+ type="text" |
|
|
+ id="tracDescription" |
|
|
+ validation="validate_description"> |
|
|
+ <label>DESCRIPTION</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracRepository" |
|
|
+ options="repositories_list()"> |
|
|
+ <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_REPOSITORY_NAME</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="text" |
|
|
+ id="tracRepositoryPath"> |
|
|
+ <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_REPOSITORY_PATH</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <subroutine src="print_trac_domains()" /> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracAccess" |
|
|
+ options="'local' => 'LOCAL', |
|
|
+ 'global' => 'GLOBAL'"> |
|
|
+ <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_ACCESS_TYPE</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracGroups" |
|
|
+ options="group_list()" |
|
|
+ multiple="1" size="5"> |
|
|
+ <description>TRAC_FIELD_GROUPS_DESCRIPTION</description> |
|
|
+ <label>TRAC_FIELD_GROUPS</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <field |
|
|
+ type="select" |
|
|
+ id="tracUsers" |
|
|
+ options="user_list()" |
|
|
+ multiple="1" size="5"> |
|
|
+ <label>TRAC_FIELD_USERS</label> |
|
|
+ </field> |
|
|
+ |
|
|
+ <subroutine src="print_save_or_add_button()" /> |
|
|
+ |
|
|
+ </page> |
|
|
+ |
|
|
+ <!-- page 3 --> |
|
|
+ <page |
|
|
+ name="Remove" |
|
|
+ pre-event="turn_off_buttons()" |
|
|
+ post-event="remove_trac_project()"> |
|
|
+ |
|
|
+ <title>TRAC_FORM_REMOVE_TITLE</title> |
|
|
+ <description>TRAC_FORM_REMOVE_DESCRIPTION</description> |
|
|
+ |
|
|
+ <subroutine src="print_button('REMOVE')" /> |
|
|
+ |
|
|
+ </page> |
|
|
+ |
|
|
+</form> |
|