forked from GNUsocial/gnu-social
User friendlieness in scripts/delete_notice.php
This commit is contained in:
parent
2669c51265
commit
2730510393
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
|
|
||||||
$shortoptions = 'i::n::u::y';
|
$shortoptions = 'i::u::y';
|
||||||
$longoptions = array('id=', 'nickname=', 'uri=', 'yes');
|
$longoptions = array('id=', 'uri=', 'yes');
|
||||||
|
|
||||||
$helptext = <<<END_OF_HELP
|
$helptext = <<<END_OF_HELP
|
||||||
delete_notice.php [options]
|
delete_notice.php [options]
|
||||||
@ -35,22 +35,19 @@ END_OF_HELP;
|
|||||||
|
|
||||||
require_once INSTALLDIR.'/scripts/commandline.inc';
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
if (have_option('i', 'id')) {
|
try {
|
||||||
|
if (have_option('i', 'id')) {
|
||||||
$id = get_option_value('i', 'id');
|
$id = get_option_value('i', 'id');
|
||||||
$notice = Notice::getByID($id);
|
$notice = Notice::getByID($id);
|
||||||
if (!$notice instanceof Notice) {
|
} else if (have_option('u', 'uri')) {
|
||||||
print "Can't find notice with ID $id\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else if (have_option('u', 'uri')) {
|
|
||||||
$uri = get_option_value('u', 'uri');
|
$uri = get_option_value('u', 'uri');
|
||||||
$notice = Notice::getKV('uri', $uri);
|
$notice = Notice::getByUri($uri);
|
||||||
if (!$notice instanceof Notice) {
|
} else {
|
||||||
print "Can't find notice with URI '$uri'\n";
|
print $helptext;
|
||||||
exit(1);
|
throw new ClientException('You must provide either an ID or a URI.');
|
||||||
}
|
}
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
print "You must provide either an ID, a URI or a nickname.\n";
|
print "ERROR: {$e->getMessage()}\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user