/** * Returns the context address. * * @return SilvercartAddress */ public function getAddress() { $member = SilvercartCustomer::currentUser(); $id = $this->customParameters['addressID']; if ($member && $id) { $filter = array("MemberID" => $member->ID, "ID" => $id); $this->address = SilvercartAddress::get()->filter($filter)->first(); } return $this->address; }
/** * statements to be called on instanciation * * @return void * * @author Sebastian Diel <*****@*****.**> * @since 04.03.2014 */ public function init() { $addressID = false; if (isset($_POST['addressID'])) { $addressID = Convert::raw2sql($_POST['addressID']); } else { $addressID = $this->getRequest()->param('ID'); } $this->setAddressID($addressID); $this->setBreadcrumbElementID($addressID); if (is_numeric($addressID)) { // get the address to check whether it is related to the actual customer or not. $address = SilvercartAddress::get()->byID($addressID); if ($address->MemberID > 0) { if ($address->Member()->ID != Member::currentUserID()) { // the address is not related to the customer, redirect elsewhere... $this->redirect($this->Parent()->Link()); } } else { $this->redirect($this->Parent()->Link()); } } else { $this->redirect($this->Parent()->Link()); } $this->registerCustomHtmlForm('SilvercartEditAddressForm', new SilvercartEditAddressForm($this, array('addressID' => $addressID))); parent::init(); }