diff options
author | Adrian Lang <mail@adrianlang.de> | 2009-08-21 12:13:24 +0200 |
---|---|---|
committer | Adrian Lang <mail@adrianlang.de> | 2009-08-21 12:13:24 +0200 |
commit | 70235d7f05d2ce7dda77af88518612fa005783df (patch) | |
tree | f8722056494597d047c545def94bd82ea1238dcc /actions/postnotice.php | |
parent | b0bb1fff2e79a01b2fa2eece79d2c644860bbb97 (diff) |
Update libomb, fix some omb handling stuff, improve error handling.
Diffstat (limited to 'actions/postnotice.php')
-rw-r--r-- | actions/postnotice.php | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/actions/postnotice.php b/actions/postnotice.php index 74be47119..97e887c46 100644 --- a/actions/postnotice.php +++ b/actions/postnotice.php @@ -47,12 +47,28 @@ require_once INSTALLDIR.'/extlib/libomb/service_provider.php'; */ class PostnoticeAction extends Action { + /** + * For initializing members of the class. + * + * @param array $argarray misc. arguments + * + * @return boolean true + */ + function prepare($argarray) + { + parent::prepare($argarray); + try { + $this->checkNotice(); + } catch (Exception $e) { + $this->clientError($e->getMessage()); + return false; + } + return true; + } + function handle($args) { parent::handle($args); - if (!$this->checkNotice()) { - return; - } try { $srv = new OMB_Service_Provider(null, omb_oauth_datastore(), omb_oauth_server()); @@ -67,10 +83,15 @@ class PostnoticeAction extends Action { $content = common_shorten_links($_POST['omb_notice_content']); if (mb_strlen($content) > 140) { - $this->clientError(_('Invalid notice content'), 400); - return false; + throw new Exception(_('The notice content is too long.')); + } + $license = $_POST['omb_notice_license']; + $site_license = common_config('license', 'url'); + if ($license && !common_compatible_license($license, $site_license)) { + throw new Exception(sprintf(_('Notice license ā%sā is not ' . + 'compatible with site license ā%sā.'), + $license, $site_license)); } - return true; } } ?> |