/** * is account locked * @return boolean */ public static function locked() { $user = self::getAccount(session::getUserId()); if (empty($user)) { return false; } if ($user['locked'] == 1) { return true; } return false; }
/** * 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; }
/** * set account timezone (account_timezone) */ public static function setAccountTimezone() { // set user timezone - only in web mode if (!conf::isCli()) { $timezone = cache::get('account_timezone', session::getUserId()); if ($timezone) { date_default_timezone_set($timezone); } else { self::setCookieTimezone(); } } }
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); } }
/** * * Method checks an account based on session user_id. It checks: * a) if an account is locked * b) if the current user_id does not correspond to an account. * * In both cases all sessions are killed. * Method is run at boot. In diversen\boot * * @return void */ public static function checkAccount() { $user_id = session::getUserId(); if ($user_id) { $a = q::select('account')->filter('id =', $user_id)->fetchSingle(); // user may have been deleted if (empty($a)) { self::killSessionAll($user_id); return false; } if ($a['locked'] == 1) { self::killSessionAll($user_id); return false; } } return true; }
/** * function for getting an account * @param int $id user_id * @return array $row from account */ public static function getAccount($id = null) { if (!$id) { $id = session::getUserId(); } $db = new db(); $row = $db->selectOne('account', 'id', $id); return $row; }
/** * 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); }
/** * /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(); }