本文整理汇总了PHP中Profile::staticGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::staticGet方法的具体用法?PHP Profile::staticGet怎么用?PHP Profile::staticGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::staticGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('网页错误,请返回重试
'));
return false;
}
$id = $this->trimmed('profile');
if (!$id) {
$this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
$this->clientError(_('No profile with that ID.'));
return false;
}
return true;
}
示例2: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
common_set_returnto($_SERVER['REQUEST_URI']);
if (Event::handle('RedirectToLogin', array($this, null))) {
common_redirect(common_local_url('login'), 303);
}
}
$id = $this->trimmed('id');
if (!$id) {
$this->profile = false;
} else {
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
// TRANS: Client error displayed when referring to non-existing profile ID.
$this->clientError(_('No profile with that ID.'));
return false;
}
}
$current = common_current_user()->getProfile();
if ($this->profile && !$current->canTag($this->profile)) {
// TRANS: Client error displayed when trying to tag a user that cannot be tagged.
$this->clientError(_('You cannot tag this user.'));
}
return true;
}
示例3: prepare
function prepare($args)
{
Action::prepare($args);
// skip the ProfileAction code and replace it...
$id = $this->arg('id');
$this->user = false;
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
// TRANS: Error message displayed when referring to a user without a profile.
$this->serverError(_m('User has no profile.'));
return false;
}
$user = User::staticGet('id', $this->profile->id);
if ($user) {
// This is a local user -- send to their regular profile.
$url = common_local_url('showstream', array('nickname' => $user->nickname));
common_redirect($url);
return false;
}
$this->tag = $this->trimmed('tag');
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
common_set_returnto($this->selfUrl());
$p = Profile::current();
if (empty($this->tag)) {
$stream = new ProfileNoticeStream($this->profile, $p);
} else {
$stream = new TaggedProfileNoticeStream($this->profile, $this->tag, $p);
}
$this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
return true;
}
示例4: 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);
return false;
}
if ($this->arg('profile_id')) {
$this->profile = Profile::staticGet('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.'));
return false;
}
$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;
}
示例5: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
$this->checkSessionToken();
if (!common_logged_in()) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
} else {
// Redirect to login.
common_set_returnto($this->selfUrl());
$user = common_current_user();
if (Event::handle('RedirectToLogin', array($this, $user))) {
common_redirect(common_local_url('login'), 303);
}
}
return false;
}
$id = $this->trimmed('profileid');
if (!$id) {
// TRANS: Client error displayed when trying to change user options without specifying a user to work on.
$this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
// TRANS: Client error displayed when trying to change user options without specifying an existing user to work on.
$this->clientError(_('No profile with that ID.'));
return false;
}
return true;
}
示例6: prepare
function prepare($args)
{
parent::prepare($args);
$this->uri = $this->trimmed('uri');
$this->uri = self::normalize($this->uri);
if (self::isWebfinger($this->uri)) {
$parts = explode('@', substr(urldecode($this->uri), 5));
if (count($parts) == 2) {
list($nick, $domain) = $parts;
// @fixme confirm the domain too
// @fixme if domain checking is added, ensure that it will not
// cause problems with sites that have changed domains!
$nick = common_canonical_nickname($nick);
$this->user = User::staticGet('nickname', $nick);
}
} else {
$this->user = User::staticGet('uri', $this->uri);
if (empty($this->user)) {
// try and get it by profile url
$profile = Profile::staticGet('profileurl', $this->uri);
if (!empty($profile)) {
$this->user = User::staticGet('id', $profile->id);
}
}
}
if (!$this->user) {
$this->clientError(_('No such user.'), 404);
return false;
}
return true;
}
示例7: prepare
function prepare($args)
{
parent::prepare($args);
if (!common_logged_in()) {
// TRANS: Client error displayed trying a change a subscription while not logged in.
$this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. ' . 'Try again, please.'));
return false;
}
$id = $this->trimmed('profile');
if (!$id) {
// TRANS: Client error displayed trying a change a subscription without providing a profile.
$this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
// TRANS: Client error displayed trying a change a subscription for a non-existant profile ID.
$this->clientError(_('No profile with that ID.'));
return false;
}
return true;
}
示例8: 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.'));
return false;
}
// 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.'));
return false;
}
// Profile to subscribe to
$tagged_id = $this->arg('tagged');
$this->tagged = Profile::staticGet('id', $tagged_id);
if (empty($this->tagged)) {
// TRANS: Client error displayed when referring to a non-existing profile.
$this->clientError(_('No such profile.'));
return false;
}
$id = $this->arg('peopletag_id');
$this->peopletag = Profile_list::staticGet('id', $id);
if (empty($this->peopletag)) {
// TRANS: Client error displayed trying to reference a non-existing list.
$this->clientError(_('No such list.'));
return false;
}
return true;
}
示例9: saveNew
static function saveNew($from, $to, $content, $source)
{
$sender = Profile::staticGet('id', $from);
if (!$sender->hasRight(Right::NEWMESSAGE)) {
// TRANS: Client exception thrown when a user tries to send a direct message while being banned from sending them.
throw new ClientException(_('You are banned from sending direct messages.'));
}
$msg = new Message();
$msg->from_profile = $from;
$msg->to_profile = $to;
$msg->content = common_shorten_links($content);
$msg->rendered = common_render_text($content);
$msg->created = common_sql_now();
$msg->source = $source;
$result = $msg->insert();
if (!$result) {
common_log_db_error($msg, 'INSERT', __FILE__);
// TRANS: Message given when a message could not be stored on the server.
return _('Could not insert message.');
}
$orig = clone $msg;
$msg->uri = common_local_url('showmessage', array('message' => $msg->id));
$result = $msg->update($orig);
if (!$result) {
common_log_db_error($msg, 'UPDATE', __FILE__);
// TRANS: Message given when a message could not be updated on the server.
return _('Could not update message with new URI.');
}
return $msg;
}
示例10: importUser
/**
* Load or create an imported profile from Yammer data.
*
* @param object $item loaded JSON data for Yammer importer
* @return Profile
*/
function importUser($item)
{
$data = $this->prepUser($item);
$nickname = $data['options']['nickname'];
$profileId = $this->findImportedUser($data['orig_id']);
if ($profileId) {
return Profile::staticGet('id', $profileId);
} else {
$user = User::staticGet('nickname', $nickname);
if ($user) {
common_log(LOG_WARN, "Copying Yammer profile info onto existing user {$nickname}");
$profile = $user->getProfile();
$this->savePropertiesOn($profile, $data['options'], array('fullname', 'homepage', 'bio', 'location'));
} else {
$user = User::register($data['options']);
$profile = $user->getProfile();
}
if ($data['avatar']) {
try {
$this->saveAvatar($data['avatar'], $profile);
} catch (Exception $e) {
common_log(LOG_ERR, "Error importing Yammer avatar: " . $e->getMessage());
}
}
$this->recordImportedUser($data['orig_id'], $profile->id);
return $profile;
}
}
示例11: 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)) {
throw new ClientException(_('Only logged-in users can view private messages.'), 403);
}
$id = $this->trimmed('id');
$this->gm = Group_message::staticGet('id', $id);
if (empty($this->gm)) {
throw new ClientException(_('No such message'), 404);
}
$this->group = User_group::staticGet('id', $this->gm->to_group);
if (empty($this->group)) {
throw new ServerException(_('Group not found.'));
}
if (!$this->user->isMember($this->group)) {
throw new ClientException(_('Cannot read message.'), 403);
}
$this->sender = Profile::staticGet('id', $this->gm->from_profile);
if (empty($this->sender)) {
throw new ServerException(_('No sender found.'));
}
return true;
}
示例12: 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::staticGet('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::staticGet('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::staticGet('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;
}
示例13: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
parent::prepare($argarray);
$subscriberId = $this->trimmed('subscriber');
$this->_subscriber = Profile::staticGet('id', $subscriberId);
if (empty($this->_subscriber)) {
// 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::staticGet('id', $subscribedId);
if (empty($this->_subscribed)) {
// 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 (empty($this->_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;
}
示例14: showFeedForm
function showFeedForm($mirror)
{
$profile = Profile::staticGet('id', $mirror->subscribed);
if ($profile) {
$form = new EditMirrorForm($this, $profile);
$form->show();
}
}
示例15: hasRight
function hasRight($right)
{
$profile = Profile::staticGet($this->id);
if ($profile) {
return $profile->hasright($right);
} else {
throw new Exception("Missing profile");
}
}