本文整理汇总了PHP中Profile::experience方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::experience方法的具体用法?PHP Profile::experience怎么用?PHP Profile::experience使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::experience方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public static function get($post_id, $cache_time = 0, $sort = null)
{
Phalanx::loadClasses('public.Profile', 'public.Badges');
$cache_time = $cache_time ? $cache_time : MEMCACHE_SECONDS;
$m = Model::Factory('comment c', true, $cache_time);
$m->fields('c.id AS id', 'u.id AS user_id', 'c.comment AS comment', 'c.date AS date', 'c.in_reply_to AS in_reply_to', 'c.like_count AS likes', 'c.dislike_count AS dislikes', 'u.login AS user', 'ud.avatar AS avatar', 'c.wp_comment_author AS wp_comment_author', 'c.wp_comment_author_email AS wp_comment_author_email');
$m->leftJoin('user u', 'u.id = c.user_id');
$m->leftJoin('user_data ud', 'ud.user_id = u.id');
$m->where("posts_id='{$post_id}' AND c.status=1 AND u.banned IS NULL");
if (is_null($sort)) {
$m->order("c.id ASC");
} elseif ($sort == 'like') {
$m->order("c.like_count DESC");
}
$data = $m->all();
$comments = array();
$Session = new Session();
if (is_array($data)) {
foreach ($data as $each) {
$o = new stdClass();
$o->id = $each->id;
$o->comment = $each->comment;
$o->date = Date::RelativeTime($each->date);
$o->rating = new stdClass();
$o->rating->megaboga = (int) $each->likes;
$o->rating->whatever = (int) $each->dislikes;
$o->my_rating = self::userRating($Session->user->id, $each->id);
$o->user = new stdClass();
$o->create_links = $each->user_id == 0 ? false : true;
$o->user->login = $each->user_id == 0 ? $each->wp_comment_author : $each->user;
$o->user->avatar = $each->user_id == 0 ? "http://www.gravatar.com/avatar/" . md5(strtolower(trim($each->wp_comment_author_email))) . "?d=" . urlencode(MEDIA_DIR . 'images/avatar/square/default.jpg') . "&s=44" : $each->avatar;
$o->user->id = $each->user_id;
if ($each->user_id != 0) {
$o->user->experience = Profile::experience($each->user_id);
$o->user->badges = Badges::from_user($each->user_id, 4);
}
if ($each->in_reply_to == '' || $each->in_reply_to == '0') {
$o->replies = is_array($comments[$each->id]->replies) ? $comments[$each->id]->replies : array();
$comments[$each->id] = $o;
} else {
$comments[$each->in_reply_to]->replies[] = $o;
}
}
}
return $comments;
}
示例2: Login
public function Login()
{
$user = Profile::login($this->post->username, md5($this->post->password));
$o = new stdClass();
if ($user and $user->banned != 1) {
$this->session->logged_in = true;
$this->session->user = $user;
$this->session->accept_token = md5(REQUEST_IP) . sha1('SkyNerd a REDE SOCIAL do JoVemNerd');
$o->status = true;
$o->login = $user->login;
$o->avatar = $user->other_data->avatar;
$o->experience = Profile::experience($this->session->user->id);
$o->badges = Badges::from_user($this->session->user->id, 4);
} else {
$o->status = false;
$o->reason = $user->banned == 1 ? 'banned' : 'incorrect_info';
}
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST");
header("Content-type: text/html; charset=utf-8");
echo json_encode($o);
}
示例3: build_from_list
public static function build_from_list($uid, $list_id, stdClass $config)
{
Phalanx::loadClasses('Friendship');
$friends_ids = Friendship::get_friend_array($uid);
$friends_ids = implode(', ', $friends_ids);
$where = "";
if (property_exists($config, 'min')) {
$where .= " AND p.id < '{$config->min}'";
}
if (property_exists($config, 'max')) {
$where .= " AND p.id < '{$config->max}'";
}
Phalanx::loadClasses('Lists', 'SocialNetwork', 'Facebook', 'Twitter', 'twitteroauth', 'Instagram', 'PostCategory', 'Favorites', 'Profile');
$list = Lists::from_user($uid, $list_id);
$categories = array();
foreach ($list->categories as $category) {
$categories[] = $category->id;
}
if (sizeof($categories) > 0) {
Phalanx::loadClasses('Posts', 'PostComments');
$categories_ids = implode("', '", $categories);
$custom_tl = array();
$m = Model::Factory('posts p', false, 0);
$m->fields('DISTINCT p.id AS id', 'p.original_posts_id AS original_id', 'p.user_id AS user_id', 'p.content AS content', 'p.date AS date', 'p.title AS title', 'p.promoted AS promoted', 'u.name AS name', 'u.login AS user', 'ud.avatar AS avatar', 'p.like_count AS likes', 'p.dislike_count AS dislikes', 'p.comment_count AS comments', 'p.reblog_count AS reblogs', 'p.reply_count AS replies');
$m->innerJoin('user u', 'u.id = p.user_id');
$m->innerJoin('user_data ud', 'ud.user_id = p.user_id');
$m->innerJoin('posts_has_category phc', 'p.id = phc.posts_id');
$m->where("p.user_id IN({$friends_ids}) AND phc.category_id IN ('{$categories_ids}') {$where} AND u.banned IS NULL AND p.status=1 AND p.date > DATE_SUB(NOW(), INTERVAL 1 MONTH)");
# $m->group("p.original_posts_id");
$m->order('p.id DESC');
$m->limit(NUMBER_OF_POSTS_LOADED_PER_TIME);
$skynerd_posts = $m->all();
foreach ($skynerd_posts as $each) {
$o = new stdClass();
$o->date = Date::RelativeTime($each->date);
$o->id = $each->id;
$o->user = $each->user;
$o->name = $each->name;
$o->title = $each->title;
$o->avatar = $each->avatar;
$o->user_id = $each->user_id;
$o->rating = new stdClass();
$o->rating->megaboga = $each->likes;
$o->rating->whatever = $each->dislikes;
$o->my_rating = Posts::userRating($uid, $each->id);
$o->content = trim($each->content);
$o->comments = $v->comments;
$o->replies = $v->replies;
$o->categories = PostCategory::from_post($each->id);
$o->is_reblogged = Posts::userHasReblogged($each->id, $uid);
$o->is_favorite = Favorites::is_favorite($uid, $each->id);
$o->user_points = Profile::experience($v->user_id);
$o->promoted = (bool) $each->promoted;
if (!empty($o->original_id)) {
//Se o post for um reblog, então o conteúdo dele deve ser o do reblogado, mostrando as ações
$originalPost = Posts::from_user(false, $o->original_id);
$originalPost = reset($originalPost);
$o->content = $originalPost->content;
$o->title = $originalPost->title;
$o->reblogged_from = $originalPost->user;
$o->original_date = $originalPost->date;
$o->rating->reblog_count = $originalPost->rating->reblog_count;
$o->is_reblogged = Posts::userHasReblogged($originalPost->id, $uid);
}
$custom_tl[] = $o;
}
}
return $custom_tl;
}
示例4: Comment
public function Comment()
{
if (!$this->isLoggedIn) {
return;
}
if (!$this->session->recent_comments) {
$this->session->recent_comments = new stdClass();
}
if (!$this->session->recent_comments->{"pid" . $this->post->post_id}) {
$this->session->recent_comments->{"pid" . $this->post->post_id} = array();
}
if (in_array(md5($this->post->comment), $this->session->recent_comments->{"pid" . $this->post->post_id})) {
header("Content-type:application/json;charset=utf-8");
$o = new stdClass();
$o->status = 0;
$o->message = "Comentário duplicado";
die(json_encode($o));
}
if (trim($this->post->comment) == '') {
header("Content-type:application/json;charset=utf-8");
$o = new stdClass();
$o->status = 0;
$o->message = "Comentário vazio";
die(json_encode($o));
}
$m = Model::Factory('comment', false, false);
$m->posts_id = $this->post->post_id;
$m->comment = trim($this->post->comment);
$m->user_id = $this->session->user->id;
if ($this->post->in_reply_to) {
$m->in_reply_to = $this->post->in_reply_to;
}
$m->date = date('Y-m-d H:i:s');
if (isset($this->post->in_reply_to)) {
$m->in_reply_to = $this->post->in_reply_to;
$n = new Notification(Notification::REPLYED_COMMENT, $this->session->user->id, $this->post->in_reply_to);
} else {
$n = new Notification(Notification::COMMENTED_POST, $this->session->user->id, $this->post->post_id);
}
$s = $m->insert();
if ($s) {
$this->session->recent_comments->{"pid" . $this->post->post_id}[] = md5($this->post->comment);
Phalanx::loadClasses('Profile');
preg_match_all('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', $this->post->comment, $usernames);
foreach ($usernames[1] as $username) {
$user = Profile::get_user_info($username);
if ($user) {
$n = new Notification(Notification::TAGGED_IN_A_COMMENT, $this->session->user->id, $this->post->post_id, $user->id);
}
}
if ($this->post->in_reply_to) {
Model::ExecuteQuery("UPDATE posts SET reply_count = reply_count+1 WHERE id='{$this->post->post_id}'");
} else {
Model::ExecuteQuery("UPDATE posts SET comment_count = comment_count+1 WHERE id='{$this->post->post_id}'");
}
Phalanx::loadClasses('Profile', 'Badges');
header("Content-type:application/json;charset=utf-8");
$o = new stdClass();
$o->status = 1;
$o->isReply = $this->post->in_reply_to ? true : false;
$o->id = $s;
$o->avatar = $this->session->user->other_data->avatar;
$o->user = $this->session->user->login;
$o->comment = nl2br(trim(preg_replace('/(?<=|(?<=[.A-Za-z0-9_-]))@([.A-Za-z0-9_-]+[.A-Za-z0-9_-]+)/', '<a class="profile-link" href="' . HOST . 'perfil/$1"e>@$1</a>', $this->post->comment)));
$o->comment_id = $s;
$o->post_id = $this->post->post_id;
if ($this->post->in_reply_to) {
$o->in_reply_to = $this->post->in_reply_to;
}
$o->experience = Profile::experience($this->session->user->id);
$o->badges = Badges::from_user($this->session->user->id, 4);
die(json_encode($o));
}
}
示例5: exportFromUser
public static function exportFromUser($uid)
{
Phalanx::loadClasses('PostCategory', 'PostComments', 'Favorites');
$m = Model::Factory('posts p', 0);
$m->fields('p.id AS id', 'p.original_posts_id AS original_id', 'p.title AS title', 'p.user_id AS user_id', 'p.content AS content', 'p.date AS date', 'p.public AS privacy', 'p.like_count AS likes', 'p.dislike_count AS dislikes', 'p.reblog_count AS reblogs', 'p.comment_count AS comments', 'p.reply_count AS replies', 'p.promoted AS promoted', 'u.name AS name', 'u.login AS user', 'ud.avatar AS avatar');
$m->innerJoin('user u', 'u.id = p.user_id');
$m->innerJoin('user_data ud', 'ud.user_id = p.user_id');
$m->order('p.id DESC');
$where = array();
$where[] = "p.status=1";
$where[] = "p.original_posts_id IS NULL";
if ($uid) {
$where[] = "p.user_id = '{$uid}'";
}
$where = implode(" AND ", $where);
$m->where($where);
$data = $m->all();
$ret = array();
$Session = new Session();
foreach ($data as $v) {
$o = new stdClass();
$o->date = Date::RelativeTime($v->date);
$o->id = $v->id;
$o->original_id = $v->original_id;
$o->title = $v->title;
$o->user = $v->user;
$o->name = $v->name;
$o->avatar = $v->avatar;
$o->user_id = $v->user_id;
$o->content = trim($v->content);
$o->rating = new stdClass();
$o->rating->whatever = (int) abs($v->dislikes);
$o->rating->megaboga = (int) abs($v->likes);
$o->rating->reblog_count = (int) abs($v->reblogs);
$o->my_rating = self::userRating($Session->user->id, $v->id);
$o->is_reblogged = self::userHasReblogged($o->original_id, $Session->user->id);
$o->categories = PostCategory::from_post($v->id);
$o->comments = $v->comments;
$o->comments_array = PostComments::get($v->id);
$o->replies = $v->replies;
$o->privacy = $v->privacy;
$o->promoted = $v->promoted;
$o->is_favorite = Favorites::is_favorite($uid, $v->id);
$o->user_points = Profile::experience($v->user_id);
if (!empty($o->original_id)) {
//Se o post for um reblog, então o conteúdo dele deve ser o do reblogado, mostrando as ações
$originalPost = self::from_user(false, $o->original_id);
$originalPost = reset($originalPost);
$o->content = $originalPost->content;
$o->title = $originalPost->title;
$o->reblogged_from = $originalPost->user;
$o->original_date = $originalPost->date;
$o->rating->reblog_count = $originalPost->rating->reblog_count;
}
$ret[] = $o;
}
return $ret;
}