- $term_objtype = ($item['resource-id'] ? TERM_OBJ_PHOTO : TERM_OBJ_POST);
-
- $t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'",
- intval($item['id']),
- DBA::escape($term)
- );
-
- if (!$blocktags && $t[0]['tcount'] == 0) {
- q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
- intval($item['id']),
- $term_objtype,
- TERM_HASHTAG,
- DBA::escape($term),
- '',
- intval($owner_uid)
- );
- }
-
- // if the original post is on this site, update it.
- $original_item = Item::selectFirst(['tag', 'id', 'uid'], ['origin' => true, 'uri' => $item['uri']]);
- if (DBA::isResult($original_item)) {
- $x = q("SELECT `blocktags` FROM `user` WHERE `uid`=%d LIMIT 1",
- intval($original_item['uid'])
- );
- $t = q("SELECT COUNT(`tid`) AS `tcount` FROM `term` WHERE `oid`=%d AND `term`='%s'",
- intval($original_item['id']),
- DBA::escape($term)
- );
-
- if (DBA::isResult($x) && !$x[0]['blocktags'] && $t[0]['tcount'] == 0){
- q("INSERT INTO term (`oid`, `otype`, `type`, `term`, `url`, `uid`) VALUE (%d, %d, %d, '%s', '%s', %d)",
- intval($original_item['id']),
- $term_objtype,
- TERM_HASHTAG,
- DBA::escape($term),
- '',
- intval($owner_uid)
- );
- }
- }
-