]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
merge save and ajax save
authorEvan Prodromou <evan@prodromou.name>
Sun, 23 Nov 2008 01:40:03 +0000 (20:40 -0500)
committerEvan Prodromou <evan@prodromou.name>
Sun, 23 Nov 2008 01:40:03 +0000 (20:40 -0500)
darcs-hash:20081123014003-84dde-ea8f5d167a544617efb22bb0c553f18d718a65c6.gz

actions/newnotice.php

index 875e862504616fc0eda8a55c246799ec6d99ee01..3c336d3b0862e4e58c525e0fd78b8b3f0e41b28b 100644 (file)
@@ -35,11 +35,7 @@ class NewnoticeAction extends Action {
                                return;
                        }
 
-                       if ($this->boolean('ajax')) {
-                               $this->ajax_save_new_notice();
-                       } else {
-                               $this->save_new_notice();
-                       }
+                       $this->save_new_notice();
                } else {
                        $this->show_form();
                }
@@ -88,67 +84,27 @@ class NewnoticeAction extends Action {
 
                common_broadcast_notice($notice);
 
-               $returnto = $this->trimmed('returnto');
-
-               if ($returnto) {
-                       $url = common_local_url($returnto,
-                                                                       array('nickname' => $user->nickname));
+               if ($this->boolean('ajax')) {
+                       common_start_html('text/xml');
+                       common_element_start('head');
+                       common_element('title', null, _('Notice posted'));
+                       common_element_end('head');
+                       common_element_start('body');
+                       $this->show_notice($notice);
+                       common_element_end('body');
+                       common_element_end('html');
                } else {
-                       $url = common_local_url('shownotice',
-                                                                       array('notice' => $notice->id));
-               }
-               common_redirect($url, 303);
-       }
-
-       function ajax_save_new_notice() {
-
-               $user = common_current_user();
-               assert($user); # XXX: maybe an error instead...
-               $content = $this->trimmed('status_textarea');
-
-               if (!$content) {
-                       $this->ajax_error_msg(_('No content!'));
-                       return;
-               } else {
-                       $content = common_shorten_links($content);
-
-                       if (mb_strlen($content) > 140) {
-                               common_debug("Content = '$content'", __FILE__);
-                               common_debug("mb_strlen(\$content) = " . mb_strlen($content), __FILE__);
-                               $this->ajax_error_msg(_('That\'s too long. Max notice size is 140 chars.'));
-                               return;
+                       $returnto = $this->trimmed('returnto');
+                       
+                       if ($returnto) {
+                               $url = common_local_url($returnto,
+                                                                               array('nickname' => $user->nickname));
+                       } else {
+                               $url = common_local_url('shownotice',
+                                                                               array('notice' => $notice->id));
                        }
+                       common_redirect($url, 303);
                }
-
-               $inter = new CommandInterpreter();
-
-               $cmd = $inter->handle_command($user, $content);
-
-               if ($cmd) {
-                       $cmd->execute(new WebChannel());
-                       return;
-               }
-
-               $replyto = $this->trimmed('inreplyto');
-
-               $notice = Notice::saveNew($user->id, $content, 'web', 1, ($replyto == 'false') ? NULL : $replyto);
-
-               if (is_string($notice)) {
-                       $this->ajax_error_msg($notice);
-                       return;
-               }
-
-               common_broadcast_notice($notice);
-
-               common_start_html('text/xml');
-               common_element_start('head');
-               common_element('title', null, _('Notice posted'));
-               common_element_end('head');
-               common_element_start('body');
-               $this->show_notice($notice);
-               common_element_end('body');
-               common_element_end('html');
-
        }
 
        function ajax_error_msg($msg) {
@@ -167,6 +123,10 @@ class NewnoticeAction extends Action {
        }
 
        function show_form($msg=NULL) {
+               if ($msg && $this->boolean('ajax')) {
+                       $this->ajax_error_msg($msg);
+                       return;
+               }
                $content = $this->trimmed('status_textarea');
                if (!$content) {
                        $replyto = $this->trimmed('replyto');