Initial checkin of new feature to select users from participants page for a recipient list for sending an IM to. Please test.

This commit is contained in:
mjollnir_ 2005-08-22 05:44:13 +00:00
parent 70fc3b3dcd
commit f19570d0ec
5 changed files with 234 additions and 5 deletions

View File

@ -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<br /><b>$a->email</b>.<br />
The new password was automatically generated - you might like to
<a href=\"$a->link\">change your password</a> 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';

View File

@ -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 '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&amp;course='. $course->id .'">'. $string->fullprofile .'...</a>';
if (!empty($messageselect) && $isteacher) {
echo '<br /><input type="checkbox" name="email'.$user->id.'" /> ';
}
echo '</td></tr></table>';
}

View File

@ -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 '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
}
if ($isteacher) {
echo '<form action="messageselect.php" method="post" name="messageselect">';
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
}
if ($fullmode) { // Print simple listing
if ($totalcount < 1) {
print_heading(get_string("nostudentsfound", "", $course->students));
@ -391,7 +397,7 @@
if($matchcount > 0) {
foreach ($students as $student) {
print_user($student, $course);
print_user($student, $course, true);
}
}
else {
@ -427,7 +433,10 @@
'<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&amp;course='.$course->id.'">'.fullname($student).'</a></strong>',
$student->city,
$country,
$lastaccess));
$lastaccess,
($isteacher ? '<input type="checkbox" name="email'.$student->id.'" />' : '')
));
}
}
@ -435,6 +444,15 @@
}
if ($isteacher) {
echo '<center>';
echo '<input type="button" onclick="checkall()" value="'.get_string('checkall').'" />';
echo '<input type="button" onclick="checknone()" value="'.get_string('checknone').'" />';
$displaylist[1] = get_string('messageselectadd');
choose_from_menu ($displaylist, "messageselect", "", get_string("withselectedusers"), "javascript:document.messageselect.submit()");
echo '</center></form>';
}
if ($perpage == 99999) {
echo '<div id="showall"><a href="'.$baseurl.'&amp;perpage='.DEFAULT_PAGE_SIZE.'">'.get_string('showperpage', '', DEFAULT_PAGE_SIZE).'</a></div>';
}

74
user/message.html Normal file
View File

@ -0,0 +1,74 @@
<form name="theform" method="post" action="messageselect.php">
<input type="hidden" name="id" value="<?php p($id) ?>" />
<input type="hidden" name="returnto" value="<?php p($returnto) ?>" />
<input type="hidden" name="deluser" value="" />
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
<table border="0" cellpadding="5">
<tr valign="top">
<td align="right"><b>
<?php print_string("messagebody"); ?>:
</b></td>
<td align="left" rowspan="2">
<?php print_textarea($usehtmleditor, 25, 65, 630, 400, "messagebody", $messagebody); ?>
</td>
</tr>
<tr valign="top">
<td align="right" valign="middle" nowrap="nowrap">
<?php
helpbutton("reading", get_string("helpreading"), "moodle", true, true);
echo "<br />";
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
echo "<br />";
helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
echo "<br />";
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
emoticonhelpbutton("theform", "message");
}
?>
<br />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("formattexttype"); ?>:</b></td>
<td>
<?php
if ($usehtmleditor) { /// Trying this out for a while
print_string('formathtml');
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
} else {
choose_from_menu(format_text_menu(), "format", $format, "");
}
helpbutton("textformat", get_string("helpformatting"));
?>
</td>
</tr>
<tr><td align="center" colspan="2"><input type="submit" name="preview" value="Preview" /></td></tr>
</table>
<?php print_simple_box_end(); ?>
<table align="center"><tr><th colspan="4"><? print_string('currentlyselectedusers'); ?></th></tr>
<?php
if (count($SESSION->emailto[$id])) {
foreach ($SESSION->emailto[$id] as $user) {
echo '<tr><td>'.fullname($user,true).'</td><td>'.$user->email.'</td><td>';
if ($user->emailstop) {
$error = get_string('emaildisable');
} elseif (empty($user->email)) {
$error = get_string('emailempty');
}
if (!empty($error)) {
echo '<img src="'.$CFG->wwwroot.'/pix/t/emailno.gif" alt="'.$error.'" title="'.$error.'"/>';
unset($error);
}
echo '</td><td><input type="submit" onClick="this.form.deluser.value='.$user->id.';" value="remove" /></td></tr>';
}
}
else {
echo '<tr><td colspan="3" align="center">'.get_string('nousersyet').'</td></tr>';
}
?>
</table>
</form>

116
user/messageselect.php Normal file
View File

@ -0,0 +1,116 @@
<?php
{
require_once('../config.php');
require_once($CFG->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,"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> <a href=\"index.php?id=$course->id\">".get_string("participants")."</a> -> ".$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 '<form method="post" action="messageselect.php" style="margin: 0 20px;">
<input type="hidden" name="returnto" value="'.stripslashes($returnto).'">
<input type="hidden" name="id" value="'.$id.'">
<input type="hidden" name="format" value="'.$format.'">
<input type="hidden" name="messagebody" value="'.htmlentities(stripslashes($messagebody)).'">';
echo "<br/><h3>".get_string('previewhtml')."</h3><div class=\"messagepreview\">\n".format_text(stripslashes($messagebody),$format)."\n</div>";
echo "\n<p align=\"center\"><input type=\"submit\" name=\"send\" value=\"Send\" /> <input type=\"submit\" name=\"edit\" value=\"Edit\" /></p>\n</form>";
} 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 '<p align="center"><a href="index.php?id='.$id.'">'.get_string('backtoparticipants').'</a></p>';
}
print_footer();
exit;
} else {
notify(get_string('nousersyet'));
}
}
echo '<p align="center"><a href="'.$returnto.'">'.get_string("keepsearching").'</a>'.((count($SESSION->emailto[$id])) ? ', '.get_string('usemessageform') : '').'</p>';
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();
}
?>