//Return a content encoded to support interactivities linking. Every module
-
+
function data_backup_mods($bf,$preferences) {
global $CFG;
$status = true;
-
+
// iterate
if ($datas = get_records('data','course',$preferences->backup_course,"id")) {
foreach ($datas as $data) {
function data_backup_one_mod($bf,$preferences,$data) {
global $CFG;
-
+
if (is_numeric($data)) { // backwards compatibility
$data = get_record('data','id',$data);
}
$instanceid = $data->id;
-
+
$status = true;
fwrite ($bf,full_tag("APPROVAL",4,false,$data->approval));
fwrite ($bf,full_tag("SCALE",4,false,$data->scale));
fwrite ($bf,full_tag("ASSESSED",4,false,$data->assessed));
-
+
// if we've selected to backup users info, then call any other functions we need
// including backing up individual files
-
+
$status = backup_data_fields($bf,$preferences,$data->id);
-
+
if (backup_userdata_selected($preferences,'data',$data->id)) {
//$status = backup_someuserdata_for_this_instance();
//$status = backup_somefiles_for_this_instance();
// ... etc
- $status = backup_data_records($bf,$preferences,$data->id);
+ $status = backup_data_records($bf,$preferences,$data->id);
if ($status) {
$status = backup_data_files_instance($bf,$preferences,$data->id); //recursive copy
}
}
fwrite ($bf,end_tag("MOD",3,true));
return $status;
-
+
}
fwrite ($bf,full_tag("PARAM8",6,false,$fie_sub->param8));
fwrite ($bf,full_tag("PARAM9",6,false,$fie_sub->param9));
fwrite ($bf,full_tag("PARAM10",6,false,$fie_sub->param10));
-
+
//End submission
$status =fwrite ($bf,end_tag("FIELD",5,true));
}
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/data");
}
}
-
+
return $status;
}
}
return $info;
}
-
+
// otherwise continue as normal
//First the course data
$info[0][0] = get_string("modulenameplural","data");
} else {
$info[0][1] = 0;
}
-
+
//Now, if requested, the user_data
if ($user_data) {
// any other needed stuff
}
require_login($course->id, false, $cm);
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
+
if ($commentid) {
if (! $comment = get_record('data_comments', 'id', $commentid)) {
error('Comment ID is misconfigured');
}
- if ($comment->recordid != $record->id) {
+ if ($comment->recordid != $record->id) {
error('Comment ID is misconfigured');
}
- if (!has_capability('mod/data:managecomments', $context) && $comment->userid != $USER->id) {
+ if (!has_capability('mod/data:managecomments', $context) && $comment->userid != $USER->id) {
error('Comment is not yours to edit!');
}
}
}
redirect('view.php?rid='.$record->id.'&page='.$page, get_string('commentsaved', 'data'));
break;
-
+
case 'edit': //print edit form
print_header();
print_heading(get_string('edit'));
echo '<input type="hidden" name="commentid" value="'.$comment->id.'" />';
echo '<input type="hidden" name="rid" value="'.$record->id.'" />';
echo '<input type="hidden" name="page" value="'.$page.'" />';
-
+
echo '<textarea name="commentcontent">'.s($comment->content).'</textarea>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="mode" value="editcommit" />';
echo '</form></div>';
print_footer();
break;
-
+
case 'editcommit': //update db
if (empty($commentcontent)) {
redirect('view.php?rid='.$record->id.'&page='.$page, get_string('commentempty', 'data'));
}
redirect('view.php?rid='.$record->id.'&page='.$page, get_string('commentsaved', 'data'));
break;
-
+
case 'delete': //deletes single comment from db
if ($confirm and confirm_sesskey() and $comment) {
delete_records('data_comments','id',$comment->id);
print_header();
data_print_comment($data, $comment, $page);
- notice_yesno(get_string('deletecomment','data'),
+ notice_yesno(get_string('deletecomment','data'),
'comment.php?rid='.$record->id.'&commentid='.$comment->id.'&page='.$page.
'&sesskey='.sesskey().'&mode=delete&confirm=1',
'view.php?rid='.$record->id.'&page='.$page);
}
break;
-
+
default: //print all listing, and add comment form
print_header();
data_print_comments($data, $record, $page);
print_footer();
break;
-
+
}
$data_enablerssfeeds = true;
}
-
+
choose_from_menu ($options, "data_enablerssfeeds", $data_enablerssfeeds, "", "", "");
}
?>
</td>
<td>
- <?php
+ <?php
print_string("configenablerssfeeds","data");
if (!isset($CFG->enablerssfeeds) || $CFG->enablerssfeeds == 0) {
print_string("configenablerssfeedsdisabled");
header('Content-type: text/css'); // Correct MIME type
echo $data->csstemplate;
- }
+ }
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
+// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
function data_upgrade($oldversion) {
table_column("data", "", "assessed", "integer", "10");
table_column("data", "", "assesspublic", "integer", "4");
}
-
+
if ($oldversion < 2006022700) {
table_column("data_comments", "", "created", "integer", "10");
table_column("data_comments", "", "modified", "integer", "10");
}
-
+
if ($oldversion < 2006030700) {
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'add', 'data', 'name')");
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'update', 'data', 'name')");
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates saved', 'data', 'name')");
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates def', 'data', 'name')");
}
-
+
if ($oldversion < 2006032700) {
table_column('data', '', 'defaultsort', 'integer', '10', 'unsigned', '0');
table_column('data', '', 'defaultsortdir', 'tinyint', '4', 'unsigned', '0', 'not null', 'defaultsort');
if ($oldversion < 2006032900) {
table_column('data', '', 'csstemplate', 'text', '', '', '', 'not null', 'rsstemplate');
}
-
+
if ($oldversion < 2006050500) { // 2 fields have got no default null values
table_column('data_comments','content','content','text','','','','not null');
table_column('data_fields','description','description','text','','','','not null');
table_column('data_fields','param9','param9','text','','','','not null');
table_column('data_fields','param10','param10','text','','','','not null');
}
-
+
if ($oldversion < 2006052400) {
table_column('data','','rsstitletemplate','text','','','','not null','rsstemplate');
}
if ($oldversion < 2006081700) {
table_column('data', '', 'jstemplate', 'text', '', '', '', 'not null', 'csstemplate');
}
-
+
if ($oldversion < 2006092000) {
// Upgrades for new roles and capabilities support.
require_once($CFG->dirroot.'/mod/data/lib.php');
modify_database('', 'ALTER TABLE prefix_data DROP COLUMN participants;');
modify_database('', 'ALTER TABLE prefix_data DROP COLUMN assesspublic;');
modify_database('', 'ALTER TABLE prefix_data DROP COLUMN ratings;');
-
+
}
if ($oldversion < 2006092302) { // Changing some TEXT fields to NULLable and no default
# -- phpMyAdmin SQL Dump
# -- version 2.6.2
# -- http://www.phpmyadmin.net
-# --
+# --
# -- Host: localhost
# -- Generation Time: Aug 25, 2005 at 03:52 PM
# -- Server version: 3.23.54
# -- PHP Version: 4.2.2
-# --
+# --
# -- --------------------------------------------------------
// THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
//
-// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
+// IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
// LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
function data_upgrade($oldversion) {
table_column("data", "", "approval", "integer", "4", "unsigned", "0", "not null");
table_column("data_records", "", "approved", "integer", "4", "unsigned", "0", "not null");
}
-
+
if ($oldversion < 2006020801) {
table_column("data", "", "scale", "integer");
table_column("data", "", "assessed", "integer");
table_column("data_comments", "", "created", "integer");
table_column("data_comments", "", "modified", "integer");
}
-
+
if ($oldversion < 2006030700) {
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'view', 'data', 'name');");
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'add', 'data', 'name')");
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates saved', 'data', 'name')");
modify_database('', "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('data', 'templates defaults', 'data', 'name')");
}
-
+
if ($oldversion < 2006032700) {
table_column('data', '', 'defaultsort', 'integer', '10', 'unsigned', '0');
table_column('data', '', 'defaultsortdir', 'tinyint', '4', 'unsigned', '0', 'not null', 'defaultsort');
if ($oldversion < 2006032900) {
table_column('data', '', 'csstemplate', 'text', '', '', '', 'not null', 'rsstemplate');
}
-
+
if ($oldversion < 2006050500) { // drop all tables, and create from scratch
execute_sql("DROP TABLE {$CFG->prefix}data", false);
recordid integer NOT NULL default '0',
rating integer NOT NULL default '0'
);");
-
+
}
-
+
if ($oldversion < 2006052400) {
table_column('data','','rsstitletemplate','text','','','','not null','rsstemplate');
}
if ($oldversion < 2006081700) {
table_column('data', '', 'jstemplate', 'text', '', '', '', 'not null', 'csstemplate');
}
-
+
if ($oldversion < 2006092000) {
// Upgrades for new roles and capabilities support.
require_once($CFG->dirroot.'/mod/data/lib.php');
modify_database('', 'ALTER TABLE prefix_data DROP COLUMN participants;');
modify_database('', 'ALTER TABLE prefix_data DROP COLUMN assesspublic;');
modify_database('', 'ALTER TABLE prefix_data DROP COLUMN ratings;');
-
+
}
if ($oldversion < 2006092302) { // Changing some TEXT fields to NULLable and no default
<?php //$Id$
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the data module
//
// Sometimes, changes between versions involve
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
+/// And upgrade begins here. For each one, you'll need one
+/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
error('Course Module ID was incorrect');
}
}
-
+
require_login($course->id, false, $cm);
-
+
if (!isloggedin() or isguest()) {
redirect('view.php?d='.$data->id);
}
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// If it's hidden then it's don't show anything. :)
"$navigation ".format_string($data->name), "", "", true, '', navmenu($course, $cm));
notice(get_string("activityiscurrentlyhidden"));
}
-
+
/// Can't use this if there are no fields
if (has_capability('mod/data:managetemplates', $context)) {
if (!record_exists('data_fields','dataid',$data->id)) { // Brand new database!
if ($cancel) {
redirect('view.php?d='.$data->id);
}
-
+
/// RSS and CSS and JS meta
$meta = '';
$strdata = get_string('modulenameplural','data');
print_header_simple($data->name, '', "<a href='index.php?id=$course->id'>$strdata</a> -> $data->name",
- '', $meta, true, update_module_button($cm->id, $course->id, get_string('modulename', 'data')),
+ '', $meta, true, update_module_button($cm->id, $course->id, get_string('modulename', 'data')),
navmenu($course, $cm), '', '');
print_heading(format_string($data->name));
/// All student edits are marked unapproved by default
$record = get_record('data_records','id',$rid);
-
+
if ($data->approval == 1 || has_capability('mod/data:approve', $context)) {
$record->approved = 1;
} else {
$record->approved = 0;
}
-
+
$record->groupid = $currentgroup;
$record->timemodified = time();
update_record('data_records',$record);
///Empty form checking - you can't submit an empty form!
$emptyform = true; // assume the worst
-
- foreach ($datarecord as $name => $value) {
+
+ foreach ($datarecord as $name => $value) {
if (!in_array($name, $ignorenames)) {
$namearr = explode('_', $name); // Second one is the field id
if (empty($field->field) || ($namearr[1] != $field->field->id)) { // Try to reuse classes
$field = data_get_field_from_id($namearr[1], $data);
}
if ($field->notemptyfield($value, $name)) {
- $emptyform = false;
+ $emptyform = false;
break; // if anything has content, this form is not empty, so stop now!
}
}
- }
+ }
if ($emptyform){ //nothing gets written to database
notify(get_string('emptyaddform','data'));
}
if (!$emptyform && $recordid = data_add_record($data, $currentgroup)) { //add instance to data_record
-
+
/// Insert a whole lot of empty records to make sure we have them
$fields = get_records('data_fields','dataid',$data->id);
foreach ($fields as $field) {
echo '<input name="rid" value="'.$rid.'" type="hidden" />';
echo '<input name="sesskey" value="'.sesskey().'" type="hidden" />';
print_simple_box_start('center','80%');
-
+
if (!$rid){
print_heading(get_string('newentry','data'), '', 2);
}
-
+
/******************************************
* Regular expression replacement section *
******************************************/
if ($data->addtemplate){
$possiblefields = get_records('data_fields','dataid',$data->id,'id');
-
+
///then we generate strings to replace
foreach ($possiblefields as $eachfield){
$field = data_get_field($eachfield, $data);
echo data_generate_default_template($data, 'addtemplate', $rid, true, false);
$newtext = '';
}
-
+
echo $newtext;
echo '<div align="center"><input type="submit" name="saveandview" value="'.get_string('saveandview','data').'" />';
if ($rid) {
print_simple_box_end();
echo '</form>';
-
+
/// Upload records section. Only for teachers and the admin.
-
+
if (has_capability('mod/data:manageentries',$context)) {
if ($import) {
print_simple_box_start('center','80%');
$field = data_get_field($eachfield, $data);
$field->print_after_form();
}
-
+
print_footer($course);
?>
require_once('../../config.php');
require_once('lib.php');
-
+
$id = optional_param('id', 0, PARAM_INT); // course module id
$d = optional_param('d', 0, PARAM_INT); // database id
$fid = optional_param('fid', 0 , PARAM_INT); // update field id
if ($cancel) {
$mode = 'list';
}
-
-
+
+
if ($id) {
if (! $cm = get_coursemodule_from_id('data', $id)) {
error('Course Module ID was incorrect');
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/data:managetemplates', $context);
-
+
/************************************
* Data Processing *
***********************************/
if (confirm_sesskey() and $fieldinput = data_submitted($CFG->wwwroot.'/mod/data/field.php')){
//$fieldinput->name = data_clean_field_name($fieldinput->name);
-
+
/// Only store this new field if it doesn't already exist.
if (($fieldinput->name == '') or data_fieldname_exists($fieldinput->name, $data->id)) {
$displaynoticebad = get_string('invalidfieldname','data');
- } else {
-
+ } else {
+
/// Check for arrays and convert to a comma-delimited string
data_convert_arrays_to_strings($fieldinput);
/// Update some templates
data_append_new_field_to_templates($data, $field->field->name);
- add_to_log($course->id, 'data', 'fields add',
+ add_to_log($course->id, 'data', 'fields add',
"field.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id);
-
+
$displaynoticegood = get_string('fieldadded','data');
}
}
//$fieldinput->name = data_clean_field_name($fieldinput->name);
if (($fieldinput->name == '') or data_fieldname_exists($fieldinput->name, $data->id, $fieldinput->fid)) {
-
+
$displaynoticebad = get_string('invalidfieldname','data');
} else {
/// Create a field object to collect and store the data safely
$field = data_get_field_from_id($fid, $data);
$oldfieldname = $field->field->name;
-
+
$field->field->name = $fieldinput->name;
$field->field->description = $fieldinput->description;
-
+
for ($i=1; $i<=10; $i++) {
if (isset($fieldinput->{'param'.$i})) {
$field->field->{'param'.$i} = $fieldinput->{'param'.$i};
$field->field->{'param'.$i} = '';
}
}
-
+
$field->update_field();
-
+
/// Update the templates.
data_replace_field_in_templates($data, $oldfieldname, $field->field->name);
-
- add_to_log($course->id, 'data', 'fields update',
+
+ add_to_log($course->id, 'data', 'fields update',
"field.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id);
-
+
$displaynoticegood = get_string('fieldupdated','data');
}
}
error('There was an error updating the database');
}
}
-
- add_to_log($course->id, 'data', 'fields delete',
+
+ add_to_log($course->id, 'data', 'fields delete',
"field.php?d=$data->id", $field->field->name, $cm->id);
-
+
$displaynoticegood = get_string('fielddeleted', 'data');
}
// Print confirmation message.
$field = data_get_field_from_id($fid, $data);
- notice_yesno('<strong>'.$field->name().': '.$field->field->name.'</strong><br /><br />'. get_string('confirmdeletefield','data'),
+ notice_yesno('<strong>'.$field->name().': '.$field->field->name.'</strong><br /><br />'. get_string('confirmdeletefield','data'),
'field.php?d='.$data->id.'&mode=delete&fid='.$fid.'&sesskey='.sesskey().'&confirm=1',
'field.php?d='.$data->id);
/// Print the browsing interface
-
+
///get the list of possible fields (plugins)
$directories = get_list_of_plugins('mod/data/field/');
$menufield = array();
$menufield[$directory] = get_string($directory,'data'); //get from language files
}
asort($menufield); //sort in alphabetical order
-
+
if (($mode == 'new') && (!empty($newtype)) && confirm_sesskey()) { /// Adding a new field
$CFG->pagepath='mod/data/field/'.$newtype;
$CFG->pagepath='mod/data/field/'.$newtype;
data_print_header($course,$cm,$data,'fields');
-
-
+
+
if (!record_exists('data_fields','dataid',$data->id)) {
notify(get_string('nofieldindatabase','data')); // nothing in database
notify(get_string('pleaseaddsome','data', 'preset.php?id='.$cm->id)); // link to presets
if ($fff = get_records('data_fields','dataid',$data->id,'id')){
foreach ($fff as $ff) {
-
+
$field = data_get_field($ff, $data);
$table->data[] = array(
' '.
'<a href="field.php?d='.$data->id.'&mode=delete&fid='.$field->field->id.'&sesskey='.sesskey().'">'.
'<img src="'.$CFG->pixpath.'/t/delete.gif" height="11" width="11" border="0" alt="'.get_string('delete').'" title="'.get_string('delete').'" /></a>'
-
+
);
}
}
print_table($table);
- }
-
+ }
+
echo '<div class="fieldadd" align="center">';
echo get_string('newfield','data').': ';
}
echo '</select>';
echo ' ';
-
+
$options = array(0 => get_string('ascending', 'data'),
1 => get_string('descending', 'data'));
choose_from_menu($options, 'defaultsortdir', $data->defaultsortdir, '');
echo '<input type="submit" value="'.get_string('go').'" />';
-
+
echo '</form>';
echo '</div>';
}
class data_field_checkbox extends data_field_base {
var $type = 'checkbox';
-
+
function data_field_checkbox($field=0, $data=0) {
parent::data_field_base($field, $data);
}
-
+
function display_add_field($recordid=0) {
global $CFG;
-
+
$content = array();
if ($recordid) {
$str = '<div title="'.s($this->field->description).'">';
$str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
-
+
$i = 0;
foreach (explode("\n", $this->field->param1) as $checkbox) {
$checkbox = trim($checkbox);
}
$str .= '<input type="checkbox" id="field_'.$this->field->id.'_'.$i.'" name="field_' . $this->field->id . '[]" ';
$str .= 'value="' . s($checkbox) . '" ';
-
+
if (array_search($checkbox, $content) !== false) {
$str .= 'checked />';
} else {
$str .= '<label for="field_'.$this->field->id.'_'.$i.'">'.$checkbox.'</label><br />';
$i++;
}
- $str .= '</fieldset>';
+ $str .= '</fieldset>';
$str .= '</div>';
return $str;
}
$content->fieldid = $this->field->id;
$content->recordid = $recordid;
$content->content = $this->format_data_field_checkbox_content($value);
-
+
if ($oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
$content->id = $oldcontent->id;
return update_record('data_content', $content);
return insert_record('data_content', $content);
}
}
-
+
function display_browse_field($recordid, $template) {
-
+
if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
$contentArr = array();
if (!empty($content->content)) {
}
$str = '<div title="'.s($this->field->description).'">';
- $str .= print_date_selector('field_'.$this->field->id.'_day', 'field_'.$this->field->id.'_month',
+ $str .= print_date_selector('field_'.$this->field->id.'_day', 'field_'.$this->field->id.'_month',
'field_'.$this->field->id.'_year', $content, true);
$str .= '</div>';
$content->fieldid = $this->field->id;
$content->recordid = $recordid;
$content->content = make_timestamp($this->year, $this->month, $this->day, 12, 0, 0, 0, false);
-
+
if ($oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
$content->id = $oldcontent->id;
return update_record('data_content', $content);
///////////////////////////////////////////////////////////////////////////
class data_field_file extends data_field_base {
-
+
var $type = 'file';
function data_field_file($field=0, $data=0) {
}
$str = '<div title="' . s($this->field->description) . '">';
- $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
+ $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
$str .= '<input type="hidden" name ="field_'.$this->field->id.'_file" value="fakevalue" />';
$str .= get_string('file','data'). ' <input type="file" name ="field_'.$this->field->id.'" id="field_'.
$this->field->id.'" title="'.s($this->field->description).'" /><br />';
$str .= get_string('optionalfilename','data').' <input type="text" name="field_' .$this->field->id.'_filename"
id="field_'.$this->field->id.'_filename" value="'.s($displayname).'" /><br />';
$str .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.s($this->field->param3).'" />';
- $str .= '</fieldset>';
+ $str .= '</fieldset>';
$str .= '</div>';
if ($recordid and isset($content)){ // Print icon
if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
$contents[0] = $content->content;
$contents[1] = $content->content1;
-
+
$src = empty($contents[0])? '':$contents[0];
$name = empty($contents[1])? $src:$contents[1];
} else {
$source = $CFG->wwwroot.'/file.php?file=/'.$path;
}
-
+
$width = $this->field->param1 ? ' width = "'.s($this->field->param1).'" ':' ';
$height = $this->field->param2 ? ' height = "'.s($this->field->param2).'" ':' ';
-
+
require_once($CFG->libdir.'/filelib.php');
$icon = mimeinfo('icon', $src);
$str = '<img src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" /> '.
}
return false;
}
-
+
}
?>
-<?php
+<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
class data_field_latlong extends data_field_base {
var $type = 'latlong';
-
+
// This is an array of URL schemes for linking out to services, using the float values of lat and long.
// In each scheme, the special markers @lat@ and @long@ will be replaced by the float values.
// The config options for the field store each service name that should be displayed, in a comma-separated
}
$str = '<div title="'.s($this->field->description).'">';
- $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
+ $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
$str .= '<table><tr><td align="right">';
$str .= '<label for="field_'.$this->field->id.'_0">' . get_string('latitude', 'data') . '</label></td><td><input type="text" name="field_'.$this->field->id.'_0" id="field_'.$this->field->id.'_0" value="'.s($lat).'" size="10" />°N</td></tr>';
$str .= '<tr><td align="right"><label for="field_'.$this->field->id.'_1">' . get_string('longitude', 'data') . '</label></td><td><input type="text" name="field_'.$this->field->id.'_1" id="field_'.$this->field->id.'_1" value="'.s($long).'" size="10" />°E</td></tr>';
$str .= '</table>';
- $str .= '</fieldset>';
+ $str .= '</fieldset>';
$str .= '</div>';
-
+
return $str;
}
if (empty($lat) or empty($long)) {
return '';
}
-
+
if($lat < 0) {
$compasslat = "" . sprintf('%01.4f', 0 - $lat) . '°S';
} else {
} else {
$compasslong = "" . sprintf('%01.4f', $long) . "°E";
}
-
+
$str = '<form style="display:inline;">';
$str.= "$compasslat, $compasslong";
-
-
+
+
// Now let's create the jump-to-services link
$servicesshown = explode(',', $this->field->param1);
."'>$servicesshown[0]</a> ";
} elseif (sizeof($servicesshown)>1) {
$str .= "\n<select name='jumpto'>";
-
+
foreach($servicesshown as $servicename){
// Add a link to a service
$str .= "\n <option value='"
// which allows the "Go" button to refer to the drop-down selector.
$str .= "\n</select><input type='button' value='" . get_string('go') . "' onclick='if(previousSibling.value){self.location=previousSibling.value}'/>";
}
-
+
$str.= '</form>';
-
+
return $str;
}
return false;
default:
break;
}
-
+
if ($oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
$content->id = $oldcontent->id;
return update_record('data_content', $content);
switch ($CFG->dbtype) {
case 'mysql': // string in an arithmetic operation is converted to a floating-point number
- return '('.$fieldname.'+0.0)';
+ return '('.$fieldname.'+0.0)';
default:
- return 'CAST('.$fieldname.' AS REAL)';
+ return 'CAST('.$fieldname.' AS REAL)';
}
}
}
} else { // List all items in turn
$contents = get_records('data_content', 'fieldid', $fieldid);
-
+
echo '<Document>';
foreach($contents as $content) {
function data_latlong_kml_get_item_name($content, $field) {
// $field->param2 contains the user-specified labelling method
-
+
$name = '';
-
+
if($field->param2 > 0) {
$name = htmlspecialchars(get_field('data_content', 'content', 'fieldid', $field->param2, 'recordid', $content->recordid));
}elseif($field->param2 == -2) {
if($name=='') { // Done this way so that "item #" is the default that catches any problems
$name = get_string('entry', 'data') . " #$content->recordid";
}
-
-
+
+
return $name;
}
}
}
- $str .= choose_from_menu($options, 'field_'.$this->field->id, $content,
+ $str .= choose_from_menu($options, 'field_'.$this->field->id, $content,
get_string('menuchoose', 'data'), '', '', true, false, 0, 'field_'.$this->field->id);
$str .= '</div>';
class data_field_multimenu extends data_field_base {
var $type = 'multimenu';
-
+
function data_field_multimenu($field=0, $data=0) {
parent::data_field_base($field, $data);
}
-
-
+
+
function display_add_field($recordid=0) {
if ($recordid){
$str = '<div title="'.s($this->field->description).'">';
$str .= '<select name="field_' . $this->field->id . '[]" id="field_' . $this->field->id . '" multiple="multiple">';
-
+
foreach (explode("\n",$this->field->param1) as $option) {
$option = trim($option);
$str .= '<option value="' . s($option) . '"';
}
$str .= '</select>';
$str .= '</div>';
-
+
return $str;
}
return insert_record('data_content', $content);
}
}
-
+
function format_data_field_multimenu_content($content) {
if (!is_array($content)) {
$str = $content;
$str = clean_param($str, PARAM_NOTAGS);
return $str;
}
-
-
+
+
function display_browse_field($recordid, $template) {
if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
$content->fieldid = $this->field->id;
$content->recordid = $recordid;
$content->content = (float)$value;
-
+
if ($oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
$content->id = $oldcontent->id;
return update_record('data_content', $content);
switch ($CFG->dbtype) {
case 'mysql': // string in an arithmetic operation is converted to a floating-point number
- return '('.$fieldname.'+0.0)';
+ return '('.$fieldname.'+0.0)';
default:
- return 'CAST('.$fieldname.' AS REAL)';
+ return 'CAST('.$fieldname.' AS REAL)';
}
}
require_once($CFG->dirroot.'/mod/data/field/file/field.class.php'); // Base class is 'file'
-class data_field_picture extends data_field_file {
+class data_field_picture extends data_field_file {
var $type = 'picture';
}
$str = '<div title="'.s($this->field->description).'">';
- $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
+ $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
$str .= '<input type="hidden" name ="field_'.$this->field->id.'_file" id="field_'.$this->field->id.'_file" value="fakevalue" />';
$str .= '<label for="field_'.$this->field->id.'">'.get_string('picture','data'). '</label> <input type="file" name ="field_'.$this->field->id.'" id="field_'.$this->field->id.'" /><br />';
$str .= '<label for="field_'.$this->field->id.'_filename">'.get_string('alttext','data') .'</label> <input type="text" name="field_'
if ($filepath){
$str .= '<img width="'.s($this->previewwidth).'" height="'.s($this->previewheight).'" src="'.$filepath.'" alt="" />';
}
- $str .= '</fieldset>';
+ $str .= '</fieldset>';
$str .= '</div>';
return $str;
}
function display_browse_field($recordid, $template) {
global $CFG;
-
+
if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
if (isset($content->content)){
$contents[0] = $content->content;
if ($oldfield && ($oldfield->param4 != $this->field->param4 || $oldfield->param5 != $this->field->param5)) {
// Check through all existing records and update the thumbnail
- if ($contents = get_records('data_content', 'fieldid', $this->field->id)) {
+ if ($contents = get_records('data_content', 'fieldid', $this->field->id)) {
if (count($contents) > 20) {
notify(get_string('resizingimages', 'data'), 'notifysuccess');
echo "\n\n"; // To make sure that ob_flush() has the desired effect
}
switch ($image->type) {
- case 1:
+ case 1:
if (function_exists('ImageCreateFromGIF')) {
- $im = ImageCreateFromGIF($originalfile);
+ $im = ImageCreateFromGIF($originalfile);
} else {
return;
}
break;
- case 2:
+ case 2:
if (function_exists('ImageCreateFromJPEG')) {
- $im = ImageCreateFromJPEG($originalfile);
+ $im = ImageCreateFromJPEG($originalfile);
} else {
return;
}
break;
case 3:
if (function_exists('ImageCreateFromPNG')) {
- $im = ImageCreateFromPNG($originalfile);
+ $im = ImageCreateFromPNG($originalfile);
} else {
return;
}
// fix for MDL-7270
$thumbwidth = isset($this->field->param4)?$this->field->param4:'';
$thumbheight = isset($this->field->param5)?$this->field->param5:'';
-
+
if ($thumbwidth || $thumbheight) { // Only if either width OR height specified do we want a thumbnail
-
+
$wcrop = $image->width;
$hcrop = $image->height;
-
+
if ($thumbwidth && !$thumbheight) {
$thumbheight = $image->height * $thumbwidth / $image->width;
} else if($thumbheight && !$thumbwidth) {
$hcrop = intval($thumbheight * $wratio);
}
}
-
+
// At this point both $thumbwidth and $thumbheight are set, and $wcrop and $hcrop
if (function_exists('ImageCreateTrueColor') and $CFG->gdversion >= 2) {
$im1 = ImageCreateTrueColor($thumbwidth,$thumbheight);
}
$cx = $image->width / 2;
$cy = $image->height / 2;
-
+
// These "half" measurements use the "crop" values rather than the actual dimensions
$halfwidth = floor($wcrop * 0.5);
$halfheight = floor($hcrop * 0.5);
-
- ImageCopyBicubic($im1, $im, 0, 0, $cx-$halfwidth, $cy-$halfheight,
+
+ ImageCopyBicubic($im1, $im, 0, 0, $cx-$halfwidth, $cy-$halfheight,
$thumbwidth, $thumbheight, $halfwidth*2, $halfheight*2);
-
+
if (function_exists('ImageJpeg')) {
@touch($thumbnaillocation); // Helps in Safe mode
if (ImageJpeg($im1, $thumbnaillocation, 90)) {
@chmod($thumbnaillocation, 0666);
}
}
-
+
} else { // Try and remove the thumbnail - we don't want thumbnailing active
@unlink($thumbnaillocation);
}
class data_field_radiobutton extends data_field_base {
var $type = 'radiobutton';
-
+
function data_field_radiobutton($field=0, $data=0) {
parent::data_field_base($field, $data);
}
-
-
+
+
function display_add_field($recordid=0) {
global $CFG;
$str = '<div title="'.s($this->field->description).'">';
$str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
-
+
$i = 0;
foreach (explode("\n",$this->field->param1) as $radio) {
$radio = trim($radio);
$str .= '<label for="field_'.$this->field->id.'_'.$i.'">'.$radio.'</label><br />';
$i++;
}
- $str .= '</fieldset>';
+ $str .= '</fieldset>';
$str .= '</div>';
return $str;
}
class data_field_textarea extends data_field_base {
var $type = 'textarea';
-
+
function data_field_textarea($field=0, $data=0) {
parent::data_field_base($field, $data);
}
-
-
+
+
function display_add_field($recordid=0) {
global $CFG;
}
$str = '<div title="'.$this->field->description.'">';
-
+
if (can_use_richtext_editor()) {
// Show a rich text html editor.
$str .= $this->gen_textarea(true, $text);
// Get the available text formats for this field.
$formatsForField = format_text_menu();
$str .= '<br />';
-
- $str .= choose_from_menu($formatsForField, 'field_' . $this->field->id .
+
+ $str .= choose_from_menu($formatsForField, 'field_' . $this->field->id .
'_content1', $format, 'choose', '', '', true);
$str .= helpbutton('textformat', get_string('helpformatting'), 'moodle', true, false, '', true);
$str .= '</div>';
return $str;
}
-
-
+
+
function gen_textarea($usehtmleditor, $text='') {
- return print_textarea($usehtmleditor, $this->field->param3, $this->field->param2,
+ return print_textarea($usehtmleditor, $this->field->param3, $this->field->param2,
'', '', 'field_'.$this->field->id, $text, '', true, 'field_' . $this->field->id);
}
-
-
+
+
function print_after_form() {
if (can_use_richtext_editor()) {
use_html_editor('field_' . $this->field->id, '', 'field_' . $this->field->id);
}
}
-
-
+
+
function update_content($recordid, $value, $name='') {
$content = new object;
$content->fieldid = $this->field->id;
$str .= '<input type="text" name="field_'.$this->field->id.'_0" id="field_'.$this->field->id.'_0" value="'.s($url).'" size="60" />';
}
$str .= '</div>';
-
+
return $str;
}
if (!empty($this->field->param2)) { // param2 forces the text to something
$text = $this->field->param2;
}
-
+
if ($this->field->param1) { // param1 defines whether we want to autolink the url.
if (!empty($text)) {
$str = '<a href="'.$url.'">'.$text.'</a>';
default:
break;
}
-
+
if ($oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
$content->id = $oldcontent->id;
return update_record('data_content', $content);
return insert_record('data_content', $content);
}
}
-
+
function notemptyfield($value, $name){
$names = explode('_',$name);
$value = clean_param($value, PARAM_URL); //clean first
if (empty($courseid)) {
return $text;
}
-
+
// Create a list of all the resources to search for. It may be cached already.
if (empty($contentlist)) {
// We look for text field contents only, and only if the field has
'AND dr.id = dc.recordid ' .
"AND df.type = 'text' " .
'AND df.param1 = 1';
-
+
if (!$datacontents = get_records_sql($sql)) {
return $text;
}
-
+
$contentlist = array();
-
+
foreach ($datacontents as $datacontent) {
$currentcontent = trim($datacontent->content);
$strippedcontent = strip_tags($currentcontent);
-
+
if (!empty($strippedcontent)) {
$contentlist[] = new filterobject(
$currentcontent,
$rid = optional_param('rid', 0, PARAM_INT); // record id
$fielddelimiter = optional_param('fielddelimiter', ',', PARAM_CLEANHTML); // characters used as field delimiters for csv file import
$fieldenclosure = optional_param('fieldenclosure', '', PARAM_CLEANHTML); // characters used as record delimiters for csv file import
-
+
if ($id) {
if (! $cm = get_coursemodule_from_id('data', $id)) {
error('Course Module ID was incorrect');
error('Course Module ID was incorrect');
}
}
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/data:uploadentries', $context);
-
+
if (has_capability('mod/data:managetemplates', $context)) {
if (!count_records('data_fields','dataid',$data->id)) { // Brand new database!
redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry
error (get_string('noaccess','data'));
}
}
-
+
/// Print the page header
$strdata = get_string('modulenameplural','data');
/// Print the tabs
$currenttab = 'add';
include('tabs.php');
-
-
+
+
$um = new upload_manager('recordsfile', false, false, null, false, 0);
-
+
if ($um->preprocess_files() && confirm_sesskey()) {
$filename = $um->files['recordsfile']['tmp_name'];
-
+
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
if (function_exists('apache_child_terminate')) {
@apache_child_terminate();
}
-
+
//Fix mac/dos newlines
$text = my_file_get_contents($filename);
$text = preg_replace('!\r\n?!',"\n",$text);
$fp = fopen($filename, "w");
fwrite($fp, $text);
fclose($fp);
-
+
$recordsadded = 0;
-
+
if (!$records = data_get_records_csv($filename, $fielddelimiter, $fieldenclosure)) {
error('get_records_csv failed to read data from the uploaded file. Please check file for field name typos and formatting errors.');
} else {
//$db->debug = true;
$fieldnames = array_shift($records);
-
+
foreach ($records as $record) {
if ($recordid = data_add_record($data, 0)) { // add instance to data_record
$fields = get_records('data_fields', 'dataid', $data->id, '', 'name, id, type');
-
+
// do a manual round of inserting, to make sure even empty contents get stored
foreach ($fields as $field) {
$content->recordid = $recordid;
// Perform a simple field count check for each record.
function data_get_records_csv($filename, $fielddelimiter=',', $fieldenclosure="\n") {
global $db;
-
+
if (empty($fielddelimiter)) {
$fielddelimiter = ',';
}
if (empty($fieldenclosure)) {
$fieldenclosure = "\n";
}
-
+
if (!$fp = fopen($filename, "r")) {
error('get_records_csv failed to open '.$filename);
}
$rows = array();
$fieldnames = fgetcsv($fp, 4096, $fielddelimiter, $fieldenclosure);
-
+
if (empty($fieldnames)) {
fclose($fp);
return false;
}
$rows[] = $fieldnames;
-
+
while (($data = fgetcsv($fp, 4096, $fielddelimiter, $fieldenclosure)) !== false) {
if (count($data) > count($fieldnames)) {
// For any given record, we can't have more data entities than the number of fields.
}
$rows[] = $data;
}
-
+
fclose($fp);
return $rows;
}
$strdata = get_string('modulename','data');
print_header_simple($strdata, '', $strdata, '', '', true, "", navmenu($course));
-
+
if (! $datas = get_all_instances_in_course("data", $course)) {
notice("There are no databases", "$CFG->wwwroot/course/view.php?id=$course->id");
}
} else {
$numunapprovedrecords = '-';
}
-
+
$rsslink = '';
if ($rss && $data->rssarticles > 0) {
$rsslink = rss_get_link($course->id, $USER->id, 'data', $data->id, 'RSS');
$currentsection = $data->section;
}
$row = array ($printsection, $link, $data->intro, $numrecords, $numunapprovedrecords);
-
+
} else {
$row = array ($link, $data->intro, $numrecords, $numunapprovedrecords);
}
echo "<br />";
print_table($table);
print_footer($course);
-
+
?>
header('Content-type: text/css'); // Correct MIME type
echo $data->jstemplate;
- }
+ }
}
if ($update) {
- $newdata = new object();
+ $newdata = new object();
$newdata->id = $data->id;
$newdata->{$template} = $str;
if (!update_record('data', $newdata)) {
class data_mod_form extends moodleform_mod {
- function definition() {
+ function definition() {
- global $CFG;
- $mform =& $this->_form;
- $renderer =& $mform->defaultRenderer();
+ global $CFG;
+ $mform =& $this->_form;
+ $renderer =& $mform->defaultRenderer();
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'));
- $mform->setType('name', PARAM_TEXT);
- $mform->addRule('name', null, 'required', null, 'client');
+ $mform->setType('name', PARAM_TEXT);
+ $mform->addRule('name', null, 'required', null, 'client');
- $mform->addElement('htmleditor', 'intro', get_string('intro', 'data'));
- $mform->setType('intro', PARAM_RAW);
- $mform->addRule('intro', null, 'required', null, 'client');
+ $mform->addElement('htmleditor', 'intro', get_string('intro', 'data'));
+ $mform->setType('intro', PARAM_RAW);
+ $mform->addRule('intro', null, 'required', null, 'client');
$mform->addElement('date_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'), array('optional'=>true));
(array_combine(range(1, DATA_MAX_ENTRIES),//keys
range(1, DATA_MAX_ENTRIES)));//values
$mform->addElement('select', 'requiredentries', get_string('requiredentries', 'data'), $countoptions);
- $mform->setHelpButton('requiredentries', array('requiredentries', get_string('requiredentries', 'data'), 'data'));
+ $mform->setHelpButton('requiredentries', array('requiredentries', get_string('requiredentries', 'data'), 'data'));
$mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
- $mform->setHelpButton('requiredentriestoview', array('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data'));
+ $mform->setHelpButton('requiredentriestoview', array('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data'));
$mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
- $mform->setHelpButton('maxentries', array('maxentries', get_string('maxentries', 'data'), 'data'));
+ $mform->setHelpButton('maxentries', array('maxentries', get_string('maxentries', 'data'), 'data'));
$ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
$mform->addElement('select', 'comments', get_string('comments', 'data'), $ynoptions);
- $mform->setHelpButton('comments', array('comments', get_string('allowcomments', 'data'), 'data'));
+ $mform->setHelpButton('comments', array('comments', get_string('allowcomments', 'data'), 'data'));
$mform->addElement('select', 'approval', get_string('requireapproval', 'data'), $ynoptions);
- $mform->setHelpButton('approval', array('requireapproval', get_string('requireapproval', 'data'), 'data'));
+ $mform->setHelpButton('approval', array('requireapproval', get_string('requireapproval', 'data'), 'data'));
$mform->addElement('select', 'numberrssarticles', get_string('numberrssarticles', 'data') , $countoptions);
$buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert'));
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
- $renderer->addStopFieldsetElements('buttonar');
- }
+ $renderer->addStopFieldsetElements('buttonar');
+ }
}
$buttons = ' ';
}
print_header($title, $this->courserecord->fullname, $crumbtext, '', $meta, true, $buttons, navmenu($this->courserecord, $this->modulerecord));
-
+
}
function get_type() {
for (i=0; i < imageDivs.length; i++) {
currentHeight = imageDivs[i].offsetHeight;
currentWidth = imageDivs[i].offsetWidth;
-
+
if (currentHeight > maxListHeight) {
ratio = maxListHeight / currentHeight;
imageDivs[i].style.width = (currentWidth*ratio) + 'px';
if (imageDiv) {
currentHeight = imageDiv.offsetHeight;
currentWidth = imageDiv.offsetWidth;
-
+
if (currentHeight > maxHeight) {
ratio = maxHeight / currentHeight;
imageDiv.style.width = (currentWidth*ratio) + 'px';
imageDiv.style.height = (currentHeight*ratio) + 'px';
-
+
}
}
}
if (isset($info['MOD']['#']['ASSESSPUBLIC']['0']['#'])) {
$database->assesspublic = backup_todb($info['MOD']['#']['ASSESSPUBLIC']['0']['#']);
}
-
+
$newid = insert_record ('data', $database);
//Do some output
if (!defined('RESTORE_SILENTLY')) {
echo "<li>".get_string("modulename","data")." \"".format_string(stripslashes($database->name),true)."\"</li>";
}
-
+
if ($newid) {
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,
// Moodle 1.5
$restore_userdata_selected = $restore->mods['data']->userinfo;
}
-
+
//Restore data_fields first!!! need to hold an array of [oldid]=>newid due to double dependencies
$status = $status and data_fields_restore_mods ($mod->id, $newid, $info, $restore);
-
+
if ($restore_userdata_selected) {
$status = $status and data_records_restore_mods ($mod->id, $newid, $info, $restore);
}
// It means the backup was made pre Moodle 1.7. We check the
// backup_version to make sure.
if (isset($database->participants) && isset($database->assesspublic)) {
-
+
if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
notice('Default teacher role was not found. Roles and permissions '.
'for your database modules will have to be manually set.');
data_convert_to_roles($database, $teacherroles, $studentroles,
$restore->mods['data']->instances[$mod->id]->restored_as_course_module);
}
-
+
} else {
$status = false;
}
} else {
$status = false;
}
-
+
return $status;
}
function data_fields_restore_mods ($old_data_id, $new_data_id, $info, $restore) {
global $CFG, $fieldids;
-
-
+
+
$fields = $info['MOD']['#']['FIELDS']['0']['#']['FIELD'];
for ($i = 0; $i < sizeof($fields); $i++) {
-
+
$fie_info = $fields[$i];
$oldid = backup_todb($fie_info['#']['ID']['0']['#']);
-
+
$field -> dataid = $new_data_id;
$field -> type = backup_todb($fie_info['#']['TYPE']['0']['#']);
$field -> name = backup_todb($fie_info['#']['NAME']['0']['#']);
$field -> param8 = backup_todb($fie_info['#']['PARAM8']['0']['#']);
$field -> param9 = backup_todb($fie_info['#']['PARAM9']['0']['#']);
$field -> param10 = backup_todb($fie_info['#']['PARAM10']['0']['#']);
-
+
$newid = insert_record ("data_fields",$field);
-
+
$fieldids[$oldid] = $newid; //so we can use them in sub tables that depends on both fieldid and recordid
//Do some output
}
backup_flush(300);
}
-
+
if ($newid) {
//We have the newid, update backup_ids
$status = backup_putid($restore->backup_unique_code,"data_fields",$oldid, $newid);
} else {
$status = false;
}
-
+
}
return $status;
if ($user) {
$record->userid = $user->new_id;
}
-
+
$newid = insert_record ("data_records",$record);
//Do some output
//in CFG->dataroot
$dest_dir = $CFG->dataroot."/".$restore->course_id;
$status = check_dir_exists($dest_dir,true);
-
+
//Now, locate course's moddata directory
$moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
$this_record_path = $this_field_path = $this_field_path."/".$new_record_id;
$status = check_dir_exists($this_record_path,true);
//And now, copy temp_path to user_data_path
-
+
$status = @backup_copy_file($temp_path, $this_record_path);
}
// Iterate over all data.
if ($datas = get_records('data')) {
foreach ($datas as $data) {
-
+
if ($data->rssarticles > 0) {
// Get the first field in the list (a hack for now until we have a selector)
"FROM {$CFG->prefix}data_records dr " .
"WHERE dr.dataid = {$data->id} " .$approved.
'ORDER BY dr.timecreated DESC';
-
+
if (!$records = get_records_sql($sql, 0, $data->rssarticles)) {
continue;
}
continue;
}
}
-
+
// Now create all the articles
mtrace('Creating feed for '.$data->name);
array_push($recordarray, $record);
$item = null;
-
+
// guess title or not
if ($data->rsstitletemplate) {
$item->title = data_print_template('rsstitletemplate', $recordarray, $data, '', 0, true);
$item->description = data_print_template('rsstemplate', $recordarray, $data, '', 0, true);
$item->pubdate = $record->timecreated;
$item->link = $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$record->id;
-
+
array_push($items, $item);
}
$course = get_record('course', 'id', $data->course);
-
+
// First all rss feeds common headers.
$header = rss_standard_header($course->shortname.': '.format_string($data->name,true),
$CFG->wwwroot."/mod/data/view.php?d=".$data->id,
format_string($data->intro,true));
-
+
if (!empty($header)) {
$articles = rss_add_items($items);
}
-
+
// Now all rss feeds common footers.
if (!empty($header) && !empty($articles)) {
$footer = rss_standard_footer();
// Now, if everything is ok, concatenate it.
if (!empty($header) && !empty($articles) && !empty($footer)) {
$rss = $header.$articles.$footer;
-
+
//Save the XML contents to file.
$status = rss_save_file('data', $data, $rss);
}
if (empty($currenttab) or empty($data) or empty($course)) {
error('You cannot call this script in that way');
}
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$inactive = NULL;
$row = array();
-
+
$row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'), '', true);
if (isset($record)) {
} else {
$defaultemplate = 'singletemplate';
}
-
- $row[] = new tabobject('templates', $CFG->wwwroot.'/mod/data/templates.php?d='.$data->id.'&mode='.$defaultemplate,
+
+ $row[] = new tabobject('templates', $CFG->wwwroot.'/mod/data/templates.php?d='.$data->id.'&mode='.$defaultemplate,
get_string('templates','data'));
- $row[] = new tabobject('fields', $CFG->wwwroot.'/mod/data/field.php?d='.$data->id,
+ $row[] = new tabobject('fields', $CFG->wwwroot.'/mod/data/field.php?d='.$data->id,
get_string('fields','data'), '', true);
- $row[] = new tabobject('presets', $CFG->wwwroot.'/mod/data/preset.php?d='.$data->id,
+ $row[] = new tabobject('presets', $CFG->wwwroot.'/mod/data/preset.php?d='.$data->id,
get_string('presets', 'data'), '', true);
}
}
}
$tabs[] = $row;
}
-
+
/// Print out the tabs and continue!
print_tabs($tabs, $currenttab, $inactive);
-
+
?>
require_once('../../config.php');
require_once('lib.php');
require_once($CFG->libdir.'/blocklib.php');
-
+
require_login();
$id = optional_param('id', 0, PARAM_INT); // course module id
/// Print the page header
$strdata = get_string('modulenameplural','data');
-
+
// For the javascript for inserting template tags: initialise the default textarea to
// 'edit_template' - it is always present in all different possible views.
$editorobj = 'editor_'.md5('template');
-
+
$bodytag = 'onload="';
$bodytag .= 'if (typeof('.$editorobj.') != \'undefined\') { currEditor = '.$editorobj.'; } ';
$bodytag .= 'currTextarea = document.tempform.template;';
$bodytag .= '" ';
-
+
print_header_simple($data->name, '', "<a href='index.php?id=$course->id'>$strdata</a> -> $data->name",
- '', '', true, update_module_button($cm->id, $course->id, get_string('modulename', 'data')),
+ '', '', true, update_module_button($cm->id, $course->id, get_string('modulename', 'data')),
navmenu($course, $cm), '', $bodytag);
-
+
print_heading(format_string($data->name));
/// Groups needed for Add entry tab
/// Print the tabs.
$currenttab = 'templates';
- include('tabs.php');
+ include('tabs.php');
/// Processing submitted data, i.e updating form.
$resettemplate = false;
/// html editor is by default disabled
- $editor = isset($SESSION->data_use_editor) ? $SESSION->data_use_editor : (can_use_html_editor() ? 1 : 0);
+ $editor = isset($SESSION->data_use_editor) ? $SESSION->data_use_editor : (can_use_html_editor() ? 1 : 0);
if (($mytemplate = data_submitted($CFG->wwwroot.'/mod/data/templates.php')) && confirm_sesskey()) {
$newtemplate->id = $data->id;
$newtemplate->{$mode} = $mytemplate->template;
-
+
if (!empty($mytemplate->switcheditor)) {
$editor = $editor ? 0 : 1;
$SESSION->data_use_editor = $editor;
}
/// If everything is empty then generate some defaults
- if (empty($data->addtemplate) and empty($data->singletemplate) and
+ if (empty($data->addtemplate) and empty($data->singletemplate) and
empty($data->listtemplate) and empty($data->rsstemplate)) {
data_generate_default_template($data, 'singletemplate');
data_generate_default_template($data, 'listtemplate');
echo '</td>';
echo '</tr>';
}
-
+
// Print the main template.
echo '<tr><td valign="top">';
echo '<label for="availabletags">'.get_string('availabletags','data').'</label>';
helpbutton('tags', get_string('tags','data'), 'data');
echo '<br />';
-
+
echo '<select name="fields1[]" id="availabletags" size="10" ';
-
+
// Javascript to insert the field tags into the textarea.
echo 'onclick="';
echo 'if (typeof(currEditor) != \'undefined\' && currEditor._editMode == \'wysiwyg\') {';
echo 'insertAtCursor(currTextarea, this.options[selectedIndex].value);'; // For inserting when in HTMLArea code view or for normal textareas.
echo '}';
echo '">';
-
+
$fields = get_records('data_fields', 'dataid', $data->id);
echo '<optgroup label="'.get_string('fields', 'data').'">';
foreach ($fields as $field) {
}
echo '</optgroup>';
}
-
+
// Print special tags. fix for MDL-7031
if ($mode != 'addtemplate') {
echo '<optgroup label="'.get_string('buttons', 'data').'">';
echo '<br /><br /><br /><br /><input type="submit" name="defaultform" value="'.get_string('resettemplate','data').'" />';
}
echo '</td>';
-
+
echo '<td>';
if ($mode == 'listtemplate'){
- echo '<div align="center"><label for="edit-template">'.get_string('multientry','data').'</label></div>';
+ echo '<div align="center"><label for="edit-template">'.get_string('multientry','data').'</label></div>';
} else {
echo '<div align="center"><label for="edit-template">'.get_string($mode,'data').'</label></div>';
}
print_textarea($usehtmleditor, 20, 72, 0, 0, 'template', $data->{$mode});
echo '</td>';
echo '</tr>';
-
+
if ($mode == 'listtemplate'){
echo '<tr>';
echo '<td> </td>';
echo '<tr><td align="center" colspan="2">';
echo '<input type="submit" value="'.get_string('savetemplate','data').'" /> ';
-
+
echo '</td></tr></table>';
-
-
+
+
print_simple_box_end();
echo '</form>';
if ($usehtmleditor) {
- use_html_editor('template');
+ use_html_editor('template');
if ($mode == 'listtemplate'){
use_html_editor('listtemplateheader');
use_html_editor('listtemplatefooter');
require_once("$CFG->libdir/rsslib.php");
require_once('pagelib.php');
-
+
/// One of these is necessary!
$id = optional_param('id', 0, PARAM_INT); // course module id
/// These can be added to perform an action on a record
$approve = optional_param('approve', 0, PARAM_INT); //approval recordid
$delete = optional_param('delete', 0, PARAM_INT); //delete recordid
-
+
if ($id) {
if (! $cm = get_coursemodule_from_id('data', $id)) {
error('Course Module ID was incorrect');
}
require_course_login($course, true, $cm);
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/data:viewentry', $context);
$meta .= '<script type="text/javascript" src="'.$CFG->wwwroot.'/mod/data/js.php?d='.$data->id.'"></script>';
}
-
+
/// Print the page header
$PAGE->print_header($course->shortname.': %fullname%', '', $meta);
-
+
/// If we have blocks, then print the left side here
if (!empty($CFG->showblocksonmodpages)) {
}
print_heading(format_string($data->name));
-
+
// Do we need to show a link to the RSS feed for the records?
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
echo '<div style="float:right;">';
echo '</div>';
echo '<div style="clear:both;"></div>';
}
-
+
if ($data->intro and empty($page) and empty($record) and $mode != 'single') {
print_simple_box(format_text($data->intro), 'center', '70%', '', 5, 'generalbox', 'intro');
}
/// Check to see if groups are being used here
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
- $currentgroup = setup_and_print_groups($course, $groupmode,
+ $currentgroup = setup_and_print_groups($course, $groupmode,
'view.php?d='.$data->id.'&search='.s($search).'&sort='.s($sort).
'&order='.s($order).'&');
} else {
} else { // Print a confirmation page
if ($deleterecord = get_record('data_records', 'id', $delete)) { // Need to check this is valid
if ($deleterecord->dataid == $data->id) { // Must be from this database
- notice_yesno(get_string('confirmdeleterecord','data'),
+ notice_yesno(get_string('confirmdeleterecord','data'),
'view.php?d='.$data->id.'&delete='.$delete.'&confirm=1&sesskey='.sesskey(),
'view.php?d='.$data->id);
} else {
$currenttab = 'list';
}
- include('tabs.php');
+ include('tabs.php');
/// Approve any requested records
$what = ' DISTINCT r.id, r.approved, r.userid, u.firstname, u.lastname, c.'.$sortcontent.' ';
$count = ' COUNT(DISTINCT c.recordid) ';
$tables = $CFG->prefix.'data_content c,'.$CFG->prefix.'data_records r,'.$CFG->prefix.'data_content c1, '.$CFG->prefix.'user u ';
- $where = 'WHERE c.recordid = r.id
- AND c.fieldid = '.$sort.'
- AND r.dataid = '.$data->id.'
- AND r.userid = u.id
+ $where = 'WHERE c.recordid = r.id
+ AND c.fieldid = '.$sort.'
+ AND r.dataid = '.$data->id.'
+ AND r.userid = u.id
AND c1.recordid = r.id ';
$sortorder = ' ORDER BY '.$sortcontentfull.' '.$order.' , r.id ASC ';
if ($search) {
$searchselect = ' ';
}
- } else if ($search) {
+ } else if ($search) {
$what = ' DISTINCT r.id, r.approved, r.userid, u.firstname, u.lastname ';
$count = ' COUNT(DISTINCT c.recordid) ';
$tables = $CFG->prefix.'data_content c,'.$CFG->prefix.'data_records r, '.$CFG->prefix.'user u ';
- $where = 'WHERE c.recordid = r.id
- AND r.userid = u.id
+ $where = 'WHERE c.recordid = r.id
+ AND r.userid = u.id
AND r.dataid = '.$data->id;
$sortorder = ' ORDER BY r.id ASC ';
$searchselect = " AND (c.content LIKE '%$search%') ";
/// To actually fetch the records
$fromsql = ' FROM '.$tables.$where.$groupselect.$approveselect.$searchselect;
-
+
$sqlselect = 'SELECT '.$what.$fromsql.$sortorder;
$sqlcount = 'SELECT '.$count.$fromsql; // Total number of records
# if ($content = get_field('data_content', 'content', 'recordid', $record->id, 'fieldid', $sort)) {
# $content = addslashes($content);
# if ($order == 'ASC') {
-# $lessthan = " AND $sortcontentfull < '$content'
+# $lessthan = " AND $sortcontentfull < '$content'
# OR ($sortcontentfull = '$content' AND r.id < '$record->id') ";
# } else {
-# $lessthan = " AND $sortcontentfull > '$content'
+# $lessthan = " AND $sortcontentfull > '$content'
# OR ($sortcontentfull = '$content' AND r.id < '$record->id') ";
# }
# } else { // Failed to find data (shouldn't happen), so fall back to something easy
if (empty($records)) { // Nothing to show!
if ($record) { // Something was requested so try to show that at least (bug 5132)
- if (has_capability('mod/data:manageentries', $context) || empty($data->approval) ||
+ if (has_capability('mod/data:manageentries', $context) || empty($data->approval) ||
$record->approved || (isloggedin() && $record->userid == $USER->id)) {
if (!$currentgroup || $record->groupid == $currentgroup || $record->groupid == 0) {
$records[] = $record;