Exemple #1
0
 function __init__($args)
 {
     parent::__init__($args);
     if (!$this->isSession('__concert_key')) {
         $this->setSession('__concert_key', md5(time() + mt_rand(0, 9999999)));
     }
     if ($this->isPost()) {
         if (!$this->isVariable('__concert_key') || $this->getVariable('__concert_key') != $this->getSession('__concert_key')) {
             ExceptionTrigger::raise(new GenericException('__concert_key'));
             Header::redirect(Rhaco::url());
         }
     }
 }
Exemple #2
0
 function isActive($db)
 {
     if ($this->private) {
         return ExceptionTrigger::raise(new GenericException('このイベントに参加することは出来ません'));
     }
     if ($this->periodDate < time()) {
         return ExceptionTrigger::raise(new GenericException('参加登録期限が過ぎています'));
     }
     if ($db->count(new Participant(), new C(Q::eq(Participant::columnEvent(), $this->id))) >= $this->maxParticipant) {
         return ExceptionTrigger::raise(new GenericException('参加登録可能人数を超えています'));
     }
     return true;
 }
Exemple #3
0
<?php

require dirname(__FILE__) . '/__init__.php';
Rhaco::import('generic.Flow');
$flow = new Flow();
$db = new DbUtil(Event::connection());
if ($flow->isPost() && $flow->isVariable('answer') && strtolower($flow->getVariable('answer')) == strtolower(Rhaco::constant('ANSWER'))) {
    $p = $flow->toObject(new Participant());
    if ($db->insert($p)) {
        $flow->setVariable('participant', $p);
        $flow->write('thanks.html');
        Rhaco::end();
    }
} else {
    ExceptionTrigger::raise(new GenericException('登録に失敗しました'));
}
$flow->setVariable('event', $db->get(new Event(), new C(Q::depend(), Q::eq(Event::columnId(), Rhaco::constant('CURRENT_EVENT', 1)))));
$flow->setVariable('hatena', Rhaco::obj('HatenaSyntax', array('headlevel' => 4, 'id' => 'event_description')));
$flow->write('index.html');