From aab98aaff18f6540054b654f45109ffd264217c0 Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 13 Dec 2006 20:26:11 +0000 Subject: [PATCH] data mod whitespace cleanup - there are already many accessibility related changes and fixes that are not backportable anyway and merging from previous versions is not expected --- mod/data/backuplib.php | 26 ++++----- mod/data/comment.php | 22 ++++---- mod/data/config.html | 4 +- mod/data/css.php | 2 +- mod/data/db/mysql.php | 16 +++--- mod/data/db/mysql.sql | 4 +- mod/data/db/postgres7.php | 18 +++---- mod/data/db/upgrade.php | 6 +-- mod/data/edit.php | 40 +++++++------- mod/data/field.php | 62 +++++++++++----------- mod/data/field/checkbox/field.class.php | 18 +++---- mod/data/field/date/field.class.php | 4 +- mod/data/field/file/field.class.php | 14 ++--- mod/data/field/latlong/field.class.php | 30 +++++------ mod/data/field/latlong/kml.php | 10 ++-- mod/data/field/menu/field.class.php | 2 +- mod/data/field/multimenu/field.class.php | 16 +++--- mod/data/field/number/field.class.php | 6 +-- mod/data/field/picture/field.class.php | 38 ++++++------- mod/data/field/radiobutton/field.class.php | 10 ++-- mod/data/field/textarea/field.class.php | 26 ++++----- mod/data/field/url/field.class.php | 8 +-- mod/data/filter.php | 10 ++-- mod/data/import.php | 36 ++++++------- mod/data/index.php | 8 +-- mod/data/js.php | 2 +- mod/data/lib.php | 2 +- mod/data/mod_form.php | 32 +++++------ mod/data/pagelib.php | 2 +- mod/data/preset/imagegallery/jstemplate.js | 6 +-- mod/data/restorelib.php | 36 ++++++------- mod/data/rsslib.php | 18 +++---- mod/data/tabs.php | 16 +++--- mod/data/templates.php | 44 +++++++-------- mod/data/view.php | 42 +++++++-------- 35 files changed, 318 insertions(+), 318 deletions(-) diff --git a/mod/data/backuplib.php b/mod/data/backuplib.php index cc328f58a0..2af71ff064 100644 --- a/mod/data/backuplib.php +++ b/mod/data/backuplib.php @@ -35,12 +35,12 @@ //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) { @@ -62,12 +62,12 @@ function data_backup_mods($bf,$preferences) { 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; @@ -98,25 +98,25 @@ function data_backup_one_mod($bf,$preferences,$data) { 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; - + } @@ -150,7 +150,7 @@ function backup_data_fields($bf,$preferences,$dataid){ 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)); } @@ -324,7 +324,7 @@ function backup_data_files($bf,$preferences) { $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/data"); } } - + return $status; } @@ -365,7 +365,7 @@ function data_check_backup_mods($course,$user_data=false,$backup_unique_code,$in } return $info; } - + // otherwise continue as normal //First the course data $info[0][0] = get_string("modulenameplural","data"); @@ -374,7 +374,7 @@ function data_check_backup_mods($course,$user_data=false,$backup_unique_code,$in } else { $info[0][1] = 0; } - + //Now, if requested, the user_data if ($user_data) { // any other needed stuff diff --git a/mod/data/comment.php b/mod/data/comment.php index 8b359ad0a5..bc2cea1f6a 100755 --- a/mod/data/comment.php +++ b/mod/data/comment.php @@ -29,17 +29,17 @@ } 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!'); } } @@ -59,7 +59,7 @@ } 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')); @@ -68,7 +68,7 @@ echo ''; echo ''; echo ''; - + echo ''; echo ''; echo ''; @@ -77,7 +77,7 @@ echo ''; print_footer(); break; - + case 'editcommit': //update db if (empty($commentcontent)) { redirect('view.php?rid='.$record->id.'&page='.$page, get_string('commentempty', 'data')); @@ -92,7 +92,7 @@ } 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); @@ -102,7 +102,7 @@ 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); @@ -110,13 +110,13 @@ } break; - + default: //print all listing, and add comment form print_header(); data_print_comments($data, $record, $page); print_footer(); break; - + } diff --git a/mod/data/config.html b/mod/data/config.html index 0022219294..baca72ff46 100644 --- a/mod/data/config.html +++ b/mod/data/config.html @@ -19,13 +19,13 @@ $data_enablerssfeeds = true; } - + choose_from_menu ($options, "data_enablerssfeeds", $data_enablerssfeeds, "", "", ""); } ?> - enablerssfeeds) || $CFG->enablerssfeeds == 0) { print_string("configenablerssfeedsdisabled"); diff --git a/mod/data/css.php b/mod/data/css.php index 6e9cf07f94..00469ed2ed 100755 --- a/mod/data/css.php +++ b/mod/data/css.php @@ -37,4 +37,4 @@ header('Content-type: text/css'); // Correct MIME type echo $data->csstemplate; - } + } diff --git a/mod/data/db/mysql.php b/mod/data/db/mysql.php index 38a14a93b6..058939611b 100644 --- a/mod/data/db/mysql.php +++ b/mod/data/db/mysql.php @@ -2,7 +2,7 @@ // 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) { @@ -28,12 +28,12 @@ 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')"); @@ -43,7 +43,7 @@ function data_upgrade($oldversion) { 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'); @@ -53,7 +53,7 @@ function data_upgrade($oldversion) { 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'); @@ -68,7 +68,7 @@ function data_upgrade($oldversion) { 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'); } @@ -76,7 +76,7 @@ function data_upgrade($oldversion) { 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'); @@ -110,7 +110,7 @@ function data_upgrade($oldversion) { 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 diff --git a/mod/data/db/mysql.sql b/mod/data/db/mysql.sql index 5e03cf6cc9..13cbf8b81c 100755 --- a/mod/data/db/mysql.sql +++ b/mod/data/db/mysql.sql @@ -1,12 +1,12 @@ # -- 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 -# -- +# -- # -- -------------------------------------------------------- diff --git a/mod/data/db/postgres7.php b/mod/data/db/postgres7.php index 5c8d2a969d..3a5d7644cd 100644 --- a/mod/data/db/postgres7.php +++ b/mod/data/db/postgres7.php @@ -2,7 +2,7 @@ // 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) { @@ -22,7 +22,7 @@ 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"); @@ -33,7 +33,7 @@ function data_upgrade($oldversion) { 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')"); @@ -44,7 +44,7 @@ function data_upgrade($oldversion) { 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'); @@ -54,7 +54,7 @@ function data_upgrade($oldversion) { 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); @@ -150,9 +150,9 @@ function data_upgrade($oldversion) { recordid integer NOT NULL default '0', rating integer NOT NULL default '0' );"); - + } - + if ($oldversion < 2006052400) { table_column('data','','rsstitletemplate','text','','','','not null','rsstemplate'); } @@ -160,7 +160,7 @@ function data_upgrade($oldversion) { 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'); @@ -194,7 +194,7 @@ function data_upgrade($oldversion) { 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 diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index c5105db184..954fbdd281 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -1,6 +1,6 @@ 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. :) @@ -72,7 +72,7 @@ "$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! @@ -89,7 +89,7 @@ if ($cancel) { redirect('view.php?d='.$data->id); } - + /// RSS and CSS and JS meta $meta = ''; @@ -110,7 +110,7 @@ $strdata = get_string('modulenameplural','data'); print_header_simple($data->name, '', "$strdata -> $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)); @@ -150,13 +150,13 @@ /// 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); @@ -197,26 +197,26 @@ ///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) { @@ -260,17 +260,17 @@ echo ''; echo ''; 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); @@ -285,7 +285,7 @@ echo data_generate_default_template($data, 'addtemplate', $rid, true, false); $newtext = ''; } - + echo $newtext; echo '
'; if ($rid) { @@ -297,9 +297,9 @@ print_simple_box_end(); echo ''; - + /// Upload records section. Only for teachers and the admin. - + if (has_capability('mod/data:manageentries',$context)) { if ($import) { print_simple_box_start('center','80%'); @@ -348,6 +348,6 @@ $field = data_get_field($eachfield, $data); $field->print_after_form(); } - + print_footer($course); ?> diff --git a/mod/data/field.php b/mod/data/field.php index 2459c1cb4b..3a5ea41f92 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -25,7 +25,7 @@ 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 @@ -38,8 +38,8 @@ if ($cancel) { $mode = 'list'; } - - + + if ($id) { if (! $cm = get_coursemodule_from_id('data', $id)) { error('Course Module ID was incorrect'); @@ -67,7 +67,7 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/data:managetemplates', $context); - + /************************************ * Data Processing * ***********************************/ @@ -77,14 +77,14 @@ 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); @@ -98,9 +98,9 @@ /// 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'); } } @@ -113,7 +113,7 @@ //$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 { @@ -123,10 +123,10 @@ /// 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}; @@ -134,15 +134,15 @@ $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'); } } @@ -172,10 +172,10 @@ 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'); } @@ -186,7 +186,7 @@ // Print confirmation message. $field = data_get_field_from_id($fid, $data); - notice_yesno(''.$field->name().': '.$field->field->name.'

