/** * Adds a Display * @return * @param $display Object * @param $isAuditing Object * @param $defaultLayoutID Object * @param $license Object * @param $licensed Object * @param $incSchedule Object */ public function Add($display, $isAuditing, $defaultLayoutID, $license, $licensed, $incSchedule) { Debug::LogEntry('audit', 'IN', 'Display', 'Add'); try { $dbh = PDOConnect::init(); // Create the SQL $SQL = ""; $SQL .= "INSERT INTO display (display, isAuditing, defaultlayoutid, license, licensed, inc_schedule, email_alert, alert_timeout) "; $SQL .= " VALUES (:display, :isauditing, :defaultlayoutid, :license, :licensed, :inc_schedule, :email_alert, :alert_timeout) "; $sth = $dbh->prepare($SQL); $sth->execute(array('display' => $display, 'isauditing' => 0, 'defaultlayoutid' => 1, 'license' => $license, 'licensed' => 0, 'inc_schedule' => 0, 'email_alert' => 0, 'alert_timeout' => 0)); // Get the ID of the inserted record $displayId = $dbh->lastInsertId(); // Also want to add the DisplayGroup associated with this Display. $displayGroupObject = new DisplayGroup($this->db); if (!($displayGroupId = $displayGroupObject->Add($display, 1, ''))) { $this->ThrowError(25001, __('Could not add a display group for the new display.')); } // Link the Two together if (!$displayGroupObject->Link($displayGroupId, $displayId)) { $this->ThrowError(25001, __('Could not link the new display with its group.')); } Debug::LogEntry('audit', 'OUT', 'Display', 'Add'); return $displayId; } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage()); if (!$this->IsError()) { $this->SetError(25000, __('Could not add display')); } return false; } }
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; }
/** * Adds a Display Group * @return */ public function Add() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); $displayGroup = Kit::GetParam('group', _POST, _STRING); $description = Kit::GetParam('desc', _POST, _STRING); $displayGroupObject = new DisplayGroup($db); if (!($displayGroupId = $displayGroupObject->Add($displayGroup, 0, $description))) { trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); } // Add full permissions for this user to this group $security = new DisplayGroupSecurity($db); if (!$security->Link($displayGroupId, $this->user->getGroupFromID($this->user->userid, true), 1, 1, 1)) { trigger_error(__('Unable to set permissions')); } $response->SetFormSubmitResponse(__('Display Group Added'), false); $response->Respond(); }