/** * Edits a Display Group * @return */ public function Edit() { // Check the token if (!Kit::CheckToken()) { trigger_error('Token does not match', E_USER_ERROR); } $db =& $this->db; $response = new ResponseManager(); $displayGroupID = Kit::GetParam('DisplayGroupID', _POST, _INT); $displayGroup = Kit::GetParam('group', _POST, _STRING); $description = Kit::GetParam('desc', _POST, _STRING); // Auth $auth = $this->user->DisplayGroupAuth($displayGroupID, true); if (!$auth->edit) { trigger_error(__('You do not have permission to edit this display group'), E_USER_ERROR); } // Deal with the Edit $displayGroupObject = new DisplayGroup($db); if (!$displayGroupObject->Edit($displayGroupID, $displayGroup, $description)) { trigger_error($displayGroupObject->GetErrorMessage(), E_USER_ERROR); } $response->SetFormSubmitResponse(__('Display Group Edited'), false); $response->Respond(); }
/** * Edits a Display * @return * @param $displayID Object * @param $isAuditing Object * @param $defaultLayoutID Object * @param $licensed Object * @param $incSchedule Object */ public function Edit() { Debug::LogEntry('audit', 'IN', get_class(), __FUNCTION__); // Validation if ($this->display == '') { return $this->SetError(__("Can not have a display without a name")); } if ($this->wakeOnLanEnabled == 1 && $this->wakeOnLanTime == '') { return $this->SetError(__('Wake on Lan is enabled, but you have not specified a time to wake the display')); } try { $dbh = PDOConnect::init(); // Check the number of licensed displays $maxDisplays = Config::GetSetting('MAX_LICENSED_DISPLAYS'); if ($maxDisplays > 0) { // See if this is a license switch // Has the licence flag toggled? if ($this->currentLicensed != $this->licensed && $this->licensed == 1) { // License change - test number of licensed displays. $sth = $dbh->prepare('SELECT COUNT(DisplayID) AS CountLicensed FROM display WHERE licensed = 1'); $sth->execute(); if (!($row = $sth->fetch())) { $this->ThrowError(1, __('Unable to get count of licensed displays.')); } $count = Kit::ValidateParam($row['CountLicensed'], _INT); $sth->closeCursor(); if ($count + 1 > $maxDisplays) { $this->ThrowError(25000, sprintf(__('You have exceeded your maximum number of licensed displays. %d'), $maxDisplays)); } } } // Validate some parameters // Fill $addr with client's IP address, if $addr is empty if ($this->broadCastAddress != '') { // Resolve broadcast address // same as (but easier than): preg_match("/\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b/",$addr) if (!filter_var($this->broadCastAddress, FILTER_VALIDATE_IP)) { $this->ThrowError(25015, __('BroadCast Address is not a valid IP Address')); } } // Check whether $cidr is valid if ($this->cidr != '') { if (!is_numeric($this->cidr) || $this->cidr < 0 || $this->cidr > 32) { $this->ThrowError(25015, __('CIDR subnet mask is not a number within the range of 0 to 32.')); } } // Check whether $secureOn is valid if ($this->secureOn != '') { $this->secureOn = strtoupper($this->secureOn); $this->secureOn = str_replace(":", "-", $this->secureOn); if (!preg_match("/([A-F0-9]{2}[-]){5}([0-9A-F]){2}/", $this->secureOn) || strlen($this->secureOn) != 17) { $this->ThrowError(25015, __('Pattern of secureOn-password is not "xx-xx-xx-xx-xx-xx" (x = digit or CAPITAL letter)')); } } Debug::LogEntry('audit', 'Validation Complete and Passed', 'Display', 'Edit'); // Update the display record $SQL = ' UPDATE display SET display = :display, defaultlayoutid = :defaultlayoutid, inc_schedule = :incschedule, licensed = :licensed, isAuditing = :isauditing, email_alert = :emailalert, alert_timeout = :alerttimeout, WakeOnLan = :wakeonlan, WakeOnLanTime = :wakeonlantime, BroadCastAddress = :broadcastaddress, SecureOn = :secureon, Cidr = :cidr, GeoLocation = POINT(:latitude, :longitude), displayprofileid = :displayprofileid WHERE displayid = :displayid'; $sth = $dbh->prepare($SQL); $sth->execute(array('display' => $this->display, 'defaultlayoutid' => $this->defaultLayoutId, 'incschedule' => $this->incSchedule, 'licensed' => $this->licensed, 'isauditing' => $this->isAuditing, 'emailalert' => $this->emailAlert, 'alerttimeout' => $this->alertTimeout, 'wakeonlan' => $this->wakeOnLanEnabled, 'wakeonlantime' => $this->wakeOnLanTime, 'broadcastaddress' => $this->broadCastAddress, 'secureon' => $this->secureOn, 'cidr' => $this->cidr, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'displayprofileid' => $this->displayProfileId, 'displayid' => $this->displayId)); Debug::LogEntry('audit', 'Display Edited', 'Display', 'Edit'); // Use a DisplayGroup to handle the default layout and displaygroup name for this display Kit::ClassLoader('displaygroup'); $displayGroupObject = new DisplayGroup(); // Do we also want to update the linked Display Groups name (seeing as that is what we will be presenting to everyone) if (!$displayGroupObject->Edit($this->displayGroupId, $this->display, $this->description)) { $this->ThrowError(25002, __('Could not update this display with a new name.')); } \Xibo\Helper\Log::audit('Display', $this->displayId, 'Display Edited', $this->jsonSerialize()); return true; } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage(), get_class(), __FUNCTION__); if (!$this->IsError()) { $this->SetError(25000, __('Could not update display')); } return false; } }