[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS Update: gleipnir
- To: cvs@lists.cleannorth.org
- Subject: CVS Update: gleipnir
- From: Dan Brosemer <odin@cleannorth.org>
- Date: Sun, 17 Aug 2008 14:32:22 -0400 (EDT)
- List-help: <mailto:cvs-request@lists.cleannorth.org?subject=help>
- List-post: <mailto:cvs@lists.cleannorth.org>
- List-subscribe: <mailto:cvs-request@lists.cleannorth.org?subject=subscribe>
- List-unsubscribe: <mailto:cvs-request@lists.cleannorth.org?subject=unsubscribe>
- Resent-date: Sun, 17 Aug 2008 14:32:26 -0400 (EDT)
- Resent-from: cvs@lists.cleannorth.org
- Resent-message-id: <38WASD.A.JuC.Q7GqIB@skroob.cleannorth.org>
- Resent-sender: cvs-request@lists.cleannorth.org
Log Message:
-----------
Add a delete function and remove need for the ingroups query
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.5
retrieving revision 1.6
diff -Lpublic_html/gallery/picture.pl -Lpublic_html/gallery/picture.pl -u -r1.5 -r1.6
--- public_html/gallery/picture.pl
+++ public_html/gallery/picture.pl
@@ -40,7 +40,14 @@
do { print $gleipnir->output; exit } if $gleipnir->done;
-$gleipnir = ShowPage( -gleipnir => $gleipnir );
+if ($cgi->param('action') eq 'delete')
+ {
+ $gleipnir = DoDelete( -gleipnir => $gleipnir );
+ }
+else
+ {
+ $gleipnir = ShowPage( -gleipnir => $gleipnir );
+ };
print $gleipnir->output;
exit;
@@ -54,24 +61,15 @@
my $pictureid = $cgi->param('id')||($ENV{PATH_INFO} =~ m%/(\d+)\.(jpg|png|jpeg)$%i)[0];
- # build a where clause that will filter out pictures this user does not have access to
- my $ingroups = ();
- if ( defined( $gleipnir->groups ) )
- {
- $ingroups = join( ",", ( $gleipnir->groups ) );
- $ingroups = "or g.gid in ($ingroups)" if ($ingroups);
- }
-
- $ingroups = " gid is null " . $ingroups;
-
my $SQL = <<EOT;
-select gp.pictureid, gp.gallery, gp.image_path, gp.title, gp.caption, gp.exif, gp.uploader, gp.uploaded, g.identifier, g.description
-from gallery_picture gp left join gallery g on g.galleryid = gp.gallery where gp.pictureid = ? and ($ingroups)
+select gp.pictureid, gp.gallery, gp.image_path, gp.title, gp.caption, gp.exif, gp.uploader, gp.uploaded, g.identifier, g.description, g.gid
+from gallery_picture gp left join gallery g on g.galleryid = gp.gallery where gp.pictureid = ?
EOT
my $cursor = $dbh->prepare($SQL);
$cursor->execute( $pictureid );
my $ref = $cursor->fetchrow_hashref;
+ return $gleipnir->error('403') if defined($ref->{gid}) and !$gleipnir->ingroup($ref->{gid});
if ($ENV{PATH_INFO} =~ m/(full|thumb)\/(\d+)\.(jpg|png|jpeg)$/i)
{
@@ -80,7 +78,6 @@
binmode IMG;
my $img = join('', <DEFANGED_IMG>);
close IMG;
- #return $gleipnir->body($gleipnir->cfetch(dirs => 'imagedir').'/'.$ref->{image_path});
$gleipnir->mimetype( ( MIME::Types::by_suffix($ref->{image_path}) )[0] );
return $gleipnir->body($img);
}
@@ -104,4 +101,33 @@
return $gleipnir->body( $template->output );
};
+ };
+
+sub DoDelete
+ {
+ my %options = @_;
+ my $gleipnir = $options{-gleipnir};
+ my $cgi = $gleipnir->cgi;
+ my $dbh = $gleipnir->dbh;
+
+ my $pictureid = $cgi->param('id')||($ENV{PATH_INFO} =~ m%/(\d+)\.(jpg|png|jpeg)$%i)[0];
+
+ my $SQL = <<EOT;
+select gallery from gallery_picture
+where pictureid = ?
+EOT
+
+ my $cursor = $dbh->prepare($SQL);
+ $cursor->execute($pictureid);
+ my $gallery = $cursor->fetchrow;
+
+ $SQL = <<EOT;
+delete from gallery_picture
+where pictureid = ?
+EOT
+
+ $cursor = $dbh->prepare($SQL);
+ $cursor->execute($pictureid);
+
+ return $gleipnir->url('/gallery/?gallery='.$gallery);
};
- Prev by Date: CVS Update: gleipnir
- Next by Date: CVS Update: svartalfheim.net
- Previous by thread: CVS Update: gleipnir
- Next by thread: CVS Update: gleipnir
- Index(es):