Example #1
0
 /**
  * Deletes a Display
  * @return 
  * @param $displayID int
  */
 public function Delete($displayID)
 {
     Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__);
     try {
         $dbh = PDOConnect::init();
         // Pass over to the DisplayGroup data class so that it can try and delete the
         // display specific group first (it is that group which is linked to schedules)
         $displayGroupObject = new DisplayGroup($this->db);
         // Do we also want to update the linked Display Groups name (seeing as that is what we will be presenting to everyone)
         if (!$displayGroupObject->DeleteDisplay($displayID)) {
             $this->ThrowError($displayGroupObject->GetErrorMessage(), $displayGroupObject->GetErrorMessage());
         }
         // Delete the blacklist
         $sth = $dbh->prepare('DELETE FROM blacklist WHERE DisplayID = :displayid');
         $sth->execute(array('displayid' => $displayID));
         // Now we know the Display Group is gone - and so are any links
         // delete the display
         $sth = $dbh->prepare('DELETE FROM display WHERE DisplayID = :displayid');
         $sth->execute(array('displayid' => $displayID));
         \Xibo\Helper\Log::audit('Display', $displayID, 'Display Deleted', array('displayId' => $displayID));
         return true;
     } catch (Exception $e) {
         Debug::LogEntry('error', $e->getMessage());
         if (!$this->IsError()) {
             $this->SetError(25015, __('Unable to delete display record.'));
         }
         return false;
     }
 }