diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-02-28 21:11:16 -0800 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-02-28 21:11:16 -0800 |
commit | fc44c9a7f456a146a20884c56676baf7343dd923 (patch) | |
tree | bcc572d966709bfa19277eb48c3f2f831d49d8ba /classes | |
parent | 02ba71b0f186b406071a97c3267603d4863a4b21 (diff) | |
parent | 458c03786735bd3e3b6619b2d20538bd55acd0c6 (diff) |
Merge branch '0.7.x' into 0.8.x
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Profile_tag.php | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index cb60cbaec..0a1ad9cd6 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -4,7 +4,7 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Profile_tag extends Memcached_DataObject +class Profile_tag extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ @@ -23,45 +23,46 @@ class Profile_tag extends Memcached_DataObject ###END_AUTOCODE static function getTags($tagger, $tagged) { - + $tags = array(); # XXX: store this in memcached - + $profile_tag = new Profile_tag(); $profile_tag->tagger = $tagger; $profile_tag->tagged = $tagged; - + $profile_tag->find(); - + while ($profile_tag->fetch()) { $tags[] = $profile_tag->tag; } - + $profile_tag->free(); - + return $tags; } - + static function setTags($tagger, $tagged, $newtags) { - + + $newtags = array_unique($newtags); $oldtags = Profile_tag::getTags($tagger, $tagged); - + # Delete stuff that's old that not in new - + $to_delete = array_diff($oldtags, $newtags); - + # Insert stuff that's in new and not in old - + $to_insert = array_diff($newtags, $oldtags); - + $profile_tag = new Profile_tag(); - + $profile_tag->tagger = $tagger; $profile_tag->tagged = $tagged; - + $profile_tag->query('BEGIN'); - + foreach ($to_delete as $deltag) { $profile_tag->tag = $deltag; $result = $profile_tag->delete(); @@ -70,7 +71,7 @@ class Profile_tag extends Memcached_DataObject return false; } } - + foreach ($to_insert as $instag) { $profile_tag->tag = $instag; $result = $profile_tag->insert(); @@ -79,12 +80,12 @@ class Profile_tag extends Memcached_DataObject return false; } } - + $profile_tag->query('COMMIT'); - + return true; } - + # Return profiles with a given tag static function getTagged($tagger, $tag) { $profile = new Profile(); |