Пример #1
0
 public function add($user_follow, $user_followed, $type)
 {
     $check = Relationship::model()->findAllByAttributes(array('user_id_1' => $user_follow, 'user_id_2' => $user_followed));
     $check_2 = Relationship::model()->findAllByAttributes(array('user_id_2' => $user_follow, 'user_id_1' => $user_followed));
     $check_3 = Follow::model()->findByAttributes(array('user_follow' => $user_follow, 'user_followed' => $user_followed));
     if ($check || $check_2 || $check_3 || $user_followed == Yii::app()->session['user_id']) {
         return FALSE;
     }
     $model = new Follow();
     $model->user_follow = $user_follow;
     $model->user_followed = $user_followed;
     $model->created_at = time();
     $model->update_at = time();
     $model->type = $type;
     $user_follow_data = User::model()->findByPk($user_follow);
     $user_followed_data = User::model()->findByPk($user_followed);
     if ($user_follow != Yii::app()->session['user_id']) {
         $arr_noti = array('user_id' => $user_follow, 'content' => "{$user_follow_data->username} vừa theo dõi bạn", 'type' => 'follow', 'recipient_id' => $user_followed_data->id, 'url' => Yii::app()->createAbsoulteUrl('user/profile', array('user_id' => $user_follow_data->id, 'ref' => 'noti')));
         Notifications::model()->add($arr_noti);
     }
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
Пример #2
0
 /**
  * @todo rewrite as proper SQL (or many-to-many once it works)
  */
 function add_follower(User $follower)
 {
     $f = Follow::find_by_user_id_and_follower_id($this->id, $follower->id);
     if (!$f) {
         $f = new Follow();
         $f->user_id = $this->id;
         $f->follower_id = $follower->id;
         $f->save();
     }
     // foreach($this->follows as $f) {
     //     echo $f->follower_id."\n<br>";
     // }
 }
Пример #3
0
 public function Tweet_follower($id_user)
 {
     $follow = new Follow($id_user);
     $id_follower = $follow->id_follower($this->_db, $this->_id_user);
     $affiche = '';
     foreach ($id_follower as $value) {
         $tweet_follower = $this->getUserTweets($this->_db, $value->id_follower);
         foreach ($tweet_follower as $val) {
             $affiche .= $this->display($val);
         }
         //function display()
     }
     return $affiche;
 }
Пример #4
0
 public function register($aid, $name, $gender, $age, $type, $u_name, $u_gender, $u_city, $inviter)
 {
     $user = new User();
     $user->name = $u_name;
     $user->gender = $u_gender;
     $user->city = $u_city;
     $user->code = $this->createInviteCode();
     $user->inviter = $inviter;
     $user->gold = 500;
     $reward_items = array(1101 => 3, 1102 => 3, 1103 => 3, 1104 => 3, 1105 => 3, 1106 => 3, 1107 => 3, 1201 => 2, 1202 => 2, 1203 => 2, 1204 => 2, 1205 => 2, 1206 => 2, 1207 => 2, 1301 => 1, 1302 => 1, 1303 => 1, 1304 => 1, 1305 => 1, 2101 => 3, 2102 => 3, 2103 => 3, 2104 => 3);
     $user->items = serialize($reward_items);
     $user->save();
     if (!isset($aid)) {
         $animal = new Animal();
         $animal->name = $name;
         $animal->gender = $gender;
         $animal->age = $age;
         $animal->type = $type;
         $animal->from = substr($type, 0, 1);
         $animal->master_id = $user->usr_id;
         $animal->save();
         $aid = $animal->aid;
         $circle = new Circle();
         $circle->aid = $aid;
         $circle->usr_id = $user->usr_id;
         $circle->rank = 0;
         $circle->save();
     } else {
         $circle = new Circle();
         $circle->aid = $aid;
         $circle->usr_id = $user->usr_id;
         $circle->save();
     }
     $f = new Follow();
     $f->usr_id = $user->usr_id;
     $f->aid = $aid;
     $f->create_time = time();
     $f->save();
     $user->aid = $aid;
     $user->saveAttributes(array('aid'));
     $user->initialize();
     $user->rewardInviter();
     //$this->onRegister = array($user, 'initialize');
     //$this->onRegister = array($user, 'rewardInviter');
     $this->owner->usr_id = $user->usr_id;
     $this->owner->saveAttributes(array('usr_id'));
     $this->onRegister(new CEvent());
     return $user;
 }
Пример #5
0
 /**
  * @sendmsg
  */
 public function actionSendmsg()
 {
     //查找我关注的【满足条件才能发邮件】
     $uid = Yii::$app->user->getId();
     $follows = Follow::find()->where(['uid' => $uid])->all();
     if (count($follows) <= 0) {
         Yii::$app->session->setFlash('error', '请您先关注朋友后,再来发消息!');
         return $this->redirect(['index/users']);
     }
     $ids = array();
     foreach ($follows as $v) {
         array_push($ids, $v->fid);
     }
     //发送对象
     $uses = YiiUser::findAll($ids);
     $to = array();
     foreach ($uses as $v) {
         $to[$v->id] = $v->nickname;
     }
     $model = new Msg();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->fid = $uid;
         $model->send_time = time();
         if ($model->save()) {
             Yii::$app->session->setFlash('success', '发送成功!');
         } else {
             Yii::$app->session->setFlash('error', '发送失败!');
         }
         //echo "<pre/>";print_r(Yii::$app->request->post());die();
     }
     return $this->render('sendmsg', ['model' => $model, 'to' => $to]);
 }
Пример #6
0
 private function getViewIndexDatas()
 {
     $current_user_id = Session::get('user')['id'];
     $owners_id = Follow::where('follower_id', $current_user_id)->where('is_deleted', 0)->get(['followed_id'])->toArray();
     array_walk($owners_id, function (&$value, $key) {
         $value = $value['followed_id'];
     });
     $owners_id[] = $current_user_id;
     //        $privacy = Privacy::where('name',"Công khai")->get()->first();
     $entries = Entry::whereIn('user_id', $owners_id)->where('privacy', 1)->orWhere('user_id', $current_user_id)->orderBy('updated_at', 'DESC')->paginate($this->entries_per_page);
     $left_albums = Album::whereIn('user_id', $owners_id)->where('privacy', 1)->orWhere('user_id', $current_user_id)->orderBy('updated_at', 'DESC')->get();
     //        $datas = array();
     //
     //        foreach ($entries as $index => $entry) {
     //            if (FEUsersHelper::isCurrentUser($entry->user_id)) {
     //                if($this->getEntry($entry->entry_id, $entry->type, null)){
     //                    $datas[] = $this->getEntry($entry->entry_id, $entry->type, null);
     //                }
     //            } else{
     //                if($this->getEntry($entry->entry_id, $entry->type, $privacy->id)){
     //                    $datas[] = $this->getEntry($entry->entry_id, $entry->type, $privacy->id);
     //                }
     //
     //            }
     //        }
     ////        $datas = $this->pagination($datas, 3, $page);
     $suggests = FEUsersHelper::getSuggestes();
     return array('datas' => $entries, 'suggestes' => $suggests, 'left_albums' => $left_albums);
 }
Пример #7
0
 public function testGetRankingSuccess()
 {
     $user_id = $this->_user_id;
     $_params = $this->_params;
     $_params['user_id'] = $user_id;
     $response = $this->_getAuth($_params);
     //get created login information
     $page = 1;
     $limit = 10;
     $user = Profile::orderBy('rate_count', 'desc')->forPage($page, $limit)->get();
     if (count($user) != 0) {
         foreach ($user as $users) {
             $follow = Follow::where('from_id', $user_id)->where('to_id', $users->user_id)->first();
             if ($follow) {
                 $users->is_follow = true;
             } else {
                 if ($users->user_id != $user_id) {
                     $users->is_follow = false;
                 }
             }
             if ($users->image != null) {
                 $users->image = URL::asset($users->image);
             }
         }
     }
     $this->assertNotNull($user);
     $this->assertEquals(array("code" => ApiResponse::OK, "data" => $user->toArray()), json_decode($response->getContent(), true));
 }
