')); }
// keep HTML tags string cleaner
function okh($str) { global $c; return mysqli_real_escape_string($c, $str); }
// 1. lookups, like a username
function single_row_select($qry, $j=1, $c) {
$r = mysqli_query($c, $qry); d_err($qry);
$e = mysqli_error($c); if($e) { d_err("sql error: " . $e ); }
$a = mysqli_fetch_assoc($r);
$e = mysqli_error($c); if($e) { d_err("sql error: " . $e ); }
if (! $j) { return $a; } return json_encode($a); }
// 1a. inserts
function single_row_insert($qry, $j=1, $c) {
$r = mysqli_query($c, $qry);
//d_err($qry);
//$e = mysqli_error($c); if($e) { d_err("sql error: " . $e ); }
$new_id = mysqli_insert_id($c);
return $new_id; }
/*$a = mysqli_fetch_assoc($c);
$e = mysqli_error($c); if($e) { d_err("sql error: " . $e ); }
if (! $j) { return $a; } return json_encode($a); } */
// 2. grid or fancier joins, like get all sessions, rosters, todos, etc
function multi_row_select($qry, $j=1, $db) {
$rows = array();
$result = mysqli_query($db, $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=0, $db) { global $c, $c2;
$r = mysqli_query($db, $qry);
$a = mysqli_num_rows($r);
$row = mysqli_fetch_array($r, MYSQLI_NUM);
$id = $row[0]; // getting the id of that which exists... assuming first column has it.
d_err("does exist: {$a}");
$e = mysqli_error($db); if($e) { d_err("sql error: " . $e); }
if ($a && $full_record) { return $row; } if ($a) { return $id; } return 0; }
////////////////////
////////////////////
//
// SSO
//
// Set GLOBAL VARS corresponding to current logged in user.
// They may only edit their own dir info.
//
$server = $_SERVER['SERVER_NAME'];
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
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];
session_start();
$_SESSION['USER_TYPE'] = $USER_TYPE;
$_SESSION['USER_GOO'] = $USER_GOO;
$_SESSION['USER_EMAIL'] = $USER_EMAIL;
} else {
$USER_TYPE = $_SESSION['USER_TYPE'];
$USER_GOO = $_SESSION['USER_GOO'];
$USER_EMAIL = $_SESSION['USER_EMAIL'];
}
} else {
//echo json_encode( array("result"=>"not logged in") );
exit();
/*$USER = 0;
$USER_NAME = 0;
$USER_PERS_ID = 0;
$USER_CONF_U_ID = 0;
$USER_PERS_EXT_ID = 0; */
}
$status = "ID:{$USER_GOO}
";
$status .= "Email:{$USER_EMAIL}
";
$status .= "Employee type:{$USER_TYPE}
";
d_err($status);
// Current academic year
$AY = single_row_select("SELECT * FROM conf_academicyears WHERE label='2021-2022';",0, $c2);
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// 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]
function user_record() { global $USER, $USER_EMAIL, $USER_NAME, $USER_PERS_ID, $USER_CONF_U_ID, $USER_PERS_EXT_ID, $c, $c2;
$LC_EMAIL = strtolower($USER_EMAIL);
$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}'";
//p2($q1);
$usr_dir = single_row_select($q1, 0, $c);
//p2($usr_dir);
$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}'";
//p2($q2);
$usr_conf = single_row_select($q2, 0, $c2);
//p2($usr_conf);
$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}';
//p2($q3);
$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');
//p2($q4);
$usr_web = single_row_select($q4,0,$c);
//p2($usr_ext);
$mega = __::extend( (object) $mega, (object) $usr_web );
$USER = $mega;
}
if ($USER_EMAIL) { user_record(); }
// //
// //
// // LOG ENTRIES
// //
// //
// Enter or get browser log entry
function insert_or_get_browser($b) {
global $c2;
$BROWSER = ok($b);
$existing = does_exist( "SELECT id FROM www_browsers WHERE string='$BROWSER'", 0, $c2);
if ($existing) {
return $existing;
} else {
$q = "INSERT INTO www_browsers (string) VALUES ('$BROWSER')";
single_row_select($q,0,$c2);
return does_exist( "SELECT id FROM www_browsers WHERE string='$BROWSER'",0,$c2);
}
return 0; }
// Log everything!
function log_it($action) {
global $USER, $c2;
if (! $USER) {
$USER = array( 'name'=>'unknown', 'id'=>-1 ); }
$user_browser = $_SERVER['HTTP_USER_AGENT'];
$user_ip = $_SERVER['REMOTE_ADDR'];
$BROWSER = insert_or_get_browser($user_browser);
$ACTION = ok($action);
//$id = ok($_POST['id']);
$qupdate = "INSERT INTO gavi_logs SET action='{$action}', personnel_id='{$USER->id}', name='{$USER->name}', browser=$BROWSER, ip='$user_ip'";
single_row_select($qupdate,0,$c2);
return array("result"=>"success","action"=>"logged","query"=>$qupdate,"err"=>mysqli_error($c2));
}
function unescape_commas($s) { return preg_replace('/\[CMA\]/', ',', $s); }
function name_to_lc($fn,$ln) {
$fn = str_replace( array( '-', ' '), '', strtolower($fn) );
$ln = str_replace( array( '-', ' '), '', strtolower($ln) );
return $fn . "_" . $ln;
}
function name_to_file($fn,$ln) {
$fn = str_replace( array( '-', ' '), '', strtolower($fn) );
$ln = str_replace( array( '-', ' '), '', strtolower($ln) );
return $fn . "_" . $ln . ".jpg";
}
function check_dir_photo($fn,$ln) { global $USER;
$filename = name_to_file( $fn,$ln );
$path = '/gavilan.edu/staff/images_sm/' . $filename;
$dir_pic_exists = 0;
$dir_pic_path = 'images_sm/nobody.jpg';
if (file_exists($path)) {
$dir_pic_exists = 1;
$dir_pic_path = 'images_sm/' . $filename; }
$USER->dir_pic_exists = $dir_pic_exists;
$USER->dir_pic_path = $dir_pic_path;
return $dir_pic_exists;
}
check_dir_photo($USER->first_name, $USER->last_name);
//
//
//
////////////////////
////////////////////
//require __DIR__ . '/vendor/autoload.php';
// Sample URL
//
// https://www.gavilan.edu/staff/dir_api.php?a=update&cols=name,msg&vals=peter,hello
//
// https://intranet1.gavilan.edu/dir/dir_api.php?a=update&cols=name,msg&vals=peter,hello
/*
NEXT STEPS:
- figure out permissions system
- which means knowing dept / hierarchy
- which means cross referencing PERSONNEL and EXT and CONF_USERS.....
## Permissions summary
0. There is a list of table+column combos that users are allowed to edit.
0.5 An activity "belongs" to the user who owns it (or created it).
1. Simple cases:
- current user is updating their own (allowable) record. Allow.
2. Superuser:
- current user is executive, hr, it, or root. (7,2,8,3) Allow.
3. User is "Dept Editor" (4) and
-is updating a record belonging to someone in their dept. Allow.
4. Harder: Updating events
5. Updating attendance, approvals, or other restricted tables. Only FPLC (1) or superusers.
*/
function check_permission( $acting_user, $target_user, $table ) {
// TODO
return true;
}
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// Everyone. Basic dir. Include status==0 which is unpublished.
function staff_dir() { global $c;
return multi_row_select('SELECT first_name,last_name,department,status, room,phone_number,email,web_on,id FROM personnel',1, $c);
// WHERE status IS null OR status=1
}
// Everyone. Basic dir
function staff_dir_ext() { global $c;
return multi_row_select('SELECT p.first_name,p.last_name,p.department,p.status, p.room,phone_number,LOWER(p.email) AS email,p.web_on, p.id, e.id AS ext_id, e.role, e.goo_short, e.c_users AS c_users_id_ext, e.ilearn_id, e.sched_alias, e.dept1, e.dept2, e.gtitle, e.active, e.use_dir_photo, e.general_photo_release, e.dir_photo_path, e.etc, c.id AS conf_id, c.goo AS conf_goo, c.name AS conf_name FROM gavi_db.personnel p LEFT JOIN PeterDB.gavi_personnel_ext e ON p.id=e.personnel LEFT JOIN PeterDB.conf_users c ON LOWER(p.email)=LOWER(c.email) ORDER BY p.last_name LIMIT 5000',1, $c);
}
if (isset($_REQUEST['a']) && $_REQUEST['a']=='list') {
echo staff_dir_ext(); exit(); }
// Everyone. Directory info with DEPTS and TITLES added
function staff_dir_full_ext() { global $c;
return multi_row_select('SELECT p.first_name,p.last_name,p.department,p.status, p.room,phone_number,LOWER(p.email) AS email,p.web_on, p.id, e.id AS ext_id, e.role, e.goo_short, e.c_users AS c_users_id_ext, e.ilearn_id, e.sched_alias, e.dept1, e.dept2, e.gtitle, e.active, e.use_dir_photo, e.general_photo_release, e.dir_photo_path, e.etc, e.espanol, e.zoom, e.preferred_contact, c.id AS conf_id, c.goo AS conf_goo, c.name AS conf_name, d.name AS dept1name, t.name AS titlename, d.parent AS deptparent FROM gavi_db.personnel p LEFT JOIN PeterDB.gavi_personnel_ext e ON p.id=e.personnel LEFT JOIN PeterDB.conf_users c ON LOWER(p.email)=LOWER(c.email) LEFT JOIN PeterDB.gavi_departments d ON e.dept1=d.id LEFT JOIN PeterDB.gavi_titles t ON e.gtitle=t.id ORDER BY p.last_name LIMIT 5000',1, $c);
}
if (isset($_REQUEST['a']) && $_REQUEST['a']=='list2') { echo staff_dir_full_ext(); exit(); }
// 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); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='list/semester') {
echo semester_sections(); exit(); }
// STAFF + COURSES COMBINED
function staff_dir_w_sections() { global $c;
// just one semesters sections?
$WHERE = "WHERE pgs.sem='fa21'";
// all recorded semesters
$WHERE = "";
return multi_row_select("SELECT p.first_name,p.last_name,p.department,p.status,p.staff_type, p.room,phone_number,LOWER(p.email) AS email,p.web_on, p.id, e.id AS ext_id, e.role, e.goo_short, e.c_users AS c_users_id_ext, e.ilearn_id, e.sched_alias, e.dept1, e.dept2, e.gtitle, e.active, e.use_dir_photo, e.general_photo_release, e.dir_photo_path, e.etc, e.espanol, e.zoom, e.preferred_contact, c.id AS conf_id, c.goo AS conf_goo, c.name AS conf_name, d.name AS dept1name, t.name AS titlename, d.parent AS deptparent, GROUP_CONCAT(DISTINCT s.code SEPARATOR ', ') AS sections, COUNT(s.code) AS num_taught FROM gavi_db.personnel p LEFT JOIN PeterDB.gavi_personnel_ext e ON p.id=e.personnel LEFT JOIN PeterDB.conf_users c ON LOWER(p.email)=LOWER(c.email) LEFT JOIN PeterDB.gavi_departments d ON e.dept1=d.id LEFT JOIN PeterDB.gavi_titles t ON e.gtitle=t.id LEFT JOIN ( SELECT * FROM PeterDB.gavi_sections pgs {$WHERE}) s ON e.id=s.teacher_id GROUP BY p.id ORDER BY p.last_name LIMIT 2500",0, $c);
}
if (isset($_REQUEST['a']) && $_REQUEST['a']=='list/staffsemester') {
echo json_encode(staff_dir_w_sections()); exit(); }
// JOB TITLES LIST
function job_titles() { global $c2;
return multi_row_select("SELECT DISTINCT id, name FROM gavi_titles ORDER BY name",1, $c2);
}
if (isset($_REQUEST['a']) && $_REQUEST['a']=='get/jobtitles') {
echo job_titles(); exit(); }
//
//
//
//
//
// Helper tables
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);
return json_encode( array( 'departments'=>$ddd, 'titles'=>$ttt, 'roles'=>$rrr, 'committees'=>$ccc ) );
exit();
}
if (isset($_REQUEST['a']) && $_REQUEST['a']=='menus') {
echo sub_menus(); exit(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// 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));
// no exit cause it gets called in pages
}
if (isset($_GET['a']) && $_GET['a'] == 'get/gavevents') { get_events(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// SEARCH AN INSTRUCTOR BY NAME IN SCHEDULE
//
function get_instructor() {
global $c2;
$i = ok($_REQUEST['inst']);
echo json_encode( single_row_select("SELECT * FROM gavi_personnel_ext WHERE sched_alias='{$i}';",0, $c2));
exit(); }
if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'get/instructor/name' ) { get_instructor(); }
function get_instructor_fuzzy() {
global $c2;
$i = ok($_REQUEST['inst']);
echo json_encode( single_row_select("SELECT * FROM gavi_personnel_ext WHERE sched_alias LIKE '{$i}';",0, $c2));
exit(); }
if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'get/instructor/fuzzyname' ) { get_instructor_fuzzy(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// COURSE SECTIONS in a semester
//
function get_sections($semester) {
global $c;
$semester = ok($semester);
echo json_encode( 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));
exit(); }
if (isset($_REQUEST['a']) && preg_match('/^get\/sections\/(\w\w\d\d)$/', $_REQUEST['a'], $matches)) {
get_sections( $matches[1] ); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// 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));
exit(); }
if (isset($_REQUEST['a']) && $_GET['a'] == 'get/sections') { get_all_sections(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// all COURSE SECTIONS of a single INSTRUCTOR
//
// use their gavi_personnel_ext id
//
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));
exit(); }
if (isset($_REQUEST['a']) && preg_match('/^get\/sections\/(\d+)$/', $_REQUEST['a'], $matches)) {
get_instructor_sections( $matches[1] ); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// get COURSE SINGLE SECTION including welcome letter
//
// Housekeeping: if the gavi_welcome_letters row doesn't exist, we need to make it and populate it with the example text.
//
//
function get_section($sem,$crn) {
global $c, $c2;
$sem = ok($sem);
$crn = ok($crn);
//echo $sem;
//echo $crn;
$sched_id = 0;
$sched_entry = single_row_select( "SELECT * FROM PeterDB.gavi_sections gs WHERE sem='{$sem}' AND crn='{$crn}';",0, $c2);
if ($sched_entry) {
$sched_id = $sched_entry['id'];
}
else {
echo "no row for that section
";
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);
if ($wl_entry) {
echo json_encode($wl_entry);
exit();
}
else {
// no WL row for that section
$logaction = log_it("Creating default welcome letter for Semester: $sem CRN: $crn");
$default = json_decode( file_get_contents('default_welcome_letter.json') );
$default->what_expect = okh($default->what_expect);
$default->assessments = okh($default->assessments);
$default->textbook = okh($default->textbook);
$default->other_info = okh($default->other_info);
$default->introduction = okh($default->introduction);
$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);
$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);
echo json_encode($wl_entry);
exit();
}
exit(); }
if (isset($_REQUEST['a']) && preg_match('/^get\/section\/(\w\w\d\d)\/(\d+)$/', $_REQUEST['a'], $matches)) {
get_section( $matches[1], $matches[2] ); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// 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.gets_survey,c.category,c.parent,c.recording,c.instructions,c.image_url,c.is_flex_approved,c.cal_uid,sst.type,sst.id AS typeId, 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); }
if (isset($_GET['a']) && $_GET['a'] == 'get/sessions') { echo json_encode(get_sessions()); exit(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// 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.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);
echo json_encode($my_sessions);
exit(); }
if (isset($_GET['a']) && $_GET['a'] == 'get/mysessions') { get_user_sessions(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// ARBITRARY USER'S SIGNED UP, (OR HOSTING,) SESSIONS / WORKSHOPS / EVENTS
//
// 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.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);
// AND c.starttime BETWEEN CAST('{$AY['begin']}' AS DATE) AND CAST('{$AY['end']}' AS DATETIME)
return $my_sessions; }
if (isset($_GET['a']) && preg_match('/get\/sessions\/(\d+)$/', $_GET['a'], $matches)) { echo json_encode( get_anyuser_sessions($matches[1])); exit(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// 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);
echo json_encode($my_sessions);
exit(); }
if (isset($_GET['a']) && $_GET['a'] == 'get/logs') { get_recent_logs(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// SIGNUP for (possibly overlapping time) session ...
//
function signup() {
global $c2, $AY, $USER;
preg_match('/signup\/(\d+)$/', $_GET['a'], $matches);
$ses = $matches[1];
$ts = date("Y-m-d H:i:s");
$logaction = log_it("Signed up for session: {$ses}");
$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->id_c_users}",0,$c2);
if ($existing) {
$qupdate = "UPDATE conf_signups SET session={$ses}, timestamp='{$ts}' WHERE session={$ses} AND user={$USER->id_c_users}";
single_row_select($qupdate,1,$c2);
echo json_encode( array("result"=>"success","action"=>"updated","logaction"=>$logaction, "query"=>$qupdate,"err"=>mysqli_error($c2)));
} else {
$q = "INSERT INTO conf_signups (session,user,timestamp) VALUES ({$ses},{$USER->id_c_users},'{$ts}')";
single_row_select($q,1,$c2);
echo json_encode( array("result"=>"success","action"=>"inserted","logaction"=>$logaction, "ses"=>$_SESSION,"query"=>$q,"err"=>mysqli_error($c2)));
} exit(); }
if (isset($_GET['a']) && preg_match('/signup\/(\d+)$/', $_GET['a'], $matches)) { signup(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// CANCEL a signup
//
function signdown() {
global $c2, $AY, $USER;
preg_match('/signdown\/(\d+)$/', $_GET['a'], $matches);
$ses = $matches[1];
$q = "DELETE FROM conf_signups WHERE session={$ses} AND user={$USER->id_c_users}";
single_row_select($q,1,$c2);
$logaction = log_it("Canceled signup for session: $ses");
echo json_encode( array("result"=>"success","action"=>"deleted","logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2)));
exit(); }
if (isset($_GET['a']) && preg_match('/signdown\/(\d+)$/', $_GET['a'], $matches)) { signdown(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// NEW SESSION
//
function new_session() {
global $c2, $AY, $USER;
$title = ok($_POST['title']); $starttime = ok($_POST['starttime']);
$length = ok($_POST['length']); if ($length=='') { $length=1; }
$track = ok($_POST['track']); $gets_survey = ok($_POST['gets_survey']);
$is_flex_approved = ok($_POST['is_flex_approved']); $category = ok($_POST['title']);
if ($category=='') { $category=0; }
$author = ok($_POST['author']); if ($author=='') { $author=1; } // $USER->id_c_users; }
$is_custom = ok($_POST['is_custom']); $parent = ok($_POST['parent']);
$desc = okh($_POST['desc']); $location = okh($_POST['location']);
$recording = okh($_POST['recording']); $instructions = okh($_POST['instructions']);
$type = ok($_POST['type']); if ($type=='') { $type=19; }
$cal_uid = ok($_POST['cal_uid']);
$q = "INSERT INTO conf_sessions (`title`,`starttime`,`length`,`track`,`gets_survey`,`is_flex_approved`,`category`,`author`,`is_custom`,`parent`,`desc`,`location`,`recording`,`instructions`,`type`,`cal_uid`) VALUES ('{$title}', '{$starttime}', '{$length}', '{$track}', '{$gets_survey}', '{$is_flex_approved}', '{$category}', '{$author}', '{$is_custom}', '{$parent}', '{$desc}', '{$location}', '{$recording}', '{$instructions}', '{$type}', '{$cal_uid}');";
$ins = single_row_insert($q,0,$c2);
$logaction = log_it("created new session: {$title}");
echo json_encode( array("result"=>"success","action"=>"inserted new session","insert"=>$ins, "query"=>$q,"logaction"=>$logaction,"err"=>mysqli_error($c2)));
exit(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='set/newsession') { new_session(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// Editing of session info
//
function set_sessioninfo() {
global $c, $c2, $AY, $USER;
$table = 'conf_sessions';
if (isset($_POST['id'])) {
$ID = ok($_REQUEST['id']);
if (! check_permission( $USER->id, $ID, $table)) {
echo json_encode( array("result"=>"fail", "err"=>"dont have permission to edit this") );
exit();
} else {
$logaction = log_it("edited session id: {$ID}");
$WHERECLAUSE = " WHERE id={$ID}";
$date = date('Y-m-d H:i:s');
$cols = explode(',', $_REQUEST['cols']); $vals = explode(',', $_REQUEST['vals']);
$vals = __::map($vals, unescape_commas);
$cv = __::zip($cols,$vals);
$q = __::reduce($cv, function($memo, $a) { return $memo . ok($a[0]) . "='" . okh($a[1]) . "', "; }, "UPDATE {$table} SET ");
$q = substr($q, 0, -2);
$q .= $WHERECLAUSE;
single_row_select($q,0,$c1);
echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated","logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2)));
}
} else {
echo json_encode( array("result"=>"fail", "err"=>"no activity id specified") ); }
exit(); }
//if (isset($_POST['a']) && $_POST['a']=='update/activity') { set_sessioninfo(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='update/activity') { set_sessioninfo(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// update a name, lname, dept, phone, extension, email, type, room, status, user_id, or web_on
function update_dir() {
global $USER, $c, $c2;
$WHERECLAUSE = " WHERE id={$USER->id}";
if (isset($_POST['id'])) { // editing another person's data
if (! check_permission( $USER->id, $_POST['id'], 'personnel')) {
echo json_encode( array("result"=>"fail", "err"=>"dont have permission to edit this") );
exit();
} else {
$logaction = log_it("updating personnel record of personnel id {$_POST['id']}");
$WHERECLAUSE = " WHERE id={$_POST['id']}";
}
} else {
$logaction = log_it("updating personnel record");
}
// date modified is now
$date = date('Y-m-d H:i:s');
$cols = explode(',', $_REQUEST['cols']); $vals = explode(',', $_REQUEST['vals']);
$vals = __::map($vals, unescape_commas);
$cv = __::zip($cols,$vals);
$q = __::reduce($cv, function($memo, $a) { return $memo . ok($a[0]) . "='" . ok($a[1]) . "', "; }, "UPDATE personnel SET ");
//$q = substr($q, 0, -2);
$q .= "time_updated='" . $date . "'";
$q .= $WHERECLAUSE;
if ($USER->id) {
single_row_select($q,0,$c);
echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated","logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c)));
}
else {
$logaction2 = log_it("failed to update personnel record");
echo json_encode( array("result"=>"fail", "err"=>"dont have an id for user") );
}
exit();
}
//if (isset($_POST['a']) && $_POST['a']=='update') { update_dir(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='update') { update_dir(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// update goo, dept1/dept2, title, active, use_dir_photo
function update_dir_ext() {
global $USER, $c, $c2;
$WHERECLAUSE = " WHERE id={$USER->ext_id}";
#print_r($_REQUEST);
if (isset($_REQUEST['id'])) { // editing another person's data
if (! check_permission( $USER->id, $_REQUEST['id'], 'personnel_ext')) {
echo json_encode( array("result"=>"fail", "err"=>"dont have permission to edit this") );
exit();
} else {
$logaction = log_it("updating personnel_ext record of personnel id {$_REQUEST['id']}");
$WHERECLAUSE = " WHERE id={$_REQUEST['id']}";
}
} else {
$logaction = log_it("updating personnel_ext record");
}
// date modified is now
$date = date('Y-m-d H:i:s');
$cols = explode(',', $_REQUEST['cols']); $vals = explode(',', $_REQUEST['vals']);
$vals = __::map($vals, unescape_commas);
$cv = __::zip($cols,$vals);
$q = __::reduce($cv, function($memo, $a) { return $memo . ok($a[0]) . "='" . ok($a[1]) . "', "; }, "UPDATE gavi_personnel_ext SET ");
$q = substr($q, 0, -2);
$q .= $WHERECLAUSE;
single_row_select($q,0,$c2);
echo json_encode( array("result"=>"success","action"=>"updated","logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2)));
exit();
}
//if (isset($_POST['a']) && $_POST['a']=='update_xt') { update_dir_ext(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='update_xt') { update_dir_ext(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// update person, officehours, title, picture, education, bio, courses, personal_page, changed
function update_webpage() {
global $USER_PERS_ID, $USER, $c, $c2;
$WHERECLAUSE = " WHERE person={$USER->id}";
if (isset($_POST['id'])) { // editing another person's data
if (! check_permission( $USER->id, $_POST['id'], 'personnel')) {
echo json_encode( array("result"=>"fail", "err"=>"dont have permission to edit this") );
exit();
} else {
$logaction = log_it("updating bio webpage record of personnel id {$_POST['id']}");
$WHERECLAUSE = " WHERE person={$_POST['id']}";
}
} else {
$logaction = log_it("updating bio webpage record");
}
$date = date('Y-m-d H:i:s');
$cols = explode(',', $_REQUEST['cols']); $vals = explode(',', $_REQUEST['vals']);
$vals = __::map($vals, unescape_commas);
$cv = __::zip($cols,$vals);
$q = __::reduce($cv, function($memo, $a) { return $memo . ok($a[0]) . "='" . okh($a[1]) . "', "; }, "UPDATE webpages SET ");
$q .= "changed='" . $date . "'";
$q .= $WHERECLAUSE;
if ($USER->id) {
single_row_select($q,0,$c);
echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>"updated","logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c)));
}
else {
$logaction2 = log_it("failed to update bio webpage record");
echo json_encode( array("result"=>"fail", "err"=>"dont have an id for user") );
}
exit();
}
//if (isset($_POST['a']) && $_POST['a']=='update_web') { update_webpage(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='update_web') { update_webpage(); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// update a course section record
function update_section($update=1) {
global $USER, $c2;
$WHERECLAUSE = "";
$START = "INSERT INTO gavi_sections SET ";
$action = "inserted";
if ( check_permission( $USER->id, 0, 'gavi_sections')) {
if ($update) {
$START = "UPDATE webpages SET ";
$WHERECLAUSE = " WHERE id={$_REQUEST['id']}";
$action = "updated";
$logaction = log_it("updating section id {$_REQUEST['id']}");
} else {
$logaction = log_it("inserting new section");
}
} else {
echo json_encode( array("result"=>"fail", "err"=>"dont have permission to edit this") );
exit();
}
$cols = explode(',', $_REQUEST['cols']); $vals = explode(',', $_REQUEST['vals']);
$vals = __::map($vals, unescape_commas);
$cv = __::zip($cols,$vals);
$q = __::reduce($cv, function($memo, $a) { return $memo . ok($a[0]) . "='" . ok($a[1]) . "', "; }, $START);
$q = substr($q, 0, -2);
$q .= $WHERECLAUSE;
single_row_select($q,0,$c2);
echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>$action,
"logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2)));
exit();
}
//if (isset($_POST['a']) && $_POST['a']=='update/section') { update_section(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='update/section') { update_section(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='add/section') { update_section(0); }
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
//
// update a WELCOME LETTER
//
function update_welcome_letter($update=1) {
global $USER, $c2;
$WHERECLAUSE = "";
$START = "INSERT INTO gavi_welcome_letters SET ";
$action = "inserted";
if ( check_permission( $USER->id, 0, 'gavi_welcome_letters')) {
if ($update) {
$START = "UPDATE gavi_welcome_letters SET ";
$WHERECLAUSE = " WHERE id={$_REQUEST['id']}";
$action = "updated";
$logaction = log_it("updating welcome letter id {$_REQUEST['id']}");
} else {
$logaction = log_it("inserting new welcome letter");
}
} else {
echo json_encode( array("result"=>"fail", "err"=>"dont have permission to edit this") );
exit();
}
$cols = explode(',', $_REQUEST['cols']); $vals = explode(',', $_REQUEST['vals']);
$vals = __::map($vals, unescape_commas);
$cv = __::zip($cols,$vals);
$q = __::reduce($cv, function($memo, $a) { return $memo . ok($a[0]) . "='" . okh($a[1]) . "', "; }, $START);
$q = substr($q, 0, -2);
$q .= $WHERECLAUSE;
single_row_select($q,0,$c2);
echo json_encode( array("rawvalstr"=>$_REQUEST['vals'], "result"=>"success","action"=>$action,
"logaction"=>$logaction, "query"=>$q,"err"=>mysqli_error($c2)));
exit();
}
//if (isset($_POST['a']) && $_POST['a']=='update/letter') { update_welcome_letter(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='update/letter') { update_welcome_letter(); }
if (isset($_REQUEST['a']) && $_REQUEST['a']=='add/letter') { update_welcome_letter(0); }
function handle_pic_upload() { global $USER;
$uploaddir = '/gavilan.edu/staff/uploads/';
$date = date('Ymd_Hi');
$uploadfile = $uploaddir . name_to_lc($USER->first_name,$USER->last_name) . "_" . $date . "_" . basename($_FILES['file']['name']);
echo '';
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "";
}
//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;
$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}'";
//p2($q1);
$usr_dir = single_row_select($q1, 0, $c);
//p2($usr_dir);
$q2 = "SELECT id AS id_c_users, goo, email AS email_c_users, name, active FROM conf_users WHERE email='{$usr_dir['email']}'";
//p2($q2);
$usr_conf = single_row_select($q2, 0, $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}'";
$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');
//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) {
$filename = "images_sm/" . name_to_file( $mega->first_name, $mega->last_name );
$mega->bbqueryfix = "UPDATE gavi_personnel_ext SET use_dir_photo=1, dir_photo_path='{$filename}' WHERE id='{$mega->ext_id}'";
} 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}')"; }
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);
//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 . "'";
//p2($q2);
$usr_conf = single_row_select($q2, 0, $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;
//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');
//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) {
$filename = "images_sm/" . name_to_file( $mega->first_name, $mega->last_name );
$mega->bbqueryfix = "UPDATE gavi_personnel_ext SET use_dir_photo=1, dir_photo_path='{$filename}' WHERE id='{$mega->ext_id}'";
} 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}')"; }
elseif ($mega->id && ! $mega->personnel_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);
$emails = __::pluck($all_personnel, 'email');
//echo json_encode($emails);
//exit();
//$emails = array_slice($emails, 0, 10);
$full = __::map( $emails, get_a_user );
//echo json_encode($full);
//$results = __::map( __::pluck($full,'aaqueryfix'), insert_c2);
//$results = __::pluck($full,'bbqueryfix');
//$results = __::map( $results, insert_c2);
echo json_encode( $full );
exit(); }
if (isset($_REQUEST['merge'])) { merge_tables(); }
/*
echo basename(__FILE__);
echo "
";
echo basename($_SERVER["SCRIPT_FILENAME"]);
*/
//
//
// DO NOTHING IF FILE WAS INCLUDED
//
// OTHERWISE, RETURN BASIC USER INFO
//
//
if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
// Called directly as api or in browser
//
if ($USER_EMAIL) {
// log it as an access
$logaction = log_it("accessed personnel record editor (in peters hhh tester folder)");
$USER->logresult = $logaction;
// Default case is current user data to be embedded in editor page
echo json_encode($USER);
exit();
} else {
echo json_encode( array("result"=>"not logged in") );
exit();
}
}
//
// ELSE it was "included"...
?>