is not only in editing mode, but ALLOWED to be editing the current course.
Used to show editing buttons etc
$readingicon[] = "<IMG SRC=\"../mod/reading/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Reading\">";
}
}
- if ($USER->editing) {
+ if (isediting($course->id)) {
$readingdata[] = "<A HREF=\"mod.php?id=$course->id§ion=0&add=reading\">Add reading...</A>";
$readingicon[] = " ";
}
if (isteacher($USER->id) || isadmin()) {
print_simple_box("Admin", $align="CENTER", $width="100%", $color="$THEME->cellheading");
$adminicon[]="<IMG SRC=\"../pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"Edit\">";
- if ($USER->editing) {
+ if (isediting($course->id)) {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">Turn editing off</A>";
} else {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
if (isteacher($course->id)) {
$adminicon[]="<IMG SRC=\"../pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"Edit\">";
- if ($USER->editing) {
+ if (isediting($course->id)) {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">Turn editing off</A>";
} else {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
$thisweek->id = insert_record("course_sections", $thisweek);
}
- if ($USER->editing) {
+ if (isediting($course->id)) {
$thisweek->summary .= " <A HREF=editweek.php?id=$thisweek->id><IMG SRC=\"../pix/t/edit.gif\" BORDER=0 ALT=\"Edit summary\"></A></P>";
}
echo "<IMG SRC=\"../mod/$mod->modname/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"$mod->modfullname\">";
echo " <A TITLE=\"$mod->modfullname\"";
echo " HREF=\"../mod/$mod->modname/view.php?id=$mod->id\">$instancename</A>";
- if ($USER->editing) {
+ if (isediting($course->id)) {
echo make_editing_buttons($mod->id);
}
echo "<BR>\n";
}
echo "</UL></P>\n";
- if ($USER->editing) {
+ if (isediting($course->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id§ion=$week&add=",
$modtypes, "section$week", "", "Add...");
<TD VALIGN="TOP" NOWRAP>
<? $readings = list_all_readings();
- if ($site->newsitems > 0 or $readings or ($USER->editing and isadmin())) {
+ if ($site->newsitems > 0 or $readings or isediting($site->id)) {
print_simple_box(get_string("mainmenu"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<LI>$reading";
}
}
- if ($USER->editing and isadmin()) {
+ if (isediting($site->id)) {
echo "<P align=right><A HREF=\"$CFG->wwwroot/course/mod.php?id=$site->id§ion=0&add=reading\">".
get_string("addreading", "reading")."</A>...</P>";
} else {
</TD>
<TD WIDTH="30%" VALIGN="TOP">
<?
- if ($USER->editing and isadmin()) {
+ if (isediting($site->id)) {
$site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
}
print_simple_box($site->summary, "", "100%", $THEME->cellheading);
return record_exists_sql("SELECT * FROM user WHERE user='$userid' AND username = 'guest' ");
}
+function isediting($courseid, $user=NULL) {
+ global $USER;
+ if (!$user){
+ $user = $USER;
+ }
+ return ($user->editing and isteacher($courseid, $user->id));
+}
+
function reset_login_count() {
global $SESSION;