/[smecontribs]/rpms/smeserver-trac/contribs7/smeserver-trac-0.4-newlines.patch
ViewVC logotype

Contents of /rpms/smeserver-trac/contribs7/smeserver-trac-0.4-newlines.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Tue Nov 25 16:20:32 2008 UTC (15 years, 11 months ago) by slords
Branch: MAIN
CVS Tags: smeserver-trac-0_4-58_el4_sme, smeserver-trac-0_4-56_el4_sme, smeserver-trac-0_4-55_el4_sme, smeserver-trac-0_4-67_el4_sme, smeserver-trac-0_4-54_el4_sme, smeserver-trac-0_4-52_el4_sme, smeserver-trac-0_4-57_el4_sme, smeserver-trac-0_4-64_el4_sme, smeserver-trac-0_4-63_el4_sme, smeserver-trac-0_4-66_el4_sme, HEAD
Changes since 1.2: +0 -0 lines
Restore

1 --- smeserver-trac-0.4/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/trac.pm.newlines 2007-04-27 00:54:46.000000000 -0600
2 +++ smeserver-trac-0.4/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/trac.pm 2008-04-26 09:16:34.000000000 -0600
3 @@ -1,954 +1,954 @@
4 -#!/usr/bin/perl -w
5 -#----------------------------------------------------------------------
6 -# $Id: trac.pm 69 2007-03-25 13:20:24Z marco $
7 -# vim: ft=perl ts=4 sw=4 et:
8 -#----------------------------------------------------------------------
9 -# Copyright (C) 2007 Marco Hess
10 -#
11 -# This program is free software; you can redistribute it and/or modify
12 -# it under the terms of the GNU General Public License as published by
13 -# the Free Software Foundation; either version 2 of the License, or
14 -# (at your option) any later version.
15 -#
16 -# This program is distributed in the hope that it will be useful,
17 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
18 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 -# GNU General Public License for more details.
20 -#
21 -# You should have received a copy of the GNU General Public License
22 -# along with this program; if not, write to the Free Software
23 -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 -#----------------------------------------------------------------------
25 -
26 -package esmith::FormMagick::Panel::trac;
27 -
28 -use strict;
29 -use warnings;
30 -
31 -use esmith::FormMagick;
32 -use esmith::AccountsDB;
33 -use esmith::ConfigDB;
34 -use esmith::DomainsDB;
35 -use esmith::cgi;
36 -use esmith::util;
37 -use File::Basename;
38 -use Exporter;
39 -use Carp;
40 -use Sys::Syslog;
41 -
42 -use constant TRUE => 1;
43 -use constant FALSE => 0;
44 -
45 -our @ISA = qw(esmith::FormMagick Exporter);
46 -
47 -our @EXPORT = qw(
48 - show_trac_projects
49 - print_trac_field_name
50 - repositories_list
51 - group_list
52 - user_list
53 - max_trac_project_name_length
54 - handle_trac_projects
55 - create_trac_project
56 - remove_trac_project
57 - getExtraParams
58 - print_save_or_add_button
59 - validate_name
60 - validate_radio
61 - wherenext
62 - maxLength
63 -);
64 -
65 -our $ConfigDB = esmith::ConfigDB->open
66 - or die "Can't open the Config database : $!\n" ;
67 -
68 -our $AccountsDB = esmith::AccountsDB->open
69 - or die "Can't open the Account database : $!\n" ;
70 -
71 -our $DomainsDB = esmith::DomainsDB->open
72 - or die "Can't open the Domains database : $!\n" ;
73 -
74 -
75 -# fields and records separator for sub records
76 -use constant FS => "," ;
77 -use constant RS => ";" ;
78 -
79 -=pod
80 -
81 -=head1 NAME
82 -
83 -esmith::FormMagick::Panels::trac - Trac
84 -
85 -=head1 SYNOPSIS
86 -
87 -use esmith::FormMagick::Panels::trac
88 -
89 -my $panel = esmith::FormMagick::Panel::trac->new();
90 -$panel->display();
91 -
92 -=head1 DESCRIPTION
93 -
94 -This module is the backend to the Trac panel, responsible
95 -for supplying all functions used by that panel. It is a subclass
96 -of esmith::FormMagick itself, so it inherits the functionality
97 -of a FormMagick object.
98 -
99 -=cut
100 -
101 -=head2 new()
102 -
103 -Exactly as for esmith::FormMagick
104 -
105 -=cut
106 -
107 -sub new
108 -{
109 - my $proto = shift;
110 - my $class = ref($proto) || $proto;
111 - my $self = esmith::FormMagick::new($class);
112 - $self->{calling_package} = (caller)[0];
113 -
114 - return $self;
115 -}
116 -
117 -=head1 HTML GENERATION ROUTINES
118 -
119 -Routines for generating chunks of HTML needed by the panel.
120 -
121 -=cut
122 -
123 -=head2 show_trac_projects()
124 -
125 -This function displays a table of trac project environments on the system
126 -including the links to modify and remove the trac project environment.
127 -
128 -=cut
129 -
130 -sub show_trac_projects {
131 - my $fm = shift;
132 - my $q = $fm->{cgi};
133 -
134 - # Setup the various localised text field for the trac project table
135 - my $name = $fm->localise('TRAC_TABLE_HEADER_NAME');
136 - my $description = $fm->localise('TRAC_TABLE_HEADER_DESCRIPTION');
137 - my $domains = $fm->localise('TRAC_TABLE_HEADER_DOMAINS');
138 - my $repository = $fm->localise('TRAC_TABLE_HEADER_REPOSITORY');
139 - my $path = $fm->localise('TRAC_TABLE_HEADER_PATH');
140 - my $access = $fm->localise('TRAC_TABLE_HEADER_ACCESS');
141 - my $action_h = $fm->localise('TRAC_TABLE_HEADER_ACTION');
142 - my $view = $fm->localise('TRAC_ACTION_VIEW');
143 - my $modify = $fm->localise('TRAC_ACTION_MODIFY');
144 - my $remove = $fm->localise('TRAC_ACTION_REMOVE');
145 - my $backup = $fm->localise('TRAC_ACTION_BACKUP');
146 - my $restore = $fm->localise('TRAC_ACTION_RESTORE');
147 -
148 - print $q->start_table({-class => 'sme-noborder'}), "\n";
149 -
150 - # Check if any repositories exist
151 - my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository');
152 - unless ( scalar @repositories )
153 - {
154 - print $q->Tr($q->td($q->h2($fm->localise('NO_REPOSITORIES'))));
155 - return "";
156 - }
157 -
158 - # TODO what about the case that all repositories have been deleted
159 - # but the Trac project environments are still there? Can we remove the
160 - # trac projects or do we need to reassign the projects to
161 - # another repository? The code above prevents us from accessing the
162 - # trac projects when there are no more repositories.
163 -
164 - print $q->Tr($q->td($q->a({-class => "button-like",
165 - href => "trac?page=0&page_stack=&Next=Next&wherenext=Create"},
166 - $fm->localise('TRAC_ADD_BUTTON'))));
167 -
168 - # Check if any trac projects exist
169 - my @TracProjects = $AccountsDB->get_all_by_prop('type' => 'trac');
170 - unless ( scalar @TracProjects )
171 - {
172 - print $q->Tr($q->td($q->h2($fm->localise('NO_TRAC_PROJECTS'))));
173 - return "";
174 - }
175 -
176 - # Show the list of configures trac projects
177 - print $q->Tr($q->td($q->h2($fm->localise('CURRENT_TRAC_PROJECTS'))));
178 -
179 - print $q->Tr($q->td($fm->localise('TRAC_MODIFY_REMOVE_BUTTON_DESCRIPTION')));
180 -
181 - print $q->start_table({-CLASS => "sme-border"}),"\n";
182 - print $q->Tr (
183 - esmith::cgi::genSmallCell($q, $name, "header"),
184 - esmith::cgi::genSmallCell($q, $description,"header"),
185 - esmith::cgi::genSmallCell($q, $domains, "header"),
186 - esmith::cgi::genSmallCell($q, $repository, "header"),
187 - esmith::cgi::genSmallCell($q, $path, "header"),
188 - esmith::cgi::genSmallCell($q, $access, "header"),
189 - esmith::cgi::genSmallCell($q, $action_h, "header", 3)),"\n";
190 -
191 - my $scriptname = basename($0);
192 -
193 - foreach my $TracProject (@TracProjects)
194 - {
195 - my $trac_name = $TracProject->key();
196 - my $trac_desc = $TracProject->prop('Description');
197 - my $trac_domains = join("<br>", split(FS, $TracProject->prop('Domains')));
198 - my $trac_repo = $TracProject->prop('Repository');
199 - my $trac_path = $TracProject->prop('RepositoryPath');
200 - my $trac_access = $TracProject->prop('Access') || 'local';
201 - my $modifiable = $TracProject->prop('Modifiable') || 'yes';
202 - my $removable = $TracProject->prop('Removable') || 'yes';
203 -
204 - my $params = $fm->build_trac_project_cgi_params($trac_name, $TracProject->props());
205 -
206 - my $href = "$scriptname?$params&action=modify&wherenext=";
207 -
208 - my $actionView = '&nbsp;';
209 - $actionView .= $q->a({href => '/' . $TracProject->key(),
210 - target => '_blank'}, $view ) . '&nbsp;';
211 -
212 - my $actionModify = '&nbsp;';
213 - if ($modifiable eq 'yes')
214 - {
215 - $actionModify .= $q->a({href => "${href}Modify"}, $modify) . '&nbsp;';
216 - }
217 -
218 - my $actionRemove = '&nbsp;';
219 - if ($removable eq 'yes')
220 - {
221 - $actionRemove .= $q->a({href => "${href}Remove"}, $remove) . '&nbsp;';
222 - }
223 -
224 - my $actionBackup = '&nbsp;';
225 - $actionBackup .= $q->a({href => "${href}Backup"}, $backup) . '&nbsp;';
226 -
227 - my $actionRestore = '&nbsp;';
228 - $actionRestore .= $q->a({href => "${href}Restore"}, $restore) . '&nbsp;';
229 -
230 - print $q->Tr(
231 - esmith::cgi::genSmallCell($q, $trac_name, "normal"),
232 - esmith::cgi::genSmallCell($q, $trac_desc, "normal"),
233 - esmith::cgi::genSmallCell($q, $trac_domains, "normal"),
234 - esmith::cgi::genSmallCell($q, $trac_repo, "normal"),
235 - esmith::cgi::genSmallCell($q, $trac_path, "normal"),
236 - esmith::cgi::genSmallCell($q, $trac_access, "normal"),
237 - esmith::cgi::genSmallCell($q, $actionView, "normal"),
238 - esmith::cgi::genSmallCell($q, $actionModify, "normal"),
239 - esmith::cgi::genSmallCell($q, $actionRemove, "normal")
240 - );
241 - }
242 -
243 - print $q->end_table,"\n";
244 -
245 - print $q->end_table,"\n";
246 -
247 - return "";
248 -}
249 -
250 -=cut
251 -
252 -=head2 print_save_or_add_button()
253 -
254 -Prints the ADD button when a new trac project environment is addded and the SAVE buttom
255 -whem modifications are made.
256 -
257 -=cut
258 -
259 -sub print_save_or_add_button {
260 -
261 - my ($fm) = @_;
262 -
263 - my $cgi = $fm->{cgi};
264 -
265 - if (($cgi->param("action") || '') eq "modify") {
266 - $fm->print_button("SAVE");
267 - } else {
268 - $fm->print_button("ADD");
269 - }
270 -}
271 -
272 -=head1 HELPER FUNCTIONS FOR THE PANEL
273 -
274 -Routines for modifying the database and signaling events
275 -from the server-manager panel
276 -
277 -=cut
278 -
279 -=head2 build_trac_project_cgi_params($fm, $tracprojectname, %oldprops)
280 -
281 -Constructs the parameters for the links in the trac project environments table
282 -
283 -=cut
284 -
285 -sub build_trac_project_cgi_params {
286 - my ($self, $tracprojectname, %oldprops) = @_;
287 -
288 - my %props = (
289 - page => 0,
290 - page_stack => "",
291 - tracName => $tracprojectname,
292 - );
293 -
294 - return $self->props_to_query_string(\%props);
295 -}
296 -
297 -*wherenext = \&CGI::FormMagick::wherenext;
298 -
299 -=head2 print_trac_field_name()
300 -
301 -Helper function to print the field NAME so that it becomes
302 -an edit field upon ADD and a fixed field upon MODIFY.
303 -
304 -Also read all the account db values so the other fields
305 -can show the existing values.
306 -
307 -=cut
308 -
309 -sub print_trac_field_name {
310 - my $fm = shift;
311 - my $in = $fm->{cgi}->param('tracName') || '';
312 - my $action = $fm->{cgi}->param('action') || '';
313 -
314 - print qq(<tr><td class="sme-noborders-label">) .
315 - $fm->localise('TRAC_FIELD_PROJECT_NAME') . qq(</td>\n);
316 -
317 - if ($action eq 'modify' and $in) {
318 - #-------------------------------------------------------
319 - # Updating an existing record.
320 - #--------------------------------------------------------
321 -
322 - my $rec = $AccountsDB->get($in);
323 - my $modifiable = $rec->prop('Modifiable') || 'yes';
324 - my $removable = $rec->prop('Removable') || 'yes';
325 -
326 - print qq(
327 - <td class="sme-noborders-content">$in
328 - <input type="hidden" name="tracName" value="$in">
329 - <input type="hidden" name="action" value="modify">
330 - </td>
331 - );
332 -
333 - # Read the values for each field from the accounts db and store
334 - # them in the cgi object so our form will have the correct
335 - # info displayed.
336 - my $q = $fm->{cgi};
337 - if ($rec)
338 - {
339 - $q->param(-name=>'tracDescription',-value=>
340 - $rec->prop('Description'));
341 -
342 - $q->param(-name=>'tracRepository',-value=>
343 - $rec->prop('Repository'));
344 -
345 - $q->param(-name=>'tracRepositoryPath',-value=>
346 - $rec->prop('RepositoryPath'));
347 -
348 - # domain list is handled separately
349 -
350 - $q->param(-name=>'tracGroups',-value=>
351 - join(FS, split(FS, $rec->prop('Groups'))));
352 -
353 - $q->param(-name=>'tracUsers',-value=>
354 - join(FS, split(FS, $rec->prop('Users'))));
355 -
356 - $q->param(-name=>'tracAccess',-value=>
357 - $rec->prop('Access')),
358 - }
359 - } else {
360 - #-------------------------------------------------------
361 - # Adding a new record so allow an entry field for the
362 - # name.
363 - #--------------------------------------------------------
364 - print qq(
365 - <td><input type="text" name="tracName" value="$in">
366 - <input type="hidden" name="action" value="create">
367 - </td>
368 - );
369 - }
370 -
371 - print qq(</tr>\n);
372 - return undef;
373 -}
374 -
375 -
376 -=head2 print_trac_domains()
377 -
378 -When this server has more than one domain this function takes
379 -the list of domains and returns a string of html checkboxes
380 -for all these domains.
381 -
382 -Those domains that are listed with this Trac environment
383 -will have their checkbox checked.
384 -
385 -=cut
386 -
387 -sub print_trac_domains() {
388 -
389 - # Retrieve the Trac account name from the CGI parameters
390 - my $fm = shift;
391 - my $name = $fm->{'cgi'}->param('tracName');
392 - my $action = $fm->{'cgi'}->param("action") || '';
393 - my $out = "";
394 -
395 - # Get a full list of all the domains on this server.
396 - my @domains = $DomainsDB->get_all_by_prop( type => 'domain' );
397 - my $numdomains = @domains;
398 -
399 - # If there is more than one domain, we generate a list
400 - # of checkboxes. Otherwise we just show the primary domain.
401 - if ($numdomains > 1) {
402 -
403 - # With the Trac account name, get the list of the Domains for which
404 - # this Trac account is active.
405 - my $trac_domains_list = "";
406 - if ($AccountsDB->get($name)) {
407 - $trac_domains_list = $AccountsDB->get($name)->prop('Domains');
408 - }
409 -
410 - # Split the comma separated list into the individual bits.
411 - my %trac_domains;
412 - foreach my $trac_domain ( split ( /,/, $trac_domains_list ) ) {
413 - $trac_domains{$trac_domain} = 1;
414 - }
415 -
416 - # Now generate the table of domains with a checkbox in front of it.
417 - # If the domain is in our listed domains for the Trac environment, the
418 - # checkbox will show checked.
419 - $out = " <tr>\n";
420 - $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAINS_DESCRIPTION') . "</td>";
421 - $out .= " </tr>\n";
422 - $out .= " <tr>\n";
423 - $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAINS') . "</td>\n";
424 - $out .= " <td>\n";
425 - $out .= " <table border='0' cellspacing='0' cellpadding='0'>\n";
426 - $out .= " <tr>\n";
427 -
428 - foreach my $domain (sort @domains) {
429 -
430 - # If this is a ADD form, we default check all domains, otherwise only
431 - # those that are in our Trac project list.
432 - my $checked = "";
433 - if ( $action eq 'modify' ) {
434 - if ( $trac_domains{ $domain->key() } ) {
435 - $checked = "checked";
436 - }
437 - } else {
438 - $checked = "checked";
439 - }
440 -
441 - $out .= " <tr>\n";
442 - $out .= " <td><input type=\"checkbox\" name=\"tracDomains\" $checked value=\"" . $domain->key . "\"></td>\n";
443 - $out .= " <td>" . $domain->key . "</td>\n";
444 - $out .= " </tr>\n";
445 - }
446 -
447 - $out .= " </table>\n";
448 - $out .= " </td>\n";
449 - $out .= " </tr>\n";
450 - }
451 - else
452 - {
453 - # We only have a single domain, so we just show this domain but without the
454 - # checkbox (so it can't be unchecked).
455 - my $domainname = $ConfigDB->get('DomainName')->value();
456 - $out = " <tr>\n";
457 - $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAIN_DESCRIPTION') . "</td>";
458 - $out .= " </tr>\n";
459 - $out .= " <tr>\n";
460 - $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAIN') . "</td>\n";
461 - $out .= " <td><input type=\"hidden\" name=\"tracDomains\" value=\"" . $domainname . "\">";
462 - $out .= $domainname . "</td>\n";
463 - $out .= " </tr>\n";
464 - }
465 -
466 - return $out;
467 -}
468 -
469 -
470 -=pod
471 -
472 -=head2 repositories_list()
473 -
474 -Returns a hash of repositories for the Create/Modify screen's repository
475 -field's drop down list.
476 -
477 -=cut
478 -
479 -sub repositories_list
480 -{
481 - my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository');
482 - my %repositories = ();
483 - foreach my $repository (@repositories) {
484 - $repositories{$repository->key()} = $repository->prop('Description') . " (" . $repository->key . ")";
485 - }
486 - return \%repositories;
487 -}
488 -
489 -=head2 group_list()
490 -
491 -Returns a hash of groups for the Create/Modify screen's group
492 -field's drop down list.
493 -
494 -=cut
495 -
496 -sub group_list
497 -{
498 - my @groups = $AccountsDB->groups();
499 - my %groups = ();
500 - foreach my $group (@groups) {
501 - $groups{$group->key()} = $group->prop('Description')." (".$group->key.")";
502 - }
503 - return \%groups;
504 -}
505 -
506 -=head2 user_list()
507 -
508 -Returns a hash of users for the Create/Modify screen's user field's
509 -drop down list.
510 -
511 -=cut
512 -
513 -sub user_list
514 -{
515 - my @users = $AccountsDB->users();
516 - my %users = ();
517 - foreach my $user (@users) {
518 - $users{$user->key()} = $user->prop('LastName').", ". $user->prop('FirstName')." (". $user->key.")";
519 - }
520 - return \%users;
521 -}
522 -
523 -=head1 THE ROUTINES THAT ACTUALLY DO THE WORK
524 -
525 -=cut
526 -
527 -=head2 handle_trac_projects()
528 -
529 -Determine whether to modify or add the trac project environment
530 -
531 -=cut
532 -
533 -sub handle_trac_projects {
534 -
535 - my ($fm) = @_;
536 -
537 - if ($fm->cgi->param("action") eq "create") {
538 - $fm->create_trac_project();
539 - } else {
540 - $fm->modify_trac_project();
541 - }
542 -
543 -}
544 -
545 -=head2 create_trac_project()
546 -
547 -Handle the create event for the trac project environment
548 -
549 -=cut
550 -
551 -sub create_trac_project {
552 -
553 - my ($fm) = @_;
554 -
555 - # Validate Name
556 - # =============
557 -
558 - my $name = $fm->cgi->param('tracName');
559 - my $msg;
560 -
561 - $msg = $fm->validate_name($name);
562 - unless ($msg eq "OK")
563 - {
564 - return $fm->error($msg);
565 - }
566 -
567 - $msg = $fm->max_trac_project_name_length($name);
568 - unless ($msg eq "OK")
569 - {
570 - return $fm->error($msg);
571 - }
572 -
573 - $msg = $fm->conflict_check($name);
574 - unless ($msg eq "OK")
575 - {
576 - return $fm->error($msg);
577 - }
578 -
579 - # Validate & Setup Domain List
580 - # ============================
581 -
582 - my @active_trac_domains = $fm->cgi->param('tracDomains');
583 -
584 - $msg = $fm->validate_trac_has_domains(@active_trac_domains);
585 - unless ($msg eq "OK")
586 - {
587 - return $fm->error($msg);
588 - }
589 -
590 - my $domain_list = "";
591 - foreach my $domain (@active_trac_domains) {
592 - if ($domain_list) {
593 - $domain_list .= "," . $domain;
594 - } else {
595 - $domain_list = $domain;
596 - }
597 - }
598 -
599 - # Setup Group List
600 - # ================
601 -
602 - my @groups = $fm->cgi->param('tracGroups');
603 -
604 - my $group_list = "";
605 - foreach my $group (@groups) {
606 - if ($group_list) {
607 - $group_list .= "," . $group;
608 - } else {
609 - $group_list = $group;
610 - }
611 - }
612 -
613 - # Setup User List
614 - # ===============
615 -
616 - my @users = $fm->cgi->param('tracUsers');
617 -
618 - my $user_list = "";
619 - foreach my $user (@users) {
620 - if ($user_list) {
621 - $user_list .= "," . $user;
622 - } else {
623 - $user_list = $user;
624 - }
625 - }
626 -
627 - # Update Database
628 - # ===============
629 -
630 - my $uid = $AccountsDB->get_next_uid();
631 - if (my $acct = $AccountsDB->new_record($name, {
632 - Description => $fm->cgi->param('tracDescription'),
633 - Repository => $fm->cgi->param('tracRepository'),
634 - RepositoryPath => $fm->cgi->param('tracRepositoryPath'),
635 - Domains => "$domain_list",
636 - Groups => "$group_list",
637 - Users => "$user_list",
638 - Modifiable => 'yes',
639 - Removable => 'yes',
640 - Access => $fm->cgi->param('tracAccess'),
641 - type => 'trac',
642 - }) )
643 - {
644 - # Untaint $name before use in system()
645 - $name =~ /(.+)/; $name = $1;
646 -
647 - $fm->clear_params();
648 -
649 - if (system ("/sbin/e-smith/signal-event", "trac-project-create", $name) == 0) {
650 - $fm->success("SUCCESSFULLY_CREATED_TRAC_PROJECT");
651 - } else {
652 - $fm->error("ERROR_WHILE_CREATING_TRAC_PROJECT");
653 - }
654 - } else {
655 - $fm->error('CANT_CREATE_TRAC_PROJECT');
656 - }
657 -}
658 -
659 -=head2 modify_trac_project()
660 -
661 -Handle the modify event for the trac project environment
662 -
663 -=cut
664 -
665 -sub modify_trac_project {
666 -
667 - my ($fm) = @_;
668 - my $name = $fm->cgi->param('tracName');
669 -
670 - # Validate Name
671 - # =============
672 -
673 - my $msg = $fm->validate_name($name);
674 - unless ($msg eq "OK")
675 - {
676 - return $fm->error($msg);
677 - }
678 -
679 - # Validate & Setup Domain List
680 - # ============================
681 -
682 - my @active_trac_domains = $fm->cgi->param('tracDomains');
683 -
684 - $msg = $fm->validate_trac_has_domains(@active_trac_domains);
685 - unless ($msg eq "OK")
686 - {
687 - return $fm->error($msg);
688 - }
689 -
690 - my $domain_list;
691 - foreach my $domain (@active_trac_domains) {
692 - if ($domain_list) {
693 - $domain_list .= "," . $domain;
694 - } else {
695 - $domain_list = $domain;
696 - }
697 - }
698 -
699 - # Setup Group List
700 - # ================
701 -
702 - my @groups = $fm->cgi->param('tracGroups');
703 -
704 - my $group_list;
705 - foreach my $group (@groups) {
706 - if ($group_list) {
707 - $group_list .= "," . $group;
708 - } else {
709 - $group_list = $group;
710 - }
711 - }
712 -
713 - # Setup User List
714 - # ===============
715 -
716 - my @users = $fm->cgi->param('tracUsers');
717 -
718 - my $user_list;
719 - foreach my $user (@users) {
720 - if ($user_list) {
721 - $user_list .= "," . $user;
722 - } else {
723 - $user_list = $user;
724 - }
725 - }
726 -
727 - # Update Database
728 - # ===============
729 -
730 - if (my $acct = $AccountsDB->get($name)) {
731 - if ($acct->prop('type') eq 'trac') {
732 -
733 - $acct->merge_props(
734 - Description => $fm->cgi->param('tracDescription'),
735 - Repository => $fm->cgi->param('tracRepository'),
736 - RepositoryPath => $fm->cgi->param('tracRepositoryPath'),
737 - Domains => $domain_list,
738 - Groups => $group_list,
739 - Users => $user_list,
740 - Access => $fm->cgi->param('tracAccess'),
741 - type => 'trac',
742 - );
743 -
744 - # Untaint $name before use in system()
745 - $name =~ /(.+)/; $name = $1;
746 -
747 - $fm->clear_params();
748 -
749 - if (system ("/sbin/e-smith/signal-event", "trac-project-modify", $name) == 0)
750 - {
751 - $fm->success("SUCCESSFULLY_MODIFIED_TRAC_PROJECT");
752 - } else {
753 - $fm->error("ERROR_WHILE_MODIFYING_TRAC_PROJECT");
754 - }
755 - } else {
756 - $fm->error('CANT_FIND_TRAC_PROJECT');
757 - }
758 - } else {
759 - $fm->error('CANT_FIND_TRAC_PROJECT');
760 - }
761 -}
762 -
763 -=head2 remove_trac_project()
764 -
765 -Handle the remove event for the trac project environment
766 -
767 -=cut
768 -
769 -sub remove_trac_project {
770 -
771 - my $fm = shift;
772 -
773 - my $name = $fm->cgi->param('tracName');
774 - if (my $acct = $AccountsDB->get($name)) {
775 - if ($acct->prop('type') eq 'trac') {
776 - $acct->set_prop('type', 'trac-deleted');
777 -
778 - # Untaint $name before use in system()
779 - $name =~ /(.+)/; $name = $1;
780 - if (system ("/sbin/e-smith/signal-event", "trac-project-delete", $name) == 0) {
781 - $fm ->success("SUCCESSFULLY_DELETED_TRAC_PROJECT");
782 - $acct->delete();
783 - } else {
784 - $fm ->error("ERROR_WHILE_DELETING_TRAC_PROJECT");
785 - }
786 - } else {
787 - $fm->error('CANT_FIND_TRAC_PROJECT');
788 - }
789 -
790 - } else {
791 - $fm->error('CANT_FIND_TRAC_PROJECT');
792 - }
793 - $fm->wherenext('First');
794 -}
795 -
796 -=head1 VALIDATION ROUTINES
797 -
798 -=head2 max_trac_project_name_length()
799 -
800 -Checks the length of a given trac project environment name against the
801 -maximum set in the maxTracNameLength record of the configuration database.
802 -Defaults to a maximum length of $self->{defaultMaxLength} if nothing is
803 -set in the config db.
804 -
805 -=cut
806 -
807 -sub max_trac_project_name_length {
808 - my ($fm, $data) = @_;
809 -
810 - $ConfigDB->reload();
811 - my $max;
812 - if (my $max_record = $ConfigDB->get('maxTracNameLength')) {
813 - $max = $max_record->value();
814 - }
815 -
816 - if (length($data) <= $max) {
817 - return "OK";
818 - } else {
819 - return $fm->localise("MAX_TRAC_NAME_LENGTH_ERROR",
820 - {acctName => $data,
821 - maxRepositoryNameLength => $max,
822 - maxLength => $max});
823 - }
824 -}
825 -
826 -=head2 getExtraParams()
827 -
828 -Sets variables used in the lexicon to their required values.
829 -
830 -=cut
831 -
832 -sub getExtraParams {
833 -
834 - my $fm = shift;
835 - my $TracProjectName = $fm->cgi->param('tracName');
836 - my $TracProjectDescription = '';
837 - my $maxLength = $ConfigDB->get('maxTracNameLength');
838 -
839 - if ($TracProjectName)
840 - {
841 - my $TracAccount = $AccountsDB->get($TracProjectName);
842 - if ($TracAccount)
843 - {
844 - $TracProjectDescription = $TracAccount->prop('Description');
845 - }
846 - }
847 -
848 - return (name => $TracProjectName,
849 - description => $TracProjectDescription,
850 - maxLength => $maxLength);
851 -}
852 -
853 -=head2 validate_name()
854 -
855 -Checks that the name supplied does not contain any unacceptable chars.
856 -Returns OK on success or a localised error message otherwise.
857 -
858 -=cut
859 -
860 -sub validate_name {
861 -
862 - my ($fm, $tracName) = @_;
863 -
864 - unless ($tracName =~ /^([a-z][\_\.\-a-z0-9]*)$/)
865 - {
866 - return $fm->localise('TRAC_PROJECT_NAME_HAS_INVALID_CHARS', {tracName => $tracName});
867 - }
868 -
869 - return "OK";
870 -}
871 -
872 -=head2 conflict_check()
873 -
874 -Check the proposed name for clashes with existing pseudonyms or other
875 -accounts of any type.
876 -
877 -=cut
878 -
879 -sub conflict_check {
880 -
881 - my ($fm, $name) = @_;
882 - my $rec = $AccountsDB->get($name);
883 -
884 - my $type;
885 - if (defined $rec)
886 - {
887 - my $type = $rec->prop('type');
888 - if ($type eq "pseudonym")
889 - {
890 - my $acct = $rec->prop("Account");
891 - my $acct_type = $AccountsDB->get($acct)->prop('type');
892 -
893 - return $fm->localise('ACCT_CLASHES_WITH_PSEUDONYM',
894 - {acctName => $name, acctType => $acct_type, acct => $acct});
895 - }
896 - }
897 - elsif (defined getpwnam($name) || defined getgrnam($name))
898 - {
899 - $type = 'system';
900 - }
901 - else
902 - {
903 - # No account record and no account
904 - return 'OK';
905 - }
906 - return $fm->localise('ACCOUNT_EXISTS',
907 - {acctName => $name, acctType => $type});
908 -}
909 -
910 -=head2 validate_trac_has_domains()
911 -
912 -Validates that the cgi parameter DOMAINS is an array with at least one entry
913 -Returns OK if true. Otherwise, returns NO_DOMAINS
914 -
915 -=cut
916 -
917 -sub validate_trac_has_domains {
918 -
919 - my $fm = shift;
920 - my @domains = @_;
921 -
922 - my $count = @domains;
923 -
924 - if ( $count == 0 ) {
925 - return ('NO_DOMAINS');
926 - }
927 - else {
928 - return ('OK');
929 - }
930 -}
931 -
932 -=head2 clear_params()
933 -
934 -This method clears-out the parameters used in form submission so that they are
935 -not inadvertenly picked-up where they should not be.
936 -
937 -=cut
938 -
939 -sub clear_params {
940 -
941 - my $fm = shift;
942 - my $q = $fm->{cgi};
943 -
944 - # Don't delete tracName here as we need in the next page for
945 - # status messages.
946 -
947 - $q->delete('tracDescription');
948 - $q->delete('tracRepository');
949 - $q->delete('tracRepositoryPath');
950 - $q->delete('tracDomains');
951 - $q->delete('tracGroups');
952 - $q->delete('tracUsers');
953 - $q->delete('tracAccess');
954 -
955 -}
956 -
957 -1;
958 +#!/usr/bin/perl -w
959 +#----------------------------------------------------------------------
960 +# $Id: trac.pm 69 2007-03-25 13:20:24Z marco $
961 +# vim: ft=perl ts=4 sw=4 et:
962 +#----------------------------------------------------------------------
963 +# Copyright (C) 2007 Marco Hess
964 +#
965 +# This program is free software; you can redistribute it and/or modify
966 +# it under the terms of the GNU General Public License as published by
967 +# the Free Software Foundation; either version 2 of the License, or
968 +# (at your option) any later version.
969 +#
970 +# This program is distributed in the hope that it will be useful,
971 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
972 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
973 +# GNU General Public License for more details.
974 +#
975 +# You should have received a copy of the GNU General Public License
976 +# along with this program; if not, write to the Free Software
977 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
978 +#----------------------------------------------------------------------
979 +
980 +package esmith::FormMagick::Panel::trac;
981 +
982 +use strict;
983 +use warnings;
984 +
985 +use esmith::FormMagick;
986 +use esmith::AccountsDB;
987 +use esmith::ConfigDB;
988 +use esmith::DomainsDB;
989 +use esmith::cgi;
990 +use esmith::util;
991 +use File::Basename;
992 +use Exporter;
993 +use Carp;
994 +use Sys::Syslog;
995 +
996 +use constant TRUE => 1;
997 +use constant FALSE => 0;
998 +
999 +our @ISA = qw(esmith::FormMagick Exporter);
1000 +
1001 +our @EXPORT = qw(
1002 + show_trac_projects
1003 + print_trac_field_name
1004 + repositories_list
1005 + group_list
1006 + user_list
1007 + max_trac_project_name_length
1008 + handle_trac_projects
1009 + create_trac_project
1010 + remove_trac_project
1011 + getExtraParams
1012 + print_save_or_add_button
1013 + validate_name
1014 + validate_radio
1015 + wherenext
1016 + maxLength
1017 +);
1018 +
1019 +our $ConfigDB = esmith::ConfigDB->open
1020 + or die "Can't open the Config database : $!\n" ;
1021 +
1022 +our $AccountsDB = esmith::AccountsDB->open
1023 + or die "Can't open the Account database : $!\n" ;
1024 +
1025 +our $DomainsDB = esmith::DomainsDB->open
1026 + or die "Can't open the Domains database : $!\n" ;
1027 +
1028 +
1029 +# fields and records separator for sub records
1030 +use constant FS => "," ;
1031 +use constant RS => ";" ;
1032 +
1033 +=pod
1034 +
1035 +=head1 NAME
1036 +
1037 +esmith::FormMagick::Panels::trac - Trac
1038 +
1039 +=head1 SYNOPSIS
1040 +
1041 +use esmith::FormMagick::Panels::trac
1042 +
1043 +my $panel = esmith::FormMagick::Panel::trac->new();
1044 +$panel->display();
1045 +
1046 +=head1 DESCRIPTION
1047 +
1048 +This module is the backend to the Trac panel, responsible
1049 +for supplying all functions used by that panel. It is a subclass
1050 +of esmith::FormMagick itself, so it inherits the functionality
1051 +of a FormMagick object.
1052 +
1053 +=cut
1054 +
1055 +=head2 new()
1056 +
1057 +Exactly as for esmith::FormMagick
1058 +
1059 +=cut
1060 +
1061 +sub new
1062 +{
1063 + my $proto = shift;
1064 + my $class = ref($proto) || $proto;
1065 + my $self = esmith::FormMagick::new($class);
1066 + $self->{calling_package} = (caller)[0];
1067 +
1068 + return $self;
1069 +}
1070 +
1071 +=head1 HTML GENERATION ROUTINES
1072 +
1073 +Routines for generating chunks of HTML needed by the panel.
1074 +
1075 +=cut
1076 +
1077 +=head2 show_trac_projects()
1078 +
1079 +This function displays a table of trac project environments on the system
1080 +including the links to modify and remove the trac project environment.
1081 +
1082 +=cut
1083 +
1084 +sub show_trac_projects {
1085 + my $fm = shift;
1086 + my $q = $fm->{cgi};
1087 +
1088 + # Setup the various localised text field for the trac project table
1089 + my $name = $fm->localise('TRAC_TABLE_HEADER_NAME');
1090 + my $description = $fm->localise('TRAC_TABLE_HEADER_DESCRIPTION');
1091 + my $domains = $fm->localise('TRAC_TABLE_HEADER_DOMAINS');
1092 + my $repository = $fm->localise('TRAC_TABLE_HEADER_REPOSITORY');
1093 + my $path = $fm->localise('TRAC_TABLE_HEADER_PATH');
1094 + my $access = $fm->localise('TRAC_TABLE_HEADER_ACCESS');
1095 + my $action_h = $fm->localise('TRAC_TABLE_HEADER_ACTION');
1096 + my $view = $fm->localise('TRAC_ACTION_VIEW');
1097 + my $modify = $fm->localise('TRAC_ACTION_MODIFY');
1098 + my $remove = $fm->localise('TRAC_ACTION_REMOVE');
1099 + my $backup = $fm->localise('TRAC_ACTION_BACKUP');
1100 + my $restore = $fm->localise('TRAC_ACTION_RESTORE');
1101 +
1102 + print $q->start_table({-class => 'sme-noborder'}), "\n";
1103 +
1104 + # Check if any repositories exist
1105 + my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository');
1106 + unless ( scalar @repositories )
1107 + {
1108 + print $q->Tr($q->td($q->h2($fm->localise('NO_REPOSITORIES'))));
1109 + return "";
1110 + }
1111 +
1112 + # TODO what about the case that all repositories have been deleted
1113 + # but the Trac project environments are still there? Can we remove the
1114 + # trac projects or do we need to reassign the projects to
1115 + # another repository? The code above prevents us from accessing the
1116 + # trac projects when there are no more repositories.
1117 +
1118 + print $q->Tr($q->td($q->a({-class => "button-like",
1119 + href => "trac?page=0&page_stack=&Next=Next&wherenext=Create"},
1120 + $fm->localise('TRAC_ADD_BUTTON'))));
1121 +
1122 + # Check if any trac projects exist
1123 + my @TracProjects = $AccountsDB->get_all_by_prop('type' => 'trac');
1124 + unless ( scalar @TracProjects )
1125 + {
1126 + print $q->Tr($q->td($q->h2($fm->localise('NO_TRAC_PROJECTS'))));
1127 + return "";
1128 + }
1129 +
1130 + # Show the list of configures trac projects
1131 + print $q->Tr($q->td($q->h2($fm->localise('CURRENT_TRAC_PROJECTS'))));
1132 +
1133 + print $q->Tr($q->td($fm->localise('TRAC_MODIFY_REMOVE_BUTTON_DESCRIPTION')));
1134 +
1135 + print $q->start_table({-CLASS => "sme-border"}),"\n";
1136 + print $q->Tr (
1137 + esmith::cgi::genSmallCell($q, $name, "header"),
1138 + esmith::cgi::genSmallCell($q, $description,"header"),
1139 + esmith::cgi::genSmallCell($q, $domains, "header"),
1140 + esmith::cgi::genSmallCell($q, $repository, "header"),
1141 + esmith::cgi::genSmallCell($q, $path, "header"),
1142 + esmith::cgi::genSmallCell($q, $access, "header"),
1143 + esmith::cgi::genSmallCell($q, $action_h, "header", 3)),"\n";
1144 +
1145 + my $scriptname = basename($0);
1146 +
1147 + foreach my $TracProject (@TracProjects)
1148 + {
1149 + my $trac_name = $TracProject->key();
1150 + my $trac_desc = $TracProject->prop('Description');
1151 + my $trac_domains = join("<br>", split(FS, $TracProject->prop('Domains')));
1152 + my $trac_repo = $TracProject->prop('Repository');
1153 + my $trac_path = $TracProject->prop('RepositoryPath');
1154 + my $trac_access = $TracProject->prop('Access') || 'local';
1155 + my $modifiable = $TracProject->prop('Modifiable') || 'yes';
1156 + my $removable = $TracProject->prop('Removable') || 'yes';
1157 +
1158 + my $params = $fm->build_trac_project_cgi_params($trac_name, $TracProject->props());
1159 +
1160 + my $href = "$scriptname?$params&action=modify&wherenext=";
1161 +
1162 + my $actionView = '&nbsp;';
1163 + $actionView .= $q->a({href => '/' . $TracProject->key(),
1164 + target => '_blank'}, $view ) . '&nbsp;';
1165 +
1166 + my $actionModify = '&nbsp;';
1167 + if ($modifiable eq 'yes')
1168 + {
1169 + $actionModify .= $q->a({href => "${href}Modify"}, $modify) . '&nbsp;';
1170 + }
1171 +
1172 + my $actionRemove = '&nbsp;';
1173 + if ($removable eq 'yes')
1174 + {
1175 + $actionRemove .= $q->a({href => "${href}Remove"}, $remove) . '&nbsp;';
1176 + }
1177 +
1178 + my $actionBackup = '&nbsp;';
1179 + $actionBackup .= $q->a({href => "${href}Backup"}, $backup) . '&nbsp;';
1180 +
1181 + my $actionRestore = '&nbsp;';
1182 + $actionRestore .= $q->a({href => "${href}Restore"}, $restore) . '&nbsp;';
1183 +
1184 + print $q->Tr(
1185 + esmith::cgi::genSmallCell($q, $trac_name, "normal"),
1186 + esmith::cgi::genSmallCell($q, $trac_desc, "normal"),
1187 + esmith::cgi::genSmallCell($q, $trac_domains, "normal"),
1188 + esmith::cgi::genSmallCell($q, $trac_repo, "normal"),
1189 + esmith::cgi::genSmallCell($q, $trac_path, "normal"),
1190 + esmith::cgi::genSmallCell($q, $trac_access, "normal"),
1191 + esmith::cgi::genSmallCell($q, $actionView, "normal"),
1192 + esmith::cgi::genSmallCell($q, $actionModify, "normal"),
1193 + esmith::cgi::genSmallCell($q, $actionRemove, "normal")
1194 + );
1195 + }
1196 +
1197 + print $q->end_table,"\n";
1198 +
1199 + print $q->end_table,"\n";
1200 +
1201 + return "";
1202 +}
1203 +
1204 +=cut
1205 +
1206 +=head2 print_save_or_add_button()
1207 +
1208 +Prints the ADD button when a new trac project environment is addded and the SAVE buttom
1209 +whem modifications are made.
1210 +
1211 +=cut
1212 +
1213 +sub print_save_or_add_button {
1214 +
1215 + my ($fm) = @_;
1216 +
1217 + my $cgi = $fm->{cgi};
1218 +
1219 + if (($cgi->param("action") || '') eq "modify") {
1220 + $fm->print_button("SAVE");
1221 + } else {
1222 + $fm->print_button("ADD");
1223 + }
1224 +}
1225 +
1226 +=head1 HELPER FUNCTIONS FOR THE PANEL
1227 +
1228 +Routines for modifying the database and signaling events
1229 +from the server-manager panel
1230 +
1231 +=cut
1232 +
1233 +=head2 build_trac_project_cgi_params($fm, $tracprojectname, %oldprops)
1234 +
1235 +Constructs the parameters for the links in the trac project environments table
1236 +
1237 +=cut
1238 +
1239 +sub build_trac_project_cgi_params {
1240 + my ($self, $tracprojectname, %oldprops) = @_;
1241 +
1242 + my %props = (
1243 + page => 0,
1244 + page_stack => "",
1245 + tracName => $tracprojectname,
1246 + );
1247 +
1248 + return $self->props_to_query_string(\%props);
1249 +}
1250 +
1251 +*wherenext = \&CGI::FormMagick::wherenext;
1252 +
1253 +=head2 print_trac_field_name()
1254 +
1255 +Helper function to print the field NAME so that it becomes
1256 +an edit field upon ADD and a fixed field upon MODIFY.
1257 +
1258 +Also read all the account db values so the other fields
1259 +can show the existing values.
1260 +
1261 +=cut
1262 +
1263 +sub print_trac_field_name {
1264 + my $fm = shift;
1265 + my $in = $fm->{cgi}->param('tracName') || '';
1266 + my $action = $fm->{cgi}->param('action') || '';
1267 +
1268 + print qq(<tr><td class="sme-noborders-label">) .
1269 + $fm->localise('TRAC_FIELD_PROJECT_NAME') . qq(</td>\n);
1270 +
1271 + if ($action eq 'modify' and $in) {
1272 + #-------------------------------------------------------
1273 + # Updating an existing record.
1274 + #--------------------------------------------------------
1275 +
1276 + my $rec = $AccountsDB->get($in);
1277 + my $modifiable = $rec->prop('Modifiable') || 'yes';
1278 + my $removable = $rec->prop('Removable') || 'yes';
1279 +
1280 + print qq(
1281 + <td class="sme-noborders-content">$in
1282 + <input type="hidden" name="tracName" value="$in">
1283 + <input type="hidden" name="action" value="modify">
1284 + </td>
1285 + );
1286 +
1287 + # Read the values for each field from the accounts db and store
1288 + # them in the cgi object so our form will have the correct
1289 + # info displayed.
1290 + my $q = $fm->{cgi};
1291 + if ($rec)
1292 + {
1293 + $q->param(-name=>'tracDescription',-value=>
1294 + $rec->prop('Description'));
1295 +
1296 + $q->param(-name=>'tracRepository',-value=>
1297 + $rec->prop('Repository'));
1298 +
1299 + $q->param(-name=>'tracRepositoryPath',-value=>
1300 + $rec->prop('RepositoryPath'));
1301 +
1302 + # domain list is handled separately
1303 +
1304 + $q->param(-name=>'tracGroups',-value=>
1305 + join(FS, split(FS, $rec->prop('Groups'))));
1306 +
1307 + $q->param(-name=>'tracUsers',-value=>
1308 + join(FS, split(FS, $rec->prop('Users'))));
1309 +
1310 + $q->param(-name=>'tracAccess',-value=>
1311 + $rec->prop('Access')),
1312 + }
1313 + } else {
1314 + #-------------------------------------------------------
1315 + # Adding a new record so allow an entry field for the
1316 + # name.
1317 + #--------------------------------------------------------
1318 + print qq(
1319 + <td><input type="text" name="tracName" value="$in">
1320 + <input type="hidden" name="action" value="create">
1321 + </td>
1322 + );
1323 + }
1324 +
1325 + print qq(</tr>\n);
1326 + return undef;
1327 +}
1328 +
1329 +
1330 +=head2 print_trac_domains()
1331 +
1332 +When this server has more than one domain this function takes
1333 +the list of domains and returns a string of html checkboxes
1334 +for all these domains.
1335 +
1336 +Those domains that are listed with this Trac environment
1337 +will have their checkbox checked.
1338 +
1339 +=cut
1340 +
1341 +sub print_trac_domains() {
1342 +
1343 + # Retrieve the Trac account name from the CGI parameters
1344 + my $fm = shift;
1345 + my $name = $fm->{'cgi'}->param('tracName');
1346 + my $action = $fm->{'cgi'}->param("action") || '';
1347 + my $out = "";
1348 +
1349 + # Get a full list of all the domains on this server.
1350 + my @domains = $DomainsDB->get_all_by_prop( type => 'domain' );
1351 + my $numdomains = @domains;
1352 +
1353 + # If there is more than one domain, we generate a list
1354 + # of checkboxes. Otherwise we just show the primary domain.
1355 + if ($numdomains > 1) {
1356 +
1357 + # With the Trac account name, get the list of the Domains for which
1358 + # this Trac account is active.
1359 + my $trac_domains_list = "";
1360 + if ($AccountsDB->get($name)) {
1361 + $trac_domains_list = $AccountsDB->get($name)->prop('Domains');
1362 + }
1363 +
1364 + # Split the comma separated list into the individual bits.
1365 + my %trac_domains;
1366 + foreach my $trac_domain ( split ( /,/, $trac_domains_list ) ) {
1367 + $trac_domains{$trac_domain} = 1;
1368 + }
1369 +
1370 + # Now generate the table of domains with a checkbox in front of it.
1371 + # If the domain is in our listed domains for the Trac environment, the
1372 + # checkbox will show checked.
1373 + $out = " <tr>\n";
1374 + $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAINS_DESCRIPTION') . "</td>";
1375 + $out .= " </tr>\n";
1376 + $out .= " <tr>\n";
1377 + $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAINS') . "</td>\n";
1378 + $out .= " <td>\n";
1379 + $out .= " <table border='0' cellspacing='0' cellpadding='0'>\n";
1380 + $out .= " <tr>\n";
1381 +
1382 + foreach my $domain (sort @domains) {
1383 +
1384 + # If this is a ADD form, we default check all domains, otherwise only
1385 + # those that are in our Trac project list.
1386 + my $checked = "";
1387 + if ( $action eq 'modify' ) {
1388 + if ( $trac_domains{ $domain->key() } ) {
1389 + $checked = "checked";
1390 + }
1391 + } else {
1392 + $checked = "checked";
1393 + }
1394 +
1395 + $out .= " <tr>\n";
1396 + $out .= " <td><input type=\"checkbox\" name=\"tracDomains\" $checked value=\"" . $domain->key . "\"></td>\n";
1397 + $out .= " <td>" . $domain->key . "</td>\n";
1398 + $out .= " </tr>\n";
1399 + }
1400 +
1401 + $out .= " </table>\n";
1402 + $out .= " </td>\n";
1403 + $out .= " </tr>\n";
1404 + }
1405 + else
1406 + {
1407 + # We only have a single domain, so we just show this domain but without the
1408 + # checkbox (so it can't be unchecked).
1409 + my $domainname = $ConfigDB->get('DomainName')->value();
1410 + $out = " <tr>\n";
1411 + $out .= " <td colspan=2>" . $fm->localise('TRAC_FIELD_DOMAIN_DESCRIPTION') . "</td>";
1412 + $out .= " </tr>\n";
1413 + $out .= " <tr>\n";
1414 + $out .= " <td class=\"sme-noborders-label\">" . $fm->localise('TRAC_FIELD_DOMAIN') . "</td>\n";
1415 + $out .= " <td><input type=\"hidden\" name=\"tracDomains\" value=\"" . $domainname . "\">";
1416 + $out .= $domainname . "</td>\n";
1417 + $out .= " </tr>\n";
1418 + }
1419 +
1420 + return $out;
1421 +}
1422 +
1423 +
1424 +=pod
1425 +
1426 +=head2 repositories_list()
1427 +
1428 +Returns a hash of repositories for the Create/Modify screen's repository
1429 +field's drop down list.
1430 +
1431 +=cut
1432 +
1433 +sub repositories_list
1434 +{
1435 + my @repositories = $AccountsDB->get_all_by_prop('type' => 'repository');
1436 + my %repositories = ();
1437 + foreach my $repository (@repositories) {
1438 + $repositories{$repository->key()} = $repository->prop('Description') . " (" . $repository->key . ")";
1439 + }
1440 + return \%repositories;
1441 +}
1442 +
1443 +=head2 group_list()
1444 +
1445 +Returns a hash of groups for the Create/Modify screen's group
1446 +field's drop down list.
1447 +
1448 +=cut
1449 +
1450 +sub group_list
1451 +{
1452 + my @groups = $AccountsDB->groups();
1453 + my %groups = ();
1454 + foreach my $group (@groups) {
1455 + $groups{$group->key()} = $group->prop('Description')." (".$group->key.")";
1456 + }
1457 + return \%groups;
1458 +}
1459 +
1460 +=head2 user_list()
1461 +
1462 +Returns a hash of users for the Create/Modify screen's user field's
1463 +drop down list.
1464 +
1465 +=cut
1466 +
1467 +sub user_list
1468 +{
1469 + my @users = $AccountsDB->users();
1470 + my %users = ();
1471 + foreach my $user (@users) {
1472 + $users{$user->key()} = $user->prop('LastName').", ". $user->prop('FirstName')." (". $user->key.")";
1473 + }
1474 + return \%users;
1475 +}
1476 +
1477 +=head1 THE ROUTINES THAT ACTUALLY DO THE WORK
1478 +
1479 +=cut
1480 +
1481 +=head2 handle_trac_projects()
1482 +
1483 +Determine whether to modify or add the trac project environment
1484 +
1485 +=cut
1486 +
1487 +sub handle_trac_projects {
1488 +
1489 + my ($fm) = @_;
1490 +
1491 + if ($fm->cgi->param("action") eq "create") {
1492 + $fm->create_trac_project();
1493 + } else {
1494 + $fm->modify_trac_project();
1495 + }
1496 +
1497 +}
1498 +
1499 +=head2 create_trac_project()
1500 +
1501 +Handle the create event for the trac project environment
1502 +
1503 +=cut
1504 +
1505 +sub create_trac_project {
1506 +
1507 + my ($fm) = @_;
1508 +
1509 + # Validate Name
1510 + # =============
1511 +
1512 + my $name = $fm->cgi->param('tracName');
1513 + my $msg;
1514 +
1515 + $msg = $fm->validate_name($name);
1516 + unless ($msg eq "OK")
1517 + {
1518 + return $fm->error($msg);
1519 + }
1520 +
1521 + $msg = $fm->max_trac_project_name_length($name);
1522 + unless ($msg eq "OK")
1523 + {
1524 + return $fm->error($msg);
1525 + }
1526 +
1527 + $msg = $fm->conflict_check($name);
1528 + unless ($msg eq "OK")
1529 + {
1530 + return $fm->error($msg);
1531 + }
1532 +
1533 + # Validate & Setup Domain List
1534 + # ============================
1535 +
1536 + my @active_trac_domains = $fm->cgi->param('tracDomains');
1537 +
1538 + $msg = $fm->validate_trac_has_domains(@active_trac_domains);
1539 + unless ($msg eq "OK")
1540 + {
1541 + return $fm->error($msg);
1542 + }
1543 +
1544 + my $domain_list = "";
1545 + foreach my $domain (@active_trac_domains) {
1546 + if ($domain_list) {
1547 + $domain_list .= "," . $domain;
1548 + } else {
1549 + $domain_list = $domain;
1550 + }
1551 + }
1552 +
1553 + # Setup Group List
1554 + # ================
1555 +
1556 + my @groups = $fm->cgi->param('tracGroups');
1557 +
1558 + my $group_list = "";
1559 + foreach my $group (@groups) {
1560 + if ($group_list) {
1561 + $group_list .= "," . $group;
1562 + } else {
1563 + $group_list = $group;
1564 + }
1565 + }
1566 +
1567 + # Setup User List
1568 + # ===============
1569 +
1570 + my @users = $fm->cgi->param('tracUsers');
1571 +
1572 + my $user_list = "";
1573 + foreach my $user (@users) {
1574 + if ($user_list) {
1575 + $user_list .= "," . $user;
1576 + } else {
1577 + $user_list = $user;
1578 + }
1579 + }
1580 +
1581 + # Update Database
1582 + # ===============
1583 +
1584 + my $uid = $AccountsDB->get_next_uid();
1585 + if (my $acct = $AccountsDB->new_record($name, {
1586 + Description => $fm->cgi->param('tracDescription'),
1587 + Repository => $fm->cgi->param('tracRepository'),
1588 + RepositoryPath => $fm->cgi->param('tracRepositoryPath'),
1589 + Domains => "$domain_list",
1590 + Groups => "$group_list",
1591 + Users => "$user_list",
1592 + Modifiable => 'yes',
1593 + Removable => 'yes',
1594 + Access => $fm->cgi->param('tracAccess'),
1595 + type => 'trac',
1596 + }) )
1597 + {
1598 + # Untaint $name before use in system()
1599 + $name =~ /(.+)/; $name = $1;
1600 +
1601 + $fm->clear_params();
1602 +
1603 + if (system ("/sbin/e-smith/signal-event", "trac-project-create", $name) == 0) {
1604 + $fm->success("SUCCESSFULLY_CREATED_TRAC_PROJECT");
1605 + } else {
1606 + $fm->error("ERROR_WHILE_CREATING_TRAC_PROJECT");
1607 + }
1608 + } else {
1609 + $fm->error('CANT_CREATE_TRAC_PROJECT');
1610 + }
1611 +}
1612 +
1613 +=head2 modify_trac_project()
1614 +
1615 +Handle the modify event for the trac project environment
1616 +
1617 +=cut
1618 +
1619 +sub modify_trac_project {
1620 +
1621 + my ($fm) = @_;
1622 + my $name = $fm->cgi->param('tracName');
1623 +
1624 + # Validate Name
1625 + # =============
1626 +
1627 + my $msg = $fm->validate_name($name);
1628 + unless ($msg eq "OK")
1629 + {
1630 + return $fm->error($msg);
1631 + }
1632 +
1633 + # Validate & Setup Domain List
1634 + # ============================
1635 +
1636 + my @active_trac_domains = $fm->cgi->param('tracDomains');
1637 +
1638 + $msg = $fm->validate_trac_has_domains(@active_trac_domains);
1639 + unless ($msg eq "OK")
1640 + {
1641 + return $fm->error($msg);
1642 + }
1643 +
1644 + my $domain_list;
1645 + foreach my $domain (@active_trac_domains) {
1646 + if ($domain_list) {
1647 + $domain_list .= "," . $domain;
1648 + } else {
1649 + $domain_list = $domain;
1650 + }
1651 + }
1652 +
1653 + # Setup Group List
1654 + # ================
1655 +
1656 + my @groups = $fm->cgi->param('tracGroups');
1657 +
1658 + my $group_list;
1659 + foreach my $group (@groups) {
1660 + if ($group_list) {
1661 + $group_list .= "," . $group;
1662 + } else {
1663 + $group_list = $group;
1664 + }
1665 + }
1666 +
1667 + # Setup User List
1668 + # ===============
1669 +
1670 + my @users = $fm->cgi->param('tracUsers');
1671 +
1672 + my $user_list;
1673 + foreach my $user (@users) {
1674 + if ($user_list) {
1675 + $user_list .= "," . $user;
1676 + } else {
1677 + $user_list = $user;
1678 + }
1679 + }
1680 +
1681 + # Update Database
1682 + # ===============
1683 +
1684 + if (my $acct = $AccountsDB->get($name)) {
1685 + if ($acct->prop('type') eq 'trac') {
1686 +
1687 + $acct->merge_props(
1688 + Description => $fm->cgi->param('tracDescription'),
1689 + Repository => $fm->cgi->param('tracRepository'),
1690 + RepositoryPath => $fm->cgi->param('tracRepositoryPath'),
1691 + Domains => $domain_list,
1692 + Groups => $group_list,
1693 + Users => $user_list,
1694 + Access => $fm->cgi->param('tracAccess'),
1695 + type => 'trac',
1696 + );
1697 +
1698 + # Untaint $name before use in system()
1699 + $name =~ /(.+)/; $name = $1;
1700 +
1701 + $fm->clear_params();
1702 +
1703 + if (system ("/sbin/e-smith/signal-event", "trac-project-modify", $name) == 0)
1704 + {
1705 + $fm->success("SUCCESSFULLY_MODIFIED_TRAC_PROJECT");
1706 + } else {
1707 + $fm->error("ERROR_WHILE_MODIFYING_TRAC_PROJECT");
1708 + }
1709 + } else {
1710 + $fm->error('CANT_FIND_TRAC_PROJECT');
1711 + }
1712 + } else {
1713 + $fm->error('CANT_FIND_TRAC_PROJECT');
1714 + }
1715 +}
1716 +
1717 +=head2 remove_trac_project()
1718 +
1719 +Handle the remove event for the trac project environment
1720 +
1721 +=cut
1722 +
1723 +sub remove_trac_project {
1724 +
1725 + my $fm = shift;
1726 +
1727 + my $name = $fm->cgi->param('tracName');
1728 + if (my $acct = $AccountsDB->get($name)) {
1729 + if ($acct->prop('type') eq 'trac') {
1730 + $acct->set_prop('type', 'trac-deleted');
1731 +
1732 + # Untaint $name before use in system()
1733 + $name =~ /(.+)/; $name = $1;
1734 + if (system ("/sbin/e-smith/signal-event", "trac-project-delete", $name) == 0) {
1735 + $fm ->success("SUCCESSFULLY_DELETED_TRAC_PROJECT");
1736 + $acct->delete();
1737 + } else {
1738 + $fm ->error("ERROR_WHILE_DELETING_TRAC_PROJECT");
1739 + }
1740 + } else {
1741 + $fm->error('CANT_FIND_TRAC_PROJECT');
1742 + }
1743 +
1744 + } else {
1745 + $fm->error('CANT_FIND_TRAC_PROJECT');
1746 + }
1747 + $fm->wherenext('First');
1748 +}
1749 +
1750 +=head1 VALIDATION ROUTINES
1751 +
1752 +=head2 max_trac_project_name_length()
1753 +
1754 +Checks the length of a given trac project environment name against the
1755 +maximum set in the maxTracNameLength record of the configuration database.
1756 +Defaults to a maximum length of $self->{defaultMaxLength} if nothing is
1757 +set in the config db.
1758 +
1759 +=cut
1760 +
1761 +sub max_trac_project_name_length {
1762 + my ($fm, $data) = @_;
1763 +
1764 + $ConfigDB->reload();
1765 + my $max;
1766 + if (my $max_record = $ConfigDB->get('maxTracNameLength')) {
1767 + $max = $max_record->value();
1768 + }
1769 +
1770 + if (length($data) <= $max) {
1771 + return "OK";
1772 + } else {
1773 + return $fm->localise("MAX_TRAC_NAME_LENGTH_ERROR",
1774 + {acctName => $data,
1775 + maxRepositoryNameLength => $max,
1776 + maxLength => $max});
1777 + }
1778 +}
1779 +
1780 +=head2 getExtraParams()
1781 +
1782 +Sets variables used in the lexicon to their required values.
1783 +
1784 +=cut
1785 +
1786 +sub getExtraParams {
1787 +
1788 + my $fm = shift;
1789 + my $TracProjectName = $fm->cgi->param('tracName');
1790 + my $TracProjectDescription = '';
1791 + my $maxLength = $ConfigDB->get('maxTracNameLength');
1792 +
1793 + if ($TracProjectName)
1794 + {
1795 + my $TracAccount = $AccountsDB->get($TracProjectName);
1796 + if ($TracAccount)
1797 + {
1798 + $TracProjectDescription = $TracAccount->prop('Description');
1799 + }
1800 + }
1801 +
1802 + return (name => $TracProjectName,
1803 + description => $TracProjectDescription,
1804 + maxLength => $maxLength);
1805 +}
1806 +
1807 +=head2 validate_name()
1808 +
1809 +Checks that the name supplied does not contain any unacceptable chars.
1810 +Returns OK on success or a localised error message otherwise.
1811 +
1812 +=cut
1813 +
1814 +sub validate_name {
1815 +
1816 + my ($fm, $tracName) = @_;
1817 +
1818 + unless ($tracName =~ /^([a-z][\_\.\-a-z0-9]*)$/)
1819 + {
1820 + return $fm->localise('TRAC_PROJECT_NAME_HAS_INVALID_CHARS', {tracName => $tracName});
1821 + }
1822 +
1823 + return "OK";
1824 +}
1825 +
1826 +=head2 conflict_check()
1827 +
1828 +Check the proposed name for clashes with existing pseudonyms or other
1829 +accounts of any type.
1830 +
1831 +=cut
1832 +
1833 +sub conflict_check {
1834 +
1835 + my ($fm, $name) = @_;
1836 + my $rec = $AccountsDB->get($name);
1837 +
1838 + my $type;
1839 + if (defined $rec)
1840 + {
1841 + my $type = $rec->prop('type');
1842 + if ($type eq "pseudonym")
1843 + {
1844 + my $acct = $rec->prop("Account");
1845 + my $acct_type = $AccountsDB->get($acct)->prop('type');
1846 +
1847 + return $fm->localise('ACCT_CLASHES_WITH_PSEUDONYM',
1848 + {acctName => $name, acctType => $acct_type, acct => $acct});
1849 + }
1850 + }
1851 + elsif (defined getpwnam($name) || defined getgrnam($name))
1852 + {
1853 + $type = 'system';
1854 + }
1855 + else
1856 + {
1857 + # No account record and no account
1858 + return 'OK';
1859 + }
1860 + return $fm->localise('ACCOUNT_EXISTS',
1861 + {acctName => $name, acctType => $type});
1862 +}
1863 +
1864 +=head2 validate_trac_has_domains()
1865 +
1866 +Validates that the cgi parameter DOMAINS is an array with at least one entry
1867 +Returns OK if true. Otherwise, returns NO_DOMAINS
1868 +
1869 +=cut
1870 +
1871 +sub validate_trac_has_domains {
1872 +
1873 + my $fm = shift;
1874 + my @domains = @_;
1875 +
1876 + my $count = @domains;
1877 +
1878 + if ( $count == 0 ) {
1879 + return ('NO_DOMAINS');
1880 + }
1881 + else {
1882 + return ('OK');
1883 + }
1884 +}
1885 +
1886 +=head2 clear_params()
1887 +
1888 +This method clears-out the parameters used in form submission so that they are
1889 +not inadvertenly picked-up where they should not be.
1890 +
1891 +=cut
1892 +
1893 +sub clear_params {
1894 +
1895 + my $fm = shift;
1896 + my $q = $fm->{cgi};
1897 +
1898 + # Don't delete tracName here as we need in the next page for
1899 + # status messages.
1900 +
1901 + $q->delete('tracDescription');
1902 + $q->delete('tracRepository');
1903 + $q->delete('tracRepositoryPath');
1904 + $q->delete('tracDomains');
1905 + $q->delete('tracGroups');
1906 + $q->delete('tracUsers');
1907 + $q->delete('tracAccess');
1908 +
1909 +}
1910 +
1911 +1;
1912 --- smeserver-trac-0.4/root/etc/e-smith/web/functions/trac.newlines 2007-04-26 20:42:10.000000000 -0600
1913 +++ smeserver-trac-0.4/root/etc/e-smith/web/functions/trac 2008-04-26 09:16:53.000000000 -0600
1914 @@ -1,235 +1,235 @@
1915 -#!/usr/bin/perl -wT
1916 -# vim: ft=xml:
1917 -# $Id: trac 69 2007-03-25 13:20:24Z marco $
1918 -
1919 -#----------------------------------------------------------------------
1920 -# heading : Collaboration
1921 -# description : TRAC_NAVIGATION_DESCRIPTION
1922 -# navigation : 2650 2650
1923 -#----------------------------------------------------------------------
1924 -
1925 -use strict;
1926 -use warnings;
1927 -use esmith::FormMagick::Panel::trac;
1928 -my $f = esmith::FormMagick::Panel::trac->new();
1929 -$f->display();
1930 -
1931 -=pod
1932 -
1933 -=head1 NAME
1934 -
1935 -Trac project environment -- add/remove/manage trac project environments
1936 -
1937 -=head2 DESCRIPTION
1938 -
1939 -This screen allows the administrator to manage Trac environments for the subversion repositories.
1940 -
1941 -=begin testing
1942 -
1943 -use esmith::FormMagick::Tester;
1944 -use esmith::TestUtils;
1945 -use esmith::TestUtils;
1946 -use esmith::ConfigDB;
1947 -use esmith::AccountsDB;
1948 -my $panel = $Original_File;
1949 -my $ua = esmith::FormMagick::Tester->new();
1950 -
1951 -my $c = esmith::ConfigDB->open();
1952 -my $a = esmith::AccountsDB->open();
1953 -
1954 -is (mode($panel), '4750', "Check permissions on script");
1955 -ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
1956 -is ($ua->{status}, 200, "200 OK");
1957 -like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
1958 -ok ($ua->set_language("en"), "Set language to English");
1959 -ok ($ua->get_panel($panel), "Get panel");
1960 -is ($ua->{status}, 200, "200 OK");
1961 -
1962 -ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING TRAC ENVIRONMENT");
1963 -ok ($ua->follow("Click here"), "Follow 'create repository' link");
1964 -is ($ua->{status}, 200, "200 OK");
1965 -like($ua->{content}, qr/Create a new Trac environment/, "Saw page title");
1966 -like($ua->{content}, qr/Brief description/, "Saw description field");
1967 -like($ua->{content}, qr/Add/, "Saw add button");
1968 -
1969 -SKIP: {
1970 -
1971 - skip 10, "Unsafe!" unless destruction_ok();
1972 -
1973 - ok ($ua->follow("Click here"), "ACTUALLY ADDING A TRAC ENVIRONMENT");
1974 - $ua->field();
1975 - $ua->click("Add");
1976 - like($ua->{content}, qr/Successfully added Trac environment/, "Saw success message");
1977 -
1978 - ok ($ua->follow("Remove"), "REMOVING TRAC ENVIRONMENT");
1979 - like($ua->{content}, qr/Are you sure/, "Saw confirmation message");
1980 - $ua->click("Remove");
1981 - like($ua->{content}, qr/Successfully deleted/, "Saw success message");
1982 -}
1983 -
1984 -=end testing
1985 -
1986 -=cut
1987 -
1988 -__DATA__
1989 -<form
1990 - title="TRAC_FORM_TITLE"
1991 - header="/etc/e-smith/web/common/head.tmpl"
1992 - footer="/etc/e-smith/web/common/foot.tmpl">
1993 -
1994 - <!-- page 0 -->
1995 - <page
1996 - name="First"
1997 - pre-event="print_status_message()">
1998 -
1999 - <description>TRAC_FORM_DESCRIPTION</description>
2000 -
2001 - <subroutine src="show_trac_projects()" />
2002 - </page>
2003 -
2004 - <!-- page 1 -->
2005 - <page
2006 - name="Create"
2007 - pre-event="turn_off_buttons()"
2008 - post-event="handle_trac_projects()">
2009 -
2010 - <title>TRAC_FORM_ADD_TITLE</title>
2011 -
2012 - <description>TRAC_FORM_ADD_DESCRIPTION</description>
2013 -
2014 - <subroutine src="print_trac_field_name()" />
2015 -
2016 - <field
2017 - type="text"
2018 - id="tracDescription"
2019 - validation="validate_description">
2020 - <label>TRAC_FIELD_PROJECT_DESCRIPTION</label>
2021 - </field>
2022 -
2023 - <field
2024 - type="select"
2025 - id="tracRepository"
2026 - options="repositories_list()">
2027 - <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description>
2028 - <label>TRAC_FIELD_REPOSITORY_NAME</label>
2029 - </field>
2030 -
2031 - <field
2032 - type="text"
2033 - id="tracRepositoryPath">
2034 - <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description>
2035 - <label>TRAC_FIELD_REPOSITORY_PATH</label>
2036 - </field>
2037 -
2038 - <subroutine src="print_trac_domains()" />
2039 -
2040 - <field
2041 - type="select"
2042 - id="tracAccess"
2043 - options="'local' => 'LOCAL',
2044 - 'global' => 'GLOBAL'"
2045 - value='local'>
2046 - <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description>
2047 - <label>TRAC_FIELD_ACCESS_TYPE</label>
2048 - </field>
2049 -
2050 - <field
2051 - type="select"
2052 - id="tracGroups"
2053 - options="group_list()"
2054 - multiple="1" size="5">
2055 - <description>TRAC_FIELD_GROUPS_DESCRIPTION</description>
2056 - <label>TRAC_FIELD_GROUPS</label>
2057 - </field>
2058 -
2059 - <field
2060 - type="select"
2061 - id="tracUsers"
2062 - options="user_list()"
2063 - multiple="1" size="5">
2064 - <label>TRAC_FIELD_USERS</label>
2065 - </field>
2066 -
2067 - <subroutine src="print_save_or_add_button()" />
2068 - </page>
2069 -
2070 - <!-- page 2 -->
2071 - <page
2072 - name="Modify"
2073 - pre-event="turn_off_buttons()"
2074 - post-event="handle_trac_projects()">
2075 -
2076 - <title>TRAC_FORM_MODIFY_TITLE</title>
2077 - <description>TRAC_FORM_MODIFY_DESCRIPTION</description>
2078 -
2079 - <subroutine src="print_trac_field_name()" />
2080 -
2081 - <field
2082 - type="text"
2083 - id="tracDescription"
2084 - validation="validate_description">
2085 - <label>TRAC_FIELD_PROJECT_DESCRIPTION</label>
2086 - </field>
2087 -
2088 -
2089 - <field
2090 - type="select"
2091 - id="tracRepository"
2092 - options="repositories_list()">
2093 - <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description>
2094 - <label>TRAC_FIELD_REPOSITORY_NAME</label>
2095 - </field>
2096 -
2097 - <field
2098 - type="text"
2099 - id="tracRepositoryPath">
2100 - <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description>
2101 - <label>TRAC_FIELD_REPOSITORY_PATH</label>
2102 - </field>
2103 -
2104 - <subroutine src="print_trac_domains()" />
2105 -
2106 - <field
2107 - type="select"
2108 - id="tracAccess"
2109 - options="'local' => 'LOCAL',
2110 - 'global' => 'GLOBAL'">
2111 - <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description>
2112 - <label>TRAC_FIELD_ACCESS_TYPE</label>
2113 - </field>
2114 -
2115 - <field
2116 - type="select"
2117 - id="tracGroups"
2118 - options="group_list()"
2119 - multiple="1" size="5">
2120 - <description>TRAC_FIELD_GROUPS_DESCRIPTION</description>
2121 - <label>TRAC_FIELD_GROUPS</label>
2122 - </field>
2123 -
2124 - <field
2125 - type="select"
2126 - id="tracUsers"
2127 - options="user_list()"
2128 - multiple="1" size="5">
2129 - <label>TRAC_FIELD_USERS</label>
2130 - </field>
2131 -
2132 - <subroutine src="print_save_or_add_button()" />
2133 -
2134 - </page>
2135 -
2136 - <!-- page 3 -->
2137 - <page
2138 - name="Remove"
2139 - pre-event="turn_off_buttons()"
2140 - post-event="remove_trac_project()">
2141 -
2142 - <title>TRAC_FORM_REMOVE_TITLE</title>
2143 - <description>TRAC_FORM_REMOVE_DESCRIPTION</description>
2144 -
2145 - <subroutine src="print_button('REMOVE')" />
2146 -
2147 - </page>
2148 -
2149 -</form>
2150 +#!/usr/bin/perl -wT
2151 +# vim: ft=xml:
2152 +# $Id: trac 69 2007-03-25 13:20:24Z marco $
2153 +
2154 +#----------------------------------------------------------------------
2155 +# heading : Collaboration
2156 +# description : TRAC_NAVIGATION_DESCRIPTION
2157 +# navigation : 2650 2650
2158 +#----------------------------------------------------------------------
2159 +
2160 +use strict;
2161 +use warnings;
2162 +use esmith::FormMagick::Panel::trac;
2163 +my $f = esmith::FormMagick::Panel::trac->new();
2164 +$f->display();
2165 +
2166 +=pod
2167 +
2168 +=head1 NAME
2169 +
2170 +Trac project environment -- add/remove/manage trac project environments
2171 +
2172 +=head2 DESCRIPTION
2173 +
2174 +This screen allows the administrator to manage Trac environments for the subversion repositories.
2175 +
2176 +=begin testing
2177 +
2178 +use esmith::FormMagick::Tester;
2179 +use esmith::TestUtils;
2180 +use esmith::TestUtils;
2181 +use esmith::ConfigDB;
2182 +use esmith::AccountsDB;
2183 +my $panel = $Original_File;
2184 +my $ua = esmith::FormMagick::Tester->new();
2185 +
2186 +my $c = esmith::ConfigDB->open();
2187 +my $a = esmith::AccountsDB->open();
2188 +
2189 +is (mode($panel), '4750', "Check permissions on script");
2190 +ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
2191 +is ($ua->{status}, 200, "200 OK");
2192 +like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
2193 +ok ($ua->set_language("en"), "Set language to English");
2194 +ok ($ua->get_panel($panel), "Get panel");
2195 +is ($ua->{status}, 200, "200 OK");
2196 +
2197 +ok ($ua->get_panel($panel), "ABOUT TO TEST CREATING TRAC ENVIRONMENT");
2198 +ok ($ua->follow("Click here"), "Follow 'create repository' link");
2199 +is ($ua->{status}, 200, "200 OK");
2200 +like($ua->{content}, qr/Create a new Trac environment/, "Saw page title");
2201 +like($ua->{content}, qr/Brief description/, "Saw description field");
2202 +like($ua->{content}, qr/Add/, "Saw add button");
2203 +
2204 +SKIP: {
2205 +
2206 + skip 10, "Unsafe!" unless destruction_ok();
2207 +
2208 + ok ($ua->follow("Click here"), "ACTUALLY ADDING A TRAC ENVIRONMENT");
2209 + $ua->field();
2210 + $ua->click("Add");
2211 + like($ua->{content}, qr/Successfully added Trac environment/, "Saw success message");
2212 +
2213 + ok ($ua->follow("Remove"), "REMOVING TRAC ENVIRONMENT");
2214 + like($ua->{content}, qr/Are you sure/, "Saw confirmation message");
2215 + $ua->click("Remove");
2216 + like($ua->{content}, qr/Successfully deleted/, "Saw success message");
2217 +}
2218 +
2219 +=end testing
2220 +
2221 +=cut
2222 +
2223 +__DATA__
2224 +<form
2225 + title="TRAC_FORM_TITLE"
2226 + header="/etc/e-smith/web/common/head.tmpl"
2227 + footer="/etc/e-smith/web/common/foot.tmpl">
2228 +
2229 + <!-- page 0 -->
2230 + <page
2231 + name="First"
2232 + pre-event="print_status_message()">
2233 +
2234 + <description>TRAC_FORM_DESCRIPTION</description>
2235 +
2236 + <subroutine src="show_trac_projects()" />
2237 + </page>
2238 +
2239 + <!-- page 1 -->
2240 + <page
2241 + name="Create"
2242 + pre-event="turn_off_buttons()"
2243 + post-event="handle_trac_projects()">
2244 +
2245 + <title>TRAC_FORM_ADD_TITLE</title>
2246 +
2247 + <description>TRAC_FORM_ADD_DESCRIPTION</description>
2248 +
2249 + <subroutine src="print_trac_field_name()" />
2250 +
2251 + <field
2252 + type="text"
2253 + id="tracDescription"
2254 + validation="validate_description">
2255 + <label>TRAC_FIELD_PROJECT_DESCRIPTION</label>
2256 + </field>
2257 +
2258 + <field
2259 + type="select"
2260 + id="tracRepository"
2261 + options="repositories_list()">
2262 + <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description>
2263 + <label>TRAC_FIELD_REPOSITORY_NAME</label>
2264 + </field>
2265 +
2266 + <field
2267 + type="text"
2268 + id="tracRepositoryPath">
2269 + <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description>
2270 + <label>TRAC_FIELD_REPOSITORY_PATH</label>
2271 + </field>
2272 +
2273 + <subroutine src="print_trac_domains()" />
2274 +
2275 + <field
2276 + type="select"
2277 + id="tracAccess"
2278 + options="'local' => 'LOCAL',
2279 + 'global' => 'GLOBAL'"
2280 + value='local'>
2281 + <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description>
2282 + <label>TRAC_FIELD_ACCESS_TYPE</label>
2283 + </field>
2284 +
2285 + <field
2286 + type="select"
2287 + id="tracGroups"
2288 + options="group_list()"
2289 + multiple="1" size="5">
2290 + <description>TRAC_FIELD_GROUPS_DESCRIPTION</description>
2291 + <label>TRAC_FIELD_GROUPS</label>
2292 + </field>
2293 +
2294 + <field
2295 + type="select"
2296 + id="tracUsers"
2297 + options="user_list()"
2298 + multiple="1" size="5">
2299 + <label>TRAC_FIELD_USERS</label>
2300 + </field>
2301 +
2302 + <subroutine src="print_save_or_add_button()" />
2303 + </page>
2304 +
2305 + <!-- page 2 -->
2306 + <page
2307 + name="Modify"
2308 + pre-event="turn_off_buttons()"
2309 + post-event="handle_trac_projects()">
2310 +
2311 + <title>TRAC_FORM_MODIFY_TITLE</title>
2312 + <description>TRAC_FORM_MODIFY_DESCRIPTION</description>
2313 +
2314 + <subroutine src="print_trac_field_name()" />
2315 +
2316 + <field
2317 + type="text"
2318 + id="tracDescription"
2319 + validation="validate_description">
2320 + <label>TRAC_FIELD_PROJECT_DESCRIPTION</label>
2321 + </field>
2322 +
2323 +
2324 + <field
2325 + type="select"
2326 + id="tracRepository"
2327 + options="repositories_list()">
2328 + <description>TRAC_FIELD_REPOSITORY_NAME_DESCRIPTION</description>
2329 + <label>TRAC_FIELD_REPOSITORY_NAME</label>
2330 + </field>
2331 +
2332 + <field
2333 + type="text"
2334 + id="tracRepositoryPath">
2335 + <description>TRAC_FIELD_REPOSITORY_PATH_DESCRIPTION</description>
2336 + <label>TRAC_FIELD_REPOSITORY_PATH</label>
2337 + </field>
2338 +
2339 + <subroutine src="print_trac_domains()" />
2340 +
2341 + <field
2342 + type="select"
2343 + id="tracAccess"
2344 + options="'local' => 'LOCAL',
2345 + 'global' => 'GLOBAL'">
2346 + <description>TRAC_FIELD_ACCESS_TYPE_DESCRIPTION</description>
2347 + <label>TRAC_FIELD_ACCESS_TYPE</label>
2348 + </field>
2349 +
2350 + <field
2351 + type="select"
2352 + id="tracGroups"
2353 + options="group_list()"
2354 + multiple="1" size="5">
2355 + <description>TRAC_FIELD_GROUPS_DESCRIPTION</description>
2356 + <label>TRAC_FIELD_GROUPS</label>
2357 + </field>
2358 +
2359 + <field
2360 + type="select"
2361 + id="tracUsers"
2362 + options="user_list()"
2363 + multiple="1" size="5">
2364 + <label>TRAC_FIELD_USERS</label>
2365 + </field>
2366 +
2367 + <subroutine src="print_save_or_add_button()" />
2368 +
2369 + </page>
2370 +
2371 + <!-- page 3 -->
2372 + <page
2373 + name="Remove"
2374 + pre-event="turn_off_buttons()"
2375 + post-event="remove_trac_project()">
2376 +
2377 + <title>TRAC_FORM_REMOVE_TITLE</title>
2378 + <description>TRAC_FORM_REMOVE_DESCRIPTION</description>
2379 +
2380 + <subroutine src="print_button('REMOVE')" />
2381 +
2382 + </page>
2383 +
2384 +</form>

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed