Skip to content

Commit

Permalink
Allow tutors to be added in bulk email list.
Browse files Browse the repository at this point in the history
In addition, if any tutor in the list is not subscribed to the teacher forum they will be subscribed automatically.

Also show hidden tutors as well when a teacher is viewing the participants list.

And some small bug fixes
  • Loading branch information
patrickslee committed Nov 17, 2005
1 parent e4103b6 commit 9a0f850
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 45 deletions.
8 changes: 7 additions & 1 deletion lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,13 @@ function print_user($user, $course, $messageselect=false) {
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 '<br /><input type="checkbox" name="';
if (isteacher($course->id, $user->id)) {
echo 'teacher';
} else {
echo 'user';
}
echo $user->id.'" /> ';
}

echo '</td></tr></table>';
Expand Down
90 changes: 51 additions & 39 deletions user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,50 @@
$exceptions = array(); // This will be an array of userids that are shown as teachers and thus
// do not have to be shown as users as well. Only relevant on site course.

if ($isteacher) {
echo '
<script Language="JavaScript">
<!--
function checksubmit(form) {
var destination = form.formaction.options[form.formaction.selectedIndex].value;
if (destination == "" || !checkchecked(form)) {
form.formaction.selectedIndex = 0;
return false;
} else {
return true;
}
}
function checkchecked(form) {
var inputs = document.getElementsByTagName(\'INPUT\');
var checked = false;
inputs = filterByParent(inputs, function() {return form;});
for(var i = 0; i < inputs.length; ++i) {
if(inputs[i].type == \'checkbox\' && inputs[i].checked) {
checked = true;
}
}
return checked;
}
//-->
</script>
';
echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
}

if($showteachers) {

$tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess');
$tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'));

if ($isteacher) {
$tablecolumns[] = '';
$tableheaders[] = get_string('select');
}

$table = new flexible_table('user-index-teachers-'.$course->id);

$table->define_columns($tablecolumns);
Expand Down Expand Up @@ -221,7 +260,10 @@
$whereclause .= 'groupid = '.$currentgroup.' AND ';
}

$teachersql .= 'WHERE '.$whereclause.' t.course = '.$course->id.' AND u.deleted = 0 AND u.confirmed = 1 AND t.authority > 0';
$teachersql .= 'WHERE '.$whereclause.' t.course = '.$course->id.' AND u.deleted = 0 AND u.confirmed = 1';
if (!$isteacher) {
$teachersql .= ' AND t.authority > 0';
}

$teachersql .= get_lastaccess_sql($accesssince);

Expand All @@ -246,7 +288,7 @@

if ($fullmode) {
foreach ($teachers as $key => $teacher) {
print_user($teacher, $course);
print_user($teacher, $course, true);
}
} else {
$countrysort = (strpos($sortclause, 'country') !== false);
Expand All @@ -270,13 +312,17 @@
}
}

$table->add_data(array (
$data = array (
//'<input type="checkbox" name="userid[]" value="'.$teacher->id.'" />',
print_user_picture($teacher->id, $course->id, $teacher->picture, false, true),
'<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.$course->id.'">'.fullname($teacher, $isteacher).'</a></strong>',
'<strong><a'.($teacher->authority?'':' class="dimmed"').' href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.$course->id.'">'.fullname($teacher, $isteacher).'</a></strong>',
$teacher->city,
$country,
$lastaccess));
$lastaccess);
if ($isteacher) {
$data[] = '<input type="checkbox" name="teacher'.$teacher->id.'" />';
}
$table->add_data($data);
}

$table->print_html();
Expand Down Expand Up @@ -406,40 +452,6 @@
echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
}

if ($isteacher) {
echo '
<script Language="JavaScript">
<!--
function checksubmit(form) {
var destination = form.formaction.options[form.formaction.selectedIndex].value;
if (destination == "" || !checkchecked(form)) {
form.formaction.selectedIndex = 0;
return false;
} else {
return true;
}
}
function checkchecked(form) {
var inputs = document.getElementsByTagName(\'INPUT\');
var checked = false;
inputs = filterByParent(inputs, function() {return form;});
for(var i = 0; i < inputs.length; ++i) {
if(inputs[i].type == \'checkbox\' && inputs[i].checked) {
checked = true;
}
}
return checked;
}
//-->
</script>
';
echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
}

if ($fullmode) { // Print simple listing
if ($totalcount < 1) {
print_heading(get_string("nostudentsfound", "", $course->students));
Expand Down
8 changes: 7 additions & 1 deletion user/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,21 @@
<table align="center"><tr><th colspan="4"><? print_string('currentlyselectedusers'); ?></th></tr>
<?php
if (count($SESSION->emailto[$id])) {
if (!$course->teacher) {
$course->teacher = get_string('defaultcourseteacher');
}
foreach ($SESSION->emailto[$id] as $user) {
echo '<tr><td>'.fullname($user,true).'</td><td>'.$user->email.'</td><td>';
if ($user->teacher) {
echo '<img src="'.$CFG->pixpath.'/t/user.gif" alt="'.$course->teacher.'" title="'.$course->teacher.'"/>';
}
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.'"/>';
echo '<img src="'.$CFG->pixpath.'/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>';
Expand Down
18 changes: 14 additions & 4 deletions user/messageselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
$count = 0;

foreach ($_POST as $k => $v) {
if (preg_match('/^user(\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;
if (preg_match('/^(user|teacher)(\d+)$/',$k,$m)) {
if (!array_key_exists($m[2],$SESSION->emailto[$id])) {
if ($user = get_record_select('user','id = '.$m[2],'id,firstname,lastname,idnumber,nickname,email,emailstop,mailformat')) {
$SESSION->emailto[$id][$m[2]] = $user;
$SESSION->emailto[$id][$m[2]]->teacher = ($m[1] == 'teacher');
$count++;
}
}
Expand Down Expand Up @@ -84,13 +85,22 @@
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;
$teachers = array();
foreach ($SESSION->emailto[$id] as $user) {
$good = $good && message_post_message($USER,$user,$messagebody,$format,'direct');
if ($user->teacher) {
$teachers[] = $user->id;
}
}
if ($good) {
print_heading(get_string('messagedselectedusers'));
unset($SESSION->emailto[$id]);
unset($SESSION->emailselect[$id]);
if (count($teachers)) {
foreach ($teachers as $teacher) {
forum_subscribe($teacher, $forum->id);
}
}
} else {
print_heading(get_string('messagedselectedusersfailed'));
}
Expand Down

0 comments on commit 9a0f850

Please sign in to comment.