db check working
This commit is contained in:
@@ -44,6 +44,13 @@ class WebsiteManager implements WebsiteManagerContract
|
||||
}
|
||||
}
|
||||
|
||||
if ($route === 'database') {
|
||||
if ($action === 'update') {
|
||||
$this->handleUpdateDB();
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
if ($route === 'page_settings') {
|
||||
if ($action === 'create') {
|
||||
$this->handleCreate();
|
||||
@@ -155,6 +162,21 @@ class WebsiteManager implements WebsiteManagerContract
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle requests for updating the website DB.
|
||||
*/
|
||||
public function handleUpdateDB()
|
||||
{
|
||||
global $phpb_db;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$phpb_db->resolveDiffDB();
|
||||
phpb_redirect(phpb_url('website_manager', ['tab' => 'info']), [
|
||||
'message-type' => 'success',
|
||||
'message' => phpb_trans('website-manager.db-updated')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the website manager overview page.
|
||||
*/
|
||||
|
||||
@@ -8,20 +8,51 @@
|
||||
<tr>
|
||||
<th class="w-60">Database</th>
|
||||
<td>
|
||||
<form method="post" action="<?= phpb_url('website_manager', ['route' => 'database', 'action' => 'update', 'tab' => 'info']) ?>">
|
||||
<?php
|
||||
global $phpb_db;
|
||||
$tables = include __DIR__.'/../../../../../../config/tables.php';
|
||||
foreach ($tables as $table => $structure) :
|
||||
?>
|
||||
<li>
|
||||
<?= phpb_e($table) ?> (<?= phpb_e($phpb_db->tableExists($table) ? 'yes' : 'no') ?>)
|
||||
<ul>
|
||||
<li></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
endforeach;
|
||||
$diff = $phpb_db->diffDB();
|
||||
$actionNeeded = false;
|
||||
foreach ($diff as $table => $tableDiff) :
|
||||
if(!is_array($tableDiff)) $actionNeeded = true;
|
||||
?>
|
||||
<div>
|
||||
table <strong><?= phpb_e($table) ?></strong> (<?= phpb_e(is_array($tableDiff) ? (empty($tableDiff['columns']) && empty($tableDiff['uniqueKeys']) ? 'is fine' : 'has diff') : 'is not existent') ?>)
|
||||
</div>
|
||||
<?php
|
||||
if (is_array($tableDiff)) :
|
||||
foreach ($tableDiff['columns'] as $column => $def) :
|
||||
$actionNeeded = true;
|
||||
?>
|
||||
<div class="ml-4">
|
||||
<i class="ph ph-arrow-elbow-down-right"></i> column <strong><?= phpb_e($column) ?></strong> (not existent)
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
if (is_array($tableDiff)) :
|
||||
foreach ($tableDiff['uniqueKeys'] as $key => $def) :
|
||||
$actionNeeded = true;
|
||||
?>
|
||||
<div class="ml-4">
|
||||
<i class="ph ph-arrow-elbow-down-right"></i> unique key <strong><?= phpb_e($key) ?></strong> (not existent)
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
endforeach;
|
||||
if ($actionNeeded) :
|
||||
?>
|
||||
<button class="btn" type="submit">Update</button>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -16,7 +16,6 @@ $settingIns = phpb_instance('setting');
|
||||
<label class="label cursor-pointer">
|
||||
<span class="label-text"><?= phpb_e($localeText) ?></span>
|
||||
<input type="checkbox" name="languages[]" value="<?= phpb_e($locale) ?>" <?= phpb_e($settingIns::has('languages', $locale)) ? 'checked' : '' ?> class="checkbox checkbox-sm" />
|
||||
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
@@ -116,6 +115,5 @@ $settingIns = phpb_instance('setting');
|
||||
<!-- <a href="--><?php //= phpb_url('website_manager', ['route' => 'settings', 'action' => 'renderBlockThumbs']) ?><!--" class="btn btn-secondary btn-sm mr-1">-->
|
||||
<!-- --><?php //= phpb_trans('website-manager.render-thumbs') ?>
|
||||
<!-- </a>-->
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user