This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Copyright (c) STMicroelectronics, 2004-2010. All rights reserved |
||
4 | * |
||
5 | * This file is a part of Codendi. |
||
6 | * |
||
7 | * Codendi is free software; you can redistribute it and/or modify |
||
8 | * it under the terms of the GNU General Public License as published by |
||
9 | * the Free Software Foundation; either version 2 of the License, or |
||
10 | * (at your option) any later version. |
||
11 | * |
||
12 | * Codendi is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
15 | * GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License |
||
18 | * along with Codendi. If not, see <http://www.gnu.org/licenses/>. |
||
19 | */ |
||
20 | |||
21 | require_once('common/dao/FRSLogDao.class.php'); |
||
22 | |||
23 | class FRSLog { |
||
24 | |||
25 | var $dao; |
||
26 | |||
27 | /** |
||
28 | * Constructor of the class. |
||
29 | * It is also used to add FRSLog events to listen in EventManager. |
||
30 | * |
||
31 | * @return FRSLog |
||
0 ignored issues
–
show
|
|||
32 | */ |
||
33 | protected function __construct() { |
||
34 | $em = EventManager::instance(); |
||
35 | $packageEventToListen = array('frs_create_package', |
||
36 | 'frs_update_package', |
||
37 | 'frs_delete_package' |
||
38 | ); |
||
39 | foreach ($packageEventToListen as $event) { |
||
40 | $em->addListener($event, $this, 'addLogPackage', true); |
||
41 | } |
||
42 | |||
43 | $releaseEventToListen = array('frs_create_release', |
||
44 | 'frs_update_release', |
||
45 | 'frs_delete_release' |
||
46 | ); |
||
47 | foreach ($releaseEventToListen as $event) { |
||
48 | $em->addListener($event, $this, 'addLogRelease', true); |
||
49 | } |
||
50 | |||
51 | $fileEventToListen = array('frs_create_file', |
||
52 | 'frs_update_file', |
||
53 | 'frs_delete_file', |
||
54 | 'frs_restore_file' |
||
55 | ); |
||
56 | foreach ($fileEventToListen as $event) { |
||
57 | $em->addListener($event, $this, 'addLogFile', true); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | protected static $_instance; |
||
62 | |||
63 | /** |
||
64 | * Singleton pattern |
||
65 | * |
||
66 | * @return FRSLog |
||
67 | */ |
||
68 | public static function instance() { |
||
69 | if (!isset(self::$_instance)) { |
||
70 | $c = __CLASS__; |
||
71 | self::$_instance = new $c; |
||
72 | } |
||
73 | return self::$_instance; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Add log for events on FRSPackage |
||
78 | * |
||
79 | * @param String $event |
||
80 | * @param Array $params |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | function addLogPackage($event, $params) { |
||
85 | $userID = $this->_getCurrentUser()->getId(); |
||
86 | $projectID = $params['group_id']; |
||
87 | $itemID = $params['item_id']; |
||
88 | switch ($event) { |
||
89 | case 'frs_create_package' : |
||
90 | $actionID = FRSPackage::EVT_CREATE; |
||
91 | break; |
||
92 | case 'frs_update_package' : |
||
93 | $actionID = FRSPackage::EVT_UPDATE; |
||
94 | break; |
||
95 | case 'frs_delete_package' : |
||
96 | $actionID = FRSPackage::EVT_DELETE; |
||
97 | break; |
||
98 | } |
||
99 | $this->addLog($userID, $projectID, $itemID, $actionID); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Add log for events on FRSRelease |
||
104 | * |
||
105 | * @param String $event |
||
106 | * @param Array $params |
||
107 | * |
||
108 | * @return void |
||
109 | */ |
||
110 | function addLogRelease($event, $params) { |
||
111 | $userID = $this->_getCurrentUser()->getId(); |
||
112 | $projectID = $params['group_id']; |
||
113 | $itemID = $params['item_id']; |
||
114 | switch ($event) { |
||
115 | case 'frs_create_release' : |
||
116 | $actionID = FRSRelease::EVT_CREATE; |
||
117 | break; |
||
118 | case 'frs_update_release' : |
||
119 | $actionID = FRSRelease::EVT_UPDATE; |
||
120 | break; |
||
121 | case 'frs_delete_release' : |
||
122 | $actionID = FRSRelease::EVT_DELETE; |
||
123 | break; |
||
124 | } |
||
125 | $this->addLog($userID, $projectID, $itemID, $actionID); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * Add log for events on FRSFile |
||
130 | * |
||
131 | * @param String $event |
||
132 | * @param Array $params |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | function addLogFile($event, $params) { |
||
137 | $userID = $this->_getCurrentUser()->getId(); |
||
138 | $projectID = $params['group_id']; |
||
139 | $itemID = $params['item_id']; |
||
140 | switch ($event) { |
||
141 | case 'frs_create_file' : |
||
142 | $actionID = FRSFile::EVT_CREATE; |
||
143 | break; |
||
144 | case 'frs_update_file' : |
||
145 | $actionID = FRSFile::EVT_UPDATE; |
||
146 | break; |
||
147 | case 'frs_delete_file' : |
||
148 | $actionID = FRSFile::EVT_DELETE; |
||
149 | break; |
||
150 | case 'frs_restore_file' : |
||
151 | $actionID = FRSFile::EVT_RESTORE; |
||
152 | break; |
||
153 | } |
||
154 | $this->addLog($userID, $projectID, $itemID, $actionID); |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Obtain an instance of FRSLogDao |
||
159 | * |
||
160 | * @return FRSLogDao |
||
161 | */ |
||
162 | function _getFRSLogDao() { |
||
163 | if (!$this->dao) { |
||
164 | $this->dao = new FRSLogDao(CodendiDataAccess::instance()); |
||
165 | } |
||
166 | return $this->dao; |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * Store the event in DB |
||
171 | * |
||
172 | * @param Integer $userID |
||
173 | * @param Integer $projectID |
||
174 | * @param Integer $itemID |
||
175 | * @param Integer $actionID |
||
176 | * |
||
177 | * @return void |
||
178 | */ |
||
179 | function addLog($userID, $projectID, $itemID, $actionID) { |
||
180 | $dao = $this->_getFRSLogDao(); |
||
181 | $dao->addLog($userID, $projectID, $itemID, $actionID); |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * Obtain the current user |
||
186 | * |
||
187 | * @return PFUser |
||
188 | */ |
||
189 | function _getCurrentUser() { |
||
190 | $um = UserManager::instance(); |
||
191 | return $um->getCurrentUser(); |
||
192 | } |
||
193 | |||
194 | } |
||
195 | |||
196 | ?> |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.