summaryrefslogtreecommitdiff
path: root/classes/Profile_tag.php
diff options
context:
space:
mode:
authorEvan Prodromou <git@evanprodromou.name>2009-01-23 08:58:31 +0100
committerEvan Prodromou <git@evanprodromou.name>2009-01-23 08:58:31 +0100
commita7c85bebd5be9ea019a8c80d74730d7eb28d4651 (patch)
treec3fdf9575a342624bc71aad1d439ae73594f558c /classes/Profile_tag.php
parent4873277b58941ae6ec16543f437f4267ccab5ac0 (diff)
parent7aa496cd8a939960eeaf79f3397f6fe94097e047 (diff)
Merge branch 'master' of /var/www/mublog
Conflicts: actions/api.php actions/deletenotice.php actions/recoverpassword.php actions/remotesubscribe.php actions/tag.php actions/tagrss.php actions/twitapiaccount.php actions/twitapiusers.php classes/Notice.php classes/User.php lib/common.php lib/language.php lib/subs.php lib/twitterapi.php lib/util.php scripts/inbox_users.php scripts/update_translations.php Merged development trunk into laconica head. woohoo!
Diffstat (limited to 'classes/Profile_tag.php')
-rw-r--r--classes/Profile_tag.php155
1 files changed, 78 insertions, 77 deletions
diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php
index dde19aea2..cb60cbaec 100644
--- a/classes/Profile_tag.php
+++ b/classes/Profile_tag.php
@@ -16,86 +16,87 @@ class Profile_tag extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */
- function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Profile_tag',$k,$v); }
+ function staticGet($k,$v=null)
+ { return Memcached_DataObject::staticGet('Profile_tag',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- static function getTags($tagger, $tagged) {
-
- $tags = array();
+ 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) {
-
- $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();
- if (!$result) {
- common_log_db_error($profile_tag, 'DELETE', __FILE__);
- return false;
- }
- }
-
- foreach ($to_insert as $instag) {
- $profile_tag->tag = $instag;
- $result = $profile_tag->insert();
- if (!$result) {
- common_log_db_error($profile_tag, 'INSERT', __FILE__);
- return false;
- }
- }
-
- $profile_tag->query('COMMIT');
-
- 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 $tagged;
- }
+ # 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) {
+
+ $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();
+ if (!$result) {
+ common_log_db_error($profile_tag, 'DELETE', __FILE__);
+ return false;
+ }
+ }
+
+ foreach ($to_insert as $instag) {
+ $profile_tag->tag = $instag;
+ $result = $profile_tag->insert();
+ if (!$result) {
+ common_log_db_error($profile_tag, 'INSERT', __FILE__);
+ return false;
+ }
+ }
+
+ $profile_tag->query('COMMIT');
+
+ 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 $tagged;
+ }
}