Total Complexity | 93 |
Total Lines | 886 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like SequencesController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SequencesController, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class SequencesController extends BaseController |
||
15 | { |
||
16 | public $controller_name = 'SequencesController'; |
||
17 | |||
18 | /** |
||
19 | * Default method to render the controller according to the action parameter. |
||
20 | */ |
||
21 | public function render() |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Display list of all sequences in the database/schema. |
||
113 | * |
||
114 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
115 | */ |
||
116 | public function doDefault($msg = '') |
||
117 | { |
||
118 | $conf = $this->conf; |
||
119 | |||
120 | $lang = $this->lang; |
||
121 | $data = $this->misc->getDatabaseAccessor(); |
||
122 | |||
123 | $this->printTrail('schema'); |
||
124 | $this->printTabs('schema', 'sequences'); |
||
125 | $this->printMsg($msg); |
||
126 | |||
127 | // Get all sequences |
||
128 | $sequences = $data->getSequences(); |
||
129 | |||
130 | $columns = [ |
||
131 | 'sequence' => [ |
||
132 | 'title' => $lang['strsequence'], |
||
133 | 'field' => Decorator::field('seqname'), |
||
134 | 'url' => "sequences.php?action=properties&{$this->misc->href}&", |
||
135 | 'vars' => ['sequence' => 'seqname'], |
||
136 | ], |
||
137 | 'owner' => [ |
||
138 | 'title' => $lang['strowner'], |
||
139 | 'field' => Decorator::field('seqowner'), |
||
140 | ], |
||
141 | 'actions' => [ |
||
142 | 'title' => $lang['stractions'], |
||
143 | ], |
||
144 | 'comment' => [ |
||
145 | 'title' => $lang['strcomment'], |
||
146 | 'field' => Decorator::field('seqcomment'), |
||
147 | ], |
||
148 | ]; |
||
149 | |||
150 | $actions = [ |
||
151 | 'multiactions' => [ |
||
152 | 'keycols' => ['sequence' => 'seqname'], |
||
153 | 'url' => 'sequences.php', |
||
154 | ], |
||
155 | 'alter' => [ |
||
156 | 'content' => $lang['stralter'], |
||
157 | 'attr' => [ |
||
158 | 'href' => [ |
||
159 | 'url' => 'sequences.php', |
||
160 | 'urlvars' => [ |
||
161 | 'action' => 'confirm_alter', |
||
162 | 'subject' => 'sequence', |
||
163 | 'sequence' => Decorator::field('seqname'), |
||
164 | ], |
||
165 | ], |
||
166 | ], |
||
167 | ], |
||
168 | 'drop' => [ |
||
169 | 'content' => $lang['strdrop'], |
||
170 | 'attr' => [ |
||
171 | 'href' => [ |
||
172 | 'url' => 'sequences.php', |
||
173 | 'urlvars' => [ |
||
174 | 'action' => 'confirm_drop', |
||
175 | 'sequence' => Decorator::field('seqname'), |
||
176 | ], |
||
177 | ], |
||
178 | ], |
||
179 | 'multiaction' => 'confirm_drop', |
||
180 | ], |
||
181 | 'privileges' => [ |
||
182 | 'content' => $lang['strprivileges'], |
||
183 | 'attr' => [ |
||
184 | 'href' => [ |
||
185 | 'url' => 'privileges.php', |
||
186 | 'urlvars' => [ |
||
187 | 'subject' => 'sequence', |
||
188 | 'sequence' => Decorator::field('seqname'), |
||
189 | ], |
||
190 | ], |
||
191 | ], |
||
192 | ], |
||
193 | ]; |
||
194 | |||
195 | echo $this->printTable($sequences, $columns, $actions, 'sequences-sequences', $lang['strnosequences']); |
||
196 | |||
197 | $this->printNavLinks(['create' => [ |
||
1 ignored issue
–
show
|
|||
198 | 'attr' => [ |
||
199 | 'href' => [ |
||
200 | 'url' => 'sequences.php', |
||
201 | 'urlvars' => [ |
||
202 | 'action' => 'create', |
||
203 | 'server' => $_REQUEST['server'], |
||
204 | 'database' => $_REQUEST['database'], |
||
205 | 'schema' => $_REQUEST['schema'], |
||
206 | ], |
||
207 | ], |
||
208 | ], |
||
209 | 'content' => $lang['strcreatesequence'], |
||
210 | ]], 'sequences-sequences', get_defined_vars()); |
||
1 ignored issue
–
show
|
|||
211 | } |
||
212 | |||
213 | /** |
||
214 | * Generate XML for the browser tree. |
||
215 | */ |
||
216 | public function doTree() |
||
217 | { |
||
218 | $conf = $this->conf; |
||
219 | |||
220 | $lang = $this->lang; |
||
221 | $data = $this->misc->getDatabaseAccessor(); |
||
222 | |||
223 | $sequences = $data->getSequences(); |
||
224 | |||
225 | $reqvars = $this->misc->getRequestVars('sequence'); |
||
226 | |||
227 | $attrs = [ |
||
228 | 'text' => Decorator::field('seqname'), |
||
229 | 'icon' => 'Sequence', |
||
230 | 'toolTip' => Decorator::field('seqcomment'), |
||
231 | 'action' => Decorator::actionurl( |
||
232 | 'sequences.php', |
||
233 | $reqvars, |
||
234 | [ |
||
235 | 'action' => 'properties', |
||
236 | 'sequence' => Decorator::field('seqname'), |
||
237 | ] |
||
238 | ), |
||
239 | ]; |
||
240 | |||
241 | return $this->printTree($sequences, $attrs, 'sequences'); |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * Display the properties of a sequence. |
||
246 | * |
||
247 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
248 | */ |
||
249 | public function doProperties($msg = '') |
||
250 | { |
||
251 | $conf = $this->conf; |
||
252 | |||
253 | $lang = $this->lang; |
||
254 | $data = $this->misc->getDatabaseAccessor(); |
||
255 | $this->printTrail('sequence'); |
||
256 | $this->printTitle($lang['strproperties'], 'pg.sequence'); |
||
257 | $this->printMsg($msg); |
||
258 | |||
259 | // Fetch the sequence information |
||
260 | $sequence = $data->getSequence($_REQUEST['sequence']); |
||
261 | |||
262 | if (is_object($sequence) && $sequence->recordCount() > 0) { |
||
263 | $sequence->fields['is_cycled'] = $data->phpBool($sequence->fields['is_cycled']); |
||
264 | $sequence->fields['is_called'] = $data->phpBool($sequence->fields['is_called']); |
||
265 | |||
266 | // Show comment if any |
||
267 | if (null !== $sequence->fields['seqcomment']) { |
||
268 | echo '<p class="comment">', $this->misc->printVal($sequence->fields['seqcomment']), "</p>\n"; |
||
269 | } |
||
270 | |||
271 | echo '<table border="0">'; |
||
272 | echo "<tr><th class=\"data\">{$lang['strname']}</th>"; |
||
273 | if ($data->hasAlterSequenceStart()) { |
||
274 | echo "<th class=\"data\">{$lang['strstartvalue']}</th>"; |
||
275 | } |
||
276 | echo "<th class=\"data\">{$lang['strlastvalue']}</th>"; |
||
277 | echo "<th class=\"data\">{$lang['strincrementby']}</th>"; |
||
278 | echo "<th class=\"data\">{$lang['strmaxvalue']}</th>"; |
||
279 | echo "<th class=\"data\">{$lang['strminvalue']}</th>"; |
||
280 | echo "<th class=\"data\">{$lang['strcachevalue']}</th>"; |
||
281 | echo "<th class=\"data\">{$lang['strlogcount']}</th>"; |
||
282 | echo "<th class=\"data\">{$lang['strcancycle']}</th>"; |
||
283 | echo "<th class=\"data\">{$lang['striscalled']}</th></tr>"; |
||
284 | echo '<tr>'; |
||
285 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['seqname']), '</td>'; |
||
286 | if ($data->hasAlterSequenceStart()) { |
||
287 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['start_value']), '</td>'; |
||
288 | } |
||
289 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['last_value']), '</td>'; |
||
290 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['increment_by']), '</td>'; |
||
291 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['max_value']), '</td>'; |
||
292 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['min_value']), '</td>'; |
||
293 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['cache_value']), '</td>'; |
||
294 | echo '<td class="data1">', $this->misc->printVal($sequence->fields['log_cnt']), '</td>'; |
||
295 | echo '<td class="data1">', ($sequence->fields['is_cycled'] ? $lang['stryes'] : $lang['strno']), '</td>'; |
||
296 | echo '<td class="data1">', ($sequence->fields['is_called'] ? $lang['stryes'] : $lang['strno']), '</td>'; |
||
297 | echo '</tr>'; |
||
298 | echo '</table>'; |
||
299 | |||
300 | $navlinks = [ |
||
301 | 'alter' => [ |
||
302 | 'attr' => [ |
||
303 | 'href' => [ |
||
304 | 'url' => 'sequences.php', |
||
305 | 'urlvars' => [ |
||
306 | 'action' => 'confirm_alter', |
||
307 | 'server' => $_REQUEST['server'], |
||
308 | 'database' => $_REQUEST['database'], |
||
309 | 'schema' => $_REQUEST['schema'], |
||
310 | 'sequence' => $sequence->fields['seqname'], |
||
311 | ], |
||
312 | ], |
||
313 | ], |
||
314 | 'content' => $lang['stralter'], |
||
315 | ], |
||
316 | 'setval' => [ |
||
317 | 'attr' => [ |
||
318 | 'href' => [ |
||
319 | 'url' => 'sequences.php', |
||
320 | 'urlvars' => [ |
||
321 | 'action' => 'confirm_setval', |
||
322 | 'server' => $_REQUEST['server'], |
||
323 | 'database' => $_REQUEST['database'], |
||
324 | 'schema' => $_REQUEST['schema'], |
||
325 | 'sequence' => $sequence->fields['seqname'], |
||
326 | ], |
||
327 | ], |
||
328 | ], |
||
329 | 'content' => $lang['strsetval'], |
||
330 | ], |
||
331 | 'nextval' => [ |
||
332 | 'attr' => [ |
||
333 | 'href' => [ |
||
334 | 'url' => 'sequences.php', |
||
335 | 'urlvars' => [ |
||
336 | 'action' => 'nextval', |
||
337 | 'server' => $_REQUEST['server'], |
||
338 | 'database' => $_REQUEST['database'], |
||
339 | 'schema' => $_REQUEST['schema'], |
||
340 | 'sequence' => $sequence->fields['seqname'], |
||
341 | ], |
||
342 | ], |
||
343 | ], |
||
344 | 'content' => $lang['strnextval'], |
||
345 | ], |
||
346 | 'restart' => [ |
||
347 | 'attr' => [ |
||
348 | 'href' => [ |
||
349 | 'url' => 'sequences.php', |
||
350 | 'urlvars' => [ |
||
351 | 'action' => 'restart', |
||
352 | 'server' => $_REQUEST['server'], |
||
353 | 'database' => $_REQUEST['database'], |
||
354 | 'schema' => $_REQUEST['schema'], |
||
355 | 'sequence' => $sequence->fields['seqname'], |
||
356 | ], |
||
357 | ], |
||
358 | ], |
||
359 | 'content' => $lang['strrestart'], |
||
360 | ], |
||
361 | 'reset' => [ |
||
362 | 'attr' => [ |
||
363 | 'href' => [ |
||
364 | 'url' => 'sequences.php', |
||
365 | 'urlvars' => [ |
||
366 | 'action' => 'reset', |
||
367 | 'server' => $_REQUEST['server'], |
||
368 | 'database' => $_REQUEST['database'], |
||
369 | 'schema' => $_REQUEST['schema'], |
||
370 | 'sequence' => $sequence->fields['seqname'], |
||
371 | ], |
||
372 | ], |
||
373 | ], |
||
374 | 'content' => $lang['strreset'], |
||
375 | ], |
||
376 | 'showall' => [ |
||
377 | 'attr' => [ |
||
378 | 'href' => [ |
||
379 | 'url' => 'sequences.php', |
||
380 | 'urlvars' => [ |
||
381 | 'server' => $_REQUEST['server'], |
||
382 | 'database' => $_REQUEST['database'], |
||
383 | 'schema' => $_REQUEST['schema'], |
||
384 | ], |
||
385 | ], |
||
386 | ], |
||
387 | 'content' => $lang['strshowallsequences'], |
||
388 | ], |
||
389 | ]; |
||
390 | |||
391 | if (!$data->hasAlterSequenceStart()) { |
||
392 | unset($navlinks['restart']); |
||
393 | } |
||
394 | |||
395 | $this->printNavLinks($navlinks, 'sequences-properties', get_defined_vars()); |
||
396 | } else { |
||
397 | echo "<p>{$lang['strnodata']}</p>\n"; |
||
398 | } |
||
399 | } |
||
400 | |||
401 | /** |
||
402 | * Drop a sequence. |
||
403 | * |
||
404 | * @param mixed $confirm |
||
1 ignored issue
–
show
|
|||
405 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
406 | */ |
||
407 | public function doDrop($confirm, $msg = '') |
||
408 | { |
||
409 | $conf = $this->conf; |
||
410 | |||
411 | $lang = $this->lang; |
||
412 | $data = $this->misc->getDatabaseAccessor(); |
||
413 | |||
414 | if (empty($_REQUEST['sequence']) && empty($_REQUEST['ma'])) { |
||
415 | return $this->doDefault($lang['strspecifysequencetodrop']); |
||
416 | } |
||
417 | |||
418 | if ($confirm) { |
||
419 | $this->printTrail('sequence'); |
||
420 | $this->printTitle($lang['strdrop'], 'pg.sequence.drop'); |
||
421 | $this->printMsg($msg); |
||
422 | |||
423 | echo '<form action="'.\SUBFOLDER."/src/views/sequences.php\" method=\"post\">\n"; |
||
424 | |||
425 | //If multi drop |
||
426 | if (isset($_REQUEST['ma'])) { |
||
427 | foreach ($_REQUEST['ma'] as $v) { |
||
428 | $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
||
429 | echo '<p>', sprintf($lang['strconfdropsequence'], $this->misc->printVal($a['sequence'])), "</p>\n"; |
||
430 | printf('<input type="hidden" name="sequence[]" value="%s" />', htmlspecialchars($a['sequence'])); |
||
431 | } |
||
432 | } else { |
||
433 | echo '<p>', sprintf($lang['strconfdropsequence'], $this->misc->printVal($_REQUEST['sequence'])), "</p>\n"; |
||
434 | echo '<input type="hidden" name="sequence" value="', htmlspecialchars($_REQUEST['sequence']), "\" />\n"; |
||
435 | } |
||
436 | |||
437 | echo "<p><input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$lang['strcascade']}</label></p>\n"; |
||
438 | echo "<p><input type=\"hidden\" name=\"action\" value=\"drop\" />\n"; |
||
439 | echo $this->misc->form; |
||
440 | echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n"; |
||
441 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
||
442 | echo "</form>\n"; |
||
443 | } else { |
||
444 | if (is_array($_POST['sequence'])) { |
||
445 | $msg = ''; |
||
446 | $status = $data->beginTransaction(); |
||
447 | if (0 == $status) { |
||
448 | foreach ($_POST['sequence'] as $s) { |
||
449 | $status = $data->dropSequence($s, isset($_POST['cascade'])); |
||
450 | if (0 == $status) { |
||
451 | $msg .= sprintf('%s: %s<br />', htmlentities($s, ENT_QUOTES, 'UTF-8'), $lang['strsequencedropped']); |
||
452 | } else { |
||
453 | $data->endTransaction(); |
||
454 | $this->doDefault(sprintf('%s%s: %s<br />', $msg, htmlentities($s, ENT_QUOTES, 'UTF-8'), $lang['strsequencedroppedbad'])); |
||
455 | |||
456 | return; |
||
457 | } |
||
458 | } |
||
459 | } |
||
460 | if (0 == $data->endTransaction()) { |
||
461 | // Everything went fine, back to the Default page.... |
||
462 | $this->misc->setReloadBrowser(true); |
||
463 | $this->doDefault($msg); |
||
464 | } else { |
||
465 | $this->doDefault($lang['strsequencedroppedbad']); |
||
466 | } |
||
467 | } else { |
||
468 | $status = $data->dropSequence($_POST['sequence'], isset($_POST['cascade'])); |
||
469 | if (0 == $status) { |
||
470 | $this->misc->setReloadBrowser(true); |
||
471 | $this->doDefault($lang['strsequencedropped']); |
||
472 | } else { |
||
473 | $this->doDrop(true, $lang['strsequencedroppedbad']); |
||
474 | } |
||
475 | } |
||
476 | } |
||
477 | } |
||
478 | |||
479 | /** |
||
480 | * Displays a screen where they can enter a new sequence. |
||
481 | * |
||
482 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
483 | */ |
||
484 | public function doCreateSequence($msg = '') |
||
485 | { |
||
486 | $conf = $this->conf; |
||
487 | |||
488 | $lang = $this->lang; |
||
489 | $data = $this->misc->getDatabaseAccessor(); |
||
490 | |||
491 | if (!isset($_POST['formSequenceName'])) { |
||
492 | $_POST['formSequenceName'] = ''; |
||
493 | } |
||
494 | |||
495 | if (!isset($_POST['formIncrement'])) { |
||
496 | $_POST['formIncrement'] = ''; |
||
497 | } |
||
498 | |||
499 | if (!isset($_POST['formMinValue'])) { |
||
500 | $_POST['formMinValue'] = ''; |
||
501 | } |
||
502 | |||
503 | if (!isset($_POST['formMaxValue'])) { |
||
504 | $_POST['formMaxValue'] = ''; |
||
505 | } |
||
506 | |||
507 | if (!isset($_POST['formStartValue'])) { |
||
508 | $_POST['formStartValue'] = ''; |
||
509 | } |
||
510 | |||
511 | if (!isset($_POST['formCacheValue'])) { |
||
512 | $_POST['formCacheValue'] = ''; |
||
513 | } |
||
514 | |||
515 | $this->printTrail('schema'); |
||
516 | $this->printTitle($lang['strcreatesequence'], 'pg.sequence.create'); |
||
517 | $this->printMsg($msg); |
||
518 | |||
519 | echo '<form action="'.\SUBFOLDER."/src/views/sequences.php\" method=\"post\">\n"; |
||
520 | echo "<table>\n"; |
||
521 | |||
522 | echo "<tr><th class=\"data left required\">{$lang['strname']}</th>\n"; |
||
523 | echo "<td class=\"data1\"><input name=\"formSequenceName\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
524 | htmlspecialchars($_POST['formSequenceName']), "\" /></td></tr>\n"; |
||
525 | |||
526 | echo "<tr><th class=\"data left\">{$lang['strincrementby']}</th>\n"; |
||
527 | echo '<td class="data1"><input name="formIncrement" size="5" value="', |
||
528 | htmlspecialchars($_POST['formIncrement']), "\" /> </td></tr>\n"; |
||
529 | |||
530 | echo "<tr><th class=\"data left\">{$lang['strminvalue']}</th>\n"; |
||
531 | echo '<td class="data1"><input name="formMinValue" size="5" value="', |
||
532 | htmlspecialchars($_POST['formMinValue']), "\" /></td></tr>\n"; |
||
533 | |||
534 | echo "<tr><th class=\"data left\">{$lang['strmaxvalue']}</th>\n"; |
||
535 | echo '<td class="data1"><input name="formMaxValue" size="5" value="', |
||
536 | htmlspecialchars($_POST['formMaxValue']), "\" /></td></tr>\n"; |
||
537 | |||
538 | echo "<tr><th class=\"data left\">{$lang['strstartvalue']}</th>\n"; |
||
539 | echo '<td class="data1"><input name="formStartValue" size="5" value="', |
||
540 | htmlspecialchars($_POST['formStartValue']), "\" /></td></tr>\n"; |
||
541 | |||
542 | echo "<tr><th class=\"data left\">{$lang['strcachevalue']}</th>\n"; |
||
543 | echo '<td class="data1"><input name="formCacheValue" size="5" value="', |
||
544 | htmlspecialchars($_POST['formCacheValue']), "\" /></td></tr>\n"; |
||
545 | |||
546 | echo "<tr><th class=\"data left\"><label for=\"formCycledValue\">{$lang['strcancycle']}</label></th>\n"; |
||
547 | echo '<td class="data1"><input type="checkbox" id="formCycledValue" name="formCycledValue" ', |
||
548 | (isset($_POST['formCycledValue']) ? ' checked="checked"' : ''), " /></td></tr>\n"; |
||
549 | |||
550 | echo "</table>\n"; |
||
551 | echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create_sequence\" />\n"; |
||
552 | echo $this->misc->form; |
||
553 | echo "<input type=\"submit\" name=\"create\" value=\"{$lang['strcreate']}\" />\n"; |
||
554 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
||
555 | echo "</form>\n"; |
||
556 | } |
||
557 | |||
558 | /** |
||
559 | * Actually creates the new sequence in the database. |
||
560 | */ |
||
561 | public function doSaveCreateSequence() |
||
562 | { |
||
563 | $conf = $this->conf; |
||
564 | |||
565 | $lang = $this->lang; |
||
566 | $data = $this->misc->getDatabaseAccessor(); |
||
567 | |||
568 | // Check that they've given a name and at least one column |
||
569 | if ('' == $_POST['formSequenceName']) { |
||
570 | $this->doCreateSequence($lang['strsequenceneedsname']); |
||
571 | } else { |
||
572 | $status = $data->createSequence( |
||
573 | $_POST['formSequenceName'], |
||
574 | $_POST['formIncrement'], |
||
575 | $_POST['formMinValue'], |
||
576 | $_POST['formMaxValue'], |
||
577 | $_POST['formStartValue'], |
||
578 | $_POST['formCacheValue'], |
||
579 | isset($_POST['formCycledValue']) |
||
580 | ); |
||
581 | if (0 == $status) { |
||
582 | $this->doDefault($lang['strsequencecreated']); |
||
583 | } else { |
||
584 | $this->doCreateSequence($lang['strsequencecreatedbad']); |
||
585 | } |
||
586 | } |
||
587 | } |
||
588 | |||
589 | /** |
||
590 | * Restarts a sequence. |
||
591 | */ |
||
592 | public function doRestart() |
||
593 | { |
||
594 | $conf = $this->conf; |
||
595 | |||
596 | $lang = $this->lang; |
||
597 | $data = $this->misc->getDatabaseAccessor(); |
||
598 | |||
599 | $status = $data->restartSequence($_REQUEST['sequence']); |
||
600 | if (0 == $status) { |
||
601 | $this->doProperties($lang['strsequencerestart']); |
||
602 | } else { |
||
603 | $this->doProperties($lang['strsequencerestartbad']); |
||
604 | } |
||
605 | } |
||
606 | |||
607 | /** |
||
608 | * Resets a sequence. |
||
609 | */ |
||
610 | public function doReset() |
||
611 | { |
||
612 | $conf = $this->conf; |
||
613 | |||
614 | $lang = $this->lang; |
||
615 | $data = $this->misc->getDatabaseAccessor(); |
||
616 | |||
617 | $status = $data->resetSequence($_REQUEST['sequence']); |
||
618 | if (0 == $status) { |
||
619 | $this->doProperties($lang['strsequencereset']); |
||
620 | } else { |
||
621 | $this->doProperties($lang['strsequenceresetbad']); |
||
622 | } |
||
623 | } |
||
624 | |||
625 | /** |
||
626 | * Set Nextval of a sequence. |
||
627 | */ |
||
628 | public function doNextval() |
||
629 | { |
||
630 | $conf = $this->conf; |
||
631 | |||
632 | $lang = $this->lang; |
||
633 | $data = $this->misc->getDatabaseAccessor(); |
||
634 | |||
635 | $status = $data->nextvalSequence($_REQUEST['sequence']); |
||
636 | if (0 == $status) { |
||
637 | $this->doProperties($lang['strsequencenextval']); |
||
638 | } else { |
||
639 | $this->doProperties($lang['strsequencenextvalbad']); |
||
640 | } |
||
641 | } |
||
642 | |||
643 | /** |
||
644 | * Function to save after 'setval'ing a sequence. |
||
645 | */ |
||
646 | public function doSaveSetval() |
||
647 | { |
||
648 | $conf = $this->conf; |
||
649 | |||
650 | $lang = $this->lang; |
||
651 | $data = $this->misc->getDatabaseAccessor(); |
||
652 | |||
653 | $status = $data->setvalSequence($_POST['sequence'], $_POST['nextvalue']); |
||
654 | if (0 == $status) { |
||
655 | $this->doProperties($lang['strsequencesetval']); |
||
656 | } else { |
||
657 | $this->doProperties($lang['strsequencesetvalbad']); |
||
658 | } |
||
659 | } |
||
660 | |||
661 | /** |
||
662 | * Function to allow 'setval'ing of a sequence. |
||
663 | * |
||
664 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
665 | */ |
||
666 | public function doSetval($msg = '') |
||
667 | { |
||
668 | $conf = $this->conf; |
||
669 | |||
670 | $lang = $this->lang; |
||
671 | $data = $this->misc->getDatabaseAccessor(); |
||
672 | |||
673 | $this->printTrail('sequence'); |
||
674 | $this->printTitle($lang['strsetval'], 'pg.sequence'); |
||
675 | $this->printMsg($msg); |
||
676 | |||
677 | // Fetch the sequence information |
||
678 | $sequence = $data->getSequence($_REQUEST['sequence']); |
||
679 | |||
680 | if (is_object($sequence) && $sequence->recordCount() > 0) { |
||
681 | echo '<form action="'.\SUBFOLDER."/src/views/sequences.php\" method=\"post\">\n"; |
||
682 | echo '<table border="0">'; |
||
683 | echo "<tr><th class=\"data left required\">{$lang['strlastvalue']}</th>\n"; |
||
684 | echo '<td class="data1">'; |
||
685 | echo "<input name=\"nextvalue\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
686 | $this->misc->printVal($sequence->fields['last_value']), "\" /></td></tr>\n"; |
||
687 | echo "</table>\n"; |
||
688 | echo "<p><input type=\"hidden\" name=\"action\" value=\"setval\" />\n"; |
||
689 | echo '<input type="hidden" name="sequence" value="', htmlspecialchars($_REQUEST['sequence']), "\" />\n"; |
||
690 | echo $this->misc->form; |
||
691 | echo "<input type=\"submit\" name=\"setval\" value=\"{$lang['strsetval']}\" />\n"; |
||
692 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
||
693 | echo "</form>\n"; |
||
694 | } else { |
||
695 | echo "<p>{$lang['strnodata']}</p>\n"; |
||
696 | } |
||
697 | } |
||
698 | |||
699 | /** |
||
700 | * Function to save after altering a sequence. |
||
701 | */ |
||
702 | public function doSaveAlter() |
||
775 | } |
||
776 | } |
||
777 | |||
778 | /** |
||
779 | * Function to allow altering of a sequence. |
||
780 | * |
||
781 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
782 | */ |
||
783 | public function doAlter($msg = '') |
||
900 | } |
||
901 | } |
||
902 | } |
||
903 |