if (!common_logged_in()) {
common_user_error(_t('Not logged in.'));
} else if ($this->arg('METHOD') == 'POST') {
- if ($this->save_new_notice()) {
- # XXX: smarter redirects
- $user = common_current_user();
- assert(!is_null($user)); # see if... above
- # XXX: redirect to source
- # XXX: use Ajax instead of a redirect
- common_redirect(common_local_url('all',
- array('nickname' =>
- $user->nickname)));
+ $id = $this->save_new_notice();
+
+ if ($id) {
+ common_broadcast_notices($id);
+ common_redirect(common_local_url('shownotice',
+ array('notice' => $id)), 303);
} else {
common_server_error(_t('Problem saving notice.'));
}
+ common_local_url()
- configuration for DB_DataObject
+ date formatting
++ new notice redirects to notice page
++ date in shown notice links to notice page
++ common_redirect()
- release 0.1
- require valid nicknames
- store canonical username for comparison and fetch
$config =
array('site' =>
- array('name' => 'Just another µB'),
+ array('name' => 'Just another µB',
+ 'server' => 'localhost',
+ 'path' => '/'),
'avatar' =>
array('directory' => INSTALLDIR . 'files',
'path' => '/files'),
}
function common_local_url($action, $args) {
+ global $config;
/* XXX: pretty URLs */
$extra = '';
foreach ($args as $key => $value) {
$extra .= "&${key}=${value}";
}
- /* XXX: correct path */
- return "/index.php?action=${action}${extra}";
+ return "http://".$config['site']['server'].'/'.$config['site']['path']."/index.php?action=${action}${extra}";
}
function commmon_date_string($dt) {
return date(DATE_RFC822);
}
+function common_redirect($url, $code=307) {
+ static $status = (301 => "Moved Permanently",
+ 302 => "Found",
+ 303 => "See Other",
+ 307 => "Temporary Redirect");
+ header("Status: ${code} $status[$code]");
+ header("Location: $url");
+ common_element('a', array('href' => $url), $url);
+}
+
+function common_broadcast_notices($id) {
+ // XXX: broadcast notices to remote subscribers
+ // XXX: broadcast notices to SMS
+ // XXX: broadcast notices to Jabber
+ // XXX: broadcast notices to other IM
+ // XXX: use a queue system like http://code.google.com/p/microapps/wiki/NQDQ
+ return true;
+}
+
// XXX: set up gettext
function _t($str) { $str }
$profile->nickname);
# FIXME: URL, image, video, audio
common_element('span', array('class' => 'content'), $notice->content);
- common_element('span', array('class' => 'date'),
+ $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
+ common_element('a', array('class' => 'notice',
+ 'href' => $noticeurl),
common_date_string($notice->created));
common_end_element('div');
}