3
* Xibo - Digitial Signage - http://www.xibo.org.uk
4
* Copyright (C) 2011 Daniel Garner
6
* This file is part of Xibo.
8
* Xibo is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Affero General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
13
* Xibo is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
18
* You should have received a copy of the GNU Affero General Public License
19
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
21
defined('XIBO') or die('Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.');
23
class LayoutMediaGroupSecurity extends Data
25
public function __construct(database $db)
27
parent::__construct($db);
31
* Links a Display Group to a Group
33
* @param $displayGroupID Object
34
* @param $groupID Object
36
public function Link($layoutId, $regionId, $mediaId, $groupId, $view, $edit, $del)
40
Debug::LogEntry($db, 'audit', 'IN', 'LayoutMediaGroupSecurity', 'Link');
44
$SQL .= "INTO lklayoutmediagroup ";
46
$SQL .= " LayoutID, ";
47
$SQL .= " RegionID, ";
56
$SQL .= sprintf(" %d, '%s', '%s', %d, %d, %d, %d ", $layoutId, $regionId, $mediaId, $groupId, $view, $edit, $del);
59
if (!$db->query($SQL))
61
trigger_error($db->error());
62
$this->SetError(25026, __('Could not Link Layout Media to Group'));
67
Debug::LogEntry($db, 'audit', 'OUT', 'LayoutMediaGroupSecurity', 'Link');
73
* Links everyone to the layout specified
74
* @param <type> $layoutId
80
public function LinkEveryone($layoutId, $regionId, $mediaId, $view, $edit, $del)
84
Debug::LogEntry($db, 'audit', 'IN', 'LayoutMediaGroupSecurity', 'LinkEveryone');
86
$groupId = $db->GetSingleValue("SELECT GroupID FROM `group` WHERE IsEveryone = 1", 'GroupID', _INT);
88
return $this->Link($layoutId, $regionId, $mediaId, $groupId, $view, $edit, $del);
92
* Unlinks a display group from a group
94
* @param $displayGroupID Object
95
* @param $groupID Object
97
public function Unlink($layoutId, $regionId, $mediaId, $groupId)
101
Debug::LogEntry($db, 'audit', 'IN', 'LayoutMediaGroupSecurity', 'Unlink');
104
$SQL .= "DELETE FROM ";
105
$SQL .= " lklayoutmediagroup ";
106
$SQL .= sprintf(" WHERE LayoutID = %d AND RegionID = '%s' AND MediaID = '%s' AND GroupID = %d ", $layoutId, $regionId, $mediaId, $groupId);
108
if (!$db->query($SQL))
110
trigger_error($db->error());
111
$this->SetError(25027, __('Could not Unlink Layout Media from Group'));
116
Debug::LogEntry($db, 'audit', 'OUT', 'LayoutMediaGroupSecurity', 'Unlink');
122
* Unlinks a display group from a group
124
* @param $displayGroupID Object
125
* @param $groupID Object
127
public function UnlinkAll($layoutId, $regionId, $mediaId)
131
Debug::LogEntry($db, 'audit', 'IN', 'LayoutMediaGroupSecurity', 'Unlink');
134
$SQL .= "DELETE FROM ";
135
$SQL .= " lklayoutmediagroup ";
136
$SQL .= sprintf(" WHERE LayoutID = %d AND RegionID = '%s' AND MediaID = '%s' ", $layoutId, $regionId, $mediaId);
138
if (!$db->query($SQL))
140
trigger_error($db->error());
141
$this->SetError(25028, __('Could not Unlink Layout Media from Group'));
146
Debug::LogEntry($db, 'audit', 'OUT', 'LayoutMediaGroupSecurity', 'Unlink');
152
* Copies a media items permissions
153
* @param <type> $layoutId
154
* @param <type> $regionId
155
* @param <type> $mediaId
156
* @param <type> $newMediaId
159
public function Copy($layoutId, $regionId, $mediaId, $newMediaId)
163
Debug::LogEntry($db, 'audit', 'IN', 'LayoutMediaGroupSecurity', 'Copy');
167
$SQL .= "INTO lklayoutmediagroup ";
169
$SQL .= " LayoutID, ";
170
$SQL .= " RegionID, ";
171
$SQL .= " MediaID, ";
172
$SQL .= " GroupID, ";
177
$SQL .= " SELECT LayoutID, RegionID, '%s', GroupID, View, Edit, Del ";
178
$SQL .= " FROM lklayoutmediagroup ";
179
$SQL .= " WHERE LayoutID = %d AND RegionID = '%s' AND MediaID = '%s' ";
181
$SQL = sprintf($SQL, $newMediaId, $layoutId, $regionId, $mediaId);
183
if (!$db->query($SQL))
185
trigger_error($db->error());
186
$this->SetError(25028, __('Could not Copy Layout Media Security'));
b'\\ No newline at end of file'