X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FProfile_tag.php;h=6d6f49bedc634abf174d6d5d663da38e18d35302;hb=8fac7a9f6c01b2bb0033584d792296cc19b871d2;hp=f1a60fdaa677f50084d1b6610508cf45710376ef;hpb=8c710ad2c1b80544acccb515f7b601aadff2de16;p=quix0rs-gnu-social.git diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php index f1a60fdaa6..6d6f49bedc 100644 --- a/classes/Profile_tag.php +++ b/classes/Profile_tag.php @@ -15,10 +15,6 @@ class Profile_tag extends Managed_DataObject public $tag; // varchar(64) primary_key not_null public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP - /* Static get */ - 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 @@ -46,10 +42,6 @@ class Profile_tag extends Managed_DataObject ); } - function pkeyGet($kv) { - return Memcached_DataObject::pkeyGet('Profile_tag', $kv); - } - function links() { return array('tagger,tag' => 'profile_list:tagger,tag'); @@ -86,7 +78,7 @@ class Profile_tag extends Managed_DataObject $qry = sprintf($qry, $tagger, $tagged); if (!$include_priv) { - $qry .= 'profile_list.private = 0'; + $qry .= ' and profile_list.private = 0'; } $profile_list->query($qry); @@ -99,23 +91,26 @@ class Profile_tag extends Managed_DataObject static function getTagsArray($tagger, $tagged, $auth_user_id=null) { $ptag = new Profile_tag(); - $ptag->tagger = $tagger; - $ptag->tagged = $tagged; - - if ($tagger != $auth_user_id) { - $list = new Profile_list(); - $list->private = false; - $ptag->joinAdd($list); - $ptag->selectAdd(); - $ptag->selectAdd('profile_tag.tag'); + + $qry = sprintf('select profile_tag.tag '. + 'from profile_tag join profile_list '. + ' on (profile_tag.tagger = profile_list.tagger ' . + ' and profile_tag.tag = profile_list.tag) ' . + 'where profile_tag.tagger = %d ' . + 'and profile_tag.tagged = %d ', + $tagger, $tagged); + + if ($auth_user_id != $tagger) { + $qry .= 'and profile_list.private = 0'; } $tags = array(); - $ptag->find(); + + $ptag->query($qry); + while ($ptag->fetch()) { $tags[] = $ptag->tag; } - $ptag->free(); return $tags; } @@ -158,8 +153,8 @@ class Profile_tag extends Managed_DataObject return $ptag; } - $tagger_profile = Profile::staticGet('id', $tagger); - $tagged_profile = Profile::staticGet('id', $tagged); + $tagger_profile = Profile::getKV('id', $tagger); + $tagged_profile = Profile::getKV('id', $tagged); if (Event::handle('StartTagProfile', array($tagger_profile, $tagged_profile, $tag))) { @@ -190,7 +185,7 @@ class Profile_tag extends Managed_DataObject if ($profile_list->taggedCount() >= common_config('peopletag', 'maxpeople')) { // TRANS: Client exception thrown when trying to add more people than allowed to a list. throw new ClientException(sprintf(_('You already have %1$d or more people in list %2$s, ' . - 'which is the maximum allowed number.' . + 'which is the maximum allowed number. ' . 'Try unlisting others first.'), common_config('peopletag', 'maxpeople'), $tag)); return false; @@ -281,14 +276,17 @@ class Profile_tag extends Managed_DataObject 'tag = "%s", tagger = "%s" ' . 'WHERE tag = "%s" ' . 'AND tagger = "%s"'; - $result = $tags->query(sprintf($qry, $new->tag, $new->tagger, - $orig->tag, $orig->tagger)); + $result = $tags->query(sprintf($qry, + $tags->escape($new->tag), + $tags->escape($new->tagger), + $tags->escape($orig->tag), + $tags->escape($orig->tagger))); - if (!$result) { + if ($result === false) { common_log_db_error($tags, 'UPDATE', __FILE__); - return false; + throw new Exception('Could not move Profile_tag, see db log for details.'); } - return true; + return $result; } static function blowCaches($tagger, $tagged) { @@ -304,8 +302,8 @@ class Profile_tag extends Managed_DataObject $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 . '" '); + 'WHERE profile_tag.tagger = ' . $profile->escape($tagger) . ' ' . + 'AND profile_tag.tag = "' . $profile->escape($tag) . '" '); $tagged = array(); while ($profile->fetch()) { $tagged[] = clone($profile); @@ -324,10 +322,10 @@ class Profile_tag extends Managed_DataObject return $result; } - function delete() + function delete($useWhere=false) { - $result = parent::delete(); - if ($result) { + $result = parent::delete($useWhere); + if ($result !== false) { self::blow('profile_list:tagged_count:%d:%s', $this->tagger, $this->tag);