[open-ils-commits] r76 - in sitka: . trunk trunk/src trunk/src/cgi-bin

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Dec 3 13:16:24 EST 2008


Author: jamesrf
Date: 2008-12-03 13:16:21 -0500 (Wed, 03 Dec 2008)
New Revision: 76

Added:
   sitka/trunk/
   sitka/trunk/src/
   sitka/trunk/src/cgi-bin/
   sitka/trunk/src/cgi-bin/wsdelete.cgi
   sitka/trunk/src/javascript/
Log:
WS Deletion tool added

Added: sitka/trunk/src/cgi-bin/wsdelete.cgi
===================================================================
--- sitka/trunk/src/cgi-bin/wsdelete.cgi	                        (rev 0)
+++ sitka/trunk/src/cgi-bin/wsdelete.cgi	2008-12-03 18:16:21 UTC (rev 76)
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+
+#SECURE YOUR cgi-bin!
+
+#path to your oils_header file
+require '/openils/var/oils_header.pl';
+
+use vars qw/ $apputils $memcache $user $authtoken $authtime /;
+use strict; use warnings;
+use OpenSRF::Utils::JSON;
+use CGI;
+my $query = new CGI;
+
+#if no wsname has been parametered show the form
+if (!$query->param('wsname')) {
+	print "Content-type: text/html\n\n";
+	print "<html>\n";
+	print "<head><title>Magic WS Delete-o-tron</title></head>\n";
+	print "<body>";
+	print "<form action=\"wsdelete.cgi\" method=\"post\">\n";
+	print "<h1>MAGIC WS DELETE-O-TRON!!</h1>";
+	print "<b>Full Workstation Name (case sensitive):</b><input type=\"text\" name=\"wsname\"/>\n";
+	print "<br/>";
+	print "<b>EG admin password:</b><input type=\"password\" name=\"pass\"/>\n";
+	print "<input type=\"submit\"/><br/>\n";
+	print "</form>\n";
+	print "</body>\n";
+	print "</html>\n";
+	
+#if there's a wsname, try to do something with it
+} else {
+	my $wsname = $query->param('wsname');
+	print "Content-type: text/html\n\n";
+	print "<html>\n";
+	print "<head><title>Workstation Deletion</title></head>\n";
+	print "<body>\n";
+
+	osrf_connect('/openils/conf/opensrf_core.xml');
+	oils_login('admin', $query->param('pass')) or die $!;
+
+	my $wsid = searchWS($wsname);
+	
+	if ($wsid){
+		doDeleteWS($wsid);
+		print "Workstation # $wsid ( $wsname ) has probably been deleted!";
+	} else {
+		print "Workstation $wsname Not Found!";
+	}
+	print "</body>";
+	print "</html>";
+
+}
+
+sub searchWS {
+	my $wsname = shift;
+	my $ws = simplereq( 'open-ils.storage', 
+			'open-ils.storage.direct.actor.workstation.search', 
+			{ 'name' => $wsname }
+			); 
+	oils_event_die($ws);
+	if ($ws) {
+		return $ws->id;
+	} else {
+		return;
+	}
+}
+
+
+sub doDeleteWS {
+	my $wsid = shift;
+		simplereq( 'open-ils.storage', 
+				'open-ils.storage.transaction.begin' );
+		simplereq( 'open-ils.storage', 
+					'open-ils.storage.direct.actor.workstation.delete',
+					$wsid);
+		simplereq( 'open-ils.storage', 
+				'open-ils.storage.transaction.commit' );
+}
+			
\ No newline at end of file


Property changes on: sitka/trunk/src/cgi-bin/wsdelete.cgi
___________________________________________________________________
Name: svn:executable
   + *



More information about the open-ils-commits mailing list