コード例 #1
0
/**
 * GetSessions().
 * Ritorna l'elenco di tutte le sessioni.
 * La chiave sarà SesOrder_SesType e la descrizione cambierà a seconda del valore di $extend
 *
 * @param char $type: tipo di sessione; null => tutte, Q qualifica E eliminatorie F final
 * @param bool $extend: true per la descrizione estesa: 'Nome (Tipo Ordine)' false per quella breve: Nome (Ordine)
 * @param string[] $ids: vettore di id. se specificato verranno ritornati quelli
 * @param int $tour: null considera il torneo aperto se no quello passato.
 *
 * @return mixed: array con l'elenco delle sessioni con la descrizione impostata in base a $extend e l'id SesOrder_SesType
 */
function GetSessions($type = null, $extend = false, $ids = null, $tour = null)
{
    $tour = !is_null($tour) ? $tour : $_SESSION['TourId'];
    $sessionsTypes = GetSessionsTypes();
    $filter = "SesTournament=" . StrSafe_DB($tour) . " ";
    if (is_null($ids)) {
        if (!is_null($type) && array_key_exists($type, $sessionsTypes)) {
            $filter .= "AND SesType='" . $type . "' ";
        }
    } else {
        if (!is_array($ids)) {
            $ids = array($ids);
        }
        $in = array();
        for ($i = 0; $i < count($ids); ++$i) {
            $in[] = StrSafe_DB($ids[$i]);
        }
        $filter .= "AND CONCAT(SesOrder,'_',SesType) IN (" . implode(',', $in) . ") ";
    }
    $ret = array();
    $q = "SELECT * FROM Session WHERE {$filter} ORDER BY locate(SesType, 'QEF'), SesOrder ";
    $r = safe_r_sql($q);
    // 	debug_svela($q);
    if ($r && safe_num_rows($r) > 0) {
        while ($row = safe_fetch($r)) {
            $tmp = $row;
            $tmp->Id = $row->SesOrder . '_' . $row->SesType;
            if ($row->SesName != '') {
                $tmp->Descr = $row->SesOrder . ': ' . $row->SesName;
                if ($extend) {
                    $tmp->Descr = $row->SesName . ' (' . $sessionsTypes[$row->SesType] . ' ' . $row->SesOrder . ')';
                }
            } else {
                $tmp->Descr = $tmp->SesOrder;
            }
            $ret[] = $tmp;
        }
    }
    return $ret;
}
コード例 #2
0
ファイル: ManSessions.php プロジェクト: brian-nelson/ianseo
require_once 'Common/Fun_Various.inc.php';
require_once 'Tournament/Fun_Tournament.local.inc.php';
require_once 'Tournament/Fun_ManSessions.inc.php';
if (defined('hideSchedulerAndAdvancedSession')) {
    header('location: ManSessions_kiss.php');
    exit;
}
if (!CheckTourSession()) {
    print get_text('CrackError');
    exit;
}
$msg = "";
$tourId_safe = StrSafe_DB($_SESSION['TourId']);
$command = isset($_REQUEST['Command']) ? $_REQUEST['Command'] : null;
// tipi sessione
$sessionsTypes = GetSessionsTypes();
if (!is_null($command) && !IsBlocked(BIT_BLOCK_TOURDATA)) {
    if ($command == 'SAVE') {
        $myRequest = array('oldKey', 'd_SesOrder', 'd_SesType', 'd_SesName', 'd_SesTar4Session', 'd_SesAth4Target', 'd_SesFirstTarget', 'd_SesFollow');
        $toSave = array();
        foreach ($myRequest as $v) {
            if (isset($_REQUEST[$v])) {
                $toSave[$v] = $_REQUEST[$v];
            } else {
                $toSave[$v] = null;
            }
        }
        /*print '<pre>';
        		print_r($toSave);
        		print '</pre>';exit;*/
        // le var ci devono esser tutte