Fixed saving edit_by in some Controllers

This commit is contained in:
Frank Schubert
2025-01-24 15:04:24 +01:00
parent 22bd84663a
commit 39cf386638
53 changed files with 556 additions and 61 deletions

View File

@@ -16,8 +16,19 @@ class ADBHausnummer extends mfBaseModel {
$this->table = "Hausnummer"; $this->table = "Hausnummer";
mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, 0); mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, 0);
} }
public function afterSave() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function afterSave() {
// prevent potential infinite loop // prevent potential infinite loop
$nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id); $nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id);
if(!$nesting_level) { if(!$nesting_level) {

View File

@@ -13,7 +13,17 @@ class ADBWohneinheit extends mfBaseModel {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->table = "Wohneinheit"; $this->table = "Wohneinheit";
} }
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function afterSave() { protected function afterSave() {
if(!$this->id) return true; if(!$this->id) return true;
if(!$this->hausnummer_id) return true; if(!$this->hausnummer_id) return true;

View File

@@ -41,9 +41,18 @@ class Address extends mfBaseModel {
$this->getCoords(); $this->getCoords();
$this->in_after_save--; $this->in_after_save--;
} }
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getCoords() { public function getCoords() {
$update_needed = false; $update_needed = false;
if($this->id) { if($this->id) {

View File

@@ -355,11 +355,7 @@ class AddressController extends mfBaseController {
$data['allow_contact'] = ($r->allow_contact) ? 1 : 0; $data['allow_contact'] = ($r->allow_contact) ? 1 : 0;
$data['allow_spin'] = ($r->allow_spin) ? 1 : 0; $data['allow_spin'] = ($r->allow_spin) ? 1 : 0;
$data['edit_by'] = 1;
if($mode == "add") { if($mode == "add") {
$data['create_by'] = 1;
$address = AddressModel::create($data); $address = AddressModel::create($data);
} else { } else {
$address->update($data); $address->update($data);

View File

@@ -28,8 +28,18 @@ class Building extends mfBaseModel {
return $address; return $address;
} }
protected function afterSave() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function afterSave() {
if($this->in_after_save) return true; if($this->in_after_save) return true;
$this->in_after_save++; $this->in_after_save++;

View File

@@ -216,8 +216,6 @@ class BuildingController extends mfBaseController {
$data['description'] = trim($r->description); $data['description'] = trim($r->description);
$data['note'] = trim($r->note); $data['note'] = trim($r->note);
$data['edit_by'] = 1;
if($this->me->is(["Admin", "netowner"])) { if($this->me->is(["Admin", "netowner"])) {
if($r->gps_lat) $data['gps_lat'] = trim($r->gps_lat); if($r->gps_lat) $data['gps_lat'] = trim($r->gps_lat);
if($r->gps_long) $data['gps_long'] = trim($r->gps_long); if($r->gps_long) $data['gps_long'] = trim($r->gps_long);

View File

@@ -20,6 +20,16 @@ class ConstructionConsent extends mfBaseModel {
private $footer_size = "8"; private $footer_size = "8";
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function afterSave() { protected function afterSave() {
$this->createHistory(); $this->createHistory();
} }

View File

@@ -3,6 +3,16 @@
class ConstructionConsentContact extends mfBaseModel { class ConstructionConsentContact extends mfBaseModel {
private $consent; private $consent;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {

View File

@@ -6,6 +6,16 @@ class ConstructionConsentHistory extends mfBaseModel {
private $editor; private $editor;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getValue($type = "new", $raw = false) { public function getValue($type = "new", $raw = false) {
if($type != "old" && $type != "new") return null; if($type != "old" && $type != "new") return null;

View File

@@ -5,6 +5,15 @@ class ConstructionConsentJournal extends mfBaseModel {
private $creator; private $creator;
private $editor; private $editor;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if($name == "creator") { if($name == "creator") {

View File

@@ -3,6 +3,16 @@
class ConstructionConsentNetwork extends mfBaseModel { class ConstructionConsentNetwork extends mfBaseModel {
private $adb_netzgebiet; private $adb_netzgebiet;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {

View File

@@ -10,6 +10,16 @@ class ConstructionConsentOwner extends mfBaseModel {
$this->createHistory(); $this->createHistory();
} }
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
private function createHistory() { private function createHistory() {
if(!$this->id) return true; if(!$this->id) return true;

View File

@@ -5,6 +5,16 @@ class ConstructionConsentProject extends mfBaseModel {
private $networks; private $networks;
private $adb_networks; private $adb_networks;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {

View File

@@ -39,6 +39,16 @@ class Contract extends mfBaseModel {
private $editor; private $editor;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function afterSave() { protected function afterSave() {
if($this->in_after_save) return true; if($this->in_after_save) return true;
$this->in_after_save++; $this->in_after_save++;

View File

@@ -885,7 +885,6 @@ class ContractController extends mfBaseController {
if ($mode == "add") { if ($mode == "add") {
$contract = ContractModel::create($contract_data); $contract = ContractModel::create($contract_data);
} else { } else {
$contract->edit_by = $this->me->id;
$contract->update($contract_data); $contract->update($contract_data);
} }

View File

@@ -3,8 +3,19 @@
class ContractconfigItem extends mfBaseModel { class ContractconfigItem extends mfBaseModel {
private $value; private $value;
public $contract_id; public $contract_id;
public function setContractId($contract_id) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function setContractId($contract_id) {
if(!is_numeric($contract_id)) { if(!is_numeric($contract_id)) {
return false; return false;
} }

View File

@@ -3,7 +3,17 @@
class ContractconfigValue extends mfBaseModel { class ContractconfigValue extends mfBaseModel {
private $item; private $item;
protected function afterSave() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function afterSave() {
$this->runAfterSaveHooks(); $this->runAfterSaveHooks();
} }

View File

@@ -3,8 +3,19 @@
class Contractconfiggroup extends mfBaseModel { class Contractconfiggroup extends mfBaseModel {
private $items; private $items;
private $contract_id; private $contract_id;
public function setContractId($contract_id) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function setContractId($contract_id) {
if(!is_numeric($contract_id)) { if(!is_numeric($contract_id)) {
return false; return false;
} }

View File

@@ -3,8 +3,18 @@
class ContractconfiggroupProductgroup extends mfBaseModel { class ContractconfiggroupProductgroup extends mfBaseModel {
private $productgroup; private $productgroup;
private $contractconfiggroup; private $contractconfiggroup;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if(!$this->id) { if(!$this->id) {

View File

@@ -5,8 +5,18 @@ class Contractjournal extends mfBaseModel {
private $contractfile; private $contractfile;
private $creator; private $creator;
private $editor; private $editor;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if($name == "contractfile") { if($name == "contractfile") {

View File

@@ -16,7 +16,17 @@ class Contractqueue extends mfBaseModel {
private $creator; private $creator;
private $editor; private $editor;
protected function afterSave() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function afterSave() {
$this->crediting_partner = null; $this->crediting_partner = null;
$this->reseller = null; $this->reseller = null;
$this->owner = null; $this->owner = null;

View File

@@ -6,6 +6,16 @@ class Mailtemplate extends mfBaseModel {
private $editor; private $editor;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getVariableReplacedSubject($replaceVars) { public function getVariableReplacedSubject($replaceVars) {
return $this->replaceVariables($this->subject, $replaceVars); return $this->replaceVariables($this->subject, $replaceVars);
} }

View File

@@ -8,6 +8,15 @@ class MailtemplateDispatch extends mfBaseModel {
private $creator; private $creator;
private $editor; private $editor;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function sendToRecipients($test_to_email = false) { public function sendToRecipients($test_to_email = false) {
$emails = []; $emails = [];

View File

@@ -6,6 +6,16 @@ class MaintenanceNotification extends mfBaseModel {
private $editor; private $editor;
private $creator; private $creator;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function sendToRecipients($test_to_email = false) { public function sendToRecipients($test_to_email = false) {
$emails = $this->getRecipients(); $emails = $this->getRecipients();

View File

@@ -3,6 +3,15 @@
class MaintenanceNotificationTemplate extends mfBaseModel { class MaintenanceNotificationTemplate extends mfBaseModel {
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {

View File

@@ -9,8 +9,17 @@ class Network extends mfBaseModel {
private $buildings; private $buildings;
private $adb_netzgebiet; private $adb_netzgebiet;
protected function beforeUpdate($data) {
public function getTypeAddresses($search_type) { if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getTypeAddresses($search_type) {
if(!$this->id) { if(!$this->id) {
return false; return false;
} }

View File

@@ -7,8 +7,18 @@ class OpenAccessId extends mfBaseModel {
private $adb_wohneinheit; private $adb_wohneinheit;
private $adb_wohneinheit_count; private $adb_wohneinheit_count;
private $termination; private $termination;
public function loadRandomUnassigned($attributes = []) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function loadRandomUnassigned($attributes = []) {
$where = "active = 1 AND assigned = 0 AND adb_wohneinheit_id IS NULL AND termination_id IS NULL AND exported = 0 AND exported_to IS NULL"; $where = "active = 1 AND assigned = 0 AND adb_wohneinheit_id IS NULL AND termination_id IS NULL AND exported = 0 AND exported_to IS NULL";
if(array_key_exists("owner_id", $attributes) && $attributes['owner_id']) { if(array_key_exists("owner_id", $attributes) && $attributes['owner_id']) {

View File

@@ -16,7 +16,17 @@ class Order extends mfBaseModel {
private $shippingdate; private $shippingdate;
protected function afterSave() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function afterSave() {
if($this->billingaddress_id) { if($this->billingaddress_id) {
$this->getProperty("billingaddress")->generateFibuAccountNumber(); $this->getProperty("billingaddress")->generateFibuAccountNumber();
} }

View File

@@ -4,8 +4,18 @@ class OrderJournal extends mfBaseModel {
private $order; private $order;
private $creator; private $creator;
private $editor; private $editor;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if(!$this->id) { if(!$this->id) {

View File

@@ -10,8 +10,19 @@ class OrderProduct extends mfBaseModel {
private $voiceplan; private $voiceplan;
private $editor; private $editor;
private $creator; private $creator;
public function formatAmount() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function formatAmount() {
if(!$this->id) { if(!$this->id) {
return 0; return 0;
} }

View File

@@ -3,8 +3,19 @@
class Pop extends mfBaseModel { class Pop extends mfBaseModel {
protected $forcestr = ['gps_lat','gps_long','vlan_public','vlan_nat','vlan_ipv6']; protected $forcestr = ['gps_lat','gps_long','vlan_public','vlan_nat','vlan_ipv6'];
private $network; private $network;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if ($this->$name == null) { if ($this->$name == null) {
if (!$this->id) { if (!$this->id) {

View File

@@ -21,6 +21,16 @@ class Preorder extends mfBaseModel {
private $logistics; private $logistics;
private $history; private $history;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function afterLoad() { public function afterLoad() {
if($this->uid === "string") { if($this->uid === "string") {
$this->uid = ""; $this->uid = "";

View File

@@ -23,8 +23,19 @@ class Preordercampaign extends mfBaseModel {
private $active_operators; private $active_operators;
private $passive_operators; private $passive_operators;
private $statusnotifcation_mailtemplates; private $statusnotifcation_mailtemplates;
public function getAllFcpNames() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getAllFcpNames() {
if(!$this->id) return []; if(!$this->id) return [];
$network = $this->getProperty("network"); $network = $this->getProperty("network");

View File

@@ -1,5 +1,15 @@
<?php <?php
class PreordercampaignApiuser extends mfBaseModel { class PreordercampaignApiuser extends mfBaseModel {
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
} }

View File

@@ -6,6 +6,16 @@ class PreordercampaignOperator extends mfBaseModel
private $preordercampaign; private $preordercampaign;
private $isps; private $isps;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
protected function beforeDelete() { protected function beforeDelete() {
// delete all ISPs // delete all ISPs
foreach(PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $this->id]) as $isp) { foreach(PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $this->id]) as $isp) {

View File

@@ -4,6 +4,16 @@ class PreordercampaignOperatorIsp extends mfBaseModel
{ {
private $isp; private $isp;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {

View File

@@ -1,5 +1,15 @@
<?php <?php
class PreordercampaignOriginhostname extends mfBaseModel { class PreordercampaignOriginhostname extends mfBaseModel {
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
} }

View File

@@ -1,5 +1,15 @@
<?php <?php
class PreordercampaignSalescluster extends mfBaseModel { class PreordercampaignSalescluster extends mfBaseModel {
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
} }

View File

@@ -5,6 +5,16 @@ class PreordercampaignStatusnotificationMailtemplate extends mfBaseModel {
private $mailtemplate; private $mailtemplate;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {

View File

@@ -7,8 +7,18 @@ class Preordernotification extends mfBaseModel {
private $creator; private $creator;
private $editor; private $editor;
public function getPreorders() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getPreorders() {
if(!$this->preordercampaign_id) return false; if(!$this->preordercampaign_id) return false;
$preorder_filter = json_decode($this->preorder_filter, true); $preorder_filter = json_decode($this->preorder_filter, true);

View File

@@ -7,8 +7,18 @@ class Product extends mfBaseModel {
private $sla; private $sla;
private $networks; private $networks;
private $attributes; private $attributes;
public function loadAttributes() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function loadAttributes() {
$this->attributes = []; $this->attributes = [];
if(!$this->producttech_id) { if(!$this->producttech_id) {

View File

@@ -3,8 +3,18 @@
class ProductNetwork extends mfBaseModel { class ProductNetwork extends mfBaseModel {
private $product; private $product;
private $network; private $network;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if(!$this->id) { if(!$this->id) {

View File

@@ -3,8 +3,18 @@
class Productgroup extends mfBaseModel { class Productgroup extends mfBaseModel {
private $products; private $products;
private $contractconfiggroups; private $contractconfiggroups;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if(!$this->id) { if(!$this->id) {

View File

@@ -2,8 +2,18 @@
class Producttech extends mfBaseModel { class Producttech extends mfBaseModel {
private $attributes; private $attributes;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if($name == "attributes") { if($name == "attributes") {

View File

@@ -4,6 +4,16 @@ class RimoWorkorder extends mfBaseModel {
private $adb_wohneinheit; private $adb_wohneinheit;
private $termination; private $termination;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function afterSave() { public function afterSave() {
// prevent potential infinite loop // prevent potential infinite loop
$nesting_level = mfValuecache::singleton()->get("rimoworkorder-save-nesting-level-".$this->id); $nesting_level = mfValuecache::singleton()->get("rimoworkorder-save-nesting-level-".$this->id);

View File

@@ -2,8 +2,18 @@
class Vatgroup extends mfBaseModel { class Vatgroup extends mfBaseModel {
private $rates; private $rates;
private function loadRates() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
private function loadRates() {
foreach(VatrateModel::search(["vatgroup_id" => $this->id]) as $rate) { foreach(VatrateModel::search(["vatgroup_id" => $this->id]) as $rate) {
$this->rates[$rate->area] = $rate; $this->rates[$rate->area] = $rate;
} }

View File

@@ -1,5 +1,15 @@
<?php <?php
class Vatrate extends mfBaseModel { class Vatrate extends mfBaseModel {
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
} }

View File

@@ -4,8 +4,18 @@ class Voicenumber extends mfBaseModel {
private $block; private $block;
private $orderproduct; private $orderproduct;
private $contract; private $contract;
public function loadFromBlock(Voicenumberblock $block) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function loadFromBlock(Voicenumberblock $block) {
$this->voicenumberblock_id = $block->id; $this->voicenumberblock_id = $block->id;
//$this->countrycode = $block->countrycode; //$this->countrycode = $block->countrycode;
//$this->areacode = $block->areacode; //$this->areacode = $block->areacode;

View File

@@ -10,8 +10,19 @@ class Voicenumberblock extends mfBaseModel {
private $short_last; private $short_last;
private $files; private $files;
private $numbers; private $numbers;
public function isNumberInBlock($number) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function isNumberInBlock($number) {
return ($number >= $this->first && $number <= $this->last); return ($number >= $this->first && $number <= $this->last);
} }

View File

@@ -10,7 +10,17 @@ class Voiceplan extends mfBaseModel {
public $import_errors; public $import_errors;
public function getDestinationByNumber($number) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getDestinationByNumber($number) {
if(!$number) return false; if(!$number) return false;
$prefix = $number; $prefix = $number;

View File

@@ -5,8 +5,18 @@ class Voiceplandestination extends mfBaseModel {
private $voiceplan; private $voiceplan;
private $voiceplanzone; private $voiceplanzone;
public function getProperty($name) { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
if(!$this->id) { if(!$this->id) {

View File

@@ -5,8 +5,18 @@ class Voiceplanzone extends mfBaseModel {
private $voiceplan; private $voiceplan;
public $cloned_destinations = []; public $cloned_destinations = [];
public function getDestinationCountOrPrefix() { protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
$me->loadMe();
$data["edit_by"] = $me->id;
}
return $data;
}
public function getDestinationCountOrPrefix() {
$destinations = $this->getProperty("destinations"); $destinations = $this->getProperty("destinations");
if(count($destinations) == 1) { if(count($destinations) == 1) {
return "+".$destinations[0]->prefix; return "+".$destinations[0]->prefix;

View File

@@ -129,6 +129,10 @@ class mfBaseModel {
} }
public function update(array $data) { public function update(array $data) {
if(method_exists($this, "beforeUpdate")) {
$data = $this->beforeUpdate($data);
}
foreach($data as $key => $value) { foreach($data as $key => $value) {
if($value === null) { if($value === null) {
$this->$key = null; $this->$key = null;
@@ -136,6 +140,12 @@ class mfBaseModel {
$this->$key = $value; $this->$key = $value;
} }
} }
if(method_exists($this, "afterUpdate")) {
$this->afterUpdate($data);
}
return true;
} }
public function save() { public function save() {