diff --git a/lang/en/moodle.php b/lang/en/moodle.php
index 4225a4c2dc3..a07d8a377a5 100644
--- a/lang/en/moodle.php
+++ b/lang/en/moodle.php
@@ -19,6 +19,8 @@ $string['addactivity'] = 'Add an activity...';
$string['addadmin'] = 'Add admin';
$string['addcreator'] = 'Add course creator';
$string['added'] = 'Added $a';
+$string['addedrecip'] = 'Added $a new recipient';
+$string['addedrecips'] = 'Added $a new recipients';
$string['addedtogroup'] = 'Added to group $a';
$string['addedtogroupnot'] = 'Not added to group $a';
$string['addedtogroupnotenrolled'] = 'Not added to group $a, because not enrolled in course';
@@ -103,6 +105,7 @@ $string['autosubscribeno'] = 'No: don\'t automatically subscribe me to forums';
$string['autosubscribeyes'] = 'Yes: when I post, subscribe me to that forum';
$string['availability'] = 'Availability';
$string['availablecourses'] = 'Available Courses';
+$string['backtoparticipants'] = 'Back to participants list';
$string['backup'] = 'Backup';
$string['backupcancelled'] = 'Backup Cancelled';
$string['backupcoursefileshelp'] = 'If enabled then course files will be included in automated backups';
@@ -148,12 +151,14 @@ $string['categoryduplicate'] = 'A category named \'$a\' already exists!';
$string['changedpassword'] = 'Changed password';
$string['changepassword'] = 'Change password';
$string['changessaved'] = 'Changes saved';
+$string['checkall'] = 'Check all';
$string['checkingbackup'] = 'Checking backup';
$string['checkingcourse'] = 'Checking course';
$string['checkingforbbexport'] = 'Checking for BlackBoard export';
$string['checkinginstances'] = 'Checking instances';
$string['checkingsections'] = 'Checking sections';
$string['checklanguage'] = 'Check language';
+$string['checknone'] = 'Check none';
$string['childcoursenotfound'] = 'Child course not found!';
$string['choose'] = 'Choose';
$string['choosecourse'] = 'Choose a course';
@@ -209,6 +214,7 @@ $string['coursebackup'] = 'Course backup';
$string['coursecategories'] = 'Course categories';
$string['coursecategory'] = 'Course category';
$string['coursecreators'] = 'Course creators';
+$string['coursemessage'] = 'Message course users';
$string['coursefiles'] = 'Course files';
$string['courseformats'] = 'Course formats';
$string['coursegrades'] = 'Course grades';
@@ -256,6 +262,7 @@ $string['currency'] = 'Currency';
$string['currentcourseadding'] = 'Current course, adding data to it';
$string['currentcoursedeleting'] = 'Current course, deleting it first';
$string['currentlanguage'] = 'Current language';
+$string['currentlyselectedusers'] = 'Currently selected users';
$string['currentlocaltime'] = 'your current local time';
$string['currentpicture'] = 'Current picture';
$string['currentrelease'] = 'Current release information';
@@ -412,6 +419,10 @@ $string['emailpasswordsent'] = 'Thank you for confirming the change of password.
An email containing your new password has been sent to your address at
$a->email.
The new password was automatically generated - you might like to
link\">change your password to something easier to remember.';
+$string['messagedselectedusers'] = 'Select users have been messaged and the recipient list reset.';
+$string['messagedselectedusersfailed'] = 'Something went wrong while messaging selected users. Some may have received the email.';
+$string['messageselect'] = 'Select this user as an email recipient';
+$string['messageselectadd'] = 'Add / send message';
$string['enable'] = 'Enable';
$string['encryptedcode'] = 'Encrypted code';
$string['enrolledincourse'] = 'Enrolled in course \"$a\"';
@@ -608,6 +619,7 @@ $string['ip_address'] = 'IP Address';
$string['jump'] = 'Jump';
$string['jumpto'] = 'Jump to...';
$string['keep'] = 'Keep';
+$string['keepsearching'] = 'Keep searching';
$string['langltr'] = 'Language direction left-to-right';
$string['langrtl'] = 'Language direction right-to-left';
$string['language'] = 'Language';
@@ -684,6 +696,7 @@ $string['maximumgrade'] = 'Maximum grade';
$string['maximumshort'] = 'Max';
$string['maximumupload'] = 'Maximum upload size';
$string['maxsize'] = 'Max size: $a';
+$string['messagebody'] = 'Message body';
$string['metaassigncourses'] = 'Assign courses';
$string['metaalreadycourses'] = 'Courses already assigned';
$string['metaalreadyhascourses'] = 'This meta course already has child courses.';
@@ -885,6 +898,7 @@ $string['potentialteachers'] = 'Potential teachers';
$string['preferredlanguage'] = 'Preferred language';
$string['preferredtheme'] = 'Preferred theme';
$string['preview'] = 'Preview';
+$string['previewhtml'] = 'HTML Format Preview';
$string['previeworchoose'] = 'Preview or choose a theme';
$string['previous'] = 'Previous';
$string['profile'] = 'Profile';
@@ -898,6 +912,7 @@ $string['readinginfofrombackup'] = 'Reading info from backup';
$string['readme'] = 'README';
$string['recentactivity'] = 'Recent Activity';
$string['recentactivityreport'] = 'Full report of recent activity...';
+$string['recipientslist'] = 'Recipients list';
$string['recreatedcategory'] = 'Recreated category $a';
$string['refreshingevents'] = 'Refreshing events';
$string['registration'] = 'Moodle Registration';
@@ -1124,6 +1139,7 @@ $string['uploadserverlimit'] = 'Uploaded file exceeded the maximum size limit se
$string['uploadthisfile'] = 'Upload this file';
$string['uploadusers'] = 'Upload users';
$string['usedinnplaces'] = 'Used in $a places';
+$string['usemessageform'] = 'or use the form below to send a message to the selected students';
$string['user'] = 'User';
$string['userconfirmed'] = 'Confirmed $a';
$string['userdata'] = 'User Data';
@@ -1179,6 +1195,7 @@ $string['whattocallzip'] = 'What do you want to call the zip file?';
$string['withchosenfiles'] = 'With chosen files';
$string['withoutuserdata'] = 'without user data';
$string['withuserdata'] = 'with user data';
+$string['withselectedusers'] = 'With selected users...';
$string['wordforstudent'] = 'Your word for Student';
$string['wordforstudenteg'] = 'eg Student, Participant etc';
$string['wordforstudents'] = 'Your word for Students';
diff --git a/lib/weblib.php b/lib/weblib.php
index 0cf4132b45d..4347383955e 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -2520,7 +2520,7 @@ function print_user_picture($userid, $courseid, $picture, $size=0, $returnstring
* @param user $user A {@link $USER} object representing a user
* @param course $course A {@link $COURSE} object representing a course
*/
-function print_user($user, $course) {
+function print_user($user, $course, $messageselect=false) {
global $CFG, $USER;
@@ -2607,6 +2607,10 @@ function print_user($user, $course) {
}
echo ''. $string->fullprofile .'...';
+ if (!empty($messageselect) && $isteacher) {
+ echo '
';
+ }
+
echo '';
}
diff --git a/user/index.php b/user/index.php
index 5f1478d35e9..9d2b734f365 100644
--- a/user/index.php
+++ b/user/index.php
@@ -243,8 +243,8 @@
$guest = get_guest();
$exceptions[] = $guest->id;
- $tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess');
- $tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'));
+ $tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess','messageselect');
+ $tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'), ($isteacher) ? get_string('select') : '');
$table = new flexible_table('user-index-students');
@@ -338,6 +338,12 @@
echo '
('.get_string('unusedaccounts', '', $CFG->longtimenosee).')
'; } + if ($isteacher) { + echo ''; + } + if ($perpage == 99999) { echo ''; } diff --git a/user/message.html b/user/message.html new file mode 100644 index 00000000000..7d29476c05b --- /dev/null +++ b/user/message.html @@ -0,0 +1,74 @@ + diff --git a/user/messageselect.php b/user/messageselect.php new file mode 100644 index 00000000000..be9a7ef4e76 --- /dev/null +++ b/user/messageselect.php @@ -0,0 +1,116 @@ +dirroot.'/message/lib.php'); + + $id = required_param('id'); + $messagebody = optional_param('messagebody',null,false); + $send = optional_param('send',null); + $returnto = optional_param('returnto',null); + $preview = optional_param('preview',null); + $format = optional_param('format',FORMAT_MOODLE); + $edit = optional_param('edit',null); + $deluser = optional_param('deluser',null); + + if (!$course = get_record('course','id',$id)) { + error("Invalid course id"); + } + + if (!isteacher($course->id)) { + error("Only teachers can use this page"); + } + + if (empty($SESSION->emailto)) { + $SESSION->emailto = array(); + } + if (!array_key_exists($id,$SESSION->emailto)) { + $SESSION->emailto[$id] = array(); + } + + if ($deluser) { + if (array_key_exists($id,$SESSION->emailto) && array_key_exists($deluser,$SESSION->emailto[$id])) { + unset($SESSION->emailto[$id][$deluser]); + } + } + + $count = 0; + + foreach ($_POST as $k => $v) { + if (preg_match('/email(\d+)/',$k,$m)) { + if (!array_key_exists($m[1],$SESSION->emailto[$id])) { + if ($user = get_record_select('user','id = '.$m[1],'id,firstname,lastname,idnumber,email,emailstop,mailformat')) { + $SESSION->emailto[$id][$m[1]] = $user; + $count++; + } + } + } + } + + $strtitle = get_string('coursemessage'); + + if (empty($messagebody)) { + $formstart = "theform.messagebody"; + } else { + $formstart = ""; + } + + print_header($strtitle,$strtitle,"wwwroot/course/view.php?id=$course->id\">$course->shortname -> id\">".get_string("participants")." -> ".$strtitle,$formstart); + + + if ($count) { + if ($count == 1) { + $heading = get_string('addedrecip','moodle',$count); + } else { + $heading = get_string('addedrecips','moodle',$count); + } + print_heading($heading); + } + + if (!empty($messagebody) && !$edit && !$deluser) { + if (count($SESSION->emailto[$id])) { + if ($preview) { + echo '"; + } elseif ($send) { + $good = 1; + foreach ($SESSION->emailto[$id] as $user) { + $good = $good && message_post_message($USER,$user,$messagebody,$format,'direct'); + } + if ($good) { + print_heading(get_string('messagedselectedusers')); + unset($SESSION->emailto[$id]); + } else { + print_heading(get_string('messagedselectedusersfailed')); + } + echo ''.get_string('backtoparticipants').'
'; + } + print_footer(); + exit; + } else { + notify(get_string('nousersyet')); + } + } + + echo ''.get_string("keepsearching").''.((count($SESSION->emailto[$id])) ? ', '.get_string('usemessageform') : '').'
'; + + if ((!empty($send) || !empty($preview) || !empty($edit)) && (empty($messagebody))) { + notify(get_string('allfieldsrequired')); + } + + if (count($SESSION->emailto[$id])) { + $usehtmleditor = can_use_richtext_editor(); + require("message.html"); + if ($usehtmleditor) { + use_html_editor("messagebody"); + } + } + + print_footer(); + +} +?> \ No newline at end of file