本文整理汇总了PHP中Notice::staticGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::staticGet方法的具体用法?PHP Notice::staticGet怎么用?PHP Notice::staticGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::staticGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
function prepare($args)
{
parent::prepare($args);
$this->user = common_current_user();
if (empty($this->user)) {
$this->clientError(_('Only logged-in users can repeat notices.'));
return false;
}
$id = $this->trimmed('notice');
if (empty($id)) {
$this->clientError(_('No notice specified.'));
return false;
}
$this->notice = Notice::staticGet('id', $id);
if (empty($this->notice)) {
$this->clientError(_('No notice specified.'));
return false;
}
if ($this->user->id == $this->notice->profile_id) {
$this->clientError(_("You can't repeat your own notice."));
return false;
}
$token = $this->trimmed('token-' . $id);
if (empty($token) || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return false;
}
$profile = $this->user->getProfile();
if ($profile->hasRepeated($id)) {
$this->clientError(_('You already repeated that notice.'));
return false;
}
return true;
}
示例2: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
Action::prepare($argarray);
$this->id = $this->trimmed('id');
$this->answer = QnA_Answer::staticGet('id', $this->id);
if (empty($this->answer)) {
// TRANS: Client exception thrown when requesting a non-existing answer.
throw new ClientException(_m('No such answer.'), 404);
}
$this->question = $this->answer->getQuestion();
if (empty($this->question)) {
// TRANS: Client exception thrown when requesting an answer that has no connected question.
throw new ClientException(_m('No question for this answer.'), 404);
}
$this->notice = Notice::staticGet('uri', $this->answer->uri);
if (empty($this->notice)) {
// TRANS: Did we used to have it, and it got deleted?
throw new ClientException(_m('No such answer.'), 404);
}
$this->user = User::staticGet('id', $this->answer->profile_id);
if (empty($this->user)) {
// TRANS: Client exception thrown when requesting answer data for a non-existing user.
throw new ClientException(_m('No such user.'), 404);
}
$this->profile = $this->user->getProfile();
if (empty($this->profile)) {
// TRANS: Client exception thrown when requesting answer data for a user without a profile.
throw new ServerException(_m('User without a profile.'));
}
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
return true;
}
示例3: handle
function handle($notice)
{
assert($notice instanceof Notice);
$this->notice = $notice;
$this->user = User::staticGet($notice->profile_id);
$this->pushUser();
foreach ($notice->getGroups() as $group) {
$oprofile = Ostatus_profile::staticGet('group_id', $group->id);
if ($oprofile) {
$this->pingReply($oprofile);
} else {
$this->pushGroup($group->id);
}
}
foreach ($notice->getReplies() as $profile_id) {
$oprofile = Ostatus_profile::staticGet('profile_id', $profile_id);
if ($oprofile) {
$this->pingReply($oprofile);
}
}
if (!empty($this->notice->reply_to)) {
$replyTo = Notice::staticGet('id', $this->notice->reply_to);
if (!empty($replyTo)) {
foreach ($replyTo->getReplies() as $profile_id) {
$oprofile = Ostatus_profile::staticGet('profile_id', $profile_id);
if ($oprofile) {
$this->pingReply($oprofile);
}
}
}
}
return true;
}
示例4: prepare
function prepare($args)
{
parent::prepare($args);
$this->id = $this->trimmed('notice');
if (empty($this->id)) {
$this->clientError(_('No notice ID.'));
}
$notice = Notice::staticGet('id', $this->id);
if (empty($notice)) {
$this->clientError(_('No notice.'));
}
$atts = $notice->attachments();
if (empty($atts)) {
$this->clientError(_('No attachments.'));
}
foreach ($atts as $att) {
if (!empty($att->filename)) {
$this->filerec = $att;
break;
}
}
if (empty($this->filerec)) {
$this->clientError(_('No uploaded attachments.'));
}
return true;
}
示例5: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
$this->user = $this->auth_user;
$this->notice = Notice::staticGet($this->arg('id'));
return true;
}
示例6: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
parent::prepare($argarray);
// User must be logged in.
$user = common_current_user();
if (empty($user)) {
throw new ClientException(_("You must be logged in to train spam."), 403);
}
// User must have the right to review spam
if (!$user->hasRight(ActivitySpamPlugin::TRAINSPAM)) {
throw new ClientException(_('You cannot review spam on this site.'), 403);
}
$id = $this->trimmed('notice');
$this->notice = Notice::staticGet('id', $id);
if (empty($this->notice)) {
throw new ClientException(_("No such notice."));
}
$this->checkSessionToken();
$filter = null;
Event::handle('GetSpamFilter', array(&$filter));
if (empty($filter)) {
throw new ServerException(_("No spam filter configured."));
}
$this->filter = $filter;
$this->category = $this->trimmed('category');
if ($this->category !== SpamFilter::SPAM && $this->category !== SpamFilter::HAM) {
throw new ClientException(_("No such category."));
}
return true;
}
示例7: prepare
function prepare($args)
{
parent::prepare($args);
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Client error displayed when trying to repeat a notice while not logged in.
$this->clientError(_('Only logged-in users can repeat notices.'));
return false;
}
$id = $this->trimmed('notice');
if (empty($id)) {
// TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID.
$this->clientError(_('No notice specified.'));
return false;
}
$this->notice = Notice::staticGet('id', $id);
if (empty($this->notice)) {
// TRANS: Client error displayed when trying to repeat a non-existing notice.
$this->clientError(_('No notice specified.'));
return false;
}
$token = $this->trimmed('token-' . $id);
if (empty($token) || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return false;
}
return true;
}
示例8: getStreamByIds
static function getStreamByIds($ids)
{
$cache = Cache::instance();
if (!empty($cache)) {
$notices = array();
foreach ($ids as $id) {
$n = Notice::staticGet('id', $id);
if (!empty($n)) {
$notices[] = $n;
}
}
return new ArrayWrapper($notices);
} else {
$notice = new Notice();
if (empty($ids)) {
//if no IDs requested, just return the notice object
return $notice;
}
$notice->whereAdd('id in (' . implode(', ', $ids) . ')');
$notice->find();
$temp = array();
while ($notice->fetch()) {
$temp[$notice->id] = clone $notice;
}
$wrapped = array();
foreach ($ids as $id) {
if (array_key_exists($id, $temp)) {
$wrapped[] = $temp[$id];
}
}
return new ArrayWrapper($wrapped);
}
}
示例9: twitter_status_array
function twitter_status_array($notice, $include_user = true)
{
$profile = $notice->getProfile();
$twitter_status = array();
$twitter_status['text'] = $notice->content;
$twitter_status['truncated'] = 'false';
# Not possible on Laconica
$twitter_status['created_at'] = $this->date_twitter($notice->created);
$twitter_status['in_reply_to_status_id'] = $notice->reply_to ? intval($notice->reply_to) : null;
$twitter_status['source'] = $this->source_link($notice->source);
$twitter_status['id'] = intval($notice->id);
$replier_profile = null;
if ($notice->reply_to) {
$reply = Notice::staticGet(intval($notice->reply_to));
if ($reply) {
$replier_profile = $reply->getProfile();
}
}
$twitter_status['in_reply_to_user_id'] = $replier_profile ? intval($replier_profile->id) : null;
$twitter_status['in_reply_to_screen_name'] = $replier_profile ? $replier_profile->nickname : null;
if (isset($this->auth_user)) {
$twitter_status['favorited'] = $this->auth_user->hasFave($notice) ? 'true' : 'false';
} else {
$twitter_status['favorited'] = 'false';
}
if ($include_user) {
# Don't get notice (recursive!)
$twitter_user = $this->twitter_user_array($profile, false);
$twitter_status['user'] = $twitter_user;
}
return $twitter_status;
}
示例10: getNotice
/**
* Look up a notice from an argument, by poster's name to get last post
* or notice_id prefixed with #.
*
* @return Notice
* @throws CommandException
*/
function getNotice($arg)
{
$notice = null;
if (Event::handle('StartCommandGetNotice', array($this, $arg, &$notice))) {
if (substr($this->other, 0, 1) == '#') {
// A specific notice_id #123
$notice = Notice::staticGet(substr($arg, 1));
if (!$notice) {
throw new CommandException(_('Notice with that id does not exist'));
}
}
if (Validate::uri($this->other)) {
// A specific notice by URI lookup
$notice = Notice::staticGet('uri', $arg);
}
if (!$notice) {
// Local or remote profile name to get their last notice.
// May throw an exception and report 'no such user'
$recipient = $this->getProfile($arg);
$notice = $recipient->getCurrentNotice();
if (!$notice) {
throw new CommandException(_('User has no last notice'));
}
}
}
Event::handle('EndCommandGetNotice', array($this, $arg, &$notice));
if (!$notice) {
throw new CommandException(_('Notice with that id does not exist'));
}
return $notice;
}
示例11: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error. POST is a HTTP command. It should not be translated.
$this->clientError(_('This method requires a POST.'), 400, $this->format);
return false;
}
$id = $this->trimmed('id');
$this->original = Notice::staticGet('id', $id);
if (empty($this->original)) {
$this->clientError(_('No such notice.'), 400, $this->format);
return false;
}
$this->user = $this->auth_user;
if ($this->user->id == $this->original->profile_id) {
$this->clientError(_('Cannot repeat your own notice.'), 400, $this->format);
return false;
}
$profile = $this->user->getProfile();
if ($profile->hasRepeated($id)) {
$this->clientError(_('Already repeated that notice.'), 400, $this->format);
return false;
}
return true;
}
示例12: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
$this->user = $this->auth_user;
$this->notice_id = (int) $this->trimmed('id');
if (empty($notice_id)) {
$this->notice_id = (int) $this->arg('id');
}
$this->notice = Notice::staticGet((int) $this->notice_id);
return true;
}
示例13: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
// TRANS: Client error displayed when trying to remove a favorite while not logged in.
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$fave = new Fave();
$fave->user_id = $user->id;
$fave->notice_id = $notice->id;
if (!$fave->find(true)) {
// TRANS: Client error displayed when trying to remove favorite status for a notice that is not a favorite.
$this->clientError(_('This notice is not a favorite!'));
return;
}
$result = $fave->delete();
if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__);
// TRANS: Server error displayed when removing a favorite from the database fails.
$this->serverError(_('Could not delete favorite.'));
return;
}
$user->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title for page on which favorites can be added.
$this->element('title', null, _('Add to favorites'));
$this->elementEnd('head');
$this->elementStart('body');
$favor = new FavorForm($this, $notice);
$favor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303);
}
}
示例14: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
$this->user = $this->auth_user;
$this->notice = Notice::staticGet($this->arg('id'));
if ($this->notice->repeat_of != '') {
common_log(LOG_DEBUG, 'Trying to Fave ' . $this->notice->id . ', repeat of ' . $this->notice->repeat_of);
common_log(LOG_DEBUG, 'Will Fave ' . $this->notice->repeat_of . ' instead');
$real_notice_id = $this->notice->repeat_of;
$this->notice = Notice::staticGet($real_notice_id);
}
return true;
}
示例15: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
// 'id' is an undocumented parameter in Twitter's API. Several
// clients make use of it, so we support it too.
// show.json?id=12345 takes precedence over /show/12345.json
$this->notice_id = (int) $this->trimmed('id');
if (empty($notice_id)) {
$this->notice_id = (int) $this->arg('id');
}
$this->notice = Notice::staticGet((int) $this->notice_id);
return true;
}