function init() { parent::init(); if (!Member::currentUser()) { $link = RegisterAndEditDetailsPage::link_for_going_to_page_via_making_user($this->Link()); $this->redirect($link); } if (isset($_REQUEST["ModuleProductID"])) { $this->moduleProductID = intval($_REQUEST["ModuleProductID"]); } }
public function donewlistingform($data = null, $form = null) { //add new search record here.... if (!isset($data["NewListingAddress"])) { $data["NewListingAddress"] = ''; } if (!isset($data["NewListingName"])) { $data["NewListingName"] = ''; } $extension = ''; if (Versioned::current_stage() == "Live") { $extension = "_Live"; } if (DataObject::get_one("SiteTree", "\"SiteTree{$extension}\".\"Title\" = '" . Convert::raw2sql($data["NewListingName"]) . "'") || !$data["NewListingName"] || strlen($data["NewListingName"]) < 3) { $form->addErrorMessage('NewListingName', 'Sorry, but a listing with that name already exists.', "bad"); Director::redirectBack(); return; } $addressArray = $form->dataFieldByName("NewListingAddress")->getAddressArray(); if ($addressArray) { if (GoogleMapLocationsObject::pointExists($addressArray)) { $form->addErrorMessage('NewListingAddress', 'This address already exists for another listing. Please check the existing listings first to prevent double-ups OR use a more specific address.', "bad"); Director::redirectBack(); return; } $parentPage = BrowseCitiesPage::get_clostest_city_page($addressArray); if (!$parentPage) { $form->addErrorMessage('NewListingAddress', 'Location could not be found. ', "bad"); Director::redirectBack(); return; } $nextLink = $this->linkWithExtras(array("parent" => $parentPage->ID, "address" => $addressArray, "name" => $data["NewListingName"]), 'createnewbusinesslistingfrompoint'); if (!Member::currentMember()) { $nextLink = RegisterAndEditDetailsPage::link_for_going_to_page_via_making_user($nextLink); } Director::redirect($nextLink); return; } $nextLink = $this->linkWithExtras(array("address" => $data["NewListingAddress"], "name" => $data["NewListingName"])); Director::redirect($this->backwardLink); return; }