We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 770efece authored by Evan Prodromou's avatar Evan Prodromou

don't reinsert existing bookmark

parent 15f4e0a9
......@@ -116,8 +116,37 @@ class Notice_bookmark extends Memcached_DataObject
return array(false, false, false);
}
static function getByURL($user, $url)
{
$file = File::staticGet('url', $url);
if (!empty($file)) {
$f2p = new File_to_post();
$f2p->file_id = $file->id;
if ($f2p->find()) {
while ($f2p->fetch()) {
$n = Notice::staticGet('id', $f2p->post_id);
if (!empty($n)) {
if ($n->profile_id == $user->id) {
$nb = Notice_bookmark::staticGet('notice_id', $n->id);
if (!empty($nb)) {
return $nb;
}
}
}
}
}
}
return null;
}
static function saveNew($user, $title, $url, $rawtags, $description, $options=null)
{
$nb = self::getByURL($user, $url);
if (!empty($nb)) {
throw new ClientException(_('Bookmark already exists.'));
}
if (empty($options)) {
$options = array();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment