Skip to content

Commit

Permalink
MDL-19808 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 9fad7b2 commit 9146b97
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 deletions mod/forum/db/upgrade.php
Expand Up @@ -21,7 +21,7 @@
// before any action that may take longer time to finish.

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

$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
$result = true;
Expand All @@ -38,7 +38,7 @@ function xmldb_forum_upgrade($oldversion) {
if ($result && $oldversion < 2007101512) {

/// Cleanup the forum subscriptions
notify('Removing stale forum subscriptions', 'notifysuccess');
echo $OUTPUT->notification('Removing stale forum subscriptions', 'notifysuccess');

$roles = get_roles_with_capability('moodle/course:view', CAP_ALLOW);
$roles = array_keys($roles);
Expand Down Expand Up @@ -125,7 +125,7 @@ function xmldb_forum_upgrade($oldversion) {
$filepath = "$CFG->dataroot/$post->course/$CFG->moddata/forum/$post->forum/$post->id/$post->attachment";
if (!is_readable($filepath)) {
//file missing??
notify("File not readable, skipping: ".$filepath);
echo $OUTPUT->notification("File not readable, skipping: ".$filepath);
$post->attachment = '';
$DB->update_record('forum_posts', $post);
continue;
Expand All @@ -135,7 +135,7 @@ function xmldb_forum_upgrade($oldversion) {
$filearea = 'forum_attachment';
$filename = clean_param($post->attachment, PARAM_FILE);
if ($filename === '') {
notify("Unsupported post filename, skipping: ".$filepath);
echo $OUTPUT->notification("Unsupported post filename, skipping: ".$filepath);
$post->attachment = '';
$DB->update_record('forum_posts', $post);
continue;
Expand Down
10 changes: 5 additions & 5 deletions mod/forum/discuss.php
Expand Up @@ -21,7 +21,7 @@
}

if (!$forum = $DB->get_record('forum', array('id' => $discussion->forum))) {
notify("Bad forum ID stored in this discussion");
echo $OUTPUT->notification("Bad forum ID stored in this discussion");
}

if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
Expand Down Expand Up @@ -76,7 +76,7 @@
get_context_instance(CONTEXT_MODULE,$cmto->id));

if (!forum_move_attachments($discussion, $forum->id, $forumto->id)) {
notify("Errors occurred while moving attachment directories - check your file permissions");
echo $OUTPUT->notification("Errors occurred while moving attachment directories - check your file permissions");
}
$DB->set_field('forum_discussions', 'forum', $forumto->id, array('id' => $discussion->id));
$DB->set_field('forum_read', 'forumid', $forumto->id, array('discussionid' => $discussion->id));
Expand Down Expand Up @@ -229,16 +229,16 @@
$a = new object();
$a->blockafter = $forum->blockafter;
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
notify(get_string('thisforumisthrottled','forum',$a));
echo $OUTPUT->notification(get_string('thisforumisthrottled','forum',$a));
}

if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) &&
!forum_user_has_posted($forum->id,$discussion->id,$USER->id)) {
notify(get_string('qandanotify','forum'));
echo $OUTPUT->notification(get_string('qandanotify','forum'));
}

if ($move == -1 and confirm_sesskey()) {
notify(get_string('discussionmoved', 'forum', format_string($forum->name,true)));
echo $OUTPUT->notification(get_string('discussionmoved', 'forum', format_string($forum->name,true)));
}

$canrate = has_capability('mod/forum:rate', $modcontext);
Expand Down
32 changes: 16 additions & 16 deletions mod/forum/lib.php
Expand Up @@ -127,7 +127,7 @@ function forum_add_instance($forum) {
* @return bool success
*/
function forum_update_instance($forum) {
global $DB;
global $DB, $OUTPUT;

$forum->timemodified = time();
$forum->id = $forum->instance;
Expand All @@ -153,7 +153,7 @@ function forum_update_instance($forum) {
if ($forum->type == 'single') { // Update related discussion and post.
if (! $discussion = $DB->get_record('forum_discussions', array('forum'=>$forum->id))) {
if ($discussions = $DB->get_records('forum_discussions', array('forum'=>$forum->id), 'timemodified ASC')) {
notify('Warning! There is more than one discussion in this forum - using the most recent');
echo $OUTPUT->notification('Warning! There is more than one discussion in this forum - using the most recent');
$discussion = array_pop($discussions);
} else {
// try to recover by creating initial discussion - MDL-16262
Expand Down Expand Up @@ -2985,7 +2985,7 @@ function forum_subscribed_users($course, $forum, $groupid=0, $context = NULL) {
*/
function forum_get_course_forum($courseid, $type) {
// How to set up special 1-per-course forums
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

if ($forums = $DB->get_records_select("forum", "course = ? AND type = ?", array($courseid, $type), "id ASC")) {
// There should always only be ONE, but with the right combination of
Expand Down Expand Up @@ -3016,7 +3016,7 @@ function forum_get_course_forum($courseid, $type) {
$forum->forcesubscribe = 0;
break;
default:
notify("That forum type doesn't exist!");
echo $OUTPUT->notification("That forum type doesn't exist!");
return false;
break;
}
Expand All @@ -3025,7 +3025,7 @@ function forum_get_course_forum($courseid, $type) {
$forum->id = $DB->insert_record("forum", $forum);

if (! $module = $DB->get_record("modules", array("name" => "forum"))) {
notify("Could not find forum module!!");
echo $OUTPUT->notification("Could not find forum module!!");
return false;
}
$mod = new object();
Expand All @@ -3034,15 +3034,15 @@ function forum_get_course_forum($courseid, $type) {
$mod->instance = $forum->id;
$mod->section = 0;
if (! $mod->coursemodule = add_course_module($mod) ) { // assumes course/lib.php is loaded
notify("Could not add a new course module to the course '" . format_string($course->fullname) . "'");
echo $OUTPUT->notification("Could not add a new course module to the course '" . format_string($course->fullname) . "'");
return false;
}
if (! $sectionid = add_mod_to_section($mod) ) { // assumes course/lib.php is loaded
notify("Could not add the new course module to that section");
echo $OUTPUT->notification("Could not add the new course module to that section");
return false;
}
if (! $DB->set_field("course_modules", "section", $sectionid, array("id" => $mod->coursemodule))) {
notify("Could not update the course module with the correct section");
echo $OUTPUT->notification("Could not update the course module with the correct section");
return false;
}
include_once("$CFG->dirroot/course/lib.php");
Expand Down Expand Up @@ -4154,12 +4154,12 @@ function forum_print_mode_form($id, $mode, $forumtype='') {
* @return string
*/
function forum_search_form($course, $search='') {
global $CFG;
global $CFG, $OUTPUT;

$output = '<div class="forumsearch">';
$output .= '<form action="'.$CFG->wwwroot.'/mod/forum/search.php" style="display:inline">';
$output .= '<fieldset class="invisiblefieldset">';
$output .= helpbutton('search', get_string('search'), 'moodle', true, false, '', true);
$output .= $OUTPUT->help_icon(moodle_help_icon::make('search', get_string('search')));
$output .= '<input name="search" type="text" size="18" value="'.s($search, true).'" alt="search" />';
$output .= '<input value="'.get_string('searchforums', 'forum').'" type="submit" />';
$output .= '<input name="id" type="hidden" value="'.$course->id.'" />';
Expand Down Expand Up @@ -5502,9 +5502,9 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=-1, $di
} else if ($groupmode and has_capability('mod/forum:startdiscussion', $context)) {
// inform users why they can not post new discussion
if ($currentgroup) {
notify(get_string('cannotadddiscussion', 'forum'));
echo $OUTPUT->notification(get_string('cannotadddiscussion', 'forum'));
} else {
notify(get_string('cannotadddiscussionall', 'forum'));
echo $OUTPUT->notification(get_string('cannotadddiscussionall', 'forum'));
}
}

Expand Down Expand Up @@ -7351,7 +7351,7 @@ function forum_get_separate_modules($courseid) {
* @return bool
*/
function forum_check_throttling($forum, $cm=null) {
global $USER, $CFG, $DB;
global $USER, $CFG, $DB, $OUTPUT;

if (is_numeric($forum)) {
$forum = $DB->get_record('forum',array('id'=>$forum));
Expand Down Expand Up @@ -7397,7 +7397,7 @@ function forum_check_throttling($forum, $cm=null) {
print_error('forumblockingtoomanyposts', 'error', $CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id, $a);
}
if ($forum->warnafter <= $numposts) {
notify(get_string('forumblockingalmosttoomanyposts','forum',$a));
echo $OUTPUT->notification(get_string('forumblockingalmosttoomanyposts','forum',$a));
}


Expand Down Expand Up @@ -7616,7 +7616,7 @@ function forum_reset_course_form_defaults($course) {
function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
$studentroles=array(), $guestroles=array(), $cmid=NULL) {

global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

if (!isset($forum->open) && !isset($forum->assesspublic)) {
// We assume that this forum has already been converted to use the
Expand Down Expand Up @@ -7712,7 +7712,7 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
if (empty($cmid)) {
// We were not given the course_module id. Try to find it.
if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
notify('Could not get the course module for the forum');
echo $OUTPUT->notification('Could not get the course module for the forum');
return false;
} else {
$cmid = $cm->id;
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/post.php
Expand Up @@ -775,7 +775,7 @@
&& !has_capability('mod/forum:viewqandawithoutposting', $modcontext)
&& !empty($discussion->id)
&& !forum_user_has_posted($forum->id, $discussion->id, $USER->id)) {
notify(get_string('qandanotify','forum'));
echo $OUTPUT->notification(get_string('qandanotify','forum'));
}

forum_check_throttling($forum, $cm);
Expand Down
6 changes: 3 additions & 3 deletions mod/forum/search.php
Expand Up @@ -249,9 +249,9 @@
function forum_print_big_search_form($course) {
global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT;

print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro');
echo $OUTPUT->box(get_string('searchforumintro', 'forum'), 'searchbox boxaligncenter', 'intro');

print_simple_box_start("center");
echo $OUTPUT->box_start('generalbox boxaligncenter');

echo $PAGE->requires->js('mod/forum/forum.js')->asap();

Expand Down Expand Up @@ -358,7 +358,7 @@ function forum_print_big_search_form($course) {
echo $PAGE->requires->js_function_call('lockoptions_timetoitems')->asap();
echo $PAGE->requires->js_function_call('lockoptions_timefromitems')->asap();

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

/**
Expand Down
4 changes: 2 additions & 2 deletions mod/forum/subscribers.php
Expand Up @@ -145,11 +145,11 @@
}
}

print_simple_box_start('center');
echo $OUTPUT->box_start('generalbox boxaligncenter');

include('subscriber.html');

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

echo $OUTPUT->footer();

Expand Down
4 changes: 2 additions & 2 deletions mod/forum/unsubscribeall.php
Expand Up @@ -25,7 +25,7 @@
$DB->delete_records('forum_subscriptions', array('userid'=>$USER->id));
$DB->set_field('user', 'autosubscribe', 0, array('id'=>$USER->id));
echo $OUTPUT->box(get_string('unsubscribealldone', 'forum'));
print_continue($return);
echo $OUTPUT->continue_button($return);
echo $OUTPUT->footer();
die;

Expand All @@ -40,7 +40,7 @@

} else {
echo $OUTPUT->box(get_string('unsubscribeallempty', 'forum'));
print_continue($return);
echo $OUTPUT->continue_button($return);
echo $OUTPUT->footer();
die;
}
Expand Down
12 changes: 6 additions & 6 deletions mod/forum/view.php
Expand Up @@ -135,7 +135,7 @@
$streveryoneisnowsubscribed = get_string('everyoneisnowsubscribed', 'forum');
$strallowchoice = get_string('allowchoice', 'forum');
echo '<span class="helplink">' . get_string("forcessubscribe", 'forum') . '</span><br />';
helpbutton("subscription", $strallowchoice, "forum");
echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strallowchoice, "forum"));
echo '&nbsp;<span class="helplink">';
if (has_capability('mod/forum:managesubscriptions', $context)) {
echo "<a title=\"$strallowchoice\" href=\"subscribe.php?id=$forum->id&amp;force=no\">$strallowchoice</a>";
Expand All @@ -147,13 +147,13 @@
} else if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
$strsubscriptionsoff = get_string('disallowsubscribe','forum');
echo $strsubscriptionsoff;
helpbutton("subscription", $strsubscriptionsoff, "forum");
echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strsubscriptionsoff, "forum"));
} else {
$streveryonecannowchoose = get_string("everyonecannowchoose", "forum");
$strforcesubscribe = get_string("forcesubscribe", "forum");
$strshowsubscribers = get_string("showsubscribers", "forum");
echo '<span class="helplink">' . get_string("allowsallsubscribe", 'forum') . '</span><br />';
helpbutton("subscription", $strforcesubscribe, "forum");
echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strforcesubscribe, "forum"));
echo '&nbsp;';

if (has_capability('mod/forum:managesubscriptions', $context)) {
Expand Down Expand Up @@ -209,18 +209,18 @@
if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
$a->blockafter = $forum->blockafter;
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
notify(get_string('thisforumisthrottled','forum',$a));
echo $OUTPUT->notification(get_string('thisforumisthrottled','forum',$a));
}

if ($forum->type == 'qanda' && !has_capability('moodle/course:manageactivities', $context)) {
notify(get_string('qandanotify','forum'));
echo $OUTPUT->notification(get_string('qandanotify','forum'));
}

switch ($forum->type) {
case 'single':
if (! $discussion = $DB->get_record("forum_discussions", array("forum" => $forum->id))) {
if ($discussions = $DB->get_records("forum_discussions", array("forum" => $forum->id), "timemodified ASC")) {
notify("Warning! There is more than one discussion in this forum - using the most recent");
echo $OUTPUT->notification("Warning! There is more than one discussion in this forum - using the most recent");
$discussion = array_pop($discussions);
} else {
print_error('nodiscussions', 'forum');
Expand Down

0 comments on commit 9146b97

Please sign in to comment.