getName() != "" || $this->getSurname() != "") { $fullname = $this->getName() . ' ' . $this->getSurname(); } } return $fullname; } public function getAddress() { $address = parent::getAddress(); if (null === $address) { if ($this->getStreet() != "" || $this->getHouse() != "" || $this->getFlat() != "") { $old_address = $this->getStreet() . ' ' . $this->getHouse(); if ($this->getFlat() != "") { $old_address .= '/' . $this->getFlat(); } $address = $old_address; } } return $address; } public function getName() { $name = parent::getName(); if (empty($name)) { $fullname_array = explode(' ', parent::getFullName()); $name = $fullname_array[0]; } return $name; } public function getSurname() { $surname = parent::getSurname(); if (empty($surname)) { $fullname_array = explode(' ', parent::getFullName()); foreach ($fullname_array as $key => $array) { if ($key != 0) { $surname .= $array; $surname .= " "; } } $surname = substr($surname, 0, strlen($surname) - 1); } return $surname; } /** * @return string * @deprecated use getAddress method */ public function getStreet() { $street = parent::getStreet(); if (empty($street)) { $aparser = new stAddressParser(parent::getAddress()); $result = $aparser->getAddress(); $street = $result['s1']; } return $street; } /** * @return string * @deprecated use getAddress method */ public function getHouse() { $house = parent::getHouse(); if (empty($house)) { $aparser = new stAddressParser(parent::getAddress()); $result = $aparser->getAddress(); $house = $result['n1']; } return $house; } /** * @return string * @deprecated use getAddress method */ public function getFlat() { $flat = parent::getFlat(); if (empty($flat)) { $aparser = new stAddressParser(parent::getAddress()); $result = $aparser->getAddress(); $flat = $result['n2']; } return $flat; } public function hydrate(ResultSet $rs, $startcol = 1) { $ret = parent::hydrate($rs, $startcol); $crypt = Crypt::getInstance(); if ($crypt->isEncrypted($this->crypt)) { $this->address = $crypt->Decrypt($this->address, $this->crypt); $this->address_more = $crypt->Decrypt($this->address_more, $this->crypt); $this->region = $crypt->Decrypt($this->region, $this->crypt); $this->street = $crypt->Decrypt($this->street, $this->crypt); $this->house = $crypt->Decrypt($this->house, $this->crypt); $this->flat = $crypt->Decrypt($this->flat, $this->crypt); $this->code = $crypt->Decrypt($this->code, $this->crypt); $this->town = $crypt->Decrypt($this->town, $this->crypt); } return $ret; } public function save($con = null, $forced = false) { $crypt = Crypt::getInstance(); $address_more = $this->getAddressMore(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::ADDRESS_MORE)) { $address_more_crypt = $crypt->Encrypt($this->getAddressMore()); $this->setAddressMore($address_more_crypt); } $region = $this->getRegion(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::REGION)) { $region_crypt = $crypt->Encrypt($this->getRegion()); $this->setRegion($region_crypt); } //new format addresss $address = $this->getAddress(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::ADDRESS)) { $address_crypt = $crypt->Encrypt($this->getAddress()); $this->setAddress($address_crypt); } //old format addresss ****************** if (!$address) { $street = $this->getStreet(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::STREET) || $this->isColumnModified(InvoiceUserSellerPeer::ADDRESS)) { $street_crypt = $crypt->Encrypt($this->getStreet()); if ($this->isColumnModified(InvoiceUserSellerPeer::ADDRESS)) { $aparser = new stAddressParser($address); $result = $aparser->getAddress(); $street_crypt = $crypt->Encrypt($result['s1']); $street = $street_crypt; } $this->setStreet($street_crypt); } $house = $this->getHouse(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::HOUSE) || $this->isColumnModified(InvoiceUserSellerPeer::ADDRESS)) { $house_crypt = $crypt->Encrypt($this->getHouse()); if ($this->isColumnModified(InvoiceUserSellerPeer::ADDRESS)) { $aparser = new stAddressParser($address); $result = $aparser->getAddress(); $house_crypt = $crypt->Encrypt($result['n1']); $house = $house_crypt; } $this->setHouse($house_crypt); } $flat = $this->getFlat(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::FLAT) || $this->isColumnModified(InvoiceUserSellerPeer::ADDRESS)) { $flat_crypt = $crypt->Encrypt($this->getFlat()); if ($this->isColumnModified(InvoiceUserSellerPeer::ADDRESS)) { $aparser = new stAddressParser($address); $result = $aparser->getAddress(); $flat_crypt = $crypt->Encrypt(isset($result['n2']) ? $result['n2'] : ''); $flat = $flat_crypt; } $this->setFlat($flat_crypt); } } else { $this->setFlat(null); $this->setHouse(null); $this->setStreet(null); } $code = $this->getCode(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::CODE)) { $code_crypt = $crypt->Encrypt($this->getCode()); $this->setCode($code_crypt); } $town = $this->getTown(); if (!$crypt->checkVersion($this->crypt) || $this->isColumnModified(InvoiceUserSellerPeer::TOWN)) { $town_crypt = $crypt->Encrypt($this->getTown()); $this->setTown($town_crypt); } $this->setCrypt(Crypt::VERSION); $ret = parent::save($con); $this->setAddress($address); $this->setAddressMore($address_more); $this->setRegion($region); if (!$address) { $this->setStreet($street); $this->setHouse($house); $this->setFlat($flat); } $this->setCode($code); $this->setTown($town); return $ret; } }