Пример #8
0
 public function create()
 {
     redirect_guest_user(LOGIN_URL);
     $thread = Thread::get(Param::get('thread_id'));
     $page = Param::get('page_next');
     $auth_user = User::getAuthenticated();
     if (!$auth_user) {
         return;
     }
     if ($page == 'create_end') {
         $comment = new Comment();
         $comment->body = trim(Param::get('body'));
         $comment->user_id = $auth_user->id;
         try {
             $comment->create($thread);
             $follow = Follow::getByThreadAndUser($thread->id, $comment->user_id);
             if ($follow) {
                 $thread = Thread::get($thread->id);
                 $last_comment = Comment::getLastInThread($thread);
                 if ($last_comment) {
                     $follow->last_comment = $last_comment->id;
                     $follow->update();
                 }
             }
             redirect(VIEW_THREAD_URL, array('id' => $thread->id));
         } catch (ValidationException $e) {
             $page = 'create';
         }
     } else {
         throw new PageNotFoundException();
     }
     $title = 'Create Comment';
     $this->set(get_defined_vars());
     $this->render($page);
 }
 public function follow()
 {
     //Checks if user is logged in
     if (Auth::check()) {
         //checks if ajax request
         if (Request::ajax()) {
             $post = Input::get('post');
             $user = Auth::user()->id;
             //checks if user is already following post
             $follow = DB::table('follows')->where('user_id', $user)->where('post_id', $post);
             //if row exists
             if ($follow->count() > 0) {
                 //remove row
                 $follow->delete();
             } else {
                 //add new row
                 Follow::create(['user_id' => $user, 'post_id' => $post]);
             }
         } else {
             return "No Ajax Request";
         }
     } else {
         return "Not logged in";
     }
 }
Пример #10
0
 public function actionAllDiggList()
 {
     $feedId = intval(EnvUtil::getRequest("feedid"));
     $result = FeedDigg::model()->fetchUserList($feedId, 5);
     $uids = ConvertUtil::getSubByKey($result, "uid");
     $followStates = Follow::model()->getFollowStateByFids(Ibos::app()->user->uid, $uids);
     $this->renderPartial("alldigglist", array("list" => $result, "followstates" => $followStates, "feedid" => $feedId));
 }
Пример #11
0
 public function update()
 {
     $auth_user = User::getAuthenticated();
     if (!$auth_user) {
         throw new PermissionException();
     }
     send_json(array('hasUpdates' => Follow::getUpdates($auth_user) ? true : false));
 }
Пример #12
0
 public function actionUnFollow()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $fid = StringUtil::filterCleanHtml($_POST["fid"]);
         $res = Follow::model()->unFollow(Ibos::app()->user->uid, intval($fid));
         $this->ajaxReturn(array("isSuccess" => !!$res, "msg" => Follow::model()->getError("unFollow")));
     }
 }
Пример #13
0
 public function create()
 {
     redirect_guest_user(LOGIN_URL);
     $thread = new Thread();
     $comment = new Comment();
     $page = Param::get('page_next', 'create');
     $auth_user = User::getAuthenticated();
     $categories = Category::getAll();
     switch ($page) {
         case 'create':
             break;
         case 'create_end':
             $thread->title = trim_collapse(Param::get('title'));
             $thread->category_id = Param::get('category');
             $thread->user_id = $auth_user->id;
             $comment->user_id = $auth_user->id;
             $comment->body = trim(Param::get('body'));
             $db = DB::conn();
             try {
                 $db->begin();
                 $thread->create($comment);
                 $follow = new Follow();
                 $follow->thread_id = $thread->id;
                 $follow->user_id = $auth_user->id;
                 $follow->last_comment = Comment::getFirstInThread($thread)->id;
                 $follow->create();
                 $db->commit();
                 redirect(VIEW_THREAD_URL, array('id' => $thread->id));
             } catch (ValidationException $e) {
                 $page = 'create';
                 $db->rollback();
             } catch (CategoryException $e) {
                 $thread->validation_errors['category']['exists'] = true;
                 $page = 'create';
                 $db->rollback();
             }
             break;
         default:
             throw new PageNotFoundException("{$page} is not found");
             break;
     }
     $title = 'Create Thread';
     $this->set(get_defined_vars());
     $this->render($page);
 }
Пример #14
0
 /**
  * Get following user list of current user
  * @return array Array of following user_id
  */
 public function getFollowingUsersId()
 {
     $result = array();
     $follows = Follow::where('follower_id', $this->id)->where('is_deleted', 0)->where('followed_id', '!=', $this->id)->get();
     foreach ($follows as $follow) {
         $result[] = $follow->followed_id;
     }
     return $result;
 }
