summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5dbae67)
Move the actual checking logic into the main library. Do the checking
in both `new' and `update' operations.
$op->bad if @ARGV;
$op->ok or Odin::fail "usage: new [-l LANG] [-t TITLE]";
$p{content} = read_content;
$op->bad if @ARGV;
$op->ok or Odin::fail "usage: new [-l LANG] [-t TITLE]";
$p{content} = read_content;
- @{$db->selectall_arrayref
- ("SELECT lang FROM odin_pastebin_lang WHERE lang = ?", undef, $p{lang})}
- or Odin::fail "unknown language `$p{lang}'";
my ($tag, $edit) = Odin::new_pastebin %p;
print "$Odin::PASTEBIN/$tag $edit\n";
} elsif ($op eq "get") {
my ($tag, $edit) = Odin::new_pastebin %p;
print "$Odin::PASTEBIN/$tag $edit\n";
} elsif ($op eq "get") {
our $PASTEBIN_PROPCOLS = join ", ", @PASTEBIN_PROPS;
our $PASTEBIN_PROPPLACES = join ", ", map "?", @PASTEBIN_PROPS;
our $PASTEBIN_PROPCOLS = join ", ", @PASTEBIN_PROPS;
our $PASTEBIN_PROPPLACES = join ", ", map "?", @PASTEBIN_PROPS;
+sub check_lang ($) {
+ my ($lang) = @_;
+
+ return unless defined $lang;
+ my $db = open_db;
+ @{$db->selectall_arrayref
+ ("SELECT lang FROM odin_pastebin_lang WHERE lang = ?", undef, $lang)}
+ or fail "unknown language `$lang'";
+}
+
sub new_pastebin (\%) {
my ($new) = @_;
sub new_pastebin (\%) {
my ($new) = @_;
my $tag;
merge_hash %$new, %PASTEBIN_DEFAULTS;
my $tag;
merge_hash %$new, %PASTEBIN_DEFAULTS;
+ check_lang $new->{lang};
xact {
$tag = encode_tag next_seq $db, "odin_pastebin_seq";
insert_record $db, "odin_pastebin",
xact {
$tag = encode_tag next_seq $db, "odin_pastebin_seq";
insert_record $db, "odin_pastebin",
my $db = open_db;
my $editp = 0;
my $db = open_db;
my $editp = 0;
+ check_lang $new->{lang};
xact {
get_pastebin_check_editkey_or_owner $db, $tag, $editkey, my %old;
for my $p (@PASTEBIN_PROPS) {
xact {
get_pastebin_check_editkey_or_owner $db, $tag, $editkey, my %old;
for my $p (@PASTEBIN_PROPS) {