Various little fixes to remove warnings (usually about empty variables)

when error_reporting is turned up to 15 or so ... more of these to come ...
This commit is contained in:
moodler 2002-12-29 17:32:32 +00:00
parent a900458749
commit 9c9f7d7790
28 changed files with 1600 additions and 65 deletions

1466
CHANGES

File diff suppressed because it is too large Load Diff

View File

@ -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();

View File

@ -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;
@ -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);
}
@ -214,7 +214,7 @@
}
}
if ($updated_modules) {
if (!empty($updated_modules)) {
print_continue("index.php");
die;
}
@ -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");
}

View File

@ -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");
}
}

View File

@ -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

View File

@ -342,7 +342,7 @@ function print_recent_activity($course) {
}
}
if ($changelist) {
if (!empty($changelist)) {
foreach ($changelist as $changeinfo => $change) {
if ($change) {
$changes[$changeinfo] = $change;
@ -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>";

View File

@ -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" :

View File

@ -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");
@ -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.

View File

@ -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>";
}

View File

@ -26,6 +26,7 @@
"<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
true, "", $headerbutton);
$firstcolumn = false; // for now
$side = 175;
?>
@ -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);

View File

@ -13,6 +13,7 @@ I would suggest that you:
MOST IMPORTANT
|-------------------
|
| - files.php
| - install.html
| - upgrade.html
|

View File

@ -26,7 +26,9 @@
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

View File

@ -21,6 +21,7 @@
"proxyhost" => "",
"proxyport" => "",
"maxeditingtime" => 1800,
"changepassword" => true,
"country" => "",
"guestloginbutton" => 1
);

View File

@ -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";
@ -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();
@ -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));
}
@ -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 {

View File

@ -127,9 +127,9 @@
/// 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
}

View File

@ -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";
@ -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;
}
}
@ -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>)";
@ -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 {

View File

@ -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";

View File

@ -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);
}

View File

@ -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",

View File

@ -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");
@ -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;
@ -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");
}

View File

@ -68,6 +68,7 @@
$onsubmit = "onsubmit=\"copyrichtext(theform.message);\"";
} else {
$defaultformat = FORMAT_MOODLE;
$onsubmit = "";
}
@ -271,6 +272,10 @@
$navtail = "$toppost->subject";
}
if (empty($post->edit)) {
$post->edit = "";
}
$strforums = get_string("modulenameplural", "forum");
@ -278,13 +283,17 @@
$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id);
if (empty($discussion->name)) {
$discussion->name = $forum->name;
}
if ($course->category) {
print_header("$course->shortname: $discussion->name: $toppost->subject", "$course->fullname",
"<A HREF=../../course/view.php?id=$course->id>$course->shortname</A> ->
$navmiddle -> $navtail", "$forumstart", "", true, "", navmenu($course, $cm));
$navmiddle -> $navtail", "$formstart", "", true, "", navmenu($course, $cm));
} else {
print_header("$course->shortname: $discussion->name: $toppost->subject", "$course->fullname",
"$navmiddle -> $navtail", "");
"$navmiddle -> $navtail", "$formstart", "", true, "", navmenu($course, $cm));
}

View File

