diff --git a/config/geopath.default.php b/config/geopath.default.php index bf2ef1432d..c301f446ae 100644 --- a/config/geopath.default.php +++ b/config/geopath.default.php @@ -7,6 +7,8 @@ * It may be customized in node-specific configuration file. */ +use src\Models\GeoCache\GeoCache; + $geopathCfg = []; /** @@ -27,3 +29,7 @@ */ $geopathCfg['geopathOwnerMinFounds'] = 100; +/** + * Array of types of geocaches forbidden in geopaths + */ +$geopathCfg['forbiddenCacheTypes'] = [ GeoCache::TYPE_EVENT, GeoCache::TYPE_OWNCACHE ]; diff --git a/src/Controllers/GeoPathApiController.php b/src/Controllers/GeoPathApiController.php new file mode 100644 index 0000000000..b8168d2fbd --- /dev/null +++ b/src/Controllers/GeoPathApiController.php @@ -0,0 +1,293 @@ +checkUserLoggedAjax(); + + $geoPath = CacheSet::fromCacheSetIdFactory($geoPathId); + if(!$geoPath) { + $this->ajaxErrorResponse("No such geoPath!", self::HTTP_STATUS_NOT_FOUND); + } + + if(!$geoPath->isOwner($this->loggedUser)){ + $this->ajaxErrorResponse("Logged user is not a geopath owner!", self::HTTP_STATUS_FORBIDDEN); + } + + $cache = GeoCache::fromCacheIdFactory($cacheId); + if(!$cache) { + $this->ajaxErrorResponse("No such cache!", self::HTTP_STATUS_NOT_FOUND); + } + + if($cache->getOwnerId() != $this->loggedUser->getUserId()) { + $this->ajaxErrorResponse("Cache not belong to logged user!", self::HTTP_STATUS_CONFLICT); + } + + if($cache->isPowerTrailPart(TRUE)){ + $this->ajaxErrorResponse("Already part of GeoPath", self::HTTP_STATUS_CONFLICT); + } + + if(!CacheSet::isCacheStatusAllowedForGeoPathAdd($cache) || + !CacheSet::isCacheTypeAllowedForGeoPath($cache)) { + $this->ajaxErrorResponse("Cache of improper type/state!", self::HTTP_STATUS_CONFLICT); + } + + try{ + $geoPath->addCache($cache); + }catch(\RuntimeException $e){ + $this->ajaxErrorResponse($e->getMessage()); + } + + $this->ajaxSuccessResponse("Cache added.", ['localizedMessage' => tr('gp_ownCacheAddedToGeopath')]); + } + + /** + * Remove cache from geopath + */ + public function rmCacheFromGeopathAjax($cacheId) + { + $this->checkUserLoggedAjax(); + + if(!$this->loggedUser->hasOcTeamRole()){ + $this->ajaxErrorResponse( + "Logged user is not allowed to removed caches from geoPath!", + self::HTTP_STATUS_FORBIDDEN); + } + + $cache = GeoCache::fromCacheIdFactory($cacheId); + if(!$cache) { + $this->ajaxErrorResponse("No such cache!", self::HTTP_STATUS_NOT_FOUND); + } + + if(!$cache->isPowerTrailPart(true)){ + $this->ajaxErrorResponse("This cache not belongs to geoPath!", self::HTTP_STATUS_CONFLICT); + } + + $geoPath = CacheSet::fromCacheSetIdFactory($cache->getPowerTrail()->getId()); + if(!$geoPath){ + $this->ajaxErrorResponse("Cache belongs to unknown geoPath!", self::HTTP_STATUS_NOT_FOUND); + } + + $geoPath->removeCache($cache); + + $this->ajaxSuccessResponse("Cache removed.", ['localizedMessage' => tr('gp_cacheRemovedFromGeopath')]); + } + + /** + * Uploading of the new geoPath logo + * This is fast replacement for ajaxImage.php + */ + public function uploadLogoAjax($geoPathId) + { + if (!$this->loggedUser) { + $this->ajaxErrorResponse("User not authorized!"); + } + + if (!$geoPath = CacheSet::fromCacheSetIdFactory($geoPathId)){ + $this->ajaxErrorResponse("No such geopath!"); + } + + if (!$geoPath->isOwner($this->loggedUser)) { + $this->ajaxErrorResponse("Logged user is not an geopath owner!"); + } + + $uploadModel = GeopathLogoUploadModel::forGeopath($geoPathId); + + try { + $tmpLogoFileArr = FileUploadMgr::processFileUpload($uploadModel); + $tmpLogoFile = array_shift($tmpLogoFileArr); + } catch (\RuntimeException $e){ + // some error occured on upload processing + $this->ajaxErrorResponse($e->getMessage(), 500); + } + + // FileUploadMgr returns single filename saved in server tmp directory on server + + $newLogoPath = OcConfig::getDynFilesPath(true) . CacheSet::DIR_LOGO_IMG . '/' . Uuid::create(); + + // resize the new logo + $newLogoPath = OcImage::createThumbnail($uploadModel->getDirAtServer().'/'.$tmpLogoFile, $newLogoPath, [250,250]); + + // create URL of the image + $newLogoFileUrl = CacheSet::DIR_LOGO_IMG .'/'.basename($newLogoPath); + + // new log is ready to use - update DB + $geoPath->updateLogoImg($newLogoFileUrl); + + $this->ajaxJsonResponse($newLogoFileUrl); + } + + /** + * Add cache candidate to geoPath by geoPath owner + * Cache is not owned by logged user. + * + * @param integer $geoPathId + * @param integer $cacheId + */ + public function addCacheCandidateAjax($geoPathId, $cacheId, $resendEmail=null) + { + $this->checkUserLoggedAjax(); + + $geoPath = CacheSet::fromCacheSetIdFactory($geoPathId); + if(!$geoPath) { + $this->ajaxErrorResponse("No such geoPath!", self::HTTP_STATUS_NOT_FOUND); + } + + if(!$geoPath->isOwner($this->loggedUser)){ + $this->ajaxErrorResponse("Logged user is not a geopath owner!", self::HTTP_STATUS_FORBIDDEN); + } + + $cache = GeoCache::fromCacheIdFactory($cacheId); + if(!$cache) { + $this->ajaxErrorResponse("No such cache!", self::HTTP_STATUS_NOT_FOUND); + } + + if($cache->getOwnerId() == $this->loggedUser->getUserId()) { + $this->ajaxErrorResponse( + "Cache belongs to logged user! No need to create candidate.", + self::HTTP_STATUS_CONFLICT, + ['localizedMessage' => tr('gp_ownedCacheAddDirect')]); + } + + // check if this cache is not a part of geocache already + if($cache->isPowerTrailPart(true)) { + // this cache is already a part of some geoPath + $this->ajaxErrorResponse( + "Already part of GeoPath", + self::HTTP_STATUS_CONFLICT, + ['localizedMessage' => tr('gp_candidateAlreadyInGeocache')]); + } + + // check if geocache is alredy a candidate + if(!$resendEmail && $geoPath->isCandidateExists($cache)){ + if($geoPath->isCandidateExists($cache, true)){ + // this cache is already a candidate to THIS geopath + $this->ajaxErrorResponse( + "This cache is already a candidate to this geopath!", + self::HTTP_STATUS_CONFLICT, + ['localizedMessage' => tr('gp_alreadyCandidateToThisGeopath')]); + } else { + // this cache is already a candidate but to OTHER geopath + $this->ajaxErrorResponse( + "This cache is already a candidate to other geopath!", + self::HTTP_STATUS_CONFLICT, + ['localizedMessage' => tr('gp_alreadyCandidateToOtherGeopath')]); + } + } + + // this cache is not a candidate to any geopath yet + $geoPath->addCacheCandidate($cache); + + $this->ajaxSuccessResponse( + "Candidate saved. Email to cache owner is sent.", + ['localizedMessage' => tr('gp_candidateProposalSaved')]); + } + + /** + * Allow geopath owner to update geopath: center point, points, caches count + * + * @param integer $geoPathId + */ + public function refreshCachesNumberAjax($geoPathId) + { + $this->checkUserLoggedAjax(); + + $geoPath = CacheSet::fromCacheSetIdFactory($geoPathId); + if(!$geoPath) { + $this->ajaxErrorResponse("No such geoPath!", self::HTTP_STATUS_NOT_FOUND); + } + + if(!$geoPath->isOwner($this->loggedUser)){ + $this->ajaxErrorResponse("Logged user is not a geopath owner!", self::HTTP_STATUS_FORBIDDEN); + } + + // recalculate Center adn Points + $geoPath->recalculateCenterPoint(); + $geoPath->updatePoints(); + $geoPath->updateCachesCount(); + + $this->ajaxSuccessResponse("Caches number, points and center point updated.", + ['newCachesCount' => $geoPath->getCacheCount()]); + } + + public function cancelCacheCandidateAjax($candidateId) + { + $this->checkUserLoggedAjax(); + + // find candidate record + $candidate = GeopathCandidate::fromCandidateIdFactory($candidateId); + if(!$candidate){ + $this->ajaxErrorResponse('No such candidate!'); + } + + // check if user is allowed to cancel offer (owner of geopath can cancel it) + $geopath = $candidate->getGeopath(); + if(!$geopath->isOwner($this->loggedUser)) { + $this->ajaxErrorResponse('User is not owner of this geopath assign to offer!'); + } + + // everything is OK, cancle the candidate + $candidate->cancelOffer(); + $this->ajaxSuccessResponse("Candidate offer canceled succesful."); + } + + public function refuseCacheCandidateAjax($candidateId) + { + $this->checkUserLoggedAjax(); + + // find candidate record + $candidate = GeopathCandidate::fromCandidateIdFactory($candidateId); + if (!$candidate) { + $this->ajaxErrorResponse('No such candidate!'); + } + + // check if user is allowed to cancel offer (owner of geopath can cancel it) + $cache = $candidate->getGeoCache(); + if ($cache->getOwnerId() != $this->loggedUser->getUserId()) { + $this->ajaxErrorResponse('User is not owner of this geocache assign to offer!'); + } + + $candidate->refuseOffer(); + $this->ajaxSuccessResponse("Candidate offer refused succesful."); + } + + public function acceptCacheCandidateAjax($candidateId) + { + $this->checkUserLoggedAjax(); + + // find candidate record + $candidate = GeopathCandidate::fromCandidateIdFactory($candidateId); + if (!$candidate) { + $this->ajaxErrorResponse('No such candidate!'); + } + + // check if user is allowed to cancel offer (owner of geopath can cancel it) + $cache = $candidate->getGeoCache(); + if ($cache->getOwnerId() != $this->loggedUser->getUserId()) { + $this->ajaxErrorResponse('User is not owner of this geocache assign to offer!'); + } + + try{ + $candidate->acceptOffer(); + } catch (\RuntimeException $e) { + $this->ajaxErrorResponse($e->getMessage()); + } + + $this->ajaxSuccessResponse("Candidate offer accepted succesful."); + } +} diff --git a/src/Controllers/GeoPathController.php b/src/Controllers/GeoPathController.php index c93090ec45..b7d30c872c 100644 --- a/src/Controllers/GeoPathController.php +++ b/src/Controllers/GeoPathController.php @@ -3,14 +3,8 @@ use src\Utils\Text\UserInputFilter; use src\Models\CacheSet\CacheSet; -use src\Utils\FileSystem\FileUploadMgr; -use src\Utils\Img\OcImage; -use src\Models\CacheSet\GeopathLogoUploadModel; -use src\Models\OcConfig\OcConfig; -use src\Utils\Generators\Uuid; use src\Models\GeoCache\GeoCache; use src\Models\ChunkModels\ListOfCaches\ListOfCachesModel; -use src\Models\ChunkModels\ListOfCaches\Column_GeoPathIcon; use src\Models\CacheSet\GeopathCandidate; use src\Models\ChunkModels\ListOfCaches\Column_CacheName; use src\Models\ChunkModels\ListOfCaches\Column_SimpleText; @@ -21,10 +15,10 @@ use src\Models\User\MultiUserQueries; use src\Models\ChunkModels\ListOfCaches\Column_UserName; use src\Models\ChunkModels\ListOfCaches\Column_ActionButtons; +use src\Controllers\Core\ViewBaseController; -class GeoPathController extends BaseController +class GeoPathController extends ViewBaseController { - public function __construct() { parent::__construct(); @@ -57,219 +51,6 @@ public function searchByName() $this->view->buildView(); } - /** - * Uploading of the new geoPath logo - * This is fast replacement for ajaxImage.php - */ - public function uploadLogoAjax($geoPathId) - { - if (!$this->loggedUser) { - $this->ajaxErrorResponse("User not authorized!"); - } - - if (!$geoPath = CacheSet::fromCacheSetIdFactory($geoPathId)){ - $this->ajaxErrorResponse("No such geopath!"); - } - - if (!$geoPath->isOwner($this->loggedUser)) { - $this->ajaxErrorResponse("Logged user is not an geopath owner!"); - } - - $uploadModel = GeopathLogoUploadModel::forGeopath($geoPathId); - - try { - $tmpLogoFileArr = FileUploadMgr::processFileUpload($uploadModel); - $tmpLogoFile = array_shift($tmpLogoFileArr); - } catch (\RuntimeException $e){ - // some error occured on upload processing - $this->ajaxErrorResponse($e->getMessage(), 500); - } - - // FileUploadMgr returns single filename saved in server tmp directory on server - - $newLogoPath = OcConfig::getDynFilesPath(true) . CacheSet::DIR_LOGO_IMG . '/' . Uuid::create(); - - // resize the new logo - $newLogoPath = OcImage::createThumbnail($uploadModel->getDirAtServer().'/'.$tmpLogoFile, $newLogoPath, [250,250]); - - // create URL of the image - $newLogoFileUrl = CacheSet::DIR_LOGO_IMG .'/'.basename($newLogoPath); - - // new log is ready to use - update DB - $geoPath->updateLogoImg($newLogoFileUrl); - - $this->ajaxJsonResponse($newLogoFileUrl); - } - - /** - * Add cache to the geoPath by cache owner and geopath - */ - public function addOwnCacheToGeopathAjax($geoPathId, $cacheId) - { - $this->checkUserLoggedAjax(); - - $geoPath = CacheSet::fromCacheSetIdFactory($geoPathId); - if(!$geoPath) { - $this->ajaxErrorResponse("No such geoPath!", self::HTTP_STATUS_NOT_FOUND); - } - - if(!$geoPath->isOwner($this->loggedUser)){ - $this->ajaxErrorResponse("Logged user is not a geopath owner!", self::HTTP_STATUS_FORBIDDEN); - } - - $cache = GeoCache::fromCacheIdFactory($cacheId); - if(!$cache) { - $this->ajaxErrorResponse("No such cache!", self::HTTP_STATUS_NOT_FOUND); - } - - if($cache->getOwnerId() != $this->loggedUser->getUserId()) { - $this->ajaxErrorResponse("Cache not belong to logged user!", self::HTTP_STATUS_CONFLICT); - } - - if($cache->isPowerTrailPart(TRUE)){ - $this->ajaxErrorResponse("Already part of GeoPath", self::HTTP_STATUS_CONFLICT); - } - - if(!CacheSet::isCacheStatusAllowedForGeoPathAdd($cache) || - !CacheSet::isCacheTypeAllowedForGeoPath($cache)) { - $this->ajaxErrorResponse("Cache of improper type/state!", self::HTTP_STATUS_CONFLICT); - } - - try{ - $geoPath->addCache($cache); - }catch(\RuntimeException $e){ - $this->ajaxErrorResponse($e->getMessage()); - } - - $this->ajaxSuccessResponse("Cache added.", ['localizedMessage' => tr('gp_ownCacheAddedToGeopath')]); - } - - /** - * Remove cache from geopath - */ - public function rmCacheFromGeopathAjax($cacheId) - { - $this->checkUserLoggedAjax(); - - if(!$this->loggedUser->hasOcTeamRole()){ - $this->ajaxErrorResponse( - "Logged user is not allowed to removed caches from geoPath!", - self::HTTP_STATUS_FORBIDDEN); - } - - $cache = GeoCache::fromCacheIdFactory($cacheId); - if(!$cache) { - $this->ajaxErrorResponse("No such cache!", self::HTTP_STATUS_NOT_FOUND); - } - - if(!$cache->isPowerTrailPart(true)){ - $this->ajaxErrorResponse("This cache not belongs to geoPath!", self::HTTP_STATUS_CONFLICT); - } - - $geoPath = CacheSet::fromCacheSetIdFactory($cache->getPowerTrail()->getId()); - if(!$geoPath){ - $this->ajaxErrorResponse("Cache belongs to unknown geoPath!", self::HTTP_STATUS_NOT_FOUND); - } - - $geoPath->removeCache($cache); - - $this->ajaxSuccessResponse("Cache removed.", ['localizedMessage' => tr('gp_cacheRemovedFromGeopath')]); - } - - /** - * Add cache candidate to geoPath by geoPath owner - * Cache is not owned by logged user. - * - * @param integer $geoPathId - * @param integer $cacheId - */ - public function addCacheCandidateAjax($geoPathId, $cacheId, $resendEmail=null) - { - $this->checkUserLoggedAjax(); - - $geoPath = CacheSet::fromCacheSetIdFactory($geoPathId); - if(!$geoPath) { - $this->ajaxErrorResponse("No such geoPath!", self::HTTP_STATUS_NOT_FOUND); - } - - if(!$geoPath->isOwner($this->loggedUser)){ - $this->ajaxErrorResponse("Logged user is not a geopath owner!", self::HTTP_STATUS_FORBIDDEN); - } - - $cache = GeoCache::fromCacheIdFactory($cacheId); - if(!$cache) { - $this->ajaxErrorResponse("No such cache!", self::HTTP_STATUS_NOT_FOUND); - } - - if($cache->getOwnerId() == $this->loggedUser->getUserId()) { - $this->ajaxErrorResponse( - "Cache belongs to logged user! No need to create candidate.", - self::HTTP_STATUS_CONFLICT, - ['localizedMessage' => tr('gp_ownedCacheAddDirect')]); - } - - // check if this cache is not a part of geocache already - if($cache->isPowerTrailPart(true)) { - // this cache is already a part of some geoPath - $this->ajaxErrorResponse( - "Already part of GeoPath", - self::HTTP_STATUS_CONFLICT, - ['localizedMessage' => tr('gp_candidateAlreadyInGeocache')]); - } - - // check if geocache is alredy a candidate - if(!$resendEmail && $geoPath->isCandidateExists($cache)){ - if($geoPath->isCandidateExists($cache, true)){ - // this cache is already a candidate to THIS geopath - $this->ajaxErrorResponse( - "This cache is already a candidate to this geopath!", - self::HTTP_STATUS_CONFLICT, - ['localizedMessage' => tr('gp_alreadyCandidateToThisGeopath')]); - } else { - // this cache is already a candidate but to OTHER geopath - $this->ajaxErrorResponse( - "This cache is already a candidate to other geopath!", - self::HTTP_STATUS_CONFLICT, - ['localizedMessage' => tr('gp_alreadyCandidateToOtherGeopath')]); - } - } - - // this cache is not a candidate to any geopath yet - $geoPath->addCacheCandidate($cache); - - $this->ajaxSuccessResponse( - "Candidate saved. Email to cache owner is sent.", - ['localizedMessage' => tr('gp_candidateProposalSaved')]); - } - - - /** - * Allow geopath owner to update geopath: center point, points, caches count - * - * @param integer $geoPathId - */ - public function refreshCachesNumberAjax ($geoPathId) - { - $this->checkUserLoggedAjax(); - - $geoPath = CacheSet::fromCacheSetIdFactory($geoPathId); - if(!$geoPath) { - $this->ajaxErrorResponse("No such geoPath!", self::HTTP_STATUS_NOT_FOUND); - } - - if(!$geoPath->isOwner($this->loggedUser)){ - $this->ajaxErrorResponse("Logged user is not a geopath owner!", self::HTTP_STATUS_FORBIDDEN); - } - - // recalculate Center adn Points - $geoPath->recalculateCenterPoint(); - $geoPath->updatePoints(); - $geoPath->updateCachesCount(); - - $this->ajaxSuccessResponse("Caches number, points and center point updated.", - ['newCachesCount' => $geoPath->getCacheCount()]); - } - public function acceptCacheCandidate($geopathId, $cacheId, $code) { $this->acceptCancelCandidate($geopathId, $cacheId, $code, true); @@ -319,72 +100,6 @@ private function acceptCancelCandidate($geopathId, $cacheId, $code, $proposalAcc $this->view->redirect($geoPath->getUrl()); } - public function cancelCacheCandidateAjax($candidateId) - { - $this->checkUserLoggedAjax(); - - // find candidate record - $candidate = GeopathCandidate::fromCandidateIdFactory($candidateId); - if(!$candidate){ - $this->ajaxErrorResponse('No such candidate!'); - } - - // check if user is allowed to cancel offer (owner of geopath can cancel it) - $geopath = $candidate->getGeopath(); - if(!$geopath->isOwner($this->loggedUser)) { - $this->ajaxErrorResponse('User is not owner of this geopath assign to offer!'); - } - - // everything is OK, cancle the candidate - $candidate->cancelOffer(); - $this->ajaxSuccessResponse("Candidate offer canceled succesful."); - } - - public function refuseCacheCandidateAjax($candidateId) - { - $this->checkUserLoggedAjax(); - - // find candidate record - $candidate = GeopathCandidate::fromCandidateIdFactory($candidateId); - if (!$candidate) { - $this->ajaxErrorResponse('No such candidate!'); - } - - // check if user is allowed to cancel offer (owner of geopath can cancel it) - $cache = $candidate->getGeoCache(); - if ($cache->getOwnerId() != $this->loggedUser->getUserId()) { - $this->ajaxErrorResponse('User is not owner of this geocache assign to offer!'); - } - - $candidate->refuseOffer(); - $this->ajaxSuccessResponse("Candidate offer refused succesful."); - } - - public function acceptCacheCandidateAjax($candidateId) - { - $this->checkUserLoggedAjax(); - - // find candidate record - $candidate = GeopathCandidate::fromCandidateIdFactory($candidateId); - if (!$candidate) { - $this->ajaxErrorResponse('No such candidate!'); - } - - // check if user is allowed to cancel offer (owner of geopath can cancel it) - $cache = $candidate->getGeoCache(); - if ($cache->getOwnerId() != $this->loggedUser->getUserId()) { - $this->ajaxErrorResponse('User is not owner of this geocache assign to offer!'); - } - - try{ - $candidate->acceptOffer(); - } catch (\RuntimeException $e) { - $this->displayCommonErrorPageAndExit($e->getMessage()); - } - - $this->ajaxSuccessResponse("Candidate offer refused succesful."); - } - /** * List of caches - candidates to given geopath * @@ -462,8 +177,6 @@ public function candidatesList($geopathId) ]; }, 'width10')); - - $this->view->setVar('listModel', $listModel); $this->view->buildView(); diff --git a/src/Models/CacheSet/CacheSetCommon.php b/src/Models/CacheSet/CacheSetCommon.php index 78dccaa886..c82eb701a1 100644 --- a/src/Models/CacheSet/CacheSetCommon.php +++ b/src/Models/CacheSet/CacheSetCommon.php @@ -8,6 +8,7 @@ use src\Models\Coordinates\Altitude; use src\Models\Coordinates\Coordinates; use src\Models\GeoCache\GeoCache; +use src\Models\OcConfig\OcConfig; class CacheSetCommon extends BaseObject { @@ -92,12 +93,7 @@ public static function getCacheSetUrlById($id){ public static function isCacheTypeAllowedForGeoPath(GeoCache $cache) { // these cache types are forbiden in geopaths - $forbiddenTypes = [ - GeoCache::TYPE_EVENT, - GeoCache::TYPE_OWNCACHE, - GeoCache::TYPE_WEBCAM, - ]; - + $forbiddenTypes = OcConfig::geopathForbiddenCacheTypes(); return !in_array($cache->getCacheType(), $forbiddenTypes); } diff --git a/src/Models/CacheSet/GeopathLogoUploadModel.php b/src/Models/CacheSet/GeopathLogoUploadModel.php index e5d1d48023..a6b3644e08 100644 --- a/src/Models/CacheSet/GeopathLogoUploadModel.php +++ b/src/Models/CacheSet/GeopathLogoUploadModel.php @@ -24,7 +24,7 @@ public static function forGeopath($id) $obj->setMaxFileNumber(1); // script hich handle the logo upload - $obj->submitUrl = "/geoPath/uploadLogoAjax/$id"; + $obj->submitUrl = "/geoPathApi/uploadLogoAjax/$id"; // logo is always resized to given size - so oryginal img. is not important $obj->setDirs(self::DEFAULT_TMP_DIR); diff --git a/src/Models/OcConfig/GeopathConfigTrait.php b/src/Models/OcConfig/GeopathConfigTrait.php index 0219dddd05..ed57ef6545 100644 --- a/src/Models/OcConfig/GeopathConfigTrait.php +++ b/src/Models/OcConfig/GeopathConfigTrait.php @@ -35,6 +35,14 @@ public static function geopathOwnerMinFounds(): int return self::getKeyFromGeopathConfig('geopathOwnerMinFounds'); } + /** + * Array of types of geocaches forbidden in geopaths + */ + public static function geopathForbiddenCacheTypes(): array + { + return self::getKeyFromGeopathConfig('forbiddenCacheTypes'); + } + protected function getGeopathConfig(): array { if (! $this->geopathConfig) { @@ -53,4 +61,5 @@ private static function getKeyFromGeopathConfig(string $key) return $geopathConfig[$key]; } + } diff --git a/src/Views/geoPath/gpCandidatesList.tpl.php b/src/Views/geoPath/gpCandidatesList.tpl.php index e90519d989..bb0e0f49fa 100644 --- a/src/Views/geoPath/gpCandidatesList.tpl.php +++ b/src/Views/geoPath/gpCandidatesList.tpl.php @@ -18,7 +18,7 @@ function cancelCandidateOffer(icon, candidateId){ jQueryIcon.attr("title", ""); $.ajax({ - url: "/GeoPath/cancelCacheCandidateAjax/"+candidateId, + url: "/GeoPathApi/cancelCacheCandidateAjax/"+candidateId, type: "get", cache: false, error: function (xhr) { diff --git a/src/Views/geoPath/myCandidatesList.tpl.php b/src/Views/geoPath/myCandidatesList.tpl.php index fcb0d6356d..37ddbcac7a 100644 --- a/src/Views/geoPath/myCandidatesList.tpl.php +++ b/src/Views/geoPath/myCandidatesList.tpl.php @@ -20,7 +20,7 @@ function acceptOffer(btn, candidateId){ img.appendTo(btnContainer); $.ajax({ - url: '/GeoPath/acceptCacheCandidateAjax/'+candidateId, + url: '/GeoPathApi/acceptCacheCandidateAjax/'+candidateId, type: "get", cache: false, @@ -47,7 +47,7 @@ function refuseOffer(btn, candidateId){ img.appendTo(btnContainer); $.ajax({ - url: '/GeoPath/refuseCacheCandidateAjax/'+candidateId, + url: '/GeoPathApi/refuseCacheCandidateAjax/'+candidateId, type: "get", cache: false, diff --git a/src/Views/powerTrail.tpl.php b/src/Views/powerTrail.tpl.php index ca41017cc2..ba18216a32 100644 --- a/src/Views/powerTrail.tpl.php +++ b/src/Views/powerTrail.tpl.php @@ -127,7 +127,7 @@ function ajaxRmOtherUserCache(){ var newCacheId2 = $('#newCacheNameId2').val(); request = $.ajax({ - url: "/GeoPath/rmCacheFromGeopathAjax/"+newCacheId2, + url: "/GeoPathApi/rmCacheFromGeopathAjax/"+newCacheId2, type: "get", }); @@ -738,7 +738,7 @@ function ajaxAddOtherUserCache(){ var newCacheId = $('#newCacheNameId').val(); request = $.ajax({ - url: "/GeoPath/addCacheCandidateAjax/"+$('#xmd34nfywr54').val()+"/"+newCacheId, + url: "/GeoPathApi/addCacheCandidateAjax/"+$('#xmd34nfywr54').val()+"/"+newCacheId, type: "get", }); @@ -1106,7 +1106,7 @@ function ajaxCountPtCaches(ptId) { $('#cacheCountUserActions').hide(); request = $.ajax({ - url: "/geoPath/refreshCachesNumberAjax/"+ptId, + url: "/geoPathApi/refreshCachesNumberAjax/"+ptId, type: "get" }); @@ -1140,7 +1140,7 @@ function ajaxAddCacheToPT(cacheId) { var projectId = $('#ptSelectorForCache' + cacheId).val(); $('#addCacheLoader' + cacheId).show(); $.ajax({ - url: "/geoPath/addOwnCacheToGeopathAjax/"+projectId+'/'+cacheId, + url: "/geoPathApi/addOwnCacheToGeopathAjax/"+projectId+'/'+cacheId, type: "get", success: function(response, textStatus, jqXHR){ diff --git a/src/Views/powerTrailCOG.tpl.php b/src/Views/powerTrailCOG.tpl.php index 1f75b31459..60aaf74e17 100644 --- a/src/Views/powerTrailCOG.tpl.php +++ b/src/Views/powerTrailCOG.tpl.php @@ -45,7 +45,7 @@ function rmCache(cacheId) { $("#rmCacheLoader" + cacheId).show(); request = $.ajax({ - url: "/GeoPath/rmCacheFromGeopathAjax/"+cacheId, + url: "/GeoPathApi/rmCacheFromGeopathAjax/"+cacheId, type: "get", });