public function Boot() { $db =& $this->db; // Will need to add some upgrade PHP to create a DisplayGroup (+ link record) for every Currently existing display. $dg = new DisplayGroup($db); // Get all displays $SQL = "SELECT DisplayID, Display FROM display"; if (!($result = $db->query($SQL))) { reportError('20.php', "Error creating display groups"); } while ($row = $db->get_assoc_row($result)) { // For each display create a display group and link it to the display $displayID = Kit::ValidateParam($row['DisplayID'], _INT); $display = Kit::ValidateParam($row['Display'], _STRING); $displayGroupID = $dg->Add($display, 1); $dg->Link($displayGroupID, $displayID); } // We also need to do a number on the schedule records // Each schedule record needs to be altered so that the displayID_list now reflects the displayGroupIDs $this->UpdateSchedules(); // Create groups for all current users $this->UpdateUserGroups(); return true; }
/** * 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(); }
/** * 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; } }
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(); }
/** * Edits a Displays Name * @return * @param $license Object * @param $display Object */ public function EditDisplayName($license, $display) { Debug::LogEntry('audit', 'IN', 'DisplayGroup', 'EditDisplayName'); try { $dbh = PDOConnect::init(); // Update the display with its new name (using the licence as the key) $sth = $dbh->prepare('UPDATE display SET display = :display WHERE license = :license'); $sth->execute(array('display' => $display, 'license' => $license)); // Also need to update the display group name here. $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->EditDisplayGroup($displayID, $display)) { $this->ThrowError(25015, __('Could not update this display with a new name.')); } Debug::LogEntry('audit', 'OUT', 'DisplayGroup', 'EditDisplayName'); return true; } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage()); if (!$this->IsError()) { $this->SetError(25015, __('Unable to edit display record.')); } return false; } }