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 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); // for get_human_size()
18 require(AT_INCLUDE_PATH.'../mods/_standard/file_storage/file_storage.inc.php');
20 // check folders and files id
21 if (isset($_GET['folders'])){
22 if (is_array($_GET['folders'])){
23 foreach($_GET['folders'] as $k=>$v){
24 $_GET['folders'][$k] = abs($_GET['folders'][$k]);
27 $_GET['folders']= abs($_GET['folders']);
30 if (isset($_GET['files'])){
31 if (is_array($_GET['files'])){
32 foreach($_GET['files'] as $k=>$v){
33 $_GET['files'][$k] = abs($_GET['files'][$k]);
36 $_GET['files']= abs($_GET['files']);
40 if (isset($_GET['submit_workspace'])) {
41 unset($_GET['folder']);
42 unset($assignment_for);
44 $owner_type = abs($_GET['ot']);
46 if ($owner_type == WORKSPACE_GROUP) {
48 $parts = explode('_', $_GET['ot'], 2);
49 if (isset($parts[1]) && $parts[1] && isset($_SESSION['groups'][$parts[1]])) {
50 $owner_id = $parts[1];
52 $owner_type = WORKSPACE_COURSE;
55 } else if ($owner_type == WORKSPACE_ASSIGNMENT) {
56 $parts = explode('_', $_GET['ot'], 3);
58 if (isset($parts[1]) && $parts[1]) {
59 if ($parts[2] == 'my') {
60 $assignment_for = 'my';
62 $owner_id = $parts[1];
64 $owner_type = WORKSPACE_ASSIGNMENT;
70 $_REQUEST['folder'] = 0;
71 } else if (isset($_REQUEST['ot'], $_REQUEST['oid'])) {
72 $owner_type = abs($_REQUEST['ot']);
73 $owner_id = abs($_REQUEST['oid']);
74 } else if (isset($_SESSION['fs_owner_type'], $_SESSION['fs_owner_id'], $_SESSION['fs_folder_id'])) {
75 $owner_type = abs($_SESSION['fs_owner_type']);
76 $owner_id = abs($_SESSION['fs_owner_id']);
78 $owner_type = WORKSPACE_COURSE;
81 if (isset($_REQUEST['folder'])) {
82 $folder_id = abs($_REQUEST['folder']);
83 } else if (isset($_SESSION['fs_folder_id'])) {
84 $folder_id = abs($_SESSION['fs_folder_id']);
89 // init the owner_id if not currently set
90 if (!isset($owner_id)) {
91 if ($owner_type == WORKSPACE_COURSE) {
92 $owner_id = $_SESSION['course_id'];
93 } else if ($owner_type == WORKSPACE_PERSONAL) {
94 $owner_id = $_SESSION['member_id'];
95 } else if ($owner_type == WORKSPACE_GROUP) {
96 $owner_id = $group_id;
100 $owner_arg_prefix = '?ot='.$owner_type.SEP.'oid='.$owner_id. SEP;
102 if ($assignment_for == 'my') {
103 $owner_arg_prefix .= 'folder='.$_SESSION['member_id'];
105 if (!($owner_status = fs_authenticate($owner_type, $owner_id))) {
106 $msg->addError('ACCESS_DENIED');
107 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php', AT_PRETTY_URL_IS_HEADER));
110 $_SESSION['fs_owner_type'] = $owner_type;
111 $_SESSION['fs_owner_id'] = $owner_id;
112 $_SESSION['fs_folder_id'] = $folder_id;
114 if (isset($_GET['submit_workspace'])) {
115 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix, AT_PRETTY_URL_IS_HEADER));
119 // action - Submit Assignment
120 if (isset($_GET['assignment']) && (isset($_GET['files']) || isset($_GET['folders']))) {
121 if (isset($_GET['folders'])) {
122 $msg->addError('HAND_IN_FOLDER');
123 } else if (!isset($_GET['files'])) {
124 $msg->addError('NO_ITEM_SELECTED');
126 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/assignment.php?'.$_SERVER['QUERY_STRING']);
130 // action - View Revisions
131 else if (isset($_GET['revisions'], $_GET['files'])) {
132 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
133 $file_id = current($_GET['files']);
134 header('Location: '.url_rewrite('mods/_standard/file_storage/revisions.php'.$owner_arg_prefix.'id='.$file_id, AT_PRETTY_URL_IS_HEADER));
138 // action - View Comments
139 else if (isset($_GET['comments'], $_GET['files'])) {
140 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
141 $file_id = current($_GET['files']);
142 header('Location: '.url_rewrite('comments.php'.$owner_arg_prefix.'id='.$file_id, AT_PRETTY_URL_IS_HEADER));
146 // action - Edit File/Folder
147 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_GET['edit']) && (isset($_GET['folders']) || isset($_GET['files']))) {
148 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
149 $file_id = current($_GET['files']);
150 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/edit.php'.$owner_arg_prefix.'id='.$file_id);
152 } else if (is_array($_GET['folders']) && (count($_GET['folders']) == 1) && empty($_GET['files'])) {
153 $folder_id = current($_GET['folders']);
154 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/edit_folder.php'.$owner_arg_prefix.'id='.$folder_id);
158 // action - Move Files/Folders
159 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_GET['move']) && (isset($_GET['folders']) || isset($_GET['files']))) {
160 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/move.php'.$owner_arg_prefix.$_SERVER['QUERY_STRING']);
163 // action - Download Files/Folders
164 else if (isset($_GET['download']) && (isset($_GET['folders']) || isset($_GET['files']))) {
165 if (is_array($_GET['files']) && (count($_GET['files']) == 1) && empty($_GET['folders'])) {
166 $file_id = current($_GET['files']);
167 $sql = "SELECT file_name, file_size FROM ".TABLE_PREFIX."files WHERE file_id=$file_id AND owner_type=$owner_type AND owner_id=$owner_id";
168 $result = mysql_query($sql, $db);
169 if ($row = mysql_fetch_assoc($result)) {
170 $ext = fs_get_file_extension($row['file_name']);
172 if (isset($mime[$ext]) && $mime[$ext][0]) {
173 $file_mime = $mime[$ext][0];
175 $file_mime = 'application/octet-stream';
177 $file_path = fs_get_file_path($file_id) . $file_id;
180 header("Content-Encoding: none");
181 header('Content-Type: ' . $file_mime);
182 header('Content-transfer-encoding: binary');
183 header('Content-Disposition: attachment; filename="'.htmlspecialchars($row['file_name']).'"');
184 header('Expires: 0');
185 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
186 header('Pragma: public');
187 header('Content-Length: '.$row['file_size']);
189 // see the note in get.php about the use of x-Sendfile
190 header('x-Sendfile: '.$file_path);
191 header('x-Sendfile: ', TRUE); // if we get here then it didn't work
193 @readfile($file_path);
197 // zip multiple files and folders
198 require(AT_INCLUDE_PATH . 'classes/zipfile.class.php');
199 $zipfile = new zipfile();
201 $zip_file_name = fs_get_workspace($owner_type, $owner_id); // want the name of the workspace
202 $zip_file_name = str_replace(" ","_",$zip_file_name );
204 if (is_array($_GET['files'])) {
205 foreach ($_GET['files'] as $file_id) {
206 $file_path = fs_get_file_path($file_id) . $file_id;
209 $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";
210 $result = mysql_query($sql, $db);
211 if (($row = mysql_fetch_assoc($result)) && file_exists($file_path)) {
212 $zipfile->add_file(file_get_contents($file_path), $row['file_name'], $row['date']);
216 if (is_array($_GET['folders'])) {
217 foreach($_GET['folders'] as $folder_id) {
218 fs_download_folder($folder_id, $zipfile, $owner_type, $owner_id);
219 $row['title'] = str_replace(" ","_",$row['title'] );
220 $zipfile->create_dir($row['title']);
223 if (count($_GET['folders']) == 1) {
224 // zip just one folder, use that folder's title as the zip file name
225 $row = fs_get_folder_by_id($_GET['folders'][0], $owner_type, $owner_id);
227 $zip_file_name = $row['title'];
228 $zip_file_name = str_replace(" ","_",$zip_file_name );
233 $zipfile->send_file($zip_file_name);
237 // action - Delete Files/Folders (pre-confirmation)
238 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_GET['delete']) && (isset($_GET['folders']) || isset($_GET['files']))) {
239 $hidden_vars = array();
240 $hidden_vars['folder'] = $folder_id;
241 $hidden_vars['ot'] = $owner_type;
242 $hidden_vars['oid'] = $owner_id;
243 if (isset($_GET['files'])) {
244 $file_list_to_print = '';
245 $files = implode(',', $_GET['files']);
246 $hidden_vars['files'] = $files;
247 $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";
248 $result = mysql_query($sql, $db);
249 while ($row = mysql_fetch_assoc($result)) {
250 $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>';
252 $msg->addConfirm(array('FILE_DELETE', $file_list_to_print), $hidden_vars);
255 if (isset($_GET['folders'])) {
256 $dir_list_to_print = '';
257 $folders = implode(',', $_GET['folders']);
258 $hidden_vars['folders'] = $folders;
259 $rows = fs_get_folder_by_id($_GET['folders'], $owner_type, $owner_id);
260 foreach ($rows as $row) {
261 $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>';
263 $msg->addConfirm(array('DIR_DELETE', $dir_list_to_print), $hidden_vars);
266 require(AT_INCLUDE_PATH.'header.inc.php');
267 $msg->printConfirm();
268 require(AT_INCLUDE_PATH.'footer.inc.php');
272 // action - Confirm Delete Files/Folders
273 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['submit_yes'])) {
276 if (isset($_POST['files'])) {
277 $files = explode(',', $_POST['files']);
279 if (isset($_POST['folders'])) {
280 $folders = explode(',', $_POST['folders']);
283 foreach ($files as $file) {
284 fs_delete_file($file, $owner_type, $owner_id);
286 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
289 if (isset($folders)) {
290 foreach ($folders as $folder) {
291 fs_delete_folder($folder, $owner_type, $owner_id);
293 $msg->addFeedback('DIR_DELETED');
296 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.abs($_POST['folder']), AT_PRETTY_URL_IS_HEADER));
299 // action - Cancel Delete
300 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['submit_no'])) {
301 $msg->addFeedback('CANCELLED');
302 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.abs($_POST['folder']), AT_PRETTY_URL_IS_HEADER));
305 // action - Create Folder
306 } else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['create_folder'])) {
307 // create a new folder
308 $_POST['new_folder_name'] = trim($_POST['new_folder_name']);
310 if (!$_POST['new_folder_name']) {
311 $msg->addError(array('EMPTY_FIELDS', _AT('name')));
314 if (!$msg->containsErrors()) {
315 $_POST['new_folder_name'] = $addslashes($_POST['new_folder_name']);
317 $parent_folder_id = abs($_POST['folder']);
319 $sql = "INSERT INTO ".TABLE_PREFIX."folders VALUES (NULL, $parent_folder_id, $owner_type, $owner_id, '$_POST[new_folder_name]')";
320 $result = mysql_query($sql, $db);
321 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
322 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.$parent_folder_id, AT_PRETTY_URL_IS_HEADER));
327 else if (query_bit($owner_status, WORKSPACE_AUTH_WRITE) && isset($_POST['upload'])) {
328 // handle the file upload
329 $_POST['comments'] = trim($_POST['comments']);
331 $parent_folder_id = abs($_POST['folder']);
333 if ($_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE) {
334 $msg->addError(array('FILE_TOO_BIG', get_human_size(megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1)))));
336 } else if (!isset($_FILES['file']['name']) || ($_FILES['file']['error'] == UPLOAD_ERR_NO_FILE) || ($_FILES['file']['size'] == 0)) {
337 $msg->addError('FILE_NOT_SELECTED');
339 } else if ($_FILES['file']['error'] || !is_uploaded_file($_FILES['file']['tmp_name'])) {
340 $msg->addError('FILE_NOT_SAVED');
343 // check that we own this folder
344 if ($parent_folder_id) {
345 $sql = "SELECT folder_id FROM ".TABLE_PREFIX."folders WHERE folder_id=$parent_folder_id AND owner_type=$owner_type AND owner_id=$owner_id";
346 $result = mysql_query($sql, $db);
347 if (!$row = mysql_fetch_assoc($result)) {
348 $msg->addError('ACCESS_DENIED');
349 header('Location: '.AT_BASE_HREF.'mods/_standard/file_storage/index.php');
354 if (!$msg->containsErrors()) {
355 $_POST['description'] = $addslashes(trim($_POST['description']));
356 $_FILES['file']['name'] = addslashes($_FILES['file']['name']);
358 if ($_POST['comments']) {
364 $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]')";
365 $result = mysql_query($sql, $db);
367 if ($result && ($file_id = mysql_insert_id($db))) {
368 $path = fs_get_file_path($file_id);
369 move_uploaded_file($_FILES['file']['tmp_name'], $path . $file_id);
371 // check if this file name already exists
372 $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";
373 $result = mysql_query($sql, $db);
374 if ($row = mysql_fetch_assoc($result)) {
375 if ($_config['fs_versioning']) {
376 $sql = "UPDATE ".TABLE_PREFIX."files SET parent_file_id=$file_id, date=date WHERE file_id=$row[file_id]";
377 $result = mysql_query($sql, $db);
379 $sql = "UPDATE ".TABLE_PREFIX."files SET num_revisions=$row[num_revisions]+1, date=date WHERE file_id=$file_id";
380 $result = mysql_query($sql, $db);
382 fs_delete_file($row['file_id'], $owner_type, $owner_id);
386 $msg->addFeedback('FILE_UPLOADED');
388 $msg->addError('FILE_NOT_SAVED');
391 header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.$parent_folder_id, AT_PRETTY_URL_IS_HEADER));
393 } else if ((isset($_GET['delete']) || isset($_GET['download']) || isset($_GET['move']) || isset($_GET['edit']) || isset($_GET['assignment'])) && !isset($_GET['files']) && !isset($_GET['folders'])) {
394 $msg->addError('NO_ITEM_SELECTED');
397 if (query_bit($owner_status, WORKSPACE_AUTH_WRITE)) {
398 $onload = 'hideform(\'upload\'); hideform(\'c_folder\');';
401 require(AT_INCLUDE_PATH.'header.inc.php');
403 $orders = array('asc' => 'desc', 'desc' => 'asc');
404 $cols = array('file_name' => 1, 'file_size' => 1, 'date' => 1);
406 if (isset($_GET['asc'])) {
408 $col = isset($cols[$_GET['asc']]) ? $_GET['asc'] : 'file_name';
409 } else if (isset($_GET['desc'])) {
411 $col = isset($cols[$_GET['desc']]) ? $_GET['desc'] : 'file_name';
418 $folder_path = fs_get_folder_path($folder_id, $owner_type, $owner_id);
420 $folders = fs_get_folder_by_pid($folder_id, $owner_type, $owner_id);
423 $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";
424 $result = mysql_query($sql, $db);
426 while ($row = mysql_fetch_assoc($result)) {
432 <?php if (query_bit($owner_status, WORKSPACE_AUTH_WRITE)): ?>
433 <form method="post" action="<?php echo 'mods/_standard/file_storage/index.php'.$owner_arg_prefix; ?>" enctype="multipart/form-data" name="form0">
434 <input type="hidden" name="folder" value="<?php echo $folder_id; ?>" />
435 <div style="margin-left:auto; margin-right:auto;width: 95%;">
436 <div class="input-form" style="width: 48%; float: right;" >
438 <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>
442 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="fname"><?php echo _AT('name'); ?></label><br />
443 <input type="text" id="fname" name="new_folder_name" size="20" />
445 <div class="row buttons">
446 <input type="submit" name="create_folder" value="<?php echo _AT('create'); ?>" class="button" />
452 <div class="input-form" style="float: left; width: 48%;">
454 <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>
458 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="file"><?php echo _AT('upload_file'); ?></label><br />
459 <input type="file" name="file" id="file" />
460 <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>
463 <label for="description"><?php echo _AT('description'); ?></label><br />
464 <textarea name="description" id="description" rows="1" cols="20"></textarea>
466 <div class="row buttons">
467 <input type="submit" name="upload" value="<?php echo _AT('upload'); ?>" class="button"/>
478 if ($_SESSION['groups']) {
479 $file_storage_groups = array();
480 $groups_list = implode(',',$_SESSION['groups']);
481 $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";
482 $result = mysql_query($sql, $db);
483 while ($row = mysql_fetch_assoc($result)) {
484 $file_storage_groups[] = $row;
488 if (authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN)) {
489 $file_storage_assignments = array();
490 $sql = "SELECT * FROM ".TABLE_PREFIX."assignments WHERE course_id=$_SESSION[course_id] ORDER BY title";
491 $result = mysql_query($sql, $db);
492 while ($row = mysql_fetch_assoc($result)) {
493 $file_storage_assignments[] = $row;
497 if ($_SESSION['member_id'] && $_SESSION['enroll']){
498 $my_assignments = array();
499 $sql = "SELECT distinct a.title, a.assignment_id FROM ".TABLE_PREFIX."assignments a, ".TABLE_PREFIX."files f
500 WHERE a.course_id = ".$_SESSION[course_id]."
501 AND a.assignment_id = f.owner_id
502 AND f.owner_type= ".WORKSPACE_ASSIGNMENT."
503 AND f.member_id = ".$_SESSION['member_id']."
505 $result = mysql_query($sql, $db);
506 while ($row = mysql_fetch_assoc($result)) {
507 $my_assignments[] = $row;
511 <div style="margin-left:auto;margin-right:auto; clear:both;width:95%;">
512 <form method="get" action="<?php echo url_rewrite('mods/_standard/file_storage/index.php', AT_PRETTY_URL_IS_HEADER);?>" name="form">
513 <input type="hidden" name="folder" value="<?php echo $folder_id; ?>" />
514 <input type="hidden" name="oid" value="<?php echo $owner_id; ?>" />
517 <?php if ($col == 'file_name'): ?>
521 <?php elseif($col == 'file_size'): ?>
525 <?php elseif($col == 'date'): ?>
533 <label for="ot"><?php echo _AT('workspace'); ?> </label>
534 <select name="ot" id="ot">
535 <option value="1" <?php if ($owner_type == WORKSPACE_COURSE) { echo 'selected="selected"'; } ?>><?php echo _AT('course_files'); ?></option>
536 <?php if ($_SESSION['member_id'] && $_SESSION['enroll']): ?>
537 <option value="2" <?php if ($owner_type == WORKSPACE_PERSONAL) { echo 'selected="selected"'; } ?>><?php echo _AT('my_files'); ?></option>
539 <?php if ($file_storage_groups): ?>
540 <optgroup label="<?php echo _AT('groups'); ?>">
541 <?php foreach ($file_storage_groups as $group): ?>
542 <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>
546 <?php if (count($my_assignments) != 0) : ?>
547 <optgroup label="<?php echo _AT('assignments'); ?>">
548 <?php foreach ($my_assignments as $my_assignment): ?>
549 <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>
553 <?php if (authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN) && count($file_storage_assignments) != 0) : ?>
554 <optgroup label="<?php echo _AT('assignments'); ?>">
555 <?php foreach ($file_storage_assignments as $assignment): ?>
556 <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>
561 <input type="submit" name="submit_workspace" value="<?php echo _AT('go'); ?>" class="button" />
564 <?php echo _AT('current_path'); ?>
566 if ($owner_type == WORKSPACE_ASSIGNMENT && !authenticate(AT_PRIV_ASSIGNMENTS, AT_PRIV_RETURN))
567 { // student assignment's folder; if it's instrutor who has priviledge to view all students' assignments, folder is 0
568 $folder = $_SESSION['member_id'];
575 echo url_rewrite($_SERVER['PHP_SELF'].$owner_arg_prefix.'folder='.$folder); ?>"><?php echo _AT('home'); ?></a>
576 <?php foreach ($folder_path as $folder_info): ?>
577 <?php if ($folder_info['folder_id'] == $folder_id): ?>
578 » <?php echo AT_print($folder_info['title'], 'input.text'); ?>
579 <?php $parent_folder_id = $folder_info['parent_folder_id']; ?>
581 » <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>
587 <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>
588 <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>
589 <th scope="col"><?php echo _AT('author'); ?></th>
590 <th scope="col"><?php if ($_config['fs_versioning']): ?><?php echo _AT('revisions'); ?><?php endif; ?></th>
591 <th scope="col"><?php echo _AT('comments'); ?></th>
592 <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>
593 <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>
600 <input type="submit" name="download" value="<?php echo _AT('download'); ?>" class="button"/>
601 <?php if (query_bit($owner_status, WORKSPACE_AUTH_WRITE)): ?>
602 <?php if (($owner_type != WORKSPACE_COURSE) && !(($owner_type == WORKSPACE_PERSONAL) && ($_SESSION['is_admin'] || authenticate(AT_PRIV_GROUPS,true))) ): ?>
603 <input type="submit" name="assignment" value="<?php echo _AT('hand_in'); ?>" class="button"/>
605 <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" class="button"/>
606 <input type="submit" name="move" value="<?php echo _AT('move'); ?>" class="button"/>
607 <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" class="button"/>
613 <?php if ($folder_id): ?>
615 <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>
618 <?php if ($folders || $files): ?>
619 <?php foreach ($folders as $folder_info): ?>
620 <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">
621 <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>
622 <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='.
623 $folder_info['folder_id']); ?>"><?php echo AT_print($folder_info['title'], 'input.text'); ?></a></label></td>
631 <?php foreach ($files as $file_info): ?>
632 <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">
633 <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>
635 <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>
636 <?php if ($file_info['description']): ?>
637 <p class="fm-desc"><?php echo htmlspecialchars($file_info['description']); ?></p>
640 <td valign="top"><?php echo get_display_name($file_info['member_id']); ?></td>
642 <?php if ($_config['fs_versioning']): ?>
643 <?php if ($file_info['num_revisions']):
644 if ($file_info['num_revisions'] == 1) {
645 $lang_var = 'fs_revision';
647 $lang_var = 'fs_revisions';
651 <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>
659 if ($file_info['num_comments'] == 1) {
660 $lang_var = 'fs_comment';
662 $lang_var = 'fs_comments';
665 <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>
666 <td align="right" valign="top"><?php echo get_human_size($file_info['file_size']); ?></td>
667 <td align="right" valign="top"><?php echo AT_date(_AT('filemanager_date_format'), $file_info['date'], AT_DATE_MYSQL_DATETIME); ?></td>
672 <td colspan="7"><?php echo _AT('none_found'); ?></td>
679 <script type="text/javascript">
681 function checkbuttons(state) {
682 document.form.selectall.checked = state;
684 var num_files_checked = 0;
685 var num_folders_checked = 0;
686 for (var i=0;i<document.form.elements.length;i++) {
687 var e = document.form.elements[i];
688 if ((e.name == 'folders[]') && (e.type=='checkbox') && e.checked) {
689 num_folders_checked++;
690 } else if ((e.name == 'files[]') && (e.type=='checkbox') && e.checked) {
694 if (num_files_checked + num_folders_checked > 1) {
695 if (document.form.edit)
696 document.form.edit.disabled = true;
698 if (document.form.edit)
699 document.form.edit.disabled = false;
702 function CheckAll() {
703 var state = document.form.selectall.checked;
704 for (var i=0;i<document.form.elements.length;i++) {
705 var e = document.form.elements[i];
706 if ((e.name == 'folders[]') && (e.type=='checkbox')) {
708 rowselectbox(document.getElementById('r_' + e.value + '_1'), state, 'checkbuttons(' + state + ')');
709 } else if ((e.name == 'files[]') && (e.type=='checkbox')) {
711 rowselectbox(document.getElementById('r_' + e.value + '_0'), state, 'checkbuttons(' + state + ')');
716 function hideform(id) {
717 document.getElementById(id).style.display='none';
720 function toggleform(id) {
721 if (document.getElementById(id).style.display == "none") {
723 document.getElementById(id).style.display='';
725 if (id == "c_folder") {
726 document.form0.new_folder_name.focus();
727 } else if (id == "upload") {
728 document.form0.file.focus();
733 document.getElementById(id).style.display='none';
740 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>