- if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
- q("update item set tag = '%s' where id = %d limit 1",
+ $t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'",
+ intval($r[0]['id']),
+ dbesc($term)
+ );
+ if(count($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($r[0]['id']),
+ $term_objtype,
+ TERM_HASHTAG,
+ dbesc($term),
+ dbesc($a->get_baseurl() . '/search?tag=' . $term),
+ intval($owner_uid)
+ );
+ }
+
+ /*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
+ q("update item set tag = '%s' where id = %d",