1 | <?php
|
---|
2 | /*
|
---|
3 | $Id: file_admin.php 2292 2009-08-24 09:40:09Z andrewsimpson $
|
---|
4 |
|
---|
5 | (c) 2002 - 2009 Andrew Simpson <andrew.simpson at paradise.net.nz>
|
---|
6 |
|
---|
7 | WebCollab
|
---|
8 | ---------------------------------------
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under the
|
---|
11 | terms of the GNU General Public License as published by the Free Software Foundation;
|
---|
12 | either version 2 of the License, or (at your option) any later version.
|
---|
13 |
|
---|
14 | This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
---|
16 | PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License along with this
|
---|
19 | program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
---|
20 | Cambridge, MA 02139, USA.
|
---|
21 |
|
---|
22 | Function:
|
---|
23 | ---------
|
---|
24 |
|
---|
25 | Lists files assigned to a task
|
---|
26 |
|
---|
27 | */
|
---|
28 |
|
---|
29 | //security check
|
---|
30 | if(! defined('UID' ) ) {
|
---|
31 | die('Direct file access not permitted' );
|
---|
32 | }
|
---|
33 |
|
---|
34 | if(! ADMIN ) {
|
---|
35 | error('Access denied', 'This feature is only for admins' );
|
---|
36 | }
|
---|
37 |
|
---|
38 | include_once(BASE.'includes/time.php' );
|
---|
39 |
|
---|
40 | $content = '';
|
---|
41 |
|
---|
42 | //get the files from this task
|
---|
43 | $q = db_query('SELECT '.PRE.'files.id AS id,
|
---|
44 | '.PRE.'files.filename AS filename,
|
---|
45 | '.PRE.'files.uploaded AS uploaded,
|
---|
46 | '.PRE.'files.size AS size,
|
---|
47 | '.PRE.'files.description AS description,
|
---|
48 | '.PRE.'files.uploader AS uploader,
|
---|
49 | '.PRE.'tasks.id AS task_id,
|
---|
50 | '.PRE.'tasks.name AS task_name,
|
---|
51 | '.PRE.'users.id AS userid,
|
---|
52 | '.PRE.'users.fullname AS username
|
---|
53 | FROM '.PRE.'files
|
---|
54 | LEFT JOIN '.PRE.'tasks ON ('.PRE.'files.taskid='.PRE.'tasks.id)
|
---|
55 | LEFT JOIN '.PRE.'users ON ('.PRE.'users.id='.PRE.'files.uploader)
|
---|
56 | ORDER BY task_name' );
|
---|
57 |
|
---|
58 | $content .= "<table>\n";
|
---|
59 |
|
---|
60 | //show them
|
---|
61 | for($i=0 ; $row = @db_fetch_array($q, $i ) ; ++$i ) {
|
---|
62 |
|
---|
63 | if($i > 0 ) {
|
---|
64 | //not the first line, need to add a divider
|
---|
65 | $content .= "<tr><td><hr /></td></tr>\n";
|
---|
66 | }
|
---|
67 |
|
---|
68 | //file part
|
---|
69 | $content .= "<tr><td>".$lang['task'].":</td><td>".
|
---|
70 | "<a href=\"tasks.php?x=".X."&action=show&taskid=".$row['task_id']."\">".$row['task_name']."</a>".
|
---|
71 | "</td></tr>\n".
|
---|
72 | "<tr><td>".$lang['file']."</td><td>".
|
---|
73 | "<a href=\"files.php?x=".X."&action=download&fileid=".$row['id']."\"". "onclick=\"window.open('files.php?x=".X."&action=download&fileid=".$row['id']."'); return false\">".$row['filename']."</a>".
|
---|
74 | " <small>(".nice_size($row['size'] ).") </small>".
|
---|
75 | //delete option
|
---|
76 | "<span class=\"textlink\">[<a href=\"files.php?x=".X."&action=delete&fileid=".$row['id']."&admin=1&taskid=".$row['task_id']."\">".$lang['del']."</a>]</span></td></tr>\n".
|
---|
77 | //user part
|
---|
78 | "<tr><td>".$lang['uploader']." </td><td><a href=\"users.php?x=".X."&action=show&userid=".$row['userid']."\">".$row['username']."</a> (".nicetime( $row['uploaded'] ).")</td></tr>\n";
|
---|
79 |
|
---|
80 | //show description
|
---|
81 | if( $row['description'] != '' ) {
|
---|
82 | $content .= "<tr><td>".$lang['description'].":</td><td><small><i>".nl2br($row['description'])."</i></small></td></tr>\n";
|
---|
83 | }
|
---|
84 | //blank line to end
|
---|
85 | $content .= "<tr><td> </td></tr>\n";
|
---|
86 |
|
---|
87 | }
|
---|
88 |
|
---|
89 | $content .= "</table>\n";
|
---|
90 |
|
---|
91 | if($i == 0 ) {
|
---|
92 | //no files found in database
|
---|
93 | $content = $lang['no_files']."\n";
|
---|
94 | new_box($lang['manage_files'], $content );
|
---|
95 | }
|
---|
96 | else {
|
---|
97 | //show found content
|
---|
98 | new_box( $lang['manage_files'], $content );
|
---|
99 | }
|
---|
100 |
|
---|
101 | ?>
|
---|