本文整理汇总了PHP中Reply::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Reply::insert方法的具体用法?PHP Reply::insert怎么用?PHP Reply::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reply
的用法示例。
在下文中一共展示了Reply::insert方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveStatusMentions
function saveStatusMentions($notice, $status)
{
$mentions = array();
if (empty($status->entities) || empty($status->entities->user_mentions)) {
return;
}
foreach ($status->entities->user_mentions as $mention) {
$flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE);
if (!empty($flink)) {
$user = User::staticGet('id', $flink->user_id);
if (!empty($user)) {
$reply = new Reply();
$reply->notice_id = $notice->id;
$reply->profile_id = $user->id;
$reply->modified = $notice->created;
common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}");
$id = $reply->insert();
}
}
}
}
示例2: saveReply
function saveReply($profileId)
{
$reply = new Reply();
$reply->notice_id = $this->id;
$reply->profile_id = $profileId;
$reply->modified = $this->created;
$reply->insert();
return $reply;
}
示例3: saveReplies
/**
* Pull @-replies from this message's content in StatusNet markup format
* and save reply records indicating that this message needs to be
* delivered to those users.
*
* Mail notifications to local profiles will be sent later.
*
* @return array of integer profile IDs
*/
function saveReplies()
{
// Don't save reply data for repeats
if (!empty($this->repeat_of)) {
return array();
}
$sender = Profile::staticGet($this->profile_id);
// @todo ideally this parser information would only
// be calculated once.
$mentions = common_find_mentions($this->content, $this);
$replied = array();
// store replied only for first @ (what user/notice what the reply directed,
// we assume first @ is it)
foreach ($mentions as $mention) {
foreach ($mention['mentioned'] as $mentioned) {
// skip if they're already covered
if (!empty($replied[$mentioned->id])) {
continue;
}
// Don't save replies from blocked profile to local user
$mentioned_user = User::staticGet('id', $mentioned->id);
if (!empty($mentioned_user) && $mentioned_user->hasBlocked($sender)) {
continue;
}
$reply = new Reply();
$reply->notice_id = $this->id;
$reply->profile_id = $mentioned->id;
$id = $reply->insert();
if (!$id) {
common_log_db_error($reply, 'INSERT', __FILE__);
// TRANS: Server exception thrown when a reply cannot be saved.
// TRANS: %1$d is a notice ID, %2$d is the ID of the mentioned user.
throw new ServerException(sprintf(_("Could not save reply for %1{$d}, %2{$d}."), $this->id, $mentioned->id));
} else {
$replied[$mentioned->id] = 1;
self::blow('reply:stream:%d', $mentioned->id);
}
}
}
$recipientIds = array_keys($replied);
return $recipientIds;
}
示例4: saveStatusMentions
function saveStatusMentions($notice, $status)
{
$mentions = array();
if (empty($status->entities) || empty($status->entities->user_mentions)) {
return;
}
foreach ($status->entities->user_mentions as $mention) {
try {
$flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE);
$user = $flink->getUser();
$reply = new Reply();
$reply->notice_id = $notice->id;
$reply->profile_id = $user->id;
$reply->modified = $notice->created;
common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}");
$id = $reply->insert();
} catch (NoSuchUserException $e) {
common_log(LOG_WARNING, 'No local user found for Foreign_link with id: ' . $mention->id);
} catch (NoResultException $e) {
common_log(LOG_WARNING, 'No foreign link or profile found for Foreign_link with id: ' . $mention->id);
}
}
}
示例5: saveReply
function saveReply($profileId, $isMention = false)
{
$reply = new Reply();
$reply->notice_id = $this->id;
$reply->profile_id = $profileId;
$reply->modified = $this->created;
if ($isMention) {
$reply->content_type = NOTICE::CONTENT_TYPE_MENTIONS;
} else {
$reply->content_type = NOTICE::CONTENT_TYPE_COMMENT;
}
$reply->insert();
return $reply;
}
示例6: saveReplies
function saveReplies()
{
// Alternative reply format
$tname = false;
if (preg_match('/^T ([A-Z0-9]{1,64}) /', $this->content, $match)) {
$tname = $match[1];
}
// extract all @messages
$cnt = preg_match_all('/(?:^|\\s)@([a-z0-9]{1,64})/', $this->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($this->profile_id);
$replied = array();
// store replied only for first @ (what user/notice what the reply directed,
// we assume first @ is it)
for ($i = 0; $i < count($names); $i++) {
$nickname = $names[$i];
$recipient = common_relative_profile($sender, $nickname, $this->created);
if (!$recipient) {
continue;
}
if ($i == 0 && $recipient->id != $sender->id && !$this->reply_to) {
// Don't save reply to self
$reply_for = $recipient;
$recipient_notice = $reply_for->getCurrentNotice();
if ($recipient_notice) {
$orig = clone $this;
$this->reply_to = $recipient_notice->id;
$this->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 = $this->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})/', $this->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 = $this->id;
$reply->profile_id = $t->id;
$id = $reply->insert();
if (!$id) {
common_log_db_error($reply, 'INSERT', __FILE__);
return;
} else {
$replied[$recipient->id] = 1;
}
}
}
}
}
foreach (array_keys($replied) as $recipient) {
$user = User::staticGet('id', $recipient);
if ($user) {
mail_notify_attn($user, $this);
}
}
}