Exemplo n.º 1
0
 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);
     $Object = new Object(array(Object::DISTANCE => 10, Object::TIME_IN_SECONDS => 3600, Object::SPORTID => 1));
     $Inserter = new Inserter($this->PDO);
     $Inserter->setAccountID(0);
     $Inserter->setEquipmentIDs(array($this->EquipmentA));
     $Inserter->insert($Object);
     $this->assertEquals(array(10, 3600), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM));
     $this->assertEquals(array(0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM));
     $Deleter = new Deleter($this->PDO, $Object);
     $Deleter->setAccountID(0);
     $Deleter->setEquipmentIDs(array($this->EquipmentA));
     $Deleter->delete();
     $this->assertEquals(array(0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentA)->fetch(PDO::FETCH_NUM));
     $this->assertEquals(array(0, 0), $this->PDO->query('SELECT `distance`, `time` FROM `runalyze_equipment` WHERE `id`=' . $this->EquipmentB)->fetch(PDO::FETCH_NUM));
 }
Exemplo n.º 2
0
 /**
  * @param int $id
  */
 protected function delete($id)
 {
     $Deleter = new Deleter($this->PDO, $this->fetch($id));
     $Deleter->setAccountID(0);
     $Deleter->delete();
 }
Exemplo n.º 3
0
<?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);