Fix tag insertion/update

- Delete all tags related to a specific profile on submit
- Add tags only if the profile is available
This commit is contained in:
Hypolite Petovan 2018-01-14 22:24:12 -05:00
parent 522cc7bb17
commit e24172ab05

View file

@ -39,6 +39,9 @@ function run_submit($url)
`updated` = '%s' `updated` = '%s'
WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($profile_id) WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($profile_id)
); );
$r = q("DELETE FROM `tag` WHERE `nurl` = '%s'",
dbesc($r[0]['nurl'])
);
} }
//Remove duplicates. //Remove duplicates.
@ -185,16 +188,10 @@ function run_submit($url)
$t = substr($t, 0, 254); $t = substr($t, 0, 254);
if (strlen($t)) { if (strlen($t)) {
$r = q("SELECT `id` FROM `tag` WHERE `term` = '%s' and `nurl` = '%s' LIMIT 1", $r = q("INSERT INTO `tag` (`term`, `nurl`) VALUES ('%s', '%s') ",
dbesc($t), dbesc($t),
dbesc($nurl) dbesc($nurl)
); );
if (!count($r)) {
$r = q("INSERT INTO `tag` (`term`, `nurl`) VALUES ('%s', '%s') ",
dbesc($t),
dbesc($nurl)
);
}
} }
} }
} }