<?php require_once 'common.php'; check_roostermaker($_GET['secret']); header('Content-type: application/json; charset=UTF-8'); //header('Content-type: text/plain; charset=UTF-8'); $ret = mdb2_single_val("SELECT locking_status FROM locking WHERE locking_id = 0 AND locking_randid = '%q'", $_GET['randid']); if ($ret === NULL) { echo '{}'; } else { echo $ret; }
function insert_les($separator, $zermelo_id, $dag0, $uur0, $vakken0, $lesgroepen0, $docenten0, $lokalen0, $file_id, $notitie) { $dag = $dag0 == '' ? 0 : get_dag($dag0); $uur = $uur0 == '' ? 0 : ($separator == '/' ? get_uur($uur0) : get_uur_udmz($uur0)); if ($uur > config('MAX_LESUUR')) { logit("lesuur in rooster ({$uur}) groter dan MAX_LESUUR"); } $lesgroepen1 = implode(',', $lesgroepen = array_map('cleanup_lesgroepen', explode_and_sort($separator, $lesgroepen0))); $vakken1 = implode(',', $vakken = explode_and_sort($separator, $vakken0)); $docenten1 = implode(',', $docenten = explode_and_sort($separator, $docenten0)); $lokalen1 = implode(',', $lokalen = explode_and_sort($separator, $lokalen0)); // als er een dollarteken in een notitie voorkomt, // gooi het en alles erna (en whitespace ervoor) dan weg if (($clean = strstr($notitie, '$', true)) !== false) { $notitie = trim($clean); } // we hebben een lock, dus er is geen race condition // hebben we deze les al? $les_id = mdb2_single_val(<<<EOQ SELECT les_id FROM lessen WHERE dag = {$dag} AND uur = {$uur} AND vakken = '%q' AND lesgroepen = '%q' AND docenten = '%q' AND lokalen = '%q' AND notitie = '%q' EOQ , $vakken1, $lesgroepen1, $docenten1, $lokalen1, $notitie); if (!$les_id) { // deze les is nieuw mdb2_exec(<<<EOT INSERT INTO lessen ( dag, uur, vakken, lesgroepen, docenten, lokalen, notitie ) VALUES ( {$dag}, {$uur}, '%q', '%q', '%q', '%q', '%q' ) EOT , $vakken1, $lesgroepen1, $docenten1, $lokalen1, $notitie); $les_id = mdb2_last_insert_id(); $entity_ids = array(); // FIXME schrap dl.+ van vakken $vakken = array_map('addslash', $vakken); if ($lesgroepen0) { foreach ($lesgroepen as $naam) { $entity_ids[] = add_entity($naam, LESGROEP); } } if ($vakken0) { foreach ($vakken as $naam) { $entity_ids[] = add_entity($naam, VAK); } } if ($docenten0) { foreach ($docenten as $naam) { $entity_ids[] = add_entity($naam, DOCENT); } } if ($lokalen0) { foreach ($lokalen as $naam) { $entity_ids[] = add_entity($naam, LOKAAL); } } foreach ($entity_ids as $entity_id) { add_entities2lessen($entity_id, $les_id); } } mdb2_exec("INSERT INTO files2lessen ( file_id, zermelo_id, les_id ) VALUES ( {$file_id}, {$zermelo_id}, {$les_id} )"); }
<?php require_once 'common.php'; check_roostermaker($_GET['secret']); $file_id = mdb2_single_val(<<<EOQ SELECT file_id FROM files WHERE file_type = 1 AND file_status = 1 ORDER BY file_version DESC LIMIT 1 EOQ ); $res = mdb2_query(<<<EOQ SELECT ll, name, stamklassen.entity_name klas, GROUP_CONCAT(CONCAT(doc, '/', bla) SEPARATOR ';') info FROM ( \tSELECT ppl_id, ll, doc, GROUP_CONCAT(vakken ORDER BY vakken) bla FROM ( \t\tSELECT DISTINCT ll.entity_id ppl_id, ll.entity_name ll, doc.entity_name doc, lessen.vakken \t\tFROM grp2ppl \t\tJOIN entities2lessen AS grp2les ON grp2les.entity_id = grp2ppl.lesgroep_id \t\tJOIN files2lessen ON files2lessen.les_id = grp2les.les_id AND file_id = {$file_id} \t\tJOIN lessen ON lessen.les_id = files2lessen.les_id \t\tJOIN entities2lessen AS doc2les ON doc2les.les_id = grp2les.les_id AND file_id = {$file_id} \t\tJOIN entities AS doc ON doc.entity_id = doc2les.entity_id AND doc.entity_type = %i \t\tJOIN entities AS ll ON ll.entity_id = grp2ppl.ppl_id \t\tWHERE file_id_basis = {$file_id} \t) AS lijst \tGROUP BY ppl_id, doc ) AS lijst JOIN names ON names.entity_id = ppl_id JOIN grp2ppl ON grp2ppl.ppl_id = lijst.ppl_id AND file_id_basis = {$file_id} JOIN entities AS stamklassen ON stamklassen.entity_id = grp2ppl.lesgroep_id AND stamklassen.entity_type = %i GROUP BY lijst.ppl_id ORDER BY klas, surname, firstname, prefix
<?php require_once 'common.php'; check_roostermaker($_GET['secret']); $res = mdb2_query(<<<EOQ SELECT weken.week_id, week, MAX(basis_id) basis_id FROM weken LEFT JOIN roosters ON roosters.week_id = weken.week_id AND roosters.wijz_id = 0 GROUP BY week_id ORDER BY week_id EOQ ); $week_options = ''; $test = 0; while ($wk = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { $week_options .= '<option' . (!$wk['basis_id'] && !$test++ ? ' selected' : '') . ' value="' . $wk['week_id'] . '">week ' . $wk['week'] . ($wk['basis_id'] ? ' (' . mdb2_single_val("SELECT file_version FROM files JOIN roosters ON roosters.file_id = files.file_id WHERE wijz_id = 0 AND basis_id = {$wk['basis_id']}") . ')' : '') . '</option>' . "\n"; } $sub0 = "CONCAT('<a href=\"getfile.php?file_id=', file_id, '&secret=" . config('UPLOAD_SECRET') . "\">', file_name, '</a>')"; $res = mdb2_query(<<<EOQ SELECT week, CONCAT('<input type="checkbox"', CASE WHEN ma = 1 THEN ' checked' ELSE '' END, ' name="id', week_id, 'ma">') ma, CONCAT('<input type="checkbox"', CASE WHEN di = 1 THEN ' checked' ELSE '' END, ' name="id', week_id, 'di">') di, CONCAT('<input type="checkbox"', CASE WHEN wo = 1 THEN ' checked' ELSE '' END, ' name="id', week_id, 'wo">') wo, CONCAT('<input type="checkbox"', CASE WHEN do = 1 THEN ' checked' ELSE '' END, ' name="id', week_id, 'do">') do, CONCAT('<input type="checkbox"', CASE WHEN vr = 1 THEN ' checked' ELSE '' END, ' name="id', week_id, 'vr">') vr FROM weken ORDER BY week_id EOQ ); $res_geupload = mdb2_query(<<<EOQ SELECT week, basis_id, wijz_id, {$sub0} file_name, FROM_UNIXTIME(timestamp) timestamp, IFNULL(file_version, '-') file_version FROM roosters JOIN weken USING (week_id) JOIN files USING (file_id) ORDER BY rooster_id DESC EOQ
SELECT CONCAT('<span style="display: inline-block"><input type="checkbox" name="entity_ids[]" value="', \tentities.entity_id, '"', CASE WHEN bericht_id IS NOT NULL THEN ' checked' ELSE '' END, '>', \tentity_name, '</input></span>') FROM entities LEFT JOIN entities2berichten ON entities2berichten.entity_id = entities.entity_id AND entities2berichten.bericht_id = %i WHERE (entity_active = 1 OR entities2berichten.entity_id IS NOT NULL) AND entity_type = %i ORDER BY entity_name EOQ; $koppel_count_query = <<<EOQ SELECT COUNT(*) FROM entities2berichten JOIN entities ON entities.entity_id = entities2berichten.entity_id WHERE bericht_id = %i AND entity_type = %i EOQ; $k_stamklassen = mdb2_col(0, $koppel_query, $bericht_id, STAMKLAS); $k_lesgroepen = mdb2_col(0, $koppel_query, $bericht_id, LESGROEP); $k_categorieen = mdb2_col(0, $koppel_query, $bericht_id, CATEGORIE); $count_stamklassen = mdb2_single_val($koppel_count_query, $bericht_id, STAMKLAS); $count_lesgroepen = mdb2_single_val($koppel_count_query, $bericht_id, LESGROEP); $count_categorieen = mdb2_single_val($koppel_count_query, $bericht_id, CATEGORIE); header("Content-Type: text/html; charset=UTF-8"); ?> <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>Bericht</title> <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.10.4.custom.min.css"> <style type="text/css"><!-- body { font-size: 10px; } #content { font-size: 13px; }
function entity_prevnext($name, $type) { if ($type != LOKAAL && $type != DOCENT && $type != STAMKLAS && $type != VAK && $type != CATEGORIE) { fatal_error('unsupported prevnext'); } $prev = mdb2_single_val("SELECT MAX(entity_name) FROM entities WHERE entity_name < '%q' AND entity_active IS NOT NULL AND entity_type = {$type}", $name); $next = mdb2_single_val("SELECT MIN(entity_name) FROM entities WHERE entity_name > '%q' AND entity_active IS NOT NULL AND entity_type = {$type}", $name); if ($type == VAK) { $name = substr($name, 1); } return '<span class="noprint">' . make_link_conditional($prev, '<') . '</span>' . htmlenc($name) . '<span class="noprint">' . make_link_conditional($next, '>') . '</span>'; }
} $safe_week = (int) $_GET['wk']; if ($safe_week != $_GET['wk']) { echo '[]'; exit; } if (config('HIDE_STUDENTS')) { echo '[]'; exit; } $week_id = mdb2_single_val("SELECT week_id FROM weken WHERE week = {$safe_week}"); if (!$week_id) { echo '[]'; exit; } $file_id = mdb2_single_val("SELECT file_id FROM roosters WHERE week_id <= {$week_id} AND wijz_id = 0 ORDER BY rooster_id DESC LIMIT 1"); if (!$file_id) { echo '[]'; exit; } $query = <<<EOT SELECT entities.entity_name id, CONCAT(name, ' (', stamklassen.entity_name, '/', entities.entity_name, ')') value FROM names JOIN entities ON names.entity_id = entities.entity_id JOIN grp2ppl ON ppl_id = names.entity_id JOIN entities AS stamklassen ON stamklassen.entity_id = lesgroep_id WHERE file_id_basis = {$file_id} AND stamklassen.entity_type = 5 AND name LIKE '%%%w%%' LIMIT 15 EOT; $result = mdb2_query($query, $_GET['term']); header("Content-Type: application/json; charset=UTF-8"); $array = $result->fetchAll(MDB2_FETCHMODE_ASSOC);