Пример #15
0
 public function run()
 {
     DB::table('follows')->delete();
     $user_id = User::where('email', '*****@*****.**')->first()->user_id;
     $user_1 = User::where('email', '*****@*****.**')->first()->user_id;
     $user_2 = User::where('email', '*****@*****.**')->first()->user_id;
     Follow::create(array('id' => '1', 'from_id' => $user_id, 'to_id' => $user_1));
     Follow::create(array('id' => '2', 'from_id' => $user_id, 'to_id' => $user_2));
 }
 /**
  * Display customer profile
  *
  * @param $profile
  * @return Response
  */
 public function show($profile)
 {
     $p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first();
     $page = Page::where('title', '=', 'faq-customer')->first();
     $follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get();
     $follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get();
     $wall = new \Illuminate\Database\Eloquent\Collection();
     $events = new \Illuminate\Database\Eloquent\Collection();
     $comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get();
     $hidden = unserialize(Cookie::get('hide'));
     //dd( Cookie::get('hide') );
     if (count($follow) > 0) {
         foreach ($follow as $f) {
             $s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get();
             $e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get();
             $wall = $wall->merge($s);
             $events = $events->merge($e);
         }
     }
     if (count($follow_hub) > 0) {
         foreach ($follow_hub as $h) {
             $hub = Hub::where('id', '=', $h->hub)->first();
             if (!is_null($hub)) {
                 $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
                 $artists_list = [];
                 $songs = [];
                 $events = [];
                 foreach ($artists as $a) {
                     $artists_list[] = $a->id;
                 }
                 if (count($artists_list) > 0) {
                     $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
                     $events = ArtistEvent::whereIn('artist', $artists_list)->get();
                 }
                 $news = News::where('hub', '=', $hub->id)->take(3)->get();
                 $wall = $wall->merge($songs);
                 $events = $events->merge($events);
             }
         }
     }
     $purchased = Purchase::where('customer', '=', $p->id)->get();
     foreach ($purchased as $pp) {
         $song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get();
         $download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first();
         $song_purchased[0]->purchased = true;
         if (isset($download)) {
             $song_purchased[0]->link = $download->url;
         }
         $wall = $wall->merge($song_purchased);
     }
     $wall->sortByDesc('created_at');
     if (!isset($news)) {
         $news = null;
     }
     return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]);
 }
 public function destroy($resource)
 {
     $follow = Follow::firstOrNew(array('id' => $resource, 'user_id' => Auth::id()));
     if ($follow->id !== null) {
         $manager = App::make('feed_manager');
         FeedManager::unfollowUser($follow->user_id, $follow->target_id);
         $follow->delete();
     }
     return Redirect::to(Input::get('next'));
 }
 /**
  * Show the activities from a users.
  */
 public function profile($username)
 {
     $user = User::where('username', '=', $username)->firstOrFail();
     $feed = FeedManager::getUserFeed($user->id);
     $enricher = new Enrich();
     $activities = $feed->getActivities(0, 25)['results'];
     $activities = $enricher->enrichActivities($activities);
     $follow = Follow::firstOrNew(array('user_id' => Auth::id(), 'target_id' => $user->id));
     return View::make('profile', array('profile' => $user, 'activities' => $activities, 'follow' => $follow));
 }
Пример #19
0
 public function getHeader($lang = array())
 {
     $onlineStatus = UserUtil::getOnlineStatus($this->getUid());
     $styleMap = array(-1 => "o-pm-offline", 1 => "o-pm-online");
     $data = array("user" => $this->getUser(), "assetUrl" => $this->getAssetUrl("user"), "swfConfig" => AttachUtil::getUploadConfig(), "onlineIcon" => $styleMap[$onlineStatus], "lang" => $lang);
     if ($this->getIsWeiboEnabled()) {
         $data["userData"] = UserData::model()->getUserData($this->getUid());
         !$this->getIsMe() && ($data["states"] = Follow::model()->getFollowState(Ibos::app()->user->uid, $this->getUid()));
     }
     return $this->renderPartial("application.modules.user.views.header", $data, true);
 }
