/**
 * returns the localised name of the specified workspace
 */
function fs_get_workspace($owner_type, $owner_id) {
	if ($owner_type == WORKSPACE_PERSONAL) {
		return _AT('my_files');

	} else if ($owner_type == WORKSPACE_COURSE) {
		return _AT('course_files');

	} else if ($owner_type == WORKSPACE_GROUP) {
		global $db;
		$sql = "SELECT title FROM ".TABLE_PREFIX."groups WHERE group_id=$owner_id";
		$result = mysql_query($sql, $db);
		$row    = mysql_fetch_assoc($result);
		return $row['title'];

	} else if ($owner_type == WORKSPACE_ASSIGNMENT) {
		$row    = fs_get_assignment($owner_id);
		return ($row ? $row['title'] : false);
	} /*
		else if ($owner_type == WORKSPACE_SYSTEM) {
		return _AT('system_files');
     }
	*/
}
Beispiel #2
0
$owner_type = abs($_REQUEST['ot']);
$owner_id   = abs($_REQUEST['oid']);
$owner_arg_prefix = '?ot='.$owner_type.SEP.'oid='.$owner_id. SEP;
if (!($owner_status = fs_authenticate($owner_type, $owner_id)) || !query_bit($owner_status, WORKSPACE_AUTH_WRITE)) { 
	$msg->addError('ACCESS_DENIED');
	header('Location: '.url_rewrite('mods/_standard/file_storage/index.php', AT_PRETTY_URL_IS_HEADER));
	exit;
}

if (isset($_POST['cancel'])) {
	$msg->addFeedback('CANCELLED');
	header('Location: '.url_rewrite('mods/_standard/file_storage/index.php'.$owner_arg_prefix.'folder='.abs($_POST['folder']), AT_PRETTY_URL_IS_HEADER));
	exit;
} else if (isset($_POST['submit'])) {
	$_POST['assignment'] = abs($_POST['assignment']);
	$assignment_row    = fs_get_assignment($_POST['assignment']);

	if (!$assignment_row) {
		$msg->addError('ACCESS_DENIED');
		header('Location: '.url_rewrite('mods/_standard/file_storage/index.php', AT_PRETTY_URL_IS_HEADER));
		exit;
	}

	if (!$assignment_row['assign_to']) {
		if (!$_SESSION['enroll']) {
			$msg->addError('ACCESS_DENIED');
			header('Location: '.url_rewrite('mods/_standard/file_storage/index.php', AT_PRETTY_URL_IS_HEADER));
			exit;
		}

	} else {
/**
 * returns the localised name of the specified workspace
 */
function fs_get_workspace($owner_type, $owner_id)
{
    if ($owner_type == WORKSPACE_PERSONAL) {
        return _AT('my_files');
    } else {
        if ($owner_type == WORKSPACE_COURSE) {
            return _AT('course_files');
        } else {
            if ($owner_type == WORKSPACE_GROUP) {
                $sql = "SELECT title FROM %sgroups WHERE group_id=%d";
                $row = queryDB($sql, array(TABLE_PREFIX, $owner_id), TRUE);
                return $row['title'];
            } else {
                if ($owner_type == WORKSPACE_ASSIGNMENT) {
                    $row = fs_get_assignment($owner_id);
                    return $row ? $row['title'] : false;
                }
            }
        }
    }
}