本文整理汇总了PHP中Profile::getKV方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::getKV方法的具体用法?PHP Profile::getKV怎么用?PHP Profile::getKV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::getKV方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: atompubPrepare
protected function atompubPrepare()
{
$subscriberId = $this->trimmed('subscriber');
$this->_subscriber = Profile::getKV('id', $subscriberId);
if (!$this->_subscriber instanceof Profile) {
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
// TRANS: %d is the non-existing profile ID number.
throw new ClientException(sprintf(_('No such profile id: %d.'), $subscriberId), 404);
}
$subscribedId = $this->trimmed('subscribed');
$this->_subscribed = Profile::getKV('id', $subscribedId);
if (!$this->_subscribed instanceof Profile) {
// TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID.
// TRANS: %d is the non-existing profile ID number.
throw new ClientException(sprintf(_('No such profile id: %d.'), $subscribedId), 404);
}
$this->_subscription = Subscription::pkeyGet(array('subscriber' => $subscriberId, 'subscribed' => $subscribedId));
if (!$this->_subscription instanceof Subscription) {
// TRANS: Client exception thrown when trying to display a subscription for a non-subscribed profile ID.
// TRANS: %1$d is the non-existing subscriber ID number, $2$d is the ID of the profile that was not subscribed to.
$msg = sprintf(_('Profile %1$d not subscribed to profile %2$d.'), $subscriberId, $subscribedId);
throw new ClientException($msg, 404);
}
return true;
}
示例2: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Client error displayed when trying to perform an action while not logged in.
$this->clientError(_('You must be logged in to unsubscribe from a list.'));
}
// Only allow POST requests
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error displayed when trying to use another method than POST.
$this->clientError(_('This action only accepts POST requests.'));
}
// CSRF protection
$token = $this->trimmed('token');
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.'));
}
$tagger_arg = $this->trimmed('tagger');
$tag_arg = $this->trimmed('tag');
$id = intval($this->arg('id'));
if ($id) {
$this->peopletag = Profile_list::getKV('id', $id);
} else {
// TRANS: Client error displayed when trying to perform an action without providing an ID.
$this->clientError(_('No ID given.'), 404);
}
if (!$this->peopletag || $this->peopletag->private) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'), 404);
}
$this->tagger = Profile::getKV('id', $this->peopletag->tagger);
return true;
}
示例3: silencespammer
function silencespammer($filter, $user, $minimum, $percent)
{
printfnq("Testing user %s\n", $user->nickname);
$profile = Profile::getKV('id', $user->id);
if ($profile->isSilenced()) {
printfnq("Already silenced %s\n", $user->nickname);
return;
}
$cnt = $profile->noticeCount();
if ($cnt < $minimum) {
printfnq("Only %d notices posted (minimum %d); skipping\n", $cnt, $minimum);
return;
}
$ss = new Spam_score();
$ss->query(sprintf("SELECT count(*) as spam_count " . "FROM notice join spam_score on notice.id = spam_score.notice_id " . "WHERE notice.profile_id = %d AND spam_score.is_spam = 1", $profile->id));
while ($ss->fetch()) {
$spam_count = $ss->spam_count;
}
$spam_percent = $spam_count * 100.0 / $cnt;
if ($spam_percent > $percent) {
printfnq("Silencing user %s (%d/%d = %0.2f%% spam)\n", $user->nickname, $spam_count, $cnt, $spam_percent);
try {
$profile->silence();
} catch (Exception $e) {
printfnq("Error: %s", $e->getMessage());
}
}
}
示例4: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
parent::prepare($argarray);
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Client exception thrown when trying to view group private messages without being logged in.
throw new ClientException(_m('Only logged-in users can view private messages.'), 403);
}
$id = $this->trimmed('id');
$this->gm = Group_message::getKV('id', $id);
if (empty($this->gm)) {
// TRANS: Client exception thrown when trying to view a non-existing group private message.
throw new ClientException(_m('No such message.'), 404);
}
$this->group = User_group::getKV('id', $this->gm->to_group);
if (empty($this->group)) {
// TRANS: Server exception thrown when trying to view group private messages for a non-exsting group.
throw new ServerException(_m('Group not found.'));
}
if (!$this->user->isMember($this->group)) {
// TRANS: Client exception thrown when trying to view a group private message without being a group member.
throw new ClientException(_m('Cannot read message.'), 403);
}
$this->sender = Profile::getKV('id', $this->gm->from_profile);
if (empty($this->sender)) {
// TRANS: Server exception thrown when trying to view a group private message without a sender.
throw new ServerException(_m('No sender found.'));
}
return true;
}
示例5: prepare
/**
* Check pre-requisites and instantiate attributes
*
* @param Array $args array of arguments (URL, GET, POST)
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// CSRF protection
$token = $this->trimmed('token');
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.'));
}
// Only for logged-in users
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
}
// Profile to subscribe to
$tagged_id = $this->arg('tagged');
$this->tagged = Profile::getKV('id', $tagged_id);
if (empty($this->tagged)) {
// TRANS: Client error displayed trying to perform an action related to a non-existing profile.
$this->clientError(_('No such profile.'));
}
$id = $this->arg('peopletag_id');
$this->peopletag = Profile_list::getKV('id', $id);
if (empty($this->peopletag)) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'));
}
return true;
}
示例6: __construct
/**
* constructor
*
* Also initializes the owner attribute.
*
* @param Notice $notice The notice we'll display
*/
function __construct($peopletag, $current, $out = null)
{
parent::__construct($out);
$this->peopletag = $peopletag;
$this->current = $current;
$this->profile = Profile::getKV('id', $this->peopletag->tagger);
}
示例7: show
function show()
{
$links = array();
$you = false;
$cur = common_current_user();
foreach ($this->getProfiles() as $id) {
if ($cur && $cur->id == $id) {
$you = true;
// TRANS: Reference to the logged in user in favourite list.
array_unshift($links, _m('FAVELIST', 'You'));
} else {
$profile = Profile::getKV('id', $id);
if ($profile instanceof Profile) {
$links[] = sprintf('<a class="h-card" href="%s">%s</a>', htmlspecialchars($profile->getUrl()), htmlspecialchars($profile->getBestName()));
}
}
}
if ($links) {
$count = count($links);
$msg = $this->getListMessage($count, $you);
$out = sprintf($msg, $this->magicList($links));
$this->showStart();
$this->out->raw($out);
$this->showEnd();
return $count;
} else {
return 0;
}
}
示例8: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
$cur = common_current_user();
if (empty($cur)) {
// TRANS: Client error displayed trying to approve group membership while not logged in.
$this->clientError(_('Must be logged in.'), 403);
}
if ($this->arg('profile_id')) {
$this->profile = Profile::getKV('id', $this->arg('profile_id'));
} else {
// TRANS: Client error displayed trying to approve subscriptionswithout specifying a profile to approve.
$this->clientError(_('Must specify a profile.'));
}
$this->request = Subscription_queue::pkeyGet(array('subscriber' => $this->profile->id, 'subscribed' => $cur->id));
if (empty($this->request)) {
// TRANS: Client error displayed trying to approve subscription for a non-existing request.
// TRANS: %s is a user nickname.
$this->clientError(sprintf(_('%s is not in the moderation queue for your subscriptions.'), $this->profile->nickname), 403);
}
$this->approve = (bool) $this->arg('approve');
$this->cancel = (bool) $this->arg('cancel');
if (!$this->approve && !$this->cancel) {
// TRANS: Client error displayed trying to approve/deny subscription.
$this->clientError(_('Internal error: received neither cancel nor abort.'));
}
if ($this->approve && $this->cancel) {
// TRANS: Client error displayed trying to approve/deny subscription
$this->clientError(_('Internal error: received both cancel and abort.'));
}
return true;
}
示例9: doPreparation
protected function doPreparation()
{
$profile_id = $this->int('unsubscribeto');
$this->target = Profile::getKV('id', $profile_id);
if (!$this->target instanceof Profile) {
throw new NoProfileException($profile_id);
}
}
示例10: showFeedForm
function showFeedForm($mirror)
{
$profile = Profile::getKV('id', $mirror->subscribed);
if ($profile) {
$form = new EditMirrorForm($this, $profile);
$form->show();
}
}
示例11: prepare
function prepare($args)
{
parent::prepare($args);
$args = $this->returnToArgs();
$this->profile = Profile::getKV('nickname', $args[1]['nickname']);
//die(print_r($this->profile));
gnusocial_profile_merge($this->profile);
return true;
}
示例12: handle
function handle($data)
{
assert(is_array($data));
assert(is_string($data['salmonuri']));
assert(is_string($data['entry']));
$actor = Profile::getKV($data['actor']);
Salmon::post($data['salmonuri'], $data['entry'], $actor->getUser());
// @fixme detect failure and attempt to resend
return true;
}
示例13: atompubPrepare
protected function atompubPrepare()
{
$this->_profile = Profile::getKV('id', $this->trimmed('profile'));
if (!$this->_profile instanceof Profile) {
// TRANS: Client exception.
throw new ClientException(_('No such profile.'), 404);
}
$this->_memberships = Group_member::byMember($this->_profile->id, $this->offset, $this->limit);
return true;
}
示例14: getMember
function getMember()
{
$member = Profile::getKV('id', $this->profile_id);
if (empty($member)) {
// TRANS: Exception thrown providing an invalid profile ID.
// TRANS: %s is the invalid profile ID.
throw new Exception(sprintf(_("Profile ID %s is invalid."), $this->profile_id));
}
return $member;
}
示例15: 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;
}