public function Permissions() { // Check the token if (!Kit::CheckToken()) { trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR); } $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $campaignId = Kit::GetParam('campaignId', _POST, _INT); $groupIds = Kit::GetParam('groupids', _POST, _ARRAY); $ownerId = Kit::GetParam('ownerId', _POST, _INT); $auth = $this->user->CampaignAuth($campaignId, true); if (!$auth->modifyPermissions) { trigger_error(__('You do not have permissions to edit this campaign'), E_USER_ERROR); } // Change the owner? if ($ownerId > 0) { // Update this Campaign with a new owner Campaign::setOwner($campaignId, $ownerId); } // Unlink all Kit::ClassLoader('campaignsecurity'); $security = new CampaignSecurity($db); if (!$security->UnlinkAll($campaignId)) { trigger_error(__('Unable to set permissions')); } // Some assignments for the loop $lastGroupId = 0; $first = true; $view = 0; $edit = 0; $del = 0; $permissions = array(); // List of groupIds with view, edit and del assignments foreach ($groupIds as $groupPermission) { $groupPermission = explode('_', $groupPermission); $groupId = $groupPermission[0]; if ($first) { // First time through $first = false; $lastGroupId = $groupId; } if ($groupId != $lastGroupId) { // The groupId has changed, so we need to write the current settings to the db. // Link new permissions if (!$security->Link($campaignId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions')); } // Store $permissions[] = array('groupId' => $lastGroupId, 'view' => $view, 'edit' => $edit, 'del' => $del); // Reset $lastGroupId = $groupId; $view = 0; $edit = 0; $del = 0; } switch ($groupPermission[1]) { case 'view': $view = 1; break; case 'edit': $edit = 1; break; case 'del': $del = 1; break; } } // Need to do the last one if (!$first) { if (!$security->Link($campaignId, $lastGroupId, $view, $edit, $del)) { trigger_error(__('Unable to set permissions')); } $permissions[] = array('groupId' => $lastGroupId, 'view' => $view, 'edit' => $edit, 'del' => $del); } $replaceInLayouts = Kit::GetParam('replaceInLayouts', _POST, _CHECKBOX); if ($replaceInLayouts) { Debug::LogEntry('audit', 'Permissions to push down: ' . json_encode($permissions), get_class(), __FUNCTION__); // Layout object to deal with layout information Kit::ClassLoader('layout'); $layoutObject = new Layout($db); // Get all layouts for this Campaign foreach ($this->user->LayoutList(NULL, array('campaignId' => $campaignId)) as $layout) { // Set for ease of use $layoutId = $layout['layoutid']; Debug::LogEntry('audit', 'Processing permissions for layout id' . $layoutId, get_class(), __FUNCTION__); // Set the permissions on this layout (if its not the same one!) if ($layout['campaignid'] != $campaignId) { // Set permissions on this Layout $auth = $this->user->CampaignAuth($layout['campaignid'], true); if ($auth->modifyPermissions) { if (!$security->UnlinkAll($layout['campaignid'])) { continue; } foreach ($permissions as $permission) { $security->Link($layout['campaignid'], $permission['groupId'], $permission['view'], $permission['edit'], $permission['del']); } } } // Get all regions and media and set permissions on those too $layoutInformation = $layoutObject->LayoutInformation($layoutId); // Region and Media Security Class Kit::ClassLoader('layoutregiongroupsecurity'); Kit::ClassLoader('layoutmediagroupsecurity'); $layoutSecurity = new LayoutRegionGroupSecurity($this->db); $layoutMediaSecurity = new LayoutMediaGroupSecurity($this->db); foreach ($layoutInformation['regions'] as $region) { // Make sure we have permission $regionAuth = $this->user->RegionAssignmentAuth($region['ownerid'], $layoutId, $region['regionid'], true); if (!$regionAuth->modifyPermissions) { continue; } // Set the permissions on the region // Unlink all if (!$layoutSecurity->UnlinkAll($layoutId, $region['regionid'])) { continue; } foreach ($permissions as $permission) { if (!$layoutSecurity->Link($layoutId, $region['regionid'], $permission['groupId'], $permission['view'], $permission['edit'], $permission['del'])) { trigger_error($layoutSecurity->GetErrorMessage(), E_USER_ERROR); } } // Find all media nodes foreach ($region['media'] as $media) { $originalUserId = $media['userid'] == '' ? $layout['ownerid'] : $media['userid']; // Make sure we have permission $mediaAuth = $this->user->MediaAssignmentAuth($originalUserId, $layoutId, $region['regionid'], $media['mediaid'], true); if (!$mediaAuth->modifyPermissions) { continue; } // Set the permissions on the media node if (!$layoutMediaSecurity->UnlinkAll($layoutId, $region['regionid'], $media['mediaid'])) { continue; } foreach ($permissions as $permission) { if (!$layoutMediaSecurity->Link($layoutId, $region['regionid'], $media['mediaid'], $permission['groupId'], $permission['view'], $permission['edit'], $permission['del'])) { trigger_error($layoutMediaSecurity->GetErrorMessage(), E_USER_ERROR); } } } } } } $response->SetFormSubmitResponse(__('Permissions Changed')); $response->Respond(); }
/** * Returns a string containing the required files xml for the requesting display * @param string $hardwareKey Display Hardware Key * @return string $requiredXml Xml Formatted String */ function RequiredFiles($serverKey, $hardwareKey, $version) { $db =& $this->db; // Sanitize $serverKey = Kit::ValidateParam($serverKey, _STRING); $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); $version = Kit::ValidateParam($version, _STRING); $rfLookahead = Kit::ValidateParam(Config::GetSetting('REQUIRED_FILES_LOOKAHEAD'), _INT); // Make sure we are talking the same language if (!$this->CheckVersion($version)) { throw new SoapFault('Sender', 'Your client is not of the correct version for communication with this server.'); } // Make sure we are sticking to our bandwidth limit if (!$this->CheckBandwidth()) { throw new SoapFault('Receiver', "Bandwidth Limit exceeded"); } $libraryLocation = Config::GetSetting("LIBRARY_LOCATION"); // auth this request... if (!$this->AuthDisplay($hardwareKey)) { throw new SoapFault('Sender', 'This display is not licensed.'); } if ($this->isAuditing == 1) { Debug::LogEntry("audit", '[IN] with hardware key: ' . $hardwareKey, "xmds", "RequiredFiles"); } $requiredFilesXml = new DOMDocument("1.0"); $fileElements = $requiredFilesXml->createElement("files"); $fileElements->setAttribute('version_instructions', $this->version_instructions); $requiredFilesXml->appendChild($fileElements); $currentdate = time(); $rfLookahead = $currentdate + $rfLookahead; // Get a list of all layout ids in the schedule right now. $SQL = " SELECT DISTINCT layout.layoutID "; $SQL .= " FROM `campaign` "; $SQL .= " INNER JOIN schedule_detail ON schedule_detail.CampaignID = campaign.CampaignID "; $SQL .= " INNER JOIN `lkcampaignlayout` ON lkcampaignlayout.CampaignID = campaign.CampaignID "; $SQL .= " INNER JOIN `layout` ON lkcampaignlayout.LayoutID = layout.LayoutID "; $SQL .= " INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = schedule_detail.DisplayGroupID "; $SQL .= " INNER JOIN display ON lkdisplaydg.DisplayID = display.displayID "; $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); $SQL .= sprintf(" AND schedule_detail.FromDT < %d AND schedule_detail.ToDT > %d ", $rfLookahead, $currentdate - 3600); $SQL .= " AND layout.retired = 0 "; if ($this->isAuditing == 1) { Debug::LogEntry("audit", $SQL, "xmds", "RequiredFiles"); } if (!($results = $db->query($SQL))) { trigger_error($db->error()); return new SoapFault('Sender', 'Unable to get a list of layouts'); } // Our layout list will always include the default layout $layouts = array(); $layouts[] = $this->defaultLayoutId; // Build up the other layouts into an array while ($row = $db->get_assoc_row($results)) { $layouts[] = Kit::ValidateParam($row['layoutID'], _INT); } // Create a comma separated list to pass into the query which gets file nodes $layoutIdList = implode(',', $layouts); // Add file nodes to the $fileElements $SQL = " SELECT 'layout' AS RecordType, layout.layoutID AS path, layout.layoutID AS id, MD5(layout.xml) AS `MD5`, NULL AS FileSize, layout.background, layout.xml AS xml "; $SQL .= " FROM layout "; $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList); $SQL .= " UNION "; $SQL .= " SELECT 'media' AS RecordType, storedAs AS path, media.mediaID AS id, media.`MD5`, media.FileSize, NULL AS background, NULL AS xml "; $SQL .= " FROM media "; $SQL .= " \tINNER JOIN lklayoutmedia "; $SQL .= " \tON lklayoutmedia.MediaID = media.MediaID "; $SQL .= " \tINNER JOIN layout "; $SQL .= " \tON layout.LayoutID = lklayoutmedia.LayoutID"; $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList); $SQL .= "\r\n UNION\r\n SELECT 'media' AS RecordType, storedAs AS path, media.mediaID AS id, media.`MD5`, media.FileSize, NULL AS background, NULL AS xml \r\n FROM `media`\r\n INNER JOIN `lkmediadisplaygroup`\r\n ON lkmediadisplaygroup.mediaid = media.MediaID\r\n INNER JOIN lkdisplaydg \r\n ON lkdisplaydg.DisplayGroupID = lkmediadisplaygroup.DisplayGroupID\r\n INNER JOIN display \r\n ON lkdisplaydg.DisplayID = display.displayID\r\n "; $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); $SQL .= " ORDER BY RecordType DESC"; if ($this->isAuditing == 1) { Debug::LogEntry("audit", $SQL, "xmds", "RequiredFiles"); } if (!($results = $db->query($SQL))) { trigger_error($db->error()); return new SoapFault('Sender', 'Unable to get a list of files'); } while ($row = $db->get_assoc_row($results)) { $recordType = Kit::ValidateParam($row['RecordType'], _WORD); $path = Kit::ValidateParam($row['path'], _STRING); $id = Kit::ValidateParam($row['id'], _STRING); $md5 = Kit::ValidateParam($row['MD5'], _HTMLSTRING); $fileSize = Kit::ValidateParam($row['FileSize'], _INT); $background = Kit::ValidateParam($row['background'], _STRING); $xml = Kit::ValidateParam($row['xml'], _HTMLSTRING); if ($recordType == 'layout') { // For layouts the MD5 column is the layout xml $fileSize = strlen($xml); if ($this->isAuditing == 1) { Debug::LogEntry("audit", 'MD5 for layoutid ' . $id . ' is: [' . $md5 . ']', "xmds", "RequiredFiles"); } } else { if ($recordType == 'media') { // If they are empty calculate them and save them back to the media. if ($md5 == '' || $fileSize == 0) { $md5 = md5_file($libraryLocation . $path); $fileSize = filesize($libraryLocation . $path); // Update the media record with this information $SQL = sprintf("UPDATE media SET `MD5` = '%s', FileSize = %d WHERE MediaID = %d", $md5, $fileSize, $id); if (!$db->query($SQL)) { trigger_error($db->error()); } } } else { continue; } } // Add the file node $file = $requiredFilesXml->createElement("file"); $file->setAttribute("type", $recordType); $file->setAttribute("path", $path); $file->setAttribute("id", $id); $file->setAttribute("size", $fileSize); $file->setAttribute("md5", $md5); $fileElements->appendChild($file); // If this is a layout type and there is a background then add the background node // TODO: We need to alter the layout table to have a background ID rather than a path // TODO: We need to alter the background edit method to create a lklayoutmedia link for // background images (and maintain it when they change) if ($recordType == 'layout' && $background != '') { // Also append another file node for the background image (if there is one) $file = $requiredFilesXml->createElement("file"); $file->setAttribute("type", "media"); $file->setAttribute("path", $background); $file->setAttribute("md5", md5_file($libraryLocation . $background)); $file->setAttribute("size", filesize($libraryLocation . $background)); $fileElements->appendChild($file); } } Kit::ClassLoader('layout'); // Go through each layout and see if we need to supply any resource nodes. foreach ($layouts as $layoutId) { // Load the layout XML and work out if we have any ticker / text / dataset media items $layout = new Layout($db); $layoutInformation = $layout->LayoutInformation($layoutId); foreach ($layoutInformation['regions'] as $region) { foreach ($region['media'] as $media) { if ($media['mediatype'] == 'ticker' || $media['mediatype'] == 'text' || $media['mediatype'] == 'datasetview') { // Append this item to required files $file = $requiredFilesXml->createElement("file"); $file->setAttribute('type', 'resource'); $file->setAttribute('id', rand()); $file->setAttribute('layoutid', $layoutId); $file->setAttribute('regionid', $region['regionid']); $file->setAttribute('mediaid', $media['mediaid']); $fileElements->appendChild($file); } } } } // Add a blacklist node $blackList = $requiredFilesXml->createElement("file"); $blackList->setAttribute("type", "blacklist"); $fileElements->appendChild($blackList); // Populate $SQL = "SELECT MediaID\r\n FROM blacklist\r\n WHERE DisplayID = " . $this->displayId . "\r\n AND isIgnored = 0"; if (!($results = $db->query($SQL))) { trigger_error($db->error()); return new SoapFault('Sender', 'Unable to get a list of blacklisted files'); } // Add a black list element for each file while ($row = $db->get_row($results)) { $file = $requiredFilesXml->createElement("file"); $file->setAttribute("id", $row[0]); $blackList->appendChild($file); } // Phone Home? $this->PhoneHome(); if ($this->isAuditing == 1) { Debug::LogEntry("audit", $requiredFilesXml->saveXML(), "xmds", "RequiredFiles"); Debug::LogEntry("audit", "[OUT]", "xmds", "RequiredFiles"); } // Return the results of requiredFiles() $requiredFilesXml->formatOutput = true; $output = $requiredFilesXml->saveXML(); // Log Bandwidth $this->LogBandwidth($this->displayId, 2, strlen($output)); return $output; }
/** * Returns a string containing the required files xml for the requesting display * @param string $serverKey The Server Key * @param string $hardwareKey Display Hardware Key * @return string $requiredXml Xml Formatted String * @throws SoapFault */ function RequiredFiles($serverKey, $hardwareKey) { // Sanitize $serverKey = Kit::ValidateParam($serverKey, _STRING); $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); $rfLookAhead = Kit::ValidateParam(Config::GetSetting('REQUIRED_FILES_LOOKAHEAD'), _INT); // Check the serverKey matches if ($serverKey != Config::GetSetting('SERVER_KEY')) { throw new SoapFault('Sender', 'The Server key you entered does not match with the server key at this address'); } // Make sure we are sticking to our bandwidth limit if (!$this->CheckBandwidth()) { throw new SoapFault('Receiver', 'Bandwidth Limit exceeded'); } $libraryLocation = Config::GetSetting("LIBRARY_LOCATION"); // auth this request... if (!$this->AuthDisplay($hardwareKey)) { throw new SoapFault('Sender', 'This display is not licensed.'); } if ($this->isAuditing == 1) { Debug::Audit('hardwareKey = ' . $hardwareKey, $this->displayId); } // Remove all Nonces for this display $nonce = new Nonce(); $nonce->RemoveAllXmdsNonce($this->displayId); // Build a new RF $requiredFilesXml = new DOMDocument("1.0"); $fileElements = $requiredFilesXml->createElement("files"); $requiredFilesXml->appendChild($fileElements); // Hour to hour time bands for the query // Start at the current hour $fromFilter = time(); // Move forwards an hour and the rf look ahead $rfLookAhead = $fromFilter + 3600 + $rfLookAhead; // Dial both items back to the top of the hour $fromFilter = $fromFilter - $fromFilter % 3600; $toFilter = $rfLookAhead - $rfLookAhead % 3600; if ($this->isAuditing == 1) { Debug::Audit(sprintf('Required files date criteria. FromDT = %s. ToDt = %s', date('Y-m-d h:i:s', $fromFilter), date('Y-m-d h:i:s', $toFilter)), $this->displayId); } try { $dbh = PDOConnect::init(); // Get a list of all layout ids in the schedule right now. $SQL = " SELECT DISTINCT layout.layoutID "; $SQL .= " FROM `campaign` "; $SQL .= " INNER JOIN schedule ON schedule.CampaignID = campaign.CampaignID "; $SQL .= " INNER JOIN schedule_detail ON schedule_detail.eventID = schedule.eventID "; $SQL .= " INNER JOIN `lkcampaignlayout` ON lkcampaignlayout.CampaignID = campaign.CampaignID "; $SQL .= " INNER JOIN `layout` ON lkcampaignlayout.LayoutID = layout.LayoutID "; $SQL .= " INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = schedule_detail.DisplayGroupID "; $SQL .= " WHERE lkdisplaydg.DisplayID = :displayId "; $SQL .= " AND schedule_detail.FromDT < :fromdt AND schedule_detail.ToDT > :todt "; $SQL .= " AND layout.retired = 0 "; $sth = $dbh->prepare($SQL); $sth->execute(array('displayId' => $this->displayId, 'fromdt' => $toFilter, 'todt' => $fromFilter)); // Our layout list will always include the default layout $layouts = array(); $layouts[] = $this->defaultLayoutId; // Build up the other layouts into an array foreach ($sth->fetchAll() as $row) { $layouts[] = Kit::ValidateParam($row['layoutID'], _INT); } } catch (Exception $e) { Debug::Error('Error getting layout listing. ' . $e->getMessage(), $this->displayId); return new SoapFault('Sender', 'Unable to get a list of layouts'); } // Create a comma separated list to pass into the query which gets file nodes $layoutIdList = implode(',', $layouts); try { $dbh = PDOConnect::init(); // Add file nodes to the $fileElements $SQL = "\n SELECT 1 AS DownloadOrder, 'media' AS RecordType, storedAs AS path, media.mediaID AS id, media.`MD5`, media.FileSize, NULL AS xml\n FROM `media`\n WHERE media.type = 'font'\n OR (media.type = 'module' AND media.moduleSystemFile = 1)\n UNION\n "; $SQL .= " SELECT 4 AS DownloadOrder, 'layout' AS RecordType, layout.layoutID AS path, layout.layoutID AS id, MD5(layout.xml) AS `MD5`, NULL AS FileSize, layout.xml AS xml "; $SQL .= " FROM layout "; $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList); $SQL .= " UNION "; $SQL .= " SELECT 3 AS DownloadOrder, 'media' AS RecordType, storedAs AS path, media.mediaID AS id, media.`MD5`, media.FileSize, NULL AS xml "; $SQL .= " FROM media "; $SQL .= " INNER JOIN lklayoutmedia "; $SQL .= " ON lklayoutmedia.MediaID = media.MediaID "; $SQL .= " INNER JOIN layout "; $SQL .= " ON layout.LayoutID = lklayoutmedia.LayoutID"; $SQL .= sprintf(" WHERE layout.layoutid IN (%s) ", $layoutIdList); $SQL .= "\n UNION\n SELECT 2 AS DownloadOrder, 'media' AS RecordType, storedAs AS path, media.mediaID AS id, media.`MD5`, media.FileSize, NULL AS xml\n FROM `media`\n INNER JOIN `lkmediadisplaygroup`\n ON lkmediadisplaygroup.mediaid = media.MediaID\n INNER JOIN lkdisplaydg\n ON lkdisplaydg.DisplayGroupID = lkmediadisplaygroup.DisplayGroupID\n "; $SQL .= " WHERE lkdisplaydg.DisplayID = :displayId "; $SQL .= " ORDER BY DownloadOrder, RecordType DESC"; $sth = $dbh->prepare($SQL); $sth->execute(array('displayId' => $this->displayId)); // Prepare a SQL statement in case we need to update the MD5 and FileSize on media nodes. $mediaSth = $dbh->prepare('UPDATE media SET `MD5` = :md5, FileSize = :size WHERE MediaID = :mediaid'); // What is the send file mode? $sendFileMode = Config::GetSetting('SENDFILE_MODE'); // Keep a list of path names added to RF to prevent duplicates $pathsAdded = array(); foreach ($sth->fetchAll() as $row) { $recordType = Kit::ValidateParam($row['RecordType'], _WORD); $path = Kit::ValidateParam($row['path'], _STRING); $id = Kit::ValidateParam($row['id'], _STRING); $md5 = Kit::ValidateParam($row['MD5'], _HTMLSTRING); $fileSize = Kit::ValidateParam($row['FileSize'], _INT); $xml = Kit::ValidateParam($row['xml'], _HTMLSTRING); $mediaNonce = ''; if ($recordType == 'layout') { // Check we haven't added this before if (in_array('layout_' . $id, $pathsAdded)) { continue; } // For layouts the MD5 column is the layout xml $fileSize = strlen($xml); if ($this->isAuditing == 1) { Debug::Audit('MD5 for layoutId ' . $id . ' is: [' . $md5 . ']', $this->displayId); } // Add nonce $nonce->AddXmdsNonce('layout', $this->displayId, NULL, $fileSize, NULL, $id); $pathsAdded[] = 'layout_' . $id; } else { if ($recordType == 'media') { // Check we haven't added this before if (in_array('media_' . $path, $pathsAdded)) { continue; } // If they are empty calculate them and save them back to the media. if ($md5 == '' || $fileSize == 0) { $md5 = md5_file($libraryLocation . $path); $fileSize = filesize($libraryLocation . $path); // Update the media record with this information $mediaSth->execute(array('md5' => $md5, 'size' => $fileSize, 'mediaid' => $id)); } // Add nonce $mediaNonce = $nonce->AddXmdsNonce('file', $this->displayId, $id, $fileSize, $path); $pathsAdded[] = 'media_' . $path; } else { continue; } } // Add the file node $file = $requiredFilesXml->createElement("file"); $file->setAttribute("type", $recordType); $file->setAttribute("id", $id); $file->setAttribute("size", $fileSize); $file->setAttribute("md5", $md5); if ($recordType == 'media' && $sendFileMode != 'Off') { // Serve a link instead (standard HTTP link) $file->setAttribute("path", Kit::GetXiboRoot() . '?file=' . $mediaNonce); $file->setAttribute("saveAs", $path); $file->setAttribute("download", 'http'); } else { $file->setAttribute("download", 'xmds'); $file->setAttribute("path", $path); } $fileElements->appendChild($file); } } catch (Exception $e) { Debug::Error('Unable to get a list of required files. ' . $e->getMessage(), $this->displayId); return new SoapFault('Sender', 'Unable to get a list of files'); } // Go through each layout and see if we need to supply any resource nodes. foreach ($layouts as $layoutId) { // Load the layout XML and work out if we have any ticker / text / data set media items $layout = new Layout(); $layoutInformation = $layout->LayoutInformation($layoutId); foreach ($layoutInformation['regions'] as $region) { foreach ($region['media'] as $media) { if ($media['render'] == 'html' || $media['mediatype'] == 'ticker' || $media['mediatype'] == 'text' || $media['mediatype'] == 'datasetview' || $media['mediatype'] == 'webpage' || $media['mediatype'] == 'embedded') { // Append this item to required files $file = $requiredFilesXml->createElement("file"); $file->setAttribute('type', 'resource'); $file->setAttribute('id', rand()); $file->setAttribute('layoutid', $layoutId); $file->setAttribute('regionid', $region['regionid']); $file->setAttribute('mediaid', $media['mediaid']); $file->setAttribute('updated', isset($media['updated']) ? $media['updated'] : 0); $fileElements->appendChild($file); $nonce->AddXmdsNonce('resource', $this->displayId, NULL, NULL, NULL, $layoutId, $region['regionid'], $media['mediaid']); } } } } // Add a blacklist node $blackList = $requiredFilesXml->createElement("file"); $blackList->setAttribute("type", "blacklist"); $fileElements->appendChild($blackList); try { $dbh = PDOConnect::init(); $sth = $dbh->prepare('SELECT MediaID FROM blacklist WHERE DisplayID = :displayid AND isIgnored = 0'); $sth->execute(array('displayid' => $this->displayId)); // Add a black list element for each file foreach ($sth->fetchAll() as $row) { $file = $requiredFilesXml->createElement("file"); $file->setAttribute("id", $row['MediaID']); $blackList->appendChild($file); } } catch (Exception $e) { Debug::Error('Unable to get a list of blacklisted files. ' . $e->getMessage(), $this->displayId); return new SoapFault('Sender', 'Unable to get a list of blacklisted files'); } // Phone Home? $this->PhoneHome(); if ($this->isAuditing == 1) { Debug::Audit($requiredFilesXml->saveXML(), $this->displayId); } // Return the results of requiredFiles() $requiredFilesXml->formatOutput = true; $output = $requiredFilesXml->saveXML(); // Log Bandwidth $this->LogBandwidth($this->displayId, Bandwidth::$RF, strlen($output)); return $output; }
function ManualRegionPositionForm() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $regionid = Kit::GetParam('regionid', _GET, _STRING); $layoutid = Kit::GetParam('layoutid', _GET, _INT); $scale = Kit::GetParam('scale', _GET, _DOUBLE); $zoom = Kit::GetParam('zoom', _GET, _DOUBLE); // Load the region and get the dimensions, applying the scale factor if necessary (only v1 layouts will have a scale factor != 1) $region = new region($db); $regionNode = $region->getRegion($layoutid, $regionid); $top = round($regionNode->getAttribute('top') * $scale, 0); $left = round($regionNode->getAttribute('left') * $scale, 0); $width = round($regionNode->getAttribute('width') * $scale, 0); $height = round($regionNode->getAttribute('height') * $scale, 0); $zindex = $regionNode->getAttribute('zindex'); $ownerId = $region->GetOwnerId($layoutid, $regionid); $regionName = $regionNode->getAttribute('name'); $regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutid, $regionid, true); if (!$regionAuth->edit) { trigger_error(__('You do not have permissions to edit this region'), E_USER_ERROR); } // Set some information about the form Theme::Set('form_id', 'RegionProperties'); Theme::Set('form_action', 'index.php?p=timeline&q=ManualRegionPosition'); Theme::Set('form_meta', '<input type="hidden" name="layoutid" value="' . $layoutid . '"><input type="hidden" name="regionid" value="' . $regionid . '"><input type="hidden" name="scale" value="' . $scale . '"><input type="hidden" name="zoom" value="' . $zoom . '">'); $formFields = array(); $formFields[] = FormManager::AddText('name', __('Name'), $regionName, __('Name of the Region'), 'n', 'maxlength="50"'); $formFields[] = FormManager::AddNumber('top', __('Top'), $top, __('Offset from the Top Corner'), 't'); $formFields[] = FormManager::AddNumber('left', __('Left'), $left, __('Offset from the Left Corner'), 'l'); $formFields[] = FormManager::AddNumber('width', __('Width'), $width, __('Width of the Region'), 'w'); $formFields[] = FormManager::AddNumber('height', __('Height'), $height, __('Height of the Region'), 'h'); // Transitions if (count($this->user->TransitionAuth('out')) > 0) { // Add none to the list $transitions = $this->user->TransitionAuth('out'); $transitions[] = array('code' => '', 'transition' => 'None', 'class' => ''); $formFields[] = FormManager::AddCombo('transitionType', __('Exit Transition'), $region->GetOption($layoutid, $regionid, 'transOut', ''), $transitions, 'code', 'transition', __('What transition should be applied when this region is finished?'), 't'); $formFields[] = FormManager::AddNumber('transitionDuration', __('Duration'), $region->GetOption($layoutid, $regionid, 'transOutDuration', 0), __('The duration for this transition, in milliseconds.'), 'l', '', 'transition-group'); // Compass points for direction $compassPoints = array(array('id' => 'N', 'name' => __('North')), array('id' => 'NE', 'name' => __('North East')), array('id' => 'E', 'name' => __('East')), array('id' => 'SE', 'name' => __('South East')), array('id' => 'S', 'name' => __('South')), array('id' => 'SW', 'name' => __('South West')), array('id' => 'W', 'name' => __('West')), array('id' => 'NW', 'name' => __('North West'))); $formFields[] = FormManager::AddCombo('transitionDirection', __('Direction'), $region->GetOption($layoutid, $regionid, 'transOutDirection', ''), $compassPoints, 'id', 'name', __('The direction for this transition. Only appropriate for transitions that move, such as Fly.'), 'd', 'transition-group transition-direction'); // Add some dependencies $response->AddFieldAction('transitionType', 'init', '', array('.transition-group' => array('display' => 'none'))); $response->AddFieldAction('transitionType', 'init', '', array('.transition-group' => array('display' => 'block')), 'not'); $response->AddFieldAction('transitionType', 'change', '', array('.transition-group' => array('display' => 'none'))); $response->AddFieldAction('transitionType', 'change', '', array('.transition-group' => array('display' => 'block')), 'not'); } $formFields[] = FormManager::AddCheckbox('loop', __('Loop?'), $region->GetOption($layoutid, $regionid, 'loop', 0), __('If there is only one item in this region should it loop? Not currently available for Windows Players.'), 'l'); $formFields[] = FormManager::AddNumber('zindex', __('Layer'), $zindex == 0 ? NULL : $zindex, __('The layering order of this region (z-index). Advanced use only. '), 'z'); Theme::Set('form_fields', $formFields); // Add some information about the whole layout to this request. $layout = new Layout(); $layoutInformation = $layout->LayoutInformation($layoutid); $response->extra['layoutInformation'] = array('width' => $layoutInformation['width'], 'height' => $layoutInformation['height']); $response->SetFormRequestResponse(NULL, __('Region Options'), '350px', '275px'); $response->AddButton(__('Cancel'), 'XiboDialogClose()'); $response->AddButton(__('Save'), '$("#RegionProperties").submit()'); $response->AddButton(__('Set Full Screen'), 'setFullScreenLayout()'); $response->Respond(); }