diff --git a/api2.php b/api2.php index f73444d..c14d7b1 100644 --- a/api2.php +++ b/api2.php @@ -1,6 +1,6 @@ - - $_REQUEST['vals'], "result"=>"success","action"=>"updated", "query"=>$q,"err"=>mysqli_error($c2))); + echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated", "query"=>$q,"err"=>mysqli_error($c))); } else { echo json_encode( array("result"=>"fail", "err"=>"no activity id specified") ); } exit(); diff --git a/dir_api.php b/dir_api.php index 21eb3f3..791b91f 100644 --- a/dir_api.php +++ b/dir_api.php @@ -11,48 +11,30 @@ $DEBUG = 0; // \__|_| |_|\___| |_____/_/ \_\_/_/ \_\_.__/ \__,_|___/\___| // // -// DATABASE -// -// Yes, there's two different databases. -// -// $c = gavi_db -// $c2 = PeterDB -// -// Why? Just to keep you on your toes. -// -// also, there's 3 different tables that have people/users. Why? Reasons. Which mostly no longer apply. -// I recommend combining conf_users and gavi_personnel_ext so at least there's -// one less opportunity to get out of sync. -// // // The $j argument is true for a json result, or false for a raw db object result. // -$TESTSITE = 1; +$TESTSITE = 1; if ($TESTSITE) { - $DBServer = '192.168.1.6'; $DBUser = 'phowell'; - $DBPass = 'rolley34'; $DBName = 'db'; - - $DBUser2 = 'phowell'; + $DBUser2 = 'phowell'; $DBServer = '192.168.1.6'; $DBPass2 = 'rolley34'; $DBName2 = 'db'; } else { - $DBServer = 'localhost'; $DBUser = 'www'; - $DBPass = '@$df'; $DBName = 'gavi_db'; - - $DBUser2 = 'phowell'; + $DBUser2 = 'phowell'; $DBServer = 'localhost'; $DBPass2 = 'p^howell'; $DBName2 = 'PeterDB'; } +/* # not using www account anymore $c = new mysqli($DBServer, $DBUser, $DBPass, $DBName); if ($c->connect_error) { die('Database connection failed: ' . $c->connect_error ); } if (!mysqli_select_db($c, $DBName)) { die("Uh oh, couldn't select database $DBName"); } +*/ -$c2 = new mysqli($DBServer, $DBUser2, $DBPass2, $DBName2); -if ($c2->connect_error) { die('Database connection failed: ' . $c2->connect_error ); } -if (!mysqli_select_db($c2, $DBName2)) { die("Uh oh, couldn't select database 'PeterDB'"); } +$c = new mysqli($DBServer, $DBUser2, $DBPass2, $DBName2); +if ($c->connect_error) { die('Database connection failed: ' . $c->connect_error ); } +if (!mysqli_select_db($c, $DBName2)) { die("Uh oh, couldn't select database 'PeterDB'"); } mysqli_set_charset($c, 'utf8'); -mysqli_set_charset($c2, 'utf8'); include('underscore.php'); $_ = new __(); @@ -82,18 +64,18 @@ function logout() { session_destroy(); } $server = $_SERVER['SERVER_NAME']; $options_query = "SELECT label,value FROM `conf_uinforecord` WHERE id>1"; -$options_array = multi_row_select($options_query, 0, $c2); +$options_array = multi_row_select($options_query, 0); $OPTIONS = array_reduce($options_array, function ($result, $item) { $result[$item["label"]] = $item["value"]; return $result; }, array()); $default_ay_query = "SELECT begin,end FROM conf_academicyears ca JOIN conf_uinforecord cu ON cu.value=ca.id WHERE cu.label='default_ay';"; -$AY = single_row_select($default_ay_query,0, $c2); +$AY = single_row_select($default_ay_query,0); $OPTIONS['year'] = $AY; $conf_query = "SELECT semester,date1,date2,title FROM conf_conferences cc JOIN conf_uinforecord cu ON cu.value=cc.id WHERE cu.label='default_conference';"; -$CONF = single_row_select($conf_query,0, $c2); +$CONF = single_row_select($conf_query,0); $OPTIONS['conf'] = $CONF; @@ -109,7 +91,7 @@ function name_to_file($fn,$ln) { // 1. lookups, like a username -function single_row_select($qry, $j, $c) { +function single_row_select($qry, $j) { global $c; $r = mysqli_query($c, $qry); d_err($qry); $e = mysqli_error($c); if($e) { d_err("sql error: " . $e ); } if (!$r) { return $r; } @@ -119,7 +101,7 @@ function single_row_select($qry, $j, $c) { if (! $j) { return $a; } return json_encode($a); } // 1a. inserts -function single_row_insert($qry, $j, $c) { +function single_row_insert($qry, $j) { global $c; $r = mysqli_query($c, $qry); //d_err($qry); //$e = mysqli_error($c); if($e) { d_err("sql error: " . $e ); } @@ -131,25 +113,25 @@ function single_row_insert($qry, $j, $c) { if (! $j) { return $a; } return json_encode($a); } */ // 1b. updates -function single_row_update($qry, $j, $c) { +function single_row_update($qry, $j) { global $c; $r = mysqli_query($c, $qry); return 1; } // 2. grid or fancier joins, like get all sessions, rosters, todos, etc -function multi_row_select($qry, $j, $db) { +function multi_row_select($qry, $j) { global $c; $rows = array(); - $result = mysqli_query($db, $qry); + $result = mysqli_query($c, $qry); while($r = mysqli_fetch_assoc($result)) { $rows[] = $r; } if (! $j) { return $rows; } return json_encode( $rows); } // 3. Check if an entry exists -function does_exist($qry, $full_record, $db) { global $c, $c2; - $r = mysqli_query($db, $qry); +function does_exist($qry, $full_record) { global $c; + $r = mysqli_query($c, $qry); $a = mysqli_num_rows($r); if (! $a ) { return 0; } $row = mysqli_fetch_array($r, MYSQLI_NUM); $id = $row[0]; // getting the id of that which exists... assuming first column has it. - $e = mysqli_error($db); if($e) { d_err("sql error: " . $e); } + $e = mysqli_error($c); if($e) { d_err("sql error: " . $e); } if ($a && $full_record) { return $row; } if ($a) { return $id; } return 0; } @@ -160,14 +142,14 @@ function does_exist($qry, $full_record, $db) { global $c, $c2; // // // // Enter or get browser log entry function insert_or_get_browser($b) { - global $c2; + global $c; $BROWSER = ok($b); - $existing = does_exist( "SELECT id FROM www_browsers WHERE string='$BROWSER'", 0, $c2); + $existing = does_exist( "SELECT id FROM www_browsers WHERE string='$BROWSER'", 0); if ($existing) { return $existing; } else { $q = "INSERT INTO www_browsers (string) VALUES ('$BROWSER')"; - single_row_insert($q,0,$c2); - return does_exist( "SELECT id FROM www_browsers WHERE string='$BROWSER'",0,$c2); } } + single_row_insert($q,0,$c); + return does_exist( "SELECT id FROM www_browsers WHERE string='$BROWSER'",0,$c); } } function dumpit($var) { ob_start(); @@ -176,25 +158,6 @@ function dumpit($var) { ob_end_clean(); return $a; } -// // -// // Log everything! -function log_it($action) { - global $USER, $USER_GOO, $USER_EMAIL, $c2; - //echo("\n\n\n"); - - if (! $USER) { - $USER = array( 'user_id'=>'unknown', 'id'=>-1 ); } - $user_browser = $_SERVER['HTTP_USER_AGENT']; - $user_ip = $_SERVER['REMOTE_ADDR']; - - $BROWSER = insert_or_get_browser($user_browser); - $ACTION = ok($action) . " / " . dumpit($USER) . " / " . $USER_GOO . " / " . $USER_EMAIL; - - //$persid = $USER->id; - //if (! $persid) { $persid = -1; } - $qupdate = "INSERT INTO gavi_logs SET action='{$ACTION}', " /*personnel_id='{$persid}',name='{$USER->user_id}', */ . "browser=$BROWSER, ip='$user_ip'"; - single_row_insert($qupdate,0,$c2); - return array("result"=>"success","action"=>"logged","query"=>$qupdate,"err"=>mysqli_error($c2)); } // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // @@ -248,151 +211,8 @@ function check_dir_photo($fn,$ln) { global $USER; -///// -///// -// -// Insert new user -// -// For whatever reason, we haven't seen this person before. Insert their conf_user row -// so they can have their choices recorded. -// -function insert_new_user() { global $USER, $USER_EMAIL, $USER_GOO, $USER_NAME, $USER_PERS_ID, $USER_CONF_U_ID, $USER_PERS_EXT_ID, $c, $c2; - $LC_EMAIL = strtolower($USER_EMAIL); - single_row_insert("INSERT INTO conf_users (goo, email, name) VALUES ('{$USER_GOO}','{$LC_EMAIL}','{$USER_NAME}');", 1, $c2); - $logaction = log_it("Made a new conf_users row for {$USER_NAME} / {$LC_EMAIL} / {$USER_GOO}"); -} - - -// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // -// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // -// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // -// -// Fetching a person's records -// -// 1. use their email to lookup PERSONNEL -// - basic directory info -// -// 2. use their email to lookup CONF_USERS -// - flex app, workshop signups -// -// 3. use conf_users.id to lookup in gavi_personnel_ext.c_users -// - goo, depts, job title, image active -// -// 4. use personnel.id to lookup [webpages, welcomepages, etc] -// -// -// Ultimately the user's data goes into the global $USER - -function user_record() { global $USER, $USER_EMAIL, $USER_GOO, $USER_NAME, $USER_PERS_ID, $USER_CONF_U_ID, $USER_PERS_EXT_ID, $c, $c2; - $LC_EMAIL = strtolower($USER_EMAIL); - - if (! $USER_EMAIL) { - $goo = substr($USER_GOO, 3); - $q0 = "SELECT email FROM conf_users WHERE goo='{$goo}'"; - $temp_usr = single_row_select($q0,0,$c2); - - if (is_null($temp_usr)) { - // we have a new user here... - // and the missing email might be a problem.... - insert_new_user(); - } - //echo($goo); - //print_r($temp_usr); - //echo($temp_usr->email); - //echo("\n"); - $LC_EMAIL = strtolower($temp_usr['email']); - } - - $usr_check = single_row_select("SELECT id FROM conf_users WHERE LOWER(email)='{$LC_EMAIL}';",0,$c2); - if (is_null($usr_check)) { - // we have a new user here... - insert_new_user(); - } - - //$q1 = "SELECT last_name, first_name, department, extension, phone_number, email, room, user_id, time_updated, id, web_on, status FROM personnel WHERE LOWER(email)='{$LC_EMAIL}'"; - //$usr_dir = single_row_select($q1, 0, $c); - - $q2 = "SELECT id AS conf_id, goo AS conf_goo, email AS conf_email, name AS conf_name, active AS conf_active FROM conf_users WHERE LOWER(email)='{$LC_EMAIL}'"; - $USER = single_row_select($q2, 0, $c2); - //$mega = $_->extend( (object) $usr_dir, (object) $usr_conf ); - - //$q3 = 'SELECT id AS ext_id, personnel AS personnel_id, role, goo_short, c_users AS c_users_id_ext, ilearn_id, sched_alias, dept1, dept2, gtitle, active, use_dir_photo, general_photo_release, etc, espanol, zoom, preferred_contact FROM gavi_personnel_ext WHERE personnel=' . $mega->id . ';'; // c_users={$mega->conf_id}'; - //$usr_ext = single_row_select($q3,0,$c2); - //$mega = $_->extend( (object) $mega, (object) $usr_ext ); - - //$q4 = 'SELECT person, officehours, title, picture, education, bio, courses, personal_page, changed FROM webpages WHERE person=' . $mega->id . ';'; // '{$mega->id}'"; // personnel=1'); - //$usr_web = single_row_select($q4,0,$c); - //$mega = $_->extend( (object) $mega, (object) $usr_web ); - //$USER = $mega; - } - - - - - - -// _____ _____ _ _ _____ _ ______ _ ____ _ _ -// / ____|_ _| \ | |/ ____| | | ____| (_) / __ \| \ | | -// | (___ | | | \| | | __| | | |__ ___ _ __ _ _ __ | | | | \| | -// \___ \ | | | . ` | | |_ | | | __| / __| |/ _` | '_ \ | | | | . ` | -// ____) |_| |_| |\ | |__| | |____| |____ \__ \ | (_| | | | | | |__| | |\ | -// |_____/|_____|_| \_|\_____|______|______| |___/_|\__, |_| |_| \____/|_| \_| -// __/ | -// |___/ -// SSO -// -// Set GLOBAL VARS corresponding to current logged in user. -// They may only edit their own dir info. -// - - - - -if ( $server == 'intranet1.gavilan.edu' ) { // The SSO check should have happened on the actual page. If it gets -// // stuck on an api call the app will break. - if ( session_id() == '' ) { // session_status() == PHP_SESSION_ACTIVE // newer php uses this - require 'mAuth.php'; - $USER_TYPE = $attributes['http://wso2.org/claims/Roles'][0]; - $USER_GOO = $attributes['http://wso2.org/claims/uid'][0]; - $USER_EMAIL = $attributes['http://wso2.org/claims/emailaddress'][0]; - ?> - - first_name, $USER->last_name); - } - -// -// -// -// - - - - +include('single_sign_on.php'); @@ -504,20 +324,20 @@ function check_permission( $acting_user, $target_id, $table ) { // Helper tables // // JOB TITLES LIST -function job_titles() { global $c2; - return multi_row_select("SELECT DISTINCT id, name FROM gavi_titles ORDER BY name",1, $c2); } +function job_titles() { global $c; + return multi_row_select("SELECT DISTINCT id, name FROM gavi_titles ORDER BY name",1, $c); } if (isset($_REQUEST['a']) && $_REQUEST['a']=='get/jobtitles') { echo job_titles(); exit(); } // all SUB MENUS // -function sub_menus() { global $c2; - $ddd = multi_row_select('SELECT * FROM gavi_departments ORDER BY name',0, $c2); - $ttt = multi_row_select('SELECT * FROM gavi_titles ORDER BY name',0, $c2); - $rrr = multi_row_select("SELECT * FROM gavi_roles ORDER BY 'descr'",0, $c2); - $ccc = multi_row_select('SELECT * FROM gavi_committees ORDER BY name',0, $c2); - $sss = multi_row_select('SELECT * FROM conf_sessiontypes ORDER BY id',0, $c2); - $ppp = multi_row_select("SELECT * FROM `conf_sessions` WHERE `type` = '20' OR `type` = '21' ORDER BY starttime",0, $c2); +function sub_menus() { global $c; + $ddd = multi_row_select('SELECT * FROM gavi_departments ORDER BY name',0, $c); + $ttt = multi_row_select('SELECT * FROM gavi_titles ORDER BY name',0, $c); + $rrr = multi_row_select("SELECT * FROM gavi_roles ORDER BY 'descr'",0, $c); + $ccc = multi_row_select('SELECT * FROM gavi_committees ORDER BY name',0, $c); + $sss = multi_row_select('SELECT * FROM conf_sessiontypes ORDER BY id',0, $c); + $ppp = multi_row_select("SELECT * FROM `conf_sessions` WHERE `type` = '20' OR `type` = '21' ORDER BY starttime",0, $c); return json_encode( array( 'departments'=>$ddd, 'titles'=>$ttt, 'roles'=>$rrr, 'committees'=>$ccc, 'sessiontypes'=>$sss, 'parents'=>$ppp ) ); } @@ -528,9 +348,9 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='menus') { echo sub_menus(); exit() // all NAMES // function get_names() { - global $c2, $AY, $USER; + global $c, $AY, $USER; $q = "SELECT u.id, u.name FROM conf_users AS u ORDER BY u.name"; - echo json_encode( array("users"=>multi_row_select($q,0,$c2), "result"=>"success","err"=>mysqli_error($c2))); + echo json_encode( array("users"=>multi_row_select($q,0,$c), "result"=>"success","err"=>mysqli_error($c))); exit(); } if (isset($_GET['a']) && $_GET['a'] == 'get/names') { get_names(); } @@ -539,8 +359,8 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/names') { get_names(); } // get most RECENT LOGS // function get_recent_logs() { - global $c2, $USER; - $my_sessions = multi_row_select("SELECT * FROM `gavi_logs` ORDER BY `id` DESC LIMIT 150",0,$c2); + global $c, $USER; + $my_sessions = multi_row_select("SELECT * FROM `gavi_logs` ORDER BY `id` DESC LIMIT 150",0,$c); echo json_encode($my_sessions); exit(); } if (isset($_GET['a']) && $_GET['a'] == 'get/logs') { get_recent_logs(); } @@ -549,7 +369,7 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/logs') { get_recent_logs(); } // gavilan college EVENTS // function get_events() { global $c; - echo json_encode( multi_row_select("SELECT * FROM events WHERE date >= CURDATE() AND visible='1' ORDER BY time LIMIT 6;",0, $c)); } + echo json_encode( multi_row_select("SELECT * FROM events WHERE date >= CURDATE() AND visible='1' ORDER BY time LIMIT 6;",0)); } if (isset($_GET['a']) && $_GET['a'] == 'get/gavevents') { get_events(); exit(); } @@ -628,8 +448,8 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='signups') { // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Courses in a semester -function semester_sections() { global $c2; - return multi_row_select("SELECT * FROM `gavi_sections` s WHERE s.sem='fa21' ORDER BY s.teacher_id",1, $c2); } +function semester_sections() { global $c; + return multi_row_select("SELECT * FROM `gavi_sections` s WHERE s.sem='fa21' ORDER BY s.teacher_id",1, $c); } if (isset($_REQUEST['a']) && $_REQUEST['a']=='list/semester') { echo semester_sections(); exit(); } @@ -658,16 +478,16 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='list/staffsemester') { // // SEARCH AN INSTRUCTOR BY NAME IN SCHEDULE // -function get_instructor() { global $c2; +function get_instructor() { global $c; $i = ok($_REQUEST['inst']); - echo json_encode( single_row_select("SELECT * FROM gavi_personnel_ext WHERE sched_alias='{$i}';",0, $c2)); + echo json_encode( single_row_select("SELECT * FROM gavi_personnel_ext WHERE sched_alias='{$i}';",0)); exit(); } if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'get/instructor/name' ) { get_instructor(); } function get_instructor_fuzzy() { - global $c2; + global $c; $i = ok($_REQUEST['inst']); - echo json_encode( single_row_select("SELECT * FROM gavi_personnel_ext WHERE sched_alias LIKE '{$i}';",0, $c2)); + echo json_encode( single_row_select("SELECT * FROM gavi_personnel_ext WHERE sched_alias LIKE '{$i}';",0)); exit(); } if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'get/instructor/fuzzyname' ) { get_instructor_fuzzy(); } @@ -678,7 +498,7 @@ if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'get/instructor/fuzzyname' ) { ge // function get_sections($semester) { global $c; $semester = ok($semester); - return multi_row_select("SELECT s.id,s.code,s.name,s.descr,s.teacher_id,s.days,s.start_date,s.end_date,s.units,s.ztc,s.location,s.delivery,s.status,s.pnp,s.note,s.crn,s.sem,p.personnel AS personnel_id,p.use_dir_photo,p.dir_photo_path,d.last_name,d.first_name,d.phone_number,d.email,d.room,d.web_on,s.sem FROM PeterDB.gavi_sections s LEFT JOIN PeterDB.gavi_personnel_ext p ON s.teacher_id=p.id LEFT JOIN personnel d ON d.id=p.personnel WHERE sem='{$semester}' ORDER BY code;",0, $c); } + return multi_row_select("SELECT s.id,s.code,s.name,s.descr,s.teacher_id,s.days,s.start_date,s.end_date,s.units,s.ztc,s.location,s.delivery,s.status,s.pnp,s.note,s.crn,s.sem,p.personnel AS personnel_id,p.use_dir_photo,p.dir_photo_path,d.last_name,d.first_name,d.phone_number,d.email,d.room,d.web_on,s.sem FROM PeterDB.gavi_sections s LEFT JOIN PeterDB.gavi_personnel_ext p ON s.teacher_id=p.id LEFT JOIN personnel d ON d.id=p.personnel WHERE sem='{$semester}' ORDER BY code;",0); } if (isset($_REQUEST['a']) && preg_match('/^get\/sections\/(\w\w\d\d)$/', $_REQUEST['a'], $matches)) { echo json_encode( get_sections( $matches[1] ) ); exit(); } @@ -687,7 +507,7 @@ if (isset($_REQUEST['a']) && preg_match('/^get\/sections\/(\w\w\d\d)$/', $_REQUE // all COURSE SECTIONS by semester and crn only // function get_all_sections() { global $c; - echo json_encode( multi_row_select("SELECT s.id,s.code,s.crn,s.sem,s.teacher_id,s.delivery,s.status,p.personnel AS personnel_id,d.last_name,d.first_name FROM PeterDB.gavi_sections s LEFT JOIN PeterDB.gavi_personnel_ext p ON s.teacher_id=p.id LEFT JOIN personnel d ON d.id=p.personnel ORDER BY sem,code;",0, $c)); + echo json_encode( multi_row_select("SELECT s.id,s.code,s.crn,s.sem,s.teacher_id,s.delivery,s.status,p.personnel AS personnel_id,d.last_name,d.first_name FROM PeterDB.gavi_sections s LEFT JOIN PeterDB.gavi_personnel_ext p ON s.teacher_id=p.id LEFT JOIN personnel d ON d.id=p.personnel ORDER BY sem,code;",0)); exit(); } if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'get/sections') { get_all_sections(); } @@ -700,7 +520,7 @@ if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'get/sections') { get_all_section // function get_instructor_sections($teacherid) { global $c; - echo json_encode( multi_row_select("SELECT s.id,s.code,s.name,s.descr,s.teacher_id,s.days,s.times,s.link,s.start_date,s.end_date,s.units,s.ztc,s.location,s.delivery,s.xlist_to,s.status,s.pnp,s.note,s.crn,s.sem,s.year FROM PeterDB.gavi_sections s WHERE s.teacher_id='{$teacherid}' ORDER BY s.sem,s.code;",0, $c)); + echo json_encode( multi_row_select("SELECT s.id,s.code,s.name,s.descr,s.teacher_id,s.days,s.times,s.link,s.start_date,s.end_date,s.units,s.ztc,s.location,s.delivery,s.xlist_to,s.status,s.pnp,s.note,s.crn,s.sem,s.year FROM PeterDB.gavi_sections s WHERE s.teacher_id='{$teacherid}' ORDER BY s.sem,s.code;",0)); exit(); } if (isset($_REQUEST['a']) && preg_match('/^get\/sections\/(\d+)$/', $_REQUEST['a'], $matches)) { get_instructor_sections( $matches[1] ); } @@ -714,19 +534,19 @@ if (isset($_REQUEST['a']) && preg_match('/^get\/sections\/(\d+)$/', $_REQUEST['a // // function get_section($sem,$crn) { - global $c, $c2; + global $c, $c; $sem = ok($sem); $crn = ok($crn); $sched_id = 0; - $sched_entry = single_row_select( "SELECT * FROM PeterDB.gavi_sections gs WHERE sem='{$sem}' AND crn='{$crn}';",0, $c2); + $sched_entry = single_row_select( "SELECT * FROM PeterDB.gavi_sections gs WHERE sem='{$sem}' AND crn='{$crn}';",0); if ($sched_entry) { $sched_id = $sched_entry['id']; } else { echo json_encode( array( "result"=>"fail", "reason"=>"no row for that section {$sem} {$crn}.") ); exit(); } - $wl_entry = single_row_select( "SELECT s.id,s.code,s.name,s.descr,s.teacher_id,s.days,s.start_date,s.end_date,s.units,s.ztc,s.location,s.delivery,s.status,s.pnp,s.note,s.crn,s.sem,w.id AS wl_id,w.photo_path,w.format,w.length,w.course_desc,w.what_expect,w.assessments,w.textbook,w.other_info,w.introduction,w.additional_resources FROM PeterDB.gavi_welcome_letters w LEFT JOIN PeterDB.gavi_sections s ON w.section_id=s.id WHERE w.section_id='{$sched_id}';",0, $c2); + $wl_entry = single_row_select( "SELECT s.id,s.code,s.name,s.descr,s.teacher_id,s.days,s.start_date,s.end_date,s.units,s.ztc,s.location,s.delivery,s.status,s.pnp,s.note,s.crn,s.sem,w.id AS wl_id,w.photo_path,w.format,w.length,w.course_desc,w.what_expect,w.assessments,w.textbook,w.other_info,w.introduction,w.additional_resources FROM PeterDB.gavi_welcome_letters w LEFT JOIN PeterDB.gavi_sections s ON w.section_id=s.id WHERE w.section_id='{$sched_id}';",0); if ($wl_entry) { echo json_encode($wl_entry); @@ -745,11 +565,11 @@ function get_section($sem,$crn) { $default->additional_resources = okh($default->additional_resources); $q = "INSERT INTO PeterDB.gavi_welcome_letters (section_id,format,length,text_title,course_desc,what_expect,assessments,textbook,other_info,introduction,additional_resources) VALUES ('{$sched_id}', '', '', '', '', '{$default->what_expect}', '{$default->assessments}', '{$default->textbook}', '{$default->other_info}', '{$default->introduction}', '{$default->additional_resources}');"; - $new_id = single_row_insert($q,0,$c2); + $new_id = single_row_insert($q,0,$c); $q4 = "SELECT s.id,s.code,s.name,s.descr,s.teacher_id,s.days,s.start_date,s.end_date,s.units,s.ztc,s.location,s.delivery,s.status,s.pnp,s.note,s.crn,s.sem,w.id AS wl_id, w.photo_path,w.format,w.length,w.course_desc,w.what_expect,w.assessments,w.textbook,w.other_info,w.introduction,w.additional_resources FROM PeterDB.gavi_welcome_letters w LEFT JOIN PeterDB.gavi_sections s ON w.section_id=s.id WHERE w.id=" . $new_id . ";"; - $wl_entry = single_row_select( $q4, 0, $c2); + $wl_entry = single_row_select( $q4, 0); echo json_encode($wl_entry); exit(); } } @@ -764,7 +584,7 @@ if (isset($_REQUEST['a']) && preg_match('/^get\/section\/(\w\w\d\d)\/(\d+)$/', $ // // update a course section record /*function update_section($update=1) { - global $USER, $c2; + global $USER, $c; $WHERECLAUSE = ""; $START = "INSERT INTO gavi_sections SET "; $action = "inserted"; @@ -789,9 +609,9 @@ if (isset($_REQUEST['a']) && preg_match('/^get\/section\/(\w\w\d\d)\/(\d+)$/', $ $q = substr($q, 0, -2); $q .= $WHERECLAUSE; - single_row_insert($q,0,$c2); + single_row_insert($q,0,$c); echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>$action, - "logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2))); + "logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c))); exit(); } @@ -808,7 +628,7 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='add/section') { update_section(0); // update a WELCOME LETTER // /*function update_welcome_letter($update=1) { - global $USER, $c2, $_; + global $USER, $c, $_; $WHERECLAUSE = ""; $START = "INSERT INTO gavi_welcome_letters SET "; $action = "inserted"; @@ -833,9 +653,9 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='add/section') { update_section(0); $q = substr($q, 0, -2); $q .= $WHERECLAUSE; - single_row_insert($q,0,$c2); + single_row_insert($q,0,$c); echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>$action, - "logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2))); + "logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c))); exit(); } @@ -871,13 +691,13 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='add/letter') { update_welcome_lett // // GET LIST OF ALL SESSIONS / WORKSHOPS / EVENTS // -function get_sessions() { global $c2, $AY; - return multi_row_select("SELECT c.id,c.title,c.desc,c.length,c.starttime,c.track,c.location,c.location_irl,c.mode,c.gets_survey,c.category,c.parent,c.recording,c.instructions,c.image_url,c.is_flex_approved,c.cal_uid,sst.type AS typeStr, sst.id AS type, GROUP_CONCAT(ctg.tag) AS tags FROM conf_sessions c LEFT JOIN conf_sessiontypes sst ON c.type=sst.id LEFT JOIN conf_tagmember ct ON c.id=ct.session LEFT JOIN conf_tags ctg ON ctg.id=ct.tag WHERE c.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) GROUP BY c.id ORDER BY c.track, c.starttime;",0, $c2); } +function get_sessions() { global $c, $AY; + return multi_row_select("SELECT c.id,c.title,c.desc,c.length,c.starttime,c.track,c.location,c.location_irl,c.mode,c.gets_survey,c.category,c.parent,c.recording,c.instructions,c.image_url,c.is_flex_approved,c.cal_uid,sst.type AS typeStr, sst.id AS type, GROUP_CONCAT(ctg.tag) AS tags FROM conf_sessions c LEFT JOIN conf_sessiontypes sst ON c.type=sst.id LEFT JOIN conf_tagmember ct ON c.id=ct.session LEFT JOIN conf_tags ctg ON ctg.id=ct.tag WHERE c.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) GROUP BY c.id ORDER BY c.track, c.starttime;",0); } if (isset($_GET['a']) && $_GET['a'] == 'get/sessions') { echo json_encode(get_sessions()); exit(); } -function multi_row_1d($qry, $c) { +function multi_row_1d($qry) { global $c; $savedQuery = mysqli_query($c, $qry); while($savedResult = mysqli_fetch_array($savedQuery)) { $savedArray[] = $savedResult[0]; } @@ -890,17 +710,17 @@ function multi_row_1d($qry, $c) { // // GET LIST OF ALL SESSIONS + HOSTS // -function get_ses_hosts() { global $c2, $AY; - return multi_row_select("select s.id, s.title, s.starttime, u.name, u.email, u.id AS hostid from conf_sessions as s LEFT OUTER JOIN conf_hosts as h ON h.session=s.id LEFT OUTER JOIN conf_users AS u ON h.host=u.id WHERE s.id>1319 ORDER BY u.name;",1, $c2); } - //return multi_row_1d("select DISTINCT(u.email) from conf_sessions as s LEFT OUTER JOIN conf_hosts as h ON h.session=s.id LEFT OUTER JOIN conf_users AS u ON h.host=u.id WHERE s.id>1319 ORDER BY u.name;", $c2); } +function get_ses_hosts() { global $c, $AY; + return multi_row_select("select s.id, s.title, s.starttime, u.name, u.email, u.id AS hostid from conf_sessions as s LEFT OUTER JOIN conf_hosts as h ON h.session=s.id LEFT OUTER JOIN conf_users AS u ON h.host=u.id WHERE s.id>1319 ORDER BY u.name;",1); } + //return multi_row_1d("select DISTINCT(u.email) from conf_sessions as s LEFT OUTER JOIN conf_hosts as h ON h.session=s.id LEFT OUTER JOIN conf_users AS u ON h.host=u.id WHERE s.id>1319 ORDER BY u.name;"); } if (isset($_GET['a']) && $_GET['a'] == 'get/hosts') { echo get_ses_hosts(); exit(); } // // ALL HOST ENTRIES // -/*function get_all_hosts() { global $c2, $_; - $hh = multi_row_select("select host,session FROM conf_hosts ORDER BY host;",0, $c2); +/*function get_all_hosts() { global $c, $_; + $hh = multi_row_select("select host,session FROM conf_hosts ORDER BY host;",0); $byhost = $_->groupBy($hh, function($n) { return $n['host']; }); $_->map( $byhost, function($v,$k) use (&$allhost) { global $_; $allhost[$k] = $_->pluck($v,'session'); @@ -915,8 +735,8 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/allhosts') { echo json_encode(get_al // // LIST THE CURRENT USER'S SIGNED UP, (OR HOSTING,) SESSIONS / WORKSHOPS / EVENTS // -function get_user_sessions() { global $c2, $AY, $USER; - $my_sessions = multi_row_select("SELECT c.id,c.title,c.desc,c.length,c.starttime,c.track,c.location,c.location_irl,c.mode,c.gets_survey,c.category,c.parent,c.recording,c.instructions,c.image_url,c.is_flex_approved,sst.type,sst.id AS typeId, GROUP_CONCAT(ctg.tag) AS tags FROM conf_sessions c JOIN conf_signups as sup on c.id=sup.session LEFT JOIN conf_hosts as h ON h.session=c.id JOIN conf_sessiontypes sst ON c.type=sst.id LEFT JOIN conf_tagmember ct ON c.id=ct.session LEFT JOIN conf_tags ctg ON ctg.id=ct.tag WHERE (h.host='{$USER->conf_id}' OR sup.user='{$USER->conf_id}') AND c.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) GROUP BY c.id ORDER BY c.track, c.starttime;",0,$c2); +function get_user_sessions() { global $c, $AY, $USER; + $my_sessions = multi_row_select("SELECT c.id,c.title,c.desc,c.length,c.starttime,c.track,c.location,c.location_irl,c.mode,c.gets_survey,c.category,c.parent,c.recording,c.instructions,c.image_url,c.is_flex_approved,sst.type,sst.id AS typeId, GROUP_CONCAT(ctg.tag) AS tags FROM conf_sessions c JOIN conf_signups as sup on c.id=sup.session LEFT JOIN conf_hosts as h ON h.session=c.id JOIN conf_sessiontypes sst ON c.type=sst.id LEFT JOIN conf_tagmember ct ON c.id=ct.session LEFT JOIN conf_tags ctg ON ctg.id=ct.tag WHERE (h.host='{$USER->conf_id}' OR sup.user='{$USER->conf_id}') AND c.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) GROUP BY c.id ORDER BY c.track, c.starttime;",0,$c); echo json_encode($my_sessions); exit(); } if (isset($_GET['a']) && $_GET['a'] == 'get/mysessions') { get_user_sessions(); } @@ -925,7 +745,7 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/mysessions') { get_user_sessions(); // // GET ROSTERS OF ALL SESSIONS function get_rosters() { - global $AY, $c2; + global $AY, $c; /* "SELECT i.user, i.session, i.timestamp, u.goo, u.email, u.name, s.title, s.track, s.starttime, s.location, s.id AS sesid FROM conf_signups as i LEFT JOIN conf_users as u ON i.user=u.id RIGHT JOIN conf_sessions as s ON i.session=s.id WHERE s.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) {$where} ORDER BY sesid;" */ @@ -934,7 +754,7 @@ function get_rosters() { $ID = ok($_REQUEST['id']); $where = "AND s.id={$ID}"; } return multi_row_select( - "SELECT i.user, i.session, u.goo, u.email, u.name, s.id AS sesid FROM conf_signups as i LEFT JOIN conf_users as u ON i.user=u.id RIGHT JOIN conf_sessions as s ON i.session=s.id WHERE s.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) {$where} ORDER BY sesid;",0,$c2); } + "SELECT i.user, i.session, u.goo, u.email, u.name, s.id AS sesid FROM conf_signups as i LEFT JOIN conf_users as u ON i.user=u.id RIGHT JOIN conf_sessions as s ON i.session=s.id WHERE s.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) {$where} ORDER BY sesid;",0,$c); } if (isset($_GET['a']) && $_GET['a'] == 'get/rosters') { echo json_encode(get_rosters()); exit(); } @@ -943,13 +763,13 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/rosters') { echo json_encode(get_ros // // GET ALL SIGNUPS function get_signups() { - global $AY, $c2; + global $AY, $c; $where = ''; if (isset($_REQUEST['id'])) { $ID = ok($_REQUEST['id']); $where = "WHERE s.id={$ID}"; } return multi_row_select( - "SELECT i.id, i.user, i.session, i.timestamp, i.certified_at, i.badged_at, i.not_flex FROM conf_signups AS i JOIN conf_sessions AS s ON i.session=s.id WHERE s.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) {$where} ORDER BY i.id DESC;",0,$c2); } + "SELECT i.id, i.user, i.session, i.timestamp, i.certified_at, i.badged_at, i.not_flex FROM conf_signups AS i JOIN conf_sessions AS s ON i.session=s.id WHERE s.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) {$where} ORDER BY i.id DESC;",0,$c); } if (isset($_GET['a']) && $_GET['a'] == 'get/signups') { echo json_encode(get_signups()); exit(); } @@ -958,9 +778,9 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/signups') { echo json_encode(get_sig // // GET ALL USERS function get_users() { - global $AY, $c2; + global $AY, $c; return multi_row_select( - "SELECT * FROM conf_users AS u ORDER BY u.email;",0,$c2); } + "SELECT * FROM conf_users AS u ORDER BY u.email;",0,$c); } if (isset($_GET['a']) && $_GET['a'] == 'get/users') { echo json_encode(get_users()); exit(); } @@ -968,9 +788,9 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/users') { echo json_encode(get_users // // GET ALL HOSTS function get_hosttable() { - global $AY, $c2; + global $AY, $c; return multi_row_select( - "SELECT * FROM conf_hosts;",0,$c2); } + "SELECT * FROM conf_hosts;",0,$c); } if (isset($_GET['a']) && $_GET['a'] == 'get/hosttable') { echo json_encode(get_hosttable()); exit(); } @@ -985,8 +805,8 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/hosttable') { echo json_encode(get_h // all years // function get_anyuser_sessions($usr) { - global $c2, $AY, $USER; - $my_sessions = multi_row_select("SELECT c.id,c.title,c.desc,c.length,c.starttime,c.track,c.location,c.location_irl,c.mode,c.gets_survey,c.category,c.parent,c.recording,c.instructions,c.image_url,c.is_flex_approved,sst.type,sst.id AS typeId, GROUP_CONCAT(ctg.tag) AS tags FROM conf_sessions c JOIN conf_signups as sup on c.id=sup.session LEFT JOIN conf_hosts as h ON h.session=c.id JOIN conf_sessiontypes sst ON c.type=sst.id LEFT JOIN conf_tagmember ct ON c.id=ct.session LEFT JOIN conf_tags ctg ON ctg.id=ct.tag WHERE (h.host='{$usr}' OR sup.user='{$usr}') GROUP BY c.id ORDER BY c.starttime LIMIT 150;",0,$c2); + global $c, $AY, $USER; + $my_sessions = multi_row_select("SELECT c.id,c.title,c.desc,c.length,c.starttime,c.track,c.location,c.location_irl,c.mode,c.gets_survey,c.category,c.parent,c.recording,c.instructions,c.image_url,c.is_flex_approved,sst.type,sst.id AS typeId, GROUP_CONCAT(ctg.tag) AS tags FROM conf_sessions c JOIN conf_signups as sup on c.id=sup.session LEFT JOIN conf_hosts as h ON h.session=c.id JOIN conf_sessiontypes sst ON c.type=sst.id LEFT JOIN conf_tagmember ct ON c.id=ct.session LEFT JOIN conf_tags ctg ON ctg.id=ct.tag WHERE (h.host='{$usr}' OR sup.user='{$usr}') GROUP BY c.id ORDER BY c.starttime LIMIT 150;",0,$c); // AND c.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME) return $my_sessions; } @@ -994,25 +814,25 @@ if (isset($_GET['a']) && preg_match('/get\/sessions\/(\d+)$/', $_GET['a'], $matc // MY Survey ANSWERS -function get_questions() { global $c2, $USER; +function get_questions() { global $c, $USER; //return $USER->id; - return multi_row_select( "SELECT ses.id as ses_id, sup.id as sup_id, sup.certified_at as cert, sup.surveyed_at as surveyed, cus.id as user, qset.order, qq.id, qq.question, qq.type, qq.id as qid, ans.answer FROM conf_sessions as ses JOIN conf_signups as sup on ses.id = sup.session JOIN conf_users as cus on cus.id = sup.user JOIN conf_q_set as qset on ses.gets_survey = qset.q_set RIGHT JOIN conf_questions as qq on qset.question = qq.id LEFT OUTER JOIN conf_answers as ans on ans.user = sup.user AND ans.question = qq.id AND ans.session = ses.id WHERE (cus.id='{$USER->conf_id}') ORDER BY ses.starttime, ses.track asc, qset.order", 0, $c2); } + return multi_row_select( "SELECT ses.id as ses_id, sup.id as sup_id, sup.certified_at as cert, sup.surveyed_at as surveyed, cus.id as user, qset.order, qq.id, qq.question, qq.type, qq.id as qid, ans.answer FROM conf_sessions as ses JOIN conf_signups as sup on ses.id = sup.session JOIN conf_users as cus on cus.id = sup.user JOIN conf_q_set as qset on ses.gets_survey = qset.q_set RIGHT JOIN conf_questions as qq on qset.question = qq.id LEFT OUTER JOIN conf_answers as ans on ans.user = sup.user AND ans.question = qq.id AND ans.session = ses.id WHERE (cus.id='{$USER['conf_id']}') ORDER BY ses.starttime, ses.track asc, qset.order", 0); } if (isset($_GET['a']) && $_GET['a'] == 'get/questions') { echo json_encode(get_questions()); exit(); } // Single session QUESTIONS and possibly ansers -function get_session_questions($id) { global $c2, $USER; +function get_session_questions($id) { global $c, $USER; //print_r($USER); exit(); - $u = $USER->conf_id; - return multi_row_select( "SELECT ses.title, {$u} AS user, ses.id as session, q.id AS qid, q.question, q.type, ans.answer FROM conf_sessions AS ses JOIN conf_q_set AS qset ON ses.gets_survey=qset.q_set JOIN conf_questions AS q ON q.id=qset.question LEFT OUTER JOIN conf_answers AS ans ON ans.user={$u} AND ans.question=q.id AND ans.session=ses.id WHERE ses.id={$id}", 0, $c2); } + $u = $USER['conf_id']; + return multi_row_select( "SELECT ses.title, {$u} AS user, ses.id as session, q.id AS qid, q.question, q.type, ans.answer FROM conf_sessions AS ses JOIN conf_q_set AS qset ON ses.gets_survey=qset.q_set JOIN conf_questions AS q ON q.id=qset.question LEFT OUTER JOIN conf_answers AS ans ON ans.user={$u} AND ans.question=q.id AND ans.session=ses.id WHERE ses.id={$id}", 0); } if (isset($_GET['a'])&& preg_match('/get\/questions\/(\d+)$/', $_GET['a'], $matches)) { echo json_encode(get_session_questions($matches[1])); exit(); } // ALL Survey ANSWERS -function get_answers_all() { global $c2; - return multi_row_select( "SELECT ses.id AS ses_id, ses.title as s_title, ses.starttime, qq.id as q_id, qq.question as question, qq.type as type, ans.answer AS answer FROM conf_sessions AS ses JOIN conf_signups as sup on ses.id = sup.session JOIN conf_users as cus on cus.id = sup.user JOIN conf_q_set as qset on ses.gets_survey = qset.q_set RIGHT JOIN conf_questions as qq on qset.question = qq.id LEFT OUTER JOIN conf_answers as ans on ans.user = sup.user AND ans.question = qq.id AND ans.session = ses.id WHERE ans.answer is not null ORDER BY ses.starttime, ses.track asc, qset.order", 0, $c2); } +function get_answers_all() { global $c; + return multi_row_select( "SELECT ses.id AS ses_id, ses.title as s_title, ses.starttime, qq.id as q_id, qq.question as question, qq.type as type, ans.answer AS answer FROM conf_sessions AS ses JOIN conf_signups as sup on ses.id = sup.session JOIN conf_users as cus on cus.id = sup.user JOIN conf_q_set as qset on ses.gets_survey = qset.q_set RIGHT JOIN conf_questions as qq on qset.question = qq.id LEFT OUTER JOIN conf_answers as ans on ans.user = sup.user AND ans.question = qq.id AND ans.session = ses.id WHERE ans.answer is not null ORDER BY ses.starttime, ses.track asc, qset.order", 0); } if (isset($_GET['a']) && $_GET['a'] == 'get/answers/all') { echo json_encode(get_answers_all()); exit(); } @@ -1021,24 +841,24 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/answers/all') { echo json_encode(get // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // -function set_answers() { global $c, $c2; +function set_answers() { global $c; $ses_id = ok($_REQUEST['session']); $u = ok($_REQUEST['user']); $q = ok($_REQUEST['qid']); $answer = ok($_REQUEST['answer']); - $existing = does_exist( "select * from `conf_answers` where `user`='$u' and `session`='$ses_id' and `question`='$q';",0,$c2 ); + $existing = does_exist( "select * from `conf_answers` where `user`='$u' and `session`='$ses_id' and `question`='$q';",0,$c ); if ($existing) { $qupdate = "UPDATE conf_answers SET answer='$answer' WHERE session=$ses_id AND user=$u AND question=$q"; - single_row_update($qupdate,0, $c2); + single_row_update($qupdate,0); $logaction = log_it("updated answer for session: $ses_id"); } else { $qupdate = "INSERT INTO conf_answers SET user='$u', question='$q', session='$ses_id', answer='$answer'"; - single_row_insert($qupdate,0,$c2); + single_row_insert($qupdate,0,$c); $logaction = log_it("Saved answer for session: $ses_id"); } - echo json_encode( array("result"=>"success", "logaction"=>$logaction, "action"=>"save survey answer","query"=>$qupdate,"err"=>mysqli_error($c2))); + echo json_encode( array("result"=>"success", "logaction"=>$logaction, "action"=>"save survey answer","query"=>$qupdate,"err"=>mysqli_error($c))); exit(); } if (isset($_REQUEST['a']) && $_REQUEST['a']=='update/answers') { set_answers(); } @@ -1049,15 +869,15 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='update/answers') { set_answers(); function set_cert() { #echo "saving"; - global $USER, $c2; + global $USER, $c; $ses_id = ok($_REQUEST['ses_id']); $cert = ok($_REQUEST['cert']); $date = "'" . date('Y-m-d H:i:s') . "'"; if ($cert=="null") { $date = "NULL"; } $qupdate = "UPDATE conf_signups SET `certified_at`=$date where `user`='$USER' and `session`='$ses_id'"; - single_row_update($qupdate, 0, $c2); + single_row_update($qupdate, 0); $logaction = log_it("updated certified state for session: $ses_id"); - echo json_encode( array("result"=>"success", "logaction"=>$logaction, "action"=>"save cert","query"=>$qupdate,"err"=>mysqli_error($c2))); + echo json_encode( array("result"=>"success", "logaction"=>$logaction, "action"=>"save cert","query"=>$qupdate,"err"=>mysqli_error($c))); //print_r($_POST); exit(); } @@ -1072,7 +892,7 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='set/cert') { set_cert(); } // SIGNUP for (possibly overlapping time) session ... /// id_c_users // function signup() { - global $c2, $AY, $USER; + global $c, $AY, $USER; preg_match('/signup\/(\d+)$/', $_GET['a'], $matches); $ses = $matches[1]; $ts = date("Y-m-d H:i:s"); @@ -1082,16 +902,16 @@ function signup() { if (isset($_SESSION)) { $sesh = $_SESSION; } $existing = does_exist( - "SELECT i.id FROM conf_signups AS i JOIN conf_sessions AS s ON i.session=s.id WHERE s.id={$ses} AND i.user=" . $USER->conf_id,0,$c2); + "SELECT i.id FROM conf_signups AS i JOIN conf_sessions AS s ON i.session=s.id WHERE s.id={$ses} AND i.user=" . $USER['conf_id'],0,$c); if ($existing) { - $qupdate = "UPDATE conf_signups SET session={$ses}, timestamp='{$ts}' WHERE session={$ses} AND user=" . $USER->conf_id; - single_row_select($qupdate,1,$c2); - echo json_encode( array("result"=>"success","action"=>"updated","logaction"=>$logaction, "query"=>$qupdate,"err"=>mysqli_error($c2))); + $qupdate = "UPDATE conf_signups SET session={$ses}, timestamp='{$ts}' WHERE session={$ses} AND user=" . $USER['conf_id']; + single_row_select($qupdate,1,$c); + echo json_encode( array("result"=>"success","action"=>"updated","logaction"=>$logaction, "query"=>$qupdate,"err"=>mysqli_error($c))); } else { - $q = "INSERT INTO conf_signups (session,user,timestamp) VALUES ({$ses}," . $USER->conf_id . ",'{$ts}')"; - single_row_insert($q,1,$c2); + $q = "INSERT INTO conf_signups (session,user,timestamp) VALUES ({$ses}," . $USER['conf_id'] . ",'{$ts}')"; + single_row_insert($q,1,$c); echo json_encode( array( /* "userglobal"=>$USER, */ "result"=>"success","action"=>"inserted", /* "logaction"=>$logaction, */ - "ses"=>$sesh,"query"=>$q,"err"=>mysqli_error($c2))); + "ses"=>$sesh,"query"=>$q,"err"=>mysqli_error($c))); } exit(); } if (isset($_GET['a']) && preg_match('/signup\/(\d+)$/', $_GET['a'], $matches)) { signup(); } @@ -1103,14 +923,14 @@ if (isset($_GET['a']) && preg_match('/signup\/(\d+)$/', $_GET['a'], $matches)) { // CANCEL a signup // function signdown() { - global $c2, $AY, $USER; + global $c, $AY, $USER; preg_match('/signdown\/(\d+)$/', $_GET['a'], $matches); $ses = $matches[1]; - $q = "DELETE FROM conf_signups WHERE session={$ses} AND user=" . $USER->conf_id; - single_row_update($q,1,$c2); + $q = "DELETE FROM conf_signups WHERE session={$ses} AND user=" . $USER['conf_id']; + single_row_update($q,1); $logaction = log_it("Canceled signup for session: $ses"); - echo json_encode( array("result"=>"success","action"=>"deleted","logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2))); + echo json_encode( array("result"=>"success","action"=>"deleted","logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c))); exit(); } if (isset($_GET['a']) && preg_match('/signdown\/(\d+)$/', $_GET['a'], $matches)) { signdown(); } @@ -1122,14 +942,14 @@ if (isset($_GET['a']) && preg_match('/signdown\/(\d+)$/', $_GET['a'], $matches)) // add a HOST for a session ... // function addhost($sesid,$hostid) { - global $c2; + global $c; $sesid = ok($sesid); $hostid = ok($hostid); - $existing = does_exist("SELECT h.host, h.session FROM conf_hosts AS h WHERE h.host={$hostid} AND h.session={$sesid}",0,$c2); + $existing = does_exist("SELECT h.host, h.session FROM conf_hosts AS h WHERE h.host={$hostid} AND h.session={$sesid}",0,$c); if ($existing) { return array("result"=>"success","action"=>"already a host"); } else { $qupdate = "INSERT INTO conf_hosts SET session='{$sesid}', host='{$hostid}';"; - $new_id = single_row_insert($qupdate,0,$c2); - $e = mysqli_error($c2); + $new_id = single_row_insert($qupdate,0,$c); + $e = mysqli_error($c); if ($new_id) { $success = " with new id {$new_id}"; } else { $success = " -- error: {$e}"; } $logaction = log_it("Added host {$hostid} to session: {$sesid}"); @@ -1144,11 +964,11 @@ if (isset($_GET['a']) && preg_match('/add\/host\/(\d+)\/(\d+)$/', $_GET['a'], $m // REMOVE a HOST for a session ... // function removehost($sesid,$hostid) { - global $c2; + global $c; $sesid = ok($sesid); $hostid = ok($hostid); $qupdate = "DELETE FROM conf_hosts WHERE session='{$sesid}' AND host='{$hostid}';"; - $new_id = single_row_update($qupdate,0,$c2); - $e = mysqli_error($c2); + $new_id = single_row_update($qupdate,0); + $e = mysqli_error($c); $logaction = log_it("Removed host {$hostid} to session: {$sesid}"); return array("result"=>"success","action"=>"removed host","query"=>$qupdate,"err"=>$e); } @@ -1166,7 +986,7 @@ if (isset($_GET['a']) && preg_match('/remove\/host\/(\d+)\/(\d+)$/', $_GET['a'], // NEW SESSION // function new_session() { - global $c2, $AY, $USER; + global $c, $AY, $USER; $title = ok($_POST['title']); $starttime = ok($_POST['starttime']); @@ -1185,9 +1005,9 @@ function new_session() { $q = "INSERT INTO conf_sessions (`title`,`starttime`,`length`,`track`,`gets_survey`,`is_flex_approved`,`category`,`author`,`is_custom`,`parent`,`desc`,`location`,`mode`,`recording`,`instructions`,`type`,`cal_uid`) VALUES ('{$title}', '{$starttime}', '{$length}', '{$track}', '{$gets_survey}', '{$is_flex_approved}', '{$category}', '{$author}', '{$is_custom}', '{$parent}', '{$desc}', '{$location}', '{$location_irl}', '{$mode}', '{$recording}', '{$instructions}', '{$type}', '{$cal_uid}');"; - $ins = single_row_insert($q,0,$c2); + $ins = single_row_insert($q,0,$c); $logaction = log_it("created new session id: {$ins}: {$title}"); - echo json_encode( array( /*"all_args"=>$_POST,*/ "result"=>"success","action"=>"inserted new session","new_id"=>$ins, "query"=>$q,"logaction"=>$logaction,"err"=>mysqli_error($c2))); + echo json_encode( array( /*"all_args"=>$_POST,*/ "result"=>"success","action"=>"inserted new session","new_id"=>$ins, "query"=>$q,"logaction"=>$logaction,"err"=>mysqli_error($c))); exit(); } if (isset($_REQUEST['a']) && $_REQUEST['a']=='set/newsession') { new_session(); } @@ -1204,7 +1024,7 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='set/newsession') { new_session(); function reducer ($memo, $a) { return $memo . "`" . ok($a[0]) . "` = '" . okh($a[1]) . "', "; } function set_sessioninfo() { - global $c, $c2, $AY, $USER, $_; + global $c, $AY, $USER, $_; $table = 'conf_sessions'; $DO_CHECKING = 0; @@ -1226,8 +1046,8 @@ function set_sessioninfo() { $q = array_reduce($cv, 'reducer', "UPDATE `{$table}` SET "); $q = substr($q, 0, -2); $q .= $WHERECLAUSE; - single_row_update($q,0,$c2); - echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated", "query"=>$q,"err"=>mysqli_error($c2))); + single_row_update($q,0); + echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated", "query"=>$q,"err"=>mysqli_error($c))); } } else { echo json_encode( array("result"=>"fail", "err"=>"no activity id specified") ); } @@ -1248,8 +1068,8 @@ if (isset($_REQUEST['a']) && $_REQUEST['a']=='update/activity') { set_sessioninf // // GET -function get_settings() { global $AY, $c2; - return multi_row_select( "SELECT * FROM conf_uinforecord;",0,$c2); } +function get_settings() { global $AY, $c; + return multi_row_select( "SELECT * FROM conf_uinforecord;",0,$c); } if (isset($_GET['a']) && $_GET['a'] == 'get/settings') { echo json_encode(get_settings()); exit(); } @@ -1257,7 +1077,7 @@ if (isset($_GET['a']) && $_GET['a'] == 'get/settings') { echo json_encode(get_se function set_settings() { - global $c, $c2, $AY, $USER, $_; + global $c, $AY, $USER, $_; $table = 'conf_uinforecord'; $DO_CHECKING = 0; @@ -1279,8 +1099,8 @@ function set_settings() { $q = array_reduce($cv, 'reducer', "UPDATE `{$table}` SET "); $q = substr($q, 0, -2); $q .= $WHERECLAUSE; - single_row_update($q,0,$c2); - echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated", "query"=>$q,"err"=>mysqli_error($c2))); + single_row_update($q,0); + echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated", "query"=>$q,"err"=>mysqli_error($c))); } } else { echo json_encode( array("result"=>"fail", "err"=>"no activity id specified") ); } @@ -1515,11 +1335,13 @@ function handle_pic_upload() { global $USER; } //if (isset($_REQUEST['file'])) { handle_pic_upload(); } + +/* if (isset($_FILES['file'])) { handle_pic_upload(); } -function get_a_user_by_pid($user_pid) { global $c, $c2, $_; +function get_a_user_by_pid($user_pid) { global $c, $_; $q1 = "SELECT last_name, first_name, department, extension, phone_number, email, room, user_id, time_updated, id, web_on FROM personnel WHERE id='{$user_pid}'"; - $usr_dir = single_row_select($q1, 0, $c); + $usr_dir = single_row_select($q1, 0); $q2 = "SELECT id AS id_c_users, goo, email AS email_c_users, name, active FROM conf_users WHERE email='{$usr_dir['email']}'"; $usr_conf = single_row_select($q2, 0, $c2); $mega = $_->extend( (object) $usr_dir, (object) $usr_conf ); @@ -1532,7 +1354,7 @@ function get_a_user_by_pid($user_pid) { global $c, $c2, $_; // ????? - + */ /* if (!isset($mega->use_dir_photo)) { $mega->pic_exists = check_dir_photo($mega->first_name, $mega->last_name); if ($mega->pic_exists) { @@ -1547,18 +1369,21 @@ function get_a_user_by_pid($user_pid) { global $c, $c2, $_; elseif ($mega->id && ! $mega->personnel_id) { $mega->aaqueryfix = "UPDATE gavi_personnel_ext SET personnel='{$mega->id}' WHERE id='{$mega->ext_id}'"; } */ - + /* echo json_encode( $mega ); exit(); } if (isset($_REQUEST['a']) && preg_match('/^get\/user\/(\d+)$/', $_REQUEST['a'], $matches)) { get_a_user_by_pid( $matches[1] ); } +*/ + +/* function get_a_user($user_email) { global $c, $c2, $_; $q1 = "SELECT last_name, first_name, department, extension, phone_number, email, room, user_id, time_updated, id, web_on FROM personnel WHERE email='" . $user_email . "'"; //p2($q1); - $usr_dir = single_row_select($q1, 0, $c); + $usr_dir = single_row_select($q1, 0); //p2($usr_dir); $q2 = "SELECT id AS id_c_users, goo, email AS email_c_users, name, active FROM conf_users WHERE email='" . $user_email . "'"; @@ -1567,19 +1392,19 @@ function get_a_user($user_email) { global $c, $c2, $_; //p2($usr_conf); $mega = $_->extend( (object) $usr_dir, (object) $usr_conf ); - $q3 = 'SELECT id AS ext_id, personnel AS personnel_id, goo_short, c_users AS c_users_id_ext, ilearn_id, sched_alias, dept1, dept2, gtitle, active, use_dir_photo, etc FROM gavi_personnel_ext WHERE personnel=' . $mega->id; + $q3 = 'SELECT id AS ext_id, personnel AS personnel_id, goo_short, c_users AS c_users_id_ext, ilearn_id, sched_alias, dept1, dept2, gtitle, active, use_dir_photo, etc FROM gavi_personnel_ext WHERE personnel=' . $mega['id']; //p2($q3); $usr_ext = single_row_select($q3,0,$c2); //p2($usr_ext); $mega = $_->extend( (object) $mega, (object) $usr_ext ); - $q4 = 'SELECT person, officehours, title, picture, education, bio, courses, personal_page, changed FROM webpages WHERE person=' . $mega->id; // personnel=1'); + $q4 = 'SELECT person, officehours, title, picture, education, bio, courses, personal_page, changed FROM webpages WHERE person=' . $mega['id']; // personnel=1'); //p2($q3); $usr_web = single_row_select($q4,0,$c); //p2($usr_ext); $mega = $_->extend( (object) $mega, (object) $usr_web ); - /* + if (!isset($mega->use_dir_photo)) { $mega->pic_exists = check_dir_photo($mega->first_name, $mega->last_name); if ($mega->pic_exists) { @@ -1588,20 +1413,23 @@ function get_a_user($user_email) { global $c, $c2, $_; } else { $mega->bbqueryfix = "UPDATE gavi_personnel_ext SET use_dir_photo=0 WHERE id='{$mega->ext_id}'"; } - }*/ - if (! isset($mega->ext_id)) { - $mega->aaqueryfix = "INSERT INTO gavi_personnel_ext (personnel) VALUES('{$mega->id}')"; } + } + if (! isset($mega['ext_id'])) { + $mega->aaqueryfix = "INSERT INTO gavi_personnel_ext (personnel) VALUES('{$mega['id']}')"; } elseif ($mega->id && ! $mega->personnel_id) { - $mega->aaqueryfix = "UPDATE gavi_personnel_ext SET personnel='{$mega->id}' WHERE id='{$mega->ext_id}'"; } + $mega->aaqueryfix = "UPDATE gavi_personnel_ext SET personnel='{$mega['id']}' WHERE id='{$mega['ext_id']}'"; } return $mega; } +*/ - +/* function insert_c2($q) { global $c2; $result = single_row_insert($q,0,$c2); return $result; } +*/ + function merge_tables() { global $c, $_; $all_personnel = multi_row_select('SELECT first_name,last_name,department,room,phone_number,email,web_on,id FROM personnel WHERE status IS null OR status=1',0, $c); @@ -1636,14 +1464,14 @@ function fetch_personnel_dir() { global $c; exit(); } if (isset($_REQUEST['personnel'])) { fetch_personnel_dir(); } -function fetch_conf_users() { global $c2; - $all_personnel = multi_row_select('SELECT * FROM conf_users',0, $c2); +function fetch_conf_users() { global $c; + $all_personnel = multi_row_select('SELECT * FROM conf_users',0, $c); echo json_encode($all_personnel); exit(); } if (isset($_REQUEST['users'])) { fetch_conf_users(); } -function fetch_personnel_ext() { global $c2; - $all_personnel = multi_row_select('SELECT * FROM gavi_personnel_ext',0, $c2); +function fetch_personnel_ext() { global $c; + $all_personnel = multi_row_select('SELECT * FROM gavi_personnel_ext',0, $c); echo json_encode($all_personnel); exit(); } if (isset($_REQUEST['personnelext'])) { fetch_personnel_ext(); } @@ -1696,10 +1524,10 @@ function navigation($user) { } -function test_sso() { global $c2; +function test_sso() { global $c; $goo = "102586"; //"123456"; $q0 = "SELECT email FROM conf_users WHERE goo='{$goo}'"; - $temp_usr = single_row_select($q0,0,$c2); + $temp_usr = single_row_select($q0,0,$c); echo '
';
var_dump($temp_usr);
echo '';
diff --git a/graf/bird2024.png b/graf/bird2024.png
new file mode 100644
index 0000000..86ece8a
Binary files /dev/null and b/graf/bird2024.png differ
diff --git a/js/dir_app.js b/js/dir_app.js
index ac3b4cd..320afc1 100644
--- a/js/dir_app.js
+++ b/js/dir_app.js
@@ -918,7 +918,7 @@ const ActivityList = Vue.component('activitylist', {
data: function () {
return { activities:[], mysessions:[], search:'', sortby:'starttime', reversed:false, my_ses_ids:[], my_host_ids:[],
show_filters: 'all', expanded: 1, editing: -1, active:-1, hosts:{},
- hosts_by_sesid: {}, options:{}, conference:{}, ay:{}, conf:-1, survey_on:0, zoom_on:0, } },
+ hosts_by_sesid: {}, options:{}, conference:{}, ay:{}, conf:-1, survey_on:0, zoom_on:1, } },
mounted: function() {
this.fetch_myevents()
},
@@ -939,21 +939,23 @@ const ActivityList = Vue.component('activitylist', {
else { this.reversed = false; this.sortby = ss } },
swapme: function(x) { this.editing = x },
done_edit: function(id) { this.editing = -1 },
- am_editing: function(id) { return 1 },
+ am_editing: function(id) { return 0 },
fetch_myevents: function() {
var self = this;
basic_get('api2.php?query=app',
function(r2) {
self.mysessions = r2.mysessions
+ self.my_ses_ids = _.pluck(r2.mysessions, 'id')
self.activities = r2.sessions
- self.my_host_ids = r2.host
+ if (r2.host != null) { self.my_host_ids = r2.host }
+ else { self.my_host_ids = [] }
self.options = r2.options
self.conference = r2.conference
self.ay = r2.ay
- self.active = 1
self.survey_on = parseInt( _.findWhere(self.options, { label:'survey_on' }).value )
self.zoom_on = parseInt( _.findWhere(self.options, { label:'zoom_on' }).value )
+ self.active = 1
self.$forceUpdate();
} )
@@ -1012,19 +1014,7 @@ const ActivityList = Vue.component('activitylist', {
var self=this; return _.groupBy(self.mysessions_filtered, function(x) { return self.month_year(x.starttime) } ); }, },
watch: { },
template: `