From 2f043b74e72d59d1c624629f389b72d1215af632 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 22 Jan 2009 01:53:27 -0500 Subject: Move common_save_replies to Notice class --- lib/util.php | 84 ------------------------------------------------------------ 1 file changed, 84 deletions(-) (limited to 'lib/util.php') diff --git a/lib/util.php b/lib/util.php index 61b73a556..4f791a493 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1069,90 +1069,6 @@ function common_redirect($url, $code=307) exit; } -function common_save_replies($notice) -{ - // Alternative reply format - $tname = false; - if (preg_match('/^T ([A-Z0-9]{1,64}) /', $notice->content, $match)) { - $tname = $match[1]; - } - // extract all @messages - $cnt = preg_match_all('/(?:^|\s)@([a-z0-9]{1,64})/', $notice->content, $match); - - $names = array(); - - if ($cnt || $tname) { - // XXX: is there another way to make an array copy? - $names = ($tname) ? array_unique(array_merge(array(strtolower($tname)), $match[1])) : array_unique($match[1]); - } - - $sender = Profile::staticGet($notice->profile_id); - - $replied = array(); - - // store replied only for first @ (what user/notice what the reply directed, - // we assume first @ is it) - - for ($i=0; $icreated); - if (!$recipient) { - continue; - } - if ($i == 0 && ($recipient->id != $sender->id) && !$notice->reply_to) { // Don't save reply to self - $reply_for = $recipient; - $recipient_notice = $reply_for->getCurrentNotice(); - if ($recipient_notice) { - $orig = clone($notice); - $notice->reply_to = $recipient_notice->id; - $notice->update($orig); - } - } - // Don't save replies from blocked profile to local user - $recipient_user = User::staticGet('id', $recipient->id); - if ($recipient_user && $recipient_user->hasBlocked($sender)) { - continue; - } - $reply = new Reply(); - $reply->notice_id = $notice->id; - $reply->profile_id = $recipient->id; - $id = $reply->insert(); - if (!$id) { - $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); - common_log(LOG_ERR, 'DB error inserting reply: ' . $last_error->message); - common_server_error(sprintf(_('DB error inserting reply: %s'), $last_error->message)); - return; - } else { - $replied[$recipient->id] = 1; - } - } - - // Hash format replies, too - $cnt = preg_match_all('/(?:^|\s)@#([a-z0-9]{1,64})/', $notice->content, $match); - if ($cnt) { - foreach ($match[1] as $tag) { - $tagged = Profile_tag::getTagged($sender->id, $tag); - foreach ($tagged as $t) { - if (!$replied[$t->id]) { - // Don't save replies from blocked profile to local user - $t_user = User::staticGet('id', $t->id); - if ($t_user && $t_user->hasBlocked($sender)) { - continue; - } - $reply = new Reply(); - $reply->notice_id = $notice->id; - $reply->profile_id = $t->id; - $id = $reply->insert(); - if (!$id) { - common_log_db_error($reply, 'INSERT', __FILE__); - return; - } - } - } - } - } -} - function common_broadcast_notice($notice, $remote=false) { -- cgit v1.2.3-54-g00ecf