Пример #20
0
 public function testGetTimelineSuccess()
 {
     $this->setUpRating();
     $this->setUpCountry();
     $this->setUpWineNote();
     $this->setUpProfile();
     $_params = $this->_params;
     $_params['user_id'] = "user_id";
     $response = $this->_getAuth($_params);
     $error_code = ApiResponse::OK;
     $user_timeline = array();
     $user_timeline[] = $this->_user_id;
     $user_follow = Follow::where('from_id', $this->_user_id)->orderBy('updated_at', 'asc')->get();
     if (isset($user_follow)) {
         foreach ($user_follow as $user) {
             $user_timeline[] = $user->to_id;
         }
     }
     $pagination = ApiResponse::pagination();
     $page = $pagination['page'];
     $limit = $pagination['limit'];
     $wine = Wine::with('winery')->forPage($page, $limit)->get();
     $ratings = Rating::whereIn('user_id', $user_timeline)->whereNotNull('wine_unique_id')->with('profile')->with('wine')->forPage($page, $limit)->get();
     foreach ($ratings as $rating) {
         $winery = Winery::where('id', $rating->wine->winery_id)->first();
         $rating->winery = $winery;
         $country = Country::where('id', $rating->winery->country_id)->first();
         $rating->winery->country_name = $country->country_name;
         $like = Like::where('user_id', $this->_user_id)->where('rating_id', $rating->id)->first();
         if ($like) {
             $rating->liked = true;
         } else {
             $rating->liked = false;
         }
         $wishlist = Wishlist::where('user_id', $this->_user_id)->where('wine_unique_id', $rating->wine_unique_id)->first();
         if ($wishlist) {
             $rating->wishlist = true;
         } else {
             $rating->wishlist = false;
         }
         if ($rating->wine->image_url != null) {
             $rating->wine->image_url = URL::asset($rating->wine->image_url);
         }
         if ($rating->wine->wine_flag != null) {
             $rating->wine->wine_flag = URL::asset($rating->wine->wine_flag);
         }
         if ($rating->profile->image != null) {
             $rating->profile->image = URL::asset($rating->profile->image);
         }
         $rating->winery = $rating->winery->toArray();
     }
     $data = $ratings;
     $this->assertEquals(array("code" => ApiResponse::OK, "data" => $ratings->toArray()), json_decode($response->getContent(), true));
 }
Пример #21
0
 public function update($id)
 {
     $follow = Follow::find($id);
     if (FEUsersHelper::isCurrentUser($follow->follower->id)) {
         $follow->is_deleted = 1;
         $follow->save();
         echo 'true';
     } else {
         echo 'false';
     }
 }
Пример #22
0
 public function follow($slug)
 {
     $hub = Hub::where('slug', '=', $slug)->first();
     $user = Auth::user();
     if (!is_null($hub)) {
         $f = Follow::where('user', '=', $user->id)->where('hub', '=', $hub->id)->first();
         if (is_null($f)) {
             $f = new Follow();
             $f->hub = $hub->id;
             $f->user = $user->id;
             $f->save();
             return Redirect::to('hubs/' . $hub->slug);
         } else {
             $f->delete();
             return Redirect::to('hubs/' . $hub->slug);
         }
     } else {
         App::abort('404');
     }
 }
Пример #23
0
	/**
	 * @param $model
	 * @return Follow
	 */
	public function processRequest($model)
	{
            Yii::import('application.modules.users.models.User');
            Yii::import('application.modules.catalog.models.Objects');
		$follow = new Follow;
		if((Yii::app()->request->isPostRequest) && (Yii::app()->request->getPost('Follow')))
		{
			$follow->attributes = Yii::app()->request->getPost('Follow');

			if(!Yii::app()->user->isGuest)
			{
				$follow->name = Yii::app()->user->username;
				$follow->email = Yii::app()->user->email;
			}

			if($follow->validate())
			{
				$pkAttr = $model->getObjectPkAttribute();
				$follow->class_name = $model->getClassName();
				$follow->object_pk = $model->$pkAttr;
				$follow->user_id = Yii::app()->user->isGuest ? 0 : Yii::app()->user->id;
				$follow->save();

				$url = Yii::app()->getRequest()->getUrl();

				if($follow->status==Follow::STATUS_WAITING)
				{
					$url.='#';
					Yii::app()->user->setFlash('messages', 'Успешно подписаны');
                                        
                                        
				}
				elseif($follow->status==Follow::STATUS_APPROVED)
					$url.='#follow_'.$follow->id;

				// Refresh page
				Yii::app()->request->redirect($url, true);
			}
		}
		return $follow;
	}
Пример #24
0
	/**
	 * @return string approved follow's count for object
	 */
	public function getFollowCount()
	{
		Yii::import('application.modules.follow.models.Follow');

		$pk = $this->getObjectPkAttribute();
		return Follow::model()
			->approved()
			->countByAttributes(array(
			'class_name'=>$this->getClassName(),
			'object_pk'=>$this->getOwner()->$pk
		));
	}
Пример #25
0
 public static function getSuggestes()
 {
     $user_id = User::find(Session::get('user')['id'])->id;
     $following = Follow::where('follower_id', $user_id)->where('is_deleted', 0)->orderBy('updated_at', 'DESC')->get();
     $suggestes = array();
     foreach ($following as $follow) {
         $suggest_d = Follow::where('follower_id', $follow->followed->id)->where('followed_id', '!=', $user_id)->where('is_deleted', 0)->orderBy('updated_at', 'DESC')->get();
         if ($suggest_d->count() > 0) {
             foreach ($suggest_d as $suggest) {
                 $suggestes[] = $suggest;
             }
         }
     }
     return $suggestes;
 }
