Skip to content

Commit

Permalink
Various little fixes to remove warnings (usually about empty variables)
Browse files Browse the repository at this point in the history
when error_reporting is turned up to 15 or so ... more of these to come ...
  • Loading branch information
moodler committed Dec 29, 2002
1 parent a900458 commit 9c9f7d7
Show file tree
Hide file tree
Showing 28 changed files with 1,600 additions and 65 deletions.
1,466 changes: 1,466 additions & 0 deletions CHANGES

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions admin/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@
if (!isset($config)) {
$config = $CFG;
}
if (!isset($focus)) {
$focus = "";
}

$stradmin = get_string("administration");
$strconfigvariables = get_string("configvariables");

if ($site) {
print_header("$site->shortname: $strconfigvariables", "$site->fullname",
"<A HREF=\"index.php\">$stradmin</A> -> $strconfigvariables", "$focus");
print_header("$site->shortname: $strconfigvariables", $site->fullname,
"<A HREF=\"index.php\">$stradmin</A> -> $strconfigvariables", $focus);
print_heading($strconfigvariables);
} else {
print_header();
Expand Down
8 changes: 4 additions & 4 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
}
print_continue("index.php");
print_simple_box_start("CENTER");
include("$CFG->dirroot/doc/release.html");
include("$CFG->dirroot/lang/en/docs/release.html");
print_simple_box_end();
print_continue("index.php");
exit;
Expand Down Expand Up @@ -192,7 +192,7 @@
}

} else { // module not installed yet, so install it
if (!$updated_modules) {
if (!empty($updated_modules)) {
$strmodulesetup = get_string("modulesetup");
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup);
}
Expand All @@ -214,7 +214,7 @@
}
}

