1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. 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
|
|
|
/** |
22
|
|
|
* ServiceFile |
23
|
|
|
*/ |
24
|
|
|
class ServiceFile extends Service { |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* getPublicArea |
29
|
|
|
* |
30
|
|
|
* Return the link which will be displayed in public area in summary page |
31
|
|
|
*/ |
32
|
|
|
function getPublicArea() { |
33
|
|
|
$html = ''; |
34
|
|
|
$html .= '<p><a href="/file/showfiles.php?group_id='.$this->getGroupId().'">'; |
35
|
|
|
$html .= $GLOBALS['Response']->getImage("ic/file.png", array('width'=>'20', 'height'=>'20', 'alt'=>$GLOBALS['Language']->getText('include_project_home','files'))); |
36
|
|
|
$html .= ' '.$GLOBALS['Language']->getText('include_project_home','file_releases').'</a>'; |
37
|
|
|
$html .= ' ( '.$GLOBALS['Language']->getText('include_project_home','packages',count($this->_getPackagesForUser(user_getid()))).' )'; |
38
|
|
|
$html .= '</p>'; |
39
|
|
|
return $html; |
40
|
|
|
} |
41
|
|
|
/** |
42
|
|
|
* getSummaryPageContent |
43
|
|
|
* |
44
|
|
|
* Return the text to display on the summary page |
45
|
|
|
* @return arr[title], arr[content] |
|
|
|
|
46
|
|
|
*/ |
47
|
|
|
function getSummaryPageContent() { |
48
|
|
|
$hp = Codendi_HTMLPurifier::instance(); |
49
|
|
|
$user = UserManager::instance()->getCurrentUser(); |
50
|
|
|
$ret = array( |
51
|
|
|
'title' => $GLOBALS['Language']->getText('include_project_home','latest_file_releases'), |
52
|
|
|
'content' => '' |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$packages = $this->_getPackagesForUser($user->getId()); |
56
|
|
|
if (count($packages)) { |
57
|
|
|
$ret['content'] .= ' |
58
|
|
|
<table cellspacing="1" cellpadding="5" width="100%" border="0"> |
59
|
|
|
<tr class="boxitem"> |
60
|
|
|
<td> |
61
|
|
|
'.$GLOBALS['Language']->getText('include_project_home','package').' |
62
|
|
|
</td> |
63
|
|
|
<td> |
64
|
|
|
'.$GLOBALS['Language']->getText('include_project_home','version').' |
65
|
|
|
</td> |
66
|
|
|
<td> |
67
|
|
|
'.$GLOBALS['Language']->getText('include_project_home','download').' |
68
|
|
|
</td> |
69
|
|
|
</tr> |
70
|
|
|
'; |
71
|
|
|
require_once('FileModuleMonitorFactory.class.php'); |
72
|
|
|
$fmmf = new FileModuleMonitorFactory(); |
73
|
|
|
foreach($packages as $package) { |
74
|
|
|
// the icon is different whether the package is monitored or not |
75
|
|
|
if ($fmmf->isMonitoring($package['package_id'], $user, false)) { |
76
|
|
|
$monitor_img = $GLOBALS['HTML']->getImage("ic/notification_stop.png",array('alt'=>$GLOBALS['Language']->getText('include_project_home', 'stop_monitoring'), 'title'=>$GLOBALS['Language']->getText('include_project_home', 'stop_monitoring'))); |
77
|
|
|
} else { |
78
|
|
|
$monitor_img = $GLOBALS['HTML']->getImage("ic/notification_start.png",array('alt'=>$GLOBALS['Language']->getText('include_project_home', 'start_monitoring'), 'title'=>$GLOBALS['Language']->getText('include_project_home', 'start_monitoring'))); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$ret['content'] .= ' |
82
|
|
|
<TR class="boxitem"> |
83
|
|
|
<TD> |
84
|
|
|
<B>' . $hp->purify(util_unconvert_htmlspecialchars($package['package_name']), CODENDI_PURIFIER_CONVERT_HTML) . '</B> |
85
|
|
|
<a HREF="/file/filemodule_monitor.php?filemodule_id=' . $package['package_id'] . '&group_id='.$this->getGroupId().'">'. |
86
|
|
|
$monitor_img . ' |
87
|
|
|
</a> |
88
|
|
|
</TD>'; |
89
|
|
|
// Releases to display |
90
|
|
|
$ret['content'] .= '<TD>'. $hp->purify($package['release_name'], CODENDI_PURIFIER_CONVERT_HTML) .' <A href="/file/shownotes.php?group_id=' . $this->getGroupId() . '&release_id=' . $package['release_id'] . '">' . |
91
|
|
|
$GLOBALS['HTML']->getImage("ic/text.png",array('alt'=>$GLOBALS['Language']->getText('include_project_home','release_notes'), 'title'=>$GLOBALS['Language']->getText('include_project_home','release_notes'))) . ' |
92
|
|
|
</TD> |
93
|
|
|
<TD><A HREF="/file/showfiles.php?group_id=' . $this->getGroupId() . '&release_id=' . $package['release_id'] . '">'.$GLOBALS['Language']->getText('include_project_home','download').'</A></TD></TR>'; |
94
|
|
|
} |
95
|
|
|
$ret['content'] .= '</table>'; |
96
|
|
|
} else { |
97
|
|
|
$ret['content'] .= '<b>'. $GLOBALS['Language']->getText('include_project_home','no_files_released') .'</b>'; |
98
|
|
|
} |
99
|
|
|
$ret['content'] .= ' |
100
|
|
|
<div align="center"> |
101
|
|
|
<a href="/file/showfiles.php?group_id='.$this->getGroupId().'">['.$GLOBALS['Language']->getText('include_project_home','view_all_files').']</A> |
102
|
|
|
</div> |
103
|
|
|
'; |
104
|
|
|
return $ret; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
private function getFRSPackageFactory() { |
108
|
|
|
require_once('FRSPackageFactory.class.php'); |
109
|
|
|
return new FRSPackageFactory(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* _getPackagesForUser |
114
|
|
|
* |
115
|
|
|
* return the packages the user can see |
116
|
|
|
* |
117
|
|
|
* @param user_id |
118
|
|
|
*/ |
119
|
|
|
function _getPackagesForUser($user_id) { |
120
|
|
|
$frspf = $this->getFRSPackageFactory(); |
121
|
|
|
$packages = array(); |
122
|
|
|
$sql="SELECT frs_package.package_id,frs_package.name AS package_name,frs_release.name AS release_name,frs_release.release_id AS release_id,frs_release.release_date AS release_date ". |
123
|
|
|
"FROM frs_package,frs_release ". |
124
|
|
|
"WHERE frs_package.package_id=frs_release.package_id ". |
125
|
|
|
"AND frs_package.group_id='". db_ei($this->getGroupId()) ."' ". |
126
|
|
|
"AND frs_release.status_id=' ".db_ei($frspf->STATUS_ACTIVE)."' ". |
127
|
|
|
"ORDER BY frs_package.rank,frs_package.package_id,frs_release.release_date DESC, frs_release.release_id DESC"; |
128
|
|
|
$res_files = db_query($sql); |
129
|
|
|
$rows_files = db_numrows($res_files); |
130
|
|
|
if ($res_files && $rows_files >= 1) { |
131
|
|
|
for ($f=0; $f<$rows_files; $f++) { |
132
|
|
|
$package_id=db_result($res_files,$f,'package_id'); |
133
|
|
|
$release_id=db_result($res_files,$f,'release_id'); |
134
|
|
|
if ($frspf->userCanRead($this->getGroupId(), $package_id, $user_id)) { |
135
|
|
|
if (isset($package_displayed[$package_id]) && $package_displayed[$package_id]) { |
136
|
|
|
//if ($package_id==db_result($res_files,($f-1),'package_id')) { |
137
|
|
|
//same package as last iteration - don't show this release |
138
|
|
|
} else { |
139
|
|
|
$authorized=false; |
140
|
|
|
// check access. |
141
|
|
|
if (permission_exist('RELEASE_READ', $release_id)) { |
142
|
|
|
$authorized=permission_is_authorized('RELEASE_READ',$release_id, $user_id ,$this->getGroupId()); |
143
|
|
|
} else { |
144
|
|
|
$authorized=permission_is_authorized('PACKAGE_READ',$package_id, $user_id ,$this->getGroupId()); |
145
|
|
|
} |
146
|
|
|
if ($authorized) { |
147
|
|
|
$packages[] = array( |
148
|
|
|
'package_name' => db_result($res_files,$f,'package_name'), |
149
|
|
|
'release_name' => db_result($res_files,$f,'release_name'), |
150
|
|
|
'release_id' => $release_id, |
151
|
|
|
'package_id' => $package_id, |
152
|
|
|
); |
153
|
|
|
$package_displayed[$package_id] = true; |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
return $packages; |
160
|
|
|
} |
161
|
|
|
function isRequestedPageDistributed(&$request) { |
162
|
|
|
return in_array($_SERVER['SCRIPT_NAME'], array( |
163
|
|
|
'/file/admin/release.php', |
164
|
|
|
'/file/admin/frsajax.php', |
165
|
|
|
'/file/download.php', |
166
|
|
|
)); |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
?> |
170
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.