MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / glossary / formats.php
blobf1c55a6e2dd3dd31ed53e3a4e327c51dd7bafb71
1 <?php // $Id$
2 /// This file allows to manage the default behaviour of the display formats
4 require_once("../../config.php");
5 require_once("lib.php");
6 global $CFG;
8 $id = required_param('id', PARAM_INT);
9 $mode = optional_param('mode');
11 require_login();
12 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
14 if (!$site = get_site()) {
15 error("Site isn't defined!");
18 if ( !$displayformat = get_record("glossary_formats","id",$id) ) {
19 error ("Invalid Glossary Format");
22 $form = data_submitted();
23 if ( $mode == 'visible' ) {
24 if ( $displayformat ) {
25 if ( $displayformat->visible ) {
26 $displayformat->visible = 0;
27 } else {
28 $displayformat->visible = 1;
30 update_record("glossary_formats",$displayformat);
32 redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats");
33 die;
34 } elseif ( $mode == 'edit' and $form) {
36 $displayformat->popupformatname = $form->popupformatname;
37 $displayformat->showgroup = $form->showgroup;
38 $displayformat->defaultmode = $form->defaultmode;
39 $displayformat->defaulthook = $form->defaulthook;
40 $displayformat->sortkey = $form->sortkey;
41 $displayformat->sortorder = $form->sortorder;
43 update_record("glossary_formats",$displayformat);
44 redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats");
45 die;
48 $stradmin = get_string("administration");
49 $strconfiguration = get_string("configuration");
50 $strmanagemodules = get_string("managemodules");
51 $strmodulename = get_string("modulename", "glossary");
52 $strdisplayformats = get_string("displayformats","glossary");
54 $navlinks = array();
55 $navlinks[] = array('name' => $stradmin, 'link' => "../../$CFG->admin/index.php", 'type' => 'core');
56 $navlinks[] = array('name' => $strconfiguration, 'link' => "../../$CFG->admin/configure.php", 'type' => 'core');
57 $navlinks[] = array('name' => $strmanagemodules, 'link' => "../../$CFG->admin/modules.php", 'type' => 'core');
58 $navlinks[] = array('name' => $strmodulename, 'link' => "../../$CFG->admin/module.php?module=glossary&amp;sesskey=$USER->sesskey", 'type' => 'core');
59 $navlinks[] = array('name' => $strdisplayformats, 'link' => '', 'type' => 'core');
61 $navigation = build_navigation($navlinks);
63 print_header("$strmodulename: $strconfiguration", $site->fullname, $navigation);
65 print_heading($strmodulename . ': ' . get_string("displayformats","glossary"));
67 print_simple_box("<center>".get_string("configwarning", 'admin')."</center>", "center", "60%");
68 echo "<br />";
70 $yes = get_string("yes");
71 $no = get_string("no");
73 echo '<form method="post" action="formats.php" id="form">';
74 echo '<table width="90%" align="center" class="generalbox">';
76 <tr>
77 <td colspan="3" align="center"><strong>
78 <?php echo get_string('displayformat'.$displayformat->name,'glossary'); ?>
79 </strong></td>
80 </tr>
81 <tr valign="top">
82 <td align="right" width="20%"><?php print_string('popupformat','glossary'); ?></td>
83 <td>
84 <?php
85 //get and update available formats
86 $recformats = glossary_get_available_formats();
88 $formats = array();
90 //Take names
91 foreach ($recformats as $format) {
92 $formats[$format->name] = get_string("displayformat$format->name", "glossary");
94 //Sort it
95 asort($formats);
97 choose_from_menu($formats,'popupformatname',$displayformat->popupformatname);
99 </td>
100 <td width="60%">
101 <?php print_string("cnfrelatedview", "glossary") ?><br /><br />
102 </td>
103 </tr>
104 <tr valign="top">
105 <td align="right" width="20%"><?php print_string('defaultmode','glossary'); ?></td>
106 <td>
107 <select size="1" name="defaultmode">
108 <?php
109 $sletter = '';
110 $scat = '';
111 $sauthor = '';
112 $sdate = '';
113 switch ( strtolower($displayformat->defaultmode) ) {
114 case 'letter':
115 $sletter = ' selected="selected" ';
116 break;
118 case 'cat':
119 $scat = ' selected="selected" ';
120 break;
122 case 'date':
123 $sdate = ' selected="selected" ';
124 break;
126 case 'author':
127 $sauthor = ' selected="selected" ';
128 break;
131 <option value="letter" <?php p($sletter)?>>letter</option>
132 <option value="cat" <?php p($scat)?>>cat</option>
133 <option value="date" <?php p($sdate)?>>date</option>
134 <option value="author" <?php p($sauthor)?>>author</option>
135 </select>
136 </td>
137 <td width="60%">
138 <?php print_string("cnfdefaultmode", "glossary") ?><br /><br />
139 </td>
140 </tr>
141 <tr valign="top">
142 <td align="right" width="20%"><?php print_string('defaulthook','glossary'); ?></td>
143 <td>
144 <select size="1" name="defaulthook">
145 <?php
146 $sall = '';
147 $sspecial = '';
148 $sallcategories = '';
149 $snocategorised = '';
150 switch ( strtolower($displayformat->defaulthook) ) {
151 case 'all':
152 $sall = ' selected="selected" ';
153 break;
155 case 'special':
156 $sspecial = ' selected="selected" ';
157 break;
159 case '0':
160 $sallcategories = ' selected="selected" ';
161 break;
163 case '-1':
164 $snocategorised = ' selected="selected" ';
165 break;
168 <option value="ALL" <?php p($sall)?>><?php p(get_string("allentries","glossary"))?></option>
169 <option value="SPECIAL" <?php p($sspecial)?>><?php p(get_string("special","glossary"))?></option>
170 <option value="0" <?php p($sallcategories)?>><?php p(get_string("allcategories","glossary"))?></option>
171 <option value="-1" <?php p($snocategorised)?>><?php p(get_string("notcategorised","glossary"))?></option>
172 </select>
173 </td>
174 <td width="60%">
175 <?php print_string("cnfdefaulthook", "glossary") ?><br /><br />
176 </td>
177 </tr>
178 <tr valign="top">
179 <td align="right" width="20%"><?php print_string('defaultsortkey','glossary'); ?></td>
180 <td>
181 <select size="1" name="sortkey">
182 <?php
183 $sfname = '';
184 $slname = '';
185 $supdate = '';
186 $screation = '';
187 switch ( strtolower($displayformat->sortkey) ) {
188 case 'firstname':
189 $sfname = ' selected="selected" ';
190 break;
192 case 'lastname':
193 $slname = ' selected="selected" ';
194 break;
196 case 'creation':
197 $screation = ' selected="selected" ';
198 break;
200 case 'update':
201 $supdate = ' selected="selected" ';
202 break;
205 <option value="CREATION" <?php p($screation)?>><?php p(get_string("sortbycreation","glossary"))?></option>
206 <option value="UPDATE" <?php p($supdate)?>><?php p(get_string("sortbylastupdate","glossary"))?></option>
207 <option value="FIRSTNAME" <?php p($sfname)?>><?php p(get_string("firstname"))?></option>
208 <option value="LASTNAME" <?php p($slname)?>><?php p(get_string("lastname"))?></option>
209 </select>
210 </td>
211 <td width="60%">
212 <?php print_string("cnfsortkey", "glossary") ?><br /><br />
213 </td>
214 </tr>
215 <tr valign="top">
216 <td align="right" width="20%"><?php print_string('defaultsortorder','glossary'); ?></td>
217 <td>
218 <select size="1" name="sortorder">
219 <?php
220 $sasc = '';
221 $sdesc = '';
222 switch ( strtolower($displayformat->sortorder) ) {
223 case 'asc':
224 $sasc = ' selected="selected" ';
225 break;
227 case 'desc':
228 $sdesc = ' selected="selected" ';
229 break;
232 <option value="asc" <?php p($sasc)?>><?php p(get_string("ascending","glossary"))?></option>
233 <option value="desc" <?php p($sdesc)?>><?php p(get_string("descending","glossary"))?></option>
234 </select>
235 </td>
236 <td width="60%">
237 <?php print_string("cnfsortorder", "glossary") ?><br /><br />
238 </td>
239 </tr>
240 <tr valign="top">
241 <td align="right" width="20%">Include Group Breaks:</td>
242 <td>
243 <select size="1" name="showgroup">
244 <?php
245 $yselected = "";
246 $nselected = "";
247 if ($displayformat->showgroup) {
248 $yselected = " selected=\"selected\" ";
249 } else {
250 $nselected = " selected=\"selected\" ";
253 <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
254 <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
255 </select>
256 </td>
257 <td width="60%">
258 <?php print_string("cnfshowgroup", "glossary") ?><br /><br />
259 </td>
260 </tr>
261 <tr>
262 <td colspan="3" align="center">
263 <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
264 </tr>
265 <input type="hidden" name="id" value="<?php p($id) ?>" />
266 <input type="hidden" name="mode" value="edit" />
267 <?php
269 echo '</table></form>';
271 print_footer();