Пример #1
0
 public function getLocationLink()
 {
     $checkIn = CheckIn::getMostRecent($this);
     if ($checkIn) {
         $lat = $checkIn->getLat();
         $long = $checkIn->getLong();
         $time = $checkIn->getTime();
         $url = "http://maps.google.com/maps?q={$lat},+{$long}";
         return "<br /><a href=\"{$url}\">Most Recent Check-In: {$lat}, {$long} (at {$time})</a>";
     } else {
         return '';
     }
 }
Пример #2
0
 public static function inRange(CheckIn $checkIn, City $city, $direction, $distance)
 {
     switch ($direction) {
         case DIRECTION_NORTH:
             $lat = self::modifyLatitude($city->getLat(), $distance);
             return $checkIn->getLat() >= $lat;
         case DIRECTION_SOUTH:
             $lat = self::modifyLatitude($city->getLat(), -$distance);
             return $checkIn->getLat() <= $lat;
         case DIRECTION_WEST:
             $long = self::modifyLongitude($city->getLat(), $city->getLong(), -$distance);
             return $checkIn->getLong() <= $long;
         case DIRECTION_EAST:
             $long = self::modifyLongitude($city->getLat(), $city->getLong(), $distance);
             return $checkIn->getLong() >= $long;
         case DIRECTION_NEAR:
             $actualDistance = self::distMiles($checkIn->getLat(), $checkIn->getLong(), $city->getLat(), $city->getLong());
             return $actualDistance <= $distance;
     }
 }
Пример #3
0
 public static function doCheckIn(Team $team, $latitude, $longitude, $guess = null)
 {
     $data = array('team' => $team->getID(), 'latitude' => $latitude, 'longitude' => $longitude, 'guess' => $guess);
     $checkIn = new CheckIn($data);
     $checkIn->doAdd();
 }
Пример #4
0
        $clue->doUpdate('Edited clue successfully.');
        break;
    case 'delete':
        $clue = Clue::getClue($clue_id);
        foreach ($clue->getClueStates() as $clueState) {
            $clueState->doRemove();
        }
        $clue->doRemove('Deleted clue successfully.');
        break;
    case 'answer':
        $team = Session::currentTeam();
        if ($team) {
            if ($latitude && $longitude) {
                $clue = Clue::getClue($clue_id);
                if ($clue) {
                    CheckIn::doCheckIn($team, $latitude, $longitude, $guess);
                    $team->doGuessAnswer($clue, $guess);
                }
            } else {
                add_notification('You must have location turned on to submit clue answers.');
            }
        } else {
            add_notification('You must have a team to submit clue answers.');
        }
}
// VIEW
$page = new UIPage();
$position = Session::defaultPosition();
function answerForm($clueID, $clueSalt, $hashedAnswers, $serialized)
{
    return <<<EOT
Пример #5
0
date_default_timezone_set('Europe/Berlin');
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$latestCheckIn = CheckIn::getLatestCheckinByUserId(SpoonSession::get('id'));
$daysAgo = (SpoonDate::getDate("m.d.j") - SpoonDate::getDate("m.d.j", strtotime($latestCheckIn->timestamp))) * 100;
$timeAgo = SpoonDate::getDate("H:i:s") - SpoonDate::getDate("H:i:s", strtotime($latestCheckIn->timestamp));
//If the checkin is within 5 hours
//if($timeAgo > -6){
$tpl->assign('oCheckIn', true);
if (SpoonFilter::getGetValue('event', null, '') === 'plus') {
    $latestCheckIn->AddTab(SpoonFilter::getGetValue('drinkid', null, ''));
    SpoonHTTP::redirect('checkin.php');
} else {
    if (SpoonFilter::getGetValue('event', null, '') === 'min') {
        $latestCheckIn->DeleteTab(SpoonFilter::getGetValue('drinkid', null, ''));
        SpoonHTTP::redirect('checkin.php');
    }
}
$tpl->assign('pub_id', $latestCheckIn->pub->pub_id);
Пример #6
0
    SpoonHTTP::redirect('index.php');
}
$recent = CheckIn::getCheckinsByPubId($pub->pub_id);
for ($i = 0; $i < sizeof($recent); $i++) {
    $recent[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recent[$i]['timestamp']));
    //check if the user has a fb account authenticated
    if (!$recent[$i]['fb_uid']) {
        //else, use standard fb icon
        $recent[$i]['fb_uid'] = 1;
    }
}
if ($recent !== null) {
    $tpl->assign('oRecent', true);
    $tpl->assign('iRecent', $recent);
} else {
    $tpl->assign('oNoRecent', true);
}
if (CheckIn::getTopCheckinsByPubId($pub->pub_id) !== null) {
    $tpl->assign('oTopCheckins', true);
    $tpl->assign('iTopCheckins', CheckIn::getTopCheckinsByPubId($pub->pub_id));
} else {
    $tpl->assign('oNoTopCheckins', true);
}
$tpl->assign('name', $pub->name);
$tpl->assign('longitude', $pub->longitude);
$tpl->assign('latitude', $pub->latitude);
$tpl->assign('people', $pub->getNumberPeople());
$tpl->assign('checkins', $pub->getNumberCheckins());
// show the output
$tpl->assign('content', $tpl->getContent('templates/pubDetail.tpl'));
$tpl->display('templates/layout.tpl');
Пример #7
0
<?php

