1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* PHPPgAdmin v6.0.0-beta.30 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Controller; |
8
|
|
|
|
9
|
|
|
use PHPPgAdmin\Decorators\Decorator; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Base controller class. |
13
|
|
|
*/ |
|
|
|
|
14
|
|
|
class AggregatesController extends BaseController |
15
|
|
|
{ |
16
|
|
|
public $controller_name = 'AggregatesController'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Default method to render the controller according to the action parameter. |
20
|
|
|
*/ |
21
|
|
|
public function render() |
22
|
|
|
{ |
23
|
|
|
$conf = $this->conf; |
|
|
|
|
24
|
|
|
|
25
|
|
|
$lang = $this->lang; |
26
|
|
|
|
27
|
|
|
$action = $this->action; |
28
|
|
|
if ('tree' == $action) { |
29
|
|
|
return $this->doTree(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$this->printHeader($lang['straggregates']); |
33
|
|
|
$this->printBody(); |
34
|
|
|
|
35
|
|
|
switch ($action) { |
36
|
|
|
case 'create': |
37
|
|
|
$this->doCreate(); |
38
|
|
|
|
39
|
|
|
break; |
40
|
|
|
case 'save_create': |
41
|
|
|
if (isset($_POST['cancel'])) { |
42
|
|
|
$this->doDefault(); |
43
|
|
|
} else { |
44
|
|
|
$this->doSaveCreate(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
break; |
48
|
|
|
case 'alter': |
49
|
|
|
$this->doAlter(); |
50
|
|
|
|
51
|
|
|
break; |
52
|
|
|
case 'save_alter': |
53
|
|
|
if (isset($_POST['alter'])) { |
54
|
|
|
$this->doSaveAlter(); |
55
|
|
|
} else { |
56
|
|
|
$this->doProperties(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
break; |
60
|
|
|
case 'drop': |
61
|
|
|
if (isset($_POST['drop'])) { |
62
|
|
|
$this->doDrop(false); |
63
|
|
|
} else { |
64
|
|
|
$this->doDefault(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
break; |
68
|
|
|
case 'confirm_drop': |
69
|
|
|
$this->doDrop(true); |
70
|
|
|
|
71
|
|
|
break; |
72
|
|
|
default: |
73
|
|
|
$this->doDefault(); |
74
|
|
|
|
75
|
|
|
break; |
76
|
|
|
case 'properties': |
77
|
|
|
$this->doProperties(); |
78
|
|
|
|
79
|
|
|
break; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $this->printFooter(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Show default list of aggregate functions in the database. |
87
|
|
|
* |
88
|
|
|
* @param mixed $msg |
|
|
|
|
89
|
|
|
*/ |
90
|
|
|
public function doDefault($msg = '') |
91
|
|
|
{ |
92
|
|
|
$conf = $this->conf; |
93
|
|
|
|
94
|
|
|
$lang = $this->lang; |
95
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
96
|
|
|
$this->printTrail('schema'); |
97
|
|
|
$this->printTabs('schema', 'aggregates'); |
98
|
|
|
$this->printMsg($msg); |
99
|
|
|
|
100
|
|
|
$aggregates = $data->getAggregates(); |
101
|
|
|
|
102
|
|
|
$columns = [ |
103
|
|
|
'aggrname' => [ |
104
|
|
|
'title' => $lang['strname'], |
105
|
|
|
'field' => Decorator::field('proname'), |
106
|
|
|
'url' => \SUBFOLDER."/redirect/aggregate?action=properties&{$this->misc->href}&", |
107
|
|
|
'vars' => ['aggrname' => 'proname', 'aggrtype' => 'proargtypes'], |
108
|
|
|
], |
109
|
|
|
'aggrtype' => [ |
110
|
|
|
'title' => $lang['strtype'], |
111
|
|
|
'field' => Decorator::field('proargtypes'), |
112
|
|
|
], |
113
|
|
|
'aggrtransfn' => [ |
114
|
|
|
'title' => $lang['straggrsfunc'], |
115
|
|
|
'field' => Decorator::field('aggtransfn'), |
116
|
|
|
], |
117
|
|
|
'owner' => [ |
118
|
|
|
'title' => $lang['strowner'], |
119
|
|
|
'field' => Decorator::field('usename'), |
120
|
|
|
], |
121
|
|
|
'actions' => [ |
122
|
|
|
'title' => $lang['stractions'], |
123
|
|
|
], |
124
|
|
|
'comment' => [ |
125
|
|
|
'title' => $lang['strcomment'], |
126
|
|
|
'field' => Decorator::field('aggrcomment'), |
127
|
|
|
], |
128
|
|
|
]; |
129
|
|
|
|
130
|
|
|
$actions = [ |
131
|
|
|
'alter' => [ |
132
|
|
|
'content' => $lang['stralter'], |
133
|
|
|
'attr' => [ |
134
|
|
|
'href' => [ |
135
|
|
|
'url' => 'aggregates.php', |
136
|
|
|
'urlvars' => [ |
137
|
|
|
'action' => 'alter', |
138
|
|
|
'aggrname' => Decorator::field('proname'), |
139
|
|
|
'aggrtype' => Decorator::field('proargtypes'), |
140
|
|
|
], |
141
|
|
|
], |
142
|
|
|
], |
143
|
|
|
], |
144
|
|
|
'drop' => [ |
145
|
|
|
'content' => $lang['strdrop'], |
146
|
|
|
'attr' => [ |
147
|
|
|
'href' => [ |
148
|
|
|
'url' => 'aggregates.php', |
149
|
|
|
'urlvars' => [ |
150
|
|
|
'action' => 'confirm_drop', |
151
|
|
|
'aggrname' => Decorator::field('proname'), |
152
|
|
|
'aggrtype' => Decorator::field('proargtypes'), |
153
|
|
|
], |
154
|
|
|
], |
155
|
|
|
], |
156
|
|
|
], |
157
|
|
|
]; |
158
|
|
|
|
159
|
|
|
if (!$data->hasAlterAggregate()) { |
160
|
|
|
unset($actions['alter']); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
echo $this->printTable($aggregates, $columns, $actions, 'aggregates-aggregates', $lang['strnoaggregates']); |
164
|
|
|
|
165
|
|
|
$navlinks = [ |
166
|
|
|
'create' => [ |
167
|
|
|
'attr' => [ |
168
|
|
|
'href' => [ |
169
|
|
|
'url' => 'aggregates.php', |
170
|
|
|
'urlvars' => [ |
171
|
|
|
'action' => 'create', |
172
|
|
|
'server' => $_REQUEST['server'], |
173
|
|
|
'database' => $_REQUEST['database'], |
174
|
|
|
'schema' => $_REQUEST['schema'], |
175
|
|
|
], |
176
|
|
|
], |
177
|
|
|
], |
178
|
|
|
'content' => $lang['strcreateaggregate'], |
179
|
|
|
], |
180
|
|
|
]; |
181
|
|
|
$this->printNavLinks($navlinks, 'aggregates-aggregates', get_defined_vars()); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function doTree() |
|
|
|
|
185
|
|
|
{ |
186
|
|
|
$conf = $this->conf; |
|
|
|
|
187
|
|
|
|
188
|
|
|
$lang = $this->lang; |
|
|
|
|
189
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
190
|
|
|
|
191
|
|
|
$aggregates = $data->getAggregates(); |
192
|
|
|
|
193
|
|
|
$proto = Decorator::concat(Decorator::field('proname'), ' (', Decorator::field('proargtypes'), ')'); |
194
|
|
|
$reqvars = $this->misc->getRequestVars('aggregate'); |
195
|
|
|
|
196
|
|
|
$attrs = [ |
197
|
|
|
'text' => $proto, |
198
|
|
|
'icon' => 'Aggregate', |
199
|
|
|
'toolTip' => Decorator::field('aggcomment'), |
200
|
|
|
'action' => Decorator::redirecturl( |
201
|
|
|
'redirect.php', |
202
|
|
|
$reqvars, |
203
|
|
|
[ |
204
|
|
|
'action' => 'properties', |
205
|
|
|
'aggrname' => Decorator::field('proname'), |
206
|
|
|
'aggrtype' => Decorator::field('proargtypes'), |
207
|
|
|
] |
208
|
|
|
), |
209
|
|
|
]; |
210
|
|
|
|
211
|
|
|
return $this->printTree($aggregates, $attrs, 'aggregates'); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Actually creates the new aggregate in the database. |
216
|
|
|
*/ |
217
|
|
|
public function doSaveCreate() |
218
|
|
|
{ |
219
|
|
|
$conf = $this->conf; |
|
|
|
|
220
|
|
|
|
221
|
|
|
$lang = $this->lang; |
222
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
223
|
|
|
// Check inputs |
224
|
|
|
if ('' == trim($_REQUEST['name'])) { |
225
|
|
|
$this->doCreate($lang['straggrneedsname']); |
226
|
|
|
|
227
|
|
|
return; |
228
|
|
|
} |
229
|
|
|
if ('' == trim($_REQUEST['basetype'])) { |
230
|
|
|
$this->doCreate($lang['straggrneedsbasetype']); |
231
|
|
|
|
232
|
|
|
return; |
233
|
|
|
} |
234
|
|
|
if ('' == trim($_REQUEST['sfunc'])) { |
235
|
|
|
$this->doCreate($lang['straggrneedssfunc']); |
236
|
|
|
|
237
|
|
|
return; |
238
|
|
|
} |
239
|
|
|
if ('' == trim($_REQUEST['stype'])) { |
240
|
|
|
$this->doCreate($lang['straggrneedsstype']); |
241
|
|
|
|
242
|
|
|
return; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
$status = $data->createAggregate( |
246
|
|
|
$_REQUEST['name'], |
247
|
|
|
$_REQUEST['basetype'], |
248
|
|
|
$_REQUEST['sfunc'], |
249
|
|
|
$_REQUEST['stype'], |
250
|
|
|
$_REQUEST['ffunc'], |
251
|
|
|
$_REQUEST['initcond'], |
252
|
|
|
$_REQUEST['sortop'], |
253
|
|
|
$_REQUEST['aggrcomment'] |
254
|
|
|
); |
255
|
|
|
|
256
|
|
|
if (0 == $status) { |
257
|
|
|
$this->misc->setReloadBrowser(true); |
258
|
|
|
$this->doDefault($lang['straggrcreated']); |
259
|
|
|
} else { |
260
|
|
|
$this->doCreate($lang['straggrcreatedbad']); |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Displays a screen for create a new aggregate function. |
266
|
|
|
* |
267
|
|
|
* @param mixed $msg |
|
|
|
|
268
|
|
|
*/ |
269
|
|
|
public function doCreate($msg = '') |
270
|
|
|
{ |
271
|
|
|
$conf = $this->conf; |
|
|
|
|
272
|
|
|
|
273
|
|
|
$lang = $this->lang; |
274
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
275
|
|
|
|
276
|
|
|
if (!isset($_REQUEST['name'])) { |
277
|
|
|
$_REQUEST['name'] = ''; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
if (!isset($_REQUEST['basetype'])) { |
281
|
|
|
$_REQUEST['basetype'] = ''; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
if (!isset($_REQUEST['sfunc'])) { |
285
|
|
|
$_REQUEST['sfunc'] = ''; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
if (!isset($_REQUEST['stype'])) { |
289
|
|
|
$_REQUEST['stype'] = ''; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
if (!isset($_REQUEST['ffunc'])) { |
293
|
|
|
$_REQUEST['ffunc'] = ''; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
if (!isset($_REQUEST['initcond'])) { |
297
|
|
|
$_REQUEST['initcond'] = ''; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
if (!isset($_REQUEST['sortop'])) { |
301
|
|
|
$_REQUEST['sortop'] = ''; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
if (!isset($_REQUEST['aggrcomment'])) { |
305
|
|
|
$_REQUEST['aggrcomment'] = ''; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
$this->printTrail('schema'); |
309
|
|
|
$this->printTitle($lang['strcreateaggregate'], 'pg.aggregate.create'); |
310
|
|
|
$this->printMsg($msg); |
311
|
|
|
|
312
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/aggregates.php\" method=\"post\">\n"; |
313
|
|
|
echo "<table>\n"; |
314
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strname']}</th>\n"; |
315
|
|
|
echo "\t\t<td class=\"data\"><input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
316
|
|
|
htmlspecialchars($_REQUEST['name']), "\" /></td>\n\t</tr>\n"; |
317
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['straggrbasetype']}</th>\n"; |
318
|
|
|
echo "\t\t<td class=\"data\"><input name=\"basetype\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
319
|
|
|
htmlspecialchars($_REQUEST['basetype']), "\" /></td>\n\t</tr>\n"; |
320
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['straggrsfunc']}</th>\n"; |
321
|
|
|
echo "\t\t<td class=\"data\"><input name=\"sfunc\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
322
|
|
|
htmlspecialchars($_REQUEST['sfunc']), "\" /></td>\n\t</tr>\n"; |
323
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['straggrstype']}</th>\n"; |
324
|
|
|
echo "\t\t<td class=\"data\"><input name=\"stype\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
325
|
|
|
htmlspecialchars($_REQUEST['stype']), "\" /></td>\n\t</tr>\n"; |
326
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['straggrffunc']}</th>\n"; |
327
|
|
|
echo "\t\t<td class=\"data\"><input name=\"ffunc\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
328
|
|
|
htmlspecialchars($_REQUEST['ffunc']), "\" /></td>\n\t</tr>\n"; |
329
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['straggrinitcond']}</th>\n"; |
330
|
|
|
echo "\t\t<td class=\"data\"><input name=\"initcond\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
331
|
|
|
htmlspecialchars($_REQUEST['initcond']), "\" /></td>\n\t</tr>\n"; |
332
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['straggrsortop']}</th>\n"; |
333
|
|
|
echo "\t\t<td class=\"data\"><input name=\"sortop\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
334
|
|
|
htmlspecialchars($_REQUEST['sortop']), "\" /></td>\n\t</tr>\n"; |
335
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n"; |
336
|
|
|
echo "\t\t<td><textarea name=\"aggrcomment\" rows=\"3\" cols=\"32\">", |
337
|
|
|
htmlspecialchars($_REQUEST['aggrcomment']), "</textarea></td>\n\t</tr>\n"; |
338
|
|
|
|
339
|
|
|
echo "</table>\n"; |
340
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create\" />\n"; |
341
|
|
|
echo $this->misc->form; |
342
|
|
|
echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n"; |
343
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
344
|
|
|
echo "</form>\n"; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* Function to save after altering an aggregate. |
349
|
|
|
*/ |
350
|
|
|
public function doSaveAlter() |
351
|
|
|
{ |
352
|
|
|
$conf = $this->conf; |
|
|
|
|
353
|
|
|
|
354
|
|
|
$lang = $this->lang; |
355
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
356
|
|
|
|
357
|
|
|
// Check inputs |
358
|
|
|
if ('' == trim($_REQUEST['aggrname'])) { |
359
|
|
|
$this->doAlter($lang['straggrneedsname']); |
360
|
|
|
|
361
|
|
|
return; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
$status = $data->alterAggregate( |
365
|
|
|
$_REQUEST['aggrname'], |
366
|
|
|
$_REQUEST['aggrtype'], |
367
|
|
|
$_REQUEST['aggrowner'], |
368
|
|
|
$_REQUEST['aggrschema'], |
369
|
|
|
$_REQUEST['aggrcomment'], |
370
|
|
|
$_REQUEST['newaggrname'], |
371
|
|
|
$_REQUEST['newaggrowner'], |
372
|
|
|
$_REQUEST['newaggrschema'], |
373
|
|
|
$_REQUEST['newaggrcomment'] |
374
|
|
|
); |
375
|
|
|
if (0 == $status) { |
376
|
|
|
$this->doDefault($lang['straggraltered']); |
377
|
|
|
} else { |
378
|
|
|
$this->doAlter($lang['straggralteredbad']); |
379
|
|
|
|
380
|
|
|
return; |
381
|
|
|
} |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* Function to allow editing an aggregate function. |
386
|
|
|
* |
387
|
|
|
* @param mixed $msg |
|
|
|
|
388
|
|
|
*/ |
389
|
|
|
public function doAlter($msg = '') |
390
|
|
|
{ |
391
|
|
|
$conf = $this->conf; |
|
|
|
|
392
|
|
|
|
393
|
|
|
$lang = $this->lang; |
394
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
395
|
|
|
|
396
|
|
|
$this->printTrail('aggregate'); |
397
|
|
|
$this->printTitle($lang['stralter'], 'pg.aggregate.alter'); |
398
|
|
|
$this->printMsg($msg); |
399
|
|
|
|
400
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/aggregates.php\" method=\"post\">\n"; |
401
|
|
|
$aggrdata = $data->getAggregate($_REQUEST['aggrname'], $_REQUEST['aggrtype']); |
402
|
|
|
if ($aggrdata->recordCount() > 0) { |
403
|
|
|
// Output table header |
404
|
|
|
echo "<table>\n"; |
405
|
|
|
echo "\t<tr>\n\t\t<th class=\"data required\">{$lang['strname']}</th>"; |
406
|
|
|
echo "<th class=\"data required\">{$lang['strowner']}</th>"; |
407
|
|
|
echo "<th class=\"data required\">{$lang['strschema']}</th>\n\t</tr>\n"; |
408
|
|
|
|
409
|
|
|
// Display aggregate's name, owner and schema |
410
|
|
|
echo "\t<tr>\n\t\t<td><input name=\"newaggrname\" size=\"32\" maxlength=\"32\" value=\"", htmlspecialchars($_REQUEST['aggrname']), '" /></td>'; |
411
|
|
|
echo '<td><input name="newaggrowner" size="32" maxlength="32" value="', htmlspecialchars($aggrdata->fields['usename']), '" /></td>'; |
412
|
|
|
echo '<td><input name="newaggrschema" size="32" maxlength="32" value="', htmlspecialchars($_REQUEST['schema']), "\" /></td>\n\t</tr>\n"; |
413
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n"; |
414
|
|
|
echo "\t\t<td><textarea name=\"newaggrcomment\" rows=\"3\" cols=\"32\">", |
415
|
|
|
htmlspecialchars($aggrdata->fields['aggrcomment']), "</textarea></td>\n\t</tr>\n"; |
416
|
|
|
echo "</table>\n"; |
417
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_alter\" />\n"; |
418
|
|
|
echo $this->misc->form; |
419
|
|
|
echo '<input type="hidden" name="aggrname" value="', htmlspecialchars($_REQUEST['aggrname']), "\" />\n"; |
420
|
|
|
echo '<input type="hidden" name="aggrtype" value="', htmlspecialchars($_REQUEST['aggrtype']), "\" />\n"; |
421
|
|
|
echo '<input type="hidden" name="aggrowner" value="', htmlspecialchars($aggrdata->fields['usename']), "\" />\n"; |
422
|
|
|
echo '<input type="hidden" name="aggrschema" value="', htmlspecialchars($_REQUEST['schema']), "\" />\n"; |
423
|
|
|
echo '<input type="hidden" name="aggrcomment" value="', htmlspecialchars($aggrdata->fields['aggrcomment']), "\" />\n"; |
424
|
|
|
echo "<input type=\"submit\" name=\"alter\" value=\"{$lang['stralter']}\" />\n"; |
425
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
426
|
|
|
} else { |
427
|
|
|
echo "<p>{$lang['strnodata']}</p>\n"; |
428
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strback']}\" /></p>\n"; |
429
|
|
|
} |
430
|
|
|
echo "</form>\n"; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* Show confirmation of drop and perform actual drop of the aggregate function selected. |
435
|
|
|
* |
436
|
|
|
* @param mixed $confirm |
|
|
|
|
437
|
|
|
*/ |
438
|
|
|
public function doDrop($confirm) |
439
|
|
|
{ |
440
|
|
|
$conf = $this->conf; |
|
|
|
|
441
|
|
|
|
442
|
|
|
$lang = $this->lang; |
443
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
444
|
|
|
|
445
|
|
|
if ($confirm) { |
446
|
|
|
$this->printTrail('aggregate'); |
447
|
|
|
$this->printTitle($lang['strdrop'], 'pg.aggregate.drop'); |
448
|
|
|
|
449
|
|
|
echo '<p>', sprintf($lang['strconfdropaggregate'], htmlspecialchars($_REQUEST['aggrname'])), "</p>\n"; |
450
|
|
|
|
451
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/aggregates.php\" method=\"post\">\n"; |
452
|
|
|
echo "<p><input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$lang['strcascade']}</label></p>\n"; |
453
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"drop\" />\n"; |
454
|
|
|
echo '<input type="hidden" name="aggrname" value="', htmlspecialchars($_REQUEST['aggrname']), "\" />\n"; |
455
|
|
|
echo '<input type="hidden" name="aggrtype" value="', htmlspecialchars($_REQUEST['aggrtype']), "\" />\n"; |
456
|
|
|
echo $this->misc->form; |
457
|
|
|
echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n"; |
458
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
459
|
|
|
echo "</form>\n"; |
460
|
|
|
} else { |
461
|
|
|
$status = $data->dropAggregate($_POST['aggrname'], $_POST['aggrtype'], isset($_POST['cascade'])); |
462
|
|
|
if (0 == $status) { |
463
|
|
|
$this->misc->setReloadBrowser(true); |
464
|
|
|
$this->doDefault($lang['straggregatedropped']); |
465
|
|
|
} else { |
466
|
|
|
$this->doDefault($lang['straggregatedroppedbad']); |
467
|
|
|
} |
468
|
|
|
} |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Show the properties of an aggregate. |
473
|
|
|
* |
474
|
|
|
* @param mixed $msg |
|
|
|
|
475
|
|
|
*/ |
476
|
|
|
public function doProperties($msg = '') |
477
|
|
|
{ |
478
|
|
|
$conf = $this->conf; |
479
|
|
|
|
480
|
|
|
$lang = $this->lang; |
481
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
482
|
|
|
|
483
|
|
|
$this->printTrail('aggregate'); |
484
|
|
|
$this->printTitle($lang['strproperties'], 'pg.aggregate'); |
485
|
|
|
$this->printMsg($msg); |
486
|
|
|
|
487
|
|
|
$aggrdata = $data->getAggregate($_REQUEST['aggrname'], $_REQUEST['aggrtype']); |
488
|
|
|
|
489
|
|
|
if ($aggrdata->recordCount() > 0) { |
490
|
|
|
// Display aggregate's info |
491
|
|
|
echo "<table>\n"; |
492
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['strname']}</th>\n"; |
493
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($_REQUEST['aggrname']), "</td>\n</tr>\n"; |
494
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['straggrbasetype']}</th>\n"; |
495
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($_REQUEST['aggrtype']), "</td>\n</tr>\n"; |
496
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['straggrsfunc']}</th>\n"; |
497
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($aggrdata->fields['aggtransfn']), "</td>\n</tr>\n"; |
498
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['straggrstype']}</th>\n"; |
499
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($aggrdata->fields['aggstype']), "</td>\n</tr>\n"; |
500
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['straggrffunc']}</th>\n"; |
501
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($aggrdata->fields['aggfinalfn']), "</td>\n</tr>\n"; |
502
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['straggrinitcond']}</th>\n"; |
503
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($aggrdata->fields['agginitval']), "</td>\n</tr>\n"; |
504
|
|
|
if ($data->hasAggregateSortOp()) { |
505
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['straggrsortop']}</th>\n"; |
506
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($aggrdata->fields['aggsortop']), "</td>\n</tr>\n"; |
507
|
|
|
} |
508
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['strowner']}</th>\n"; |
509
|
|
|
echo "\t<td class=\"data1\">", htmlspecialchars($aggrdata->fields['usename']), "</td>\n</tr>\n"; |
510
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$lang['strcomment']}</th>\n"; |
511
|
|
|
echo "\t<td class=\"data1\">", $this->misc->printVal($aggrdata->fields['aggrcomment']), "</td>\n</tr>\n"; |
512
|
|
|
echo "</table>\n"; |
513
|
|
|
} else { |
514
|
|
|
echo "<p>{$lang['strnodata']}</p>\n"; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
$navlinks = [ |
518
|
|
|
'showall' => [ |
519
|
|
|
'attr' => [ |
520
|
|
|
'href' => [ |
521
|
|
|
'url' => 'aggregates.php', |
522
|
|
|
'urlvars' => [ |
523
|
|
|
'server' => $_REQUEST['server'], |
524
|
|
|
'database' => $_REQUEST['database'], |
525
|
|
|
'schema' => $_REQUEST['schema'], |
526
|
|
|
], |
527
|
|
|
], |
528
|
|
|
], |
529
|
|
|
'content' => $lang['straggrshowall'], |
530
|
|
|
], |
531
|
|
|
]; |
532
|
|
|
|
533
|
|
|
if ($data->hasAlterAggregate()) { |
534
|
|
|
$navlinks['alter'] = [ |
535
|
|
|
'attr' => [ |
536
|
|
|
'href' => [ |
537
|
|
|
'url' => 'aggregates.php', |
538
|
|
|
'urlvars' => [ |
539
|
|
|
'action' => 'alter', |
540
|
|
|
'server' => $_REQUEST['server'], |
541
|
|
|
'database' => $_REQUEST['database'], |
542
|
|
|
'schema' => $_REQUEST['schema'], |
543
|
|
|
'aggrname' => $_REQUEST['aggrname'], |
544
|
|
|
'aggrtype' => $_REQUEST['aggrtype'], |
545
|
|
|
], |
546
|
|
|
], |
547
|
|
|
], |
548
|
|
|
'content' => $lang['stralter'], |
549
|
|
|
]; |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
$navlinks['drop'] = [ |
553
|
|
|
'attr' => [ |
554
|
|
|
'href' => [ |
555
|
|
|
'url' => 'aggregates.php', |
556
|
|
|
'urlvars' => [ |
557
|
|
|
'action' => 'confirm_drop', |
558
|
|
|
'server' => $_REQUEST['server'], |
559
|
|
|
'database' => $_REQUEST['database'], |
560
|
|
|
'schema' => $_REQUEST['schema'], |
561
|
|
|
'aggrname' => $_REQUEST['aggrname'], |
562
|
|
|
'aggrtype' => $_REQUEST['aggrtype'], |
563
|
|
|
], |
564
|
|
|
], |
565
|
|
|
], |
566
|
|
|
'content' => $lang['strdrop'], |
567
|
|
|
]; |
568
|
|
|
|
569
|
|
|
$this->printNavLinks($navlinks, 'aggregates-properties', get_defined_vars()); |
570
|
|
|
} |
571
|
|
|
} |
572
|
|
|
|