protected function doPreparation()
{
foreach(array('inreplyto') as $opt) {
- if (!empty($this->trimmed($opt))) {
+ if ($this->trimmed($opt)) {
$this->formOpts[$opt] = $this->trimmed($opt);
}
}
+
+ if ($this->trimmed('content')) {
+ $this->formOpts['content'] = $this->trimmed('content');
+ }
}
/**
$options['reply_to'] = $replyto;
}
- $upload = MediaFile::fromUpload('attach', $this->scoped);
-
- if (isset($upload)) {
-
+ $upload = null;
+ try {
+ // throws exception on failure
+ $upload = MediaFile::fromUpload('attach', $this->scoped);
if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content_shortened, &$options))) {
$content_shortened .= ' ' . $upload->shortUrl();
}
Notice::maxContent()),
Notice::maxContent()));
}
+ } catch (NoUploadedMediaException $e) {
+ // simply no attached media to the new notice
}
+
if ($this->scoped->shareLocation()) {
// use browser data if checked; otherwise profile data
if ($this->arg('notice_data-geo')) {
$this->stored = Notice::saveNew($this->scoped->id, $content_shortened, 'web', $options);
- if (isset($upload)) {
+ if ($upload instanceof MediaFile) {
$upload->attachToNotice($this->stored);
}
Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
if (!StatusNet::isAjax()) {
- $returnto = $this->trimmed('returnto');
-
- if ($returnto) {
- $url = common_local_url($returnto,
- array('nickname' => $this->scoped->getNickname()));
- } else {
- $url = common_local_url('shownotice', array('notice' => $this->stored->id));
- }
+ $url = common_local_url('shownotice', array('notice' => $this->stored->id));
common_redirect($url, 303);
}
$nli = new NoticeListItem($notice, $this);
$nli->show();
}
+
+ public function showNoticeForm()
+ {
+ // pass
+ }
}