index.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. // check for right of current admin on this module
  3. if (cfr('CITY')) {
  4. $messages = new UbillingMessageHelper();
  5. $errorStyling = 'style="margin: auto 0; padding: 10px 3px; width: 100%;"';
  6. if (ubRouting::checkPost('newcityname')) {
  7. $newcityname = ubRouting::post('newcityname', 'safe');
  8. $newcityalias = (ubRouting::checkPost('newcityalias')) ? ubRouting::post('newcityalias', 'gigasafe') : '';
  9. if (!empty($newcityname)) {
  10. $FoundCityID = checkCityExists($newcityname);
  11. if (empty($FoundCityID)) {
  12. $cityCreationResult = zb_AddressCreateCity($newcityname, $newcityalias);
  13. if ($cityCreationResult) {
  14. $errormes = $messages->getStyledMessage($cityCreationResult, 'error', $errorStyling);
  15. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  16. } else {
  17. die();
  18. }
  19. } else {
  20. $errormes = $messages->getStyledMessage(__('City with such name already exists with ID: ') . $FoundCityID, 'error', $errorStyling);
  21. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  22. }
  23. }
  24. }
  25. if (ubRouting::checkGet('action')) {
  26. if (ubRouting::checkGet('cityid', false)) {
  27. $cityid = ubRouting::get('cityid', 'int');
  28. if (ubRouting::get('action') == 'delete') {
  29. if (!zb_AddressCityProtected($cityid)) {
  30. zb_AddressDeleteCity($cityid);
  31. die();
  32. } else {
  33. $errormes = $messages->getStyledMessage(__('You can not just remove a city where there are streets and possibly survivors'), 'error', $errorStyling);
  34. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::get('errfrmid'), '', true));
  35. }
  36. }
  37. if (ubRouting::get('action') == 'edit') {
  38. if (ubRouting::checkPost('editcityname')) {
  39. if (ubRouting::post('editcityname', 'safe')) {
  40. $FoundCityID = checkCityExists(ubRouting::post('editcityname', 'safe'), $cityid);
  41. if (empty($FoundCityID)) {
  42. $cityRenameResult = zb_AddressChangeCityName($cityid, ubRouting::post('editcityname', 'safe'));
  43. if (!empty($cityRenameResult)) {
  44. $errormes = $messages->getStyledMessage($cityRenameResult, 'error', $errorStyling);
  45. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  46. }
  47. } else {
  48. $errormes = $messages->getStyledMessage(__('City with such name already exists with ID: ') . $FoundCityID, 'error', $errorStyling);
  49. die(wf_modalAutoForm(__('Error'), $errormes, ubRouting::post('errfrmid'), '', true));
  50. }
  51. }
  52. zb_AddressChangeCityAlias($cityid, ubRouting::post('editcityalias', 'gigasafe'));
  53. die();
  54. } else {
  55. die(wf_modalAutoForm(__('Edit City'), web_CityEditForm($cityid, ubRouting::get('ModalWID')), ubRouting::get('ModalWID'), ubRouting::get('ModalWBID'), true));
  56. }
  57. }
  58. }
  59. }
  60. if (ubRouting::checkGet('ajax')) {
  61. renderCityJSON();
  62. }
  63. show_window(__('Available cities'), web_CityLister());
  64. } else {
  65. show_error(__('You cant control this module'));
  66. }