]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile_tag.php
Merge remote-tracking branch 'mainline/1.0.x' into people_tags_rebase
[quix0rs-gnu-social.git] / classes / Profile_tag.php
index 183f79145a136463472eb3dec305131ff22809b0..eb583c98fe06f4f126921631e8c33a48ffa8b110 100644 (file)
@@ -106,11 +106,11 @@ class Profile_tag extends Memcached_DataObject
 
         $ptag = new Profile_tag();
 
-        # Delete stuff that's in old and not in new
+        // Delete stuff that's in old and not in new
 
         $to_delete = array_diff($oldtags, $newtags);
 
-        # Insert stuff that's in new and not in old
+        // Insert stuff that's in new and not in old
 
         $to_insert = array_diff($newtags, $oldtags);
 
@@ -271,4 +271,19 @@ class Profile_tag extends Memcached_DataObject
         }
         return true;
     }
+
+    // Return profiles with a given tag
+    static function getTagged($tagger, $tag) {
+        $profile = new Profile();
+        $profile->query('SELECT profile.* ' .
+                        'FROM profile JOIN profile_tag ' .
+                        'ON profile.id = profile_tag.tagged ' .
+                        'WHERE profile_tag.tagger = ' . $tagger . ' ' .
+                        'AND profile_tag.tag = "' . $tag . '" ');
+        $tagged = array();
+        while ($profile->fetch()) {
+            $tagged[] = clone($profile);
+        }
+        return true;
+    }
 }