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 requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     $update = array();
     $group = Group::get()->filter(array("Code" => self::$register_group_code))->first();
     if (!$group) {
         $group = new Group();
         $group->Code = self::$register_group_code;
         $group->Title = self::$register_group_title;
         $group->write();
         Permission::grant($group->ID, self::$register_group_access_key);
         DB::alteration_message("GROUP: " . self::$register_group_code . ' (' . self::$register_group_title . ')', "created");
     } elseif (DB::query("SELECT * FROM Permission WHERE {$bt}GroupID{$bt} = " . $group->ID . " AND {$bt}Code{$bt} = '" . self::$register_group_access_key . "'")->numRecords() == 0) {
         Permission::grant($group->ID, self::$register_group_access_key);
     }
     $page = RegisterAndEditDetailsPage::get()->first();
     if (!$page) {
         $page = new RegisterAndEditDetailsPage();
         $page->Title = "Register";
         $page->URLSegment = "register";
         $page->MenuTitle = "Register";
         $update[] = "created RegisterAndEditDetailsPage";
     }
     if ($page) {
         //REGISTER
         if (strlen($page->Content) < 17) {
             $page->Content = "<p>Please log in or register here.</p>";
             $update[] = "updated Content";
         }
         //WELCOME !
         if (!$page->WelcomeTitle) {
             $page->WelcomeTitle = "Thank you for registering";
             $update[] = "updated WelcomeTitle";
         }
         if (strlen($page->WelcomeContent) < 17) {
             $page->WelcomeContent = "<p>Thank you for registration. Please make sure to remember your username and password.</p>";
             $update[] = "updated WelcomeContent";
         }
         // WELCOME BACK
         if (!$page->TitleLoggedIn) {
             $page->TitleLoggedIn = "Welcome back";
             $update[] = "updated TitleLoggedIn";
         }
         if (!$page->MenuTitleLoggedIn) {
             $page->MenuTitleLoggedIn = "Welcome back";
             $update[] = "updated MenuTitleLoggedIn";
         }
         if (strlen($page->ContentLoggedIn) < 17) {
             $page->ContentLoggedIn = "<p>Welcome back - you can do the following ....</p>";
             $update[] = "updated ContentLoggedIn";
         }
         //THANK YOU FOR UPDATING
         if (!$page->ThankYouTitle) {
             $page->ThankYouTitle = "Thank you for updating your details";
             $update[] = "updated ThankYouTitle";
         }
         if (strlen($page->ThankYouContent) < 17) {
             $page->ThankYouContent = "<p>Thank you for updating your details. </p>";
             $update[] = "updated ThankYouContent";
         }
         //ERRORS!
         if (!$page->ErrorEmailAddressAlreadyExists) {
             $page->ErrorEmailAddressAlreadyExists = "Sorry, that email address is already in use by someone else. You may have setup an account in the past or mistyped your email address.";
             $update[] = "updated ErrorEmailAddressAlreadyExists";
         }
         if (!$page->ErrorBadEmail) {
             $page->ErrorBadEmail = "Sorry, that does not appear a valid email address.";
             $update[] = "updated ErrorBadEmail";
         }
         if (!$page->ErrorPasswordDoNotMatch) {
             $page->ErrorPasswordDoNotMatch = "Your passwords do not match. Please try again.";
             $update[] = "updated ErrorPasswordDoNotMatch";
         }
         if (!$page->ErrorMustSupplyPassword) {
             $page->ErrorMustSupplyPassword = "******";
             $update[] = "updated ErrorMustSupplyPassword";
         }
         if (count($update)) {
             $page->writeToStage('Stage');
             $page->publish('Stage', 'Live');
             DB::alteration_message($page->ClassName . " created/updated: <ul><li>" . implode("</li><li>", $update) . "</li></ul>", 'created');
         }
     }
 }
 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;
 }
 protected function createBodyAppendix($screenName)
 {
     $pageLink = Director::absoluteURL($this->Link());
     $passwordResetLink = Director::absoluteURL("Security/lostpassword");
     $logInLink = Director::absoluteURL("Security/login");
     $editYourDetailsLink = Director::absoluteURL(RegisterAndEditDetailsPage::get()->first()->Link());
     $customisationArray = array("ID" => $this->ID, "PageLink" => $pageLink, "PasswordResetLink" => $passwordResetLink, "LogInLink" => $logInLink, "Title" => $this->Title, "ScreenName" => $screenName, "EditYourDetailsLink" => $editYourDetailsLink);
     $body = $this->customise($customisationArray)->renderWith("ModuleProductEmailBody");
     return $body;
 }