mirrored from git://git.moodle.org/moodle.git
/
creators.php
executable file
·148 lines (113 loc) · 4.14 KB
/
creators.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
<?PHP // $Id$
// Admin only script to assign course creator rights to users
require_once("../config.php");
define("MAX_USERS_PER_PAGE", 50);
optional_variable($search, "");
optional_variable($add, "");
optional_variable($remove, "");
if (! $site = get_site()) {
redirect("$CFG->wwwroot/$CFG->admin/index.php");
}
require_login();
if (!isadmin()) {
error("You must be an administrator to use this page.");
}
$primaryadmin = get_admin();
/// assign all of the configurable language strings
$stringstoload = array (
"assigncreators",
"administration",
"existingcreators",
"noexistingcreators",
"potentialcreators",
"nopotentialcreators",
"addcreator",
"removecreator",
"search",
"searchagain",
"users",
"toomanytoshow",
"searchresults"
);
foreach ($stringstoload as $stringtoload){
$strstringtoload = "str" . $stringtoload;
$$strstringtoload = get_string($stringtoload);
}
if ($search) {
$searchstring = $strsearchagain;
} else {
$searchstring = $strsearch;
}
print_header("$site->shortname: $strassigncreators",
"$site->fullname",
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> ->
$strassigncreators", "");
/// Add a creator if one is specified
if (!empty($_GET['add'])) {
if (! add_creator($add)) {
error("Could not add that creator!");
}
}
/// Remove a creator if one is specified.
if (!empty($_GET['remove'])) {
if (! remove_creator($remove)) {
error("Could not remove that creator!");
}
}
/// Print a help notice about this page
if (empty($add) and empty($remove) and empty($search)) {
print_simple_box("<center>".get_string("adminhelpassigncreators")."</center>", "center", "50%");
}
/// Get all existing creators
$creators = get_creators();
/// Print the lists of existing and potential creators
echo "<table cellpadding=2 cellspacing=10 align=center>";
echo "<tr><th width=50%>$strexistingcreators</th><th width=50%>$strpotentialcreators</th></tr>";
echo "<tr><td width=50% nowrap valign=top>";
/// First, show existing creators
if (! $creators) {
echo "<p align=center>$strnoexistingcreators</a>";
$creatorlist = "";
} else {
$creatorarray = array();
foreach ($creators as $creator) {
$creatorarray[] = $creator->id;
echo "<p align=right>".fullname($creator, true).", $creator->email ";
echo "<a href=\"creators.php?remove=$creator->id\"
title=\"$strremovecreator\"><img src=\"../pix/t/right.gif\"
border=0></a>";
echo "</p>";
}
$creatorlist = implode(",",$creatorarray);
unset($creatorarray);
}
echo "<td width=50% nowrap valign=top>";
/// Print list of potential creators
$usercount = get_users(false, $search, true, $creatorlist);
if ($usercount == 0) {
echo "<p align=center>$strnopotentialcreators</p>";
} else if ($usercount > MAX_USERS_PER_PAGE) {
echo "<p align=center>$strtoomanytoshow ($usercount) </p>";
} else {
if ($search) {
echo "<p align=center>($strsearchresults : $search)</p>";
}
if (!$users = get_users(true, $search, true, $creatorlist)) {
error("Could not get users!");
}
foreach ($users as $user) {
$fullname = fullname($user, TRUE);
echo "<p align=left><a href=\"creators.php?add=$user->id\"".
"title=\"$straddcreator\"><img src=\"../pix/t/left.gif\"".
"border=0></a> $fullname, $user->email";
}
}
if ($search or $usercount > MAX_USERS_PER_PAGE) {
echo "<form action=creators.php method=post>";
echo "<input type=text name=search size=20>";
echo "<input type=submit value=\"$searchstring\">";
echo "</form>";
}
echo "</tr></table>";
print_footer();
?>