Beispiel #1
0
function bulletin_add($period_id)
{
    global $pdo, $srcdir;
    include_once $srcdir . '/libs/bocal.php';
    $req = 'SELECT * ' . 'FROM marks ' . 'LEFT JOIN participations ON mark_participation = part_id ' . 'LEFT JOIN users ON mark_user = user_id ' . 'WHERE part_status = \'ACCEPTED\' ' . 'AND mark_period = ?';
    $sql = $pdo->prepare($req);
    $sql->bindValue(1, $period_id);
    $sql->execute();
    $users = array();
    $bocal = new Bocal();
    while ($mark = $sql->fetch()) {
        if ($mark['user_login'] == "") {
            continue;
        }
        $buser = $bocal->getUser($mark['user_login']);
        if ($buser['school'] != "epitech" || $buser['promo'] < date('Y')) {
            continue;
            //Skip no Epitech students and old promotions
        }
        isset($users[$mark['mark_user']]) || ($users[$mark['mark_user']] = array());
        $users[$mark['mark_user']][] = array("label" => $mark['part_title'], "duration" => $mark['part_duration'] * $mark['mark_mark'] / 20);
    }
    $ins = $pdo->prepare('INSERT INTO bulletin_user ' . '(bu_period, bu_user, bu_data) ' . 'VALUES (?, ?, ?)');
    $ins->bindValue(1, $period_id);
    foreach ($users as $userid => $details) {
        $ins->bindValue(2, $userid);
        $ins->bindValue(3, serialize($details));
        $ins->execute();
    }
}
Beispiel #2
0
function bocal_update()
{
    global $srcdir;
    include $srcdir . '/libs/bocal.php';
    $mdl = new Modele('event_bocal');
    $mdl->find();
    $boc = new Bocal();
    while ($mdl->next()) {
        $boc->getTicket($mdl->eb_ticket);
        $boc->updateDB($mdl->getKey());
    }
    echo "ok";
}
Beispiel #3
0
/**
 * Détails d'un utilisateur
 * Et optionnellement sa vie.
 */
function user_view()
{
    global $pdo, $tpl, $srcdir;
    $utime = microtime(true);
    $sql = $pdo->prepare('SELECT * FROM users LEFT JOIN user_types ON ut_id = user_type WHERE user_id = ?');
    $sql->bindValue(1, $_REQUEST['user']);
    $sql->execute();
    $user = $sql->fetch();
    $tpl->assign('user', $user);
    $sql = $pdo->prepare('SELECT * FROM user_sections LEFT JOIN sections ON section_id = us_section WHERE us_user = ?');
    $sql->bindValue(1, $user['user_id']);
    $sql->execute();
    $sections = array();
    while ($line = $sql->fetch()) {
        $sections[] = $line['section_id'];
        $tpl->append('sections', $line);
    }
    //List events
    $sql = $pdo->prepare('SELECT * FROM event_staff' . ' LEFT JOIN events ON event_id = est_event' . ' LEFT JOIN sections ON section_id = est_section' . ' WHERE est_user = ?' . ' ORDER BY event_start DESC');
    $sql->bindValue(1, $user['user_id']);
    $sql->execute();
    while ($event = $sql->fetch(PDO::FETCH_ASSOC)) {
        $tpl->append('events', $event);
    }
    $sql = $pdo->prepare('SELECT * FROM sections WHERE section_type = "primary"');
    $sql->execute();
    while ($line = $sql->fetch()) {
        if (!in_array($line['section_id'], $sections)) {
            $tpl->append('section_list', $line);
        }
    }
    $mdt = new Modele('user_mandate');
    $mdt->find(array('um_user' => $_REQUEST['user']));
    while ($mdt->next()) {
        $tpl->append('mandates', $mdt->um_mandate);
    }
    $mdl = new Modele('card');
    $mdl->find(array('card_user' => $_REQUEST['user']));
    while ($l = $mdl->next()) {
        $o = new Modele('card');
        $o->fetch($mdl->card_id);
        $tpl->append('cards', $o);
    }
    require_once $srcdir . '/libs/GoogleApi.php';
    $api = new GoogleApi();
    $mls = $api->findUserGroups($user['user_email']);
    $groups = array();
    if (isset($mls->groups)) {
        $tpl->assign('groups', $mls->groups);
        foreach ($mls->groups as $group) {
            $groups[] = $group->email;
        }
    }
    $allGroups = $api->getGroupsList();
    foreach ($allGroups->groups as $group) {
        if (!in_array($group->email, $groups)) {
            $tpl->append('otherGroups', $group);
        }
    }
    //Get Bocal data
    if ($user['user_login']) {
        include_once $srcdir . '/libs/bocal.php';
        $bocal = new Bocal();
        $bdata = $bocal->getUser($user['user_login']);
        $tpl->assign('bocal', $bdata);
        if ($bdata !== false) {
            include_once $srcdir . '/libs/intra.php';
            $intra = new EIntranet();
            $tpl->assign('intra', $intra->getUserInfos($user['user_login']));
        }
    }
    //Get activities
    $sql = $pdo->prepare('SELECT * FROM marks ' . 'LEFT JOIN participations ON part_id = mark_participation ' . 'LEFT JOIN sections ON part_section = section_id ' . 'LEFT JOIN events ON part_event = event_id ' . 'WHERE mark_user = ? ' . 'ORDER BY part_attribution_date DESC');
    $sql->bindValue(1, $user['user_id']);
    $sql->execute();
    while ($line = $sql->fetch()) {
        $tpl->append('activities', $line);
    }
    //Compta
    $mdl = new Modele('user_accounts');
    $mdl->find(array('ua_user' => $user['user_id']));
    $accounts = array(array('ua_id' => 0, 'ua_identifier' => 'Chèque', 'ua_type' => 'cheq', 'ua_number' => ''));
    while ($mdl->next()) {
        $accounts[] = $mdl->toArray();
    }
    $tpl->assign('accounts', $accounts);
    //Fin compta
    $tpl->assign('time', microtime(true) - $utime);
    $tpl->display('user_details.tpl');
    quit();
}
Beispiel #4
0
function event_bocal_view()
{
    global $tpl, $pdo, $srcdir;
    $sql = $pdo->prepare('SELECT * FROM events LEFT JOIN users ON event_owner = user_id LEFT JOIN sections ON section_id = event_section WHERE event_id = ?');
    $sql->bindValue(1, $_GET['event']);
    $sql->execute();
    $event = $sql->fetch();
    if (!$event) {
        modexec('syscore', 'notfound');
    }
    $tpl->assign('event', $event);
    $mdl = new Modele('event_bocal');
    $mdl->find(array('eb_id' => $_GET['ticket'], 'eb_event' => $event['event_id']));
    if (!$mdl->next()) {
        modexec('syscore', 'notfound');
    }
    include_once $srcdir . '/libs/bocal.php';
    $bocal = new Bocal();
    if (!$bocal->getTicket($mdl->eb_ticket)) {
        modexec('syscore', 'notfound');
    }
    $bocal->updateDB($mdl->getKey());
    $tpl->assign('ticket', $bocal);
    display();
}