Esempio n. 1
0
 public function addPresForUser($usr_id)
 {
     // begin transaction
     global $db;
     $db->beginTransaction();
     try {
         // Check if the user currently has a presentation for this session.
         // If so, remove it.
         // The loop is a bit of overkill, but in case of an erroneous situation of the user having multiple
         // presentations for the same session, this will remove those extra cases.
         //
         // Include a check to make sure that presenters don't overwrite their presentations through this method.
         $presentations = get_presentations_by_user_by_session($usr_id, $this->ses_id);
         foreach ($presentations as $presentation) {
             Presentation::deletePresentationsByUser($usr_id, $presentation['pres_id']);
         }
         // Inserts the new session for the user.
         $this->insert_presentation_for_user($usr_id);
         // commit transaction
         $db->commit();
     } catch (PDOException $e) {
         // roll back transaction
         $db->rollback();
         // log any errors to file
         log_pdo_exception($e, $usr_id, "Adding Presentation:" . $this, "addPresForUser");
         display_db_exception($e);
         // display_error("Error saving data.");
         exit;
     }
 }