diff --git a/application/ADBWohneinheit/ADBWohneinheit.php b/application/ADBWohneinheit/ADBWohneinheit.php index c909ab960..1fd57cacc 100644 --- a/application/ADBWohneinheit/ADBWohneinheit.php +++ b/application/ADBWohneinheit/ADBWohneinheit.php @@ -13,6 +13,8 @@ class ADBWohneinheit extends mfBaseModel { if(!$this->id) return true; if(!$this->hausnummer_id) return true; + // ADBWohneinheit_onSave_noAutoUnitCount can be defined if doing bulk + // operations where unit count is calculated seperately if(!defined("ADBWohneinheit_onSave_noAutoUnitCount") || !ADBWohneinheit_onSave_noAutoUnitCount) { $unit_count = ADBWohneinheitModel::count(['hausnummer_id' => $this->hausnummer_id]); $hausnummer = $this->getProperty("hausnummer"); diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 55418ef51..3df7c8f63 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -100,7 +100,7 @@ class Preorder extends mfBaseModel { $oaid->loadRandomUnassigned($oaid_attributes); if(!$oaid->oaid) { - $this->layout->setFlash("Keine weiteren OAIDs verfügbar", "error"); + $this->log->error("Keine weiteren OAIDs verfügbar"); throw new Exception("Keine weiteren OAIDs verfügbar in ".$netowner->getCompanyOrName()); } else { // make sure this OAID is not in use on another wohneinheit by accident @@ -137,7 +137,7 @@ class Preorder extends mfBaseModel { $oaid->unit_string = (string)$wohneinheit; //var_dump($oaid);exit; if(!$oaid->save()) { - $this->layout()->setFlash("Fehler beim Speichern der OAID für Preorder ".$preorder->id); + $this->log->error("Fehler beim Speichern der OAID für Preorder ".$preorder->id); $this->redirect("Preordercampaign", "Admin"); } if(!$this->save()) { diff --git a/application/Preordercampaign/PreordercampaignController.php b/application/Preordercampaign/PreordercampaignController.php index 535d56e14..197139090 100644 --- a/application/Preordercampaign/PreordercampaignController.php +++ b/application/Preordercampaign/PreordercampaignController.php @@ -610,8 +610,8 @@ class PreordercampaignController extends mfBaseController { //$preorder->save(); $resp_data = json_decode($response); if(!is_object($resp_data)) { - $this->log->error("Cannot create RimoWorkorder in Database! Invalid Response! (Preorder code: ".$preorder->ucode.") | Response: \n$response"); - throw new Exception("Cannot create RimoWorkorder in Database! Invalid Response! (Preorder code: ".$preorder->ucode.")"); + $this->log->error("Cannot create RimoWorkorder! Invalid Response! (Preorder code: ".$preorder->ucode.") | Response: \n$response"); + throw new Exception("Cannot create RimoWorkorder! Invalid Response! (Preorder code: ".$preorder->ucode.")"); } $wo = RimoWorkorderModel::create([ diff --git a/lib/mvcfronk/mfRouter/mfRouter.php b/lib/mvcfronk/mfRouter/mfRouter.php index 6036debd3..20ab7826b 100644 --- a/lib/mvcfronk/mfRouter/mfRouter.php +++ b/lib/mvcfronk/mfRouter/mfRouter.php @@ -72,6 +72,7 @@ class mfRouter { // get baseurl from fancy urls if used if(MFUSEFANCYURLS) { + //var_dump($umod, $uaction, $_SERVER); if(!$umod) { $baseurl = $_SERVER['REQUEST_URI']; } @@ -85,6 +86,89 @@ class mfRouter { $baseurl = $m[1]; } } + + // Special case for login, because mod/action in $request mask the real url + if($_SERVER['REQUEST_METHOD'] == "POST" && $umod == "mfLogin" && $uaction == "Login") { + // try to extract baseurl from env + // may not work on all webservers + $virtual = preg_replace('@/+$@', "", $_SERVER["REQUEST_URI"]); + $real = preg_replace('@/+$@', "", $_SERVER['PHP_SELF']); + + $virtual_parts = explode("/", $virtual); + $real_parts = explode("/", $real); + + /* + * if there are no parts then we're good. + * Else find Action in last and Mod in second to last part. + * Action is optional. + * + * In rare cases some parts can match by accident if a folder is + * named the same as a mod or action. There is nothing we can do. + */ + $id_part_virtual = false; + $action_part = false; + $mod_part = false; + + if(is_numeric($virtual_parts[count($virtual_parts) - 1]) && count($virtual_parts) > 2 && count($real_parts)) { + + $id_part_virtual = $virtual_parts[count($virtual_parts) - 1]; + $id_part_real = $real_parts[count($real_parts) - 1]; + + $action_part_virtual = $virtual_parts[count($virtual_parts) - 2]; + $action_part_real = $real_parts[count($real_parts) - 2]; + + $mod_part_virtual = $virtual_parts[count($virtual_parts) - 3]; + $mod_part_real = $real_parts[count($real_parts) - 3]; + + if($id_part_virtual != $id_part_real) { + $id_part = $id_part_virtual; + } + if($action_part_virtual != $action_part_real) { + $action_part = $action_part_virtual; + } + if($mod_part_virtual != $mod_part_real) { + $mod_part = $mod_part_virtual; + } + + } elseif(count($virtual_parts) > 1 && count($real_parts)) { + $action_part_virtual = $virtual_parts[count($virtual_parts) - 1]; + $action_part_real = $real_parts[count($real_parts) - 1]; + + $mod_part_virtual = $virtual_parts[count($virtual_parts) - 2]; + $mod_part_real = $real_parts[count($real_parts) - 2]; + + if($action_part_virtual != $action_part_real) { + $action_part = $action_part_virtual; + } + if($mod_part_virtual != $mod_part_real) { + $mod_part = $mod_part_virtual; + } + + } elseif(count($virtual_parts) && count($real_parts)) { + $mod_part_virtual = $virtual_parts[count($virtual_parts) - 1]; + $mod_part_real = $real_parts[count($real_parts) - 1]; + + if($mod_part_virtual != $mod_part_real) { + $mod_part = $mod_part_virtual; + } + } + + + if($id_part) { + if(preg_match("#^(.+)/$mod_part/$action_part/$id_part/?\\??#i",$_SERVER['REQUEST_URI'],$m)) { + $baseurl = $m[1]; + } + } elseif($mod_part) { + if(preg_match("#^(.+)/$mod_part/$action_part/?\\??#i",$_SERVER['REQUEST_URI'],$m)) { + $baseurl = $m[1]; + } + } else { + if(preg_match("#^(.+)/$action_part/?\\??#i",$_SERVER['REQUEST_URI'],$m)) { + $baseurl = $m[1]; + } + } + + } define("MFFANCYBASEURL",$baseurl); }