3 # Debian-specific script to register a new theme into the Gforge database
9 use vars qw/$dbh @reqlist $thdir $thname/ ;
13 require ("/usr/share/gforge/lib/include.pl") ; # Include all the predefined functions
18 debug "Usage: register-theme <dirname> <theme name>" ;
19 debug "The theme must be in /usr/share/gforge/www/themes/<dirname>/" ;
26 unless (-d "/usr/share/gforge/www/themes/$thdir") {
27 debug "The directory /usr/share/gforge/www/themes/$thdir does not exist" ;
30 unless (-e "/usr/share/gforge/www/themes/$thdir/Theme.class.php") {
31 debug "The file /usr/share/gforge/www/themes/$thdir/Theme.class.php does not exist" ;
35 $dbh->{AutoCommit} = 0;
36 $dbh->{RaiseError} = 1;
38 my ($query, $sth, @array, $version, $action) ;
40 $thdir = $dbh->quote ($thdir) ;
41 $thname = $dbh->quote ($thname) ;
43 $query = "SELECT count(*) FROM themes WHERE dirname=$thdir" ;
44 $sth = $dbh->prepare($query) ;
46 @array = $sth->fetchrow_array() ;
49 if ($array [0] != 0) {
50 $query = "UPDATE themes SET enabled=true WHERE dirname=$thdir" ;
52 $query = "INSERT INTO themes (dirname, fullname) VALUES ($thdir, $thname)" ;
57 $sth = $dbh->prepare ($query) ;
61 # debug "Committing." ;
64 # There should be a commit at the end of every block above.
65 # If there is not, then it might be symptomatic of a problem.
66 # For safety, we roll back.
71 warn "Transaction aborted because $@" ;
72 debug "Transaction aborted because $@" ;
74 debug "Please report this bug on the Debian bug-tracking system." ;
75 debug "Please include the previous messages as well to help debugging." ;
76 debug "You should not worry too much about this," ;
77 debug "your DB is still in a consistent state and should be usable." ;