Ejemplo n.º 1
0
 public static function getUserRidesWithAll()
 {
     $rideArray = UserRidesPeer::getUserRides();
     $shelfItem = new UserRides();
     $shelfItem->setDescription("(All Rides)");
     array_push($rideArray, $shelfItem);
     return $rideArray;
 }
Ejemplo n.º 2
0
                </td>
                <td>
                    <div class="form-row">
                        <label for="title">To Date:</label>
                        <?php 
echo input_date_tag('to_date', 'now', 'rich=true');
?>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="form-row">
                        <label for="title">Route:</label>
                        <?php 
echo select_tag('user_ride_id', objects_for_select(UserRidesPeer::getUserRidesWithAll(), 'getUserRideId', 'getDescription', $route), array('style' => 'width:150px'));
?>
                    </div>
                </td>
                <td>
                    <div class="form-row">
                        <label for="units">Chart Type:</label>
                        <?php 
echo radiobutton_tag('chart[]', 'Bar', false);
?>
                        <label for="units">Bar</label>
                        <?php 
echo radiobutton_tag('chart[]', 'Line', true);
?>
                        <label for="units">Line</label>
                        <?php 
Ejemplo n.º 3
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Rides is new, it will return
  * an empty collection; or if this Rides has previously
  * been saved, it will retrieve related UserRidess from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Rides.
  */
 public function getUserRidessJoinUsers($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(RidesPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collUserRidess === null) {
         if ($this->isNew()) {
             $this->collUserRidess = array();
         } else {
             $criteria->add(UserRidesPeer::RIDE_ID, $this->ride_key);
             $this->collUserRidess = UserRidesPeer::doSelectJoinUsers($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(UserRidesPeer::RIDE_ID, $this->ride_key);
         if (!isset($this->lastUserRidesCriteria) || !$this->lastUserRidesCriteria->equals($criteria)) {
             $this->collUserRidess = UserRidesPeer::doSelectJoinUsers($criteria, $con, $join_behavior);
         }
     }
     $this->lastUserRidesCriteria = $criteria;
     return $this->collUserRidess;
 }
Ejemplo n.º 4
0
 /**
  * Get the associated UserRides object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     UserRides The associated UserRides object.
  * @throws     PropelException
  */
 public function getUserRides(PropelPDO $con = null)
 {
     if ($this->aUserRides === null && $this->user_ride_id !== null) {
         $c = new Criteria(UserRidesPeer::DATABASE_NAME);
         $c->add(UserRidesPeer::USER_RIDE_ID, $this->user_ride_id);
         $this->aUserRides = UserRidesPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aUserRides->addUserRideMaps($this);
         		 */
     }
     return $this->aUserRides;
 }
Ejemplo n.º 5
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = UserRidesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setUserRideId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setRideId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setUserId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDescription($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setMileage($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setAltitudeGain($arr[$keys[5]]);
     }
 }
Ejemplo n.º 6
0
 /**
  * Selects a collection of UserRideMap objects pre-filled with all related objects.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of UserRideMap objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BaseUserRideMapPeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BaseUserRideMapPeer', $c, $con);
     }
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     UserRideMapPeer::addSelectColumns($c);
     $startcol2 = UserRideMapPeer::NUM_COLUMNS - UserRideMapPeer::NUM_LAZY_LOAD_COLUMNS;
     UserRidesPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (UserRidesPeer::NUM_COLUMNS - UserRidesPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(UserRideMapPeer::USER_RIDE_ID), array(UserRidesPeer::USER_RIDE_ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = UserRideMapPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = UserRideMapPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = UserRideMapPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             UserRideMapPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined UserRides rows
         $key2 = UserRidesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserRidesPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = UserRidesPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserRidesPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (UserRideMap) to the collection in $obj2 (UserRides)
             $obj2->addUserRideMap($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Ejemplo n.º 7
0
 public function executeAdd()
 {
     $this->userStat = new UserStats();
     $this->bikes = null;
     $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         if ($userId) {
             $rideId = $this->getRequestParameter('user_ride_id');
             $ride = UserRidesPeer::retrieveByPK($rideId);
             $this->userStat->setRideDate(join("/", $this->getRequestParameter('ride_date')));
             $this->userStat->setBikeId($this->getRequestParameter('user_bike_id'));
             $this->userStat->setRideKey($rideId);
             $this->userStat->setRideTime($this->getRequestParameter('ride_time'));
             $this->userStat->setAvgSpeed($this->getRequestParameter('avg_speed'));
             $this->userStat->setCaloriesBurned($this->getRequestParameter('cal_burned'));
             $this->userStat->setUserId($userId);
             $this->userStat->setMileage($ride->getMileage());
             $this->userStat->save();
             //now need to add the user equipment for the ride
             $c = new Criteria();
             $c->add(UserEquipementPeer::BIKE_ID, $this->userStat->getBikeId());
             $c->add(UserEquipementPeer::USER_ID, $this->userStat->getUserId());
             $equip = UserEquipementPeer::doSelect($c);
             foreach ($equip as $userEquip) {
                 $userStatEquip = new UserStatEquip();
                 $userStatEquip->setUserStatId($this->userStat->getStatNo());
                 $userStatEquip->setUserEquipId($userEquip->getEquipmentId());
                 $userStatEquip->save();
             }
             return $this->redirect('userstats/index');
         }
     }
     return sfView::SUCCESS;
 }
Ejemplo n.º 8
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(UserRidesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(UserRidesPeer::DATABASE_NAME);
         $criteria->add(UserRidesPeer::USER_RIDE_ID, $pks, Criteria::IN);
         $objs = UserRidesPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 9
0
 public function executeMap()
 {
     $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
     $this->mileagePref = sfContext::getInstance()->getUser()->getAttribute('mileage', null, 'subscriber');
     $mapMileage = $this->getRequestParameter('mapMileage');
     $this->totalMileage = 0;
     $this->elevationChart = null;
     //
     //get profile to get mileage preference
     $this->lat = 37.4419;
     $this->long = -122.1419;
     $profile = UserProfilePeer::retrieveByPK($userId);
     if ($profile) {
         $cpCity = $profile->getLatLong();
         if ($cpCity) {
             $this->lat = $cpCity->getLatitude();
             $this->long = $cpCity->getLongitude();
         }
     }
     $this->rideId = $this->getRequestParameter('rideId');
     sfContext::getInstance()->getLogger()->info('@@@@@@@@@@@@@@@rideId ' . $this->rideId);
     $this->coords = null;
     $ride = UserRidesPeer::retrieveByPK($this->rideId);
     $mapPoints = null;
     $this->rideName = "";
     if ($ride) {
         $this->rideName = $ride->getDescription();
         //see if there are any coords
         $c = new Criteria();
         $c->add(UserRideMapPeer::USER_RIDE_ID, $this->rideId);
         $mapPoints = UserRideMapPeer::doSelect($c);
         $this->coords = UserRideMap::createMapString($mapPoints);
     }
     if ($this->getRequest()->getMethod() == sfRequest::POST && $ride) {
         //need to see if we have existing route, if so then we will just delete and recreate
         if ($mapPoints) {
             foreach ($mapPoints as $mp) {
                 $mp->delete();
             }
         }
         $coordinates = $this->getRequestParameter('coords');
         sfContext::getInstance()->getLogger()->info('@@@@@@@@@@@@@@@coords ' . $coordinates);
         if ($coordinates) {
             $coordArray = explode('*', $coordinates);
             $count = 0;
             $mapPoints = array();
             foreach ($coordArray as $c) {
                 $latLng = explode(',', $c);
                 if ($latLng && count($latLng) == 2) {
                     $map = new UserRideMap();
                     $map->setUserRideId($this->rideId);
                     $map->setCoordOrder($count++);
                     $map->setLat($latLng[0]);
                     $map->setLong($latLng[1]);
                     //	$map->setElevation($this->lookupElevation($latLng[0], $latLng[1]));
                     sfContext::getInstance()->getLogger()->info('lat' . $latLng[0]);
                     sfContext::getInstance()->getLogger()->info('lng' . $latLng[1]);
                     $map->save();
                     array_push($mapPoints, $map);
                 }
             }
         }
         $this->coords = UserRideMap::createMapString($mapPoints);
         //need to save new mileage if overriden
         if ($mapMileage && $mapMileage == 1) {
             $meterMile = $this->getRequestParameter('totalMileage');
             if ($meterMile) {
                 sfContext::getInstance()->getLogger()->info('Overriding Map Mileage with' . $mapMileage);
                 $ride->setMileage($meterMile);
                 $ride->save();
             }
         }
     }
 }