/**
 * @author Matt Bush
 * (c) 2011 Stanford CS198 program. All rights reserved.
 */
ini_set('include_path', ini_get('include_path') . ':../php/data:../php/ui/:../php/misc');
require_once 'Session.php';
require_once 'Person.php';
require_once 'Date.php';
require_once 'CheckIn.php';
if (Session::currentPerson() && Session::currentPerson()->getTeam() && key_exists('latitude', $_POST) && key_exists('longitude', $_POST)) {
    $team = Session::currentPerson()->getTeam();
    $momentsAgo = id(new Date())->augment(-30)->toMySQLDate();
    $recentCheckIns = CheckIn::getCheckIns($team, $momentsAgo);
    // recent check-ins, so break the cycle
    if (count($recentCheckIns) > 0) {
        echo 0;
    } else {
        CheckIn::doCheckIn($team, $_POST['latitude'], $_POST['longitude']);
        // TODO: check to see if there is anything new, and if so, send back refresh code
        $refresh = $team->shouldRefreshClueStates();
        $changes = $refresh ? 1 : 0;
        echo $changes;
    }
} else {
    echo -1;
}
Пример #8
0
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
$tpl->assign('formaction', $_SERVER['PHP_SELF']);
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$pub = new Pub(SpoonFilter::getGetValue('id', null, ''));
//User clicks on Check in button
if (SpoonFilter::getPostValue('btnCheckIn', null, '') !== "") {
    $check = new CheckIn('');
    $check->pub = new Pub(SpoonFilter::getPostValue('pub_id', null, ''));
    $check->user = new User(SpoonSession::get('id'));
    $id = $check->Add();
    $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
    $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', SpoonSession::get('id'));
    /*post to facebook*/
    if ($user['fb_publish_stream']) {
        require_once 'facebook/facebook.php';
        // Create our Application instance (replace this with your appId and secret).
        $facebook = new Facebook(array('appId' => '118234134911012', 'secret' => 'a83b1fbf766dcf41a8238a13f53690bd', 'cookie' => true));
        $uid = SpoonSession::get('id');
        $db = new SpoonDatabase('mysql', 'localhost', 'xqdchsmn_public', 'pRAcHU8Ajath7qa3', 'xqdchsmn_public');
        $user = $db->getRecord('SELECT * FROM users WHERE user_id = ?', $uid);
        $fb_uid = $user['fb_uid'];
        $messageContent = 'I\'m at ' . $check->pub->name . ' - http://publicapp.tk/pubs/' . $check->pub->pub_id . '';
Пример #9
0
 public function qualifies(Team $team, $time, $city, $direction, $distance, $defaultIfNull)
 {
     if ($time != null) {
         if (current_mysql_time() >= $time) {
             return true;
         }
     }
     if ($direction != null && $distance != null && $city != null) {
         $checkIn = CheckIn::getMostRecent($team);
         if ($checkIn != null && Direction::inRange($checkIn, $city, $direction, $distance)) {
             return true;
         }
     }
     if ($time == null && ($direction == null || $distance == null || $city == null)) {
         return $defaultIfNull;
     }
     return false;
 }
Пример #10
0
 /**
  * Remove the specified resource from storage.
  * DELETE /patients/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function checkIn($patient_id, $doctor_id, $schedule)
 {
     $checkin = new CheckIn();
     $checkin->patient_id = $patient_id;
     $checkin->doctor_id = $doctor_id;
     $checkin->schedule = $schedule;
     if ($checkin->save()) {
         $patient = DB::table('patients')->where('id', $patient_id)->first();
         $patientAsUser = DB::table('users')->where('id', $patient->report)->first();
         DB::table('appointments')->where('patients_id', '=', $patient_id)->where('doctors_id', '=', $doctor_id)->delete();
         $content = 'Your appointment request is accepted. You have to come for visit at ' . $schedule;
         $user = array('email' => $patientAsUser->email, 'name' => $patient->name, 'detail' => $content);
         // use Mail::send function to send email passing the data and using the $user variable in the closure
         Mail::send([], [], function ($message) use($user) {
             $message->to($user['email'], $user['name'])->subject('Appointment')->setBody($user['detail']);
         });
         return Redirect::back()->with('success', 'The patient is checked in for visit');
     }
 }