Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allow tutors to be added in bulk email list.

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...
commit 9a0f8502f53f795066394a5fa03ac6fb28a630be 1 parent e4103b6
authored November 17, 2005
8  lib/weblib.php
@@ -2629,7 +2629,13 @@ function print_user($user, $course, $messageselect=false) {
2629 2629
     echo '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&amp;course='. $course->id .'">'. $string->fullprofile .'...</a>';
2630 2630
 
2631 2631
     if (!empty($messageselect) && $isteacher) {
2632  
-        echo '<br /><input type="checkbox" name="email'.$user->id.'" /> ';
  2632
+        echo '<br /><input type="checkbox" name="';
  2633
+        if (isteacher($course->id, $user->id)) {
  2634
+            echo 'teacher';
  2635
+        } else {
  2636
+            echo 'user';
  2637
+        }
  2638
+        echo $user->id.'" /> ';
2633 2639
     }
2634 2640
 
2635 2641
     echo '</td></tr></table>';
90  user/index.php
@@ -184,11 +184,50 @@
184 184
     $exceptions = array(); // This will be an array of userids that are shown as teachers and thus
185 185
                            // do not have to be shown as users as well. Only relevant on site course.
186 186
 
  187
+    if ($isteacher) {
  188
+        echo '
  189
+<script Language="JavaScript">
  190
+<!--
  191
+function checksubmit(form) {
  192
+    var destination = form.formaction.options[form.formaction.selectedIndex].value;
  193
+    if (destination == "" || !checkchecked(form)) {
  194
+        form.formaction.selectedIndex = 0;
  195
+        return false;
  196
+    } else {
  197
+        return true;
  198
+    }
  199
+}
  200
+
  201
+function checkchecked(form) {
  202
+    var inputs = document.getElementsByTagName(\'INPUT\');
  203
+    var checked = false;
  204
+    inputs = filterByParent(inputs, function() {return form;});
  205
+    for(var i = 0; i < inputs.length; ++i) {
  206
+        if(inputs[i].type == \'checkbox\' && inputs[i].checked) {
  207
+            checked = true;
  208
+        }
  209
+    }
  210
+    return checked;
  211
+}
  212
+//-->
  213
+</script>
  214
+';
  215
+        echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
  216
+        echo '<input type="hidden" name="id" value="'.$id.'" />';
  217
+        echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
  218
+        echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
  219
+    }
  220
+
187 221
     if($showteachers) {
188 222
 
189 223
         $tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess');
190 224
         $tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'));
191 225
 
  226
+        if ($isteacher) {
  227
+            $tablecolumns[] = '';
  228
+            $tableheaders[] = get_string('select');
  229
+        }
  230
+
192 231
         $table = new flexible_table('user-index-teachers-'.$course->id);
193 232
 
194 233
         $table->define_columns($tablecolumns);
@@ -221,7 +260,10 @@
221 260
             $whereclause .= 'groupid = '.$currentgroup.' AND ';
222 261
         }
223 262
 
224  
-        $teachersql .= 'WHERE '.$whereclause.' t.course = '.$course->id.' AND u.deleted = 0 AND u.confirmed = 1 AND t.authority > 0';
  263
+        $teachersql .= 'WHERE '.$whereclause.' t.course = '.$course->id.' AND u.deleted = 0 AND u.confirmed = 1';
  264
+        if (!$isteacher) {
  265
+            $teachersql .= ' AND t.authority > 0';
  266
+        }
225 267
 
226 268
         $teachersql .= get_lastaccess_sql($accesssince);
227 269
 
@@ -246,7 +288,7 @@
246 288
 
247 289
             if ($fullmode) {
248 290
                 foreach ($teachers as $key => $teacher) {
249  
-                    print_user($teacher, $course);
  291
+                    print_user($teacher, $course, true);
250 292
                 }
251 293
             } else {
252 294
                 $countrysort = (strpos($sortclause, 'country') !== false);
@@ -270,13 +312,17 @@
270 312
                         }
271 313
                     }
272 314
         
273  
-                    $table->add_data(array (
  315
+                    $data = array (
274 316
                                     //'<input type="checkbox" name="userid[]" value="'.$teacher->id.'" />',
275 317
                                     print_user_picture($teacher->id, $course->id, $teacher->picture, false, true),
276  
-                                    '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.$course->id.'">'.fullname($teacher, $isteacher).'</a></strong>',
  318
+                                    '<strong><a'.($teacher->authority?'':' class="dimmed"').' href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.$course->id.'">'.fullname($teacher, $isteacher).'</a></strong>',
277 319
                                     $teacher->city,
278 320
                                     $country,
279  
-                                    $lastaccess));
  321
+                                    $lastaccess);
  322
+                    if ($isteacher) {
  323
+                        $data[] = '<input type="checkbox" name="teacher'.$teacher->id.'" />';
  324
+                    }
  325
+                    $table->add_data($data);
280 326
                 }
281 327
                 
282 328
                 $table->print_html();
@@ -406,40 +452,6 @@
406 452
         echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
407 453
     }
408 454
 
409  
-    if ($isteacher) {
410  
-        echo '
411  
-<script Language="JavaScript">
412  
-<!--
413  
-function checksubmit(form) {
414  
-    var destination = form.formaction.options[form.formaction.selectedIndex].value;
415  
-    if (destination == "" || !checkchecked(form)) {
416  
-        form.formaction.selectedIndex = 0;
417  
-        return false;
418  
-    } else {
419  
-        return true;
420  
-    }
421  
-}
422  
-
423  
-function checkchecked(form) {
424  
-    var inputs = document.getElementsByTagName(\'INPUT\');
425  
-    var checked = false;
426  
-    inputs = filterByParent(inputs, function() {return form;});
427  
-    for(var i = 0; i < inputs.length; ++i) {
428  
-        if(inputs[i].type == \'checkbox\' && inputs[i].checked) {
429  
-            checked = true;
430  
-        }
431  
-    }
432  
-    return checked;
433  
-}
434  
-//-->
435  
-</script>
436  
-';
437  
-        echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
438  
-        echo '<input type="hidden" name="id" value="'.$id.'" />';
439  
-        echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
440  
-        echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
441  
-    }
442  
-
443 455
     if ($fullmode) {    // Print simple listing
444 456
         if ($totalcount < 1) {
445 457
             print_heading(get_string("nostudentsfound", "", $course->students));
8  user/message.html
@@ -52,15 +52,21 @@
52 52
 <table align="center"><tr><th colspan="4"><? print_string('currentlyselectedusers'); ?></th></tr>
53 53
 <?php
54 54
     if (count($SESSION->emailto[$id])) {
  55
+        if (!$course->teacher) {
  56
+            $course->teacher = get_string('defaultcourseteacher');
  57
+        }
55 58
         foreach ($SESSION->emailto[$id] as $user) {
56 59
             echo '<tr><td>'.fullname($user,true).'</td><td>'.$user->email.'</td><td>';
  60
+            if ($user->teacher) {
  61
+                echo '<img src="'.$CFG->pixpath.'/t/user.gif" alt="'.$course->teacher.'" title="'.$course->teacher.'"/>';
  62
+            }
57 63
             if ($user->emailstop) {
58 64
                 $error = get_string('emaildisable');
59 65
             } elseif (empty($user->email)) {
60 66
                 $error = get_string('emailempty');
61 67
             }
62 68
             if (!empty($error)) {
63  
-                echo '<img src="'.$CFG->wwwroot.'/pix/t/emailno.gif" alt="'.$error.'" title="'.$error.'"/>';
  69
+                echo '<img src="'.$CFG->pixpath.'/t/emailno.gif" alt="'.$error.'" title="'.$error.'"/>';
64 70
                 unset($error);
65 71
             }
66 72
             echo '</td><td><input type="submit" onClick="this.form.deluser.value='.$user->id.';" value="remove" /></td></tr>';
18  user/messageselect.php
@@ -42,10 +42,11 @@
42 42
     $count = 0;
43 43
 
44 44
     foreach ($_POST as $k => $v) {
45  
-        if (preg_match('/^user(\d+)$/',$k,$m)) {
46  
-            if (!array_key_exists($m[1],$SESSION->emailto[$id])) {
47  
-                if ($user = get_record_select('user','id = '.$m[1],'id,firstname,lastname,idnumber,email,emailstop,mailformat')) {
48  
-                    $SESSION->emailto[$id][$m[1]] = $user;
  45
+        if (preg_match('/^(user|teacher)(\d+)$/',$k,$m)) {
  46
+            if (!array_key_exists($m[2],$SESSION->emailto[$id])) {
  47
+                if ($user = get_record_select('user','id = '.$m[2],'id,firstname,lastname,idnumber,nickname,email,emailstop,mailformat')) {
  48
+                    $SESSION->emailto[$id][$m[2]] = $user;
  49
+                    $SESSION->emailto[$id][$m[2]]->teacher = ($m[1] == 'teacher');
49 50
                     $count++;
50 51
                 }
51 52
             }
@@ -84,13 +85,22 @@
84 85
                 echo "\n<p align=\"center\"><input type=\"submit\" name=\"send\" value=\"Send\" /> <input type=\"submit\" name=\"edit\" value=\"Edit\" /></p>\n</form>";
85 86
             } elseif ($send) {
86 87
                 $good = 1;
  88
+                $teachers = array();
87 89
                 foreach ($SESSION->emailto[$id] as $user) {
88 90
                     $good = $good && message_post_message($USER,$user,$messagebody,$format,'direct');
  91
+                    if ($user->teacher) {
  92
+                        $teachers[] = $user->id;
  93
+                    }
89 94
                 }
90 95
                 if ($good) {
91 96
                     print_heading(get_string('messagedselectedusers'));
92 97
                     unset($SESSION->emailto[$id]);
93 98
                     unset($SESSION->emailselect[$id]);
  99
+                    if (count($teachers)) {
  100
+                        foreach ($teachers as $teacher) {
  101
+                            forum_subscribe($teacher, $forum->id);
  102
+                        }
  103
+                    }
94 104
                 } else {
95 105
                     print_heading(get_string('messagedselectedusersfailed'));
96 106
                 }

0 notes on commit 9a0f850

Please sign in to comment.
Something went wrong with that request. Please try again.