I think that there may be some way of getting to the message functionality by using a URL though even in my system.
Tim
1) I changed the online users block so that online users are only displayed to teachers. to block_olineusers.php
$this->content = new stdClass; $this->content->text = ; $this->content->footer = ; if(!isteacher()) { return $this->content; }
2) This is not necessary but, there is a hack here (http://moodle.org/mod/forum/discuss.php?d=7723) to block_participants.php
// Takemoto I am tryint to remove this from all pages if the viewer is not the teacher.
// if ($this->instance->pageid != SITEID || // $CFG->showsiteparticipantslist > 1 || // ($CFG->showsiteparticipantslist == 1 && isteacherinanycourse()) // isteacher(SITEID)) { if (isteacher($course->id)) {
3) There are other ways of getting to the profile pages, such as from forum postings and recent activity. So, to make sure that this nevery happens the profile pages can be only shown to teachers and the current user. Gustav mentions this hack here (http://moodle.org/mod/forum/discuss.php?d=11499)
if (!isteacher()) { notice('Only teachers can use this page'); }
But that would not allow users to change their own email addresses. I think that they need to be able to change their own profile. So just after the currentuser is set
if (empty($USER->id)) { $currentuser = false; } else { $currentuser = ($user->id == $USER->id); } //Added by Takemoto to prevent all but teachers and self seeing the profiles. if (!isteacher() and !$currentuser) { error("You are not allowed to view this page"); }
Tim
Hi Timothy,
Is there a way to only permit users who are logged into the system (student or teachers) to see the list of online users? I want to prevent those who are not part of our school community to see this list for security reasons.
Thanks!
Jason
if (!isloggedin()) {
return $this->content;
}
seems to work. These two also work, isteacher(), isadmin(), and iscoursecreator() may work too.
1. Between Teachers and Students (no student<->student messaging)
2. Between Parents and Teachers (I have a parents mod installed)
Add something like this to lib/moodlelib.php:
/*
* Returns whether these two users should be allowed to send messages to each other
*/
function message_allow_messaging($sender, $recipient) {
return isteacherinanycourse($sender) || isteacherinanycourse($recipient);
}
Then added this to line 58 or so of message/send.php:
/// If one of us is NOT a parent or teacher or admin, then send error message that only teachers can message
if (!message_allow_messaging($USER->id, $user->id)) {
print_heading(get_string('onlyteacherscanmessage', 'message'));
exit;
}
Something like that should work.
Hi Rob,
what would I need to add to the code so that students could message only to students within their courses from the site main page?
thanks
Gerald
Hi Bob,
i've given this a shot but it doesn't seem to have worked.
Is the 1st bit of code meant to go in any particular place?
is the 2nd bit of code an insertion or a replacement?
Many thanks - this looks like exactly what i am looking for
If anyone is still trying to do this, have a look at my answer to this question here:
https://moodle.org/mod/forum/discuss.php?d=55934#p1128549
It works for me in Moodle 2.7
If you just want messaging within a course, the mod "Dialogue" is a good solution that doesn't involve changing the code. It has several options with regard to permissions, eg. only allow teachers to open new conversations, or say that the recipient of a solicitude for a new conversation can only be a teacher.