exit(1);
}
-require_once INSTALLDIR . '/lib/noticelist.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
/**
* Action for posting new notices
*
return _m('TITLE','New notice');
}
- /**
- * Handle input, produce output
- *
- * Switches based on GET or POST method. On GET, shows a form
- * for posting a notice. On POST, saves the results of that form.
- *
- * Results may be a full page, or just a single notice list item,
- * depending on whether AJAX was requested.
- *
- * @param array $args $_REQUEST contents
- *
- * @return void
- */
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
-
- if (!common_logged_in()) {
- // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
- $this->clientError(_('Not logged in.'), 403);
- }
-
- return true;
- }
-
/**
* This handlePost saves a new notice, based on arguments
*
*/
protected function handlePost()
{
+ parent::handlePost();
+
assert($this->scoped); // XXX: maybe an error instead...
$user = $this->scoped->getUser();
$content = $this->trimmed('status_textarea');
$options['reply_to'] = $replyto;
}
- $upload = null;
- $upload = MediaFile::fromUpload('attach');
+ $upload = MediaFile::fromUpload('attach', $this->scoped);
if (isset($upload)) {
}
}
- if ($user->shareLocation()) {
+ if ($this->scoped->shareLocation()) {
// use browser data if checked; otherwise profile data
if ($this->arg('notice_data-geo')) {
$locOptions = Notice::locationOptions($this->trimmed('lat'),
$this->trimmed('lon'),
$this->trimmed('location_id'),
$this->trimmed('location_ns'),
- $user->getProfile());
+ $this->scoped);
} else {
$locOptions = Notice::locationOptions(null,
null,
null,
null,
- $user->getProfile());
+ $this->scoped);
}
$options = array_merge($options, $locOptions);
}
- $author_id = $user->id;
+ $author_id = $this->scoped->id;
$text = $content_shortened;
// Does the heavy-lifting for getting "To:" information
if (Event::handle('StartNoticeSaveWeb', array($this, &$author_id, &$text, &$options))) {
- $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options);
+ $notice = Notice::saveNew($this->scoped->id, $content_shortened, 'web', $options);
if (isset($upload)) {
$upload->attachToNotice($notice);
Event::handle('EndNoticeSaveWeb', array($this, $notice));
}
+
+ assert($notice instanceof Notice);
+
Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options));
if (StatusNet::isAjax()) {
- header('Content-Type: text/xml;charset=utf-8');
- $this->xw->startDocument('1.0', 'UTF-8');
- $this->elementStart('html');
+ $this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Page title after sending a notice.
$this->element('title', null, _('Notice posted'));
$this->elementStart('body');
$this->showNotice($notice);
$this->elementEnd('body');
- $this->elementEnd('html');
+ $this->endHTML();
exit;
} else {
$returnto = $this->trimmed('returnto');
if ($returnto) {
$url = common_local_url($returnto,
- array('nickname' => $user->nickname));
+ array('nickname' => $this->scoped->nickname));
} else {
$url = common_local_url('shownotice',
array('notice' => $notice->id));
$this->elementStart('body');
$this->element('p', array('id' => 'error'), $msg);
$this->elementEnd('body');
- $this->elementEnd('html');
+ $this->endHTML();
}
/**
$form->show();
$this->elementEnd('body');
- $this->elementEnd('html');
+ $this->endHTML();
}
/**
*
* @return void
*/
- function showNotice($notice)
+ function showNotice(Notice $notice)
{
$nli = new NoticeListItem($notice, $this);
$nli->show();