|
|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
|
|
|
require_once(dirname(__FILE__) . '/classes/Controller.php');
|
|
|
+require_once(dirname(__FILE__) . '/classes/SecretRandomizer.class.php');
|
|
|
require_once(__DIR__.'/classes/Secret.Entity.php');
|
|
|
|
|
|
class CreateController extends Controller
|
|
|
@@ -13,13 +14,13 @@ class CreateController extends Controller
|
|
|
{
|
|
|
parent::__construct();
|
|
|
$this->campain = SecretEntity::fromId($request);
|
|
|
- $this->users = $this->campain->getUsers();
|
|
|
- $this->constraints = $this->campain->getConstraints();
|
|
|
if ($this->campain === false)
|
|
|
{
|
|
|
$this->render("404");
|
|
|
die;
|
|
|
}
|
|
|
+ $this->users = $this->campain->getUsers();
|
|
|
+ $this->constraints = $this->campain->getConstraints();
|
|
|
if (!empty($_POST))
|
|
|
$this->managePost();
|
|
|
$this->render('hash');
|
|
|
@@ -39,10 +40,15 @@ class CreateController extends Controller
|
|
|
|
|
|
public function managePost()
|
|
|
{
|
|
|
- if (!empty($_POST['cemail']))
|
|
|
+ if (!empty($_POST['launch']))
|
|
|
{
|
|
|
- $this->campain->addUser($_POST['cemail'], $_POST['cname']);
|
|
|
- $this->users = $this->campain->getUsers();
|
|
|
+ $s = new SecretRandomizer($this->campain, $this->users, $this->constraints);
|
|
|
+ $result = $s->getResult();
|
|
|
+ var_dump($result);
|
|
|
+ die;
|
|
|
+ $result->sendMails();
|
|
|
+ $this->campain->setResult($result->toString());
|
|
|
+ return;
|
|
|
}
|
|
|
$this->campain->removeConstraints();
|
|
|
$groups = array();
|
|
|
@@ -56,6 +62,11 @@ class CreateController extends Controller
|
|
|
$this->campain->addConstraint($i, $j);
|
|
|
}
|
|
|
$this->constraints = $this->campain->getConstraints();
|
|
|
+ if (!empty($_POST['cemail']))
|
|
|
+ {
|
|
|
+ $this->campain->addUser($_POST['cemail'], $_POST['cname']);
|
|
|
+ $this->users = $this->campain->getUsers();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|