mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Definition and use of new isediting() function for checking whether a user
is not only in editing mode, but ALLOWED to be editing the current course. Used to show editing buttons etc
This commit is contained in:
parent
3c720ccee1
commit
2c309dc22a
@ -33,7 +33,7 @@
|
||||
$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[] = " ";
|
||||
}
|
||||
@ -56,7 +56,7 @@
|
||||
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>";
|
||||
|
@ -62,7 +62,7 @@
|
||||
|
||||
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>";
|
||||
@ -135,7 +135,7 @@
|
||||
$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>";
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@
|
||||
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";
|
||||
@ -160,7 +160,7 @@
|
||||
}
|
||||
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...");
|
||||
|
@ -28,7 +28,7 @@
|
||||
<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");
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
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 {
|
||||
@ -99,7 +99,7 @@
|
||||
</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);
|
||||
|
@ -948,6 +948,14 @@ function isguest($userid=0) {
|
||||
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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user