/** * Init data */ protected function initData() { $this->paceUnit = $this->Context->sport()->paceUnit(); $Zones = $this->computeZones(); $hrMax = Runalyze\Configuration::Data()->HRmax(); $Pace = new Pace(0, 1, $this->paceUnit); $HR = new HeartRate(0, Runalyze\Context::Athlete()); foreach ($Zones as $paceInSeconds => $Info) { if ($Info['time'] > parent::MINIMUM_TIME_IN_ZONE) { $Pace->setTime($paceInSeconds); $HR->setBPM($Info['time'] > 0 ? $Info['hr'] / $Info['time'] : 0); $this->Data[] = array('zone' => $paceInSeconds == 0 ? __('faster') : '> ' . $Pace->valueWithAppendix(), 'time' => $Info['time'], 'distance' => $Info['distance'], 'average' => $HR->asBPM() > 0 ? $HR->string() : '-'); } } }
<?php /** * Display formular for editing a training * Call: call/call.Training.edit.php?id= */ require '../inc/class.Frontend.php'; use Runalyze\Model\Activity; use Runalyze\View\Activity\Linker; use Runalyze\View\Activity\Dataview; $Frontend = new Frontend(); if (isset($_GET['delete']) && is_numeric($_GET['delete'])) { $Deleter = new Activity\Deleter(DB::getInstance(), Runalyze\Context::Factory()->activity($_GET['delete'])); $Deleter->setAccountID(SessionAccountHandler::getId()); $Deleter->delete(); echo '<div class="panel-content"><p id="submit-info" class="error">' . __('The activity has been removed') . '</p></div>'; echo '<script>$("#multi-edit-' . (int) $_GET['delete'] . '").remove();Runalyze.Statistics.resetUrl();Runalyze.reloadContent();</script>'; exit; } $Training = new TrainingObject(Request::sendId()); $Activity = new Activity\Object($Training->getArray()); $Linker = new Linker($Activity); $Dataview = new Dataview($Activity); echo $Linker->editNavigation(); echo '<div class="panel-heading">'; echo '<h1>' . $Dataview->titleWithComment() . ', ' . $Dataview->dateAndDaytime() . '</h1>'; echo '</div>'; echo '<div class="panel-content">'; $Formular = new TrainingFormular($Training, StandardFormular::$SUBMIT_MODE_EDIT); $Formular->setId('training'); $Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W50);
/** * Init fieldset for correct elevation */ protected function initElevationCorrectionFieldset() { if ($this->dataObject->get('routeid') > 0) { $Route = Runalyze\Context::Factory()->route($this->dataObject->get('routeid')); if ($Route->hasPositionData() && !$Route->hasCorrectedElevations()) { $Fieldset = new FormularFieldset(__('Use elevation correction')); $Fieldset->setCollapsed(); $Fieldset->addInfo(' <a class="ajax" target="gps-results" href="call/call.Training.elevationCorrection.php?id=' . $this->dataObject->id() . '"><strong>' . __('Correct elevation data') . '</strong></a><br> <br> <small id="gps-results" class="block"> ' . __('Elevation data via GPS is very inaccurate. Therefore you can correct it via some satellite data.') . ' </small>'); $this->addFieldset($Fieldset); } } }
<?php /** * Display formular for editing a training * Call: call/call.Training.edit.php?id= */ require '../inc/class.Frontend.php'; use Runalyze\Model\Activity; use Runalyze\View\Activity\Linker; use Runalyze\View\Activity\Dataview; $Frontend = new Frontend(); if (isset($_GET['delete']) && is_numeric($_GET['delete'])) { $Factory = Runalyze\Context::Factory(); $Deleter = new Activity\Deleter(DB::getInstance(), $Factory->activity($_GET['delete'])); $Deleter->setAccountID(SessionAccountHandler::getId()); $Deleter->setEquipmentIDs($Factory->equipmentForActivity($_GET['delete'], true)); $Deleter->delete(); echo '<div class="panel-content"><p id="submit-info" class="error">' . __('The activity has been removed') . '</p></div>'; echo '<script>$("#multi-edit-' . (int) $_GET['delete'] . '").remove();Runalyze.Statistics.resetUrl();Runalyze.reloadContent();</script>'; exit; } $Training = new TrainingObject(Request::sendId()); $Activity = new Activity\Object($Training->getArray()); $Linker = new Linker($Activity); $Dataview = new Dataview($Activity); echo $Linker->editNavigation(); echo '<div class="panel-heading">'; echo '<h1>' . $Dataview->titleWithComment() . ', ' . $Dataview->dateAndDaytime() . '</h1>'; echo '</div>'; echo '<div class="panel-content">'; $Formular = new TrainingFormular($Training, StandardFormular::$SUBMIT_MODE_EDIT);
echo EOL; echo 'Start to clean accounts '; $_POST = array(Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::ENDURANCE => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::MAX_TRIMP => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::VDOT => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral::VDOT_CORRECTOR => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::ELEVATION => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::JD_POINTS => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::TRIMP => true, Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop::VDOT => true); /** * Run single cleanups */ $Accounts = $PDO->query(' SELECT id FROM `' . PREFIX . 'account` WHERE `cleanup`=0'); $AccountUpdate = $PDO->prepare('UPDATE `' . PREFIX . 'account` SET `cleanup`=1 WHERE `id`=?'); while ($Account = $Accounts->fetch()) { GlobalCleanupAccount::$ID = $Account['id']; DB::getInstance()->setAccountID($Account['id']); Runalyze\Context::reset(); Runalyze\Configuration::loadAll($Account['id']); ShoeFactory::reInitAllShoes(); $JobLoop = new Runalyze\Plugin\Tool\DatabaseCleanup\JobLoop(); $JobLoop->run(); $JobGeneral = new Runalyze\Plugin\Tool\DatabaseCleanup\JobGeneral(); $JobGeneral->run(); if (OUTPUT) { echo $Account['id'] . ':' . EOL; echo implode(EOL, $JobLoop->messages()); echo implode(EOL, $JobGeneral->messages()); echo EOL . EOL; } $AccountUpdate->execute(array($Account['id'])); echo '.' . (CLI ? '' : ' '); }
/** * Display privacy information */ protected function displayPrivacyInfo() { $Factory = Runalyze\Context::Factory(); $Activity = $Factory->activity($this->TrainingID); if (!$Activity->isPublic()) { echo HTML::info(__('The training is currently <strong>private</strong>') . '<br> ' . Ajax::window('<a href="' . self::$URL . '?id=' . $this->TrainingID . '&public=true"> » ' . __('make it public') . '</a>', 'small')); } else { echo HTML::info(__('The training is currently <strong>public</strong>') . '<br> ' . Ajax::window('<a href="' . self::$URL . '?id=' . $this->TrainingID . '&public=false"> » ' . __('make it private') . '</a>', 'small')); } }