From 37cb10ada7ca800d96c539805178d0d266cbabae Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Mon, 9 Feb 2015 10:19:09 +0000 Subject: [PATCH 1/3] Forgot to pass the user object into module creation. Fixes xibosignage/xibo#186 --- lib/data/region.data.class.php | 16 ++++++---------- lib/modules/module.class.php | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/data/region.data.class.php b/lib/data/region.data.class.php index 15680fc452..86b463e83d 100644 --- a/lib/data/region.data.class.php +++ b/lib/data/region.data.class.php @@ -1027,12 +1027,6 @@ public function AddFromLibrary($user, $layoutId, $regionId, $mediaList) { $mediaId = Kit::ValidateParam($mediaId, _INT); - // Check we have permissions to use this media (we will use this to copy the media later) - $mediaAuth = $user->MediaAuth($mediaId, true); - - if (!$mediaAuth->view) - return $this->SetError(__('You have selected media that you no longer have permission to use. Please reload Library form.')); - // Get the type from this media $sth = $dbh->prepare('SELECT type FROM media WHERE mediaID = :mediaid'); $sth->execute(array( @@ -1046,11 +1040,15 @@ public function AddFromLibrary($user, $layoutId, $regionId, $mediaList) { try { // Create the media object without any region and layout information - $module = ModuleFactory::createForMedia($mod, $mediaId); + $module = ModuleFactory::createForMedia($mod, $mediaId, null, $user); } catch (Exception $e) { return $this->SetError($e->getMessage()); } + + // Check we have permissions to use this media (we will use this to copy the media later) + if (!$module->auth->view) + return $this->SetError(__('You have selected media that you no longer have permission to use. Please reload Library form.')); if (!$module->SetRegionInformation($layoutId, $regionId)) return $this->SetError($module->GetErrorMessage()); @@ -1059,13 +1057,11 @@ public function AddFromLibrary($user, $layoutId, $regionId, $mediaList) { return $this->SetError($module->GetErrorMessage()); // Need to copy over the permissions from this media item & also the delete permission - Kit::ClassLoader('layoutmediagroupsecurity'); $security = new LayoutMediaGroupSecurity($this->db); - $security->Link($layoutId, $regionId, $mediaId, $user->getGroupFromID($user->userid, true), $mediaAuth->view, $mediaAuth->edit, 1); + $security->Link($layoutId, $regionId, $mediaId, $user->getGroupFromID($user->userid, true), $module->auth->view, $module->auth->edit, 1); } // Update layout status - Kit::ClassLoader('Layout'); $layout = new Layout($this->db); $layout->SetValid($layoutId, true); diff --git a/lib/modules/module.class.php b/lib/modules/module.class.php index 199e806a7f..f32d0e56b4 100644 --- a/lib/modules/module.class.php +++ b/lib/modules/module.class.php @@ -298,8 +298,6 @@ final private function SetMediaInformation($layoutid, $regionid, $mediaid, $lkid $this->assignedMedia = false; try { - $dbh = PDOConnect::init(); - // Load what we know about this media into the object // this is unauthenticated at this point $rows = Media::Entries(NULL, array('mediaId' => $mediaid, 'allModules' => 1)); From 187929ba020a6150d6a5d263f6662bbafc173042 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Mon, 9 Feb 2015 11:02:03 +0000 Subject: [PATCH 2/3] Order by Clause in DataSets. Fixes xibosignage/xibo#191 --- lib/data/dataset.data.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data/dataset.data.class.php b/lib/data/dataset.data.class.php index 6d095155c1..fee2d48dc0 100644 --- a/lib/data/dataset.data.class.php +++ b/lib/data/dataset.data.class.php @@ -442,7 +442,7 @@ public function DataSetResults($dataSetId, $columnIds, $filter = '', $ordering = $order .= ' :order' . $i . ' DESC,'; } else { - $order .= ' :order,' . $i; + $order .= ' :order' . $i . ','; } $params['order' . $i] = $orderPair; From 86b454ffe923e192ca76aec136704d070a47ebe9 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Mon, 9 Feb 2015 12:03:40 +0000 Subject: [PATCH 3/3] Move clock install to 1.7.0 upgrade SQL file. Fixes xibosignage/xibo#194 --- install/database/84.sql | 3 +++ install/database/85.sql | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install/database/84.sql b/install/database/84.sql index 2544331d2b..98541b6911 100644 --- a/install/database/84.sql +++ b/install/database/84.sql @@ -4,6 +4,9 @@ VALUES ( 'CALENDAR_TYPE', 'Gregorian', 'dropdown', 'Which Calendar Type should the CMS use?', 'Gregorian|Jalali', 'regional', 1, 'Calendar Type', '', '50', 'Gregorian', '1', 'string' ); +INSERT INTO `module` (`ModuleID`, `Module`, `Name`, `Enabled`, `RegionSpecific`, `Description`, `ImageUri`, `SchemaVersion`, `ValidExtensions`, `PreviewEnabled`, `assignable`, `render_as`) VALUES +(NULL, 'clock', 'Clock', '1', '1', 'Display a Clock', 'forms/library.gif', '1', '', '1', '1', 'html'); + INSERT INTO `displayprofile` (`name`, `type`, `config`, `isdefault`, `userid`) VALUES ('Windows', 'windows', '[]', '1', '1'), ('Android', 'android', '[]', '1', '1'); diff --git a/install/database/85.sql b/install/database/85.sql index a1e88f91e4..ab68bfeb9b 100644 --- a/install/database/85.sql +++ b/install/database/85.sql @@ -1,6 +1,3 @@ -INSERT INTO `module` (`ModuleID`, `Module`, `Name`, `Enabled`, `RegionSpecific`, `Description`, `ImageUri`, `SchemaVersion`, `ValidExtensions`, `PreviewEnabled`, `assignable`, `render_as`) VALUES -(NULL, 'clock', 'Clock', '1', '1', 'Display a Clock', 'forms/library.gif', '1', '', '1', '1', 'html'); - ALTER TABLE `display` ADD `storageAvailableSpace` INT NULL , ADD `storageTotalSpace` INT NULL;