public function handleRequest() { $arr = array('idplaces' => $_GET['idplaces']); $placedetails = PlaceDetail::find($arr); $followers = Follower::find($arr); $doIFollow = Follower::amIaFollower($arr); render('placedetail', array('title' => 'Browsing place', 'placedetails' => $placedetails, 'followers' => $followers, 'doIFollow' => $doIFollow)); }
/** * get_show takes in a username, finds the user's id from the username, gets the information about the user from the * followers and critts table and outputs it into the others.profile view */ public function action_show($username) { // we get the user's id that matches the username $user_id = User::where('username', '=', $username)->only('id'); // declare some default values for variables $following = null; $followers = 0; // if the username is not found, display an error if ($user_id == null) { echo "This username does not exist."; } else { if (Auth::user()) { // if the user tries to go to his/her own profile, redirect to user's profile action. if ($user_id == Auth::user()->id) { return Redirect::to_action('user@index'); } // check if the current user is already following $username $following = Follower::where('user_id', '=', Auth::user()->id)->where('following_id', '=', $user_id)->get() ? true : false; } // eager load the critts with user data $allcritts = Critt::with('user')->where('user_id', '=', $user_id); // order the critts and split them in chunks of 10 per page $critts = $allcritts->order_by('created_at', 'desc')->paginate(10); // count the critts $critts_count = $allcritts->count(); // count the followers $followers = Follower::where('following_id', '=', $user_id)->count(); // bind data to the view return View::make('others.profile')->with('username', $username)->with('user_id', $user_id)->with('following', $following)->with('followers', $followers)->with('count', $critts_count)->with('critts', $critts); } }
public function vaultUpdate($id) { $user = Auth::user(); $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail(); $club = Club::find($follow->club_id); $validator = Validator::make(Input::all(), Payment::$rules); if ($validator->passes()) { //validation done prior ajax $param = array('customer_vault_id' => $id, 'club' => $club->id, 'ccnumber' => Input::get('card'), 'ccexp' => sprintf('%02s', Input::get('month')) . Input::get('year'), 'cvv' => Input::get('cvv'), 'address1' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip')); $payment = new Payment(); $transaction = $payment->update_customer($param, $user); if ($transaction->response == 3 || $transaction->response == 2) { $data = array('success' => false, 'error' => $transaction); return $data; } else { //update user customer # $user->profile->customer_vault = $transaction->customer_vault_id; $user->profile->save(); //retrived data save from API - See API documentation $data = array('success' => true, 'customer' => $transaction->customer_vault_id, 'card' => substr($param['ccnumber'], -4), 'ccexp' => $param['ccexp'], 'zip' => $param['zip']); return Redirect::action('AccountController@settings')->with('notice', 'Payment information updated successfully'); } } return Redirect::back()->withErrors($validator)->withInput(); return Redirect::action('AccountController@settings'); }
public static function newInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
/** * post_unfollow is called when the "Unfollow" button is pressed on another user's profile, * deleting a relationship in the DB */ public function post_unfollow() { $following_id = Input::get('id'); $follower_id = Auth::user()->id; Follower::where('user_id', '=', $follower_id)->where('following_id', '=', $following_id)->delete(); return Redirect::back(); }
/** * Show the form for creating a new resource. * GET /player/create * * @return Response */ public function create() { $user = Auth::user(); $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail(); $club = Club::find($follow->club_id); $title = 'League Together - Player'; return View::make('app.account.player.create')->with('page_title', $title)->with('club', $club)->withUser($user); }
/** * @transaction * @userCache * * @param int $userId リクエストされたユーザのID * @param int $requestorId リクエストしたユーザのID * * @return Logics_Result */ public function accept($userId, $requestorId) { $result = new Logics_Result(); $aUser = new User($userId); $requestor = new User($requestorId); if ($aUser->isActive() && $requestor->isActive()) { $follower = new Follower(); $follower->save(array("user_id" => $requestor->id, "follow_id" => $aUser->id, "created_at" => now())); $request = new Request(); $request->setCondition("user_id", $requestor->id); $request->setCondition("request_id", $aUser->id); $request->delete(); } else { $result->failure(); } return $result; }
private function checkUnique() { $query = Follower::where('event_id', $this->getEvent())->where('user_id', $this->getUser())->first(); if (!$query) { return $this->setEvent($this->getEvent()); } else { return $this->checkUnique(); } }
/** * @test */ public function isFollowed() { $user1 = $this->getUser("test1"); $user2 = $this->getUser("test2"); $user3 = $this->getUser("test3"); $this->isFalse(Follower::isFollowed($user1->id, $user2->id)); $this->isTrue(Follower::isFollowed($user1->id, $user3->id)); $this->isTrue(Follower::isFollowed($user2->id, $user1->id)); $this->isTrue(Follower::isFollowed($user2->id, $user3->id)); $this->isTrue(Follower::isFollowed($user3->id, $user1->id)); $this->isFalse(Follower::isFollowed($user3->id, $user2->id)); }
public static function createFollower($service, array $rawfollower, PropelPDO $con = null) { $crit = new Criteria(); $crit->add(self::SENDER_ID, $rawfollower['id']); $follower = self::doSelectOne($crit, $con); if (is_null($follower)) { if (!$service->existsFriendship(sfConfig::get('twitter_user_id'), $rawfollower['id'])) { $service->createFriendship($rawfollower['id']); } $follower = new Follower(); $follower->setFollowing(true); $follower->setSenderId($rawfollower['id']); $follower->setSenderName($rawfollower['name']); $follower->setSenderScreenName($rawfollower['screen_name']); $follower->setSenderLocation($rawfollower['location']); $follower->setSenderProfileImg($rawfollower['profile_image_url']); $follower->setSenderProtected($rawfollower['protected']); $follower->save(); } return $follower; }
/** * @transaction * * @param int $userId ユーザID * * @return Logics_Result */ public function destroy($userId) { $result = new Logics_Result(); $aUser = new User($userId); if ($aUser->isSelected()) { $or = new Sabel_Db_Condition_Or(); $or->add(C::create(C::EQUAL, "user_id", $aUser->id)); $or->add(C::create(C::EQUAL, "request_id", $aUser->id)); $request = new Request(); $request->delete($or); $or = new Sabel_Db_Condition_Or(); $or->add(C::create(C::EQUAL, "user_id", $aUser->id)); $or->add(C::create(C::EQUAL, "follow_id", $aUser->id)); $follower = new Follower(); $follower->delete($or); $status = new Status(); $status->delete("user_id", $userId); $aUser->save(array("delete_flag" => true)); } return $result; }
public function getFriendsAndMyStatuses($userId, $params, $limit = null) { if ($limit === null) { $limit = self::DEFAULT_ITEM_LIMIT; } $ids = Follower::getFriendIds($userId); $ids[] = $userId; $join = new Sabel_Db_Join("Status"); $paginator = new Paginator($join->add("Users")); $paginator->setCondition(C::create(C::IN, "Users.uid", $ids)); $paginator->setDefaultOrder("Status.created_at", "desc"); return $paginator->build($limit, $params); }
/** * @test */ public function deny() { $follow = $this->getLogic("follow"); $user1 = $this->getUser("test1"); $user2 = $this->getUser("test2"); $follow->add($user1->id, $user2->id); $this->isTrue(Request::isRequested($user1->id, $user2->id)); $this->isFalse(Follower::isFollowed($user1->id, $user2->id)); $follow->deny($user2->id, $user1->id); $this->isFalse(Request::isRequested($user1->id, $user2->id)); $this->isFalse(Follower::isFollowed($user1->id, $user2->id)); $this->clear("Follower"); $this->clear("Request"); }
/** * Display a listing of the resource. * GET /follower * * @return Response */ public function index() { $user = Auth::user(); $club = $user->Clubs()->FirstOrFail(); $followers = Follower::where('club_id', '=', $club->id)->get(); $players = []; //get player from follower foreach ($followers as $follower) { $fuser = User::find($follower->user_id); if ($fuser->players) { foreach (User::find($follower->user_id)->players as $data) { $data['fullname'] = "{$data->firstname} {$data->lastname}"; $data['username'] = "******"; $data['useremail'] = "{$fuser->email}"; $players[] = $data; } } } $title = 'League Together - ' . $club->name . ' Followers'; return View::make('app.club.follower.index')->with('page_title', $title)->with('club', $club)->with('followers', $followers)->with('players', $players)->withUser($user); }
protected function home() { $protected = $this->aUser->isProtected(); $this->clientId = $this->session->getClientId(); if ($authenticated = $this->aclUser->isAuthenticated()) { $this->isFollowed = Follower::isFollowed($this->aclUser->id, $this->aUser->uid); if ($this->isFollowed) { $protected = false; } } if ($protected) { if ($authenticated) { $this->isRequested = Request::isRequested($this->aclUser->id, $this->aUser->uid); } $this->view->setName("protected"); } else { $helper = new Helpers_Paginator_Status(); $this->paginator = $helper->getStatuses($this->aUser->uid, $this->GET_VARS, 50); $this->view->setName("home"); } }
/** * @test */ public function moveRequestsToFollower() { $user2 = $this->getUser("test2"); $this->isTrue($user2->isProtected()); $user1 = $this->getUser("test1"); $user3 = $this->getUser("test3"); $request = new Request(); $request->insert(array("user_id" => $user1->id, "request_id" => $user2->id, "created_at" => now())); $request->insert(array("user_id" => $user3->id, "request_id" => $user2->id, "created_at" => now())); $this->isTrue(Request::isRequested($user1->id, $user2->id)); $this->isTrue(Request::isRequested($user3->id, $user2->id)); $this->isFalse(Follower::isFollowed($user1->id, $user2->id)); $this->isFalse(Follower::isFollowed($user3->id, $user2->id)); $user2->private_flag = false; $this->getLogic("user")->updateSettings($user2); $this->isFalse($user2->isProtected()); $this->isFalse(Request::isRequested($user1->id, $user2->id)); $this->isFalse(Request::isRequested($user3->id, $user2->id)); $this->isTrue(Follower::isFollowed($user1->id, $user2->id)); $this->isTrue(Follower::isFollowed($user3->id, $user2->id)); $this->clear("Request"); $this->clear("Follower"); }
/** * @check param required nNumber */ public function status() { $this->aStatus = $this->fetchModel("Status", $this->param); if (!$this->aStatus) { return; } $isSelf = false; $this->aUser = $aUser = new User($this->aStatus->user_id); // $this->protected = $aUser->isProtected(); $this->protected = false; if ($this->aclUser->isAuthenticated()) { if ($this->aclUser->id === $aUser->uid) { $isSelf = true; $this->protected = false; } elseif (Follower::isFollowed($this->aclUser->id, $aUser->uid)) { $this->protected = false; } } if ($isSelf) { $this->submenu->setUser($this->aclUser->id); } else { $this->submenu->setUser($aUser->uid, Views_Submenu::TYPE_OTHERS); } }
/** * Checks if the currently logged in user is following the given user. * @param int $id The ID to check * @return boolean */ public static function isFollowing($id = NULL) { if ($id == NULL || Yii::app()->user->isGuest) { return false; } $following = Follower::model()->findByAttributes(array('follower_id' => Yii::app()->user->id, 'followee_id' => $id)); return $following != NULL; }
public function PaymentStore($id) { $user = Auth::user(); $participant = Participant::find($id); $title = 'League Together - ' . $participant->event->club->name . ' Teams'; $player = $participant->player; $club = $participant->event->club; $cart = Cart::contents(true); $uuid = Uuid::generate(); //Addition for stub feature $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail(); //check if follower equal club if ($follow->club_id != $club->id) { $param = array('ccnumber' => str_replace('_', '', Input::get('card')), 'ccexp' => sprintf('%02s', Input::get('month')) . Input::get('year'), 'cvv' => Input::get('cvv'), 'address1' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip'), 'discount' => Input::get('discount'), 'club' => $club->id, 'firstname' => $user->profile->firstname, 'lastname' => $user->profile->lastname, 'phone' => $user->profile->mobile); } else { $param = array('customer_vault_id' => $user->profile->customer_vault, 'discount' => Input::get('discount'), 'club' => $club->id); } $payment = new Payment(); $transaction = $payment->sale($param); if ($transaction->response == 3 || $transaction->response == 2) { return Redirect::action('ParticipantController@paymentCreate', array($participant->id))->with('error', $transaction->responsetext); } else { foreach (Cart::contents() as $item) { $payment->id = $uuid; $payment->customer = $user->profile->customer_vault; $payment->transaction = $transaction->transactionid; $payment->subtotal = $transaction->subtotal; $payment->service_fee = $transaction->fee; $payment->total = $transaction->total; $payment->promo = $transaction->promo; $payment->tax = $transaction->tax; $payment->discount = $transaction->discount; $payment->club_id = $club->id; $payment->user_id = $user->id; $payment->player_id = $item->player_id; $payment->event_type = $participant->event->type_id; $payment->type = $transaction->type; $payment->save(); $salesfee = $item->price / getenv("SV_FEE") - $item->price; $sale = new Item(); $sale->description = $item->name; $sale->quantity = $item->quantity; $sale->price = $item->price; $sale->fee = $salesfee; $sale->participant_id = $participant->id; $sale->payment_id = $uuid; $sale->event_id = $participant->event->id; $sale->save(); $participant->accepted_on = Carbon::Now(); $participant->accepted_by = $user->profile->firstname . ' ' . $user->profile->lastname; $participant->accepted_user = $user->id; $participant->method = $item->type; $participant->status = 1; $participant->save(); //create payments plan schedule if ($item->type == "plan") { $subtotal = $participant->plan->getOriginal('recurring'); $fee = $subtotal / getenv("SV_FEE") - $subtotal; $total = $fee + $subtotal; for ($x = 1; $x < $participant->plan->recurrences + 1; $x++) { $today = Carbon::now(); $today->addMonths($x); $payon = $participant->plan->getOriginal('on'); //make sure the payday is a valid day if ($payon == 31) { if ($today->month == 2) { $payon = 28; } if ($today->month == 4 || $today->month == 6 || $today->month == 9 || $today->month == 11) { $payon = 30; } } $payday = Carbon::create($today->year, $today->month, $payon, 0); $schedule = new SchedulePayment(); $schedule->date = $payday; $schedule->description = "Membership Team " . $participant->event->name; $schedule->subtotal = number_format($subtotal, 2); $schedule->fee = number_format($fee, 2); $schedule->total = number_format($total, 2); $schedule->plan_id = $participant->plan->id; $schedule->club_id = $club->id; $schedule->participant_id = $participant->id; $status = $schedule->save(); if (!$status) { return "We process your payment but and error occurred in the process, please contact us: support@leaguetogether.com Error# 597"; } } //end for loop } //end if plan } //email receipt $payment->receipt($transaction, $club->id, $item->player_id); $data = array('club' => $club, 'player' => $player, 'user' => $user, 'participant' => $participant); $mail = Mail::send('emails.notification.event.accept', $data, function ($message) use($user, $club, $participant) { $message->from('*****@*****.**', 'C2C Lacrosse')->to($user->email, $participant->accepted_by)->subject("Thank you for joining our event | " . $club->name); foreach ($club->users()->get() as $value) { $message->bcc($value->email, $club->name); } }); return Redirect::action('ParticipantController@paymentSuccess', array($participant->id))->with('result', $transaction); } }
/** * Show the form for editing the specified resource. * GET /contact/{id}/edit * * @param int $id * @return Response */ public function edit($id) { $user = Auth::user(); $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail(); $club = Club::find($follow->club_id); $players = $user->players; $contact = Contact::find($id); $title = 'League Together - Player'; return View::make('app.account.contact.edit')->with('page_title', $title)->with('players', $players->lists('firstname', 'id'))->with('club', $club)->with('contact', $contact)->withUser($user); }
<?php require dirname(__FILE__) . '/../../model/Follower.php'; $Model = new Follower(); if ($resultRef = $Model->findAll()) { $result = $resultRef->fetch_all(); var_dump($result); } else { echo "No Result"; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Follower::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
protected function _getUserData($userId) { return array("friends" => Follower::getFriendsCount($userId), "followers" => Follower::getFollowersCount($userId), "statuses" => Status::getCountByUserId($userId), "comment" => Status::getLatestCommentByUserId($userId)); }
session_start(); if ($user->isLoggedIn()) { $loggedIn = 1; } if ($loggedIn) { $isFollowing = $follower->isFollowing($uid); $fol_count = $follower->getCount(); } if (!$userDetails->num_rows == 0) { $app->render('author.php', array('loggedIn' => $loggedIn, 'fol_count' => $fol_count, 'postDetails' => $postDetails, 'userDetails' => $userDetails, 'empty' => $empty, 'isFollowing' => $isFollowing, 'follower' => $follower)); } }); //Handle follow request $app->post('/follow/:id', function ($f_id) use($app) { require_once 'core/followers.inc.php'; $follower = new Follower(); session_start(); //add logged in user as a follower of the author : f_id if ($follower->followMe($f_id, $_SESSION['user_id'])) { } else { echo "Error"; die("Inserttion failed"); } //finally redirect the user to the same $app->redirect('/Blog-It/author/' . $f_id); }); $app->get('/post/:id', function ($pid) use($app) { require_once 'core/user.inc.php'; require_once 'core/post.inc.php'; require_once 'core/comment.inc.php'; require_once 'core/tag.inc.php';
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <?php require_once dirname(__FILE__) . "/../../vendor/php-sdk/src/facebook.php"; require_once dirname(__FILE__) . "/../../model/Follower.php"; $Follower = new Follower(); $appId = '346346428729240'; $secret = 'ea5fd9a005c0becd9e5277864bdf5417'; $config = array(); $config['appId'] = $appId; $config['secret'] = $secret; $facebook = new Facebook($config); $loginParams = array('scope' => 'user_birthday'); $statusParam = array('ok_session' => 'Now Login', 'no_user' => 'No User', 'no_session' => 'No Session'); if ($facebook->getUser()) { $fql = 'SELECT uid,name,pic,sex FROM user WHERE uid IN(SELECT uid2 FROM friend where uid1 = me())'; $followers = $facebook->api(array('method' => 'fql.query', 'query' => $fql)); foreach ($followers as $follower) { $data = array(); $data['facebook_id'] = $follower['uid']; $data['name'] = $follower['name']; $data['pic'] = $follower['pic']; $data['power'] = rand(1, 100); $data['money'] = rand(1, 100); $data['job_name'] = Job::getJob(); $uid = $follower['uid']; $result = $Follower->findBy(array('facebook_id' => $uid)); if ($result->num_rows == 0) {
<?php require dirname(__FILE__) . '/../../model/Follower.php'; $Model = new Follower(); $insertData = array(); echo $Model->deleteAll() . "\n<br />"; var_dump($insertData);
<?php require_once dirname(__FILE__) . '/../facebook.php'; require_once dirname(__FILE__) . "/../model/President.php"; require_once dirname(__FILE__) . "/../model/Follower.php"; require_once dirname(__FILE__) . "/../model/Party.php"; require_once dirname(__FILE__) . "/../model/Princess.php"; require_once dirname(__FILE__) . '/../calc_used_money.php'; // 下準備なう $President = new President(); $Follower = new Follower(); $Party = new Party(); $Princess = new Princess(); // facebook_idの取得 $facebook_id = $facebook->getUser(); // President情報の取得 $presidents = $President->findBy(array('facebook_id' => $facebook_id)); if ($presidents->num_rows == 0) { echo 'president取得の失敗なう'; die; } $president = $presidents->fetch_assoc(); // Presidentに紐付くParty情報の取得 $party = array(); $result = $Party->findBy(array('president_id' => $facebook_id)); while ($row = $result->fetch_assoc()) { array_push($party, $row); } // Presidentに紐付くPartyに紐付くFollowers情報の取得 $followers = array(); foreach ($party as $party_member) {
public function actionFollowing($id = null) { if ($id == null) { if (Yii::app()->user->isGuest) { $this->redirect($this->createUrl('site/login')); } $id = Yii::app()->user->id; } $myFollowing = array(); $following = Follower::model()->findAllByAttributes(array('follower_id' => $id)); if ($following != null) { foreach ($following as $followee) { $myFollowing[] = $followee->followee_id; } } $criteria = new CDbCriteria(); $criteria->addInCondition('id', $myFollowing); $following = User::model()->findAll($criteria); $this->render('following', array('users' => $following)); }
/** * Declares an association between this object and a Follower object. * * @param Follower $v * @return RawMessage The current object (for fluent API support) * @throws PropelException */ public function setFollower(Follower $v = null) { if ($v === null) { $this->setFollowerId(NULL); } else { $this->setFollowerId($v->getId()); } $this->aFollower = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Follower object, it will not be re-added. if ($v !== null) { $v->addRawMessage($this); } return $this; }
public static function mobile_get_favourites(\ApiParam $params) { $user = new \User(); $user->load($params->userId); $follower = \Follower::create($user); if ($follower) { $favs = $follower->favovites(); $originFavs = $favs; if ($favs && is_array($favs)) { $query = '('; foreach ($favs as $fav) { if ($fav->identity) { if ($query != '(') { $query .= ' OR '; } $query .= 'id:' . $fav->identity; } } if ($query != '(') { $query .= ')'; $ary = $params->getArrayCopy(); $ary['query'] = $query; $newParams = \Api::paramFactory($ary); $response = self::mobile_ad_list($newParams); $existingAds = $response['data']; if ($existingAds) { foreach ($existingAds as $ad) { foreach ($favs as $key => $fav) { if ($ad['id'] == $fav->identity) { unset($favs[$key]); break; } } } } if (sizeof($favs) > 0) { foreach ($favs as $fav) { array_push($existingAds, array('id' => $fav->identity, 'title' => $fav->attris['title'], 'status' => '3')); ++$response['num']; } } $adsMap = array(); foreach ($existingAds as $ad) { $adsMap[$ad['id']] = $ad; } // var_dump('ads map'); // var_dump($adsMap); $sortAds = array(); foreach ($originFavs as $fav) { array_push($sortAds, $adsMap[$fav->identity]); } // var_dump('sorted ads'); // var_dump($sortAds); $response['data'] = $sortAds; return $response; } } else { return self::composeResponse(0, '没有已收藏信息', array('count' => 0, 'data' => array(), 'num' => 0)); } } return self::composeResponse(1, 'fail'); }