芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/avenida/views/Factory.zip
PK qYD/ / CampaignFactory.phpnu [ . */ namespace Xibo\Factory; use Xibo\Entity\Campaign; use Xibo\Entity\User; use Xibo\Exception\NotFoundException; use Xibo\Service\LogServiceInterface; use Xibo\Service\SanitizerServiceInterface; use Xibo\Storage\StorageServiceInterface; /** * Class CampaignFactory * @package Xibo\Factory */ class CampaignFactory extends BaseFactory { /** * @var PermissionFactory */ private $permissionFactory; /** * @var ScheduleFactory */ private $scheduleFactory; /** * @var DisplayFactory */ private $displayFactory; /** * @var TagFactory */ private $tagFactory; /** * Construct a factory * @param StorageServiceInterface $store * @param LogServiceInterface $log * @param SanitizerServiceInterface $sanitizerService * @param User $user * @param UserFactory $userFactory * @param PermissionFactory $permissionFactory * @param ScheduleFactory $scheduleFactory * @param DisplayFactory $displayFactory */ public function __construct($store, $log, $sanitizerService, $user, $userFactory, $permissionFactory, $scheduleFactory, $displayFactory, $tagFactory) { $this->setCommonDependencies($store, $log, $sanitizerService); $this->setAclDependencies($user, $userFactory); $this->permissionFactory = $permissionFactory; $this->scheduleFactory = $scheduleFactory; $this->displayFactory = $displayFactory; $this->tagFactory = $tagFactory; } /** * @return Campaign */ public function createEmpty() { return new Campaign($this->getStore(), $this->getLog(), $this->permissionFactory, $this->scheduleFactory, $this->displayFactory, $this->tagFactory); } /** * Create Campaign * @param string $name * @param int $userId * @param string $tags * @return Campaign */ public function create($name, $userId, $tags) { $campaign = $this->createEmpty(); $campaign->ownerId = $userId; $campaign->campaign = $name; // Create some tags $campaign->tags = $this->tagFactory->tagsFromString($tags); return $campaign; } /** * Get Campaign by ID * @param int $campaignId * @return Campaign * @throws NotFoundException */ public function getById($campaignId) { $this->getLog()->debug('CampaignFactory getById(%d)', $campaignId); $campaigns = $this->query(null, array('disableUserCheck' => 1, 'campaignId' => $campaignId, 'isLayoutSpecific' => -1, 'excludeTemplates' => -1)); if (count($campaigns) <= 0) { $this->getLog()->debug('Campaign not found with ID %d', $campaignId); throw new NotFoundException(\__('Campaign not found')); } // Set our layout return $campaigns[0]; } /** * Get Campaign by Owner Id * @param int $ownerId * @return array[Campaign] */ public function getByOwnerId($ownerId) { return $this->query(null, array('ownerId' => $ownerId, 'excludeTemplates' => -1)); } /** * Get Campaign by Layout * @param int $layoutId * @return array[Campaign] */ public function getByLayoutId($layoutId) { return $this->query(null, array('disableUserCheck' => 1, 'layoutId' => $layoutId, 'excludeTemplates' => -1)); } /** * Query Campaigns * @param array $sortOrder * @param array $filterBy * @return array[Campaign] */ public function query($sortOrder = null, $filterBy = array(), $options = array()) { if ($sortOrder == null) $sortOrder = array('campaign'); $campaigns = array(); $params = array(); $select = ' SELECT `campaign`.campaignId, `campaign`.campaign, `campaign`.isLayoutSpecific, `campaign`.userId AS ownerId, ( SELECT COUNT(*) FROM lkcampaignlayout WHERE lkcampaignlayout.campaignId = `campaign`.campaignId ) AS numberLayouts, MAX(CASE WHEN `campaign`.IsLayoutSpecific = 1 THEN `layout`.retired ELSE 0 END) AS retired, ( SELECT GROUP_CONCAT(DISTINCT tag) FROM tag INNER JOIN lktagcampaign ON lktagcampaign.tagId = tag.tagId WHERE lktagcampaign.campaignId = campaign.CampaignID GROUP BY lktagcampaign.campaignId ) AS tags, ( SELECT GROUP_CONCAT(IFNULL(value, \'NULL\')) FROM tag INNER JOIN lktagcampaign ON lktagcampaign.tagId = tag.tagId WHERE lktagcampaign.campaignId = campaign.CampaignID GROUP BY lktagcampaign.campaignId ) AS tagValues '; $body = ' FROM `campaign` LEFT OUTER JOIN `lkcampaignlayout` ON lkcampaignlayout.CampaignID = campaign.CampaignID LEFT OUTER JOIN `layout` ON lkcampaignlayout.LayoutID = layout.LayoutID INNER JOIN `user` ON user.userId = campaign.userId WHERE 1 = 1 '; // View Permissions $this->viewPermissionSql('Xibo\Entity\Campaign', $body, $params, '`campaign`.campaignId', '`campaign`.userId', $filterBy); if ($this->getSanitizer()->getString('isLayoutSpecific', 0, $filterBy) != -1) { // Exclude layout specific campaigns $body .= " AND `campaign`.isLayoutSpecific = :isLayoutSpecific "; $params['isLayoutSpecific'] = $this->getSanitizer()->getString('isLayoutSpecific', 0, $filterBy); } if ($this->getSanitizer()->getString('campaignId', 0, $filterBy) != 0) { // Join Campaign back onto it again $body .= " AND `campaign`.campaignId = :campaignId "; $params['campaignId'] = $this->getSanitizer()->getString('campaignId', 0, $filterBy); } if ($this->getSanitizer()->getString('ownerId', 0, $filterBy) != 0) { // Join Campaign back onto it again $body .= " AND `campaign`.userId = :ownerId "; $params['ownerId'] = $this->getSanitizer()->getString('ownerId', 0, $filterBy); } if ($this->getSanitizer()->getString('layoutId', 0, $filterBy) != 0) { // Filter by Layout $body .= " AND `lkcampaignlayout`.layoutId = :layoutId "; $params['layoutId'] = $this->getSanitizer()->getString('layoutId', 0, $filterBy); } if ($this->getSanitizer()->getString('hasLayouts', 0, $filterBy) != 0) { $body .= " AND ( SELECT COUNT(*) FROM lkcampaignlayout WHERE lkcampaignlayout.campaignId = `campaign`.campaignId )"; $body .= ($this->getSanitizer()->getString('hasLayouts', 0, $filterBy) == 1) ? " = 0 " : " > 0"; } // Tags if ($this->getSanitizer()->getString('tags', $filterBy) != '') { $tagFilter = $this->getSanitizer()->getString('tags', $filterBy); if (trim($tagFilter) === '--no-tag') { $body .= ' AND `campaign`.campaignID NOT IN ( SELECT `lktagcampaign`.campaignId FROM `tag` INNER JOIN `lktagcampaign` ON `lktagcampaign`.tagId = `tag`.tagId ) '; } else { $operator = $this->getSanitizer()->getCheckbox('exactTags') == 1 ? '=' : 'LIKE'; $body .= " AND campaign.campaignID IN ( SELECT lktagcampaign.campaignId FROM tag INNER JOIN lktagcampaign ON lktagcampaign.tagId = tag.tagId "; $tags = explode(',', $tagFilter); $this->tagFilter($tags, $operator, $body, $params); } } if ($this->getSanitizer()->getString('name', $filterBy) != '') { $terms = explode(',', $this->getSanitizer()->getString('name', $filterBy)); $this->nameFilter('campaign', 'Campaign', $terms, $body, $params, ($this->getSanitizer()->getCheckbox('useRegexForName', $filterBy) == 1)); } // Exclude templates by default if ($this->getSanitizer()->getInt('excludeTemplates', 1, $filterBy) != -1) { if ($this->getSanitizer()->getInt('excludeTemplates', 1, $filterBy) == 1) { $body .= " AND `campaign`.campaignId NOT IN (SELECT `campaignId` FROM `lkcampaignlayout` WHERE layoutId IN (SELECT layoutId FROM lktaglayout INNER JOIN tag ON lktaglayout.tagId = tag.tagId WHERE tag = 'template')) "; } else { $body .= " AND `campaign`.campaignId IN (SELECT `campaignId` FROM `lkcampaignlayout` WHERE layoutId IN (SELECT layoutId FROM lktaglayout INNER JOIN tag ON lktaglayout.tagId = tag.tagId WHERE tag = 'template')) "; } } $group = 'GROUP BY `campaign`.CampaignID, Campaign, IsLayoutSpecific, `campaign`.userId '; if ($this->getSanitizer()->getInt('retired', -1, $filterBy) != -1) { $group .= ' HAVING retired = :retired '; $params['retired'] = $this->getSanitizer()->getInt('retired', $filterBy); if ($this->getSanitizer()->getInt('includeCampaignId', $filterBy) !== null) { $group .= ' OR campaign.campaignId = :includeCampaignId '; $params['includeCampaignId'] = $this->getSanitizer()->getInt('includeCampaignId', $filterBy); } } // Sorting? $order = ''; if (is_array($sortOrder)) $order .= 'ORDER BY ' . implode(',', $sortOrder); $limit = ''; // Paging if ($filterBy !== null && $this->getSanitizer()->getInt('start', $filterBy) !== null && $this->getSanitizer()->getInt('length', $filterBy) !== null) { $limit = ' LIMIT ' . intval($this->getSanitizer()->getInt('start', $filterBy), 0) . ', ' . $this->getSanitizer()->getInt('length', 10, $filterBy); } $intProperties = ['intProperties' => ['numberLayouts', 'isLayoutSpecific']]; // Layout durations if ($this->getSanitizer()->getInt('totalDuration', 0, $options) != 0) { $select .= ", SUM(`layout`.duration) AS totalDuration"; $intProperties = ['intProperties' => ['numberLayouts', 'totalDuration', 'displayOrder']]; } $sql = $select . $body . $group . $order . $limit; foreach ($this->getStore()->select($sql, $params) as $row) { $campaigns[] = $this->createEmpty()->hydrate($row, $intProperties); } // Paging if ($limit != '' && count($campaigns) > 0) { if ($this->getSanitizer()->getInt('retired', -1, $filterBy) != -1) { $body .= ' AND layout.retired = :retired '; } $results = $this->getStore()->select('SELECT COUNT(DISTINCT campaign.campaignId) AS total ' . $body, $params); $this->_countLast = intval($results[0]['total']); } return $campaigns; } } PK qY;; UserTypeFactory.phpnu [ setCommonDependencies($store, $log, $sanitizerService); } /** * @return UserType */ public function createEmpty() { return new UserType($this->getStore(), $this->getLog()); } /** * @return User[] */ public function getAllRoles() { return $this->query(); } /** * @return User[] */ public function getNonAdminRoles() { return $this->query(null, ['userOnly' => 1]); } /** * @param array $sortOrder * @param array $filterBy * @return array[Transition] * @throws NotFoundException */ public function query($sortOrder = ['userType'], $filterBy = null) { $entries = array(); $params = array(); try { $sql = ' SELECT userTypeId, userType FROM `usertype` WHERE 1 = 1 '; if ($this->getSanitizer()->getInt('userOnly', $filterBy) !== null) { $sql .= ' AND `userTypeId` = 3 '; } if ($this->getSanitizer()->getString('userType', $filterBy) !== null) { $sql .= ' AND userType = :userType '; $params['userType'] = $this->getSanitizer()->getString('userType', $filterBy); } // Sorting? if (is_array($sortOrder)) $sql .= 'ORDER BY ' . implode(',', $sortOrder); foreach ($this->getStore()->select($sql, $params) as $row) { $entries[] = $this->createEmpty()->hydrate($row); } return $entries; } catch (\Exception $e) { $this->getLog()->error($e); throw new NotFoundException(); } } }PK qYAŬ_! ! SavedReportFactory.phpnu [ . */ namespace Xibo\Factory; use Xibo\Entity\SavedReport; use Xibo\Entity\User; use Xibo\Exception\NotFoundException; use Xibo\Service\ConfigServiceInterface; use Xibo\Service\LogServiceInterface; use Xibo\Service\SanitizerServiceInterface; use Xibo\Storage\StorageServiceInterface; /** * Class SavedReportFactory * @package Xibo\Factory */ class SavedReportFactory extends BaseFactory { /** * @var ConfigServiceInterface */ private $config; /** * @var MediaFactory */ private $mediaFactory; /** * Construct a factory * @param StorageServiceInterface $store * @param LogServiceInterface $log * @param SanitizerServiceInterface $sanitizerService * @param User $user * @param UserFactory $userFactory * @param ConfigServiceInterface $config * @param MediaFactory $mediaFactory */ public function __construct($store, $log, $sanitizerService, $user, $userFactory, $config, $mediaFactory) { $this->setCommonDependencies($store, $log, $sanitizerService); $this->setAclDependencies($user, $userFactory); $this->config = $config; $this->mediaFactory = $mediaFactory; } /** * Create Empty * @return SavedReport */ public function createEmpty() { return new SavedReport($this->getStore(), $this->getLog(), $this->config, $this->mediaFactory, $this); } /** * Populate Saved Report table * @param string $saveAs * @param int $reportScheduleId * @param int $mediaId * @param int $generatedOn * @param int $userId * @return SavedReport */ public function create($saveAs, $reportScheduleId, $mediaId, $generatedOn, $userId) { $savedReport = $this->createEmpty(); $savedReport->saveAs = $saveAs; $savedReport->reportScheduleId = $reportScheduleId; $savedReport->mediaId = $mediaId; $savedReport->generatedOn = $generatedOn; $savedReport->userId = $userId; $savedReport->save(); return $savedReport; } /** * Get by Version Id * @param int $savedReportId * @return SavedReport * @throws NotFoundException */ public function getById($savedReportId) { $savedReports = $this->query(null, array('disableUserCheck' => 1, 'savedReportId' => $savedReportId)); if (count($savedReports) <= 0) throw new NotFoundException(__('Cannot find saved report')); return $savedReports[0]; } /** * @param null $sortOrder * @param array $filterBy * @return SavedReport[] */ public function query($sortOrder = null, $filterBy = []) { if ($sortOrder === null) $sortOrder = ['generatedOn DESC']; $params = []; $entries = []; $select = ' SELECT saved_report.reportScheduleId, saved_report.savedReportId, saved_report.saveAs, saved_report.userId, reportschedule.name AS reportScheduleName, reportschedule.reportName, saved_report.generatedOn, media.mediaId, media.originalFileName, media.storedAs, `user`.UserName AS owner '; $body = ' FROM saved_report INNER JOIN media ON saved_report.mediaId = media.mediaId INNER JOIN reportschedule ON saved_report.reportScheduleId = reportschedule.reportScheduleId '; // Media might be linked to the system user (userId 0) $body .= " LEFT OUTER JOIN `user` ON `user`.userId = `saved_report`.userId "; $body .= " WHERE 1 = 1 "; // View Permissions $this->viewPermissionSql('Xibo\Entity\SavedReport', $body, $params, '`saved_report`.savedReportId', '`saved_report`.userId', $filterBy); // Like if ($this->getSanitizer()->getString('saveAs', $filterBy) != '') { $terms = explode(',', $this->getSanitizer()->getString('saveAs', $filterBy)); $this->nameFilter('saved_report', 'saveAs', $terms, $body, $params, ($this->getSanitizer()->getCheckbox('useRegexForName', $filterBy) == 1)); } if ($this->getSanitizer()->getInt('savedReportId', -1, $filterBy) != -1) { $body .= " AND saved_report.savedReportId = :savedReportId "; $params['savedReportId'] = $this->getSanitizer()->getInt('savedReportId', $filterBy); } if ($this->getSanitizer()->getInt('reportScheduleId', $filterBy) != '') { $body .= " AND saved_report.reportScheduleId = :reportScheduleId "; $params['reportScheduleId'] = $this->getSanitizer()->getInt('reportScheduleId', $filterBy); } if ($this->getSanitizer()->getInt('generatedOn', $filterBy) != '') { $body .= " AND saved_report.generatedOn = :generatedOn "; $params['generatedOn'] = $this->getSanitizer()->getInt('generatedOn', $filterBy); } if ($this->getSanitizer()->getInt('userId', $filterBy) !== null) { $body .= ' AND `saved_report`.userId = :userId '; $params['userId'] = $this->getSanitizer()->getInt('userId', $filterBy); } // Report name if ($this->getSanitizer()->getString('reportName', $filterBy) != '') { $body .= " AND reportschedule.reportName = :reportName "; $params['reportName'] = $this->getSanitizer()->getString('reportName', $filterBy); } // User Group filter if ($this->getSanitizer()->getInt('ownerUserGroupId', 0, $filterBy) != 0) { $body .= ' AND `saved_report`.userId IN (SELECT DISTINCT userId FROM `lkusergroup` WHERE groupId = :ownerUserGroupId) '; $params['ownerUserGroupId'] = $this->getSanitizer()->getInt('ownerUserGroupId', 0, $filterBy); } // by media ID if ($this->getSanitizer()->getInt('mediaId', -1, $filterBy) != -1) { $body .= " AND media.mediaId = :mediaId "; $params['mediaId'] = $this->getSanitizer()->getInt('mediaId', $filterBy); } // Owner filter if ($this->getSanitizer()->getInt('userId', 0, $filterBy) != 0) { $body .= " AND `saved_report`.userid = :userId "; $params['userId'] = $this->getSanitizer()->getInt('userId', 0, $filterBy); } if ( $this->getSanitizer()->getCheckbox('onlyMyReport') == 1) { $body .= ' AND `saved_report`.userId = :currentUserId '; $params['currentUserId'] = $this->getUser()->userId; } // Sorting? $order = ''; if (is_array($sortOrder)) $order .= 'ORDER BY ' . implode(',', $sortOrder); $limit = ''; // Paging if ($filterBy !== null && $this->getSanitizer()->getInt('start', $filterBy) !== null && $this->getSanitizer()->getInt('length', $filterBy) !== null) { $limit = ' LIMIT ' . intval($this->getSanitizer()->getInt('start', $filterBy), 0) . ', ' . $this->getSanitizer()->getInt('length', 10, $filterBy); } $sql = $select . $body . $order . $limit; foreach ($this->getStore()->select($sql, $params) as $row) { $entries[] = $version = $this->createEmpty()->hydrate($row, [ 'intProperties' => [ 'mediaId', 'reportScheduleId', 'generatedOn' ] ]); } // Paging if ($limit != '' && count($entries) > 0) { $results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params); $this->_countLast = intval($results[0]['total']); } return $entries; } }PK qY+څY Y DisplayFactory.phpnu [ . */ namespace Xibo\Factory; use Xibo\Entity\Display; use Xibo\Entity\User; use Xibo\Exception\NotFoundException; use Xibo\Service\ConfigServiceInterface; use Xibo\Service\DisplayNotifyServiceInterface; use Xibo\Service\LogServiceInterface; use Xibo\Service\SanitizerServiceInterface; use Xibo\Storage\StorageServiceInterface; /** * Class DisplayFactory * @package Xibo\Factory */ class DisplayFactory extends BaseFactory { /** @var DisplayNotifyServiceInterface */ private $displayNotifyService; /** * @var ConfigServiceInterface */ private $config; /** * @var DisplayGroupFactory */ private $displayGroupFactory; /** * @var DisplayProfileFactory */ private $displayProfileFactory; /** * Construct a factory * @param StorageServiceInterface $store * @param LogServiceInterface $log * @param SanitizerServiceInterface $sanitizerService * @param User $user * @param UserFactory $userFactory * @param DisplayNotifyServiceInterface $displayNotifyService * @param ConfigServiceInterface $config * @param DisplayGroupFactory $displayGroupFactory * @param DisplayProfileFactory $displayProfileFactory */ public function __construct($store, $log, $sanitizerService, $user, $userFactory, $displayNotifyService, $config, $displayGroupFactory, $displayProfileFactory) { $this->setCommonDependencies($store, $log, $sanitizerService); $this->setAclDependencies($user, $userFactory); $this->displayNotifyService = $displayNotifyService; $this->config = $config; $this->displayGroupFactory = $displayGroupFactory; $this->displayProfileFactory = $displayProfileFactory; } /** * Get the Display Notify Service * @return DisplayNotifyServiceInterface */ public function getDisplayNotifyService() { return $this->displayNotifyService->init(); } /** * Create Empty Display Object * @return Display */ public function createEmpty() { return new Display($this->getStore(), $this->getLog(), $this->config, $this->displayGroupFactory, $this->displayProfileFactory, $this); } /** * @param int $displayId * @param bool|false $showTags * @return Display * @throws NotFoundException */ public function getById($displayId, $showTags = false) { $displays = $this->query(null, ['disableUserCheck' => 1, 'displayId' => $displayId, 'showTags' => $showTags]); if (count($displays) <= 0) throw new NotFoundException(); return $displays[0]; } /** * @param string $licence * @return Display * @throws NotFoundException */ public function getByLicence($licence) { $displays = $this->query(null, ['disableUserCheck' => 1, 'license' => $licence]); if (count($displays) <= 0) throw new NotFoundException(); return $displays[0]; } /** * @param int $displayGroupId * @return Display[] * @throws NotFoundException */ public function getByDisplayGroupId($displayGroupId) { return $this->query(null, ['disableUserCheck' => 1, 'displayGroupId' => $displayGroupId]); } /** * @param array $sortOrder * @param array $filterBy * @return Display[] */ public function query($sortOrder = null, $filterBy = []) { if ($sortOrder === null) $sortOrder = ['display']; $newSortOrder = []; foreach ($sortOrder as $sort) { if ($sort == '`clientSort`') { $newSortOrder[] = '`clientType`'; $newSortOrder[] = '`clientCode`'; $newSortOrder[] = '`clientVersion`'; continue; } if ($sort == '`clientSort` DESC') { $newSortOrder[] = '`clientType` DESC'; $newSortOrder[] = '`clientCode` DESC'; $newSortOrder[] = '`clientVersion` DESC'; continue; } $newSortOrder[] = $sort; } $sortOrder = $newSortOrder; // SQL function for ST_X/X and ST_Y/Y dependent on MySQL version $version = $this->getStore()->getVersion(); $functionPrefix = ($version === null || version_compare($version, '5.6.1', '>=')) ? 'ST_' : ''; $entries = array(); $params = array(); $select = ' SELECT display.displayId, display.display, display.defaultLayoutId, layout.layout AS defaultLayout, display.license, display.licensed, display.licensed AS currentlyLicensed, display.loggedIn, display.lastAccessed, display.auditingUntil, display.inc_schedule AS incSchedule, display.email_alert AS emailAlert, display.alert_timeout AS alertTimeout, display.clientAddress, display.mediaInventoryStatus, display.macAddress, display.macAddress AS currentMacAddress, display.lastChanged, display.numberOfMacAddressChanges, display.lastWakeOnLanCommandSent, display.wakeOnLan AS wakeOnLanEnabled, display.wakeOnLanTime, display.broadCastAddress, display.secureOn, display.cidr, ' . $functionPrefix . 'X(display.GeoLocation) AS latitude, ' . $functionPrefix . 'Y(display.GeoLocation) AS longitude, display.client_type AS clientType, display.client_version AS clientVersion, display.client_code AS clientCode, display.displayProfileId, display.screenShotRequested, display.storageAvailableSpace, display.storageTotalSpace, displaygroup.displayGroupId, displaygroup.description, displaygroup.bandwidthLimit, `display`.xmrChannel, `display`.xmrPubKey, `display`.lastCommandSuccess, `display`.deviceName, `display`.timeZone, `display`.overrideConfig, `display`.newCmsAddress, `display`.newCmsKey, `display`.orientation, `display`.resolution, `display`.commercialLicence '; if ($this->getSanitizer()->getCheckbox('showTags', $filterBy) === 1) { $select .= ', ( SELECT GROUP_CONCAT(DISTINCT tag) FROM tag INNER JOIN lktagdisplaygroup ON lktagdisplaygroup.tagId = tag.tagId WHERE lktagdisplaygroup.displayGroupId = displaygroup.displayGroupID GROUP BY lktagdisplaygroup.displayGroupId ) AS tags '; $select .= ", ( SELECT GROUP_CONCAT(IFNULL(value, 'NULL')) FROM tag INNER JOIN lktagdisplaygroup ON lktagdisplaygroup.tagId = tag.tagId WHERE lktagdisplaygroup.displayGroupId = displaygroup.displayGroupID GROUP BY lktagdisplaygroup.displayGroupId ) AS tagValues "; } $body = ' FROM `display` INNER JOIN `lkdisplaydg` ON lkdisplaydg.displayid = display.displayId INNER JOIN `displaygroup` ON displaygroup.displaygroupid = lkdisplaydg.displaygroupid AND `displaygroup`.isDisplaySpecific = 1 LEFT OUTER JOIN layout ON layout.layoutid = display.defaultlayoutid '; // Restrict to members of a specific display group if ($this->getSanitizer()->getInt('displayGroupId', $filterBy) !== null) { $body .= ' INNER JOIN `lkdisplaydg` othergroups ON othergroups.displayId = `display`.displayId AND othergroups.displayGroupId = :displayGroupId '; $params['displayGroupId'] = $this->getSanitizer()->getInt('displayGroupId', $filterBy); } $body .= ' WHERE 1 = 1 '; $this->viewPermissionSql('Xibo\Entity\DisplayGroup', $body, $params, 'displaygroup.displayGroupId', null, $filterBy); // Filter by Display ID? if ($this->getSanitizer()->getInt('displayId', $filterBy) !== null) { $body .= ' AND display.displayid = :displayId '; $params['displayId'] = $this->getSanitizer()->getInt('displayId', $filterBy); } // Display Profile if ($this->getSanitizer()->getInt('displayProfileId', $filterBy) !== null) { if ($this->getSanitizer()->getInt('displayProfileId', $filterBy) == -1) { $body .= ' AND IFNULL(displayProfileId, 0) = 0 '; } else { $displayProfileSelected = $this->displayProfileFactory->getById($this->getSanitizer()->getInt('displayProfileId', $filterBy)); $displayProfileDefault = $this->displayProfileFactory->getDefaultByType($displayProfileSelected->type); $body .= ' AND (`display`.displayProfileId = :displayProfileId OR (IFNULL(displayProfileId, :displayProfileDefaultId) = :displayProfileId AND display.client_type = :displayProfileType ) ) '; $params['displayProfileId'] = $this->getSanitizer()->getInt('displayProfileId', $filterBy); $params['displayProfileDefaultId'] = $displayProfileDefault->displayProfileId; $params['displayProfileType'] = $displayProfileDefault->type; } } // Filter by Wake On LAN if ($this->getSanitizer()->getInt('wakeOnLan', $filterBy) !== null) { $body .= ' AND display.wakeOnLan = :wakeOnLan '; $params['wakeOnLan'] = $this->getSanitizer()->getInt('wakeOnLan', $filterBy); } // Filter by Licence? if ($this->getSanitizer()->getString('license', $filterBy) != null) { $body .= ' AND display.license = :license '; $params['license'] = $this->getSanitizer()->getString('license', $filterBy); } // Filter by authorised? if ($this->getSanitizer()->getInt('authorised', -1, $filterBy) != -1) { $body .= ' AND display.licensed = :authorised '; $params['authorised'] = $this->getSanitizer()->getInt('authorised', $filterBy); } // Filter by Display Name? if ($this->getSanitizer()->getString('display', $filterBy) != null) { $terms = explode(',', $this->getSanitizer()->getString('display', $filterBy)); $this->nameFilter('display', 'display', $terms, $body, $params, ($this->getSanitizer()->getCheckbox('useRegexForName', $filterBy) == 1)); } if ($this->getSanitizer()->getString('macAddress', $filterBy) != '') { $body .= ' AND display.macaddress LIKE :macAddress '; $params['macAddress'] = '%' . $this->getSanitizer()->getString('macAddress', $filterBy) . '%'; } if ($this->getSanitizer()->getString('clientAddress', $filterBy) != '') { $body .= ' AND display.clientaddress LIKE :clientAddress '; $params['clientAddress'] = '%' . $this->getSanitizer()->getString('clientAddress', $filterBy) . '%'; } if ($this->getSanitizer()->getString('clientVersion', $filterBy) != '') { $body .= ' AND display.client_version LIKE :clientVersion '; $params['clientVersion'] = '%' . $this->getSanitizer()->getString('clientVersion', $filterBy) . '%'; } if ($this->getSanitizer()->getString('clientType', $filterBy) != '') { $body .= ' AND display.client_type = :clientType '; $params['clientType'] = $this->getSanitizer()->getString('clientType', $filterBy); } if ($this->getSanitizer()->getString('clientCode', $filterBy) != '') { $body .= ' AND display.client_code LIKE :clientCode '; $params['clientCode'] = '%' . $this->getSanitizer()->getString('clientCode', $filterBy) . '%'; } if ($this->getSanitizer()->getString('orientation', $filterBy) != '') { $body .= ' AND display.orientation = :orientation '; $params['orientation'] = $this->getSanitizer()->getString('orientation', $filterBy); } if ($this->getSanitizer()->getInt('mediaInventoryStatus', $filterBy) != '') { if ($this->getSanitizer()->getInt('mediaInventoryStatus', $filterBy) === -1) { $body .= ' AND display.mediaInventoryStatus <> 1 '; } else { $body .= ' AND display.mediaInventoryStatus = :mediaInventoryStatus '; $params['mediaInventoryStatus'] = $this->getSanitizer()->getInt('mediaInventoryStatus', $filterBy); } } if ($this->getSanitizer()->getInt('loggedIn', -1, $filterBy) != -1) { $body .= ' AND display.loggedIn = :loggedIn '; $params['loggedIn'] = $this->getSanitizer()->getInt('loggedIn', $filterBy); } if ($this->getSanitizer()->getInt('lastAccessed', $filterBy) !== null) { $body .= ' AND display.lastAccessed > :lastAccessed '; $params['lastAccessed'] = $this->getSanitizer()->getInt('lastAccessed', $filterBy); } // Exclude a group? if ($this->getSanitizer()->getInt('exclude_displaygroupid', $filterBy) !== null) { $body .= " AND display.DisplayID NOT IN "; $body .= " (SELECT display.DisplayID "; $body .= " FROM display "; $body .= " INNER JOIN lkdisplaydg "; $body .= " ON lkdisplaydg.DisplayID = display.DisplayID "; $body .= " WHERE lkdisplaydg.DisplayGroupID = :excludeDisplayGroupId "; $body .= " )"; $params['excludeDisplayGroupId'] = $this->getSanitizer()->getInt('exclude_displaygroupid', $filterBy); } // Media ID - direct assignment if ($this->getSanitizer()->getInt('mediaId', $filterBy) !== null) { $body .= ' AND display.displayId IN ( SELECT `lkdisplaydg`.displayId FROM `lkmediadisplaygroup` INNER JOIN `lkdgdg` ON `lkdgdg`.parentId = `lkmediadisplaygroup`.displayGroupId INNER JOIN `lkdisplaydg` ON lkdisplaydg.DisplayGroupID = `lkdgdg`.childId WHERE `lkmediadisplaygroup`.mediaId = :mediaId UNION SELECT `lkdisplaydg`.displayId FROM `lklayoutdisplaygroup` INNER JOIN `lkdgdg` ON `lkdgdg`.parentId = `lklayoutdisplaygroup`.displayGroupId INNER JOIN `lkdisplaydg` ON lkdisplaydg.DisplayGroupID = `lkdgdg`.childId WHERE `lklayoutdisplaygroup`.layoutId IN ( SELECT `region`.layoutId FROM `lkwidgetmedia` INNER JOIN `widget` ON `widget`.widgetId = `lkwidgetmedia`.widgetId INNER JOIN `playlist` ON `playlist`.playlistId = `widget`.playlistId INNER JOIN `region` ON `region`.regionId = `playlist`.regionId INNER JOIN layout ON layout.LayoutID = region.layoutId WHERE lkwidgetmedia.mediaId = :mediaId UNION SELECT `layout`.layoutId FROM `layout` WHERE `layout`.backgroundImageId = :mediaId ) ) '; $params['mediaId'] = $this->getSanitizer()->getInt('mediaId', $filterBy); } // Tags if ($this->getSanitizer()->getString('tags', $filterBy) != '') { $tagFilter = $this->getSanitizer()->getString('tags', $filterBy); if (trim($tagFilter) === '--no-tag') { $body .= ' AND `displaygroup`.displaygroupId NOT IN ( SELECT `lktagdisplaygroup`.displaygroupId FROM tag INNER JOIN `lktagdisplaygroup` ON `lktagdisplaygroup`.tagId = tag.tagId ) '; } else { $operator = $this->getSanitizer()->getCheckbox('exactTags') == 1 ? '=' : 'LIKE'; $body .= " AND `displaygroup`.displaygroupId IN ( SELECT `lktagdisplaygroup`.displaygroupId FROM tag INNER JOIN `lktagdisplaygroup` ON `lktagdisplaygroup`.tagId = tag.tagId "; $tags = explode(',', $tagFilter); $this->tagFilter($tags, $operator, $body, $params); } } // run the special query to help sort by displays already assigned to this display group, we want to run it only if we're sorting by member column. if ($this->getSanitizer()->getInt('displayGroupIdMembers', $filterBy) !== null && ($sortOrder == ['`member`'] || $sortOrder == ['`member` DESC'] )) { $members = []; foreach ($this->getStore()->select($select . $body, $params) as $row) { $displayId = $this->getSanitizer()->int($row['displayId']); $displayGroupId = $this->getSanitizer()->getInt('displayGroupIdMembers', $filterBy); if ($this->getStore()->exists('SELECT display.display, display.displayId, displaygroup.displayGroupId FROM display INNER JOIN `lkdisplaydg` ON lkdisplaydg.displayId = `display`.displayId AND lkdisplaydg.displayGroupId = :displayGroupId AND lkdisplaydg.displayId = :displayId INNER JOIN `displaygroup` ON displaygroup.displaygroupid = lkdisplaydg.displaygroupid AND `displaygroup`.isDisplaySpecific = 0', [ 'displayGroupId' => $displayGroupId, 'displayId' => $displayId ] )) { $members[] = $displayId; } } } // filter by commercial licence if ($this->getSanitizer()->getInt('commercialLicence', $filterBy) !== null) { $body .= ' AND display.commercialLicence = :commercialLicence '; $params['commercialLicence'] = $this->getSanitizer()->getInt('commercialLicence', $filterBy); } // Sorting? $order = ''; if (isset($members) && $members != [] ) { $sqlOrderMembers = 'ORDER BY FIELD(display.displayId,' . implode(',', $members) . ')'; foreach ($sortOrder as $sort) { if ($sort == '`member`') { $order .= $sqlOrderMembers; continue; } if ($sort == '`member` DESC') { $order .= $sqlOrderMembers . ' DESC'; continue; } } } if (is_array($sortOrder) && ($sortOrder != ['`member`'] && $sortOrder != ['`member` DESC'] )) { $order .= 'ORDER BY ' . implode(',', $sortOrder); } $limit = ''; // Paging if ($filterBy !== null && $this->getSanitizer()->getInt('start', $filterBy) !== null && $this->getSanitizer()->getInt('length', $filterBy) !== null) { $limit = ' LIMIT ' . intval($this->getSanitizer()->getInt('start', $filterBy), 0) . ', ' . $this->getSanitizer()->getInt('length', 10, $filterBy); } $sql = $select . $body . $order . $limit; foreach ($this->getStore()->select($sql, $params) as $row) { $display = $this->createEmpty()->hydrate($row, [ 'intProperties' => [ 'auditingUntil', 'wakeOnLanEnabled', 'numberOfMacAddressChanges', 'loggedIn', 'incSchedule', 'licensed', 'lastAccessed', 'emailAlert', 'alertTimeout', 'mediaInventoryStatus', 'clientCode', 'screenShotRequested', 'lastCommandSuccess', 'bandwidthLimit' ] ]); $display->overrideConfig = ($display->overrideConfig == '') ? [] : json_decode($display->overrideConfig, true); $entries[] = $display; } // Paging if ($limit != '' && count($entries) > 0) { $results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params); $this->_countLast = intval($results[0]['total']); } return $entries; } }PK qYA4N N CommandFactory.phpnu [ setCommonDependencies($store, $log, $sanitizerService); $this->setAclDependencies($user, $userFactory); $this->permissionFactory = $permissionFactory; } /** * Create Command * @return Command */ public function create() { return new Command($this->getStore(), $this->getLog(), $this->permissionFactory); } /** * Get by Id * @param $commandId * @return Command * @throws NotFoundException */ public function getById($commandId) { $commands = $this->query(null, ['commandId' => $commandId]); if (count($commands) <= 0) throw new NotFoundException(); return $commands[0]; } /** * Get by Display Profile Id * @param $displayProfileId * @return array[Command] */ public function getByDisplayProfileId($displayProfileId) { return $this->query(null, ['displayProfileId' => $displayProfileId]); } /** * @param array $sortOrder * @param array $filterBy * @return array */ public function query($sortOrder = null, $filterBy = []) { $entries = array(); if ($sortOrder == null) $sortOrder = ['command']; $params = array(); $select = 'SELECT `command`.commandId, `command`.command, `command`.code, `command`.description, `command`.userId '; if ($this->getSanitizer()->getInt('displayProfileId', $filterBy) !== null) { $select .= ', commandString, validationString '; } $select .= " , (SELECT GROUP_CONCAT(DISTINCT `group`.group) FROM `permission` INNER JOIN `permissionentity` ON `permissionentity`.entityId = permission.entityId INNER JOIN `group` ON `group`.groupId = `permission`.groupId WHERE entity = :permissionEntityForGroup AND objectId = command.commandId AND view = 1 ) AS groupsWithPermissions "; $params['permissionEntityForGroup'] = 'Xibo\\Entity\\Command'; $body = ' FROM `command` '; if ($this->getSanitizer()->getInt('displayProfileId', $filterBy) !== null) { $body .= ' INNER JOIN `lkcommanddisplayprofile` ON `lkcommanddisplayprofile`.commandId = `command`.commandId AND `lkcommanddisplayprofile`.displayProfileId = :displayProfileId '; $params['displayProfileId'] = $this->getSanitizer()->getInt('displayProfileId', $filterBy); } $body .= ' WHERE 1 = 1 '; $this->viewPermissionSql('Xibo\Entity\Command', $body, $params, 'command.commandId', 'command.userId', $filterBy); if ($this->getSanitizer()->getInt('commandId', $filterBy) !== null) { $body .= ' AND `command`.commandId = :commandId '; $params['commandId'] = $this->getSanitizer()->getInt('commandId', $filterBy); } if ($this->getSanitizer()->getString('command', $filterBy) != null) { $body .= ' AND `command`.command = :command '; $params['command'] = $this->getSanitizer()->getString('command', $filterBy); } if ($this->getSanitizer()->getString('code', $filterBy) != null) { $body .= ' AND `code`.code = :code '; $params['code'] = $this->getSanitizer()->getString('code', $filterBy); } // Sorting? $order = ''; if (is_array($sortOrder)) $order .= ' ORDER BY ' . implode(',', $sortOrder); $limit = ''; // Paging if ($filterBy !== null && $this->getSanitizer()->getInt('start', $filterBy) !== null && $this->getSanitizer()->getInt('length', $filterBy) !== null) { $limit = ' LIMIT ' . intval($this->getSanitizer()->getInt('start', $filterBy), 0) . ', ' . $this->getSanitizer()->getInt('length', 10, $filterBy); } $sql = $select . $body . $order . $limit; foreach ($this->getStore()->select($sql, $params) as $row) { $entries[] = (new Command($this->getStore(), $this->getLog(), $this->displayProfileFactory))->hydrate($row); } // Paging if ($limit != '' && count($entries) > 0) { unset($params['permissionEntityForGroup']); $results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params); $this->_countLast = intval($results[0]['total']); } return $entries; } }PK qYp3H H DataSetColumnTypeFactory.phpnu [ setCommonDependencies($store, $log, $sanitizerService); } /** * @return DataSetColumnType */ public function createEmpty() { return new DataSetColumnType($this->getStore(), $this->getLog()); } /** * Get By Id * @param int $id * @return DataSetColumnType * @throws NotFoundException */ public function getById($id) { $results = $this->query(null, ['dataSetColumnTypeId' => $id]); if (count($results) <= 0) throw new NotFoundException(); return $results[0]; } /** * @param null $sortOrder * @param array $filterBy * @return array[DataSetColumnType] */ public function query($sortOrder = null, $filterBy = []) { $entries = []; $params = []; $sql = 'SELECT dataSetColumnTypeId, dataSetColumnType FROM `datasetcolumntype` WHERE 1 = 1 '; if ($this->getSanitizer()->getInt('dataSetColumnTypeId') !== null) { $sql .= ' AND `datasetcolumntype`.dataSetColumnTypeId = :dataSetColumnTypeId '; $params['dataSetColumnTypeId'] = $this->getSanitizer()->getInt('dataSetColumnTypeId'); } foreach ($this->getStore()->select($sql, $params) as $row) { $entries[] = $this->createEmpty()->hydrate($row); } return $entries; } }PK qY@$ ! ApplicationRedirectUriFactory.phpnu [ setCommonDependencies($store, $log, $sanitizerService); } /** * Create Empty * @return ApplicationRedirectUri */ public function create() { return new ApplicationRedirectUri($this->getStore(), $this->getLog()); } /** * Get by ID * @param $id * @return ApplicationRedirectUri * @throws NotFoundException */ public function getById($id) { $clientRedirectUri = $this->query(null, ['id' => $id]); if (count($clientRedirectUri) <= 0) throw new NotFoundException(); return $clientRedirectUri[0]; } /** * Get by Client Id * @param $clientId * @return array[ApplicationRedirectUri] * @throws NotFoundException */ public function getByClientId($clientId) { return $this->query(null, ['clientId' => $clientId]); } /** * Query * @param null $sortOrder * @param array $filterBy * @return array */ public function query($sortOrder = null, $filterBy = []) { $entries = array(); $params = array(); $select = 'SELECT id, client_id AS clientId, redirect_uri AS redirectUri '; $body = ' FROM `oauth_client_redirect_uris` WHERE 1 = 1 '; if ($this->getSanitizer()->getString('clientId', $filterBy) != null) { $body .= ' AND `oauth_client_redirect_uris`.client_id = :clientId '; $params['clientId'] = $this->getSanitizer()->getString('clientId', $filterBy); } if ($this->getSanitizer()->getString('id', $filterBy) != null) { $body .= ' AND `oauth_client_redirect_uris`.client_id = :id '; $params['id'] = $this->getSanitizer()->getString('id', $filterBy); } // Sorting? $order = ''; if (is_array($sortOrder)) $order .= 'ORDER BY ' . implode(',', $sortOrder); $limit = ''; // Paging if ($filterBy !== null && $this->getSanitizer()->getInt('start', $filterBy) !== null && $this->getSanitizer()->getInt('length', $filterBy) !== null) { $limit = ' LIMIT ' . intval($this->getSanitizer()->getInt('start', $filterBy), 0) . ', ' . $this->getSanitizer()->getInt('length', 10, $filterBy); } // The final statements $sql = $select . $body . $order . $limit; foreach ($this->getStore()->select($sql, $params) as $row) { $entries[] = $this->create()->hydrate($row); } // Paging if ($limit != '' && count($entries) > 0) { $results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params); $this->_countLast = intval($results[0]['total']); } return $entries; } }PK qYBa<