3 class NewnoticeAction extends Action {
5 function handle($args) {
9 if (!common_logged_in()) {
10 common_user_error(_t('Not logged in.'));
11 } else if ($this->arg('METHOD') == 'POST') {
12 if ($this->save_new_notice()) {
13 # XXX: smarter redirects
14 $user = common_current_user();
15 assert(!is_null($user)); # see if... above
16 # XXX: redirect to source
17 # XXX: use Ajax instead of a redirect
18 common_redirect(common_local_url('all',
22 common_server_error(_t('Problem saving notice.'));
29 function save_new_notice() {
30 $user = common_current_user();
31 assert($user); # XXX: maybe an error instead...
32 $notice = DB_DataObject::factory('notice');
34 $notice->profile_id = $user->id; # user id *is* profile id
35 $notice->content = $this->arg('content');
36 $notice->created = time();
37 return $notice->insert();
40 function show_form() {
41 common_start_element('form', array('id' => 'newnotice', 'method' => 'POST',
42 'action' => common_local_url('newnotice')));
43 common_element('span', 'nickname', $profile->nickname);
44 common_element('textarea', array('rows' => 4, 'cols' => 80, 'id' => 'content'));
45 common_element('input', array('type' => 'submit'), 'Send');
46 common_end_element('form');