~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/data/displaygroupsecurity.data.class.php

  • Committer: Dan Garner
  • Date: 2015-03-26 14:08:33 UTC
  • Revision ID: git-v1:70d14044444f8dc5d602b99890d59dea46d9470c
Moved web servable files to web folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * Xibo - Digital Signage - http://www.xibo.org.uk
 
4
 * Copyright (C) 2009-13 Daniel Garner
 
5
 *
 
6
 * This file is part of Xibo.
 
7
 *
 
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
 
11
 * any later version. 
 
12
 *
 
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.
 
17
 *
 
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/>.
 
20
 */
 
21
use Xibo\Helper\Log;
 
22
 
 
23
defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
 
24
 
 
25
include_once('lib/data/schedule.data.class.php');
 
26
 
 
27
class DisplayGroupSecurity extends Data {       
 
28
        /**
 
29
         * Links a Display Group to a Group
 
30
         * @return 
 
31
         * @param $displayGroupID Object
 
32
         * @param $groupID Object
 
33
         */
 
34
        public function Link($displayGroupId, $groupId, $view, $edit, $del)
 
35
        {
 
36
                Log::notice('IN', 'DisplayGroupSecurity', 'Link');
 
37
                
 
38
                try {
 
39
            $dbh = \Xibo\Storage\PDOConnect::init();
 
40
                
 
41
                        $sth = $dbh->prepare('INSERT INTO lkdisplaygroupgroup (DisplayGroupID, GroupID, View, Edit, Del) VALUES (:displaygroupid, :groupid, :view, :edit, :del)');
 
42
                        $sth->execute(array(
 
43
                                        'displaygroupid' => $displayGroupId,
 
44
                                        'groupid' => $groupId,
 
45
                                        'view' => $view,
 
46
                                        'edit' => $edit,
 
47
                                        'del' => $del
 
48
                                ));
 
49
                        
 
50
                        Log::notice('OUT', 'DisplayGroupSecurity', 'Link');
 
51
                        
 
52
                        return true;
 
53
                }
 
54
        catch (Exception $e) {
 
55
            
 
56
            Log::error($e->getMessage());
 
57
 
 
58
            if (!$this->IsError())
 
59
                $this->SetError(25005, __('Could not Link Display Group to User Group'));
 
60
 
 
61
            return false;
 
62
        }
 
63
        }
 
64
        
 
65
        /**
 
66
         * Unlinks a display group from a group
 
67
         * @return 
 
68
         * @param $displayGroupID Object
 
69
         * @param $groupID Object
 
70
         */
 
71
        public function Unlink($displayGroupId, $groupId)
 
72
        {
 
73
                Log::notice('IN', 'DisplayGroupSecurity', 'Unlink');
 
74
                
 
75
                try {
 
76
            $dbh = \Xibo\Storage\PDOConnect::init();
 
77
 
 
78
            $sth = $dbh->prepare('DELETE FROM lkdisplaygroupgroup WHERE DisplayGroupID = :displaygroupid AND GroupID = :groupid');
 
79
                        $sth->execute(array(
 
80
                                        'displaygroupid' => $displayGroupId,
 
81
                                        'groupid' => $groupId
 
82
                                ));
 
83
                                
 
84
                        Log::notice('OUT', 'DisplayGroupSecurity', 'Unlink');
 
85
                        
 
86
                        return true;
 
87
                }
 
88
        catch (Exception $e) {
 
89
            
 
90
            Log::error($e->getMessage());
 
91
 
 
92
            if (!$this->IsError())
 
93
                $this->SetError(25007, __('Could not Unlink Display Group from User Group'));
 
94
 
 
95
            return false;
 
96
        }
 
97
        }
 
98
 
 
99
   /**
 
100
     * Unlinks a display group from a group
 
101
     * @return
 
102
     * @param $displayGroupID Object
 
103
     * @param $groupID Object
 
104
     */
 
105
    public function UnlinkAll($displayGroupId)
 
106
    {
 
107
        Log::notice('IN', 'DataSetGroupSecurity', 'Unlink');
 
108
        
 
109
        try {
 
110
            $dbh = \Xibo\Storage\PDOConnect::init();
 
111
 
 
112
            $sth = $dbh->prepare('DELETE FROM lkdisplaygroupgroup WHERE DisplayGroupID = :displaygroupid');
 
113
                        $sth->execute(array(
 
114
                                        'displaygroupid' => $displayGroupId
 
115
                                ));
 
116
 
 
117
                Log::notice('OUT', 'DataSetGroupSecurity', 'Unlink');
 
118
 
 
119
                return true;
 
120
        }
 
121
        catch (Exception $e) {
 
122
            
 
123
            Log::error($e->getMessage());
 
124
 
 
125
            if (!$this->IsError())
 
126
                $this->SetError(25007, __('Could not Unlink All Display Groups from User Group'));
 
127
 
 
128
            return false;
 
129
        }
 
130
    }
 
131
 
132
?>
 
 
b'\\ No newline at end of file'