Example #1
0
 public function SetFileAssociations()
 {
     $user =& $this->user;
     $response = new ResponseManager();
     $displayGroupId = Kit::GetParam('displaygroupid', _GET, _INT);
     $mediaList = Kit::GetParam('MediaID', _POST, _ARRAY_INT, array(), false);
     if ($displayGroupId == 0) {
         trigger_error(__('Display Group not selected'), E_USER_ERROR);
     }
     // Auth
     $auth = $this->user->DisplayGroupAuth($displayGroupId, true);
     if (!$auth->del) {
         trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR);
     }
     Kit::ClassLoader('displaygroup');
     $displayGroup = new DisplayGroup($this->db);
     if (!$displayGroup->AssociateFiles($this->user, $displayGroupId, $mediaList)) {
         trigger_error($displayGroup->GetErrorMessage(), E_USER_ERROR);
     }
     // Success
     $response->SetFormSubmitResponse(sprintf(__('%d Media Items Assigned'), count($mediaList)));
     $response->Respond();
 }
Example #2
0
 /**
  * Sets the Members of a group
  * @return
  */
 public function SetMemberOf()
 {
     $db =& $this->db;
     $response = new ResponseManager();
     Kit::ClassLoader('displaygroup');
     $displayGroupObject = new DisplayGroup($db);
     $displayID = Kit::GetParam('DisplayID', _REQUEST, _INT);
     $displayGroups = Kit::GetParam('DisplayGroupID', _POST, _ARRAY, array());
     $members = array();
     // Get a list of current members
     $SQL = "";
     $SQL .= "SELECT displaygroup.DisplayGroupID ";
     $SQL .= "FROM   displaygroup ";
     $SQL .= "   INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = displaygroup.DisplayGroupID ";
     $SQL .= sprintf("WHERE  lkdisplaydg.DisplayID   = %d ", $displayID);
     $SQL .= " AND displaygroup.IsDisplaySpecific = 0 ";
     if (!($resultIn = $db->query($SQL))) {
         trigger_error($db->error());
         trigger_error(__('Error getting Display Groups'), E_USER_ERROR);
     }
     while ($row = $db->get_assoc_row($resultIn)) {
         // Test whether this ID is in the array or not
         $displayGroupID = Kit::ValidateParam($row['DisplayGroupID'], _INT);
         if (!in_array($displayGroupID, $displayGroups)) {
             // Its currently assigned but not in the $displays array
             //  so we unassign
             if (!$displayGroupObject->Unlink($displayGroupID, $displayID)) {
                 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
             }
         } else {
             $members[] = $displayGroupID;
         }
     }
     foreach ($displayGroups as $displayGroupID) {
         // Add any that are missing
         if (!in_array($displayGroupID, $members)) {
             if (!$displayGroupObject->Link($displayGroupID, $displayID)) {
                 trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR);
             }
         }
     }
     $response->SetFormSubmitResponse(__('Group membership set'), false);
     $response->Respond();
 }
Example #3
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;
     }
 }