summaryrefslogtreecommitdiff
path: root/actions/newnotice.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-05-14 10:54:36 -0400
committerEvan Prodromou <evan@prodromou.name>2008-05-14 10:54:36 -0400
commit67a347bafb875be60e7554f308d80d7f0a1d2747 (patch)
treefb7d54dff5e84e1e22b1c5fca882a5f776e1d4a9 /actions/newnotice.php
parentf0a30cc89ddf82e3c774800d24f0ea3664065d9c (diff)
considerable coding
darcs-hash:20080514145436-84dde-d0994cb35d3fe8545d3f08abeec3cdfe7559c67d.gz
Diffstat (limited to 'actions/newnotice.php')
-rw-r--r--actions/newnotice.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php
new file mode 100644
index 000000000..bbfa3285d
--- /dev/null
+++ b/actions/newnotice.php
@@ -0,0 +1,48 @@
+<?php
+
+class NewnoticeAction extends Action {
+
+ function handle($args) {
+ parent::handle($args);
+ # XXX: Ajax!
+
+ 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)));
+ } else {
+ common_server_error(_t('Problem saving notice.'));
+ }
+ } else {
+ $this->show_form();
+ }
+ }
+
+ function save_new_notice() {
+ $user = common_current_user();
+ assert($user); # XXX: maybe an error instead...
+ $notice = DB_DataObject::factory('notice');
+ assert($notice);
+ $notice->profile_id = $user->id; # user id *is* profile id
+ $notice->content = $this->arg('content');
+ $notice->created = time();
+ return $notice->insert();
+ }
+
+ function show_form() {
+ common_start_element('form', array('id' => 'newnotice', 'method' => 'POST',
+ 'action' => common_local_url('newnotice')));
+ common_element('span', 'nickname', $profile->nickname);
+ common_element('textarea', array('rows' => 4, 'cols' => 80, 'id' => 'content'));
+ common_element('input', array('type' => 'submit'), 'Send');
+ common_end_element('form');
+ }
+} \ No newline at end of file