Skip to content

Commit

Permalink
MDL-19795 Upgraded calls to helpbutton, print_simple_box* and notify
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Aug 18, 2009
1 parent e6db302 commit c60e66a
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 49 deletions.
8 changes: 4 additions & 4 deletions enrol/authorize/config_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<tr valign="top">
<td align="right">an_authcode:</td>
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->an_authcode)), 'an_authcode'); ?>
<?php helpbutton('authcode', 'authcode', 'enrol/authorize'); ?><br />
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('authcode', 'authcode', 'enrol/authorize')); ?><br />
<?php print_string("adminauthcode", "enrol_authorize") ?></td>
</tr>

Expand Down Expand Up @@ -177,20 +177,20 @@
</tr>

<tr valign="top"><td colspan="2"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?>
<?php helpbutton('orderreview', 'orderreview', 'enrol/authorize'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('orderreview', 'orderreview', 'enrol/authorize')); ?>
</h4></td></tr>

<tr valign="top">
<td align="right">an_review:</td>
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->an_review)), 'an_review'); ?>
<?php helpbutton('review', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol/authorize'); ?><br />
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('review', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol/authorize')); ?><br />
<?php print_string("adminreview", "enrol_authorize") ?></td>
</tr>

<tr valign="top">
<td align="right">an_capture_day:</td>
<td><input type="text" name="an_capture_day" size="2" maxlength="2" value="<?php p($frm->an_capture_day) ?>" />
<?php helpbutton('captureday', get_string('adminhelpcapturetitle', 'enrol_authorize'), 'enrol/authorize'); ?><br />
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('captureday', get_string('adminhelpcapturetitle', 'enrol_authorize'), 'enrol/authorize')); ?><br />
<?php print_string("reviewday", "enrol_authorize", $frm->an_capture_day) ?></td>
</tr>

Expand Down
4 changes: 2 additions & 2 deletions enrol/authorize/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// before any action that may take longer time to finish.

function xmldb_enrol_authorize_upgrade($oldversion) {
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

$dbman = $DB->get_manager();
$result = true;
Expand All @@ -31,7 +31,7 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
if ($result && $oldversion < 2008020500 && is_enabled_enrol('authorize')) {
require_once($CFG->dirroot.'/enrol/authorize/localfuncs.php');
if (!check_curl_available()) {
notify("You are using the authorize.net enrolment plugin for payment handling but cUrl is not available.
echo $OUTPUT->notification("You are using the authorize.net enrolment plugin for payment handling but cUrl is not available.
PHP must be compiled with cURL+SSL support (--with-curl --with-openssl)");
}

Expand Down
21 changes: 10 additions & 11 deletions enrol/authorize/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,32 +453,31 @@ public function get_access_icons($course)
* @param object $frm
* @access public
*/
public function config_form($frm)
{
global $CFG, $DB;
public function config_form($frm) {
global $CFG, $DB, $OUTPUT;
$mconfig = get_config('enrol/authorize');

if (!check_curl_available()) {
notify('PHP must be compiled with cURL+SSL support (--with-curl --with-openssl)');
echo $OUTPUT->notification('PHP must be compiled with cURL+SSL support (--with-curl --with-openssl)');
}

if (empty($CFG->loginhttps) and substr($CFG->wwwroot, 0, 5) !== 'https') {
$a = new stdClass;
$a->url = "$CFG->wwwroot/$CFG->admin/settings.php?section=httpsecurity";
notify(get_string('adminconfighttps', 'enrol_authorize', $a));
echo $OUTPUT->notification(get_string('adminconfighttps', 'enrol_authorize', $a));
return; // notice breaks the form and xhtml later
}
elseif (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 443) { // MDL-9836
$wwwsroot = qualified_me();
$wwwsroot = str_replace('http:', 'https:', $wwwsroot);
$a = new stdClass;
$a->url = $wwwsroot;
notify(get_string('adminconfighttpsgo', 'enrol_authorize', $a));
echo $OUTPUT->notification(get_string('adminconfighttpsgo', 'enrol_authorize', $a));
return; // notice breaks the form and xhtml later
}

if (optional_param('verifyaccount', 0, PARAM_INT)) {
notify(authorize_verify_account());
echo $OUTPUT->notification(authorize_verify_account());
}

if (!empty($frm->an_review)) {
Expand All @@ -487,7 +486,7 @@ public function config_form($frm)
if ($captureday > 0 || $emailexpired > 0) {
$lastcron = $DB->get_field_sql('SELECT max(lastcron) FROM {modules}');
if ((time() - intval($lastcron) > 3600 * 24)) {
notify(get_string('admincronsetup', 'enrol_authorize'));
echo $OUTPUT->notification(get_string('admincronsetup', 'enrol_authorize'));
}
}
}
Expand All @@ -496,15 +495,15 @@ public function config_form($frm)
$a = new stdClass;
$a->count = $count;
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=".AN_STATUS_AUTH;
notify(get_string('adminpendingorders', 'enrol_authorize', $a));
echo $OUTPUT->notification(get_string('adminpendingorders', 'enrol_authorize', $a));
}

if (data_submitted()) {
if (empty($mconfig->an_login)) {
notify("an_login required");
echo $OUTPUT->notification("an_login required");
}
if (empty($mconfig->an_tran_key) && empty($mconfig->an_password)) {
notify("an_tran_key or an_password required");
echo $OUTPUT->notification("an_tran_key or an_password required");
}
}

Expand Down
8 changes: 4 additions & 4 deletions enrol/database/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ function setup_enrolments(&$user) {
* used.
*/
function sync_enrolments($role = null) {
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;
error_reporting(E_ALL);

// Connect to the external database
$enroldb = $this->enrol_connect();
if (!$enroldb) {
notify("enrol/database cannot connect to server");
echo $OUTPUT->notification("enrol/database cannot connect to server");
return false;
}

Expand Down Expand Up @@ -554,7 +554,7 @@ function process_config($config) {
// you will want to call fix_course_sortorder() after your are done
// with course creation
function create_course ($course,$skip_fix_course_sortorder=0){
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

// define a template
if (!empty($CFG->enrol_db_template)){
Expand Down Expand Up @@ -616,7 +616,7 @@ function create_course ($course,$skip_fix_course_sortorder=0){
add_to_log($newcourseid, "course", "new", "view.php?id=$newcourseid", "enrol/database auto-creation");
} else {
trigger_error("Could not create new course $extcourse from from database");
notify("Serious Error! Could not create the new course!");
echo $OUTPUT->notification("Serious Error! Could not create the new course!");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions enrol/enrol.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class enrolment_factory {
function factory($enrol = '') {
global $CFG;
global $CFG, $OUTPUT;
if (!$enrol) {
$enrol = $CFG->enrol;
}
Expand All @@ -16,7 +16,7 @@ function factory($enrol = '') {
return new $class;
} else {
trigger_error("$CFG->dirroot/enrol/$enrol/enrol.php does not exist");
notify("Enrolment file $enrol/enrol.php does not exist");
echo $OUTPUT->notification("Enrolment file $enrol/enrol.php does not exist");
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions enrol/imsenterprise/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<input type="checkbox" value="1" name="enrol_createnewusers" <?php if ($frm->enrol_createnewusers) echo "checked=\"checked\"" ?> />
</td>
<td>
<?php helpbutton('createnewusers', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('createnewusers', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand All @@ -48,7 +48,7 @@
<input type="checkbox" value="1" name="enrol_imsdeleteusers" <?php if ($frm->enrol_imsdeleteusers) echo "checked=\"checked\"" ?> />
</td>
<td>
<?php helpbutton('deleteusers', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('deleteusers', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand Down Expand Up @@ -78,7 +78,7 @@
<input type="checkbox" value="1" name="enrol_imssourcedidfallback" <?php if ($frm->enrol_imssourcedidfallback) echo "checked=\"checked\"" ?> />
</td>
<td>
<?php helpbutton('sourceddidfallback', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('sourceddidfallback', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>
<!--
Expand Down Expand Up @@ -138,7 +138,7 @@
<input type="text" <?php echo 'value="'.intval($frm->enrol_truncatecoursecodes).'"' ?> name="enrol_truncatecoursecodes" size="3" maxlength="3" />
</td>
<td>
<?php helpbutton('truncatecoursecodes', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('truncatecoursecodes', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand All @@ -148,7 +148,7 @@
<input type="checkbox" value="1" name="enrol_createnewcourses" <?php if ($frm->enrol_createnewcourses) echo "checked=\"checked\"" ?> />
</td>
<td>
<?php helpbutton('createnewcourses', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('createnewcourses', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand All @@ -158,7 +158,7 @@
<input type="checkbox" value="1" name="enrol_createnewcategories" <?php if ($frm->enrol_createnewcategories) echo "checked=\"checked\"" ?> />
</td>
<td>
<?php helpbutton('categorisation', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('categorisation', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand All @@ -168,7 +168,7 @@
<input type="checkbox" value="1" name="enrol_imsunenrol" <?php if ($frm->enrol_imsunenrol) echo "checked=\"checked\"" ?> />
</td>
<td>
<?php helpbutton('unenrol', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('unenrol', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand All @@ -180,7 +180,7 @@
<td align="right"><?php print_string('restricttarget', 'enrol_imsenterprise') ?>:</td>
<td colspan="2">
<input type="text" <?php echo 'value="'.htmlspecialchars($frm->enrol_imsrestricttarget).'"' ?> name="enrol_imsrestricttarget" size="20" maxlength="32" />
<?php helpbutton('target', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('target', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand All @@ -190,7 +190,7 @@
<input type="checkbox" value="1" name="enrol_imscapitafix" <?php if ($frm->enrol_imscapitafix) echo "checked=\"checked\"" ?> />
</td>
<td>
<?php helpbutton('capita', 'More detail about this option', 'enrol/imsenterprise'); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('capita', 'More detail about this option', 'enrol/imsenterprise')); ?>
</td>
</tr>

Expand Down
26 changes: 13 additions & 13 deletions enrol/ldap/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class enrolment_plugin_ldap {
* This function syncs a user's enrolments with those on the LDAP server.
*/
function setup_enrolments(&$user) {
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

//error_log('[ENROL_LDAP] setup_enrolments called');

// Connect to the external database
$ldap_connection = $this->enrol_ldap_connect();
if (!$ldap_connection) {
@ldap_close($ldap_connection);
notify("[ENROL_LDAP] LDAP-module cannot connect to server: {$CFG->enrol_ldap_host_url}");
echo $OUTPUT->notification("[ENROL_LDAP] LDAP-module cannot connect to server: {$CFG->enrol_ldap_host_url}");
return false;
}

Expand Down Expand Up @@ -119,20 +119,20 @@ function setup_enrolments(&$user) {

/// sync enrolments with ldap, create courses if required.
function sync_enrolments($type, $enrol = false) {
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

// Get the role. If it doesn't exist, that is bad.
$role = $DB->get_record('role', array('shortname'=>$type));
if (!$role) {
notify("No such role: $type");
echo $OUTPUT->notification("No such role: $type");
return false;
}

// Connect to the external database
$ldap_connection = $this->enrol_ldap_connect();
if (!$ldap_connection) {
@ldap_close($ldap_connection);
notify("LDAP-module cannot connect to server: $CFG->ldap_host_url");
echo $OUTPUT->notification("LDAP-module cannot connect to server: $CFG->ldap_host_url");
return false;
}

Expand Down Expand Up @@ -416,7 +416,7 @@ function process_config($config) {

function enrol_ldap_connect(){
/// connects to ldap-server
global $CFG;
global $CFG, $OUTPUT;

$result = ldap_connect($CFG->enrol_ldap_host_url);

Expand All @@ -430,14 +430,14 @@ function enrol_ldap_connect(){
$CFG->enrol_ldap_bind_dn,
$CFG->enrol_ldap_bind_pw );
if (!$bind) {
notify("Error in binding to LDAP server");
echo $OUTPUT->notification("Error in binding to LDAP server");
trigger_error("Error in binding to LDAP server $!");
}

}
return $result;
} else {
notify("LDAP-module cannot connect to server: $CFG->enrol_ldap_host_url");
echo $OUTPUT->notification("LDAP-module cannot connect to server: $CFG->enrol_ldap_host_url");
return false;
}
}
Expand All @@ -446,19 +446,19 @@ function enrol_ldap_bind($ldap_connection){
/// makes bind to ldap for searching users
/// uses ldap_bind_dn or anonymous bind

global $CFG;
global $CFG, $OUTPUT;

if ( ! empty($CFG->enrol_ldap_bind_dn) ){
//bind with search-user
if (!ldap_bind($ldap_connection, $CFG->enrol_ldap_bind_dn,$CFG->enrol_ldap_bind_pw)){
notify("Error: could not bind ldap with ldap_bind_dn/pw");
echo $OUTPUT->notification("Error: could not bind ldap with ldap_bind_dn/pw");
return false;
}

} else {
//bind anonymously
if ( !ldap_bind($ldap_connection)){
notify("Error: could not bind ldap anonymously");
echo $OUTPUT->notification("Error: could not bind ldap anonymously");
return false;
}
}
Expand Down Expand Up @@ -547,7 +547,7 @@ function find_ext_enrolments ($ldap_connection, $memberuid, $role){
// you will want to call fix_course_sortorder() after your are done
// with course creation
function create_course ($course_ext,$skip_fix_course_sortorder=0){
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

// override defaults with template course
if (!empty($CFG->enrol_ldap_template)){
Expand Down Expand Up @@ -602,7 +602,7 @@ function create_course ($course_ext,$skip_fix_course_sortorder=0){
add_to_log($newcourseid, "course", "new", "view.php?id=$newcourseid", "enrol/ldap auto-creation");
} else {
error_log("Could not create new course from LDAP from DN:" . $course_ext['dn']);
notify("Serious Error! Could not create the new course!");
echo $OUTPUT->notification("Serious Error! Could not create the new course!");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions enrol/mnet/allowed_courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@


// output the form
print_simple_box_start('center','90%','','20');
echo $OUTPUT->box_start();

?>
<div class="allowedcoursesdiv">
Expand Down Expand Up @@ -249,7 +249,7 @@
</div>
<?php

print_simple_box_end();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();

?>
4 changes: 2 additions & 2 deletions enrol/paypal/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function print_entry($course) {
echo $OUTPUT->heading(get_string('costorkey', 'enrol_paypal'));
}

print_simple_box_start("center");
echo $OUTPUT->box_end();

if ($USER->username == 'guest') { // force login only for guest user, not real users with guest role
if (empty($CFG->loginhttps)) {
Expand All @@ -68,7 +68,7 @@ function print_entry($course) {
include($CFG->dirroot.'/enrol/paypal/enrol.html');
}

print_simple_box_end();
echo $OUTPUT->box_end();

if ($course->password) { // Second option
$password = '';
Expand Down

0 comments on commit c60e66a

Please sign in to comment.