Messaging: Limit to teachers only?

Messaging: Limit to teachers only?

by Paul Andrews -
Number of replies: 10

smile


Average of ratings: -
In reply to Paul Andrews

Re: Messaging: Limit to teachers only?

by Timothy Takemoto -
Yes. I have that on mine by only allowing teachers to see profile pages and online users. Would that help you?
I think that there may be some way of getting to the message functionality by using a URL though even in my system.
Tim

In reply to Timothy Takemoto

Re: Messaging: Limit to teachers only?

by Paul Andrews -
It would be a great start - I want to allow teachers to use this but dont want students abusing it!

thoughtful
In reply to Paul Andrews

Re: Messaging: Limit to teachers only?

by Timothy Takemoto -
The trouble is that you loose not only messaging but also the ability for students to see each other's profiles, and to see that other people are online but....

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
In reply to Timothy Takemoto

Re: Messaging: Limit to teachers only?

by Jason Edwards -

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

In reply to Jason Edwards

Re: Messaging: Limit to teachers only?

by Timothy Takemoto -
A year and a half too late, but should anyone who is not using roles be interested, add this near to the top of a block (in moodle 1.6 at least)
        if (!isloggedin()) {
        return $this->content;
        }
seems to work. These two also work, isteacher(), isadmin(), and iscoursecreator() may work too.
In reply to Paul Andrews

Re: Messaging: Limit to teachers only?

by Rob Barreca -
I have modified messaging to only allow messages to be sent...

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.
In reply to Rob Barreca

Re: Messaging: Limit to teachers only?

by Deleted user -

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

In reply to Rob Barreca

Re: Messaging: Limit to teachers only?

by Richard Williamson -

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 smile

In reply to Paul Andrews

Re: Messaging: Limit to teachers only?

by Kevin Bruton -

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.