mirror of
https://github.com/friendica/friendica
synced 2025-05-01 03:04:23 +02:00
Code Standard + renaming deleteAllTags + move its call and add type param
This commit is contained in:
parent
26ed71cc14
commit
e022bac339
5 changed files with 25 additions and 31 deletions
|
@ -896,14 +896,9 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
if (!is_null($tags)) {
|
||||
if ($tags) {
|
||||
Term::insertFromTagFieldByItemId($item['id'], $tags);
|
||||
if (!empty($item['tag'])) {
|
||||
DBA::update('item', ['tag' => ''], ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Term::deleteAllTags($item['id']);
|
||||
Term::insertFromTagFieldByItemId($item['id'], $tags);
|
||||
if (!empty($item['tag'])) {
|
||||
DBA::update('item', ['tag' => ''], ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class Term
|
|||
$message['tag'] = $tags;
|
||||
|
||||
// Clean up all tags
|
||||
DBA::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]]);
|
||||
self::deleteByItemId($itemid);
|
||||
|
||||
if ($message['deleted']) {
|
||||
return;
|
||||
|
@ -294,16 +294,16 @@ class Term
|
|||
/**
|
||||
* Delete all tags from an item
|
||||
* @param int itemid - choose from which item the tags will be removed
|
||||
* @param array type - items type. default is [TERM_HASHTAG, TERM_MENTION]
|
||||
*/
|
||||
public static function deleteAllTags($itemid)
|
||||
public static function deleteByItemId($itemid, $type = [TERM_HASHTAG, TERM_MENTION])
|
||||
{
|
||||
$message = Item::selectFirst(['id'], ['id' => $itemid]);
|
||||
if (!DBA::isResult($message)) {
|
||||
if (empty($itemid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean up all tags
|
||||
DBA::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]]);
|
||||
DBA::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => $type]);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue