|
|
@@ -35,14 +35,14 @@ class OtWebsiteRepository
|
|
|
public function getAll(bool $withRestrictions = true): array
|
|
|
{
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
|
|
|
- if (!$withRestrictions) {
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
- }
|
|
|
- return $queryBuilder
|
|
|
+ $q = $queryBuilder
|
|
|
->select('*')
|
|
|
- ->from('ot_websites')
|
|
|
- ->execute()
|
|
|
- ->fetchAll();
|
|
|
+ ->from('ot_websites');
|
|
|
+ if ($withRestrictions) {
|
|
|
+ $q->where($q->expr()->eq('deleted', 0));
|
|
|
+ }
|
|
|
+ return $q->execute()
|
|
|
+ ->fetchAll();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -53,15 +53,15 @@ class OtWebsiteRepository
|
|
|
public function getWebsiteByUid(int $uid, bool $withRestrictions = true): array
|
|
|
{
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
|
|
|
- if (!$withRestrictions) {
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
- }
|
|
|
- $website = $queryBuilder
|
|
|
+ $q = $queryBuilder
|
|
|
->select('*')
|
|
|
->from('ot_websites')
|
|
|
- ->where($queryBuilder->expr()->eq('uid', $uid))
|
|
|
- ->execute()
|
|
|
- ->fetch();
|
|
|
+ ->where($queryBuilder->expr()->eq('uid', $uid));
|
|
|
+ if ($withRestrictions) {
|
|
|
+ $q->andWhere($q->expr()->eq('deleted', 0));
|
|
|
+ }
|
|
|
+ $website = $q->execute()->fetch();
|
|
|
+
|
|
|
if (!isset($website['uid'])) {
|
|
|
throw new NoSuchWebsiteException('No website found with uid ' . $uid);
|
|
|
}
|
|
|
@@ -76,15 +76,15 @@ class OtWebsiteRepository
|
|
|
public function getWebsiteByOrganizationId(int $organizationId, bool $withRestrictions = true): array
|
|
|
{
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
|
|
|
- if (!$withRestrictions) {
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
- }
|
|
|
- $website = $queryBuilder
|
|
|
+ $q = $queryBuilder
|
|
|
->select('*')
|
|
|
->from('ot_websites')
|
|
|
- ->where($queryBuilder->expr()->eq('organization_id', $organizationId))
|
|
|
- ->execute()
|
|
|
- ->fetch();
|
|
|
+ ->where($queryBuilder->expr()->eq('organization_id', $organizationId));
|
|
|
+ if ($withRestrictions) {
|
|
|
+ $q->andWhere($q->expr()->eq('deleted', 0));
|
|
|
+ }
|
|
|
+ $website = $q->execute()->fetch();
|
|
|
+
|
|
|
if (!isset($website['uid'])) {
|
|
|
throw new NoSuchWebsiteException('No website found for organization ' . $organizationId);
|
|
|
}
|
|
|
@@ -102,13 +102,15 @@ class OtWebsiteRepository
|
|
|
if (!$withRestrictions) {
|
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
|
}
|
|
|
- $website = $queryBuilder
|
|
|
+ $q = $queryBuilder
|
|
|
->select('w.*')
|
|
|
->from('ot_websites', 'w')
|
|
|
->innerJoin('w', 'pages', 'p', $queryBuilder->expr()->eq('p.ot_website_uid', 'w.uid'))
|
|
|
- ->where($queryBuilder->expr()->eq('p.uid', $pageUid))
|
|
|
- ->execute()
|
|
|
- ->fetch();
|
|
|
+ ->where($queryBuilder->expr()->eq('p.uid', $pageUid));
|
|
|
+ if ($withRestrictions) {
|
|
|
+ $q->andWhere($q->expr()->eq('w.deleted', 0));
|
|
|
+ }
|
|
|
+ $website = $q->execute()->fetch();
|
|
|
if (!isset($website['uid'])) {
|
|
|
throw new NoSuchWebsiteException('No website found for page ' . $pageUid);
|
|
|
}
|
|
|
@@ -148,13 +150,15 @@ class OtWebsiteRepository
|
|
|
if (!$withRestrictions) {
|
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
|
}
|
|
|
- $rootUid = $queryBuilder
|
|
|
+ $q = $queryBuilder
|
|
|
->select('uid')
|
|
|
->from('pages')
|
|
|
->where($queryBuilder->expr()->eq('ot_website_uid', $websiteUid))
|
|
|
- ->andWhere($queryBuilder->expr()->eq('is_siteroot', 1))
|
|
|
- ->execute()
|
|
|
- ->fetchColumn(0);
|
|
|
+ ->andWhere($queryBuilder->expr()->eq('is_siteroot', 1));
|
|
|
+ if ($withRestrictions) {
|
|
|
+ $q->andWhere($q->expr()->eq('deleted', 0));
|
|
|
+ }
|
|
|
+ $rootUid = $q->execute()->fetchColumn(0);
|
|
|
if (!$rootUid > 0) {
|
|
|
throw new NoSuchRecordException('No root page found for website ' . $websiteUid);
|
|
|
}
|
|
|
@@ -176,14 +180,16 @@ class OtWebsiteRepository
|
|
|
if (!$withRestrictions) {
|
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
|
}
|
|
|
- $rootUid = $queryBuilder
|
|
|
+ $q = $queryBuilder
|
|
|
->select('p.uid')
|
|
|
->from('pages', 'p')
|
|
|
->innerJoin('p', 'ot_websites', 'w', $queryBuilder->expr()->eq('p.ot_website_uid', 'w.uid'))
|
|
|
->where($queryBuilder->expr()->eq('w.organization_id', $organizationId))
|
|
|
- ->andWhere($queryBuilder->expr()->eq('p.is_siteroot', 1))
|
|
|
- ->execute()
|
|
|
- ->fetchColumn(0);
|
|
|
+ ->andWhere($queryBuilder->expr()->eq('p.is_siteroot', 1));
|
|
|
+ if ($withRestrictions) {
|
|
|
+ $q->andWhere($q->expr()->eq('deleted', 0));
|
|
|
+ }
|
|
|
+ $rootUid = $q->execute()->fetchColumn(0);
|
|
|
if (!$rootUid) {
|
|
|
throw new NoSuchWebsiteException("No website found for organization " . $organizationId);
|
|
|
}
|