]> git.mxchange.org Git - friendica.git/blobdiff - mod/tagger.php
add tag to term table. fix "#xNNNN" tag filter.
[friendica.git] / mod / tagger.php
index 6ae0cebf718ef40774c70e2865aff3e77ce72328..3f470a1797033741f55c8f819f3a8106f449f089 100644 (file)
@@ -151,13 +151,27 @@ EOT;
                );
        }                       
 
-       if((! $blocktags) && (! stristr($item['tag'], ']' . $term . '[' ))) {
-               q("update item set tag = '%s' where id = %d limit 1",
+       $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']),
+                dbesc($term)
+        );
+       if((! $blocktags) && $t[0]['tcount']==0 ) {
+               /*q("update item set tag = '%s' where id = %d limit 1",
                        dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
                        intval($item['id'])
+               );*/
+
+               q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
+                  intval($item['id']),
+                  $term_objtype,
+                  TERM_HASHTAG,
+                  dbesc($term),
+                  dbesc($a->get_baseurl() . '/search?tag=' . $term),
+                  intval($owner_uid)
                );
        }
-
+       
        // if the original post is on this site, update it.
 
        $r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `uri` = '%s' LIMIT 1",
@@ -167,12 +181,29 @@ EOT;
                $x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1",
                        intval($r[0]['uid'])
                );
-               if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
+               $t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'",
+                       intval($r[0]['id']),
+                       dbesc($term)
+               );
+               echo "<pre>"; var_dump($t); killme();
+               // not really sure about this...
+               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 limit 1",
                                dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
                                intval($r[0]['id'])
                        );
-               }
+               }*/
 
        }
                
@@ -188,4 +219,4 @@ EOT;
        return; // NOTREACHED
 
 
-}
\ No newline at end of file
+}