Example #1
0
 public function addPresForUser($usr_id)
 {
     // begin transaction
     global $db;
     $db->beginTransaction();
     try {
         Presentation::deletePresentationsByUserBySession($usr_id, $this->ses_id);
         // Inserts the new session for the user.
         $this->insert_presentation_for_user($usr_id);
         if ($this->pres_paired_pres_id != null) {
             $pairedPresentation = Presentation::getPresentation($this->pres_paired_pres_id);
             // iterate through a change of presentation ids until we get back to where we started.
             while ($pairedPresentation->pres_id != $this->pres_id) {
                 Presentation::deletePresentationsByUserBySession($usr_id, $pairedPresentation->ses_id);
                 // Inserts the new session for the user.
                 $pairedPresentation->insert_presentation_for_user($usr_id);
                 // iterate down the chain of paired presentations.
                 $pairedPresentation = Presentation::getPresentation($pairedPresentation->pres_paired_pres_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_error("Error saving data.");
         exit;
     }
 }