'. get_string('confirmdeletefield','data'), + notice_yesno(''.$field->name().': '.$field->field->name.'

'. get_string('confirmdeletefield','data'), 'field.php?d='.$data->id.'&mode=delete&fid='.$fid.'&sesskey='.sesskey().'&confirm=1', 'field.php?d='.$data->id); @@ -219,7 +219,7 @@ /// Print the browsing interface - + ///get the list of possible fields (plugins) $directories = get_list_of_plugins('mod/data/field/'); $menufield = array(); @@ -228,7 +228,7 @@ $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; @@ -248,8 +248,8 @@ $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 @@ -262,7 +262,7 @@ if ($fff = get_records('data_fields','dataid',$data->id,'id')){ foreach ($fff as $ff) { - + $field = data_get_field($ff, $data); $table->data[] = array( @@ -282,13 +282,13 @@ ' '. ''. ''.get_string('delete').'' - + ); } } print_table($table); - } - + } + echo '
'; echo get_string('newfield','data').': '; @@ -314,12 +314,12 @@ } echo ''; echo ' '; - + $options = array(0 => get_string('ascending', 'data'), 1 => get_string('descending', 'data')); choose_from_menu($options, 'defaultsortdir', $data->defaultsortdir, ''); echo ''; - + echo ''; echo '
'; } diff --git a/mod/data/field/checkbox/field.class.php b/mod/data/field/checkbox/field.class.php index 93aa699efc..61afa0dc75 100755 --- a/mod/data/field/checkbox/field.class.php +++ b/mod/data/field/checkbox/field.class.php @@ -25,14 +25,14 @@ 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) { @@ -42,7 +42,7 @@ class data_field_checkbox extends data_field_base { $str = '
'; $str .= '
'.$this->field->name.''; - + $i = 0; foreach (explode("\n", $this->field->param1) as $checkbox) { $checkbox = trim($checkbox); @@ -51,7 +51,7 @@ class data_field_checkbox extends data_field_base { } $str .= 'field->id.'_'.$i.'">'.$checkbox.'
'; $i++; } - $str .= '
'; + $str .= ''; $str .= '
'; return $str; } @@ -70,7 +70,7 @@ class data_field_checkbox extends data_field_base { $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); @@ -78,9 +78,9 @@ class data_field_checkbox extends data_field_base { 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)) { diff --git a/mod/data/field/date/field.class.php b/mod/data/field/date/field.class.php index de6ac78569..9717faec04 100755 --- a/mod/data/field/date/field.class.php +++ b/mod/data/field/date/field.class.php @@ -43,7 +43,7 @@ class data_field_date extends data_field_base { } $str = '
'; - $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 .= '
'; @@ -63,7 +63,7 @@ class data_field_date extends data_field_base { $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); diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index e4e2a515bb..006ec36dc5 100755 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -23,7 +23,7 @@ /////////////////////////////////////////////////////////////////////////// class data_field_file extends data_field_base { - + var $type = 'file'; function data_field_file($field=0, $data=0) { @@ -61,14 +61,14 @@ class data_field_file extends data_field_base { } $str = '
'; - $str .= '
'.$this->field->name.''; + $str .= '
'.$this->field->name.''; $str .= ''; $str .= get_string('file','data'). '
'; $str .= get_string('optionalfilename','data').'
'; $str .= ''; - $str .= '
'; + $str .= '
'; $str .= '
'; if ($recordid and isset($content)){ // Print icon @@ -87,7 +87,7 @@ class data_field_file extends data_field_base { 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]; @@ -98,10 +98,10 @@ class data_field_file extends data_field_base { } 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 = ''.$icon.' '. @@ -169,7 +169,7 @@ class data_field_file extends data_field_base { } return false; } - + } ?> diff --git a/mod/data/field/latlong/field.class.php b/mod/data/field/latlong/field.class.php index 6e7251c6eb..9addeca64f 100755 --- a/mod/data/field/latlong/field.class.php +++ b/mod/data/field/latlong/field.class.php @@ -1,4 +1,4 @@ -field->description).'">'; - $str .= '
'.$this->field->name.''; + $str .= '
'.$this->field->name.''; $str .= ''; $str .= ''; $str .= '
'; $str .= '°N
°E
'; - $str .= '
'; + $str .= '
'; $str .= '
'; - + return $str; } @@ -85,7 +85,7 @@ class data_field_latlong extends data_field_base { if (empty($lat) or empty($long)) { return ''; } - + if($lat < 0) { $compasslat = "" . sprintf('%01.4f', 0 - $lat) . '°S'; } else { @@ -96,11 +96,11 @@ class data_field_latlong extends data_field_base { } else { $compasslong = "" . sprintf('%01.4f', $long) . "°E"; } - + $str = '
'; $str.= "$compasslat, $compasslong"; - - + + // Now let's create the jump-to-services link $servicesshown = explode(',', $this->field->param1); @@ -122,7 +122,7 @@ class data_field_latlong extends data_field_base { ."'>$servicesshown[0] "; } elseif (sizeof($servicesshown)>1) { $str .= "\n'; - + foreach (explode("\n",$this->field->param1) as $option) { $option = trim($option); $str .= '
'; if ($usehtmleditor) { - use_html_editor('template'); + use_html_editor('template'); if ($mode == 'listtemplate'){ use_html_editor('listtemplateheader'); use_html_editor('listtemplatefooter'); diff --git a/mod/data/view.php b/mod/data/view.php index 9842208dd4..754d2d397d 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -28,7 +28,7 @@ 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 @@ -42,7 +42,7 @@ /// 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'); @@ -82,7 +82,7 @@ } require_course_login($course, true, $cm); - + $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/data:viewentry', $context); @@ -165,10 +165,10 @@ $meta .= ''; } - + /// 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)) { @@ -182,7 +182,7 @@ } 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 '
'; @@ -190,14 +190,14 @@ echo '
'; echo '
'; } - + 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 { @@ -229,7 +229,7 @@ } 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); @@ -252,7 +252,7 @@ } else { $currenttab = 'list'; } - include('tabs.php'); + include('tabs.php'); /// Approve any requested records @@ -305,10 +305,10 @@ $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) { @@ -317,12 +317,12 @@ $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%') "; @@ -340,7 +340,7 @@ /// 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 @@ -358,10 +358,10 @@ # 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 @@ -396,7 +396,7 @@ 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; -- 2.39.5