highlighting sloppy globals hacks

This commit is contained in:
Petr Skoda 2010-09-18 13:55:56 +00:00
parent 3f975b9c6b
commit 0a9d1b3b13
3 changed files with 7 additions and 3 deletions

View file

@ -525,7 +525,7 @@ function survey_shorten_name ($name, $numwords) {
* @param object $question * @param object $question
*/ */
function survey_print_multi($question) { function survey_print_multi($question) {
global $USER, $DB, $qnum, $checklist, $DB, $OUTPUT; global $USER, $DB, $qnum, $checklist, $DB, $OUTPUT; //TODO: this is sloppy globals abuse
$stripreferthat = get_string("ipreferthat", "survey"); $stripreferthat = get_string("ipreferthat", "survey");
$strifoundthat = get_string("ifoundthat", "survey"); $strifoundthat = get_string("ifoundthat", "survey");

View file

@ -74,8 +74,8 @@
$answers = array(); $answers = array();
foreach ($formdata as $key => $val) { foreach ($formdata as $key => $val) {
if ($key <> "userid" && $key <> "id") { if ($key <> "userid" && $key <> "id") {
if ( substr($key,0,1) == "q") { if ( substr($key,0,1) == "q") {
$key = clean_param(substr($key,1), PARAM_ALPHANUM); // keep everything but the 'q', number or Pnumber $key = clean_param(substr($key,1), PARAM_ALPHANUM); // keep everything but the 'q', number or Pnumber
} }
@ -94,6 +94,7 @@
$timenow = time(); $timenow = time();
foreach ($answers as $key => $val) { foreach ($answers as $key => $val) {
if ($key != 'sesskey') { if ($key != 'sesskey') {
$newdata = new object();
$newdata->time = $timenow; $newdata->time = $timenow;
$newdata->userid = $USER->id; $newdata->userid = $USER->id;
$newdata->survey = $survey->id; $newdata->survey = $survey->id;

View file

@ -146,7 +146,10 @@
// Cycle through all the questions in order and print them // Cycle through all the questions in order and print them
global $qnum; //TODO: ugly globals hack for survey_print_*()
global $checklist; //TODO: ugly globals hack for survey_print_*()
$qnum = 0; $qnum = 0;
$checklist = array();
foreach ($questionorder as $key => $val) { foreach ($questionorder as $key => $val) {
$question = $questions["$val"]; $question = $questions["$val"];
$question->id = $val; $question->id = $val;