- /**
- * record targets into profile_tag_inbox.
- * @return array of Profile_list objects
- */
- function saveProfileTags($known=array())
- {
- // Don't save ptags for repeats, for now
-
- if (!empty($this->repeat_of)) {
- return array();
- }
-
- if (is_array($known)) {
- $ptags = $known;
- } else {
- $ptags = array();
- }
-
- $ptag = new Profile_tag();
- $ptag->tagged = $this->profile_id;
-
- if($ptag->find()) {
- while($ptag->fetch()) {
- $plist = Profile_list::getByTaggerAndTag($ptag->tagger, $ptag->tag);
- if (!empty($plist)) {
- $ptags[] = clone($plist);
- }
- }
- }
-
- foreach ($ptags as $target) {
- $this->addToProfileTagInbox($target);
- }
-
- return $ptags;
- }
-
- function addToProfileTagInbox($plist)
- {
- $ptagi = Profile_tag_inbox::pkeyGet(array('profile_tag_id' => $plist->id,
- 'notice_id' => $this->id));
-
- if (empty($ptagi)) {
-
- $ptagi = new Profile_tag_inbox();
-
- $ptagi->query('BEGIN');
- $ptagi->profile_tag_id = $plist->id;
- $ptagi->notice_id = $this->id;
- $ptagi->created = $this->created;
-
- $result = $ptagi->insert();
- if (!$result) {
- common_log_db_error($ptagi, 'INSERT', __FILE__);
- // TRANS: Server exception thrown when saving profile_tag inbox fails.
- throw new ServerException(_('Problem saving profile_tag inbox.'));
- }
-
- $ptagi->query('COMMIT');
-
- self::blow('profile_tag:notice_ids:%d', $ptagi->profile_tag_id);
- }
-
- return true;
- }
-