]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/classes/Bookmark.php
Merge branch 'master' into social-master
[quix0rs-gnu-social.git] / plugins / Bookmark / classes / Bookmark.php
index 65c767efddaffc36212daa00707d2cd8df6babb2..b86746dde797c6f76c9d446bc68b4f7e01c1ff30 100644 (file)
@@ -92,7 +92,7 @@ class Bookmark extends Managed_DataObject
      *
      * @return Bookmark found bookmark or null
      */
-    static function getByNotice($notice)
+    static function getByNotice(Notice $notice)
     {
         return self::getKV('uri', $notice->uri);
     }
@@ -105,7 +105,7 @@ class Bookmark extends Managed_DataObject
      *
      * @return Bookmark bookmark found or null
      */
-    static function getByURL($profile, $url)
+    static function getByURL(Profile $profile, $url)
     {
         $nb = new Bookmark();
 
@@ -131,9 +131,13 @@ class Bookmark extends Managed_DataObject
      *
      * @return Notice saved notice
      */
-    static function saveNew($profile, $title, $url, $rawtags, $description,
-                            $options=null)
+    static function saveNew(Profile $profile, $title, $url, $rawtags, $description,
+                            array $options=array())
     {
+        if (!common_valid_http_url($url)) {
+            throw new ClientException(_m('Only web bookmarks can be posted (HTTP or HTTPS).'));
+        }
+
         $nb = self::getByURL($profile, $url);
 
         if (!empty($nb)) {
@@ -141,10 +145,6 @@ class Bookmark extends Managed_DataObject
             throw new ClientException(_m('Bookmark already exists.'));
         }
 
-        if (empty($options)) {
-            $options = array();
-        }
-
         if (array_key_exists('uri', $options)) {
             $other = Bookmark::getKV('uri', $options['uri']);
             if (!empty($other)) {