Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CliDelete.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. # $Id: CliDelete.php 1709 2014-11-01 18:05:39Z christian_boltz $
  3. /**
  4. * class to handle 'delete' in Cli
  5. */
  6. class CliDelete extends Shell {
  7. /**
  8. * Execution method always used for tasks
  9. */
  10. public function execute() {
  11. if (empty($this->args)) {
  12. $this->__interactive();
  13. }
  14. if (!empty($this->args[0])) {
  15. $this->__handle($this->args[0]);
  16. }
  17. }
  18. /**
  19. * Interactive mode
  20. */
  21. protected function __interactive() {
  22. $module = preg_replace('/Handler$/', '', $this->handler_to_use);
  23. $module = strtolower($module);
  24. $question = "Which $module do you want to delete?";
  25. $address = $this->in($question);
  26. $question = "Do you really want to delete '$address'?";
  27. $create = $this->in($question, array('y','n'));
  28. if ($create == 'y') $this->__handle($address);
  29. }
  30. /**
  31. * actually delete something
  32. *
  33. * @param string address to delete
  34. */
  35. protected function __handle($address) {
  36. $handler = new $this->handler_to_use($this->new);
  37. if (!$handler->init($address)) {
  38. $this->err($handler->errormsg);
  39. return;
  40. }
  41. if (!$handler->delete()) {
  42. $this->err($handler->errormsg);
  43. } else {
  44. $this->out($handler->infomsg);
  45. }
  46. }
  47. /**
  48. * Display help contents
  49. *
  50. * @access public
  51. */
  52. public function help() {
  53. $module = preg_replace('/Handler$/', '', $this->handler_to_use);
  54. $module = strtolower($module);
  55. $this->out(
  56. "Usage:
  57. postfixadmin-cli $module delete
  58. Deletes $module in interactive mode.
  59. - or -
  60. postfixadmin-cli $module delete <address>
  61. Deletes $module <address> in non-interactive mode.
  62. ");
  63. $this->_stop();
  64. }
  65. }
  66. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */