Пример #1
0
 /**
  * @param int $id
  */
 protected function delete($id)
 {
     $Deleter = new Deleter($this->PDO, $this->fetch($id));
     $Deleter->setAccountID(0);
     $Deleter->delete();
 }
Пример #2
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));
 }
Пример #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'])) {
    $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);
Пример #4
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);
Пример #5
0
 * 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);
    $View->display();
}