Ejemplo n.º 1
0
function generate_vars($section, &$vars)
{
    $vars['ok'] = false;
    $vars['full'] = false;
    if (!isset($_GET['match_id']) || !isset($_GET['nombre_billet'])) {
        return;
    }
    $nombre_billet = $_GET['nombre_billet'];
    $match = Match::get($_GET['match_id']);
    if ($match == null || $nombre_billet <= 0) {
        return;
    }
    if ($match->places < $nombre_billet) {
        $vars['full'] = true;
        return;
    }
    $match->places = $match->places - $nombre_billet;
    $match->save();
    $reservation = new Reservation();
    $reservation->utilisateur = $vars['userid'];
    $reservation->match_id = $match->id;
    $reservation->qte = $nombre_billet;
    $reservation->expiration = 'now()';
    $reservation->save();
    $vars['ok'] = true;
}
Ejemplo n.º 2
0
function generate_vars($section, &$vars)
{
    if (!isset($_GET['id'])) {
        return;
    }
    $vars['match'] = Match::get($_GET['id']);
}
Ejemplo n.º 3
0
Archivo: util.php Proyecto: pheze/ydtp2
function ajust_ticket_and_delete($reservation)
{
    $match = Match::get($reservation->match_id);
    $new_places = $match->places + $reservation->qte;
    $match->places = $new_places;
    $match->save();
    $reservation->delete();
}
Ejemplo n.º 4
0
function generate_vars($section, &$vars)
{
    if (!isset($_GET['match_id']) || !isset($_GET['nombre_billet'])) {
        $vars['ok'] = false;
        return;
    }
    $vars['ok'] = true;
    $vars['ok_place'] = false;
    if (Match::get($_GET['match_id'])->places < $_GET['nombre_billet']) {
        return;
    }
    $vars['match_id'] = $_GET['match_id'];
    $vars['nombre_billet'] = $_GET['nombre_billet'];
    $vars['ok_place'] = true;
}
Ejemplo n.º 5
0
function generate_vars($section, &$vars)
{
    if (!isset($_GET['id'])) {
        return;
    }
    $vars['match'] = Match::get($_GET['id']);
    $vars['arena'] = $vars['match']->getArena();
    $classes = array();
    for ($i = 0; $i < $vars['arena']->profondeur; $i++) {
        $classes[$i] = array();
        for ($j = 0; $j < $vars['arena']->largeur; $j++) {
            $classes[$i][$j] = get_siege_info($vars['userid'], $_GET['id'], $i, $j);
        }
    }
    $vars['classes'] = $classes;
}
Ejemplo n.º 6
0
 public function recalculateAction(Player $me, $match)
 {
     $match = Match::get($match);
     // get a match even if it's deleted
     if (!$me->canEdit($match)) {
         throw new ForbiddenException("You are not allowed to edit that match.");
     }
     return $this->showConfirmationForm(function () use($match) {
         $response = new StreamedResponse();
         $response->headers->set('Content-Type', 'text/plain');
         $response->setCallback(function () use($match) {
             $this->recalculate($match);
         });
         $response->send();
     }, "Do you want to recalculate ELO history for all teams and matches after the specified match?", "ELO history recalculated", "Recalculate ELOs", function () use($match) {
         if ($match->isDeleted()) {
             return new RedirectResponse($match->getURL('list'));
         }
         return new RedirectResponse($match->getURL('show'));
     }, "Match/recalculate.html.twig", $noButton = true);
 }
Ejemplo n.º 7
0
 public function get_match()
 {
     return Match::get($this->id_match);
 }
Ejemplo n.º 8
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return Response::json(Match::get($id));
 }
Ejemplo n.º 9
0
 /**
  * Find if a specific match is the team's last one
  *
  * @param  int|Match $match The match
  * @return bool
  */
 public function isLastMatch($match)
 {
     // Find if this team participated in any matches after the current match
     return !Match::getQueryBuilder()->with($this)->where('status')->notEquals('deleted')->where('time')->isAfter(Match::get($match)->getTimestamp())->any();
 }
Ejemplo n.º 10
0
 public function get_match()
 {
     return Match::get($this->match_id);
 }
