diff --git a/apps/maarch_entreprise/admin/update_control/update_control.php b/apps/maarch_entreprise/admin/update_control/update_control.php new file mode 100644 index 0000000000000000000000000000000000000000..e1c8ebe2661891d0233a4acbce8c646a22ca128f --- /dev/null +++ b/apps/maarch_entreprise/admin/update_control/update_control.php @@ -0,0 +1,167 @@ +<?php + +/** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. +* +*/ +/** +* @brief Maarch version test +* +* @file +* @author dev@maarch.org +* @date $date$ +* @version $Revision$ +* @ingroup admin +*/ + +core_tools::load_lang(); +$core_tools = new core_tools(); +//$core_tools->test_admin('admin_update_control', 'apps'); + +$init = false; +if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') { + $init = true; +} + +$pagePath = $_SESSION['config']['businessappurl'] . 'index.php?page=' + . 'update_control&admin=update_control'; +$pageLabel = _UPDATE_CONTROL; +$pageId = 'update_control'; +$level = ''; +if (isset($_REQUEST['level']) + && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 + || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) { + $level = $_REQUEST['level']; +} +$core_tools->manage_location_bar($pagePath, $pageLabel, $pageId, $init, $level); + +//retrives tags +$client = new \Gitlab\Client('https://labs.maarch.org/api/v4/'); +//$client->authenticate('aSecretToken', \Gitlab\Client::AUTH_URL_TOKEN); + +// $project = $client->api('projects')->show('12'); +// var_dump($project); + +$tags = $client->api('tags')->all('12'); +//var_dump($tags); + +//retrieve current version +$db = new Database(); +$query = "select param_value_int, param_value_string from parameters where id = 'database_version'"; +$stmt = $db->query($query, []); +$currentVersion = $stmt->fetchObject(); +// var_dump($currentVersion); +$currentVersionNumeric = preg_replace("/[^0-9,]/", "", $currentVersion->param_value_int); +if (!empty($currentVersion->param_value_string)) { + $currentVersionTagNumeric = preg_replace("/[^0-9,]/", "", $currentVersion->param_value_string); +} + +$allTagsNumeric = []; +$allCurrentTags = []; +$allNextTags = []; +$cptCurrentTags = 0; +$isAnyAvailableTag = false; +$isAnyAvailableVersion = false; + +foreach ($tags as $key => $value) { + //echo $tags[$key]['name'] . ' ' . preg_replace("/[^0-9,]/", "", $tags[$key]['name']) . '<br />'; + $tagNumeric = preg_replace("/[^0-9,]/", "", $tags[$key]['name']); + $allTagsNumeric[] = $tagNumeric; + $pos = strpos($tagNumeric, $currentVersionNumeric); + if ($pos === false) { + //echo 'tag not in currentVersion:'; + $isAnyAvailableVersion = true; + $allNextTags[] = $tags[$key]['name']; + } else { + //echo 'tag in currentVersion:'; + $allCurrentTags[$cptCurrentTags] = []; + $allCurrentTags[$cptCurrentTags]['name'] = $tags[$key]['name']; + $allCurrentTags[$cptCurrentTags]['numeric'] = $tagNumeric; + if ($tagNumeric > $currentVersionTagNumeric) { + $allCurrentTags[$cptCurrentTags]['enabled'] = true; + $isAnyAvailableTag = true; + } else { + $allCurrentTags[$cptCurrentTags]['enabled'] = false; + } + $cptCurrentTags++; + } + //echo $tagNumeric . '<br />'; + +} +//var_dump($allCurrentTags); + +?> +<table> + <tr> + <td> + <?php echo _YOUR_VERSION;?> + </td> + <td> + : + </td> + <td> + <?php echo _BRANCH_VERSION . ':' . $currentVersion->param_value_int + . ' ' . _TAG_VERSION . ':' . $currentVersion->param_value_string;?> + + </td> + </tr> + <tr> + <td> + <?php echo _CHOOSE_VERSION_TO_UPDATE;?> + </td> + <td> + : + </td> + <td> + <?php + if (count($tags)>0) { + ?> + <select id="version" id="name"> + <option value="default"><?php echo _SELECT_A_VERSION;?></option> + <?php + for ($i=0;$i<count($allCurrentTags);$i++) { + if ($allCurrentTags[$i]['enabled']) { + echo '<option '; + echo 'value="' . $allCurrentTags[$i]['name'] . '"'; + echo '>'; + echo $allCurrentTags[$i]['name']; + echo '</option>'; + } else { + echo '<option '; + echo 'value="' . $allCurrentTags[$i]['name'] . '"'; + echo ' disabled>'; + echo $allCurrentTags[$i]['name']; + echo '</option>'; + } + } + ?> + </select> + <?php + if ($_SESSION['user']['UserId'] == 'superadmin') { + ?> + <a href="<?php echo $_SESSION['config']['coreurl'];?>install/index.php?step=update_language"><?php echo ' ' . _CLICK_HERE_TO_GO_TO_UPDATE_MANAGEMENT;?></a> + <?php + } else { + echo _CONNECT_YOU_IN_SUPERADMIN; + } + } else { + echo _NO_AVAILABLE_TAG_TO_UPDATE . '<br />'; + } + ?> + </td> + </tr> +</table> + +<?php +if (!$isAnyAvailableTag) { + echo _NO_AVAILABLE_TAG_TO_UPDATE . '<br />'; +} + +if ($isAnyAvailableVersion) { + echo _NEW_MAJOR_VERSION_AVAILABLE . '<br />'; + for ($j=0;$j<count($allNextTags);$j++) { + echo $allNextTags[$j] . '<br />'; + } +} diff --git a/apps/maarch_entreprise/xml/services.xml b/apps/maarch_entreprise/xml/services.xml index 5c3a87b6c9945142763bef4c1f1edc4542650de1..315ad6b612698bdaeba5f65787c3c5dd58d991e5 100644 --- a/apps/maarch_entreprise/xml/services.xml +++ b/apps/maarch_entreprise/xml/services.xml @@ -375,4 +375,14 @@ <system_service>false</system_service> <enabled>true</enabled> </SERVICE> + <SERVICE> + <id>admin_update_control</id> + <name>_ADMIN_UPDATE_CONTROL</name> + <comment>_ADMIN_UPDATE_CONTROL_DESC</comment> + <servicepage>index.php?page=update_control&admin=update_control</servicepage> + <servicetype>admin</servicetype> + <system_service>true</system_service> + <style>fa fa-thumbs-o-up</style> + <enabled>true</enabled> + </SERVICE> </root> diff --git a/install/view/update_download_view.php b/install/view/update_download_view.php index 8ff96b90b4c4f7d72cb4ed2fcbee5209bfbdd521..b57eee6ed52abffaf52fe49343486c0c27c20d92 100644 --- a/install/view/update_download_view.php +++ b/install/view/update_download_view.php @@ -105,7 +105,7 @@ $currentVersion = $stmt->fetchObject(); <option value="default">Select a version</option> <?php foreach ($tags as $key => $value) { - echo $tags[$key]['name'] . '<br />'; + //echo $tags[$key]['name'] . '<br />'; echo '<option '; echo 'value="' . $tags[$key]['name'] . '"'; echo '>'; @@ -116,9 +116,7 @@ $currentVersion = $stmt->fetchObject(); </select> <?php } else { - ?> - No version available for update - <?php + echo _NO_AVAILABLE_VERSION_TO_UPDATE; } ?>