function completePoints()
 {
     $uncompletedPoints = GoogleMapLocationsObject::get()->where("\r\n\t\t\t(\r\n\t\t\t\t(\"GoogleMapLocationsObject\".\"Address\" <> \"GoogleMapLocationsObject\".\"FullAddress\")\r\n\t\t\t\tOR (\r\n\t\t\t\t\t\"GoogleMapLocationsObject\".\"Address\" = IsNull\r\n\t\t\t\t\tOR \"GoogleMapLocationsObject\".\"Address\" = ''\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t\tAND\r\n\t\t\t\t\"GoogleMapLocationsObject\".\"Manual\" <> 1\r\n\t\t\t\tAND \"GoogleMapLocationsObject\".\"Address\" <> IsNull\r\n\t\t\t\tAND ((\"GoogleMapLocationsObject\".\"Address\") <> '' OR (\"GoogleMapLocationsObject\".\"Longitude\"<> 0\r\n\t\t\t\tAND \"GoogleMapLocationsObject\".\"Latitude\" <> 0\r\n\t\t\t\tAND (\r\n\t\t\t\t\t\"GoogleMapLocationsObject\".\"Address\" = ''\r\n\t\t\t\t\tOR \"GoogleMapLocationsObject\".\"Address\" = IsNull\r\n\t\t\t\t)\r\n\t\t\t)");
     if ($uncompletedPoints->count()) {
         foreach ($uncompletedPoints as $point) {
             $point->findGooglePoints(false);
         }
     }
 }
 public function setPageDataObjectSet($PageDataObjectSet)
 {
     if (count($PageDataObjectSet)) {
         $where = "ParentID IN (-1 ";
         foreach ($PageDataObjectSet as $page) {
             if ($page->HasGeoInfo) {
                 $where .= ", " . $page->ID;
             }
         }
         $where .= ') ';
         $this->GooglePointsDataObject = GoogleMapLocationsObject::get()->where($where);
         $PageDataObjectSet = null;
     }
 }
 public function updatemexml()
 {
     //we use request here, because the data comes from javascript!
     if ($this->owner->canEdit()) {
         if (isset($_REQUEST["x"]) && isset($_REQUEST["y"]) && isset($_REQUEST["i"]) && isset($_REQUEST["a"])) {
             $lng = floatval($_REQUEST["x"]);
             $lat = floatval($_REQUEST["y"]);
             $id = intval($_REQUEST["i"]);
             $action = $_REQUEST["a"];
             if ($lng && $lat) {
                 if (0 == $id && "add" == $action) {
                     $point = new GoogleMapLocationsObject();
                     $point->ParentID = $this->owner->ID;
                     $point->Latitude = $lat;
                     $point->Longitude = $lng;
                     $point->write();
                     return $point->ID;
                 } elseif ($id > 0 && "move" == $action) {
                     $point = GoogleMapLocationsObject::get()->byID($id);
                     if ($point) {
                         if ($point->ParentID == $this->owner->ID) {
                             $point->Latitude = $lat;
                             $point->Longitude = $lng;
                             $point->Address = "";
                             $point->FullAddress = "";
                             $point->write();
                             return "location updated";
                         } else {
                             return "you dont have permission to update that location";
                         }
                     } else {
                         return "could not find location";
                     }
                 } elseif ($id && "remove" == $action) {
                     $point = GoogleMapLocationsObject::get()->byID($id);
                     if ($point) {
                         if ($point->ParentID == $this->owner->ID) {
                             $point->delete();
                             $point = null;
                             return "location deleted";
                         } else {
                             return "you dont have permission to delete that location";
                         }
                     } else {
                         return "could not find location.";
                     }
                 }
             } else {
                 return "point not defined.";
             }
         } else {
             return "not enough information was provided.";
         }
     }
     return "point could NOT be updated.";
 }