Ejemplo n.º 11
0
 public function doSyncFromFeed($data, $form)
 {
     $feeds = $this->Feeds();
     foreach ($feeds as $feed) {
         $feedreader = new ICSReader($feed->URL);
         $events = $feedreader->getEvents();
         foreach ($events as $event) {
             // translate iCal schema into Match schema
             $uid = strtok($event['UID'], '@');
             if ($match = Match::get()->filter(array("UID" => $uid))->First()) {
                 $feedevent = $match;
             } else {
                 $feedevent = Match::create();
                 $feedevent->UID = $uid;
             }
             $feedevent->Title = $event['SUMMARY'];
             //Get opposition with some string fun
             $feedevent->Opposition = trim(str_replace(array("-", "Black Doris Rovers", "vs"), "", $event['SUMMARY']));
             if (preg_match('/Round/', $feedevent->Opposition)) {
                 $opp = explode(" ", $feedevent->Opposition);
                 $opp = array_slice($opp, 2);
                 $feedevent->Opposition = trim(implode(" ", $opp));
             }
             if (isset($event['DESCRIPTION']) && !empty($event['DESCRIPTION']) && $event['DESCRIPTION'] != " ") {
                 $scores = str_replace("Result\n", "", $event['DESCRIPTION']);
                 $scores = explode("-", $scores);
                 foreach ($scores as $score) {
                     $score = trim($score);
                     $bits = explode(" ", $score);
                     if (preg_match('/Black Doris Rovers/', $score)) {
                         $feedevent->BDRScore = end($bits);
                     } else {
                         $feedevent->OppositionScore = end($bits);
                     }
                 }
                 if (intval($feedevent->BDRScore) > intval($feedevent->OppositionScore)) {
                     $feedevent->Result = 'Win';
                 } elseif (intval($feedevent->BDRScore) < intval($feedevent->OppositionScore)) {
                     $feedevent->Result = 'Loss';
                 } else {
                     $feedevent->Result = 'Draw';
                 }
             } else {
                 $feedevent->BDRScore = NULL;
                 $feedevent->OppositionScore = NULL;
                 $feedevent->Result = NULL;
             }
             $startdatetime = $this->iCalDateToDateTime($event['DTSTART']);
             if (array_key_exists('DTEND', $event) && $event['DTEND'] != NULL) {
                 $enddatetime = $this->iCalDateToDateTime($event['DTEND']);
             } elseif (array_key_exists('DURATION', $event) && $event['DURATION'] != NULL) {
                 $enddatetime = $this->iCalDurationToEndTime($event['DTSTART'], $event['DURATION']);
             }
             $new = false;
             if ($feedevent->DateTimes()->Count() == 0) {
                 $cdt = CalendarDateTime::create();
                 $new = true;
             } else {
                 $cdt = $feedevent->DateTimes()->First();
             }
             $cdt->StartDate = $startdatetime->format('Y-m-d');
             $cdt->StartTime = $startdatetime->format('H:i:s');
             $cdt->EndDate = $enddatetime->format('Y-m-d');
             $cdt->EndTime = $enddatetime->format('H:i:s');
             if ($new == true) {
                 $feedevent->DateTimes()->add($cdt);
             } else {
                 $cdt->write();
             }
             $feedevent->ParentID = $this->ID;
             $feedevent->write();
             $feedevent->publish('Stage', 'Live');
         }
     }
     $form->sessionMessage('Sync Succeeded', 'good');
     $data = $this->data();
     $data->LastSyncDate = date("Y-m-d H:i:s");
     $data->write();
     $data->publish('Stage', 'Live');
     return $this->redirectBack();
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 protected function assignLazyResult($player)
 {
     $this->email = $player['email'];
     $this->verified = $player['verified'];
     $this->receives = $player['receives'];
     $this->confirmCode = $player['confirm_code'];
     $this->outdated = $player['outdated'];
     $this->description = $player['description'];
     $this->timezone = $player['timezone'];
     $this->joined = TimeDate::fromMysql($player['joined']);
     $this->last_login = TimeDate::fromMysql($player['last_login']);
     $this->last_match = Match::get($player['last_match']);
     $this->admin_notes = $player['admin_notes'];
     $this->ban = Ban::getBan($this->id);
     $this->updateUserPermissions();
 }