Esempio n. 1
0
 /**
  * Checks for existence of a source url (in social bookmarking)
  *
  * @return array|false - array of exitsing posts
  */
 public function urlExists($h, $url = '')
 {
     //$posts = \Hotaru\Models\Post::getPostsByOrigUrl(urlencode($url));
     $posts = \Hotaru\Models2\Post::getPostsByOrigUrl($h, urlencode($url));
     if (!$posts) {
         return false;
     }
     // check whether any of found posts are being processed, if so let's delete them:
     foreach ($posts as $post) {
         if ($post->post_status == 'processing') {
             $h->post->id = $post->post_id;
             $h->deletePost($h);
         }
     }
     // check again to see if url is still present:
     //$post = \Hotaru\Models\Post::getFirstPostByOrigUrl(urlencode($url));
     $post = \Hotaru\Models2\Post::getFirstPostByOrigUrl($h, urlencode($url));
     // if present return the first existing row
     if ($post) {
         return $post;
     } else {
         return false;
     }
 }