Esempio n. 1
0
function create_tutor_request()
{
    // validate form input
    $subjects = check_subjects($_REQUEST["subjects"]);
    $subject = addslashes($subjects[0]);
    $teacher = addslashes(check_teacher($_REQUEST['teacher']));
    $tutor_categories = check_tutor_categories($_REQUEST["tutor_category"]);
    $times_per_week = addslashes(check_times_per_week($_REQUEST["times_per_week"]));
    $student_id = addslashes($_SESSION['student_id']);
    $DB = new DB();
    $insert_query = "INSERT into tutor_request set\n                   student_id='{$student_id}',\n                   teacher='{$teacher}',\n                   subject='{$subject}',\n                   times_per_week='{$times_per_week}'\n                   ";
    $DB->query($insert_query);
    $tutor_request_id = mysql_insert_id();
    if ($tutor_categories) {
        add_request_tutor_categories($tutor_categories, $tutor_request_id);
    }
    add_answers($tutor_request_id);
    return "Your request has been submitted, and we'll try and match you with a tutor as soon as we can.  We will notify you of a match via email.  Please check your email daily for the next week.  If you don't have an email, we'll call you when we've found a tutor for you.";
}
Esempio n. 2
0
 /**
  * Get list of course items created for a specific module (for the 2nd reference select list in the notes form)
  * @param int $course the course that the desired items belong to
  * @param int $module the module id that the desired items are creted by
  * @return array of modules items as object id and object description 
  */
 public static function get_general_module_items($module)
 {
     error_log("*************************************** get_general_module_items(" . serialize($module) . ")");
     $items = array();
     if (isset($_SESSION['uid']) && $_SESSION['uid']) {
         if (in_array($module, array_keys(self::$ref_object_types['general']))) {
             if ($module == MODULE_ID_USERS) {
                 if (check_teacher()) {
                     $objtype = 'user';
                     $objprops = self::$ref_object_types['general'][$module]['user'];
                     $q = "SELECT CONCAT('{$objtype}',':',u.{$objprops['id_field']}) id, {$objprops['title_field']} title " . "  FROM course_user tutor_courses JOIN course_user student_courses ON tutor_courses.course_id = student_courses.course_id" . " JOIN {$objprops['objtable']} u ON student_courses.user_id = u.{$objprops['id_field']} " . " WHERE tutor_courses.status = 1 AND student_courses.status = 5";
                     $newitems = Database::get()->queryArray($q);
                     foreach ($newitems as $ni) {
                         $items[$ni->id] = $ni->title;
                     }
                 }
             } else {
                 foreach (self::$ref_object_types['general'][$module] as $objtype => $objprops) {
                     $newitems = Database::get()->queryArray("SELECT CONCAT('{$objtype}',':',{$objprops['id_field']}) id, {$objprops['title_field']} title FROM {$objprops['objtable']}");
                     foreach ($newitems as $ni) {
                         $items[$ni->id] = $ni->title;
                     }
                 }
             }
         }
     }
     return $items;
 }