Source of file GoogleMapSearchRecord.php
Size: 1,960 Bytes - Last Modified: 2021-12-23T10:41:51+00:00
/var/www/docs.ssmods.com/process/src/code/model/GoogleMapSearchRecord.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | <?php /** * saves all places searched for on the site. * * */ class GoogleMapSearchRecord extends DataObject { private static $db = array( "IPAddres" => "Varchar(32)", "SearchedFor" => "Text" ); private static $searcheabl_fields = array( "SearchedFor" => "PartialMatchFilter" ); private static $summary_fields = array( "SearchedFor" => "Searched for ..." ); private static $has_one = array( "Member" => "Member", "Parent" => "SiteTree", "GoogleMapLocationsObject" => "GoogleMapLocationsObject" ); public static function create_new($searchedFor, $parentID = 0, $addGoogleMapLocationsObjectOrItsID = false) { $obj = new GoogleMapSearchRecord(); $obj->SearchedFor = $searchedFor; $obj->ParentID = $parentID; if ($addGoogleMapLocationsObjectOrItsID) { if ($addGoogleMapLocationsObjectOrItsID === true || $addGoogleMapLocationsObjectOrItsID === 1) { //create object $location = new GoogleMapLocationsObject(); $location->Address = $searchedFor; $location->Manual = false; $location->write(); $obj->GoogleMapLocationsObjectID = $location->ID; } else { $obj->GoogleMapLocationsObjectID = intval($addGoogleMapLocationsObjectOrItsID); } } $obj->write(); return $obj; } public function onBeforeWrite() { parent::onBeforeWrite(); $m = Member::currentUser(); if ($m) { $this->MemberID = $m->ID; } $this->IPAddres = Controller::curr()->getRequest()->getIP(); } /** * @return bool */ public function canDelete($member = null) { return false; } /** * @return bool */ public function canEdit($member = null) { return false; } } |