2006-08-15 08:42:06 +00:00
|
|
|
<?php // $Id$
|
|
|
|
/* Preset Menu
|
2006-12-08 19:36:00 +00:00
|
|
|
*
|
2006-08-15 08:42:06 +00:00
|
|
|
* This is the page that is the menu item in the config database
|
|
|
|
* pages.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('../../config.php');
|
|
|
|
require_once('lib.php');
|
|
|
|
require_once($CFG->libdir.'/uploadlib.php');
|
|
|
|
require_once($CFG->libdir.'/xmlize.php');
|
|
|
|
|
2006-12-08 19:36:00 +00:00
|
|
|
$id = optional_param('id', 0, PARAM_INT); // course module id
|
|
|
|
$d = optional_param('d', 0, PARAM_INT); // database activity id
|
|
|
|
$action = optional_param('action', 'base', PARAM_ALPHANUM); // current action
|
|
|
|
$fullname = optional_param('fullname', '', PARAM_PATH); // directory the preset is in
|
2008-04-16 03:24:28 +00:00
|
|
|
$file = optional_param('file', '', PARAM_PATH); // uploaded file
|
2006-12-08 19:36:00 +00:00
|
|
|
|
|
|
|
// find out preset owner userid and shortname
|
|
|
|
$parts = explode('/', $fullname);
|
|
|
|
$userid = empty($parts[0]) ? 0 : (int)$parts[0];
|
|
|
|
$shortname = empty($parts[1]) ? '' : $parts[1];
|
|
|
|
unset($parts);
|
|
|
|
unset($fullname);
|
2006-08-15 08:42:06 +00:00
|
|
|
|
|
|
|
if ($id) {
|
2006-12-06 20:17:58 +00:00
|
|
|
if (! $cm = get_coursemodule_from_id('data', $id)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidcoursemodule');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
2008-06-06 07:36:17 +00:00
|
|
|
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('coursemisconf');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
2008-06-06 07:36:17 +00:00
|
|
|
if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidid', 'data');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
|
|
|
} else if ($d) {
|
2008-06-06 07:36:17 +00:00
|
|
|
if (! $data = $DB->get_record('data', array('id'=>$d))) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidid', 'data');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
2008-06-06 07:36:17 +00:00
|
|
|
if (! $course = $DB->get_record('course', array('id'=>$data->course))) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('coursemisconf');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidcoursemodule');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('missingparameter');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 10:52:59 +00:00
|
|
|
// fill in missing properties needed for updating of instance
|
|
|
|
$data->course = $cm->course;
|
|
|
|
$data->cmidnumber = $cm->idnumber;
|
|
|
|
$data->instance = $cm->instance;
|
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('cannotfindcontext');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 20:17:58 +00:00
|
|
|
require_login($course->id, false, $cm);
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
require_capability('mod/data:managetemplates', $context);
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
if ($userid && ($userid != $USER->id) && !has_capability('mod/data:viewalluserpresets', $context)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('cannotaccesspresentsother', 'data');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
/* Need sesskey security check here for import instruction */
|
|
|
|
$sesskey = sesskey();
|
|
|
|
|
|
|
|
/********************************************************************/
|
|
|
|
/* Output */
|
|
|
|
data_print_header($course, $cm, $data, 'presets');
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
switch ($action) {
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
/***************** Deleting *****************/
|
|
|
|
case 'confirmdelete' :
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!confirm_sesskey()) { // GET request ok here
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidsesskey');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-12-08 19:36:00 +00:00
|
|
|
|
|
|
|
if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) {
|
|
|
|
//ok can delete
|
|
|
|
} else {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-12-08 19:36:00 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$path = data_preset_path($course, $userid, $shortname);
|
|
|
|
|
|
|
|
$strwarning = get_string('deletewarning', 'data').'<br />'.
|
|
|
|
data_preset_name($shortname, $path);
|
|
|
|
|
2006-12-08 19:36:00 +00:00
|
|
|
$options = new object();
|
|
|
|
$options->fullname = $userid.'/'.$shortname;
|
|
|
|
$options->action = 'delete';
|
|
|
|
$options->d = $data->id;
|
|
|
|
$options->sesskey = sesskey();
|
2006-10-02 17:24:54 +00:00
|
|
|
|
2006-12-08 19:36:00 +00:00
|
|
|
$optionsno = new object();
|
2006-10-02 17:24:54 +00:00
|
|
|
$optionsno->d = $data->id;
|
|
|
|
notice_yesno($strwarning, 'preset.php', 'preset.php', $options, $optionsno, 'post', 'get');
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete' :
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() and !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-12-08 19:36:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($userid > 0 and ($userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) {
|
|
|
|
//ok can delete
|
|
|
|
} else {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$presetpath = data_preset_path($course, $userid, $shortname);
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
if (!clean_preset($presetpath)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('cannotdeletepreset', 'data');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
2006-10-02 17:24:54 +00:00
|
|
|
@rmdir($presetpath);
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$strdeleted = get_string('deleted', 'data');
|
2006-12-08 19:36:00 +00:00
|
|
|
notify("$shortname $strdeleted", 'notifysuccess');
|
2006-10-02 17:24:54 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
/***************** Importing *****************/
|
|
|
|
case 'importpreset' :
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() or !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname);
|
|
|
|
$pimporter->import_options();
|
|
|
|
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Imports a zip file. */
|
|
|
|
case 'importzip' :
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() or !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-08-15 08:42:06 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
if (!make_upload_directory('temp/data/'.$USER->id)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('nopermissiontomkdir');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$presetfile = $CFG->dataroot.'/temp/data/'.$USER->id;
|
|
|
|
clean_preset($presetfile);
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
if (!unzip_file($CFG->dataroot."/$course->id/$file", $presetfile, false)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('cannotunzipfile');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$pimporter = new PresetImporter($course, $cm, $data, -$USER->id, $shortname);
|
|
|
|
$pimporter->import_options();
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
break;
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
case 'finishimport':
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() or !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$pimporter = new PresetImporter($course, $cm, $data, $userid, $shortname);
|
|
|
|
$pimporter->import();
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
$strimportsuccess = get_string('importsuccess', 'data');
|
|
|
|
$straddentries = get_string('addentries', 'data');
|
|
|
|
$strtodatabase = get_string('todatabase', 'data');
|
2008-06-06 07:36:17 +00:00
|
|
|
if (!$DB->get_records('data_records', array('dataid'=>$data->id))) {
|
2006-10-02 17:24:54 +00:00
|
|
|
notify("$strimportsuccess <a href='edit.php?d=$data->id'>$straddentries</a> $strtodatabase", 'notifysuccess');
|
|
|
|
} else {
|
|
|
|
notify("$strimportsuccess", 'notifysuccess');
|
|
|
|
}
|
|
|
|
break;
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
/* Exports as a zip file ready for download. */
|
|
|
|
case 'export':
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() or !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-12-08 19:36:00 +00:00
|
|
|
}
|
2008-06-15 15:35:27 +00:00
|
|
|
$exportfile = data_presets_export($course, $cm, $data);
|
|
|
|
$downloadsubdir = "$course->id/moddata/data/$data->id";
|
|
|
|
$filename = clean_filename($data->name . '-preset-' . gmdate("Ymd_Hi") . '.zip');
|
|
|
|
$downloadfile = "$CFG->dataroot/$downloadsubdir/$filename";
|
|
|
|
@unlink($downloadfile);
|
|
|
|
|
|
|
|
// Move the exported zip to the download folder
|
|
|
|
make_upload_directory($downloadsubdir);
|
|
|
|
if (! rename($exportfile, $downloadfile)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('cannotmovezip');
|
2008-06-15 15:35:27 +00:00
|
|
|
}
|
|
|
|
echo '<div style="text-align:center">';
|
|
|
|
echo get_string('exportedtozip', 'data') . '<br />';
|
|
|
|
echo "<a href='$CFG->wwwroot/file.php/$downloadsubdir/$filename'>" . get_string('download', 'data') . '</a>';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '</div>';
|
2006-10-02 17:24:54 +00:00
|
|
|
break;
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
/***************** Exporting *****************/
|
|
|
|
case 'save1':
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() or !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$strcontinue = get_string('continue');
|
|
|
|
$strwarning = get_string('presetinfo', 'data');
|
2006-12-08 19:36:00 +00:00
|
|
|
$strname = get_string('shortname');
|
|
|
|
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<div style="text-align:center">';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<p>'.$strwarning.'</p>';
|
|
|
|
echo '<form action="preset.php" method="post">';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<fieldset class="invisiblefieldset">';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<label for="shorname">'.$strname.'</label> <input type="text" id="shorname" name="name" value="'.$data->name.'" />';
|
|
|
|
echo '<input type="hidden" name="action" value="save2" />';
|
|
|
|
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="'.$sesskey.'" />';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<input type="submit" value="'.$strcontinue.'" /></fieldset></form></div>';
|
2006-10-02 17:24:54 +00:00
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
break;
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
case 'save2':
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() or !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$strcontinue = get_string('continue');
|
2006-12-08 19:36:00 +00:00
|
|
|
$stroverwrite = get_string('overwrite', 'data');
|
|
|
|
$strname = get_string('shortname');
|
2006-10-02 17:24:54 +00:00
|
|
|
|
|
|
|
$name = optional_param('name', $data->name, PARAM_FILE);
|
|
|
|
|
|
|
|
if (is_directory_a_preset("$CFG->dataroot/data/preset/$USER->id/$name")) {
|
|
|
|
notify("Preset already exists: Pick another name or overwrite");
|
|
|
|
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<div style="text-align:center">';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<form action="preset.php" method="post">';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<fieldset class="invisiblefieldset">';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<label for="shorname">'.$strname.'</label> <input type="textbox" name="name" value="'.$name.'" />';
|
|
|
|
echo '<input type="hidden" name="action" value="save2" />';
|
|
|
|
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="'.$sesskey.'" />';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<input type="submit" value="'.$strcontinue.'" /></fieldset></form>';
|
2006-12-08 19:36:00 +00:00
|
|
|
|
|
|
|
echo '<form action="preset.php" method="post">';
|
2007-03-01 06:27:15 +00:00
|
|
|
echo '<div>';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<input type="hidden" name="name" value="'.$name.'" />';
|
|
|
|
echo '<input type="hidden" name="action" value="save3" />';
|
|
|
|
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="'.$sesskey.'" />';
|
2007-03-01 06:27:15 +00:00
|
|
|
echo '<input type="submit" value="'.$stroverwrite.'" /></div></form>';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '</div>';
|
2006-10-02 17:24:54 +00:00
|
|
|
print_footer($course);
|
|
|
|
exit;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'save3':
|
2006-12-08 19:36:00 +00:00
|
|
|
if (!data_submitted() or !confirm_sesskey()) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('invalidrequest');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$name = optional_param('name', $data->name, PARAM_FILE);
|
|
|
|
$presetdirectory = "/data/preset/$USER->id/$name";
|
|
|
|
|
|
|
|
make_upload_directory($presetdirectory);
|
|
|
|
clean_preset($CFG->dataroot.$presetdirectory);
|
|
|
|
|
|
|
|
$file = data_presets_export($course, $cm, $data);
|
|
|
|
if (!unzip_file($file, $CFG->dataroot.$presetdirectory, false)) {
|
2008-05-23 08:12:14 +00:00
|
|
|
print_error('cannotunziptopreset', 'data');
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
notify(get_string('savesuccess', 'data'), 'notifysuccess');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$presets = data_get_available_presets($context);
|
|
|
|
|
2006-12-08 19:36:00 +00:00
|
|
|
$strimport = get_string('import');
|
|
|
|
$strfromfile = get_string('fromfile', 'data');
|
2006-10-02 17:24:54 +00:00
|
|
|
$strchooseorupload = get_string('chooseorupload', 'data');
|
2006-12-08 19:36:00 +00:00
|
|
|
$strusestandard = get_string('usestandard', 'data');
|
|
|
|
$strchoose = get_string('choose');
|
|
|
|
$strexport = get_string('export', 'data');
|
|
|
|
$strexportaszip = get_string('exportaszip', 'data');
|
|
|
|
$strsaveaspreset = get_string('saveaspreset', 'data');
|
|
|
|
$strsave = get_string('save', 'data');
|
|
|
|
$strdelete = get_string('delete');
|
|
|
|
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<div style="text-align:center">';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<table class="presets" cellpadding="5">';
|
|
|
|
echo '<tr><td valign="top" colspan="2" align="center"><h3>'.$strexport.'</h3></td></tr>';
|
|
|
|
|
2006-12-12 23:34:55 +00:00
|
|
|
echo '<tr><td><label>'.$strexportaszip.'</label>';
|
2007-12-18 21:27:45 +00:00
|
|
|
helpbutton('exportzip', '', 'data', true, true);
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '</td><td>';
|
|
|
|
$options = new object();
|
2006-10-02 17:24:54 +00:00
|
|
|
$options->action = 'export';
|
|
|
|
$options->d = $data->id;
|
|
|
|
$options->sesskey = sesskey();
|
2006-12-08 19:36:00 +00:00
|
|
|
print_single_button('preset.php', $options, $strexport, 'post');
|
|
|
|
echo '</td></tr>';
|
2006-10-02 17:24:54 +00:00
|
|
|
|
2006-12-12 23:34:55 +00:00
|
|
|
echo '<tr><td><label>'.$strsaveaspreset.'</label>';
|
2007-12-18 21:27:45 +00:00
|
|
|
helpbutton('savepreset', '', 'data', true, true);
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '</td><td>';
|
|
|
|
$options = new object();
|
2006-10-02 17:24:54 +00:00
|
|
|
$options->action = 'save1';
|
|
|
|
$options->d = $data->id;
|
|
|
|
$options->sesskey = sesskey();
|
2006-12-08 19:36:00 +00:00
|
|
|
print_single_button('preset.php', $options, $strsave, 'post');
|
2006-10-02 17:24:54 +00:00
|
|
|
echo '</td></tr>';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<tr><td valign="top" colspan="2" align="center"><h3>'.$strimport.'</h3></td></tr>';
|
|
|
|
echo '<tr><td><label for="fromfile">'.$strfromfile.'</label>';
|
2007-12-18 21:27:45 +00:00
|
|
|
helpbutton('importfromfile', '', 'data', true, true);
|
2006-10-02 17:24:54 +00:00
|
|
|
echo '</td><td>';
|
2007-01-04 21:32:36 +00:00
|
|
|
echo '<form id="uploadpreset" method="post" action="preset.php">';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<fieldset class="invisiblefieldset">';
|
2006-10-02 17:24:54 +00:00
|
|
|
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
|
|
|
|
echo '<input type="hidden" name="action" value="importzip" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
2007-12-05 06:13:17 +00:00
|
|
|
echo '<input name="file" size="20" value="" id="fromfile" type="text" /><input name="coursefiles" value="'.$strchooseorupload.'" onclick="return openpopup('."'/files/index.php?id={$course->id}&choose=uploadpreset.file', 'coursefiles', 'menubar=0,location=0,scrollbars,resizable,width=750,height=500', 0".');" type="button" />';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<input type="submit" value="'.$strimport.'" />';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '</fieldset></form>';
|
2006-10-02 17:24:54 +00:00
|
|
|
echo '</td></tr>';
|
|
|
|
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<tr valign="top"><td><label>'.$strusestandard.'</label>';
|
2007-12-18 21:27:45 +00:00
|
|
|
helpbutton('usepreset', '', 'data', true, true);
|
2006-10-02 17:24:54 +00:00
|
|
|
echo '</td><td>';
|
|
|
|
|
2007-01-04 21:32:36 +00:00
|
|
|
echo '<form id="presets" method="post" action="preset.php" >';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '<fieldset class="invisiblefieldset">';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
|
|
|
|
echo '<input type="hidden" name="action" value="importpreset" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
|
|
|
|
|
|
|
$i = 0;
|
2006-10-02 17:24:54 +00:00
|
|
|
foreach ($presets as $id => $preset) {
|
2006-12-08 19:36:00 +00:00
|
|
|
$screenshot = '';
|
2006-10-02 17:24:54 +00:00
|
|
|
if (!empty($preset->userid)) {
|
2008-06-06 07:36:17 +00:00
|
|
|
$user = $DB->get_record('user', array('id'=>$preset->userid));
|
2006-12-08 19:36:00 +00:00
|
|
|
$desc = $preset->name.' ('.fullname($user, true).')';
|
|
|
|
} else {
|
|
|
|
$desc = $preset->name;
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-12-08 19:36:00 +00:00
|
|
|
|
|
|
|
if (!empty($preset->screenshot)) {
|
|
|
|
$screenshot = '<img width="150" class="presetscreenshot" src="'.$preset->screenshot.'" alt="'.get_string('screenshot').' '.$desc.'" /> ';
|
2006-10-02 17:24:54 +00:00
|
|
|
}
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-12-08 19:36:00 +00:00
|
|
|
$fullname = $preset->userid.'/'.$preset->shortname;
|
|
|
|
|
|
|
|
$dellink = '';
|
|
|
|
if ($preset->userid > 0 and ($preset->userid == $USER->id || has_capability('mod/data:manageuserpresets', $context))) {
|
|
|
|
$dellink = ' <a href="preset.php?d='.$data->id.'&action=confirmdelete&fullname='.$fullname.'&sesskey='.sesskey().'">'.
|
2007-01-08 09:14:05 +00:00
|
|
|
'<img src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'.$strdelete.' '.$desc.'" /></a>';
|
2006-12-08 19:36:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '<input type="radio" name="fullname" id="usepreset'.$i.'" value="'.$fullname.'" /><label for="usepreset'.$i++.'">'.$desc.'</label>'.$dellink.'<br />';
|
|
|
|
}
|
|
|
|
echo '<br />';
|
|
|
|
echo '<input type="submit" value="'.$strchoose.'" />';
|
2007-01-05 08:01:33 +00:00
|
|
|
echo '</fieldset></form>';
|
2006-10-02 17:24:54 +00:00
|
|
|
echo '</td></tr>';
|
|
|
|
echo '</table>';
|
2006-12-08 19:36:00 +00:00
|
|
|
echo '</div>';
|
2006-08-15 08:42:06 +00:00
|
|
|
|
2006-10-02 17:24:54 +00:00
|
|
|
print_footer($course);
|
|
|
|
|
2006-08-15 08:42:06 +00:00
|
|
|
?>
|