feature/RVRNEXT-39-delete-communities #58
@ -176,6 +176,43 @@ class CommunityController implements IAuthenticationRequired
 | 
				
			|||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function deleteCommunity(): ?IContent
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($this->transactionRepository->countAllByCommunity($community) > 0) {
 | 
				
			||||||
 | 
					            return new JsonContent([
 | 
				
			||||||
 | 
					                'error' => ['errorText' => 'There are transactions for this community!']
 | 
				
			||||||
 | 
					            ]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($this->eventRepository->countAllByCommunity($community) > 0) {
 | 
				
			||||||
 | 
					            return new JsonContent([
 | 
				
			||||||
 | 
					                'error' => ['errorText' => 'There are events for this community!']
 | 
				
			||||||
 | 
					            ]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach ($this->communityMemberRepository->getAllByCommunity($community) as $communityMember) {
 | 
				
			||||||
 | 
					            \Container::$persistentDataManager->deleteFromDb($communityMember);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $community->setMainCurrencyId(null);
 | 
				
			||||||
 | 
					        \Container::$persistentDataManager->saveToDb($community);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach ($this->currencyRepository->getAllByCommunity($community) as $currency) {
 | 
				
			||||||
 | 
					            foreach ($this->currencyExchangeRatesRepository->getAllByCurrency($currency) as $currencyExchangeRate) {
 | 
				
			||||||
 | 
					                \Container::$persistentDataManager->deleteFromDb($currencyExchangeRate);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            \Container::$persistentDataManager->deleteFromDb($currency);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        \Container::$persistentDataManager->deleteFromDb($community);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new JsonContent(['success' => true]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getMembersEdit(): ?IContent
 | 
					    public function getMembersEdit(): ?IContent
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) {
 | 
					        if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user