Пример #26
0
 public function actionUnfollow()
 {
     $touser = Yii::app()->request->getParam('uid');
     $fuid = Yii::app()->user->id;
     $sql = "select * from {{follow}} where touid={$touser} and uid={$fuid}";
     $model = Follow::model()->findBySql($sql);
     if ($model->delete()) {
         //添加成功时候的提示信息设置
         /**
          *setFlash getFlash hasFlash 几个方法
          */
         Yii::app()->user->setFlash('unfollow', '取消关注成功 -_-!');
     }
     $this->redirect(array('follow/index', 'uid' => $fuid));
 }
Пример #27
0
 public function actionNewmsg()
 {
     $model = new Msg();
     if (isset($_POST['Msg'])) {
         $model->uid = Yii::app()->user->id;
         $model->time = time();
         $model->state = 1;
         $model->attributes = $_POST['Msg'];
         if ($model->save()) {
             $this->redirect_message('私信发送成功!', 'success', '3', $this->createUrl('msg/inbox'));
         }
     }
     $fans = Follow::model()->findAll('touid = ' . Yii::app()->user->id);
     $data = array('model' => $model, 'fans' => $fans);
     $this->render('newmsg', $data);
 }
Пример #28
0
 /**
  * Executes the widgets
  */
 public function run()
 {
     $newUsers = User::model()->active()->recently(10)->findAll();
     // Some member stats
     Yii::import('application.modules.mail.models.*');
     $statsTotalUsers = User::model()->count();
     $criteria = new CDbCriteria();
     $criteria->group = 'user_id';
     $criteria->condition = 'user_id IS NOT null';
     $statsUserOnline = UserHttpSession::model()->count($criteria);
     $statsMessageEntries = 0;
     if (Yii::app()->moduleManager->isEnabled('mail')) {
         $statsMessageEntries = MessageEntry::model()->count();
     }
     $statsUserFollow = Follow::model()->countByAttributes(array('object_model' => 'User'));
     // Render widgets view
     $this->render('memberStats', array('newUsers' => $newUsers, 'statsTotalUsers' => $statsTotalUsers, 'statsUserOnline' => $statsUserOnline, 'statsMessageEntries' => $statsMessageEntries, 'statsUserFollow' => $statsUserFollow));
 }
Пример #29
0
 public function actionUserCard()
 {
     $uid = EnvUtil::getRequest("uid");
     $user = User::model()->fetchByUid($uid);
     $onlineStatus = UserUtil::getOnlineStatus($uid);
     $styleMap = array(-1 => "o-pm-offline", 1 => "o-pm-online");
     if (empty($user)) {
         $this->error(Ibos::lang("Request tainting", "error"));
     } else {
         $weiboExists = ModuleUtil::getIsEnabled("weibo");
         $data = array("user" => $user, "status" => $styleMap[$onlineStatus], "lang" => Ibos::getLangSources(), "weibo" => $weiboExists);
         if ($weiboExists) {
             $data["userData"] = UserData::model()->getUserData($user["uid"]);
             $data["states"] = Follow::model()->getFollowState(Ibos::app()->user->uid, $user["uid"]);
         }
         $content = $this->renderPartial("userCard", $data, true);
         echo $content;
         exit;
     }
 }
Пример #30
0
 /**
  *	插入解锁照片
  *
  */
 public function insertPhoto($user_id, $param)
 {
     try {
         $p = array('user_id' => '', 'heroine_id' => '', 'photo_id' => '', 'unlock_type' => '', 'rating' => '', 'status' => '', 'is_open' => '', 'timestamp' => '', 'type' => '');
         $con_characters = Yii::app()->db_characters;
         $param = array_intersect_key($param, $p);
         $table_name = sprintf('photo_praise_%02s', dechex($user_id % 256));
         $con_characters->createCommand()->insert($table_name, $param);
         if ($param['type'] == 0 || $param['type'] == 1) {
             //查询解锁数目
             $follow = Follow::model()->getFollowRow($user_id, $param['heroine_id']);
             $unlock_counts = $follow['unlock_counts'] + 1;
             //更新解锁照片数量
             Follow::model()->updateFollowRow($user_id, $param['heroine_id'], array('unlock_counts' => $unlock_counts));
             //更新好感值
         }
     } catch (Exception $e) {
         error_log($e);
     }
 }