/** * Handle request */ private function handleRequest() { if (strlen(Request::param('public')) > 0) { $Updater = new Activity\Updater(DB::getInstance()); $Updater->setAccountID(SessionAccountHandler::getId()); $Updater->update(new Activity\Object(array('id' => $this->TrainingID, Activity\Object::IS_PUBLIC => Request::param('public') == 'true' ? 1 : 0)), array(Activity\Object::IS_PUBLIC)); } }
/** * Handle request */ protected function handleRequest() { if (Request::param('use-calculated-value') == 'true') { $oldObject = clone $this->Context->activity(); $this->Context->activity()->set(Model\Activity\Object::ELEVATION, $this->Context->route()->elevation()); $Updater = new Model\Activity\Updater(DB::getInstance(), $this->Context->activity(), $oldObject); $Updater->setAccountID(SessionAccountHandler::getId()); $Updater->update(); } }
/** * @param \Runalyze\Model\Activity\Object $new * @param \Runalyze\Model\Activity\Object $old [optional] * @param \Runalyze\Model\Trackdata\Object $track [optional] * @param \Runalyze\Model\Route\Object $route [optional] * @return \Runalyze\Model\Activity\Object */ protected function update(Object $new, Object $old = null, Model\Trackdata\Object $track = null, Model\Route\Object $route = null, $force = false) { $Updater = new Updater($this->PDO, $new, $old); $Updater->setAccountID(0); if (NULL !== $track) { $Updater->setTrackdata($track); } if (NULL !== $route) { $Updater->setRoute($route); } $Updater->forceRecalculations($force); $Updater->update(); return $this->fetch($new->id()); }
/** * File for displaying a training. * Call: call.Training.display.php?id= */ require '../inc/class.Frontend.php'; use Runalyze\Model\Activity; use Runalyze\View\Activity\Context; $Frontend = new Frontend(); $Context = new Context(Request::sendId(), SessionAccountHandler::getId()); switch (Request::param('action')) { case 'changePrivacy': $oldActivity = clone $Context->activity(); $Context->activity()->set(Activity\Entity::IS_PUBLIC, !$Context->activity()->isPublic()); $Updater = new Activity\Updater(DB::getInstance(), $Context->activity(), $oldActivity); $Updater->setAccountID(SessionAccountHandler::getId()); $Updater->update(); break; case 'delete': $Factory = Runalyze\Context::Factory(); $Deleter = new Activity\Deleter(DB::getInstance(), $Context->activity()); $Deleter->setAccountID(SessionAccountHandler::getId()); $Deleter->setEquipmentIDs($Factory->equipmentForActivity(Request::sendId(), true)); $Deleter->delete(); echo '<div class="panel-content"><p id="submit-info" class="error">' . __('The activity has been removed') . '</p></div>'; echo '<script>Runalyze.Statistics.resetUrl();Runalyze.reloadContent();</script>'; exit; break; } if (!Request::param('silent')) { $View = new TrainingView($Context);
/** * Save changes */ public function saveChanges() { $this->saveChangesForTrackdata(); $this->saveChangesForRoute(); $Updater = new Updater($this->PDO, $this->Activity, $this->OldActivity); $Updater->setAccountID($this->AccountID); $Updater->forceRecalculations(); if (null !== $this->Trackdata) { $Updater->setTrackdata($this->Trackdata); } if (null !== $this->Route) { $Updater->setRoute($this->Route); } $Updater->update(); }
use Runalyze\View\Activity\Linker; use Runalyze\Data\Elevation\Correction\NoValidStrategyException; $Frontend = new Frontend(); $Factory = Context::Factory(); $Activity = $Factory->activity(Request::sendId()); $ActivityOld = clone $Activity; $Route = $Factory->route($Activity->get(Activity\Object::ROUTEID)); $RouteOld = clone $Route; try { $Calculator = new Calculator($Route); $result = $Calculator->tryToCorrectElevation(Request::param('strategy')); } catch (NoValidStrategyException $Exception) { $result = false; } if ($result) { $Calculator->calculateElevation(); $Activity->set(Activity\Object::ELEVATION, $Route->elevation()); $UpdaterRoute = new Route\Updater(DB::getInstance(), $Route, $RouteOld); $UpdaterRoute->setAccountID(SessionAccountHandler::getId()); $UpdaterRoute->update(); $UpdaterActivity = new Activity\Updater(DB::getInstance(), $Activity, $ActivityOld); $UpdaterActivity->setAccountID(SessionAccountHandler::getId()); $UpdaterActivity->update(); echo __('Elevation data has been corrected.'); Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER_AND_TRAINING); echo Ajax::getReloadCommand(); echo Ajax::wrapJS('if($("#ajax").is(":visible") && $("#training").length)Runalyze.Overlay.load(\'' . Linker::EDITOR_URL . '?id=' . Request::sendId() . '\')'); echo Ajax::wrapJS('if($("#ajax").is(":visible") && $("#gps-results").length)Runalyze.Overlay.load(\'' . Linker::ELEVATION_INFO_URL . '?id=' . Request::sendId() . '\')'); } else { echo __('Elevation data could not be retrieved.'); }
public function testEquipment() { $this->PDO->exec('UPDATE `runalyze_equipment` SET `distance`=0, `time`=0 WHERE `id`=' . $this->EquipmentA); $this->PDO->exec('UPDATE `runalyze_equipment` SET `distance`=0, `time`=0 WHERE `id`=' . $this->EquipmentB); $OldObject = new Object(array(Object::DISTANCE => 12.34, Object::TIME_IN_SECONDS => 3600, Object::SPORTID => $this->OutdoorID)); $Inserter = new Inserter($this->PDO); $Inserter->setAccountID(0); $Inserter->setEquipmentIDs(array($this->EquipmentA)); $Inserter->insert($OldObject); $this->assertEquals(array(12.34, 3600), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM)); $this->assertEquals(array(0.0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM)); $NewObject = clone $OldObject; $Updater = new Updater($this->PDO, $NewObject, $OldObject); $Updater->setAccountID(0); $Updater->setEquipmentIDs(array($this->EquipmentB), array($this->EquipmentA)); $Updater->update(); $this->assertEquals(array(0.0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM)); $this->assertEquals(array(12.34, 3600), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM)); }
/** * Save changes */ public function saveChanges() { $oldObject = clone $this->Activity; $this->saveChangesForTrackdata(); $this->saveChangesForRoute(); $Updater = new Updater($this->PDO, $this->Activity, $oldObject); $Updater->setAccountID($this->AccountID); $Updater->forceRecalculations(); if (NULL !== $this->Trackdata) { $Updater->setTrackdata($this->Trackdata); } if (NULL !== $this->Route) { $Updater->setRoute($this->Route); } $Updater->update(); }