2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
16 * This script creates the main index page for "file storage" that
17 * handles file upload, edit, view, delete, assignment hand-in etc.
18 * The table below is the mapping between owner type and owner id:
19 ******************************************************
21 ******************************************************
22 * WORKSPACE_COURSE course_id
23 * WORKSPACE_PERSONAL member_id
24 * WORKSPACE_GROUP group_id
26 define('AT_INCLUDE_PATH', '../../../include/');
27 require(AT_INCLUDE_PATH.'vitals.inc.php');
28 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); // for get_human_size()
29 require(AT_INCLUDE_PATH.'../mods/_standard/file_storage/file_storage.inc.php');
31 // check folders and files id
32 if (isset($_GET['folders'])){
33 if (is_array($_GET['folders'])){
34 foreach($_GET['folders'] as $k=>$v){
35 $_GET['folders'][$k] = abs($_GET['folders'][$k]);
38 $_GET['folders']= abs($_GET['folders']);
41 if (isset($_GET['files'])){
42 if (is_array($_GET['files'])){
43 foreach($_GET['files'] as $k=>$v){
44 $_GET['files'][$k] = abs($_GET['files'][$k]);
47 $_GET['files']= abs($_GET['files']);
51 if (isset($_GET['submit_workspace'])) {
52 unset($_GET['folder']);
53 unset($assignment_for);
55 $owner_type = abs($_GET['ot']);
57 if ($owner_type == WORKSPACE_GROUP) {
59 $parts = explode('_', $_GET['ot'], 2);
60 if (isset($parts[1]) && $parts[1] && isset($_SESSION['groups'][$parts[1]])) {
61 $owner_id = $parts[1];
63 $owner_type = WORKSPACE_COURSE;
66 } else if ($owner_type == WORKSPACE_ASSIGNMENT) {
67 $parts = explode('_', $_GET['ot'], 3);
69 if (isset($parts[1]) && $parts[1]) {
70 if ($parts[2] == 'my') {
71 $assignment_for = 'my';
73 $owner_id = $parts[1];
75 $owner_type = WORKSPACE_ASSIGNMENT;
81 $_REQUEST['folder'] = 0;
82 } else if (isset($_REQUEST['ot'], $_REQUEST['oid'])) {
83 $owner_type = abs($_REQUEST['ot']);
84 $owner_id = abs($_REQUEST['oid']);
85 } else if (isset($_SESSION['fs_owner_type'], $_SESSION['fs_owner_id'], $_SESSION['fs_folder_id'])) {
86 $owner_type = abs($_SESSION['fs_owner_type']);
87 $owner_id = abs($_SESSION['fs_owner_id']);
89 $owner_type = WORKSPACE_COURSE;
92 if (isset($_REQUEST['folder'])) {
93 $folder_id = abs($_REQUEST['folder']);
94 } else if (isset($_SESSION['fs_folder_id'])) {
95 $folder_id = abs($_SESSION['fs_folder_id']);
100 // init the owner_id if not currently set
101 if (!isset($owner_id)) {
102 if ($owner_type == WORKSPACE_COURSE) {
103 $owner_id = $_SESSION['course_id'];
104 } else if ($owner_type == WORKSPACE_PERSONAL) {
105 $owner_id = $_SESSION['member_id'];
106 } else if ($owner_type == WORKSPACE_GROUP) {
107 $owner_id = $group_id;
111 $owner_arg_prefix = '?ot='.$owner_type.SEP.'oid='.$owner_id. SEP;
113 if ($assignment_for == 'my') {
114 $owner_arg_prefix .= 'folder='.$_SESSION['member_id'];
116 if (!($owner_status = fs_authenticate($owner_type, $owner_id))) {
117 $msg->addError('ACCESS_DENIED');
118 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php', AT_PRETTY_URL_IS_HEADER));
121 $_SESSION['fs_owner_type'] = $owner_type;
122 $_SESSION['fs_owner_id'] = $owner_id;
123 $_SESSION['fs_folder_id'] = $folder_id;
125 if (isset($_GET['submit_workspace'])) {
126 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix, AT_PRETTY_URL_IS_HEADER));
130 // action - Submit Assignment
131 if (isset($_GET['assignment']) && (isset($_GET['files']) || isset($_GET['folders']))) {
132 if (isset($_GET['folders'])) {
133 $msg->addError('HAND_IN_FOLDER');
134 } else if (!isset($_GET['files'])) {
135 $msg->addError('NO_ITEM_SELECTED');
137 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/assignment.php?'.$_SERVER['QUERY_STRING']);
141 // action - View Revisions
142 else if (isset($_GET['revisions'], $_GET['files'])) {
143 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
144 $file_id = current($_GET['files']);
145 header('Location: '.url_rewrite('mods/_standard/file_storage/revisions.php'.$owner_arg_prefix.'id='.$file_id, AT_PRETTY_URL_IS_HEADER));
149 // action - View Comments
150 else if (isset($_GET['comments'], $_GET['files'])) {
151 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
152 $file_id = current($_GET['files']);
153 header('Location: '.url_rewrite('comments.php'.$owner_arg_prefix.'id='.$file_id, AT_PRETTY_URL_IS_HEADER));
157 // action - Edit File/Folder
158 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_GET['edit']) && (isset($_GET['folders']) || isset($_GET['files']))) {
159 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
160 $file_id = current($_GET['files']);
161 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/edit.php'.$owner_arg_prefix.'id='.$file_id);
163 } else if (is_array($_GET['folders']) && (count($_GET['folders']) == 1) && empty($_GET['files'])) {
164 $folder_id = current($_GET['folders']);
165 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/edit_folder.php'.$owner_arg_prefix.'id='.$folder_id);
169 // action - Move Files/Folders
170 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_GET['move']) && (isset($_GET['folders']) || isset($_GET['files']))) {
171 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/move.php'.$owner_arg_prefix.$_SERVER['QUERY_STRING']);
174 // action - Download Files/Folders
175 else if (isset($_GET['download']) && (isset($_GET['folders']) || isset($_GET['files']))) {
176 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
177 $file_id = current($_GET['files']);
178 $sql = "SELECT file_name, file_size FROM ".TABLE_PREFIX."files WHERE file_id=$file_id";
179 $result = mysql_query($sql, $db);
180 if ($row = mysql_fetch_assoc($result)) {
181 $ext = fs_get_file_extension($row['file_name']);
183 if (isset($mime[$ext]) && $mime[$ext][0]) {
184 $file_mime = $mime[$ext][0];
186 $file_mime = 'application/octet-stream';
188 $file_path = fs_get_file_path($file_id) . $file_id;
191 header("Content-Encoding: none");
192 header('Content-Type: ' . $file_mime);
193 header('Content-transfer-encoding: binary');
194 header('Content-Disposition: attachment; filename="'.htmlspecialchars($row['file_name']).'"');
195 header('Expires: 0');
196 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
197 header('Pragma: public');
198 header('Content-Length: '.$row['file_size']);
200 // see the note in get.php about the use of x-Sendfile
201 header('x-Sendfile: '.$file_path);
202 header('x-Sendfile: ', TRUE); // if we get here then it didn't work
204 @readfile($file_path);
208 // zip multiple files and folders
209 require(AT_INCLUDE_PATH . 'classes/zipfile.class.php');
210 $zipfile = new zipfile();
212 $zip_file_name = fs_get_workspace($owner_type, $owner_id); // want the name of the workspace
213 $zip_file_name = str_replace(" ","_",$zip_file_name );
215 if (is_array($_GET['files'])) {
216 foreach ($_GET['files'] as $file_id) {
217 $file_path = fs_get_file_path($file_id) . $file_id;
220 $sql = "SELECT file_name, UNIX_TIMESTAMP(date) AS date FROM ".TABLE_PREFIX."files WHERE file_id=$file_id AND owner_type=$owner_type AND owner_id=$owner_id";
221 $result = mysql_query($sql, $db);
222 if (($row = mysql_fetch_assoc($result)) && file_exists($file_path)) {
223 $zipfile->add_file(file_get_contents($file_path), $row['file_name'], $row['date']);
227 if (is_array($_GET['folders'])) {
228 foreach($_GET['folders'] as $folder_id) {
229 fs_download_folder($folder_id, $zipfile, $owner_type, $owner_id);
230 $row['title'] = str_replace(" ","_",$row['title'] );
231 $zipfile->create_dir($row['title']);
234 if (count($_GET['folders']) == 1) {
235 // zip just one folder, use that folder's title as the zip file name
236 $row = fs_get_folder_by_id($_GET['folders'][0], $owner_type, $owner_id);
238 $zip_file_name = $row['title'];
239 $zip_file_name = str_replace(" ","_",$zip_file_name );
244 $zipfile->send_file($zip_file_name);
248 // action - Delete Files/Folders (pre-confirmation)
249 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_GET['delete']) && (isset($_GET['folders']) || isset($_GET['files']))) {
250 $hidden_vars = array();
251 $hidden_vars['folder'] = $folder_id;
252 $hidden_vars['ot'] = $owner_type;
253 $hidden_vars['oid'] = $owner_id;
254 if (isset($_GET['files'])) {
255 $file_list_to_print = '';
256 $files = implode(',', $_GET['files']);
257 $hidden_vars['files'] = $files;
258 $sql = "SELECT file_name FROM ".TABLE_PREFIX."files WHERE file_id IN ($files) AND owner_type=$owner_type AND owner_id=$owner_id ORDER BY file_name";
259 $result = mysql_query($sql, $db);
260 while ($row = mysql_fetch_assoc($result)) {
261 $file_list_to_print .= '<li style="list-style: none; margin: 0px; padding: 0px 10px;"><img src="images/file_types/'.fs_get_file_type_icon($row['file_name']).'.gif" height="16" width="16" alt="" title="" /> '.htmlspecialchars($row['file_name']).'</li>';
263 $msg->addConfirm(array('FILE_DELETE', $file_list_to_print), $hidden_vars);
266 if (isset($_GET['folders'])) {
267 $dir_list_to_print = '';
268 $folders = implode(',', $_GET['folders']);
269 $hidden_vars['folders'] = $folders;
270 $rows = fs_get_folder_by_id($_GET['folders'], $owner_type, $owner_id);
271 foreach ($rows as $row) {
272 $dir_list_to_print .= '<li style="list-style: none; margin: 0px; padding: 0px 10px;"><img src="images/folder.gif" height="18" width="20" alt="" title="" /> '.AT_print($row['title'], 'input.text').'</li>';
274 $msg->addConfirm(array('DIR_DELETE', $dir_list_to_print), $hidden_vars);
277 require(AT_INCLUDE_PATH.'header.inc.php');
278 $msg->printConfirm();
279 require(AT_INCLUDE_PATH.'footer.inc.php');
283 // action - Confirm Delete Files/Folders
284 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['submit_yes'])) {
287 if (isset($_POST['files'])) {
288 $files = explode(',', $_POST['files']);
290 if (isset($_POST['folders'])) {
291 $folders = explode(',', $_POST['folders']);
294 foreach ($files as $file) {
295 fs_delete_file($file, $owner_type, $owner_id);
297 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
300 if (isset($folders)) {
301 foreach ($folders as $folder) {
302 fs_delete_folder($folder, $owner_type, $owner_id);
304 $msg->addFeedback('DIR_DELETED');
307 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.abs($_POST['folder']), AT_PRETTY_URL_IS_HEADER));
310 // action - Cancel Delete
311 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['submit_no'])) {
312 $msg->addFeedback('CANCELLED');
313 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.abs($_POST['folder']), AT_PRETTY_URL_IS_HEADER));
316 // action - Create Folder
317 } else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['create_folder'])) {
318 // create a new folder
319 $_POST['new_folder_name'] = trim($_POST['new_folder_name']);
321 if (!$_POST['new_folder_name']) {
322 $msg->addError(array('EMPTY_FIELDS', _AT('name')));
325 if (!$msg->containsErrors()) {
326 $_POST['new_folder_name'] = $addslashes($_POST['new_folder_name']);
328 $parent_folder_id = abs($_POST['folder']);
330 $sql = "INSERT INTO ".TABLE_PREFIX."folders VALUES (NULL, $parent_folder_id, $owner_type, $owner_id, '$_POST[new_folder_name]')";
331 $result = mysql_query($sql, $db);
332 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
333 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.$parent_folder_id, AT_PRETTY_URL_IS_HEADER));
338 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['upload'])) {
339 // handle the file upload
340 $_POST['comments'] = trim($_POST['comments']);
342 $parent_folder_id = abs($_POST['folder']);
344 if ($_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE) {
345 $msg->addError(array('FILE_TOO_BIG', get_human_size(megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1)))));
347 } else if (!isset($_FILES['file']['name']) || ($_FILES['file']['error'] == UPLOAD_ERR_NO_FILE) || ($_FILES['file']['size'] == 0)) {
348 $msg->addError('FILE_NOT_SELECTED');
350 } else if ($_FILES['file']['error'] || !is_uploaded_file($_FILES['file']['tmp_name'])) {
351 $msg->addError('FILE_NOT_SAVED');
354 // check that we own this folder
355 if ($parent_folder_id) {
356 $sql = "SELECT folder_id FROM ".TABLE_PREFIX."folders WHERE folder_id=$parent_folder_id AND owner_type=$owner_type AND owner_id=$owner_id";
357 $result = mysql_query($sql, $db);
358 if (!$row = mysql_fetch_assoc($result)) {
359 $msg->addError('ACCESS_DENIED');
360 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/index.php');
365 if (!$msg->containsErrors()) {
366 $_POST['description'] = $addslashes(trim($_POST['description']));
367 $_FILES['file']['name'] = addslashes($_FILES['file']['name']);
369 if ($_POST['comments']) {
375 $sql = "INSERT INTO ".TABLE_PREFIX."files VALUES (NULL, $owner_type, $owner_id, $_SESSION[member_id], $parent_folder_id, 0, NOW(), $num_comments, 0, '{$_FILES['file']['name']}', {$_FILES['file']['size']}, '$_POST[description]')";
376 $result = mysql_query($sql, $db);
378 if ($result && ($file_id = mysql_insert_id($db))) {
379 $path = fs_get_file_path($file_id);
380 move_uploaded_file($_FILES['file']['tmp_name'], $path . $file_id);
382 // check if this file name already exists
383 $sql = "SELECT file_id, num_revisions FROM ".TABLE_PREFIX."files WHERE owner_type=$owner_type AND owner_id=$owner_id AND folder_id=$parent_folder_id AND file_id<>$file_id AND file_name='{$_FILES['file']['name']}' AND parent_file_id=0 ORDER BY file_id DESC LIMIT 1";
384 $result = mysql_query($sql, $db);
385 if ($row = mysql_fetch_assoc($result)) {
386 if ($_config['fs_versioning']) {
387 $sql = "UPDATE ".TABLE_PREFIX."files SET parent_file_id=$file_id, date=date WHERE file_id=$row[file_id]";
388 $result = mysql_query($sql, $db);
390 $sql = "UPDATE ".TABLE_PREFIX."files SET num_revisions=$row[num_revisions]+1, date=date WHERE file_id=$file_id";
391 $result = mysql_query($sql, $db);
393 fs_delete_file($row['file_id'], $owner_type, $owner_id);
397 $msg->addFeedback('FILE_UPLOADED');
399 $msg->addError('FILE_NOT_SAVED');
402 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.$parent_folder_id, AT_PRETTY_URL_IS_HEADER));
404 } else if ((isset($_GET['delete']) || isset($_GET['download']) || isset($_GET['move']) || isset($_GET['edit']) || isset($_GET['assignment'])) && !isset($_GET['files']) && !isset($_GET['folders'])) {
405 $msg->addError('NO_ITEM_SELECTED');
408 if (query_bit($owner_status, WORKSPACE_AUTH_WRITE)) {
409 $onload = 'hideform(\'upload\'); hideform(\'c_folder\');';
412 require(AT_INCLUDE_PATH.'header.inc.php');
414 $orders = array('asc' => 'desc', 'desc' => 'asc');
415 $cols = array('file_name' => 1, 'file_size' => 1, 'date' => 1);
417 if (isset($_GET['asc'])) {
419 $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'file_name';
420 } else if (isset($_GET['desc'])) {
422 $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'file_name';
429 $folder_path = fs_get_folder_path($folder_id, $owner_type, $owner_id);
431 $folders = fs_get_folder_by_pid($folder_id, $owner_type, $owner_id);
434 $sql = "SELECT * FROM ".TABLE_PREFIX."files WHERE folder_id=$folder_id AND owner_type=$owner_type AND owner_id=$owner_id AND parent_file_id=0 ORDER BY $col $order";
435 $result = mysql_query($sql, $db);
437 while ($row = mysql_fetch_assoc($result)) {
443 <?php if (query_bit($owner_status, WORKSPACE_AUTH_WRITE)): ?>
444 <form method="post" action="<?php echo 'mods/_standard/file_storage/index.php'.$owner_arg_prefix; ?>" enctype="multipart/form-data" name="form0">
445 <input type="hidden" name="folder" value="<?php echo $folder_id; ?>" />
446 <div style="margin-left:auto; margin-right:auto;width: 95%;">
447 <div class="input-form" style="width: 48%; float: right;" >
449 <h3><a href="mods/_standard/file_storage/index.php" onclick="javascript:toggleform('c_folder'); return false;" style="font-family: Helevetica, Arial, sans-serif;" onmouseover="this.style.cursor='pointer'" onfocus="this.style.cursor='pointer'"><?php echo _AT('create_folder'); ?></a></h3>
453 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="fname"><?php echo _AT('name'); ?></label><br />
454 <input type="text" id="fname" name="new_folder_name" size="20" />
456 <div class="row buttons">
457 <input type="submit" name="create_folder" value="<?php echo _AT('create'); ?>" class="button" />
463 <div class="input-form" style="float: left; width: 48%;">
465 <h3><a href="mods/_standard/file_storage/index.php" onclick="javascript:toggleform('upload'); return false;" style="font-family: Helevetica, Arial, sans-serif;" onmouseover="this.style.cursor='pointer'" onfocus="this.style.cursor='pointer'"><?php echo _AT('new_file'); ?></a></h3>
469 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="file"><?php echo _AT('upload_file'); ?></label><br />
470 <input type="file" name="file" id="file" />
471 <br /><?php echo _AT('or'); ?> <a href="mods/_standard/file_storage/new.php<?php echo $owner_arg_prefix; ?>folder=<?php echo $folder_id; ?>"><?php echo _AT('file_manager_new'); ?></a>
474 <label for="description"><?php echo _AT('description'); ?></label><br />
475 <textarea name="description" id="description" rows="1" cols="20"></textarea>
477 <div class="row buttons">
478 <input type="submit" name="upload" value="<?php echo _AT('upload'); ?>" class="button"/>
489 if ($_SESSION['groups']) {
490 $file_storage_groups = array();
491 $groups_list = implode(',',$_SESSION['groups']);
492 $sql = "SELECT G.type_id, G.title, G.group_id FROM ".TABLE_PREFIX."file_storage_groups FS INNER JOIN ".TABLE_PREFIX."groups G USING (group_id) WHERE FS.group_id IN ($groups_list) ORDER BY G.type_id, G.title";
493 $result = mysql_query($sql, $db);
494 while ($row = mysql_fetch_assoc($result)) {
495 $file_storage_groups[] = $row;
499 if (authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN)) {
500 $file_storage_assignments = array();
501 $sql = "SELECT * FROM ".TABLE_PREFIX."assignments WHERE course_id=$_SESSION[course_id] ORDER BY title";
502 $result = mysql_query($sql, $db);
503 while ($row = mysql_fetch_assoc($result)) {
504 $file_storage_assignments[] = $row;
508 if ($_SESSION['member_id'] && $_SESSION['enroll']){
509 $my_assignments = array();
510 $sql = "SELECT distinct a.title, a.assignment_id FROM ".TABLE_PREFIX."assignments a, ".TABLE_PREFIX."files f
511 WHERE a.course_id = ".$_SESSION[course_id]."
512 AND a.assignment_id = f.owner_id
513 AND f.owner_type= ".WORKSPACE_ASSIGNMENT."
514 AND f.member_id = ".$_SESSION['member_id']."
516 $result = mysql_query($sql, $db);
517 while ($row = mysql_fetch_assoc($result)) {
518 $my_assignments[] = $row;
522 <div style="margin-left:auto;margin-right:auto; clear:both;width:95%;">
523 <form method="get" action="<?php echo url_rewrite('mods/_standard/file_storage/index.php', AT_PRETTY_URL_IS_HEADER);?>" name="form">
524 <input type="hidden" name="folder" value="<?php echo $folder_id; ?>" />
525 <input type="hidden" name="oid" value="<?php echo $owner_id; ?>" />
528 <?php if ($col == 'file_name'): ?>
532 <?php elseif($col == 'file_size'): ?>
536 <?php elseif($col == 'date'): ?>
544 <label for="ot"><?php echo _AT('workspace'); ?> </label>
545 <select name="ot" id="ot">
546 <option value="1" <?php if ($owner_type == WORKSPACE_COURSE) { echo 'selected="selected"'; } ?>><?php echo _AT('course_files'); ?></option>
547 <?php if ($_SESSION['member_id'] && $_SESSION['enroll']): ?>
548 <option value="2" <?php if ($owner_type == WORKSPACE_PERSONAL) { echo 'selected="selected"'; } ?>><?php echo _AT('my_files'); ?></option>
550 <?php if ($file_storage_groups): ?>
551 <optgroup label="<?php echo _AT('groups'); ?>">
552 <?php foreach ($file_storage_groups as $group): ?>
553 <option value="<?php echo WORKSPACE_GROUP; ?>_<?php echo $group['group_id']; ?>" <?php if ($owner_type == WORKSPACE_GROUP && $owner_id == $group['group_id']) { echo 'selected="selected"'; } ?>><?php echo AT_print($group['title'], 'input.text'); ?></option>
557 <?php if (count($my_assignments) != 0) : ?>
558 <optgroup label="<?php echo _AT('assignments'); ?>">
559 <?php foreach ($my_assignments as $my_assignment): ?>
560 <option value="<?php echo WORKSPACE_ASSIGNMENT; ?>_<?php echo $my_assignment['assignment_id']; ?>_my" <?php if ($owner_type == WORKSPACE_ASSIGNMENT && $owner_id == $my_assignment['assignment_id']) { echo 'selected="selected"'; } ?>><?php echo AT_print($my_assignment['title'], 'input.text'); ?></option>
564 <?php if (authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN) && count($file_storage_assignments) != 0) : ?>
565 <optgroup label="<?php echo _AT('assignments'); ?>">
566 <?php foreach ($file_storage_assignments as $assignment): ?>
567 <option value="<?php echo WORKSPACE_ASSIGNMENT; ?>_<?php echo $assignment['assignment_id']; ?>" <?php if ($owner_type == WORKSPACE_ASSIGNMENT && $owner_id == $assignment['assignment_id']) { echo 'selected="selected"'; } ?>><?php echo AT_print($assignment['title'], 'input.text'); ?></option>
572 <input type="submit" name="submit_workspace" value="<?php echo _AT('go'); ?>" class="button" />
575 <?php echo _AT('current_path'); ?>
577 if ($owner_type == WORKSPACE_ASSIGNMENT && !authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN))
578 { // student assignment's folder; if it's instrutor who has priviledge to view all students' assignments, folder is 0
579 $folder = $_SESSION['member_id'];
586 echo url_rewrite($_SERVER['PHP_SELF'].$owner_arg_prefix.'folder='.$folder); ?>"><?php echo _AT('home'); ?></a>
587 <?php foreach ($folder_path as $folder_info): ?>
588 <?php if ($folder_info['folder_id'] == $folder_id): ?>
589 » <?php echo AT_print($folder_info['title'], 'input.text'); ?>
590 <?php $parent_folder_id = $folder_info['parent_folder_id']; ?>
592 » <a href="<?php echo url_rewrite($_SERVER['PHP_SELF'].$owner_arg_prefix.'folder='.$folder_info['folder_id']); ?>"><?php echo AT_print($folder_info['title'], 'input.text'); ?></a>
598 <th align="left" width="10"><input type="checkbox" value="<?php echo _AT('select_all'); ?>" id="all" title="<?php echo _AT('select_all'); ?>" name="selectall" onclick="CheckAll();" /></th>
599 <th scope="col"><a href="<?php echo url_rewrite($_SERVER['PHP_SELF'] . $owner_arg_prefix . 'folder='.$folder_id.SEP.$orders[$order].'=file_name'); ?>"><?php echo _AT('file'); ?></a></th>
600 <th scope="col"><?php echo _AT('author'); ?></th>
601 <th scope="col"><?php if ($_config['fs_versioning']): ?><?php echo _AT('revisions'); ?><?php endif; ?></th>
602 <th scope="col"><?php echo _AT('comments'); ?></th>
603 <th scope="col"><a href="<?php echo url_rewrite($_SERVER['PHP_SELF'] . $owner_arg_prefix . 'folder='.$folder_id.SEP.$orders[$order].'=file_size'); ?>"><?php echo _AT('size'); ?></a></th>
604 <th scope="col"><a href="<?php echo url_rewrite($_SERVER['PHP_SELF'] . $owner_arg_prefix . 'folder='.$folder_id.SEP.$orders[$order].'=date'); ?>"><?php echo _AT('date'); ?></a></th>
611 <input type="submit" name="download" value="<?php echo _AT('download'); ?>" class="button"/>
612 <?php if (query_bit($owner_status, WORKSPACE_AUTH_WRITE)): ?>
613 <?php if (($owner_type != WORKSPACE_COURSE) && !(($owner_type == WORKSPACE_PERSONAL) && ($_SESSION['is_admin'] || authenticate(AT_PRIV_GROUPS,true))) ): ?>
614 <input type="submit" name="assignment" value="<?php echo _AT('hand_in'); ?>" class="button"/>
616 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" class="button"/>
617 <input type="submit" name="move" value="<?php echo _AT('move'); ?>" class="button"/>
618 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" class="button"/>
624 <?php if ($folder_id): ?>
626 <td colspan="7"><a href="<?php echo url_rewrite($_SERVER['PHP_SELF'].$owner_arg_prefix.'folder='.intval($folder_path[count($folder_path)-1]['parent_folder_id'])); ?>"><img src="images/arrowicon.gif" border="0" height="" width="" alt="" /> <?php echo _AT('back'); ?></a></td>
629 <?php if ($folders || $files): ?>
630 <?php foreach ($folders as $folder_info): ?>
631 <tr onmousedown="document.form['f<?php echo $folder_info['folder_id']; ?>'].checked = !document.form['f<?php echo $folder_info['folder_id']; ?>'].checked; rowselectbox(this, document.form['f<?php echo $folder_info['folder_id']; ?>'].checked, 'checkbuttons(false)');" id="r_<?php echo $folder_info['folder_id']; ?>_1">
632 <td width="10"><input type="checkbox" name="folders[]" value="<?php echo $folder_info['folder_id']; ?>" id="f<?php echo $folder_info['folder_id']; ?>" onmouseup="this.checked=!this.checked" /></td>
633 <td><img src="images/folder.gif" height="18" width="20" alt="" /> <label for="f<?php echo $folder_info['folder_id']; ?>"><a href="<?php echo url_rewrite($_SERVER['PHP_SELF'].$owner_arg_prefix.'folder='.
634 $folder_info['folder_id']); ?>"><?php echo AT_print($folder_info['title'], 'input.text'); ?></a></label></td>
642 <?php foreach ($files as $file_info): ?>
643 <tr onmousedown="document.form['r<?php echo $file_info['file_id']; ?>'].checked = !document.form['r<?php echo $file_info['file_id']; ?>'].checked; rowselectbox(this, document.form['r<?php echo $file_info['file_id']; ?>'].checked, 'checkbuttons(false)');" id="r_<?php echo $file_info['file_id']; ?>_0">
644 <td valign="top" width="10"><input type="checkbox" name="files[]" value="<?php echo $file_info['file_id']; ?>" id="r<?php echo $file_info['file_id']; ?>" onmouseup="this.checked=!this.checked" /></td>
646 <img src="images/file_types/<?php echo fs_get_file_type_icon($file_info['file_name']); ?>.gif" height="16" width="16" alt="" title="" /> <label for="r<?php echo $file_info['file_id']; ?>" onmousedown="document.form['r<?php echo $file_info['file_id']; ?>'].checked = !document.form['r<?php echo $file_info['file_id']; ?>'].checked; rowselectbox(this, document.form['r<?php echo $file_info['file_id']; ?>'].checked, 'checkbuttons(false)');"><?php echo htmlspecialchars($file_info['file_name']); ?></label>
647 <?php if ($file_info['description']): ?>
648 <p class="fm-desc"><?php echo htmlspecialchars($file_info['description']); ?></p>
651 <td valign="top"><?php echo get_display_name($file_info['member_id']); ?></td>
653 <?php if ($_config['fs_versioning']): ?>
654 <?php if ($file_info['num_revisions']):
655 if ($file_info['num_revisions'] == 1) {
656 $lang_var = 'fs_revision';
658 $lang_var = 'fs_revisions';
662 <a href="<?php echo url_rewrite('mods/_standard/file_storage/revisions.php'.$owner_arg_prefix.'id='.$file_info['file_id']); ?>"><?php echo _AT($lang_var, $file_info['num_revisions']); ?></a>
670 if ($file_info['num_comments'] == 1) {
671 $lang_var = 'fs_comment';
673 $lang_var = 'fs_comments';
676 <a href="<?php echo url_rewrite('mods/_standard/file_storage/comments.php'.$owner_arg_prefix.'id='.$file_info['file_id']); ?>"><?php echo _AT($lang_var, $file_info['num_comments']); ?></a></td>
677 <td align="right" valign="top"><?php echo get_human_size($file_info['file_size']); ?></td>
678 <td align="right" valign="top"><?php echo AT_date(_AT('filemanager_date_format'), $file_info['date'], AT_DATE_MYSQL_DATETIME); ?></td>
683 <td colspan="7"><?php echo _AT('none_found'); ?></td>
690 <script type="text/javascript">
692 function checkbuttons(state) {
693 document.form.selectall.checked = state;
695 var num_files_checked = 0;
696 var num_folders_checked = 0;
697 for (var i=0;i<document.form.elements.length;i++) {
698 var e = document.form.elements[i];
699 if ((e.name == 'folders[]') && (e.type=='checkbox') && e.checked) {
700 num_folders_checked++;
701 } else if ((e.name == 'files[]') && (e.type=='checkbox') && e.checked) {
705 if (num_files_checked + num_folders_checked > 1) {
706 if (document.form.edit)
707 document.form.edit.disabled = true;
709 if (document.form.edit)
710 document.form.edit.disabled = false;
713 function CheckAll() {
714 var state = document.form.selectall.checked;
715 for (var i=0;i<document.form.elements.length;i++) {
716 var e = document.form.elements[i];
717 if ((e.name == 'folders[]') && (e.type=='checkbox')) {
719 rowselectbox(document.getElementById('r_' + e.value + '_1'), state, 'checkbuttons(' + state + ')');
720 } else if ((e.name == 'files[]') && (e.type=='checkbox')) {
722 rowselectbox(document.getElementById('r_' + e.value + '_0'), state, 'checkbuttons(' + state + ')');
727 function hideform(id) {
728 document.getElementById(id).style.display='none';
731 function toggleform(id) {
732 if (document.getElementById(id).style.display == "none") {
734 document.getElementById(id).style.display='';
736 if (id == "c_folder") {
737 document.form0.new_folder_name.focus();
738 } else if (id == "upload") {
739 document.form0.file.focus();
744 document.getElementById(id).style.display='none';
751 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>