Exemplo n.º 1
0
 /**
  * Get all pairs as an array excluding pair with user
  * @return array $ary array of pairs
  */
 public function getFormHalveAry()
 {
     $eDb = new eDb();
     $halve = $eDb->getAllHalveNotInHele(session::getUserId());
     $ary = [];
     $ary[0] = 'Ingen halv valgt';
     foreach ($halve as $halv) {
         $ary[$halv['id']] = $halv['name'];
     }
     return $ary;
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     if (!$this->checkAccess()) {
         return;
     }
     $eDb = new eDb();
     if (isset($_GET['all'])) {
         $rows = q::select('account')->filter('admin = ', 0)->order('username')->fetch();
         $this->displayAll($rows);
     }
     if (isset($_GET['par'])) {
         $rows = $eDb->getAllPairsFromPairs();
         $this->displayPairs($rows);
     }
     if (isset($_GET['par_loose'])) {
         $rows = $eDb->getAllPairsNotInHalve();
         $this->displayPairs($rows);
     }
     if (isset($_GET['halv'])) {
         $q = "SELECT * FROM halv WHERE confirmed = 1";
         $rows = q::query($q)->fetch();
         $this->displayHalve($rows);
     }
     if (isset($_GET['halv_loose'])) {
         $rows = $eDb->getAllHalveNotInHele(session::getUserId());
         // $rows = q::query($q)->fetch();
         $this->displayHalve($rows);
     }
     if (isset($_GET['hel'])) {
         $q = "SELECT * FROM hel WHERE confirmed = 1";
         $rows = q::query($q)->fetch();
         $this->displayHele($rows);
     }
     if (isset($_GET['reg_minus'])) {
         echo $this->message("Brugere som er importeret, men som endnu ikke har foretaget en opdatering på sitet.");
         $q = "SELECT * from account WHERE id NOT IN (select user_id from dancer) AND admin = 0 ORDER by username";
         $rows = q::query($q)->fetch();
         $this->displayAll($rows);
     }
     if (isset($_GET['uden'])) {
         echo $this->message("Brugere som er importeret og har foretaget en opdatering på sitet, men som endnu ikke har en verificeret partner.");
         $q = "SELECT * from account WHERE `admin` = 0 AND id NOT IN (SELECT user_a from pair UNION SELECT user_b from pair) AND id IN (SELECT user_id FROM dancer)";
         $rows = q::query($q)->fetch();
         $this->displayAll($rows);
     }
 }
Exemplo n.º 3
0
 /**
  * Create a 'hel' and all 'helmembers'
  * @param array $ary _POST
  * @return boolean $res result from R::store
  */
 public function createHel($ary)
 {
     $e = new eDb();
     // create hel
     $hel = rb::getBean('hel');
     $hel->user_id = session::getUserId();
     // Attach halve ids
     $my_halv = $e->getUserHalvFromUserId(session::getUserId());
     $hel->halv_a = $ary['halv'];
     $hel->halv_b = $my_halv['id'];
     // Attach all 8 members
     $hel = $this->attachMembersForHel($hel, $ary);
     return R::store($hel);
 }
Exemplo n.º 4
0
 /**
  * /event/user/halv
  */
 public function helAction()
 {
     $this->checkAccess();
     $eDb = new eDb();
     $halv = $eDb->getUserHalvFromUserId(session::getUserId());
     if (empty($halv)) {
         http::locationHeader('/event/user/index', 'Du skal være del af en halv kvadrille for at oprette en hel');
     }
     http::prg();
     if (isset($_POST['send'])) {
         $this->validateHel();
         if (empty($this->errors)) {
             // Prepare
             $ary = db::prepareToPostArray(array('halv'), true);
             R::begin();
             // Delete other hele
             $eDb->deleteHelFromUserId(session::getUserId());
             // Create
             $id = $eDb->createHel($ary);
             // Set a better name
             $name = $eDb->getUsersStrFromHel($id);
             $bean = rb::getBean('hel', 'id', $id);
             $bean->name = $name;
             R::store($bean);
             $res = R::commit();
             if (!$res) {
                 R::rollback();
             }
             http::locationHeader('/event/user/index');
         } else {
             echo html::getErrors($this->errors);
         }
     }
     echo $this->formCreateHel();
 }