Hidding Backup and Restore in the menu

Hidding Backup and Restore in the menu

by Genner Cerna -
Number of replies: 8
How do I hide the Backup and Restore in the menu when not logged as admin? (Available only to admins)
Average of ratings: -
In reply to Genner Cerna

Re: Hidding Backup and Restore in the menu

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Those options is available to administrators and editing teachers...

Non-editing teachers and students cannot use them...

Ciao smile

If you want to modify this, you should modify course/lib.php, but I'm not sure it this is recommended...
In reply to Eloy Lafuente (stronk7)

Re: Hidding Backup and Restore in the menu

by Genner Cerna -

Even the edit will not be able to see those options...

In reply to Genner Cerna

Re: Hidding Backup and Restore in the menu

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
You can try enclosing lines 1153 to 1157 (in course(lib.php)) inside:

if (isadmin()) { //This line before 1153

} //This line after 1157


It isn't 100% secure (editing teachers knowing the URLs will be able to execute backups), but the backup and restore links will be showed only to administrators in the course main page.

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Hidding Backup and Restore in the menu

by Genner Cerna -

if (isadmin()) {
            $admindata[]="<a href=\"$CFG->wwwroot/backup/backup.php?id=$course->id\">".get_string("backup")."...</a>";
            $adminicon[]="<img src=\"$CFG->pixpath/i/backup.gif\" height=16 width=16 alt=\"\">";
       
            $admindata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$course->id&wdir=/backupdata\">".get_string("restore")."...</a>";
            $adminicon[]="<img src=\"$CFG->pixpath/i/restore.gif\" height=16 width=16 alt=\"\">";
            $admindata[]="<a href=\"scales.php?id=$course->id\">".get_string("scales")."...</a>";
            $adminicon[]="<img src=\"$CFG->pixpath/i/scales.gif\" height=16 width=16 alt=\"\">";
                }  

For now this will do... Thanks...

In reply to Genner Cerna

Re: Hidding Backup and Restore in the menu

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Genner,

you have hidden the "Scales" link too (for your information, only)

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Hidding Backup and Restore in the menu

by Genner Cerna -

Oppsss, your right I didnt see that... Thanks

This the correct one...

if (isadmin()) {
            $admindata[]="<a href=\"$CFG->wwwroot/backup/backup.php?id=$course->id\">".get_string("backup")."...</a>";
            $adminicon[]="<img src=\"$CFG->pixpath/i/backup.gif\" height=16 width=16 alt=\"\">";
       
            $admindata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$course->id&wdir=/backupdata\">".get_string("restore")."...</a>";
            $adminicon[]="<img src=\"$CFG->pixpath/i/restore.gif\" height=16 width=16 alt=\"\">";
       }

In reply to Genner Cerna

Re: Hidding Backup and Restore in the menu

by Genner Cerna -
I tried the code in the moodle 1.3 it seems the code above doesn't affect. Still when login in as teacher the link is visible.
In reply to Genner Cerna

Re: Hidding Backup and Restore in the menu

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Genner,

under 1.3 that code has been moved to the Blocks System. So you need to enclose lines 56-60 in blocks/admin/block_admin.php with the same "if" condition.

Hope this helps, ciao smile