本文整理汇总了PHP中Model_User::find_user方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_User::find_user方法的具体用法?PHP Model_User::find_user怎么用?PHP Model_User::find_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_User
的用法示例。
在下文中一共展示了Model_User::find_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get newsfeed item as HTML
*
* @param Model_NewsfeedItem $item
* @return string
*/
public static function get(Model_NewsfeedItem $item)
{
$link = $item->is_aggregate() ? implode('<br>', self::get_links($item)) : self::get_link($item);
if (!$link) {
return '';
}
$text = '';
switch ($item->type) {
case self::TYPE_COMMENT:
$text = $item->is_aggregate() ? __('commented photos') : __('commented a photo');
break;
case self::TYPE_COMMENT_FLYER:
$text = $item->is_aggregate() ? __('commented flyers') : __('commented a flyer');
break;
case self::TYPE_FLYER_EDIT:
$text = $item->is_aggregate() ? __('updated flyers') : __('updated a flyer');
break;
case self::TYPE_NOTE:
$user = Model_User::find_user($item->data['user_id']);
if ($link && $user->loaded()) {
$text = __('tagged :user to a photo', array(':user' => HTML::user($user)));
}
break;
case self::TYPE_UPLOAD:
$text = __('added new photos to a gallery');
break;
}
return $text . '<br />' . $link;
}
示例2: get
/**
* Get newsfeed item as HTML
*
* @param Model_NewsfeedItem $item
* @return string
*/
public static function get(Model_NewsfeedItem $item)
{
$text = '';
switch ($item->type) {
case self::TYPE_COMMENT:
$gallery = Model_Gallery::factory($item->data['gallery_id']);
$image = Model_Image::factory($item->data['image_id']);
if ($gallery->loaded() && $image->loaded()) {
$text = __('commented to an image<br />:gallery', array(':gallery' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), '<i class="icon-camera icon-white"></i> ' . HTML::chars($gallery->name), array('class' => 'hoverable'))));
}
break;
case self::TYPE_COMMENT_FLYER:
$flyer = Model_Flyer::factory($item->data['flyer_id']);
if ($flyer->loaded()) {
$text = __('commented to a flyer<br />:flyer', array(':flyer' => HTML::anchor(Route::url('flyer', array('id' => $flyer->id)), '<i class="icon-picture icon-white"></i> ' . ($flyer->name ? HTML::chars($flyer->name) : __('flyer')), array('class' => 'hoverable'))));
}
break;
case self::TYPE_FLYER_EDIT:
$flyer = Model_Flyer::factory($item->data['flyer_id']);
if ($flyer->loaded()) {
$text = __('updated flyer<br />:flyer', array(':flyer' => HTML::anchor(Route::url('flyer', array('id' => $flyer->id)), '<i class="icon-picture icon-white"></i> ' . ($flyer->name ? HTML::chars($flyer->name) : __('flyer')), array('class' => 'hoverable'))));
}
break;
case self::TYPE_NOTE:
$gallery = Model_Gallery::factory($item->data['gallery_id']);
$image = Model_Image::factory($item->data['image_id']);
$user = Model_User::find_user($item->data['user_id']);
if ($gallery->loaded() && $image->loaded() && $user->loaded()) {
$text = __('tagged :user to an image<br />:gallery', array(':user' => HTML::user($user), ':gallery' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), '<i class="icon-tag icon-white"></i> ' . HTML::chars($gallery->name), array('class' => 'hoverable'))));
}
break;
}
return $text;
}
示例3: get_link
/**
* Get anchor to newsfeed item target.
*
* @static
* @param Model_NewsfeedItem $item
* @return string
*/
public static function get_link(Model_NewsfeedItem $item)
{
$text = '';
switch ($item->type) {
case self::TYPE_FRIEND:
if ($friend = Model_User::find_user($item->data['friend_id'])) {
$text = HTML::user($friend);
}
break;
}
return $text;
}
示例4: __construct
/**
* Create new view.
*
* @param Model_Forum_Post $forum_post
* @param Model_Forum_Topic $forum_topic
*/
public function __construct(Model_Forum_Post $forum_post, Model_Forum_Topic $forum_topic)
{
parent::__construct();
$this->forum_post = $forum_post;
$this->forum_topic = $forum_topic;
// Get post author
$this->author = Model_User::find_user($this->forum_post->author_id);
// Viewer's post
$this->my = self::$_user && $this->author && $this->author->id == self::$_user_id;
// Topic author's post
$this->owner = $this->author ? $this->author->id == $this->forum_topic->author_id : $this->forum_post->author_name == $this->forum_topic->author_name;
$this->id = 'post-' . $this->forum_post->id;
$this->class = 'media permalink post' . ($this->owner ? ' owner' : '') . ($this->my ? ' my' : '');
}
示例5: get
/**
* Get notification as HTML.
*
* @static
* @param Model_Notification
* @return string
*/
public static function get(Model_Notification $notification)
{
$text = '';
switch ($notification->type) {
case self::TYPE_FRIEND:
$friend = Model_User::find_user($notification->user_id);
if ($friend->loaded()) {
$text = __(':friend added you as a friend', array(':friend' => HTML::user($friend)));
} else {
$notification->delete();
}
break;
}
return $text;
}
示例6: has_permission
/**
* Check permission
*
* @param string $permission
* @param Model_User $user
* @return boolean
*/
public function has_permission($permission, $user)
{
switch ($permission) {
case self::PERMISSION_READ:
return true;
case self::PERMISSION_CREATE:
return (bool) $user;
case self::PERMISSION_COMMENT:
case self::PERMISSION_COMMENTS:
$author = Model_User::find_user($this->author_id);
return $user && ($this->author_id == $user->id || !$author->is_ignored($user) && !$author->is_ignored($user, true));
case self::PERMISSION_DELETE:
case self::PERMISSION_UPDATE:
return $user && ($this->author_id == $user->id || $user->has_role('admin'));
}
return false;
}
示例7: has
/**
* Check permission for object
*
* @static
* @param Permission_Interface $model Object implemeneting permission interface
* @param string $permission
* @param mixed $user Defaults to session user
* @return boolean
*/
public static function has(Permission_Interface $model, $permission = Permission_Interface::PERMISSION_READ, $user = false)
{
if (Kohana::$profiling === true && class_exists('Profiler', false)) {
$benchmark = Profiler::start('Anqh', __METHOD__ . '(' . get_class($model) . ')');
}
// Make sure we have a valid user, if any
$user = Model_User::find_user($user);
// Create unique permission id for caching
$permission_id = sprintf('%s:%d:%s:%d', get_class($model), $model->id(), $permission, $user && $user->loaded() ? $user->id : 0);
// If permission check not found from cache ask the model
if (!isset(self::$_permissions[$permission_id])) {
self::$_permissions[$permission_id] = $model->has_permission($permission, $user);
}
if (isset($benchmark)) {
Profiler::stop($benchmark);
}
return self::$_permissions[$permission_id];
}
示例8: user
/**
* Get URL for user
*
* @param mixed $user
* @param string $action
* @return string
*/
public static function user($user, $action = null)
{
// User id given
if (is_numeric($user) && (int) $user > 0) {
$user = Model_User::find_user($user);
}
// Model_User given
if ($user instanceof Model_User) {
$user = $user->username;
} else {
if (is_array($user) && isset($user['username'])) {
$user = $user['username'];
}
}
// Username given
if (is_string($user)) {
return Route::get('user')->uri(array('username' => urlencode($user), 'action' => $action));
}
return null;
}
示例9: bbcode_quote
/**
* Handle forum quotations
*
* @param BBCode $bbcode
* @param string $action
* @param string $name
* @param string $default
* @param array $params
* @param string $content
* @return string
*/
public function bbcode_quote($bbcode, $action, $name, $default, $params, $content)
{
// Pass all to 2nd phase
if ($action == BBCODE_CHECK) {
return true;
}
// Parse parameters
foreach ($params['_params'] as $param) {
switch ($param['key']) {
// Parent post id
case 'post':
$post = Jelly::select('forum_post', (int) $param['value']);
break;
// Parent post author
// Parent post author
case 'author':
$author_name = $param['value'];
$author = Model_User::find_user($author_name);
break;
}
}
// Add parent post
if (isset($post) && $post->loaded()) {
$quote = '<blockquote cite="' . URL::site(Route::model($post->topic)) . '?post=' . $post->id . '#post-' . $post->id . '">';
// Override author
$author = $post->author;
} else {
$quote = '<blockquote>';
}
$quote .= '<p>' . trim($content) . '</p>';
// Post author
if (isset($author) && $author->loaded()) {
$quote .= '<cite>' . __('-- :author', array(':author' => HTML::user($author))) . '</cite>';
} else {
if (isset($author_name)) {
$quote .= '<cite>' . __('-- :author', array(':author' => HTML::chars($author_name))) . '</cite>';
}
}
$quote .= '</blockquote>';
return $quote;
}
示例10: get
/**
* Get newsfeed item as HTML
*
* @static
* @param Model_NewsfeedItem $item
* @return string
*/
public static function get(Model_NewsFeedItem $item)
{
$text = '';
switch ($item->type) {
case self::TYPE_DEFAULT_IMAGE:
$image = Model_Image::factory($item->data['image_id']);
if ($image->loaded()) {
$text = __('changed their default image');
}
break;
case self::TYPE_FRIEND:
$friend = Model_User::find_user($item->data['friend_id']);
if ($friend->loaded()) {
$text = __('added :friend as a friend', array(':friend' => HTML::user($friend)));
}
break;
case self::TYPE_LOGIN:
$text = __('logged in');
break;
}
return $text;
}
示例11: user
/**
* Get URL for user
*
* @param mixed $user true for session user
* @param string $action
* @return string
*/
public static function user($user, $action = null)
{
static $_visitor;
if (is_numeric($user) && (int) $user > 0) {
// User id given
if ($user = Model_User::find_user($user)) {
$user = $user->username;
}
} else {
if ($user instanceof Model_User) {
// Model_User given
$user = $user->username;
} else {
if (is_array($user) && isset($user['username'])) {
// Light user array given
$user = $user['username'];
} else {
if ($user === true) {
// Use session user
if ($_visitor === null) {
if ($user = Visitor::instance()->get_user()) {
$_visitor = $user->username;
} else {
// No session user available
$_visitor = false;
}
}
$user = $_visitor;
}
}
}
}
// Username available
if (is_string($user)) {
return Route::url('user', array('username' => urlencode($user), 'action' => $action));
}
return null;
}
示例12: action_password
/**
* Action: Password lost
*/
public function action_password()
{
$this->history = false;
$email = $message = '';
// Handle request
if ($_POST && ($email = trim(Arr::get($_POST, 'email', '')))) {
$message = new View_Alert(__('We could not find any user or the user is missing email address, sorry.'), __('Uh oh,'));
// Find the user, accept only strings
$user = Valid::digit($email) ? false : Model_User::find_user(trim($email));
// Send email
if ($user && Valid::email($user->email)) {
$subject = __('Your new :site password', array(':site' => Kohana::$config->load('site.site_name')));
$mail = __("Forgot your password, :username?\n\nWe received a request to generate a new password for your :site account, please sign in and change your password. You should also delete this email.\n\nUsername: :username\nPassword: :password", array(':site' => Kohana::$config->load('site.site_name'), ':username' => Text::clean($user->username), ':password' => Visitor::generate_password($user->password)));
if (Email::send($user->email, Kohana::$config->load('site.email_invitation'), $subject, $mail)) {
$message = new View_Alert(__(':email should soon receive the generated password in their inbox.', array(':email' => $email)), __('Mission accomplished!'), View_Alert::SUCCESS);
$email = '';
}
}
}
// Build page
$this->view = View_Page::factory(__('Misplaced your password?'));
$this->view->add(View_Page::COLUMN_MAIN, $this->section_password($message, $email));
}
示例13: _unique
/**
* Validate callback wrapper for checking email uniqueness
*
* @static
* @param Validate $array
* @param string $field
*/
public static function _unique(Validate $array, $field)
{
if (Model_User::find_user($array[$field])) {
$array->error($field, 'unique', array('param1' => $field));
}
}
示例14: image_removal_request
/**
* Report image.
*
* @static
* @param Model_User $user
* @param Model_Image $image
* @param string $reason
*/
public static function image_removal_request(Model_User $user, Model_Image $image, $reason = null)
{
if ($user && $image) {
$author = Model_User::find_user($image->author_id);
if ($author) {
parent::add($user, $author, self::CLASS_GALLERIES, self::TYPE_IMAGE_REPORT, $image->id, $reason);
}
}
}
示例15: _get_user
/**
* Make sure given user is a proper user object
*
* @param mixed $user
* @return Model_User
*/
protected function _get_user($user)
{
static $current;
if (!is_object($current) && (is_string($user) || is_int($user))) {
$current = Model_User::find_user($user);
}
if ($user instanceof Model_User && $user->loaded()) {
$current = $user;
}
return $current;
}