if ($updated_modules) {
if (!empty($updated_modules)) {
print_continue("index.php");
die;
}
Expand All @@ -235,7 +235,7 @@

/// If any new configurations were found then send to the config page to check

if ($configchange) {
if (!empty($configchange)) {
redirect("config.php");
}

Expand Down
2 changes: 1 addition & 1 deletion admin/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function lang_save_file($path, $file, $strings) {
$value = str_replace("\\","",$value); // Delete all slashes
$value = str_replace("$"."a", "\\$"."a", $value); // Add slashes for $a
$value = str_replace("\"", "\\\"", $value); // Add slashes for "
if ($id == "string"){
if ($id == "string" and $value != ""){
fwrite($f,"\$string['$stringname'] = \"$value\";\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion course/grades.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


/// Collect modules data
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);


/// Search through all the modules, pulling out grade data
Expand Down
4 changes: 2 additions & 2 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function print_recent_activity($course) {
}
}

if ($changelist) {
if (!empty($changelist)) {
foreach ($changelist as $changeinfo => $change) {
if ($change) {
$changes[$changeinfo] = $change;
Expand Down Expand Up @@ -473,7 +473,7 @@ function print_section_block($heading, $course, $section, $mods, $modnames, $mod
$moddata[] = "<a title=\"$mod->modfullname\" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a><BR>$editbuttons";
}
}
if (isediting($site->id)) {
if (isediting($course->id)) {
$editmenu = popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=0&add=",
$modnames, "section0", "", get_string("add")."...", "mods", get_string("activities"), true);
$editmenu = "<DIV ALIGN=right>$editmenu</DIV>";
Expand Down
2 changes: 1 addition & 1 deletion course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}
echo "</TR></TABLE>";

get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);

switch ($mode) {
case "todaylogs" :
Expand Down
28 changes: 17 additions & 11 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,25 @@

add_to_log($course->id, "course", "view", "view.php?id=$course->id", "$course->id");

if ( isteacher($course->id) ) {
if ($edit == "on") {
$USER->editing = true;
} else if ($edit == "off") {
$USER->editing = false;
if (isset($edit)) {
if (isteacher($course->id)) {
if ($edit == "on") {
$USER->editing = true;
} else if ($edit == "off") {
$USER->editing = false;
}
save_session("USER");
}
}
if ($help == "on") {
$USER->help = true;
} else if ($help == "off") {
$USER->help = false;

if (isset($help)) {
if ($help == "on") {
$USER->help = true;
} else if ($help == "off") {
$USER->help = false;
}
save_session("USER");
}
save_session("USER");

$SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
save_session("SESSION");
Expand All @@ -53,7 +59,7 @@
print_header("$courseword: $course->fullname", "$course->fullname", "$course->shortname", "search.search", "", true,
update_course_icon($course->id));

get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused, $modsectioncounts);
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);

if (! $sections = get_all_sections($course->id)) {
$section->course = $course->id; // Create a default section.
Expand Down
2 changes: 1 addition & 1 deletion course/weeks.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$week&add=",
$modnames, "section$week", "", "$stradd...", "mods", $stractivities);
$modnames, "section$week", "", "$stradd...");
echo "</DIV>";
}

Expand Down
4 changes: 3 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
true, "", $headerbutton);

$firstcolumn = false; // for now
$side = 175;

?>
Expand All @@ -38,7 +39,8 @@

if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {

echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>";
$firstcolumn=true;

if ($sections[0]->sequence or isediting($site->id)) {
get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
Expand Down
1 change: 1 addition & 0 deletions lang/en/docs/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ I would suggest that you:
MOST IMPORTANT
|-------------------
|
| - files.php
| - install.html
| - upgrade.html
|
Expand Down
4 changes: 3 additions & 1 deletion lang/en/docs/release.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ <H3> New in Moodle 1.0.8 (due 1st January, 2003): </H3>
Arabic (from Ahmed Nabil), Turkish (from M. Cüneyt Birkök) and Swedish (from Set Lonnert). Many thanks
to these guys! All other languages have also had updates and fixes since 1.0.7.
The language editor has been improved slightly, making it easier to see
new strings and empty strings that need translating.</DD>
new strings and empty strings that need translating. All documentation is
now able to be localised and will appear in the current language if
translated versions exist.</DD>

<DT> Themes </DT>
<DD> Theme support of CSS has been extended to give theme makers more control
Expand Down
1 change: 1 addition & 0 deletions lib/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"proxyhost" => "",
"proxyport" => "",
"maxeditingtime" => 1800,
"changepassword" => true,
"country" => "",
"guestloginbutton" => 1
);
Expand Down
13 changes: 12 additions & 1 deletion lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ function format_time($totalsecs, $str=NULL) {
$sh = ($hours == 1) ? $str->hour : $str->hours;
$sd = ($days == 1) ? $str->day : $str->days;

$odays = "";
$ohours = "";
$omins = "";
$osecs = "";

if ($days) $odays = "$days $sd";
if ($hours) $ohours = "$hours $sh";
if ($mins) $omins = "$mins $sm";
Expand Down Expand Up @@ -268,7 +273,7 @@ function require_login($courseid=0) {

// Next, check if the user can be in a particular course
if ($courseid) {
if ($USER->student[$courseid] || $USER->teacher[$courseid] || $USER->admin) {
if (!empty($USER->student[$courseid]) or !empty($USER->teacher[$courseid]) or !empty($USER->admin)) {
if (isset($USER->realuser)) { // Make sure the REAL person can also access this course
if (!isteacher($courseid, $USER->realuser)) {
print_header();
Expand Down Expand Up @@ -416,6 +421,9 @@ function isediting($courseid, $user=NULL) {
if (!$user){
$user = $USER;
}
if (empty($user->editing)) {
return false;
}
return ($user->editing and isteacher($courseid, $user->id));
}

Expand Down Expand Up @@ -770,6 +778,9 @@ function make_mod_upload_directory($courseid) {

function valid_uploaded_file($newfile) {
/// Returns current name of file on disk if true
if (empty($newfile)) {
return "";
}
if (is_uploaded_file($newfile['tmp_name']) and $newfile['size'] > 0) {
return $newfile['tmp_name'];
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class object {};
/// then use the one from the default language. Otherwise (and this is the
/// majority of cases), use the stored locale specified by admin.

if ($USER->lang and ($USER->lang != $CFG->lang) ) {
if (!empty($USER->lang) and ($USER->lang != $CFG->lang) ) {
$CFG->locale = get_string("locale");
} else if (!$CFG->locale) {
} else if (empty($CFG->locale)) {
$CFG->locale = get_string("locale");
set_config("locale", $CFG->locale); // cache it to save lookups in future
}
Expand Down
13 changes: 8 additions & 5 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ function choose_from_menu ($options, $name, $selected="", $nothing="choose", $sc

if ($script) {
$javascript = "onChange=\"$script\"";
} else {
$javascript = "";
}

$output = "<SELECT NAME=$name $javascript>\n";
if ($nothing) {
$output .= " <OPTION VALUE=\"$nothingvalue\"\n";
Expand Down Expand Up @@ -338,14 +341,14 @@ function popup_form ($common, $options, $formname, $selected="", $nothing="choos
}
}
$output .= "</SELECT>";
if (!$return and $help) {
helpbutton($help, $helptext);
}
$output .= "</FORM>\n";

if ($return) {
return $output;
} else {
if ($help) {
helpbutton($help, $helptext);
}
echo $output;
}
}
Expand Down Expand Up @@ -612,7 +615,7 @@ function print_footer ($course=NULL) {
$realuserinfo = "";
}

if ($USER->id) {
if (isset($USER->id) and $USER->id) {
$username = "<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\">$USER->firstname $USER->lastname</A>";
$loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
" (<A HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A>)";
Expand Down Expand Up @@ -889,7 +892,7 @@ function update_course_icon($courseid) {
global $CFG, $USER;

if (isteacher($courseid)) {
if ($USER->editing) {
if (!empty($USER->editing)) {
$string = get_string("turneditingoff");
$edit = "off";
} else {
Expand Down
10 changes: 8 additions & 2 deletions login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,21 @@
}


if (empty($errormsg)) {
$errormsg = "";
}

if (empty($SESSION->wantsurl)) {
$SESSION->wantsurl = $HTTP_REFERER;
save_session("SESSION");
}

if (!$frm->username)
if (empty($frm->username)) {
$frm->username = get_moodle_cookie();
$frm->password = "";
}

if ($frm->username) {
if (!empty($frm->username)) {
$focus = "form.password";
} else {
$focus = "form.username";
Expand Down
7 changes: 6 additions & 1 deletion mod/assignment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@
}
$due = userdate($assignment->timedue);
$link = "<A HREF=\"view.php?id=$assignment->coursemodule\">$assignment->name</A>";
if ($assignment->section) {
$section = "$assignment->section";
} else {
$section = "";
}

if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($assignment->section, $link, $due, $submitted);
$table->data[] = array ($section, $link, $due, $submitted);
} else {
$table->data[] = array ($link, $due, $submitted);
}
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/discuss.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

$navmiddle = "<A HREF=\"../forum/index.php?id=$course->id\">".get_string("forums", "forum")."</A> -> <A HREF=\"../forum/view.php?f=$forum->id\">$forum->name</A>";

$searchform = forum_print_search_form($course, $search, true, "plain");
$searchform = forum_print_search_form($course, "", true, "plain");

if ($course->category) {
print_header("$course->shortname: $discussion->name", "$course->fullname",
Expand Down
6 changes: 3 additions & 3 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ function forum_set_return() {
function forum_go_back_to($default) {
global $SESSION;

if ($SESSION->fromdiscussion) {
if (!empty($SESSION->fromdiscussion)) {
$returnto = $SESSION->fromdiscussion;
unset($SESSION->fromdiscussion);
save_session("SESSION");
Expand Down Expand Up @@ -1467,7 +1467,7 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $f
echo get_string("olderdiscussions", "forum")."</A> ...</P>";
break;
}
if ($replies[$discussion->discussion]) {
if (!empty($replies[$discussion->discussion])) {
$discussion->replies = $replies[$discussion->discussion]->replies;
} else {
$discussion->replies = 0;
Expand Down Expand Up @@ -1624,7 +1624,7 @@ function forum_set_display_mode($mode=0) {
if ($mode) {
$USER->mode = $mode;
save_session("USER");
} else if (!$USER->mode) {
} else if (empty($USER->mode)) {
$USER->mode = $FORUM_DEFAULT_DISPLAY_MODE;
save_session("USER");
}
Expand Down
Loading

0 comments on commit 9c9f7d7

Please sign in to comment.