From df488915dd6decf73c0404f38c885f613e580c4d Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Tue, 30 May 2017 17:38:31 +0300 Subject: [PATCH] Fix: PHP coding style problems --- attempt.php | 16 +++++- .../backup_game_activity_task.class.php | 7 ++- backup/moodle2/backup_game_settingslib.php | 4 +- backup/moodle2/backup_game_stepslib.php | 7 ++- .../restore_game_activity_task.class.php | 1 - backup/moodle2/restore_game_stepslib.php | 56 ++++++++++++++++++- bookquiz/play.php | 2 + bookquiz/questions.php | 3 +- bookquiz/toc.php | 2 +- cross/cross_class.php | 3 + cross/crossdb_class.php | 5 +- cross/play.php | 2 + cryptex/play.php | 1 - export.php | 1 - exporthtml.php | 1 - exporthtml_hangman.php | 1 - exporthtml_millionaire.php | 1 - exporthtml_snakes.php | 1 - exportjavame.php | 1 - index.php | 1 - lib.php | 2 - millionaire/play.php | 1 - preview.php | 1 - print.php | 1 - report/overview/report.php | 1 - showanswers.php | 1 - showattempts.php | 1 - sudoku/class.Sudoku.php | 1 - sudoku/play.php | 4 +- sudoku/sdd/class.SDD.php | 29 +--------- sudoku/sdd/class.logfile.php | 1 - tabs.php | 4 +- version.php | 7 +-- 33 files changed, 105 insertions(+), 65 deletions(-) diff --git a/attempt.php b/attempt.php index 05c8613..91a008a 100644 --- a/attempt.php +++ b/attempt.php @@ -16,9 +16,8 @@ /** * This page prints a particular attempt of game - * + * * @author bdaloukas - * @version $Id: attempt.php,v 1.22 2012/07/25 23:07:43 bdaloukas Exp $ * @package game **/ require_once( "../../config.php"); @@ -39,6 +38,9 @@ $action = optional_param('action', "", PARAM_ALPHANUM); // Is the param action game_show_header( $id, $game, $course, $context); game_do_attempt( $id, $game, $action, $course, $context); +/** + * Do the required checks and print header. + */ function game_show_header( &$id, &$game, &$course, &$context) { global $DB, $USER, $PAGE, $OUTPUT; @@ -114,6 +116,10 @@ function game_show_header( &$id, &$game, &$course, &$context) { echo $OUTPUT->header(); } +/** + * Do one attempt. + */ + function game_do_attempt( $id, $game, $action, $course, $context) { global $OUTPUT; @@ -186,6 +192,9 @@ function game_do_attempt( $id, $game, $action, $course, $context) { echo $OUTPUT->footer(); } +/** + * Creates one game. + */ function game_create( $game, $id, $forcenew, $course, $context) { global $USER, $CFG, $DB; @@ -225,6 +234,9 @@ function game_create( $game, $id, $forcenew, $course, $context) { } } +/** + * Unpacks the cross. + */ function game_cross_unpackpuzzle( $g) { $ret = ""; $len = game_strlen( $g); diff --git a/backup/moodle2/backup_game_activity_task.class.php b/backup/moodle2/backup_game_activity_task.class.php index 3e095ab..2521dae 100644 --- a/backup/moodle2/backup_game_activity_task.class.php +++ b/backup/moodle2/backup_game_activity_task.class.php @@ -17,12 +17,13 @@ /** * @package mod_game * @subpackage backup-moodle2 - * class backup_game_activity_task - * @author - * @version $Id: backup_game_activity_task.class.php,v 1.2 2012/07/25 11:16:04 bdaloukas Exp $ + * class backup_game_activity_task + * @author * @package game **/ +defined('MOODLE_INTERNAL') || die(); + require_once($CFG->dirroot . '/mod/game/backup/moodle2/backup_game_stepslib.php'); // Because it exists (must). require_once($CFG->dirroot . '/mod/game/backup/moodle2/backup_game_settingslib.php'); // Because it exists (optional). diff --git a/backup/moodle2/backup_game_settingslib.php b/backup/moodle2/backup_game_settingslib.php index 998e8ae..35e15d2 100644 --- a/backup/moodle2/backup_game_settingslib.php +++ b/backup/moodle2/backup_game_settingslib.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * @package moodlecore + * @package game * @subpackage backup-moodle2 * @copyright 2010 onwards YOUR_NAME_GOES_HERE {@link YOUR_URL_GOES_HERE} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -25,3 +25,5 @@ * backup_activity_task so here there isn't any class definition, like the ones * existing in /backup/moodle2/backup_settingslib.php (activities section) */ + +defined('MOODLE_INTERNAL') || die(); diff --git a/backup/moodle2/backup_game_stepslib.php b/backup/moodle2/backup_game_stepslib.php index 5ea4205..7072801 100644 --- a/backup/moodle2/backup_game_stepslib.php +++ b/backup/moodle2/backup_game_stepslib.php @@ -18,7 +18,6 @@ * @package mod_game * @subpackage backup-moodle2 * @author bdaloukas - * @version $Id: backup_game_stepslib.php,v 1.5 2012/07/25 11:16:04 bdaloukas Exp $ */ /** @@ -28,8 +27,14 @@ /** * Define the complete game structure for backup, with file and id annotations */ + +defined('MOODLE_INTERNAL') || die(); + class backup_game_activity_structure_step extends backup_activity_structure_step { + /** + * Defines the needed structures. + */ protected function define_structure() { // To know if we are including userinfo. diff --git a/backup/moodle2/restore_game_activity_task.class.php b/backup/moodle2/restore_game_activity_task.class.php index e6b7d84..f121444 100644 --- a/backup/moodle2/restore_game_activity_task.class.php +++ b/backup/moodle2/restore_game_activity_task.class.php @@ -18,7 +18,6 @@ * @package mod_game * @subpackage backup-moodle2 * @author bdaloukas - * @version $Id: restore_game_activity_task.class.php,v 1.3 2012/07/25 11:16:04 bdaloukas Exp $ */ defined('MOODLE_INTERNAL') || die(); diff --git a/backup/moodle2/restore_game_stepslib.php b/backup/moodle2/restore_game_stepslib.php index 03caee3..46e8903 100644 --- a/backup/moodle2/restore_game_stepslib.php +++ b/backup/moodle2/restore_game_stepslib.php @@ -29,6 +29,9 @@ */ class restore_game_activity_structure_step extends restore_activity_structure_step { + /** + * Defines the neeeded structures. + */ protected function define_structure() { $paths = array(); @@ -60,6 +63,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st return $this->prepare_activity_structure($paths); } + /** + * Restores the game table. + */ protected function process_game($data) { global $DB; @@ -75,6 +81,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $this->apply_activity_instance($newitemid); } + /** + * Restores the game_export_html table. + */ protected function process_game_export_html($data) { global $DB; @@ -86,6 +95,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st } } + /** + * Restores the game_export_javame table. + */ protected function process_game_export_javame($data) { global $DB; @@ -97,6 +109,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st } } + /** + * Restores the game_grades table. + */ protected function process_game_grade($data) { global $DB; @@ -109,6 +124,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_grades', $data); } + /** + * Restores the game_repetitions table. + */ protected function process_game_repetition($data) { global $DB; @@ -121,6 +139,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_repetitions', $data); } + /** + * Restores the game_attempts table. + */ protected function process_game_attempt($data) { global $DB; @@ -148,6 +169,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $this->set_mapping('game_attempt', $oldid, $newitemid); } + /** + * Restores the game_queries table. + */ protected function process_game_query($data) { global $DB; @@ -162,6 +186,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $this->set_mapping('game_query', $oldid, $newitemid); } + /** + * Restores the game_bookquiz table. + */ protected function process_game_bookquiz($data) { global $DB; @@ -172,6 +199,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_bookquiz', $data); } + /** + * Restores the game_bookauiz_chapters table. + */ protected function process_game_bookquiz_chapter($data) { global $DB; @@ -182,6 +212,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_bookquiz_chapters', $data); } + /** + * Restores the game_bookquiz_questions table. + */ protected function process_game_bookquiz_question($data) { global $DB; @@ -192,6 +225,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_bookquiz_questions', $data); } + /** + * Restores the game_cross table. + */ protected function process_game_cross($data) { global $DB; @@ -202,6 +238,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_cross', $data); } + /** + * Restores the game_cryptex table. + */ protected function process_game_cryptex($data) { global $DB; @@ -212,6 +251,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_cryptex', $data); } + /** + * Restores the game_hangman table. + */ protected function process_game_hangman($data) { global $DB; @@ -223,6 +265,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_hangman', $data); } + /** + * Restores the game_hiddenpicture table. + */ protected function process_game_hiddenpicture($data) { global $DB; @@ -233,6 +278,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_hiddenpicture', $data); } + /** + * Restores the game_millionaire table. + */ protected function process_game_millionaire($data) { global $DB; @@ -244,6 +292,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_millionaire', $data); } + /** + * Restores the game_snakes table. + */ protected function process_game_snake($data) { global $DB; @@ -255,6 +306,9 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_snakes', $data); } + /** + * Restores the game_sudoku table. + */ protected function process_game_sudoku($data) { global $DB; @@ -265,8 +319,8 @@ class restore_game_activity_structure_step extends restore_activity_structure_st $DB->insert_record('game_sudoku', $data); } + // Add Game related files, no need to match by itemname (just internally handled context). protected function after_execute() { - // Add Game related files, no need to match by itemname (just internally handled context). $this->add_related_files('mod_game', 'snakes_file', null); $this->add_related_files('mod_game', 'snakes_board', null); } diff --git a/bookquiz/play.php b/bookquiz/play.php index 66587d0..665f725 100644 --- a/bookquiz/play.php +++ b/bookquiz/play.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); + function game_bookquiz_continue( $id, $game, $attempt, $bookquiz, $chapterid, $context) { if ($attempt != false and $bookquiz != false) { return game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $context); diff --git a/bookquiz/questions.php b/bookquiz/questions.php index 5a83c0f..0854cb4 100644 --- a/bookquiz/questions.php +++ b/bookquiz/questions.php @@ -17,11 +17,12 @@ /** * The script supports book * - * @version $Id: questions.php,v 1.6 2012/07/25 11:16:05 bdaloukas Exp $ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package game **/ +defined('MOODLE_INTERNAL') || die(); + require_once("../../../config.php"); require_once( "../headergame.php"); require_once("../locallib.php"); diff --git a/bookquiz/toc.php b/bookquiz/toc.php index 8c59d67..74cba09 100644 --- a/bookquiz/toc.php +++ b/bookquiz/toc.php @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.'); +defined('MOODLE_INTERNAL') || die(); define('NUM_NONE', '0'); define('NUM_NUMBERS', '1'); diff --git a/cross/cross_class.php b/cross/cross_class.php index ec97248..8d3ea6e 100644 --- a/cross/cross_class.php +++ b/cross/cross_class.php @@ -23,6 +23,9 @@ Codewalkers PHP Coding Contest of July 2002 Author Àngel Fenoy from Arenys de Mar, Barcelona. */ + +defined('MOODLE_INTERNAL') || die(); + class Cross { public $minputanswers; // Contains the words and the answers. diff --git a/cross/crossdb_class.php b/cross/crossdb_class.php index 286ac6e..614f3cd 100644 --- a/cross/crossdb_class.php +++ b/cross/crossdb_class.php @@ -18,12 +18,13 @@ /** * This class is a cross that can load and save to a table - * + * * @author bdaloukas - * @version $Id: crossdb_class.php,v 1.17 2012/07/25 11:16:05 bdaloukas Exp $ * @package game **/ +defined('MOODLE_INTERNAL') || die(); + class CrossDB extends Cross { public function savecross( $game, &$crossm, $crossd, $id) { global $DB, $USER; diff --git a/cross/play.php b/cross/play.php index 547640f..9fd1e5a 100644 --- a/cross/play.php +++ b/cross/play.php @@ -18,6 +18,8 @@ // This files plays the game "Crossword". +defined('MOODLE_INTERNAL') || die(); + require( "cross_class.php"); require( "crossdb_class.php"); diff --git a/cryptex/play.php b/cryptex/play.php index 2a3e37b..3ecb343 100644 --- a/cryptex/play.php +++ b/cryptex/play.php @@ -18,7 +18,6 @@ * This page plays the cryptex game * * @author bdaloukas - * @version $Id: play.php,v 1.20 2012/08/03 05:52:50 bdaloukas Exp $ * @package game **/ diff --git a/export.php b/export.php index c2e9ecb..0d420f7 100644 --- a/export.php +++ b/export.php @@ -18,7 +18,6 @@ * This page exports a game to another platform e.g. html, jar * * @author bdaloukas - * @version $Id: export.php,v 1.22 2012/07/25 11:16:03 bdaloukas Exp $ * @package game **/ diff --git a/exporthtml.php b/exporthtml.php index 318d613..a285b29 100644 --- a/exporthtml.php +++ b/exporthtml.php @@ -18,7 +18,6 @@ * This page export the game to html for games: cross, hangman * * @author bdaloukas - * @version $Id: exporthtml.php,v 1.23 2012/07/25 11:16:03 bdaloukas Exp $ * @package game **/ diff --git a/exporthtml_hangman.php b/exporthtml_hangman.php index 6e93913..977ae14 100644 --- a/exporthtml_hangman.php +++ b/exporthtml_hangman.php @@ -18,7 +18,6 @@ * This page export the game hangman to html * * @author bdaloukas - * @version $Id: exporthtml_hangman.php,v 1.10 2012/07/25 11:16:03 bdaloukas Exp $ * @package game **/ diff --git a/exporthtml_millionaire.php b/exporthtml_millionaire.php index 20afb12..5f4c5cc 100644 --- a/exporthtml_millionaire.php +++ b/exporthtml_millionaire.php @@ -18,7 +18,6 @@ * This page export the game millionaire to html * * @author bdaloukas - * @version $Id: exporthtml_millionaire.php,v 1.14 2012/07/25 11:16:03 bdaloukas Exp $ * @package game **/ diff --git a/exporthtml_snakes.php b/exporthtml_snakes.php index 2c263c0..7eb5fbd 100644 --- a/exporthtml_snakes.php +++ b/exporthtml_snakes.php @@ -18,7 +18,6 @@ * This page export the game snakes to html * * @author bdaloukas - * @version $Id: exporthtml_snakes.php,v 1.4 2011/07/23 12:34:08 bdaloukas Exp $ * @package game **/ diff --git a/exportjavame.php b/exportjavame.php index 6e19496..2ffd98f 100644 --- a/exportjavame.php +++ b/exportjavame.php @@ -18,7 +18,6 @@ * This page export the game to javame for mobile phones * * @author bdaloukas - * @version $Id: exportjavame.php,v 1.18 2012/07/25 11:16:03 bdaloukas Exp $ * @package game **/ diff --git a/index.php b/index.php index 8ddb8f2..2a81860 100644 --- a/index.php +++ b/index.php @@ -18,7 +18,6 @@ * This page lists all the instances of game module in a particular course * * @author - * @version $Id: index.php,v 1.8 2012/08/29 20:55:25 bdaloukas Exp $ * @package game **/ diff --git a/lib.php b/lib.php index 43b3a0c..ca90ea4 100644 --- a/lib.php +++ b/lib.php @@ -18,11 +18,9 @@ * Library of functions and constants for module game * * @author - * @version $Id: lib.php,v 1.36 2012/07/25 11:16:03 bdaloukas Exp $ * @package game **/ - // Define CONSTANTS. /* diff --git a/millionaire/play.php b/millionaire/play.php index bf47023..562b69e 100644 --- a/millionaire/play.php +++ b/millionaire/play.php @@ -18,7 +18,6 @@ * This file plays the game millionaire * * @author bdaloukas - * @version $Id: play.php,v 1.31 2012/07/25 11:16:05 bdaloukas Exp $ * @package game **/ diff --git a/preview.php b/preview.php index 0ef5c3a..1a5d883 100644 --- a/preview.php +++ b/preview.php @@ -18,7 +18,6 @@ * This page prints a particular attempt of game * * @author bdaloukas - * @version $Id: preview.php,v 1.10 2012/07/25 11:16:04 bdaloukas Exp $ * @package game **/ diff --git a/print.php b/print.php index e3ec473..6751756 100644 --- a/print.php +++ b/print.php @@ -18,7 +18,6 @@ * This page export the game to html * * @author bdaloukas - * @version $Id: print.php,v 1.7 2012/07/25 11:16:04 bdaloukas Exp $ * @package game **/ require_once("../../config.php"); diff --git a/report/overview/report.php b/report/overview/report.php index 1f24083..d8518c8 100644 --- a/report/overview/report.php +++ b/report/overview/report.php @@ -17,7 +17,6 @@ /** * This script lists student attempts * - * @version $Id: report.php,v 1.5 2012/07/25 11:16:07 bdaloukas Exp $ * @author bdaloukas. * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package game diff --git a/showanswers.php b/showanswers.php index f0cca3a..b353c15 100644 --- a/showanswers.php +++ b/showanswers.php @@ -18,7 +18,6 @@ * This page shows the answers of the current game * * @author bdaloukas - * @version $Id: showanswers.php,v 1.7 2012/07/25 22:46:42 bdaloukas Exp $ * @package game **/ diff --git a/showattempts.php b/showattempts.php index 223ce4e..ec4f1f9 100644 --- a/showattempts.php +++ b/showattempts.php @@ -18,7 +18,6 @@ * This page shows the answers of the current game * * @author bdaloukas - * @version $Id: showattempts.php,v 1.6 2012/07/25 11:16:04 bdaloukas Exp $ * @package game **/ diff --git a/sudoku/class.Sudoku.php b/sudoku/class.Sudoku.php index 78d5fda..511e3f3 100644 --- a/sudoku/class.Sudoku.php +++ b/sudoku/class.Sudoku.php @@ -60,7 +60,6 @@ * @author Dick Munroe * @copyright copyright @ 2005 by Dick Munroe, Cottage Software Works, Inc. * @license http://www.csworks.com/publications/ModifiedNetBSD.html - * @version 2.2.0 * @package Sudoku */ diff --git a/sudoku/play.php b/sudoku/play.php index 74977da..d5cbe38 100644 --- a/sudoku/play.php +++ b/sudoku/play.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); + require_once( "../../lib/questionlib.php"); function game_sudoku_continue( $id, $game, $attempt, $sudoku, $endofgame, $context) { @@ -284,7 +286,7 @@ function game_sudoku_showsudoku( $data, $guess, $bshowlegend, $bshowsolution, $o window.location.href = "&pos=" + pos + "&num=" + s; } - timefinish) { diff --git a/sudoku/sdd/class.SDD.php b/sudoku/sdd/class.SDD.php index fc0a82a..14be41c 100644 --- a/sudoku/sdd/class.SDD.php +++ b/sudoku/sdd/class.SDD.php @@ -26,36 +26,9 @@ * @copyright copyright @ by Dick Munroe, 2004 * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @package StructuredDataDumper - * @version 1.0.4 */ -// -// Edit History: -// -// Dick Munroe munroe@cworks.com 04-Dec-2004 -// Initial version created. -// -// Dick Munroe munroe@csworks.com 08-Dec-2004 -// Translate < to < for html output. -// -// Dick Munroe munroe@csworks.com 23-Dec-2004 -// Add interface for writing "stuff". Extend SDD -// to get things "written". -// -// Dick Munroe munroe@csworks.com 25-Dec-2004 -// If a class extends a base class, but doesn't add -// data members, a warning winds up appearing when -// printing. -// Added a memeber to fetch the state of the logging -// flag. -// -// Dick Munroe munroe@csworks.com 11-Mar-2006 -// The test for html flag should have assumed that -// $this can be defined for objects calling SDD::dump. -// -// Dick Munroe (munroe@csworks.com) 22-Mar-2006 -// Add a function to generate "newlines". -// +defined('MOODLE_INTERNAL') || die(); class sdd { /* diff --git a/sudoku/sdd/class.logfile.php b/sudoku/sdd/class.logfile.php index 32ed65e..7f1f1f2 100644 --- a/sudoku/sdd/class.logfile.php +++ b/sudoku/sdd/class.logfile.php @@ -19,7 +19,6 @@ * @copyright copyright @ by Dick Munroe, 2004 * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @package StructuredDataDumper - * @version 1.0.1 */ /* diff --git a/tabs.php b/tabs.php index 9aa44ab..c3243a3 100644 --- a/tabs.php +++ b/tabs.php @@ -22,6 +22,8 @@ * @package game */ +defined('MOODLE_INTERNAL') || die(); + if (empty($game)) { print_error('You cannot call this script in that way'); } @@ -71,7 +73,7 @@ if ($currenttab == 'reports' and isset($mode)) { $allreports = get_list_of_plugins("mod/game/report"); // Standard reports we want to show first - $reportlist = array ('overview' /*, 'regrade' , 'grading' , 'analysis'*/); + $reportlist = array ('overview'); foreach ($allreports as $report) { if (!in_array($report, $reportlist)) { diff --git a/version.php b/version.php index 4e45a41..dde1d78 100644 --- a/version.php +++ b/version.php @@ -18,8 +18,7 @@ * Code fragment to define the version of game * This fragment is called by moodle_needs_upgrading() and /admin/index.php * - * @author - * @version $Id: version.php,v 1.49 2012/07/25 22:46:42 bdaloukas Exp $ + * @author * @package game **/ @@ -36,10 +35,10 @@ if (!isset( $plugin)) { } $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2017053001; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017053002; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2010112400; // Requires Moodle 2.0. $plugin->cron = 0; // Period for cron to check this module (secs). -$plugin->release = '2017-05-30'; +$plugin->release = '2017-05-30-02'; if ($useplugin != 2) { $module = $plugin;