Skip to content
Snippets Groups Projects
Verified Commit cb83d071 authored by Damien's avatar Damien
Browse files

[REFACTORING] Update control

parent 85e2a85f
No related branches found
No related tags found
No related merge requests found
...@@ -23,59 +23,52 @@ if ($_SESSION['user']['UserId'] <> 'superadmin') { ...@@ -23,59 +23,52 @@ if ($_SESSION['user']['UserId'] <> 'superadmin') {
//retrives tags //retrives tags
$client = new \Gitlab\Client('https://labs.maarch.org/api/v4/'); $client = new \Gitlab\Client('https://labs.maarch.org/api/v4/');
//$client->authenticate('aSecretToken', \Gitlab\Client::AUTH_URL_TOKEN);
// $project = $client->api('projects')->show('12');
$tags = $client->api('tags')->all('12'); $tags = $client->api('tags')->all('12');
//retrieve current version //retrieve current version
$db = new Database(); $db = new Database();
$query = "SELECT param_value_int, param_value_string FROM parameters WHERE id = 'database_version'"; $query = "SELECT param_value_string FROM parameters WHERE id = 'database_version'";
$stmt = $db->query($query, []); $stmt = $db->query($query, []);
$currentVersion = $stmt->fetchObject(); $currentVersion = $stmt->fetchObject();
$versionBranch = substr($currentVersion->param_value_int, 0, 2) . '.' . substr($currentVersion->param_value_int, 2); $currentVersionBranch = substr($currentVersion->param_value_string, 0, 5);
$currentVersionNumeric = preg_replace("/[^0-9,]/", "", $currentVersion->param_value_int); $currentVersionBranchYear = substr($currentVersion->param_value_string, 0, 2);
if (!empty($currentVersion->param_value_string)) { $currentVersionBranchMonth = substr($currentVersion->param_value_string, 3, 2);
$currentVersionTagNumeric = preg_replace("/[^0-9,]/", "", $currentVersion->param_value_string); $currentVersionTag = substr($currentVersion->param_value_string, 6);
}
$allCurrentTags = []; $allCurrentTags = [];
$allNextTags = []; $allNextTags = [];
$cptCurrentTags = 0; $cptCurrentTags = 0;
$isAnyAvailableTag = false; $isAnyAvailableTag = false;
$isAnyAvailableVersion = false; $isAnyAvailableVersion = false;
foreach ($tags as $key => $value) { foreach ($tags as $value) {
//echo $tags[$key]['name'] . ' ' . preg_replace("/[^0-9,]/", "", $tags[$key]['name']) . '<br />'; if (!preg_match("/^\d{2}\.\d{2}\.\d+$/", $value['name'])) {
if (!preg_match("/^\d{2}\.\d{2}\.\d+$/", $tags[$key]['name'])) {
continue; continue;
} }
$tagNumeric = preg_replace("/[^0-9,]/", "", $tags[$key]['name']); $tag = substr($value['name'], 6);
$pos = strpos($tagNumeric, $currentVersionNumeric); $pos = strpos($value['name'], $currentVersionBranch);
if ($pos === false) { if ($pos === false) {
//echo 'tag not in currentVersion:'; $year = substr($value['name'], 0, 2);
$isAnyAvailableVersion = true; $month = substr($value['name'], 3, 2);
$allNextTags[] = $tags[$key]['name']; if (($year == $currentVersionBranchYear && $month > $currentVersionBranchMonth) || $year > $currentVersionBranchYear) {
$isAnyAvailableVersion = true;
$allNextTags[] = $value['name'];
}
} else { } else {
//echo 'tag in currentVersion:';
$allCurrentTags[$cptCurrentTags] = []; $allCurrentTags[$cptCurrentTags] = [];
$allCurrentTags[$cptCurrentTags]['name'] = $tags[$key]['name']; $allCurrentTags[$cptCurrentTags]['name'] = $value['name'];
$allCurrentTags[$cptCurrentTags]['numeric'] = $tagNumeric; if ($tag > $currentVersionTag) {
if ($tagNumeric > $currentVersionTagNumeric) {
$allCurrentTags[$cptCurrentTags]['enabled'] = true; $allCurrentTags[$cptCurrentTags]['enabled'] = true;
$isAnyAvailableTag = true; $isAnyAvailableTag = true;
} else { } else {
$allCurrentTags[$cptCurrentTags]['enabled'] = false; $allCurrentTags[$cptCurrentTags]['enabled'] = false;
} }
$cptCurrentTags++; ++$cptCurrentTags;
} }
} }
// require_once('install/class/Class_Install.php');
// $Class_Install = new Install;
?> ?>
<script> <script>
function launchProcess(myVar) { function launchProcess(myVar) {
...@@ -121,7 +114,7 @@ foreach ($tags as $key => $value) { ...@@ -121,7 +114,7 @@ foreach ($tags as $key => $value) {
<td><?php echo _YOUR_VERSION;?></td> <td><?php echo _YOUR_VERSION;?></td>
<td>:</td> <td>:</td>
<td> <td>
<?php echo '<b>' . $currentVersion->param_value_string . '</b> (' . _BRANCH_VERSION . ' : <b>' . $versionBranch . '</b>)';?> <?php echo '<b>' . $currentVersion->param_value_string . '</b>';?>
</td> </td>
</tr> </tr>
<tr> <tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment