/
email.php
executable file
·1196 lines (977 loc) · 43.4 KB
/
email.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?
include("objects/objects.inc.php");
$content = '';
$message = '';
ob_start();
session_start();
// include all necessary files
include("includes.inc.php");
/* if ($_SESSION['ltype'] != 'admin') { */
/* // take them right to the user lookup page */
/* header("Location: username_lookup.php"); */
/* exit; */
/* } */
//printpre($curraction);
db_connect($dbhost, $dbuser, $dbpass, $dbdb);
/******************************************************************************
* Action: list, review, user
******************************************************************************/
if ($_REQUEST['action']) {
$curraction = $_REQUEST['action'];
$action = $_REQUEST['action'];
} else {
$action = 'list';
$curraction = 'list';
}
if ($_REQUEST['email']) {
if ($_REQUEST['action'] == 'send') {
$curraction = 'send';
} else {
$curraction = 'email';
}
$action = 'email';
}
/******************************************************************************
* Determine which subsets of participants will be checked
******************************************************************************/
if ($_REQUEST[checkclass] == "Check Class only") $_REQUEST[checkgroup] = "Check Class only";
//$checkgroup = $_REQUEST['checkgroup'];
//$checkgroup = "Check Class only";
if ($curraction != "list" && $curraction != "review") $_SESSION[editors] = $_REQUEST['editors'];
//$_SESSION[editors] = $_REQUEST['editors'];
//printpre($_SESSION[editors]);
//printpre($_REQUEST);
/******************************************************************************
* Scope: site, discussion/assessment
******************************************************************************/
if ($_REQUEST['scope'])
$scope = $_REQUEST['scope'];
else if ($_REQUEST['storyid'])
$scope = 'discussion';
else
$scope = 'site';
$sql = $_REQUEST['sql'];
$query_custom = $_REQUEST['newquery'];
/******************************************************************************
* Sort order:
******************************************************************************/
if ($_REQUEST['order']) {
$order = urldecode($_REQUEST['order']);
} else if (!$_REQUEST['order'] && $action == "user") {
$order = "discussion_tstamp DESC";
} else if (!isset($order)
|| !preg_match('/^[a-z0-9_.]+( (ASC|DESC))?$/i', $order)) {
$order = "user_fname ASC";
}
$orderby = " ORDER BY $order";
/******************************************************************************
* Username and id or findall
******************************************************************************/
if ($_REQUEST['findall']) {
$userid = "'%'";
$useruname = "";
$find = "";
} else if ($_REQUEST['find']) {
$findall = "";
} else if ($_REQUEST['useruname']) {
$useruname = $_REQUEST['useruname'];
$userid = db_get_value ("user", "user_id", "user_uname = '".addslashes($useruname)."'");
if (!$userid) error("invalid username");
$userfname = db_get_value ("user", "user_fname", "user_id = '".addslashes($userid)."'");
} else if ($_REQUEST['userid']) {
$userid = $_REQUEST['userid'];
} else {
$userid = $_SESSION['aid'];
}
// if full name and not username (ie clicking full name to review...)
if ($_REQUEST['userfname'] && !$_REQUEST['useruname']) {
$userfname = urldecode($_REQUEST['userfname']);
$userfname = db_get_value ("user", "user_fname", "user_id = '".addslashes($userid)."'");
$useruname = db_get_value ("user", "user_uname", "user_id = '".addslashes($userid)."'");
}
/******************************************************************************
* Story and Site ids
******************************************************************************/
if ($_REQUEST['storyid']) $storyid = $_REQUEST['storyid'];
$siteid = $_REQUEST['siteid'];
$class_id = $_REQUEST['site'];
$site = $_REQUEST['site'];
/******************************************************************************
* STUDENT and CLASS if class get all members of class from ldap
* returns array with uname, fname and type
******************************************************************************/
$students = array();
$roster_ids = array();
if (isclass($class_id)) {
$students = getclassstudents($class_id);
foreach (array_keys($students) as $key) {
$roster_ids[] = $students[$key][id];
}
//printpre($students);
}
/******************************************************************************
* Add Participants to Roster
******************************************************************************/
if ($_REQUEST[addtoclass] == "Add Checked to Roster") {
$_SESSION[editors] = $_REQUEST[editors];
foreach($_SESSION[editors] as $studentid) {
//get ids of all student currently in class
$currentstudents = array();
foreach (array_keys($students) as $key) {
$currentstudents[] = $students[$key][id];
}
//add to class roster only if not currently a student
if (!in_array($studentid, $currentstudents)) {
//print "Participants added to roster";
$user_id = $studentid;
$ugroup_id = getClassUGroupId($class_id);
// add them to the ugroup
$query = "
INSERT INTO
ugroup_user
SET
FK_user='".addslashes($user_id)."',
FK_ugroup='".addslashes($ugroup_id)."'
";
//printpre($query);
db_query($query);
}
}
unset($_SESSION[editors]);
unset($_SESSION[roster_ids]);
unset($_SESSION[non_roster_ids]);
unset($_SESSION[logged_participants_ids]);
$students = getclassstudents($class_id);
foreach (array_keys($students) as $key) {
$roster_ids[] = $students[$key][id];
}
}
/******************************************************************************
* Query: WHERE clause
* story, site, and/or user or
* all users, all sites
******************************************************************************/
if ($_REQUEST['findall'] && !$_REQUEST['find']) {
$where = "user_id > 0";
} else if ($_REQUEST['find']) {
$useruname = $_REQUEST['useruname'];
$userid = db_get_value ("user", "user_id", "user_uname = '".addslashes($useruname)."'");
if ($userid) {
$where = "user_id = '".addslashes($userid)."'";
} else {
error("invalid username");
$where = "user_id > 0";
}
} else if ($scope == "site") {
$where = "site_id = '".addslashes($siteid)."'";
} else if ($action != "user") {
$where = "story_id = '".addslashes($storyid)."'";
} else if ($userid && $action == "user") {
$where = "user_id = '".addslashes($userid)."'";
}
if ($_REQUEST['userid'] && !$_REQUEST['findall'] && $action == "review" && $_REQUEST['userfname']) {
$where .= " AND user_id = '".addslashes($userid)."'";
}
if ($_REQUEST['findsite'] && $action == "review") {
$findsite = $_REQUEST['findsite'];
$where .= " AND slotname = ''".addslashes($findsite)."''";
}
/******************************************************************************
* Query: SELECT and ORDER clauses
******************************************************************************/
if ($action == "review" || $action == "user") {
$select = "user_id, user_fname, user_uname, user_email, discussion_rate, discussion_tstamp, discussion_id, discussion_subject, story_id, page_id, page_title, story_text_short, section_id, site_id, slot_name";
if (!isset($order)) $order = "discussion_tstamp ASC";
// action = list, email
} else {
$select = "DISTINCT user_id, user_fname, user_uname, user_email";
$order = "user_fname ASC";
}
/******************************************************************************
* Query: NUMBER of post for given user (i.e. number of posts for WHERE clause)
******************************************************************************/
$query = "
SELECT
user_id
FROM
discussion
INNER JOIN story ON FK_story = story_id
INNER JOIN page ON FK_page = page_id
INNER JOIN section ON FK_section = section_id
INNER JOIN site ON FK_site = site_id
INNER JOIN user ON FK_author = user_id
WHERE
$where
";
$r = db_query($query);
$a = db_fetch_assoc($r);
$numrows = db_num_rows($r);
/******************************************************************************
* Query: NUMBER and ID's of participants (i.e. distinct users)
******************************************************************************/
$query = "
SELECT
DISTINCT user_id
FROM
discussion
INNER JOIN story ON FK_story = story_id
INNER JOIN page ON FK_page = page_id
INNER JOIN section ON FK_section = section_id
INNER JOIN site ON FK_site = site_id
INNER JOIN user ON FK_author = user_id
WHERE
$where
";
$r = db_query($query);
$a = db_fetch_assoc($r);
$numparticipants = db_num_rows($r);
$logged_participants = db_query($query);
//print $numparticipants."<br />";
if ($action == "list") $numrows = $numparticipants;
//print $numrows."<br />";
///******************************************************************************
// * Query: GET ids of all participants discussion post information based on select:
// * 1. select summary info for each user
// * 2. select all post info for all specified users
// ******************************************************************************/
//
// $query = "
// SELECT
// $select
// FROM
// discussion
// INNER JOIN story ON FK_story = story_id
// INNER JOIN page ON FK_page = page_id
// INNER JOIN section ON FK_section = section_id
// INNER JOIN site ON section.FK_site = site.site_id
// INNER JOIN slot ON slot.FK_site = site.site_id
// INNER JOIN user ON FK_author = user_id
// WHERE
// $where $orderby
// ";
//
// //printpre($_REQUEST);
// //printpre("where: ".$where);
// //printpre($query);
// //printpre($curraction);
// //$r = db_query($query);
// //$r2 = db_query($query);
// $logged_participants = db_query($query);
printerr();
/******************************************************************************
* SUBSETS of participants
* $logged_participants_ids = ids of all users who have posted to discussion
* $roster_ids = ids of all participants in roster
* $non_roster_ids = ids of all participants not in roster
******************************************************************************/
$non_roster_ids = array();
$logged_participants_ids = array();
while ($a = db_fetch_assoc($logged_participants)) {
$logged_participant_id = $a[user_id];
$logged_participants_ids[] = $a[user_id];
if (!in_array($logged_participant_id, $roster_ids)) {
$non_roster_ids[] = $logged_participant_id;
}
}
//printpre($roster_ids);
//printpre($non_roster_ids);
//printpre($_SESSION[editors]);
/******************************************************************************
* define limits for pagination of results
******************************************************************************/
//if (!isset($lowerlimit)) $lowerlimit = 0;
//if (!isset($range)) $range = 30;
//if ($lowerlimit < 0) $lowerlimit = 0;
if (isset($_REQUEST['range']))
$range = intval($_REQUEST['range']);
else
$range = 30;
if (isset($_REQUEST['lowerlimit']))
$lowerlimit = intval($_REQUEST['lowerlimit']);
else
$lowerlimit = 0;
if ($lowerlimit < 0)
$lowerlimit = 0;
$limit = " limit $lowerlimit,30";
if ($action != "list") $limit = " LIMIT $lowerlimit,$range";
/******************************************************************************
* Query: GET all discussion post information based on select:
* 1. select summary info for each user
* 2. select all post info for all specified users
******************************************************************************/
$query = "
SELECT
$select
FROM
discussion
INNER JOIN story ON FK_story = story_id
INNER JOIN page ON FK_page = page_id
INNER JOIN section ON FK_section = section_id
INNER JOIN site ON section.FK_site = site.site_id
INNER JOIN slot ON slot.FK_site = site.site_id
INNER JOIN user ON FK_author = user_id
WHERE
$where $orderby $limit
";
//printpre($_REQUEST);
//printpre("where: ".$where);
//printpre($query);
//printpre($curraction);
$r = db_query($query);
$r2 = db_query($query);
//$logged_participants = db_query($query);
printerr();
/******************************************************************************
* Print out HTML
******************************************************************************/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
if ($action == "user") {
print "<title>Your Posts</title>";
} else {
print "<title>Participants</title>";
}
include("themes/common/logs_css.inc.php"); ?>
<script type="text/javascript">
// <![CDATA[
function changeOrder(order) {
f = document.searchform;
f.order.value=order;
f.submit();
}
function doWindow(name,width,height) {
var win = window.open("",name,"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width="+width+",height="+height);
win.focus();
}
function sendWindow(name,width,height,url) {
var win = window.open("",name,"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width="+width+",height="+height);
win.document.location=url.replace(/&/, '&');
win.focus();
}
function checkAll() {
field = document.forms[1].elements['editors[]'];
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll() {
field = document.forms[1].elements['editors[]'];
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
function checkGroup() {
selectField = document.forms[1].elements['groupcheck'];
groupName = selectField.value;
field = document.forms[1].elements['editors[]'];
classIds = new Array ();
<?
foreach ($roster_ids as $id)
print "\n\t\tclassIds.push('".$id."');";
?>
otherIds = new Array ();
<?
foreach ($non_roster_ids as $id)
print "\n\t\totherIds.push('".$id."');";
?>
switch(groupName) {
case 'all':
checkAll();
break;
case 'un_all':
uncheckAll();
break;
case 'class':
checkArrayMembersInField(classIds, field, true);
break;
case 'un_class':
checkArrayMembersInField(classIds, field, false);
break;
case 'other':
checkArrayMembersInField(otherIds, field, true);
break;
case 'un_other':
checkArrayMembersInField(otherIds, field, false);
break;
}
}
function checkArrayMembersInField (arrayToCheck, field, checkValue) {
for (i=0; i<arrayToCheck.length; i++) {
id = arrayToCheck[i];
for (j = 0; j < field.length; j++) {
if (field[j].value == id)
field[j].checked = checkValue;
}
}
}
function doFieldChange(user,scope,site,section,page,story,field,what) {
f = document.addform;
f.fieldchange.value = 1;
f.puser.value = user;
f.pscope.value = scope;
f.psite.value = site;
f.psection.value = section;
f.ppage.value = page;
f.pstory.value = story;
f.pfield.value = field;
f.pwhat.value = what;
f.submit();
}
// ]]>
</script>
</head>
<body>
<?
//printpre($_REQUEST);
/******************************************************************************
* If admin print out admin tools (e.g. add/edit users, classes, slots updates
******************************************************************************/
if ($_SESSION['ltype']=='admin') {
print "\n\t<table width='100%' class='bg'>";
print "\n\t\t<tr>\n\t\t\t<td class='bg'>";
print "\n\t\t\t\tLogs: <a href='viewsites.php?$sid&site=$site'>sites</a>";
print "\n\t\t\t\t | <a href='viewlogs.php?$sid&site=$site'>users</a>";
print "\n\t\t\t</td>\n\t\t\t<td align='right' class='bg'>";
print "\n\t\t\t\t<a href='users.php?$sid&site=$site'>add/edit users</a> | ";
print "\n\t\t\t\t<a href='classes.php?$sid&site=$site'>add/edit classes</a> | ";
print "\n\t\t\t\t<a href='add_slot.php?$sid&site=$site'>add/edit slots</a> | ";
print "\n\t\t\t\t<a href='update.php?$sid&site=$site'>segue updates</a>";
print "\n\t\t\t</td>\n\t\t</tr>";
print "\n\t</table>";
}
/******************************************************************************
* Links: Roster | Participation | Logs | Your Posts
******************************************************************************/
print "\n\t<table width='100%' class='bg'>";
// for admins print out participation select and where and order by sql
print "\n\t\t<tr>\n\t\t\t<td class='bg'>";
if ($_SESSION['ltype']=='admin') {
//print $action.": ";
//print "WHERE ".$where." ORDER BY ";
//print $order;
}
print "\n\t\t\t</td>";
print "\n\t\t\t<td class='bg' align='right'>";
// roster
if (isclass($_REQUEST[site])) print "\n\t\t\t\t<a href='add_students.php?$sid&name=$site&scope=$scope&storyid=".$_REQUEST['storyid']."'>Roster</a> |";
// participation (not link when coming from home)
if ($_REQUEST[from] != "home") {
if ($action == "user") {
print "\n\t\t\t\t <a href='email.php?$sid&siteid=$siteid&storyid=$storyid&site=$site&scope=$scope&action=list'>Participation</a>";
} else {
print " Participation";
}
if ($action == "user") {
print " - Your Posts";
} else {
print "\n\t\t\t\t - <a href='email.php?$sid&siteid=$siteid&storyid=$storyid&scope=$scope&site=$site&action=user'>Your Posts</a>";
}
// logs (not link when coming from home)
print "\n\t\t\t\t | <a href='viewlogs.php?$sid&site=$site&storyid=$storyid&scope=$scope&'>Logs</a>";
} else {
print "\n\t\t\t\t Your Posts";
}
print "\n\t\t\t</td>\n\t\t</tr>";
print "\n\t</table>\n\t<br />";
?>
<?=$content?>
<table cellspacing='1' width='100%' id='maintable'>
<tr>
<td>
<form action="<? echo $PHP_SELF ?>" method='get' name='searchform'>
<table cellspacing='1' width='100%'>
<tr>
<td>
<input type='hidden' name='order' value='<? echo urlencode($order) ?>' />
<input type='hidden' name='action' value='<? echo $action ?>' />
<input type='hidden' name='checkgroup' value='<? echo $checkgroup ?>' />
<input type='hidden' name='storyid' value='<? echo $storyid ?>' />
<input type='hidden' name='siteid' value='<? echo $siteid ?>' />
<input type='hidden' name='site' value='<? echo $site ?>' />
<input type='hidden' name='userid' value='<? echo $userid ?>' />
<input type='hidden' name='from' value='<? echo $from ?>' />
<input type='hidden' name='findall' value='<? echo $findall ?>' />
<input type='hidden' name='find' value='<? echo $find ?>' />
<input type='hidden' name='findsite' value='<? echo $findsite ?>' />
<input type='hidden' name='userfname' value='<? echo urlencode($userfname) ?>' />
</td>
<td align='right'>
<?
//$order = urlencode($order);
if ($curraction == 'user') {
$getvariables = "storyid=$storyid&siteid=$siteid&scope=$scope";
} else {
$getvariables = "storyid=$storyid&siteid=$siteid&site=$site&scope=$scope";
}
if ($userid) {
$userfname = urlencode($userfname);
$getusers = "&userid=$userid&userfname=$userfname";
}
$tpages = ceil($numrows/$range);
$curr = ceil(($lowerlimit+$range)/$range);
$prev = $lowerlimit-$range;
if ($prev < 0) $prev = 0;
$next = $lowerlimit+$range;
if ($next >= $numrows) $next = $numrows-$range;
if ($next < 0) $next = 0;
if ($action != "list") {
print "$curr of $tpages ";
if ($prev != $lowerlimit)
if (!$userfname) {
print "\n\t\t\t\t\t\t\t\t<input type='button' value='<<' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=".$prev."&".$getvariables."&action=".$curraction."\"' />";
} else {
//$userfname = urlencode($userfname);
print "\n\t\t\t\t\t\t\t\t<input type='button' value='<<' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=".$prev."&".$getvariables."&action=$curraction&userfname=$userfname&userid=$userid\"' />";
}
if ($next != $lowerlimit && $next > $lowerlimit)
if (!$userfname) {
print "\n\t\t\t\t\t\t\t\t<input type='button' value='>>' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=".$next."&".$getvariables."&action=$curraction\"' />";
} else {
print "\n\t\t\t\t\t\t\t\t<input type='button' value='>>' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=".$next."&".$getvariables."&action=$curraction&userfname=$userfname&userid=$userid\"' />";
}
}
?>
</td>
</tr>
</table>
</form>
<form action="<? echo $PHP_SELF ?>" method='post'>
<input type='hidden' name='storyid' value='<? echo $storyid ?>' />
<input type='hidden' name='siteid' value='<? echo $siteid ?>' />
<input type='hidden' name='site' value='<? echo $site ?>' />
<?
if ($numparticipants == 0) {
print "No participants found. Try extending the scope to all participants in the site";
}
/******************************************************************************
* depending on action print out either:
* list of participants
* email UI
* sent email confirmation
******************************************************************************/
/******************************************************************************
* Navigation Email | List | Review participants in discussion or site
******************************************************************************/
print "\n\t\t\t\t<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td style='font-size: 12px'>";
// lists all participants with summary of posts and avg. rating
if ($curraction == "list") {
//print "<a href='$PHP_SELF?$sid&action=email&".$getvariables.$getusers."'>Email</a> | ";
print "\n\t\t\t\t\t\t\tList | ";
print "\n\t\t\t\t\t\t\t<a href='$PHP_SELF?$sid&action=review&".htmlspecialchars($getvariables)."&order=$order'>Review</a> - ";
print $numparticipants." participants";
// reviews posts by a given user to a given site/discussion/assessment
// or reviews all posts by all users to a given site/discussion/assessment
} else if ($curraction == 'review') {
print "\n\t\t\t\t\t\t\t<a href='$PHP_SELF?$sid&action=list&".htmlspecialchars($getvariables)."&order=user_fname'>List</a> | ";
if ($_REQUEST['userid']) {
print "\n\t\t\t\t\t\t\t<a href='$PHP_SELF?$sid&action=review&".htmlspecialchars($getvariables)."'>Review all</a> - ";
print $numrows." posts from ".urldecode($userfname);
} else {
print "\n\t\t\t\t\t\t\tReview - ";
print $numrows." posts from ".$numparticipants." participants";
}
// displays all posts of a given user across all sites
} else if ($curraction == 'user') {
if ($_SESSION['ltype'] == "admin") {
print "\n\t\t\t\t\t\t\tusername: <input type='text' name='useruname' value='".$useruname."' class='textfield' />";
print "\n\t\t\t\t\t\t\t <input type='submit' name='find' value='Find' />";
print "\n\t\t\t\t\t\t\t <input type='submit' name='findall' value='Find All' /> ";
}
if ($userid) {
print "\n\t\t\t\t\t\t\t".$numrows." posts";
}
print "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
// emails all participants currently listed
} else if ($curraction == 'email') {
//print "Email | ";
print "\n\t\t\t\t\t\t\t<a href='$PHP_SELF?$sid&action=list&".htmlspecialchars($getvariables)."&order=user_fname'>List</a> | ";
print "\n\t\t\t\t\t\t\t<a href='$PHP_SELF?$sid&action=review&".htmlspecialchars($getvariables)."'>Review</a> - ";
print $numparticipants." participants";
// sends email to all participants in email list
} else if ($curraction == 'send') {
print "\n\t\t\t\t\t\t\t<a href='$PHP_SELF?$sid&action=list&".htmlspecialchars($getvariables)."&order=user_fname'>List</a> | ";
print "\n\t\t\t\t\t\t\t<a href='$PHP_SELF?$sid&action=review&".htmlspecialchars($getvariables).htmlspecialchars($getusers)."&order=$order'>Review</a> - ";
print "\n\t\t\t\t\t\t\t".$numparticipants." participants";
}
// if action is not listing of a user's posts across all sites, then include scope
// select (i.e. participants in this discussions/assessment or in this site
if ($curraction != 'user') {
print " in this ";
print "\n\t\t\t\t\t\t\t<select name='scope'>";
// if viewed from roster, then no storyid and no specific discussion/assessment is viewable
if ($_REQUEST[storyid] != "") {
print "\n\t\t\t\t\t\t\t\t<option value='discussion'";
if ($scope=='discussion')
print " selected='selected'";
print ">discussion/assessment</option>";
}
if ($scope=='site' || $_REQUEST[site] != "") {
print "\n\t\t\t\t\t\t\t\t<option";
($scope=='site')? print " value='site' selected='selected'": print "";
print ">site</option>";
}
print "\n\t\t\t\t\t\t\t</select>";
print "\n\t\t\t\t\t\t\t<input type='submit' name='update' value='Update' />";
print "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
/******************************************************************************
* Buttons:
* check all/uncheck all buttons, check class only
* add checked to roster, email checked participants
******************************************************************************/
$selectbuttons .= "\n\t\t\t\t\t\t\t<select name='groupcheck' onchange='checkGroup()'>";
$selectbuttons .= "\n\t\t\t\t\t\t\t\t<option value=''>Check...</option>";
$selectbuttons .= "\n\t\t\t\t\t\t\t\t<option value='all'>Check All</option>";
$selectbuttons .= "\n\t\t\t\t\t\t\t\t<option value='un_all'>Uncheck All</option>";
if (isclass($_REQUEST[site])) $selectbuttons .= "\n\t\t\t\t\t\t\t\t<option value='class'>Check Roster Participants</option>";
if (isclass($_REQUEST[site])) $selectbuttons .= "\n\t\t\t\t\t\t\t\t<option value='un_class'>Uncheck Roster Participants</option>";
if (isclass($_REQUEST[site])) $selectbuttons .= "\n\t\t\t\t\t\t\t\t<option value='other'>Check Other Participants</option>";
if (isclass($_REQUEST[site])) $selectbuttons .= "\n\t\t\t\t\t\t\t\t<option value='un_other'>uncheck Other Participants</option>";
$selectbuttons .= "\n\t\t\t\t\t\t\t</select> ";
if (isclass($_REQUEST[site])) $buttons .= "\n\t\t\t\t\t\t\t<input type='submit' name='addtoclass' value='Add Checked to Roster' /> ";
$buttons .= "\n\t\t\t\t\t\t\t<input type='submit' name='email' value='Email Checked Participants->' onclick=\"for (var i = 0; i < this.form.elements.length; i++) {if (this.form.elements[i].name == 'editors[]' && this.form.elements[i].checked) {return true;}} alert('None selected'); return false;\" />";
if ($action != 'email') {
print "\n\t\t\t\t\t<tr>";
print "\n\t\t\t\t\t\t<td align='left' colspan='2'>";
print $selectbuttons;
print $buttons;
print "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
}
}
?>
</table>
<?
/******************************************************************************
* if action is email, then compile to list and print out email UI
******************************************************************************/
if ($curraction == 'email') {
$emaillist = array();
foreach ($_REQUEST[editors] as $editor) {
$editor_email = db_get_value("user","user_email", "user_id ='".addslashes($editor)."'");
$editor_fname = db_get_value("user","user_fname", "user_id ='".addslashes($editor)."'");
$editor_femail = $editor_fname."<".$editor_email.">";
array_push($emaillist, $editor_femail);
$emaillist = array_unique($emaillist);
}
$to = implode(", ", $emaillist);
//compile from and cc into headers
if ($_SESSION['ltype']=='admin' && $_SESSION['lfname'] != $_SESSION['afname']) {
$from = $_SESSION['lfname']." as ".$_SESSION['afname']." <".$_SESSION['aemail'].">";
} else {
$from = $_SESSION['afname']." <".$_SESSION['aemail'].">";
}
$headers = "From: ".$from."\n";
$headers .= "Cc: ".$from."\n";
//add content type to header
$html = 1;
if ($html == 1) {
$headers .= "Content-Type: text/html\n";
}
//$text = "email text here";
//$textarea = "email";
?>
<form action="<? echo $PHP_SELF ?>" method='post' name='emailform'>
<table width='100%'>
<tr>
<td align='right'>To:</td>
<td><? echo $to ?></td>
<td align='right'></td>
</tr>
<? if ($_SESSION['ltype']=='admin' && $_SESSION['lfname'] != $_SESSION['afname']) {
print "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='right'>From:</td>\n\t\t\t\t\t\t\t\t<td>".$_SESSION['lfname']." as ".$_SESSION['afname']."</td>\n\t\t\t\t\t\t\t\t<td align='right'></td>\n\t\t\t\t\t\t\t</tr>";
} else {
print "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td align='right'>From:</td>\n\t\t\t\t\t\t\t\t<td>".$_SESSION['afname']."</td>\n\t\t\t\t\t\t\t\t<td align='right'></td>\n\t\t\t\t\t\t\t</tr>";
}
?>
<tr>
<td align='right'>Cc:</td>
<td><? echo $_SESSION['afname'] ?></td>
<td align='right'></td>
</tr>
<tr>
<td align='right'>Subject</td>
<td>
<input type='text' name='subject' value='' size='50' />
<input type='submit' name='email' value='Send' />
</td>
<td align='left'></td>
</tr>
<tr>
<td></td>
<td align='left'>
<?
require_once("htmleditor/editor.inc.php");
include("sniffer.inc.php");
addeditor ("body",80,20,$text,"discuss");
print $content;
?>
</td>
<td align='right'></td>
</tr>
</table>
<input type='hidden' name='action' value='send' />
<input type='hidden' name='scope' value='<? echo $scope ?>' />
<input type='hidden' name='storyid' value='<? echo $storyid ?>' />
<input type='hidden' name='siteid' value='<? echo $siteid ?>' />
<input type='hidden' name='site' value='<? echo $site ?>' />
<input type='hidden' name='to' value='<? echo $to ?>' />
<input type='hidden' name='headers' value='<? echo $headers ?>' />
</form>
<?
// $r = db_query($query);
exit();
/******************************************************************************
* if action is send then mail subject and body
******************************************************************************/
} else if ($curraction == 'send') {
$to = $_REQUEST[to];
$body = $_REQUEST[body];
$headers = $_REQUEST[headers];
if ($_SESSION['ltype']=='admin' && $_SESSION['lfname'] != $_SESSION['afname']) {
$subject = $_REQUEST[subject]." (sent by Segue Admin: ".$_SESSION['lfname'].")";
} else {
$subject = $_REQUEST[subject];
}
print "\n\t\t\t\t\t<table>";
print "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>To:</td>\n\t\t\t\t\t\t<td>".$to."</td>\n\t\t\t\t\t</tr>";
print "\n\t\t\t\t\t<br /><hr />"; // BAD!
print "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>From:</td>\n\t\t\t\t\t\t<td>".$_SESSION['afname']."</td>\n\t\t\t\t\t</tr>";
print "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Cc:</td>\n\t\t\t\t\t\t<td>".$_SESSION['afname']."</td>\n\t\t\t\t\t</tr>";
print "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Subject:</td>\n\t\t\t\t\t<td>".$subject."</td>\n\t\t\t\t\t</tr>";
print "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t<td>".$body."</td>\n\t\t\t\t\t</tr>";
print "\n\t\t\t</table>";
if (!mail($to, $subject, $body, $headers))
print "\n\t\t\t\tAN ERROR OCCURED SENDING MAIL!";
;
exit();
}
// }
/******************************************************************************
* Print out table of participant names
******************************************************************************/
?>
<table width='100%'>
<tr>
<th>edit</th>
<?
print "\n\t\t\t\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='user_fname desc') print "user_fname asc";
else print "user_fname desc";
print "')\">Participant Name";
if ($order =='user_fname asc') print " ∨";
if ($order =='user_fname desc') print " ∧";
print "</a></th>";
if ($curraction == 'review' || $curraction == 'user') {
if ($curraction == 'user')
print "\n\t\t\t\t\t\t<th>Site</th>";
print "\n\t\t\t\t\t\t<th>Page > Topic</th>";
print "\n\t\t\t\t\t\t<th>discussion_subject</th>";
print "\n\t\t\t\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='discussion_rate asc') print "discussion_rate desc";
else print "discussion_rate asc";
print "')\">Rating<br />Grade";
if ($order =='discussion_rate asc') print " ∨";
if ($order =='discussion_rate desc') print " ∧";
print "</a></th>";
print "\n\t\t\t\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='discussion_tstamp asc') print "discussion_tstamp desc";
else print "discussion_tstamp asc";
print "')\">Date Time";
if ($order =='discussion_tstamp asc') print " ∨";
if ($order =='discussion_tstamp desc') print " ∧";
print "</a></th>";
} else {
print "\n\t\t\t\t\t\t<th>Email</th>";
print "\n\t\t\t\t\t\t<th># of Posts</th>";
print "\n\t\t\t\t\t\t<th>Avg. Rating/Grade</th>";
}
?>
</tr>
<?
/******************************************************************************
* if a class site, print out list of students
* if student has participated get post stats
* get # of posts and avg. rating
******************************************************************************/
$color = 0;
$logged_students_id = array();
if (is_array($students) && $curraction == 'list' && isclass($_REQUEST[site])) {
$rostercount = count($students);
print "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='4'>\n\t\t\t\t\t\t\t<b>".$rostercount." Participants from Roster</b>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
foreach (array_keys($students) as $key) {
$e = $students[$key][id];
// if (!$_SESSION[editors]) {
// $checkstatus = " checked='checked'";
// } else if (in_array($e,$_SESSION[editors])) {
// $checkstatus = " checked='checked'";
// } else {
// $checkstatus = "";
// }
print "\n\t\t\t\t\t<tr>";
// if not in logged participant array, then just print out name
if (!in_array($students[$key]['id'], $logged_participants_ids)) {
print "\n\t\t\t\t\t\t<td class='td$color' align='center'>\n\t\t\t\t\t\t\t<input type='checkbox' name='editors[]' value='$e' ".$checkstatus." /></td>";
print "\n\t\t\t\t\t\t<td class='td$color'>".$students[$key][fname]."</td>";
print "\n\t\t\t\t\t\t<td class='td$color'>".$students[$key][email]."</td>";
print "\n\t\t\t\t\t\t<td class='td$color'>0</td>";
print "\n\t\t\t\t\t\t<td class='td$color'></td>";
// if in logged participants, then query for post and print summary