From 70235d7f05d2ce7dda77af88518612fa005783df Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 21 Aug 2009 12:13:24 +0200 Subject: Update libomb, fix some omb handling stuff, improve error handling. --- actions/postnotice.php | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'actions/postnotice.php') 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; } } ?> -- cgit v1.2.3-54-g00ecf