[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS Update: gleipnir



Log Message:
-----------
Edit picture

Modified Files:
--------------
    gleipnir/public_html/gallery:
        picture.pl

Revision Data
-------------
Index: picture.pl
===================================================================
RCS file: /cvs/gleipnir/public_html/gallery/picture.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lpublic_html/gallery/picture.pl -Lpublic_html/gallery/picture.pl -u -r1.11 -r1.12
--- public_html/gallery/picture.pl
+++ public_html/gallery/picture.pl
@@ -41,15 +41,19 @@
 
 do { print $gleipnir->output; exit } if $gleipnir->done;
 
-if ($cgi->param('action') eq 'delete')
+if ($gleipnir->access('galleryadmin') && ($cgi->param('action') eq 'edit'))
+	{
+		$gleipnir = Edit( -gleipnir => $gleipnir );
+	}
+elsif ($gleipnir->access('galleryadmin') && ($cgi->param('action') eq 'delete'))
 	{
 		$gleipnir = DoDelete( -gleipnir => $gleipnir );
 	}
-elsif ($cgi->param('action') eq 'rotate90')
+elsif ($gleipnir->access('galleryadmin') && ($cgi->param('action') eq 'rotate90'))
 	{
 		$gleipnir = Rotate( -gleipnir => $gleipnir, -angle => 90 );
 	}
-elsif ($cgi->param('action') eq 'rotate270')
+elsif ($gleipnir->access('galleryadmin') && ($cgi->param('action') eq 'rotate270'))
 	{
 		$gleipnir = Rotate( -gleipnir => $gleipnir, -angle => 270 );
 	}
@@ -231,4 +235,52 @@
 		$cursor->execute($rotated, $pictureid);
 
 		return $gleipnir->url('/gallery/picture.pl?id='.$pictureid);
+	};
+
+sub Edit
+	{
+		my %options  = @_;
+		my $gleipnir = $options{-gleipnir};
+		my $cgi      = $gleipnir->cgi;
+		my $dbh      = $gleipnir->dbh;
+
+		if ($cgi->param('submit'))
+			{
+				my $SQL = <<EOT;
+update gallery_picture
+set gallery = ?, caption = ?, title = ?
+where pictureid = ?
+EOT
+
+				my $cursor = $dbh->prepare($SQL);
+				$cursor->execute($cgi->param('gallery'), $cgi->param('caption'), $cgi->param('title'), $cgi->param('id'));
+				return $gleipnir->url('/gallery/picture.pl?id='.$cgi->param('id'));
+			};
+
+		my $SQL = <<EOT;
+select galleryid, identifier, gid
+from gallery order by identifier
+EOT
+
+		my @galleries = ();
+		my $cursor = $dbh->prepare($SQL);
+		$cursor->execute();
+		while (my $ref = $cursor->fetchrow_hashref)
+			{
+				push @galleries, {id => $ref->{galleryid}, title => $ref->{identifier}, selected => ($ref->{galleryid}==$cgi->param('id'))} if $gleipnir->ingroup($ref->{gid});
+			};
+
+		$SQL = <<EOT;
+select caption, title
+from gallery_picture
+where pictureid = ?
+EOT
+
+		$cursor = $dbh->prepare($SQL);
+		$cursor->execute($cgi->param('id'));
+		my ($caption, $title) = $cursor->fetchrow;
+
+		my $template = $gleipnir->template('gallery/edit');
+		$template->param(galleries => \@galleries, title => $title, caption => $caption, id => $cgi->param('id'));
+		return $gleipnir->body($template->output);
 	};


Main Menu:

Site Tools:


Here, spammer, have some addresses.