forked from GNUsocial/gnu-social
replace all tabs with four spaces
The PEAR coding standards decree: no tabs, but indent by four spaces. I've done a global search-and-replace on all tabs, replacing them by four spaces. This is a huge change, but it will go a long way to getting us towards phpcs-compliance. And that means better code readability, and that means more participation. darcs-hash:20081223191907-84dde-21e8efe210e6d5d54e935a22d0cee5c7bbfc007d.gz
This commit is contained in:
@@ -21,81 +21,81 @@ class Profile_tag extends Memcached_DataObject
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user