|
|
@@ -69,6 +69,16 @@ class SiteController extends ActionController
|
|
|
const STATUS_EXISTING = 1;
|
|
|
const STATUS_EXISTING_DELETED = 2;
|
|
|
const STATUS_EXISTING_HIDDEN = 3;
|
|
|
+ const STATUS_EXISTING_WITH_WARNINGS = 4;
|
|
|
+
|
|
|
+ const STATUS_LBL = [
|
|
|
+ self::STATUS_NO_SUCH_WEBSITE => 'Does not exist',
|
|
|
+ self::STATUS_EXISTING => 'Existing',
|
|
|
+ self::STATUS_EXISTING_DELETED => 'Existing, deleted',
|
|
|
+ self::STATUS_EXISTING_HIDDEN => 'Existing, hidden',
|
|
|
+ self::STATUS_EXISTING_WITH_WARNINGS => 'Existing with warnings',
|
|
|
+ ];
|
|
|
+
|
|
|
|
|
|
const MODE_PROD = 1;
|
|
|
const MODE_DEV = 1;
|
|
|
@@ -931,6 +941,8 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
elseif ($code == self::STATUS_EXISTING_HIDDEN) {
|
|
|
$message = 'A website exists for organization ' . $organizationId . ', but is hidden or has a restricted access';
|
|
|
+ } elseif ($code == self::STATUS_EXISTING_WITH_WARNINGS) {
|
|
|
+ $message = 'A website exists for organization ' . $organizationId . ', but warnings were raised';
|
|
|
}
|
|
|
|
|
|
$title = '';
|
|
|
@@ -941,6 +953,7 @@ class SiteController extends ActionController
|
|
|
$status = [
|
|
|
'organization_id' => $organizationId,
|
|
|
'code' => $code,
|
|
|
+ 'status' => self::STATUS_LBL[$code],
|
|
|
'message' => $message,
|
|
|
'root_uid' => $rootUid,
|
|
|
'title' => $title
|
|
|
@@ -962,6 +975,29 @@ class SiteController extends ActionController
|
|
|
|
|
|
$warnings = [];
|
|
|
|
|
|
+ // fetch pages and root page
|
|
|
+ $pages = $this->otPageRepository->getAllSitePages($rootUid);
|
|
|
+
|
|
|
+ $rootPage = null;
|
|
|
+ $pageIndex = [];
|
|
|
+ foreach ($pages as $page) {
|
|
|
+ $pageIndex[$page['uid']] = $page;
|
|
|
+ if ($page['is_siteroot'] == 1) { $rootPage = $page; }
|
|
|
+ }
|
|
|
+
|
|
|
+ // fetch organization and extradata
|
|
|
+ $organization = $this->fetchOrganization($organizationId);
|
|
|
+ $extraData = $this->fetchOrganizationExtraData($organizationId);
|
|
|
+
|
|
|
+ // load site's settings (uncomment if needed)
|
|
|
+ // $config_dir = $_ENV['TYPO3_PATH_APP'] . "/config/sites/" . $organization->getSubDomain() . '_' . $organizationId;
|
|
|
+ // $config = Yaml::parseFile($config_dir . "/config.yaml");
|
|
|
+
|
|
|
+ // Check site's title
|
|
|
+ if (trim($rootPage['title']) != trim($organization->getName())) {
|
|
|
+ $warnings[] = "Site's title does not match the organization name";
|
|
|
+ }
|
|
|
+
|
|
|
// Who is the expected owner among the be_users? there should be only one.
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
|
@@ -982,18 +1018,59 @@ class SiteController extends ActionController
|
|
|
$owner = $beUsers[0];
|
|
|
}
|
|
|
|
|
|
- // scan pages
|
|
|
- $pages = $this->otPageRepository->getAllSitePages($rootUid);
|
|
|
+ // are template constants up to date?
|
|
|
+ $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
+ $actual_constants = $queryBuilder
|
|
|
+ ->select('constants')
|
|
|
+ ->from('sys_template')
|
|
|
+ ->where($queryBuilder->expr()->eq('pid', $rootUid))
|
|
|
+ ->execute()
|
|
|
+ ->fetchColumn(0);
|
|
|
+ $expected_constants = $this->getTemplateConstants($organizationId, $extraData);
|
|
|
+ $norm = function ($s) {
|
|
|
+ return strtolower(preg_replace('/\s/', '', $s));
|
|
|
+ };
|
|
|
+ if ($norm($expected_constants) != $norm($actual_constants)) {
|
|
|
+ $warnings[] = 'Template constants need an update';
|
|
|
+ }
|
|
|
|
|
|
- foreach ($pages as $page) {
|
|
|
+ $expected_templates = [
|
|
|
+ "OpenTalent.OtTemplating->home" => 0,
|
|
|
+ "OpenTalent.OtTemplating->legal" => 0,
|
|
|
+ "OpenTalent.OtTemplating->contact" => 0
|
|
|
+ ];
|
|
|
|
|
|
+ foreach ($pages as $page) {
|
|
|
// Is it the correct owner?
|
|
|
if ($owner !== null && $page['perms_userid'] != $owner['uid']) {
|
|
|
$warnings[] = 'Page ' . $page['uid'] . ' has wrong owner';
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ if (!$page['is_siteroot']) {
|
|
|
+ // is the parent page state (deleted, hidden, restricted) the same as this page?
|
|
|
+ $parent = $pageIndex[$page['pid']];
|
|
|
|
|
|
+ if ($parent['deleted'] && !$page['deleted']) {
|
|
|
+ $warnings[] = 'The non-deleted page ' . $page['uid'] . ' has a deleted parent page';
|
|
|
+ }
|
|
|
+ if ($parent['hidden'] && !$page['hidden']) {
|
|
|
+ $warnings[] = 'The non-hidden page ' . $page['uid'] . ' has a hidden parent page';
|
|
|
+ }
|
|
|
+ if ($parent['fe_group'] < 0 && !$page['fe_group'] >= 0) {
|
|
|
+ $warnings[] = 'The non-restricted page ' . $page['uid'] . ' has a restricted parent page';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // an expected template was found, remove it from the list of expected
|
|
|
+ if (in_array($page['tx_fed_page_controller_action'], $expected_templates) &&
|
|
|
+ !$page['deleted'] && !$page['hidden']) {
|
|
|
+ unset($expected_templates[$page['tx_fed_page_controller_action']]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($expected_templates as $template => $_) {
|
|
|
+ $warnings[] = 'No page with template ' . $template;
|
|
|
+ }
|
|
|
|
|
|
return $warnings;
|
|
|
}
|
|
|
@@ -1006,6 +1083,7 @@ class SiteController extends ActionController
|
|
|
* [
|
|
|
* 'organization_id' => int,
|
|
|
* 'code' => int,
|
|
|
+ * 'status' => int,
|
|
|
* 'message' => string,
|
|
|
* 'root_uid' => ?int,
|
|
|
* 'site_title' => ?string,
|
|
|
@@ -1020,6 +1098,7 @@ class SiteController extends ActionController
|
|
|
* - STATUS_EXISTING
|
|
|
* - STATUS_EXISTING_DELETED
|
|
|
* - STATUS_EXISTING_HIDDEN
|
|
|
+ * - STATUS_EXISTING_WITH_WARNINGS
|
|
|
*
|
|
|
* @param int $organizationId the organization's id whom site cache should be cleared
|
|
|
* @param bool $fullScan If true, a 'warnings' entry will be added to the result, and a full scan of
|
|
|
@@ -1046,10 +1125,13 @@ class SiteController extends ActionController
|
|
|
// ** Look for potential issues
|
|
|
$warnings = $this->scanSite($organizationId, $rootUid);
|
|
|
}
|
|
|
- return $this->buildStatusResult($organizationId, self::STATUS_EXISTING, $rootUid, $warnings);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
+ return $this->buildStatusResult(
|
|
|
+ $organizationId,
|
|
|
+ $warnings ? self::STATUS_EXISTING_WITH_WARNINGS : self::STATUS_EXISTING,
|
|
|
+ $rootUid,
|
|
|
+ $warnings);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Retrieve the Organization object from the repository and then,
|