Skip to content

Commit

Permalink
Fixed codechecker issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Johnson committed Dec 21, 2011
1 parent 0576d1e commit a448b9c
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 113 deletions.
174 changes: 118 additions & 56 deletions block_course_appointments.php

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions db/access.php
Expand Up @@ -17,26 +17,24 @@

/**
* Capabilities for course appointments block
*
* @package blocks
* @subpackage course_appointments
*
* @package blocks_course_appointments
* @author Mark Johnson <mark.johnson@tauntons.ac.uk>
* @copyright 2011 Tauntons College, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/

$capabilities = array(

'block/course_appointments:book' => array(

'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
);
?>
14 changes: 6 additions & 8 deletions lang/en/block_course_appointments.php
Expand Up @@ -17,14 +17,13 @@

/**
* English Language Strings for course appointments block
*
* @package blocks
* @subpackage course_appointments
*
* @package block_course_appointments
* @author Mark Johnson <mark.johnson@tauntons.ac.uk>
* @copyright 2011 Tauntons College, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/

$string['pluginname'] = 'Appointments';
$string['pluginnameplural'] = 'Appointments';
$string['book'] = 'Book';
Expand All @@ -39,9 +38,8 @@
$string['notifytext'] = 'Hi {$a->student}
{$a->teacher} has booked an appointment to see you on {$a->date} at {$a->time}.
Please let {$a->teacher} know if you are unable to attend.';
$string['notifysms'] = '{$a->teacher} has booked an appointment to see you on {$a->date} at {$a->time}.
Please let them know if you are unable to attend.';
$string['notifysms'] = '{$a->teacher} has booked an appointment to see you on {$a->date} at
{$a->time}. Please let them know if you are unable to attend.';
$string['remindsms'] = 'Don\'t forget your appointment with {$a->name} at {$a->time} today.';
$string['pastdate'] = 'The time and date selected is in the past';
$string['studentdoesntexist'] = 'The selected student doesn\'t exist';
?>
54 changes: 28 additions & 26 deletions module.js
Expand Up @@ -16,34 +16,33 @@

/**
* Defines the Javascript module for the course appointments block
*
* @package blocks
* @subpackage course_appointments
*
* @package block_course_appointments
* @author Mark Johnson <mark.johnson@tauntons.ac.uk>
* @copyright 2010 Tauntons College, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/

M.block_course_appointments = {

/**
* Stores the calendar instance for access between runs of showcalendar()
* @var {Object} cal
*/
cal: false,

/**
* Stores the node for the date field so we can access and set the currently
* selected date.
*
*
* @var {Object} appointmentdate
*/
appointmentdate: {},

/**
* Module init function. Gets the button and date fields, and attaches event
* Module init function. Gets the button and date fields, and attaches event
* listers to them.
*
*
* @param {Object} Y
*/
init: function(Y) {
Expand All @@ -53,38 +52,41 @@ M.block_course_appointments = {
Y.on('click', this.showcalendar, Array(show, this.appointmentdate));
Y.on('focus', this.showcalendar, this.appointmentdate);
},

/**
* Responds to click events on the calendar button or date field, and displays the calendar.
*
*
* @param {Object} e
*/
showcalendar: function(e){
// This is a tad ugly. However YUI3 Doesn't have a calendar widget, so we need to use YUI2.

YUI().use('yui2-calendar', function(Y){
// Set up access to the YUI2 namespace, the block and the currently seelected date.
var YAHOO = Y.YUI2;
var now = new Date();
block = M.block_course_appointments;
var selected = new Date(block.appointmentdate.value);
// If this is the first time the event has run, we'll need to build and render the calendar.
// If this is the first time the event has run, we'll need to build and render the
// calendar.
if (!block.cal) {
// Set up the Calendar
// Set up the Calendar
block.cal = new YAHOO.widget.Calendar('block_courseappointments_calendarcontainer', {
iframe: false, // Turn iframe off, since container has iframe support.
hide_blank_weeks: true, // Enable, to demonstrate how we handle changing height, using changeContent
// Enable, to demonstrate how we handle changing height, using changeContent
hide_blank_weeks: true,
mindate: now,
selected: (selected.getMonth() + 1) + '/' + selected.getDate() + '/' + selected.getFullYear()
});
// Add an event listener to set the value of the date field and hide the calendar, when a date
// is selected.
// Add an event listener to set the value of the date field and hide the calendar,
// when a date is selected.
block.cal.selectEvent.subscribe(function(){
if (block.cal.getSelectedDates().length > 0) {

var selDate = block.cal.getSelectedDates()[0];

// Pretty Date Output, using Calendar's Loblock.cale values: Friday, 8 February 2008

// Pretty Date Output, using Calendar's Loblock.cale values: Friday,
// 8 February 2008
var dStr = selDate.getDate();
var mStr = block.cal.cfg.getProperty("MONTHS_SHORT")[selDate.getMonth()];
var yStr = selDate.getFullYear();
Expand All @@ -95,9 +97,9 @@ M.block_course_appointments = {
}
block.cal.hide();
});
// The calendar's container is absolutely positioned so that it overlays the block itself.
// This causes a bit of an issue if the calendar overflows the block region, so we'll extend
// the region to make sure it fits.
// The calendar's container is absolutely positioned so that it overlays the
// block itself. This causes a bit of an issue if the calendar overflows the block
// region, so we'll extend the region to make sure it fits.
block.cal.renderEvent.subscribe(function(){
var region = Y.one('.block_course_appointments').ancestor('.region-content');
region.setStyle('height', parseInt(region.getStyle('height').replace('px', '')) + 185);
Expand All @@ -107,8 +109,8 @@ M.block_course_appointments = {
// If we've already rendered the calendar, we just need to display it.
block.cal.show();
}
// Add an event listener to the document to hide the calendar if the user clicks outside the
// calendar's container, or the form row with the date controls on.
// Add an event listener to the document to hide the calendar if the user clicks
// outside the calendar's container, or the form row with the date controls on.
Y.on('click', function(e){
if (e.target.ancestor('#block_courseappointments_calendarcontainer', true) == null &&
e.target.ancestor('#block_courseappointments_daterow', true) == null) {
Expand Down
13 changes: 5 additions & 8 deletions process.php
Expand Up @@ -17,20 +17,19 @@

/**
* Processes the appointment form
*
*
* This page recieves the form from the course appointments block, passess the data
* to the validation method, and if all's well passess it on the the process method
* for insertion into the database. It then returns the user to the page displaying the block.
* If any errors were generated during validation, processing is skipped and the errors
* are stored in the session for display in the block.
*
* @package blocks
* @subpackage courseappointments
* @package block_course_appointments
* @author Mark Johnson <mark.johnson@tauntons.ac.uk>
* @copyright 2010 Tauntons College, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/

require_once('../../config.php');
require_login();
$courseid = required_param('courseid', PARAM_INT);
Expand All @@ -41,12 +40,10 @@
$SESSION->course_appointments = array();

if (isset($_POST['appointment_submit'])) {
if ($errors = $block->validate_form()) {
if ($errors = $block->validate_form()) {
$SESSION->course_appointments['errors'] = $errors;
} else {
$block->process_form();
}
}
redirect($CFG->wwwroot.'/course/view.php?id='.$courseid, '', 0);

?>
2 changes: 1 addition & 1 deletion styles.css
Expand Up @@ -17,7 +17,7 @@
Author: Mark Johnson <mark.johnson@tauntons.ac.uk>
Copyright 2011 Tauntons College, UK
Licence: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/

#block_courseappointments_calendarcontainer {
font-size: 9pt;
Expand Down
13 changes: 6 additions & 7 deletions version.php
@@ -1,4 +1,4 @@
<?php
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -19,16 +19,15 @@
* Standard plugin version file
*
* Defines the block's version and cron interval
*
* @package blocks
* @subpackage courseappointments
*
* @package block_course_appointments
* @author Mark Johnson <mark.johnson@tauntons.ac.uk>
* @copyright 2010 Tauntons College, UK
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
*/

$plugin->version = 2011030900;
$plugin->cron = 3600;$plugin->cron = 3600;
$plugin->cron = 3600;
$plugin->requires = 2010112400;
$plugin->component = 'block_course_appointments';
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit a448b9c

Please sign in to comment.