]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/newnotice.php
add design classes
[quix0rs-gnu-social.git] / actions / newnotice.php
index 9face9644356a0a08375f3dfdeee1dda5d7a7059..ae0ff9636335809f2e9aaca4697d56b567e85332 100644 (file)
@@ -152,8 +152,14 @@ class NewnoticeAction extends Action
         }
 
         $replyto = $this->trimmed('inreplyto');
+        #If an ID of 0 is wrongly passed here, it will cause a database error,
+        #so override it...
+        if ($replyto == 0) {
+            $replyto = 'false';
+        }
 
-        $notice = Notice::saveNew($user->id, $content, 'web', 1,
+//        $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
+        $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
                                   ($replyto == 'false') ? null : $replyto);
 
         if (is_string($notice)) {
@@ -161,6 +167,8 @@ class NewnoticeAction extends Action
             return;
         }
 
+        $this->saveUrls($notice);
+
         common_broadcast_notice($notice);
 
         if ($this->boolean('ajax')) {
@@ -186,6 +194,24 @@ class NewnoticeAction extends Action
         }
     }
 
+    /** save all urls in the notice to the db
+     *
+     * follow redirects and save all available file information
+     * (mimetype, date, size, oembed, etc.)
+     *
+     * @param class $notice Notice to pull URLs from
+     *
+     * @return void
+     */
+    function saveUrls($notice) {
+        common_replace_urls_callback($notice->content, array($this, 'saveUrl'), $notice->id);
+    }
+
+    function saveUrl($data) {
+        list($url, $notice_id) = $data;
+        $zzz = File::processNew($url, $notice_id);
+    }
+
     /**
      * Show an Ajax-y error message
      *
@@ -253,7 +279,7 @@ class NewnoticeAction extends Action
             }
         }
 
-        $notice_form = new NoticeForm($this, $content);
+        $notice_form = new NoticeForm($this, '', $content);
         $notice_form->show();
     }