@ -49,7 +49,7 @@
foreach ($journals as $journal) {
$entrytext = get_field("journal_entries", "text", "userid", $USER->id, "journal", $journal->id");
$entrytext = get_field("journal_entries", "text", "userid", $USER->id, "journal", $journal->id);
$journal->timestart = $course->startdate + (($journal->section - 1) * 608400);
if ($journal->daysopen) {
@ -66,8 +66,13 @@
} else {
$text .= "$strview</A></P>";
}
if ($journal->section) {
$section = "$journal->section";
} else {
$section = "";
}
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ("$journal->section",
$table->data[] = array ($section,
text_to_html($journal->intro),
$text);
} else {

View File

@ -62,8 +62,14 @@
$bestgrade = quiz_get_best_grade($quiz->id, $USER->id);
if ($quiz->section) {
$section = "$quiz->section";
} else {
$section = "";
}
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ($quiz->section, $link, "$bestgrade / $quiz->grade");
$table->data[] = array ($section, $link, "$bestgrade / $quiz->grade");
} else {
$table->data[] = array ($link, "$bestgrade / $quiz->grade");
}

View File

@ -182,6 +182,8 @@ function quiz_print_recent_activity(&$logs, $isteacher=false) {
global $CFG, $COURSE_TEACHER_COLOR;
$content = "";
return $content; // True if anything was printed, otherwise false
}

View File

@ -49,8 +49,13 @@
} else {
$ss = $strnotdone;
}
if ($survey->section) {
$section = "$survey->section";
} else {
$section = "";
}
if ($course->format == "weeks" or $course->format == "topics") {
$table->data[] = array ("$survey->section",
$table->data[] = array ($section,
"<A HREF=\"view.php?id=$survey->coursemodule\">$survey->name</A>",
"<A HREF=\"view.php?id=$survey->coursemodule\">$ss</A>");
} else {

View File

@ -7,14 +7,14 @@ if (isadmin()) {
echo "<td><input type=text name=username size=20 value=\"";
p($user->username);
echo "\">";
echo formerr($err["username"]);
if (isset($err["username"])) formerr($err["username"]);
echo "</td>";
echo "</tr>";
echo "<tr valign=top>";
echo "<td><P>".get_string("newpassword").":</td>";
echo "<td><input type=text name=newpassword size=20 value=\"";
p($user->newpassword);
if (isset($user->newpassword)) p($user->newpassword);
echo "\">";
if (isset($err["newpassword"])) {
formerr($err["newpassword"]);
@ -29,19 +29,19 @@ if (isadmin()) {
<tr valign=top>
<td><P><? print_string("firstname") ?>:</td>
<td><input type="text" name="firstname" size=30 value="<? p($user->firstname) ?>">
<? formerr($err["firstname"]) ?>
<? if (isset($err["firstname"])) formerr($err["firstname"]); ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("lastname") ?>:</td>
<td><input type="text" name="lastname" size=30 value="<? p($user->lastname) ?>">
<? formerr($err["lastname"]) ?>
<? if (isset($err["lastname"])) formerr($err["lastname"]); ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("email") ?>:</td>
<td><input type="text" name="email" size=30 value="<? p($user->email) ?>">
<? formerr($err["email"]) ?>
<? if (isset($err["email"])) formerr($err["email"]); ?>
</td>
</tr>
<tr valign=top>
@ -76,7 +76,7 @@ if (isadmin()) {
<tr valign=top>
<td><P><? print_string("city") ?>:</td>
<td><input type="text" name="city" size=25 value="<? p($user->city) ?>">
<? formerr($err["city"]) ?>
<? if (isset($err["city"])) formerr($err["city"]); ?>
</td>
</tr>
<tr valign=top>
@ -88,7 +88,7 @@ if (isadmin()) {
}
choose_from_menu ($COUNTRIES, "country", $user->country, get_string("selectacountry")."...", "", "") ?>
<? formerr($err["country"]) ?>
<? if (isset($err["country"])) formerr($err["country"]); ?>
</td>
</tr>
<tr valign=top>
@ -99,7 +99,7 @@ if (isadmin()) {
}
choose_from_menu ($languages, "lang", $user->lang, "", "", "");
}
formerr($err["lang"]);
if (isset($err["lang"])) formerr($err["lang"]);
?>
</td>
</tr>
@ -125,13 +125,13 @@ if (isadmin()) {
choose_from_menu ($timezones, "timezone", $user->timezone, get_string("serverlocaltime"), "", "99");
echo "(".get_string(currentlocaltime).")";
echo "(".get_string("currentlocaltime").")";
?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("userdescription") ?>:</td>
<td><? if ($err["description"]) {
<td><? if (isset($err["description"])) {
formerr($err["description"]);
echo "<BR>";
} ?>
@ -149,44 +149,44 @@ if (isadmin()) {
<input type="file" name="imagefile" size=40>
<? helpbutton("picture", get_string("helppicture"));
print_string("maxsize", "", display_size(get_max_upload_file_size()));
formerr($err["imagefile"]);
if (isset($err["imagefile"])) formerr($err["imagefile"]);
?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("webpage") ?>:</td>
<td><input type="text" name="url" size=50 value="<? p($user->url) ?>">
<? formerr($err["url"]) ?>
<? if (isset($err["url"])) formerr($err["url"]); ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("icqnumber") ?>:</td>
<td><input type="text" name="icq" size=25 value="<? p($user->icq) ?>">
<? formerr($err["icq"]) ?>
<? if (isset($err["icq"])) formerr($err["icq"]); ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("idnumber") ?>:</td>
<td><input type="text" name="idnumber" size=25 value="<? p($user->idnumber) ?>"> <? p($teacheronly) ?>
<? formerr($err["idnumber"]) ?>
<? if (isset($err["idnumber"])) formerr($err["idnumber"]); ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("phone") ?> 1:</td>
<td><input type="text" name="phone1" size=25 value="<? p($user->phone1) ?>"> <? p($teacheronly) ?>
<? formerr($err["phone1"]) ?>
<? if (isset($err["phone1"])) formerr($err["phone1"]); ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("phone") ?> 2:</td>
<td><input type="text" name="phone2" size=25 value="<? p($user->phone2) ?>"> <? p($teacheronly) ?>
<? formerr($err["phone2"]) ?>
<? if (isset($err["phone2"])) formerr($err["phone2"]); ?>
</td>
</tr>
<tr valign=top>
<td><P><? print_string("address") ?>:</td>
<td><input type="text" name="address" size=25 value="<? p($user->address) ?>"> <? p($teacheronly) ?>
<? formerr($err["address"]) ?>
<? if (isset($err["address"])) formerr($err["address"]); ?>
</td>
</tr>
<tr>

View File

@ -136,11 +136,13 @@
$teacher = strtolower($course->teacher);
if (!isadmin()) {
$teacheronly = "(".get_string("teacheronly", "", $teacher).")";
} else {
$teacheronly = "";
}
print_heading( get_string("userprofilefor", "", "$userfullname") );
print_simple_box_start("center", "", "$THEME->cellheading");
if ($err) {
if (!empty($err)) {
echo "<CENTER>";
notify(get_string("someerrorswerefound"));
echo "</CENTER>";

View File

@ -5,7 +5,7 @@
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
$version = 2002122301; // The current version is a date (YYYYMMDDXX)
$version = 2002122700; // The current version is a date (YYYYMMDDXX)
$release = "1.0.8 dev"; // User-friendly version number