From: Banana Date: Wed, 15 Jun 2011 11:24:12 +0000 (+0200) Subject: add bookmark only if title and url is set X-Git-Tag: 2.1-alpha-2019-0-29~122 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=9bfa0d8673d0fb99e5008b5aa1631ed9f564c53b;p=insipid.git add bookmark only if title and url is set --- diff --git a/BUGS b/BUGS index bb00faa..8ee0a88 100644 --- a/BUGS +++ b/BUGS @@ -1,7 +1,5 @@ === Open Bugs === -* Add possible even if no data is inserted ! -* Add form shown although not logged in * Case-sensitivity in SELECT statements with Postgres really do a number on the tag algorithms * Tag operations (op=tags) or not working yet. diff --git a/ChangeLog b/ChangeLog index 785e8dc..3e59dce 100755 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * tag suggest was not working correctly. * tag rename feature implemented * tag rename case sensitive problem + * add bookmark only if url and title are not empty Tue Jul 14 21:38 EST 2009 Luke Reeve diff --git a/lib/Insipid/Main.pm b/lib/Insipid/Main.pm index bbf4188..49f8538 100755 --- a/lib/Insipid/Main.pm +++ b/lib/Insipid/Main.pm @@ -141,16 +141,14 @@ sub main { # JSON # JSON Show tags: if (url_param('op') eq 'json_tags') { - print - "Content-Type: application/x-javascript;charset=UTF-8\r\n\r\n"; + print "Content-Type: application/x-javascript;charset=UTF-8\r\n\r\n"; send_json_tags(); exit; } # JSON Show bookmarks: if (url_param('op') eq 'json_posts') { - print - "Content-Type: application/x-javascript;charset=UTF-8\r\n\r\n"; + print "Content-Type: application/x-javascript;charset=UTF-8\r\n\r\n"; send_json_posts(); exit; } @@ -226,8 +224,7 @@ DOC # If the user just saved a bookmark, redirect them now. if ($redirect ne "") { - print - ""; + print ""; print ""; exit; } @@ -241,8 +238,7 @@ DOC if (url_param('op') eq 'export') { if (!defined(param('target'))) { print "

"; - print - "Include Snapshots
"; + print "Include Snapshots
"; print "
"; } } @@ -277,12 +273,9 @@ IFORM login_form(); } - if ((param('op') eq 'add_bookmark') || (param('op') eq 'edit_bookmark')) - { - + if ((param('op') eq 'add_bookmark') || (param('op') eq 'edit_bookmark')) { check_access(); - - #check to see if the url is bookmarked, then indicate that this is an edit. + #check to see if the url is bookmarked, then indicate that this is an edit. my ( $id, $url, $title, $description, $button, $tags, @@ -297,6 +290,11 @@ IFORM param('description'), param('tags') ); + if($url == '' || $title == '') { + print "URL or Title can not be empty"; + exit; + } + if (defined(param('access_level'))) { if (param('access_level') eq 'on') { $access_level = 1; @@ -306,11 +304,9 @@ IFORM } if (param('id')) { - update_bookmark(param('id'), $url, $title, $description, - $access_level, $tags); + update_bookmark(param('id'), $url, $title, $description, $access_level, $tags); } else { - add_bookmark($url, $title, $description, $access_level, 0, - $tags); + add_bookmark($url, $title, $description, $access_level, 0, $tags); if (param('snapshot')) { if (param('snapshot') eq 'on') { $id = get_bookmark_id(param('url')); @@ -327,8 +323,7 @@ IFORM } } } else { - - # Show the form, populating from the database if it's an existing entry. + # Show the form, populating from the database if it's an existing entry. my $utext = "URL:"; my $snapshot_params = ""; $id = "-1"; @@ -347,10 +342,8 @@ IFORM get_bookmark($id); $tags = get_tags($url); $button = "Save"; - $utext = - "URL (already bookmarked):"; - $extra_params = - ""; + $utext = "URL (already bookmarked):"; + $extra_params = ""; } else { # There has to be a nicer way to do this. @@ -361,8 +354,7 @@ IFORM } $access_level = 1; $button = "Add"; - $snapshot_params = - "Snapshot:\n"; + $snapshot_params = "Snapshot:\n"; } my $style = "style=\"width:500px\""; @@ -375,7 +367,7 @@ IFORM } if ($access_level eq 0) {$access_box = "";} - else {$access_box = "checked=\"true\" ";} + else {$access_box = "checked=\"true\" ";} if ($redir eq 'on') {$redir_box = "checked=\"true\"";} @@ -523,8 +515,7 @@ sub show_options { if ($hr->{'name'} eq 'version') { print "$hr->{'value'}"; } else { - print - "{'name'}\" value=\"$hr->{'value'}\" />"; + print "{'name'}\" value=\"$hr->{'value'}\" />"; } print ""; } @@ -634,8 +625,7 @@ sub do_import { $tagvalue = ""; } - add_bookmark($url, $title, "", $access_level, $epoch, $tagvalue, - 1); + add_bookmark($url, $title, "", $access_level, $epoch, $tagvalue, 1); } # Option