Exemplo n.º 1
0
function modify_mentor($mentor_id, $mentor_last_name, $mentor_first_name, $mentor_suffix, $mentor_field, $mentor_position, $mentor_company, $mentor_profile, $mentor_keywords, $pres_room, $pres_host_teacher, $pres_max_capacity, $mentor_sessions)
{
    global $db;
    $query = 'update mentor set
                 mentor_last_name = :mentor_last_name, mentor_first_name = :mentor_first_name,
                 mentor_suffix = :mentor_suffix,
                  mentor_field = :mentor_field, mentor_position = :mentor_position,
                  mentor_company = :mentor_company,
                  mentor_profile = :mentor_profile, mentor_keywords = :mentor_keywords
                 , pres_room = :pres_room,
                 pres_host_teacher = :pres_host_teacher,
                 pres_max_capacity = :pres_max_capacity WHERE mentor_id = :mentor_id';
    try {
        $statement = $db->prepare($query);
        $statement->bindValue(':mentor_last_name', $mentor_last_name);
        $statement->bindValue(':mentor_id', $mentor_id);
        $statement->bindValue(':mentor_first_name', $mentor_first_name);
        $statement->bindValue(':mentor_suffix', $mentor_suffix);
        $statement->bindValue(':mentor_field', $mentor_field);
        $statement->bindValue(':mentor_position', $mentor_position);
        $statement->bindValue(':mentor_company', $mentor_company);
        $statement->bindValue(':mentor_profile', $mentor_profile);
        $statement->bindValue(':mentor_keywords', $mentor_keywords);
        $statement->bindValue(':pres_room', $pres_room);
        $statement->bindValue(':pres_host_teacher', $pres_host_teacher);
        $statement->bindValue(':pres_max_capacity', $pres_max_capacity);
        $statement->execute();
        $statement->closeCursor();
        $db->beginTransaction();
        for ($i = 0; $i < 4; $i++) {
            $presentation = get_presentation_by_mentor_session($mentor_id, $i + 1);
            if (!empty($presentation) && empty($mentor_sessions[$i])) {
                $query = 'select pres_id from presentation where mentor_id = :mentor_id
                            and ses_id = :ses_id';
                $statement = $db->prepare($query);
                $statement->bindValue(':mentor_id', $mentor_id);
                $statement->bindValue(':ses_id', $i + 1);
                $statement->execute();
                $result = $statement->fetch();
                $statement->closeCursor();
                $pres_id = $result['pres_id'];
                $query = 'delete from pres_user_xref where pres_id = :pres_id';
                $statement = $db->prepare($query);
                $statement->bindValue(':pres_id', $pres_id);
                $statement->execute();
                $statement->closeCursor();
                $query = 'delete from presentation where mentor_id = :mentor_id
                            and ses_id = :ses_id';
                $statement = $db->prepare($query);
                $statement->bindValue(':mentor_id', $mentor_id);
                $statement->bindValue(':ses_id', $i + 1);
                $statement->execute();
                $statement->closeCursor();
            } elseif (empty($presentation) && !empty($mentor_sessions[$i])) {
                $query = 'insert into presentation values (NULL, :ses_id, :mentor_id, 0, NULL)';
                $statement = $db->prepare($query);
                $statement->bindValue(':mentor_id', $mentor_id);
                $statement->bindValue(':ses_id', $i + 1);
                $statement->execute();
                $statement->closeCursor();
            }
        }
        $db->commit();
    } catch (PDOException $e) {
        display_db_exception($e);
        $db->rollBack();
        exit;
    }
}
Exemplo n.º 2
0
     $mentor_id = filter_input(INPUT_GET, 'mentor_id');
     $mentor = get_mentor($mentor_id);
     $mentor_first_name = $mentor['mentor_first_name'];
     $mentor_last_name = $mentor['mentor_last_name'];
     $mentor_suffix = $mentor['mentor_suffix'];
     $mentor_field = $mentor['mentor_field'];
     $mentor_position = $mentor['mentor_position'];
     $mentor_company = $mentor['mentor_company'];
     $mentor_profile = $mentor['mentor_profile'];
     $mentor_keywords = $mentor['mentor_keywords'];
     $pres_room = $mentor['pres_room'];
     $pres_host_teacher = $mentor['pres_host_teacher'];
     $pres_max_capacity = $mentor['pres_max_capacity'];
     $mentor_sessions_check = [false, false, false, false];
     for ($i = 1; $i <= 4; $i++) {
         if (!empty(get_presentation_by_mentor_session($mentor_id, $i))) {
             $mentor_sessions_check[$i - 1] = true;
         }
     }
     include 'mentor_modify.php';
     exit;
     break;
 case 'modify_mentor':
     $choice = filter_input(INPUT_POST, 'choice');
     $mentor_id = filter_input(INPUT_POST, 'mentor_id');
     if (filter_input(INPUT_POST, 'choice') == "Modify") {
         $mentor_first_name = filter_input(INPUT_POST, 'mentor_first_name');
         $mentor_last_name = filter_input(INPUT_POST, 'mentor_last_name');
         $mentor_suffix = filter_input(INPUT_POST, 'mentor_suffix');
         $mentor_position = filter_input(INPUT_POST, 'mentor_position');
         $mentor_company = filter_input(INPUT_POST, 'mentor_company');