]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
better deletion of old avatars
[quix0rs-gnu-social.git] / actions / newnotice.php
index a4cc7d3aefa207ba048781018dc305cb0d60c55d..fa7badd3def07fb7906b2061c7ebd1af34e92136 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1) }
+if (!defined('LACONICA')) { exit(1); }
 
 class NewnoticeAction extends Action {
        
@@ -27,16 +27,12 @@ class NewnoticeAction extends Action {
 
                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 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+                       $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.'));
                        }
@@ -51,17 +47,19 @@ class NewnoticeAction extends Action {
                $notice = DB_DataObject::factory('notice');
                assert($notice);
                $notice->profile_id = $user->id; # user id *is* profile id
+               $notice->created = DB_DataObject_Cast::dateTime();
                $notice->content = $this->arg('content');
-               $notice->created = time();
                return $notice->insert();
        }
        
        function show_form() {
-               common_start_element('form', array('id' => 'newnotice', 'method' => 'POST',
+               common_element_start('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');
+               common_element('textarea', array('rows' => 4, 'cols' => 80,
+                                                                                'name' => 'content', 
+                                                                                'id' => 'content'));
+               common_element('input', array('type' => 'submit', 'value' => 'Send'));
+               common_element_end('form');
        }
 }
\ No newline at end of file