Skip to content
Snippets Groups Projects
Commit 0ebea0bb authored by Michael Milette's avatar Michael Milette
Browse files

Learning Block - Fix for errors in Moodle 2.5.1 and 2.6


1) Fixes a couple of PHP notices in Moodle 2.5.1
2) Fixes a number of variable and functions that needed to be initialized before they are used in Moodle 2.6.
3) Added security check in ajax_bridge to address Moodle warning
4) Duplicate string definition removed
5) Git version is now in sync with the version published on Moodle.org which seemed to be more recent.

Signed-off-by: default avatarMichael Milette <michael.milette@instruxmedia.com>
parent 23699d3b
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,11 @@ $t_id = optional_param('t_id', null, PARAM_INT); // $_GET['t_id']; ...@@ -37,6 +37,11 @@ $t_id = optional_param('t_id', null, PARAM_INT); // $_GET['t_id'];
$status = optional_param('status', null, PARAM_INT); // $_GET['status']; $status = optional_param('status', null, PARAM_INT); // $_GET['status'];
$hidetraining = optional_param('hidetraining', null, PARAM_INT); // $_GET['hidetraining']; $hidetraining = optional_param('hidetraining', null, PARAM_INT); // $_GET['hidetraining'];
$hideusers = optional_param('hideusers', null, PARAM_INT); //$_GET['hideusers']; $hideusers = optional_param('hideusers', null, PARAM_INT); //$_GET['hideusers'];
require_login(0, false);
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/blocks/learning_plan/ajax_bridge.php');
if($lp_id && $t_id) { if($lp_id && $t_id) {
$form = new search(); $form = new search();
$table = $form->display_list($lp_id, $t_id, $status); $table = $form->display_list($lp_id, $t_id, $status);
...@@ -49,7 +54,7 @@ if($lp_id && $t_id) { ...@@ -49,7 +54,7 @@ if($lp_id && $t_id) {
lpt inner join {learning_user_trainingplan} lut on lut.lpt_id=lpt.id where lpt.lp_id=? AND lut.u_id=?', lpt inner join {learning_user_trainingplan} lut on lut.lpt_id=lpt.id where lpt.lp_id=? AND lut.u_id=?',
array ($lp_id, $u_id), $limitfrom=0, $limitnum=0); array ($lp_id, $u_id), $limitfrom=0, $limitnum=0);
} }
// Find traiing on the base of lp Id. // Find training on the base of lp Id.
else if($lp_id && $t) { else if($lp_id && $t) {
$attributes = $DB->get_records_sql_menu('SELECT t_id as id,(select training_name from {learning_training} where id =t_id) as name FROM {learning_plan_training} $attributes = $DB->get_records_sql_menu('SELECT t_id as id,(select training_name from {learning_training} where id =t_id) as name FROM {learning_plan_training}
where lp_id= ?', array ($lp_id), $limitfrom=0, $limitnum=0); where lp_id= ?', array ($lp_id), $limitfrom=0, $limitnum=0);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* @package blocks * @package blocks
* @author: Azmat Ullah, Talha Noor * @author: Azmat Ullah, Talha Noor
* @date: 20-Sep-2013 * @date: 20-Sep-2013
* @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd. * @copyright Copyrights © 2012 - 2013 | 3i Logic (Pvt) Ltd.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
......
...@@ -69,7 +69,6 @@ $string['wrong_url'] = 'Wrong URL'; ...@@ -69,7 +69,6 @@ $string['wrong_url'] = 'Wrong URL';
$string['elearning'] = 'eLearning'; $string['elearning'] = 'eLearning';
$string['classroom'] = 'Class room'; $string['classroom'] = 'Class room';
$string['onthejob'] = 'On the job'; $string['onthejob'] = 'On the job';
$string['training_m'] = 'Training method';
$string['assignee'] = 'Assignee'; $string['assignee'] = 'Assignee';
$string['remove'] = 'Remove'; $string['remove'] = 'Remove';
$string['setting'] = 'Setting'; $string['setting'] = 'Setting';
...@@ -80,7 +79,3 @@ $string['learning_plan:addinstance'] = 'Add instance'; ...@@ -80,7 +79,3 @@ $string['learning_plan:addinstance'] = 'Add instance';
$string['learning_plan:managepages'] = 'Manage pages'; $string['learning_plan:managepages'] = 'Manage pages';
$string['learning_plan:viewpages'] = 'View pages'; $string['learning_plan:viewpages'] = 'View pages';
$string['user'] = 'User'; $string['user'] = 'User';
\ No newline at end of file
...@@ -29,19 +29,22 @@ require_once("{$CFG->libdir}/formslib.php"); ...@@ -29,19 +29,22 @@ require_once("{$CFG->libdir}/formslib.php");
class learningplan_form extends moodleform { class learningplan_form extends moodleform {
public function definition() { public function definition() {
$mform =& $this->_form; $mform =& $this->_form;
$errors= array();
$mform->addElement('header', 'displayinfo', get_string('learningpath', 'block_learning_plan')); $mform->addElement('header', 'displayinfo', get_string('learningpath', 'block_learning_plan'));
$mform->addElement('text', 'learning_plan', get_string('learningplan', 'block_learning_plan')); $mform->addElement('text', 'learning_plan', get_string('learningplan', 'block_learning_plan'));
$mform->addRule('learning_plan', get_string('plan_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client'); $mform->addRule('learning_plan', get_string('plan_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
$mform->addRule('learning_plan', $errors, 'required', null, 'server'); $mform->addRule('learning_plan', $errors, 'required', null, 'server');
$mform->setType('learningplan', PARAM_RAW); $mform->setType('learning_plan', PARAM_RAW);
$attributes = array('rows' => '8', 'cols' => '40'); $attributes = array('rows' => '8', 'cols' => '40');
$mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes); $mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes);
$mform->setType('description', PARAM_TEXT); $mform->setType('description', PARAM_TEXT);
$mform->addElement('hidden', 'viewpage'); $mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(); $this->add_action_buttons();
} }
public function validation($data) { public function validation($data, $files) {
global $DB; global $DB;
$errors= array(); $errors= array();
if($data['id']) { if($data['id']) {
...@@ -122,6 +125,8 @@ class training_form extends moodleform { ...@@ -122,6 +125,8 @@ class training_form extends moodleform {
$mform =& $this->_form; $mform =& $this->_form;
$mform->addElement('header', 'displayinfo', get_string('add_training', 'block_learning_plan')); $mform->addElement('header', 'displayinfo', get_string('add_training', 'block_learning_plan'));
$radioarray=array(); $radioarray=array();
if (!isset($attributes)) $attributes = "";
if (!isset($errors)) $errors = array();
$radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('elearning', 'block_learning_plan'), 1 ); $radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('elearning', 'block_learning_plan'), 1 );
$radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('classroom', 'block_learning_plan'), 2, $attributes); $radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('classroom', 'block_learning_plan'), 2, $attributes);
$radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('onthejob', 'block_learning_plan'), 3, $attributes); $radioarray[] =& $mform->createElement('radio', 'type_id', '', get_string('onthejob', 'block_learning_plan'), 3, $attributes);
...@@ -130,19 +135,23 @@ class training_form extends moodleform { ...@@ -130,19 +135,23 @@ class training_form extends moodleform {
$mform->addElement('text', 'training_name', get_string('training_name', 'block_learning_plan')); $mform->addElement('text', 'training_name', get_string('training_name', 'block_learning_plan'));
$mform->addRule('training_name', get_string('training_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client'); $mform->addRule('training_name', get_string('training_format', 'block_learning_plan'), 'regex', '#^[A-Z0-9 ]+$#i', 'client');
$mform->addRule('training_name', $errors, 'required', null, 'server'); $mform->addRule('training_name', $errors, 'required', null, 'server');
$mform->setType('training_name', PARAM_TEXT);
// $attributes = array('maxbytes' => '4194304', 'accepted_types' => "*"); // $attributes = array('maxbytes' => '4194304', 'accepted_types' => "*");
// $mform->addElement('file', 'attachment', get_string('attachment', 'block_learning_plan'), $attributes ); // $mform->addElement('file', 'attachment', get_string('attachment', 'block_learning_plan'), $attributes );
// $mform->addElement('filepicker', 'attachment', get_string('attachment', 'block_learning_plan'), null, $attributes); // $mform->addElement('filepicker', 'attachment', get_string('attachment', 'block_learning_plan'), null, $attributes);
$mform->addElement('text', 'url', get_string('url', 'block_learning_plan')); $mform->addElement('text', 'url', get_string('url', 'block_learning_plan'));
$mform->addRule('url', get_string('wrong_url', 'block_learning_plan'), 'regex', '/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', 'client'); $mform->addRule('url', get_string('wrong_url', 'block_learning_plan'), 'regex', '/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', 'client');
$mform->setType('url', PARAM_LOCALURL);
$mform->addElement('date_time_selector', 'start_date', get_string('start_date', 'block_learning_plan')); $mform->addElement('date_time_selector', 'start_date', get_string('start_date', 'block_learning_plan'));
$mform->addElement('date_time_selector', 'end_date', get_string('end_date', 'block_learning_plan')); $mform->addElement('date_time_selector', 'end_date', get_string('end_date', 'block_learning_plan'));
$mform->addElement('static', 'errormsg'); $mform->addElement('static', 'errormsg');
$mform->addElement('hidden', 'viewpage'); $mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(); $this->add_action_buttons();
} }
public function validation($data) { public function validation($data, $files) {
global $DB; global $DB;
$errors= array(); $errors= array();
if($data['id']) { if($data['id']) {
...@@ -246,7 +255,9 @@ class trainingmethod_form extends moodleform { ...@@ -246,7 +255,9 @@ class trainingmethod_form extends moodleform {
$attributes = array('rows' => '8', 'cols' => '40'); $attributes = array('rows' => '8', 'cols' => '40');
$mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes); $mform->addElement('textarea', 'description', get_string('desc', 'block_learning_plan'), $attributes);
$mform->addElement('hidden', 'viewpage'); $mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(); $this->add_action_buttons();
} }
...@@ -276,7 +287,9 @@ class assigntraining_learningplan__form extends moodleform { ...@@ -276,7 +287,9 @@ class assigntraining_learningplan__form extends moodleform {
array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2', 'label' => get_string('add_training', 'block_learning_plan'))); array('link' => $CFG->wwwroot.'/blocks/learning_plan/view.php?viewpage=2', 'label' => get_string('add_training', 'block_learning_plan')));
$select->setmultiple(true); $select->setmultiple(true);
$mform->addElement('hidden', 'viewpage'); $mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(); $this->add_action_buttons();
} }
...@@ -348,6 +361,7 @@ class assignlerningplan_user_form extends moodleform { ...@@ -348,6 +361,7 @@ class assignlerningplan_user_form extends moodleform {
public function definition() { public function definition() {
global $DB, $CFG, $USER; global $DB, $CFG, $USER;
$mform =& $this->_form; $mform =& $this->_form;
if (!isset($attributes1)) $attributes1 = "";
$mform->addElement('header', 'displayinfo', get_string('assign_learningplan_user', 'block_learning_plan')); $mform->addElement('header', 'displayinfo', get_string('assign_learningplan_user', 'block_learning_plan'));
$attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan}', null, $limitfrom=0, $limitnum=0); $attributes = $DB->get_records_sql_menu('SELECT id, learning_plan FROM {learning_learningplan}', null, $limitfrom=0, $limitnum=0);
$mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null, $mform->addElement('selectwithlink', 'l_id', get_string('learningplan', 'block_learning_plan'), $attributes, null,
...@@ -358,7 +372,9 @@ class assignlerningplan_user_form extends moodleform { ...@@ -358,7 +372,9 @@ class assignlerningplan_user_form extends moodleform {
$select->setMultiple(true); $select->setMultiple(true);
// $mform->addElement('hidden', 'assignee', $USER->id); // $mform->addElement('hidden', 'assignee', $USER->id);
$mform->addElement('hidden', 'viewpage'); $mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(); $this->add_action_buttons();
} }
...@@ -428,8 +444,11 @@ class trainingstatus_form extends moodleform { ...@@ -428,8 +444,11 @@ class trainingstatus_form extends moodleform {
$mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes); $mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes);
$attributes = array('size' => '50', 'maxlength' => '1000'); $attributes = array('size' => '50', 'maxlength' => '1000');
$mform->addElement('text', 'remarks', get_string('remarks', 'block_learning_plan'), $attributes); $mform->addElement('text', 'remarks', get_string('remarks', 'block_learning_plan'), $attributes);
$mform->setType('remarks', PARAM_TEXT);
$mform->addElement('hidden', 'viewpage'); $mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$this->add_action_buttons(); $this->add_action_buttons();
} }
...@@ -452,10 +471,12 @@ class search extends moodleform { ...@@ -452,10 +471,12 @@ class search extends moodleform {
$attributes = array('In-progress', 'Not Yet Started', 'Complete', 'All Status'); $attributes = array('In-progress', 'Not Yet Started', 'Complete', 'All Status');
$mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes); $mform->addElement('select', 'status', get_string('status', 'block_learning_plan'), $attributes);
$mform->addElement('hidden', 'viewpage'); $mform->addElement('hidden', 'viewpage');
$mform->setType('viewpage', PARAM_INT);
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('button', 'showuser', 'Search', array("id" => "btnajax")); $mform->addElement('button', 'showuser', 'Search', array("id" => "btnajax"));
} }
public function display_list($lp_id, $t_id, $status) { public function display_list($lp_id = "", $t_id = "", $status = "") {
// if ($lp_id && $t_id) { // if ($lp_id && $t_id) {
global $DB, $OUTPUT, $CFG; global $DB, $OUTPUT, $CFG;
$table = new html_table(); $table = new html_table();
......
...@@ -64,7 +64,7 @@ function user_learningplan($u_id) { ...@@ -64,7 +64,7 @@ function user_learningplan($u_id) {
return $training; return $training;
} }
function status_value($status_id) { function status_value($status_id) {
$status_value; $status_value = '';
if($status_id == '0') { if($status_id == '0') {
$status_value = 'In-Progress'; $status_value = 'In-Progress';
} else if ($status_id == '1') { } else if ($status_id == '1') {
...@@ -124,7 +124,7 @@ function display_list($lp_id, $u_id) { ...@@ -124,7 +124,7 @@ function display_list($lp_id, $u_id) {
global $DB, $OUTPUT, $CFG; global $DB, $OUTPUT, $CFG;
$table = new html_table(); $table = new html_table();
$table->id = 'statuslist'; $table->id = 'statuslist';
$table->head = array(get_string('s_no', 'block_learning_plan'), get_string('training_m', 'block_learning_plan'), get_string('user', 'block_learning_plan'), get_string('start_date', 'block_learning_plan'), get_string('end_date', 'block_learning_plan'), get_string('status', 'block_learning_plan'), get_string('remarks', 'block_learning_plan')); $table->head = array(get_string('s_no', 'block_learning_plan'), get_string('training_name', 'block_learning_plan'), get_string('user', 'block_learning_plan'), get_string('start_date', 'block_learning_plan'), get_string('end_date', 'block_learning_plan'), get_string('status', 'block_learning_plan'), get_string('remarks', 'block_learning_plan'));
$table->size = array('5%', '30%', '20%', '10%', '10%', '10%', '25%', '10%' ); $table->size = array('5%', '30%', '20%', '10%', '10%', '10%', '25%', '10%' );
$table->align = array('center', 'left', 'left', 'center', 'center', 'center', 'left', 'left', 'center'); $table->align = array('center', 'left', 'left', 'center', 'center', 'center', 'left', 'left', 'center');
$table->width = '100%'; $table->width = '100%';
......
...@@ -2,8 +2,8 @@ Learning Plan Block ...@@ -2,8 +2,8 @@ Learning Plan Block
Author: Azmat Ullah, Talha Noor Author: Azmat Ullah, Talha Noor
Plugin Installation Plugin Installation:
1 ) Extract plugin into block folder in moodle 1 ) Extract plugin folder into block folder in moodle
2 ) Login with Administrator on Moodle site 2 ) Login with Administrator on Moodle site
3) Install the plugin by clicking on 'update database' 3) Install the plugin by clicking on 'update database'
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
$plugin->version = 2011033015; // The current plugin version (Date: YYYYMMDDXX) $plugin->version = 2011033017; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011033003; // Requires this Moodle version $plugin->requires = 2011033003; // Requires this Moodle version
$plugin->release = '2.3'; $plugin->release = '2.3';
$plugin->maturity = MATURITY_BETA; $plugin->maturity = MATURITY_BETA;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
*/ */
require_once('../../config.php'); require_once('../../config.php');
$setting = null;
$row = array();
require_once('learning_plan_form.php'); require_once('learning_plan_form.php');
require_once('lib.php'); require_once('lib.php');
require_once("{$CFG->libdir}/formslib.php"); require_once("{$CFG->libdir}/formslib.php");
...@@ -34,6 +36,10 @@ $rem = optional_param('rem', null, PARAM_RAW); ...@@ -34,6 +36,10 @@ $rem = optional_param('rem', null, PARAM_RAW);
$edit = optional_param('edit', null, PARAM_RAW); $edit = optional_param('edit', null, PARAM_RAW);
$delete = optional_param('delete', null, PARAM_RAW); $delete = optional_param('delete', null, PARAM_RAW);
$id = optional_param('id', null, PARAM_INT); $id = optional_param('id', null, PARAM_INT);
require_login();
$context = context_system::instance();
$PAGE->set_context($context);
$PAGE->set_url('/blocks/learning_plan/view.php'); $PAGE->set_url('/blocks/learning_plan/view.php');
$PAGE->set_pagelayout('standard'); $PAGE->set_pagelayout('standard');
$PAGE->set_heading('Learning Plan'); $PAGE->set_heading('Learning Plan');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment