Commit b7b9c8d4 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Move group files to a separate page

parent f0a03781
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-file
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('MENUITEM', 'groups/mygroups');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'file');
define('SECTION_PAGE', 'groupfiles');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('groupfiles', 'artefact.file'));
safe_require('artefact', 'file');
$javascript = ArtefactTypeFileBase::get_my_files_js(param_integer('folder', null));
$groupid = param_integer('group');
$group = get_record_sql('
SELECT g.id, g.name, g.grouptype, m.role AS userrole
FROM {group} g INNER JOIN {group_member} m ON g.id = m.group
WHERE g.id = ' . $groupid . ' AND m.member = ' . $USER->get('id'));
if (!$group) {
throw new AccessDeniedException();
}
require_once(get_config('docroot') . 'interaction/lib.php');
require_once(get_config('docroot') . 'lib/grouptype/' . $group->grouptype . '.php');
$groupdata = json_encode($group);
$grouproles = json_encode(call_static_method('GroupType' . $group->grouptype, 'get_roles'));
$javascript .= <<<GROUPJS
var group = {$groupdata};
group.roles = {$grouproles};
browser.setgroup({$groupid});
uploader.setgroup({$groupid});
GROUPJS;
$smarty = smarty(
array('tablerenderer', 'artefact/file/js/file.js'),
array(),
array(),
array(
'sideblocks' => array(
interaction_sideblock($groupid),
),
)
);
$smarty->assign('heading', get_string('filesfor', 'artefact.file', $group->name));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->display('artefact:file:index.tpl');
?>
......@@ -34,95 +34,23 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('myfiles', 'artefact.file'));
safe_require('artefact', 'file');
$folder_id = param_integer('folder', null);
if ($folder_id) {
$folder_list = array();
$current_folder = artefact_instance_from_id($folder_id);
if ($USER->can_view_artefact($current_folder)) {
if ($current_folder->get('artefacttype') == 'folder') {
$folder_list[] = array(
'id' => $current_folder->get('id'),
'name' => $current_folder->get('title'),
);
}
while ($p = $current_folder->get('parent')) {
$current_folder = artefact_instance_from_id($p);
$folder_list[] = array(
'id' => $current_folder->get('id'),
'name' => $current_folder->get('title'),
);
}
}
$enc_folders = json_encode(array_reverse($folder_list));
}
else {
$enc_folders = json_encode(array());
}
$copyright = get_field('site_content', 'content', 'name', 'uploadcopyright');
$javascript = <<<JAVASCRIPT
var copyrightnotice = '{$copyright}';
var browser = new FileBrowser('filelist', 'myfiles.json.php', null, null, null, null, {$enc_folders});
var uploader = new FileUploader('uploader', 'upload.php', {}, null, null,
browser.refresh, browser.fileexists);
browser.changedircallback = uploader.updatedestination;
JAVASCRIPT;
$groupid = param_integer('group', null);
if ($groupid and
$group = get_record_sql('
SELECT g.id, g.name, g.grouptype, m.role AS userrole
FROM {group} g INNER JOIN {group_member} m ON g.id = m.group
WHERE g.id = ' . $groupid . ' AND m.member = ' . $USER->get('id'))) {
require_once(get_config('docroot') . 'interaction/lib.php');
require_once(get_config('docroot') . 'lib/grouptype/' . $group->grouptype . '.php');
$groupdata = json_encode($group);
$grouproles = json_encode(call_static_method('GroupType' . $group->grouptype, 'get_roles'));
$javascript .= <<<GROUPJS
var group = {$groupdata};
group.roles = {$grouproles};
browser.setgroup({$groupid});
uploader.setgroup({$groupid});
GROUPJS;
$smarty = smarty(
array('tablerenderer', 'artefact/file/js/file.js'),
array(),
array(),
array(
'sideblocks' => array(
interaction_sideblock($groupid),
),
)
);
$smarty->assign('heading', get_string('filesfor', 'artefact.file', $group->name));
}
else {
$smarty = smarty(
array('tablerenderer', 'artefact/file/js/file.js'),
array(),
array(),
array(
'sideblocks' => array(
array(
'name' => 'quota',
'weight' => -10,
'data' => array(),
),
$javascript = ArtefactTypeFileBase::get_my_files_js(param_integer('folder', null));
$smarty = smarty(
array('tablerenderer', 'artefact/file/js/file.js'),
array(),
array(),
array(
'sideblocks' => array(
array(
'name' => 'quota',
'weight' => -10,
'data' => array(),
),
)
);
$smarty->assign('heading', get_string('myfiles', 'artefact.file'));
}
),
)
);
$smarty->assign('heading', get_string('myfiles', 'artefact.file'));
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->display('artefact:file:index.tpl');
......
......@@ -65,6 +65,7 @@ $string['filetypes'] = 'Configure Uploadable File Types';
$string['filetypedescription'] = '<p>You may configure the allowed file types that users can upload here. This grants you more control over what can be uploaded. This checking is performed in addition to virus checking, if you have virus checking turned on.</p><p>Note that &quot;Unknown Application&quot; may be necessary for some movies and archive files (such as gzip) to work.<p>';
$string['folder'] = 'Folder';
$string['foldercreated'] = 'Folder created';
$string['groupfiles'] = 'Group Files';
$string['home'] = 'Home';
$string['htmlremovedmessage'] = 'You are viewing <strong>%s</strong> by <a href="%s">%s</a>. The file displayed below has been filtered to remove malicious content, and is only a rough representation of the original.';
$string['htmlremovedmessagenoowner'] = 'You are viewing <strong>%s</strong>. The file displayed below has been filtered to remove malicious content, and is only a rough representation of the original.';
......
<h3>Group Files</h3>
<p>The group files area is a repository for shared folders and files to use within your group's views.</p>
<p>You can use drag and drop to organise group files and folders.</p>
<p>For security reasons your Site Administrator may restrict some file types from being uploaded to the system. </p>
......@@ -519,6 +519,55 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
usort($filedata, array("ArtefactTypeFileBase", "my_files_cmp"));
return $filedata;
}
public static function get_my_files_js($folder_id=null) {
global $USER;
if ($folder_id) {
$folder_list = array();
$current_folder = artefact_instance_from_id($folder_id);
if ($USER->can_view_artefact($current_folder)) {
if ($current_folder->get('artefacttype') == 'folder') {
$folder_list[] = array(
'id' => $current_folder->get('id'),
'name' => $current_folder->get('title'),
);
}
while ($p = $current_folder->get('parent')) {
$current_folder = artefact_instance_from_id($p);
$folder_list[] = array(
'id' => $current_folder->get('id'),
'name' => $current_folder->get('title'),
);
}
}
$enc_folders = json_encode(array_reverse($folder_list));
}
else {
$enc_folders = json_encode(array());
}
$copyright = get_field('site_content', 'content', 'name', 'uploadcopyright');
$javascript = <<<JAVASCRIPT
var copyrightnotice = '{$copyright}';
var browser = new FileBrowser('filelist', 'myfiles.json.php', null, null, null, null, {$enc_folders});
var uploader = new FileUploader('uploader', 'upload.php', {}, null, null, browser.refresh, browser.fileexists);
browser.changedircallback = uploader.updatedestination;
JAVASCRIPT;
return $javascript;
}
}
class ArtefactTypeFile extends ArtefactTypeFileBase {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment