function add_admin() { global $input; if (!isset($input['user_ID']) || empty($input['user_ID'])) { die; } $res = add_admin_to_file($input['user_ID']); $u = db_user_read($input['user_ID']); if (!$res) { echo json_encode(array('error' => '1')); die; } echo json_encode(array('user_ID' => $input['user_ID'], 'forename' => $u['forename'], 'surname' => $u['surname'])); db_log(db_gettable('users'), 'Gave admin rights to ' . $input['user_ID'], $_SESSION['user_login']); die; }
/** * Returns the list of admins * @return array */ function parse_admin_file() { include 'admin.inc'; $admins = array(); foreach ($users as $u => $whocares) { $userinfos = db_user_read($u); $admins[] = array('user_ID' => $u, 'forename' => $userinfos['forename'], 'surname' => $userinfos['surname']); } return $admins; }
function db_users_courses_create($course_code, $user_ID) { global $statements; if (db_users_courses_get($course_code, $user_ID)) { return false; } $statements['users_courses_create']->bindParam(':course_code', $course_code); $statements['users_courses_create']->bindParam(':user_ID', $user_ID); if (!$statements['users_courses_create']->execute()) { return false; } // return informations global $db_object; $user = db_user_read($user_ID); if (!$user) { return false; } $course = db_course_read($course_code); if (!$course) { return false; } return array('user' => $user, 'course' => $course, 'id' => $db_object->lastInsertId()); }