Use $this->error for only error report
[moodle-linuxchix.git] / admin / register.php
blobcc142feb752f0f1185cef18f0694f30dedc3a306
1 <?php // $Id$
2 // register.php - allows admin to register their site on moodle.org
4 require_once('../config.php');
6 require_login();
8 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
10 if (!$site = get_site()) {
11 redirect("index.php");
14 if (!confirm_sesskey()) {
15 error(get_string('confirmsesskeybad', 'error'));
18 if (!$admin = get_admin()) {
19 error("No admins");
22 if (!$admin->country and $CFG->country) {
23 $admin->country = $CFG->country;
26 if (empty($CFG->siteidentifier)) { // Unique site identification code
27 set_config('siteidentifier', random_string(32).$_SERVER['HTTP_HOST']);
31 /// Print headings
33 $stradministration = get_string("administration");
34 $strregistration = get_string("registration");
35 $strregistrationinfo = get_string("registrationinfo");
37 print_header("$site->shortname: $strregistration", $site->fullname,
38 "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strregistration");
40 print_heading($strregistration);
42 print_simple_box($strregistrationinfo, "center", "70%");
45 /// Print the form
47 echo "<form id=\"mform1\" class=\"mform\" action=\"http://moodle.org/register/\" method=\"post\">\n";
48 echo '<fieldset id="registration">';
49 echo '<legend>Registration Information</legend>';
51 echo "<!-- The following hidden variables are to help prevent fake entries being sent. -->\n";
52 echo "<!-- Together they form a key. If any of these change between updates then the entry -->\n";
53 echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
54 echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\" />\n";
55 echo "<input type=\"hidden\" name=\"secret\" value=\"$CFG->siteidentifier\" />\n";
56 echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\" />\n";
57 echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\" />\n";
59 echo "<input type=\"hidden\" name=\"version\" value=\"$CFG->version\" />\n";
60 echo "<input type=\"hidden\" name=\"release\" value=\"$CFG->release\" />\n";
62 echo '<div class="fitem">';
63 echo '<div class="fitemtitle"><label>URL</label></div>';
64 echo '<div class="felement ftext">'.$CFG->wwwroot.'</div>';
65 echo '</div>';
67 echo '<div class="fitem">';
68 echo '<div class="fitemtitle"><label>'.get_string("currentversion").'</label></div>';
69 echo '<div class="felement ftext">'."$CFG->release ($CFG->version)".'</div>';
70 echo '</div>';
72 echo '<div class="fitem">';
73 echo '<div class="fitemtitle"><label for="sitename">'.get_string("fullsitename").'</label></div>';
74 echo '<div class="felement ftext">';
75 echo '<input size="50" id="sitename" type="text" name="sitename" value="'.$site->fullname.'" />';
76 echo '</div>';
77 echo '</div>';
79 echo '<div class="fitem">';
80 echo '<div class="fitemtitle"><label for="menucountry">'.get_string("country").'</label></div>';
81 echo '<div class="felement ftext">';
82 choose_from_menu (get_list_of_countries(), "country", $admin->country, get_string("selectacountry")."...", "", "");
83 echo '</div>';
84 echo '</div>';
86 echo '<div class="fitem">';
87 echo '<div class="fitemtitle"><label for="menupublic">'."<a href=\"http://moodle.org/sites/?country=$admin->country\" title=\"".get_string("publicdirectorytitle")."\">".get_string("publicdirectory")."</a>".'</label></div>';
88 echo '<div class="felement ftext">';
89 $options[0] = get_string("publicdirectory0");
90 $options[1] = get_string("publicdirectory1");
91 $options[2] = get_string("publicdirectory2");
92 choose_from_menu ($options, "public", "2", "", "", "");
93 unset($options);
94 echo '</div>';
95 echo '</div>';
97 echo '<div class="fitem">';
98 echo '<div class="fitemtitle"><label for="menucontact">'.get_string("registrationcontact").'</label></div>';
99 echo '<div class="felement ftext">';
100 $options[0] = get_string("registrationcontactno");
101 $options[1] = get_string("registrationcontactyes");
102 choose_from_menu ($options, "contact", "1", "", "", "");
103 unset($options);
104 echo '</div>';
105 echo '</div>';
107 echo '<div class="fitem">';
108 echo '<div class="fitemtitle"><label>'.get_string("statistics")."<br />(".get_string("notpublic").')'.'</label></div>';
109 echo '<div class="felement ftext">';
111 $count = count_records('course')-1;
112 echo get_string("courses").": ".$count;
113 echo "<input type=\"hidden\" name=\"courses\" value=\"$count\" />\n";
114 echo '<br />';
116 $count = count_records('user', 'deleted', 0);
117 echo get_string("users").": ".$count;
118 echo "<input type=\"hidden\" name=\"users\" value=\"$count\" />\n";
119 echo '<br />';
121 // total number of role assignments
122 $count = count_records('role_assignments');
123 echo get_string('roleassignments', 'role').": ".$count;
124 echo "<input type=\"hidden\" name=\"roleassignments\" value=\"$count\" />\n";
125 echo '<br />';
127 // first find all distinct roles with mod/course:update
128 // please change the name and strings to something appropriate to reflect the new data collected
129 $sql = "SELECT COUNT(DISTINCT u.id)
130 FROM {$CFG->prefix}role_capabilities rc,
131 {$CFG->prefix}role_assignments ra,
132 {$CFG->prefix}user u
133 WHERE (rc.capability = 'moodle/course:update' or rc.capability='moodle/site:doanything')
134 AND rc.roleid = ra.roleid
135 AND u.id = ra.userid";
137 $count = count_records_sql($sql);
138 echo get_string("teachers").": ".$count;
139 echo "<input type=\"hidden\" name=\"courseupdaters\" value=\"$count\" />\n";
140 echo '<br />';
142 $count = count_records('forum_posts');
143 echo get_string("posts", 'forum').": ".$count;
144 echo "<input type=\"hidden\" name=\"posts\" value=\"$count\" />\n";
145 echo '<br />';
147 $count = count_records('question');
148 echo get_string("questions", 'quiz').": ".$count;
149 echo "<input type=\"hidden\" name=\"questions\" value=\"$count\" />\n";
150 echo '<br />';
152 $count = count_records('resource');
153 echo get_string("modulenameplural", "resource").": ".$count;
154 echo "<input type=\"hidden\" name=\"resources\" value=\"$count\" />\n";
155 echo '</div>';
156 echo '</div>';
158 echo '<div class="fitem">';
159 echo '<div class="fitemtitle"><label for="adminname">'.get_string("administrator").'</label></div>';
160 echo '<div class="felement ftext">';
161 echo "<input size=\"50\" type=\"text\" id=\"adminname\" name=\"adminname\" value=\"".fullname($admin, true)."\" />";
162 echo '</div>';
163 echo '</div>';
165 echo '<div class="fitem">';
166 echo '<div class="fitemtitle"><label for="adminemail">'.get_string("email").'</label></div>';
167 echo '<div class="felement ftext">';
168 echo "<input size=\"50\" type=\"text\" id=\"adminemail\" name=\"adminemail\" value=\"$admin->email\" />";
169 echo '</div>';
170 echo '</div>';
172 echo '<div class="fitem">';
173 echo '<div class="fitemtitle"><label for="menumailme">'.get_string("registrationemail").'</label></div>';
174 echo '<div class="felement ftext">';
175 $options[0] = get_string("registrationno");
176 $options[1] = get_string("registrationyes");
177 choose_from_menu ($options, "mailme", "1", "", "", "");
178 unset($options);
179 echo '</div>';
180 echo '</div>';
182 echo '<div class="felement fsubmit"><input name="submitbutton" value="'.get_string('registrationsend').'" type="submit" id="id_submitbutton" /></div>';
184 echo "</fieldset>\n";
186 echo "</form>\n";
188 print_footer();