本文整理汇总了PHP中Notice::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::getID方法的具体用法?PHP Notice::getID怎么用?PHP Notice::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::getID方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveNew
public static function saveNew(Notice $notice, Profile $target, $reason = null)
{
try {
$att = Attention::getByKeys(['notice_id' => $notice->getID(), 'profile_id' => $target->getID()]);
throw new AlreadyFulfilledException('Attention already exists with reason: ' . var_export($att->reason, true));
} catch (NoResultException $e) {
$att = new Attention();
$att->notice_id = $notice->getID();
$att->profile_id = $target->getID();
$att->reason = $reason;
$att->created = common_sql_now();
$result = $att->insert();
if ($result === false) {
throw new Exception('Failed Attention::saveNew for notice id==' . $notice->getID() . ' target id==' . $target->getID() . ', reason=="' . $reason . '"');
}
}
return $att;
}
示例2: locFromStored
static function locFromStored(Notice $stored)
{
$loc = new Notice_location();
$loc->notice_id = $stored->getID();
if (!$loc->find(true)) {
throw new NoResultException($loc);
}
return $loc->asLocation();
}
示例3: removeEntry
public function removeEntry(Profile $actor, Notice $target)
{
$fave = new Fave();
$fave->user_id = $actor->getID();
$fave->notice_id = $target->getID();
if (!$fave->find(true)) {
// TRANS: Client error displayed when trying to remove a 'favor' when there is none in the first place.
throw new AlreadyFulfilledException(_('This is already not favorited.'));
}
$result = $fave->delete();
if ($result === false) {
common_log_db_error($fave, 'DELETE', __FILE__);
// TRANS: Server error displayed when removing a favorite from the database fails.
throw new ServerException(_('Could not delete favorite.'));
}
Fave::blowCacheForProfileId($actor->getID());
Fave::blowCacheForNoticeId($target->getID());
}
示例4: onEndShowThreadedNoticeTail
public function onEndShowThreadedNoticeTail(NoticeListItem $nli, Notice $notice, array $notices)
{
if ($this->prerender_replyforms) {
$nli->out->elementStart('li', array('class' => 'notice-reply', 'style' => 'display: none;'));
$replyForm = new NoticeForm($nli->out, array('inreplyto' => $notice->getID()));
$replyForm->show();
$nli->out->elementEnd('li');
}
return true;
}
示例5: activityObjectFromNotice
public function activityObjectFromNotice(Notice $notice)
{
$object = new ActivityObject();
$object->type = $notice->object_type ?: ActivityObject::NOTE;
$object->id = $notice->getUri();
$object->title = sprintf('New %1$s by %2$s', ActivityObject::canonicalType($object->type), $notice->getProfile()->getNickname());
$object->content = $notice->getRendered();
$object->link = $notice->getUrl();
$object->extra[] = array('status_net', array('notice_id' => $notice->getID()));
return $object;
}
示例6: saveNew
public static function saveNew(Notice $notice, Profile $profile, $reason = null)
{
$att = new Attention();
$att->notice_id = $notice->getID();
$att->profile_id = $profile->getID();
$att->reason = $reason;
$att->created = common_sql_now();
$result = $att->insert();
if ($result === false) {
throw new Exception('Could not saveNew in Attention');
}
return $att;
}
示例7: processNew
static function processNew(File $file, Notice $notice)
{
static $seen = array();
$file_id = $file->getID();
$notice_id = $notice->getID();
if (!array_key_exists($notice_id, $seen)) {
$seen[$notice_id] = array();
}
if (empty($seen[$notice_id]) || !in_array($file_id, $seen[$notice_id])) {
try {
$f2p = File_to_post::getByPK(array('post_id' => $notice_id, 'file_id' => $file_id));
} catch (NoResultException $e) {
$f2p = new File_to_post();
$f2p->file_id = $file_id;
$f2p->post_id = $notice_id;
$f2p->insert();
$file->blowCache();
}
$seen[$notice_id][] = $file_id;
}
}
示例8: handle
/**
* Handle distribution of a notice after we've saved it:
* @li add to local recipient inboxes
* @li send email notifications to local @-reply targets
* @li run final EndNoticeSave plugin events
* @li put any remaining post-processing into the queues
*
* If this function indicates failure, a warning will be logged
* and the item is placed back in the queue to be re-run.
*
* @param Notice $notice
* @return boolean true on success, false on failure
*/
public function handle(Notice $notice)
{
// We have to manually add attentions to non-profile subs and non-mentions
$ptAtts = $notice->getAttentionsFromProfileTags();
foreach (array_keys($ptAtts) as $profile_id) {
$profile = Profile::getKV('id', $profile_id);
if ($profile instanceof Profile) {
try {
common_debug('Adding Attention for ' . $notice->getID() . ' profile ' . $profile->getID());
Attention::saveNew($notice, $profile);
} catch (Exception $e) {
$this->logit($notice, $e);
}
}
}
try {
$notice->sendReplyNotifications();
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
Event::handle('EndNoticeDistribute', array($notice));
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
Event::handle('EndNoticeSave', array($notice));
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
// Enqueue for other handlers
common_enqueue_notice($notice);
} catch (Exception $e) {
$this->logit($notice, $e);
}
return true;
}
示例9: getUrlFromNotice
public static function getUrlFromNotice(Notice $notice, $anchor = true)
{
$conv = Conversation::getByID($notice->conversation);
return $conv->getUrl($anchor ? $notice->getID() : null);
}
示例10: saveActivity
//.........这里部分代码省略.........
// TRANS: Client error displayed when trying to reply to a notice a the target has no access to.
// TRANS: %1$s is a user nickname, %2$d is a notice ID (number).
throw new ClientException(sprintf(_m('%1$s has no right to reply to notice %2$d.'), $actor->getNickname(), $reply->id), 403);
}
$stored->reply_to = $reply->id;
$stored->conversation = $reply->conversation;
// If the original is private to a group, and notice has no group specified,
// make it to the same group(s)
if (empty($groups) && $reply->scope & Notice::GROUP_SCOPE) {
$replyGroups = $reply->getGroups();
foreach ($replyGroups as $group) {
if ($actor->isMember($group)) {
$groups[] = $group->id;
}
}
}
if (is_null($scope)) {
$scope = $reply->scope;
}
} else {
// If we don't know the reply, we might know the conversation!
// This will happen if a known remote user replies to an
// unknown remote user - within a known conversation.
if (empty($stored->conversation) and !empty($act->context->conversation)) {
$conv = Conversation::getKV('uri', $act->context->conversation);
if ($conv instanceof Conversation) {
common_debug('Conversation stitched together from (probably) a reply activity to unknown remote user. Activity creation time (' . $stored->created . ') should maybe be compared to conversation creation time (' . $conv->created . ').');
} else {
// Conversation entry with specified URI was not found, so we must create it.
common_debug('Conversation URI not found, so we will create it with the URI given in the context of the activity: ' . $act->context->conversation);
// The insert in Conversation::create throws exception on failure
$conv = Conversation::create($act->context->conversation, $stored->created);
}
$stored->conversation = $conv->getID();
unset($conv);
}
}
// If it's not part of a conversation, it's the beginning of a new conversation.
if (empty($stored->conversation)) {
$conv = Conversation::create();
$stored->conversation = $conv->getID();
unset($conv);
}
$notloc = null;
if ($act->context instanceof ActivityContext) {
if ($act->context->location instanceof Location) {
$notloc = Notice_location::fromLocation($act->context->location);
}
} else {
$act->context = new ActivityContext();
}
$stored->scope = self::figureOutScope($actor, $groups, $scope);
foreach ($act->categories as $cat) {
if ($cat->term) {
$term = common_canonical_tag($cat->term);
if (!empty($term)) {
$tags[] = $term;
}
}
}
foreach ($act->enclosures as $href) {
// @todo FIXME: Save these locally or....?
$urls[] = $href;
}
if (ActivityUtils::compareVerbs($stored->verb, array(ActivityVerb::POST))) {
if (empty($act->objects[0]->type)) {
示例11: fixupNoticeConversation
function fixupNoticeConversation()
{
printfnq("Ensuring all notices have a conversation ID...");
$notice = new Notice();
$notice->whereAdd('conversation is null');
$notice->whereAdd('conversation = 0', 'OR');
$notice->orderBy('id');
// try to get originals before replies
$notice->find();
while ($notice->fetch()) {
try {
$cid = null;
$orig = clone $notice;
if (!empty($notice->reply_to)) {
$reply = Notice::getKV('id', $notice->reply_to);
if ($reply instanceof Notice && !empty($reply->conversation)) {
$notice->conversation = $reply->conversation;
}
unset($reply);
}
// if still empty
if (empty($notice->conversation)) {
$child = new Notice();
$child->reply_to = $notice->getID();
$child->limit(1);
if ($child->find(true) && !empty($child->conversation)) {
$notice->conversation = $child->conversation;
}
unset($child);
}
// if _still_ empty we just create our own conversation
if (empty($notice->conversation)) {
$notice->conversation = $notice->getID();
}
$result = $notice->update($orig);
unset($orig);
} catch (Exception $e) {
print "Error setting conversation: " . $e->getMessage();
}
}
printfnq("DONE.\n");
}