本文整理汇总了PHP中Notice::getKV方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::getKV方法的具体用法?PHP Notice::getKV怎么用?PHP Notice::getKV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::getKV方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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::getKV('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;
}
示例2: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$profile = AnonymousFavePlugin::getAnonProfile();
if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error.
$this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.'));
}
$id = $this->trimmed('notice');
$notice = Notice::getKV($id);
$token = $this->checkSessionToken();
// Throws exception
$stored = Fave::addNew($profile, $notice);
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title.
$this->element('title', null, _m('Disfavor favorite'));
$this->elementEnd('head');
$this->elementStart('body');
$disfavor = new AnonDisFavorForm($this, $notice);
$disfavor->show();
$this->elementEnd('body');
$this->endHTML();
} else {
$this->returnToPrevious();
}
}
示例3: __construct
/**
* constructor
*
* Also initializes the profile attribute.
*
* @param Notice $notice The notice we'll display
*/
function __construct(Notice $notice, Action $out = null, array $prefs = array())
{
parent::__construct($out);
if (!empty($notice->repeat_of)) {
$original = Notice::getKV('id', $notice->repeat_of);
if (!$original instanceof Notice) {
// could have been deleted
$this->notice = $notice;
} else {
$this->notice = $original;
$this->repeat = $notice;
}
} else {
$this->notice = $notice;
}
$this->profile = $this->notice->getProfile();
// integer preferences
foreach (array('maxchars') as $key) {
if (array_key_exists($key, $prefs)) {
$this->{$key} = (int) $prefs[$key];
}
}
// boolean preferences
foreach (array('addressees', 'attachments', 'options') as $key) {
if (array_key_exists($key, $prefs)) {
$this->{$key} = (bool) $prefs[$key];
}
}
// string preferences
foreach (array('id_prefix', 'item_tag') as $key) {
if (array_key_exists($key, $prefs)) {
$this->{$key} = $prefs[$key];
}
}
}
示例4: 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::getKV(substr($arg, 1));
if (!$notice) {
// TRANS: Command exception text shown when a notice ID is requested that does not exist.
throw new CommandException(_('Notice with that id does not exist.'));
}
}
if (Validate::uri($this->other)) {
// A specific notice by URI lookup
$notice = Notice::getKV('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) {
// TRANS: Command exception text shown when a last user notice is requested and it does not exist.
throw new CommandException(_('User has no last notice.'));
}
}
}
Event::handle('EndCommandGetNotice', array($this, $arg, &$notice));
if (!$notice) {
// TRANS: Command exception text shown when a notice ID is requested that does not exist.
throw new CommandException(_('Notice with that id does not exist.'));
}
return $notice;
}
示例5: handle
function handle($notice)
{
assert($notice instanceof Notice);
$this->notice = $notice;
$this->user = User::getKV('id', $notice->profile_id);
try {
$profile = $this->notice->getProfile();
} catch (Exception $e) {
common_log(LOG_ERR, "Can't get profile for notice; skipping: " . $e->getMessage());
return true;
}
if ($notice->isLocal()) {
// Notices generated on remote sites will have already
// been pushed to user's subscribers by their origin sites.
$this->pushUser();
}
foreach ($notice->getGroups() as $group) {
$oprofile = Ostatus_profile::getKV('group_id', $group->id);
if ($oprofile) {
// remote group
if ($notice->isLocal()) {
$this->pingReply($oprofile);
}
} else {
// local group
$this->pushGroup($group->id);
}
}
if ($notice->isLocal()) {
// Notices generated on other sites will have already
// pinged their reply-targets.
foreach ($notice->getReplies() as $profile_id) {
$oprofile = Ostatus_profile::getKV('profile_id', $profile_id);
if ($oprofile) {
$this->pingReply($oprofile);
}
}
if (!empty($this->notice->reply_to)) {
$replyTo = Notice::getKV('id', $this->notice->reply_to);
if (!empty($replyTo)) {
foreach ($replyTo->getReplies() as $profile_id) {
$oprofile = Ostatus_profile::getKV('profile_id', $profile_id);
if ($oprofile) {
$this->pingReply($oprofile);
}
}
}
}
foreach ($notice->getProfileTags() as $ptag) {
$oprofile = Ostatus_profile::getKV('peopletag_id', $ptag->id);
if (!$oprofile) {
$this->pushPeopletag($ptag);
}
}
}
return true;
}
示例6: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
protected function prepare(array $args = array())
{
parent::prepare($args);
$id = $this->trimmed('id');
$this->original = Notice::getKV('id', $id);
if (!$this->original instanceof Notice) {
// TRANS: Client error displayed trying to repeat a non-existing notice through the API.
$this->clientError(_('No such notice.'), 400, $this->format);
}
return true;
}
示例7: prepare
protected function prepare(array $args = array())
{
parent::prepare($args);
$args = $this->returnToArgs();
$this->photoid = $args[1]['photoid'];
$this->photo = GNUsocialPhoto::getKV('id', $this->photoid);
$this->notice = Notice::getKV('id', $this->photo->notice_id);
$this->user = Profile::getKV('id', $this->notice->profile_id);
$this->conv = $this->notice->getConversation();
return true;
}
示例8: 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::getKV((int) $this->notice_id);
return true;
}
示例9: prepare
protected function prepare(array $args = array())
{
parent::prepare($args);
$this->notice = Notice::getKV($this->arg('id'));
if (!empty($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::getKV($real_notice_id);
}
return true;
}
示例10: 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::getKV($this->arg('id'));
if ($this->notice->repeat_of != '') {
common_log(LOG_DEBUG, 'Trying to unFave ' . $this->notice->id);
common_log(LOG_DEBUG, 'Will unFave ' . $this->notice->repeat_of . ' instead');
$real_notice_id = $this->notice->repeat_of;
$this->notice = Notice::getKV($real_notice_id);
}
return true;
}
示例11: getNotice
function getNotice()
{
$this->id = $this->trimmed('id');
$this->bookmark = Bookmark::getKV('id', $this->id);
if (empty($this->bookmark)) {
// TRANS: Client exception thrown when referring to a non-existing bookmark.
throw new ClientException(_m('No such bookmark.'), 404);
}
$notice = Notice::getKV('uri', $this->bookmark->uri);
if (empty($notice)) {
// Did we used to have it, and it got deleted?
// TRANS: Client exception thrown when referring to a non-existing bookmark.
throw new ClientException(_m('No such bookmark.'), 404);
}
return $notice;
}
示例12: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*
*/
protected function prepare(array $args = array())
{
parent::prepare($args);
$this->notice_id = $this->trimmed('notice_id');
$this->original = Notice::getKV('id', $this->notice_id);
if (empty($this->original)) {
// TRANS: Client error displayed trying to display redents of a non-exiting notice.
$this->clientError(_('No such notice.'), 400, $this->format);
return false;
}
$cnt = $this->trimmed('count');
if (empty($cnt) || !is_integer($cnt)) {
$this->cnt = 100;
} else {
$this->cnt = min((int) $cnt, self::MAXCOUNT);
}
return true;
}
示例13: show
/**
* show the list of notices
*
* "Uses up" the stream by looping through it. So, probably can't
* be called twice on the same list.
*
* @return int count of notices listed.
*/
function show()
{
$this->out->elementStart('div', array('id' => 'notices_primary'));
// TRANS: Header for Notices section.
$this->out->element('h2', null, _m('HEADER', 'Notices'));
$this->out->elementStart('ol', array('class' => 'notices threaded-notices xoxo'));
$notices = $this->notice->fetchAll();
$total = count($notices);
$notices = array_slice($notices, 0, NOTICES_PER_PAGE);
$allnotices = self::_allNotices($notices);
self::prefill($allnotices);
$conversations = array();
foreach ($notices as $notice) {
// Collapse repeats into their originals...
if ($notice->repeat_of) {
$orig = Notice::getKV('id', $notice->repeat_of);
if ($orig instanceof Notice) {
$notice = $orig;
}
}
$convo = $notice->conversation;
if (!empty($conversations[$convo])) {
// Seen this convo already -- skip!
continue;
}
$conversations[$convo] = true;
// Get the convo's root notice
$root = $notice->conversationRoot($this->userProfile);
if ($root instanceof Notice) {
$notice = $root;
}
try {
$item = $this->newListItem($notice);
$item->show();
} catch (Exception $e) {
// we log exceptions and continue
common_log(LOG_ERR, $e->getMessage());
continue;
}
}
$this->out->elementEnd('ol');
$this->out->elementEnd('div');
return $total;
}
示例14: doPreparation
protected function doPreparation()
{
$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.'));
}
$this->notice = Notice::getKV('id', $id);
if (!$this->notice instanceof Notice) {
// TRANS: Client error displayed when trying to repeat a non-existing notice.
$this->clientError(_('Notice not found.'));
}
$this->repeat = $this->notice->repeat($this->scoped, 'web');
if (!$this->repeat instanceof Notice) {
// TRANS: Error when unable to repeat a notice for unknown reason.
$this->clientError(_('Could not repeat notice for unknown reason. Please contact the webmaster!'));
}
return true;
}
示例15: prepare
function prepare($args)
{
parent::prepare($args);
$this->user = common_current_user();
if (!$this->user) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
common_user_error(_('Not logged in.'));
exit;
}
$notice_id = $this->trimmed('notice');
$this->notice = Notice::getKV($notice_id);
if (!$this->notice) {
// TRANS: Error message displayed trying to delete a non-existing notice.
common_user_error(_('No such notice.'));
exit;
}
$this->profile = $this->notice->getProfile();
$this->user_profile = $this->user->getProfile();
return true;
}