/** * Display pairs as a HTML table * @param array $rows */ public function displayPairs($rows) { $str = table::tableBegin(array('class' => 'uk-table uk-table-hover uk-table-striped uk-table-condensed')); foreach ($rows as $row) { $a = session::getAccount($row['user_a']); $b = session::getAccount($row['user_b']); $str .= table::trBegin(); $str .= table::td($a['username'], array('class' => 'uk-width-3-10')); $str .= table::td($b['username'], array('class' => '')); $str .= table::trEnd(); } $str .= table::tableEnd(); echo $str; }
/** * Get all pairs as an array excluding pair with user * @return array $ary array of pairs */ public function getFormPairsAry() { $eDb = new eDb(); $pairs = $eDb->getAllPairsNotInHalve(); $ary = []; $ary[0] = 'Intet par valgt'; foreach ($pairs as $pair) { $a = session::getAccount($pair['user_a']); $b = session::getAccount($pair['user_b']); if ($a['id'] == session::getUserId()) { continue; } if ($b['id'] == session::getUserId()) { continue; } $pair_str = $a['username'] . ' - ' . $b['username']; $ary[$pair['id']] = $pair_str; } return $ary; }
/** * Get a readable string of users in a 'hel' * @param int $hel * @return string $str */ public function getUsersStrFromHel($hel) { $users = $this->getUsersFromHel($hel); $ary = []; foreach ($users as $user) { $account = session::getAccount($user['user_id']); $ary[] = $account['username']; } return implode(' - ', $ary); }
/** * form that deletes a partner. * will also delete all 'halve' * @return type */ public function formDeletePartner() { $e = new eDb(); $partner_id = $e->getPairPartnerUserId(session::getUserId()); $this->javascript(); $user = session::getAccount($partner_id); echo helpers::confirmDeleteForm('delete_partner', "Du har en partner: '{$user['username']}'", 'Ophæv partnerskab'); if (isset($_POST['delete_partner'])) { R::begin(); // Update pair - delete partner $e->updateFromForm(session::getUserId(), array('partner' => 0)); $e->deletePairByUserId(session::getUserId()); // Delete halve $e->deleteHalvFromUserId(session::getUserId()); // Delete hele $e->deleteHelFromUserId(session::getUserId()); $res = R::commit(); if (!$res) { R::rollback(); } // Location http::locationHeader('/event/user/index', 'Skilsmisse fuldbyrdet. Du er løst fra din partner'); } return; }