diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-05-18 13:58:29 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-05-18 13:58:29 (GMT) |
commit | 97323fb5f40779cf38a96325ece5efb16812870d (patch) | |
tree | 075973ea92eb9f1803155dac9fcc6dd33b85ce76 | |
parent | 635dfff6d078e40afef725be9041a52a8a9d0189 (diff) |
rhrd-show can now edit show info
-rwxr-xr-x | lib/RHRD/rddb.pm | 18 | ||||
-rwxr-xr-x | utils/rhrd-show | 22 |
2 files changed, 34 insertions, 6 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm index 1172acd..1286a46 100755 --- a/lib/RHRD/rddb.pm +++ b/lib/RHRD/rddb.pm @@ -1492,6 +1492,24 @@ sub create_show_dropbox return ($cnt, 'OK', 'success'); } +sub update_show_dropbox +{ + my ($ctx, $show_id, $rhythm, $dow, $starttime, $len) = @_; + my $param = join(';', ('S', $rhythm, $dow, $starttime, $len)); + + my $sql = qq{update DROPBOXES set SET_USER_DEFINED = ? where TO_CART = ?}; + + my $sth = $ctx->{'dbh'}->prepare($sql) + or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr); + + my $cnt = $sth->execute($param, $show_id) + or return (undef, 'ERROR', "Database Error: " . $sth->errstr); + + $sth->finish(); + + return ($cnt, 'OK', 'success'); +} + sub remove_show { my ($ctx, $showid) = @_; diff --git a/utils/rhrd-show b/utils/rhrd-show index cab6ead..731b627 100755 --- a/utils/rhrd-show +++ b/utils/rhrd-show @@ -21,7 +21,6 @@ # use strict; -use lib "../lib/"; use RHRD::rddb; use RHRD::utils; use Date::Calc; @@ -180,9 +179,10 @@ sub add return 0; } + sub edit__check_arguments { - my ($showid, $title, $rhythm, $dow, $starttime, $len) = @_; + my ($show_id, $title, $rhythm, $dow, $starttime, $len) = @_; my ($result, $err, $hint) = RHRD::utils::dropbox_param_rhythm_ok($rhythm); unless($result) { @@ -213,16 +213,26 @@ sub edit__check_arguments sub edit { - my ($ctx, $showid, $title, $rhythm, $dow, $starttime, $len) = @_; + my ($ctx, $show_id, $title, $rhythm, $dow, $starttime, $len) = @_; - my $ret = edit__check_arguments($showid, $title, $rhythm, $dow, $starttime, $len); + my $ret = edit__check_arguments($show_id, $title, $rhythm, $dow, $starttime, $len); if($ret) { return $ret; } + ($dow, undef, undef) = RHRD::utils::cmdline_dow($dow); - print " not yet implemented!!\n"; + my ($result, $status, $errorstring) = RHRD::rddb::update_show_dropbox($ctx, $show_id, $rhythm, $dow, $starttime, $len); + unless(defined $result) { + print STDERR $status . ": " . $errorstring . "\n"; + return 1; + } + if ($result != 1) { + print "show '" . $show_id ."' does not exist.\n"; + return 1; + } - return 1; + print "show '" . $show_id . "' successfully changed!\n"; + return 0; } sub remove |