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/js/functions.js b/apps/maarch_entreprise/js/functions.js index 8f5c870315e91d864a715a1595ea3cba1a5fcf2c..b1c83d3c75367c90b7f2b1767688b373fa8635eb 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -1591,24 +1591,22 @@ function action_send_form_confirm_result(path_manage_script, mode_req, id_action } } -function action_change_status(path_manage_script, mode_req, res_id_values, tablename, id_coll, status,page) +function action_change_status(path_manage_script, mode_req, res_id_values, tablename, id_coll, status, page) { - if(res_id_values != '' && (mode_req == 'mass' || mode_req == 'page') - && tablename != '' && id_coll != '') - { + if(res_id_values != '' && (mode_req == 'mass' || mode_req == 'page') && tablename != '' && id_coll != '') { $j.ajax({ cache : false, url : path_manage_script, type : 'POST', - dataType : 'json', - data: { values : res_id_values, - mode : mode_req, - req : 'change_status', - table : tablename, - coll_id : id_coll, - new_status : status, - }, + data: { + values : res_id_values, + mode : mode_req, + req : 'change_status', + table : tablename, + coll_id : id_coll, + new_status : status + }, success: function(answer) { setTimeout(function(){ diff --git a/apps/maarch_entreprise/services/Table.php b/apps/maarch_entreprise/services/Table.php index a0a2d24e3cba023f7ba276e0f14634741617a544..e6fa8febe16dd8452d2d5d715b5424fd42d2ce30 100644 --- a/apps/maarch_entreprise/services/Table.php +++ b/apps/maarch_entreprise/services/Table.php @@ -24,7 +24,6 @@ require_once 'core/services/Abstract.php'; require_once 'core/core_tables.php'; require_once 'core/class/class_functions.php'; require_once 'core/class/class_db_pdo.php'; -require_once 'core/services/Logs.php'; /** * Fonctions pour réaliser le CRUD sur la base de donnees 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/core/services/Logs.php b/core/services/Logs.php deleted file mode 100644 index 1866155df0c58cb11eb0b5b298ebf8e60185d417..0000000000000000000000000000000000000000 --- a/core/services/Logs.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -/** -* @copyright 2016 capgemini -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'LogsAbstract.php'; - -class Core_Logs_Service extends Core_LogsAbstract_Service { - // Do your stuff -} diff --git a/core/services/LogsAbstract.php b/core/services/LogsAbstract.php deleted file mode 100644 index 1468c7de5e0595654ddc68577fa7a496475a6692..0000000000000000000000000000000000000000 --- a/core/services/LogsAbstract.php +++ /dev/null @@ -1,331 +0,0 @@ -<?php - -/** -* @copyright 2017 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'Abstract.php'; -require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'String.php'; -if (!defined('_LOG4PHP')) - define( - '_LOG4PHP', - 'log4php' - ); - -if (!defined('_BDD')) - define( - '_BDD', - 'database' - ); - -if (!defined('_LOGGER_NAME_TECH_DEFAULT')) - define( - '_LOGGER_NAME_TECH_DEFAULT', - 'loggerTechnique' - ); - -if (!defined('_LOGGER_NAME_FUNC_DEFAULT')) - define( - '_LOGGER_NAME_FUNC_DEFAULT', - 'loggerFonctionnel' - ); -require_once 'apps'. DIRECTORY_SEPARATOR . 'maarch_entreprise'. DIRECTORY_SEPARATOR . 'tools'. DIRECTORY_SEPARATOR . 'log4php'. DIRECTORY_SEPARATOR . 'Logger.php'; - -class Core_LogsAbstract_Service extends Core_Abstract_Service { - - protected static function getLoggingMethodConfFile() - { - $xmlFileName = 'logging_method.xml'; - if (file_exists($sLoggingMethodConfFile = 'custom' - .DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'] - .DIRECTORY_SEPARATOR . 'apps' - .DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'] - .DIRECTORY_SEPARATOR.'xml' - .DIRECTORY_SEPARATOR.$xmlFileName - )) { - return $sLoggingMethodConfFile; - } - if (file_exists($sLoggingMethodConfFile = - 'apps' - .DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'] - .DIRECTORY_SEPARATOR.'xml' - .DIRECTORY_SEPARATOR.$xmlFileName - )) { - return $sLoggingMethodConfFile; - } - return null; - } - public static function getLoggingFormat(array $aArgs = []) { - self::checkRequired($aArgs,['key']); - self::checkNumeric($aArgs,['key']); - $logging_methods = self::getLoggingMethod($aArgs); - return empty($logging_methods[$aArgs['key']]['LOG_FORMAT']) ? '[%RESULT%][%CODE_METIER%][%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]' : $logging_methods[$aArgs['key']]['LOG_FORMAT']; - } - public static function getLoggingCodeMetier(array $aArgs = []) { - self::checkRequired($aArgs,['key']); - self::checkNumeric($aArgs,['key']); - $logging_methods = self::getLoggingFormat($aArgs); - return empty($logging_methods[$aArgs['key']]['CODE_METIER']) ? '[%RESULT%][%CODE_METIER%][%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]' : $logging_methods[$aArgs['key']]['CODE_METIER']; - } - /** - * Get the logging method in the configuration file - */ - protected static function getLoggingMethod(array $aArgs = []) { - $sLoggingMethodConfFile = self::getLoggingMethodConfFile(); - - $logging_methods = []; - if ( ! $sLoggingMethodConfFile = self::getLoggingMethodConfFile() ) { - $logging_methods[0]['ID'] = 'database'; - $logging_methods[0]['ACTIVATED'] = true; - $logging_methods[1]['ID'] = 'log4php'; - $logging_methods[1]['ACTIVATED'] = true; - $logging_methods[1]['LOGGER_NAME_TECH'] = 'loggerTechnique'; - $logging_methods[1]['LOGGER_NAME_FUNC'] = 'loggerFonctionnel'; - $logging_methods[1]['LOG_FORMAT'] = '[%RESULT%][%CODE_METIER%][%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]'; - $logging_methods[1]['CODE_METIER'] = 'MAARCH'; - return $logging_methods; - } - - if (! file_exists($sLoggingMethodConfFile) ) { - throw new \Exception('not file_exists : '.$sLoggingMethodConfFile); - } - $xmlConfig = @simplexml_load_file($sLoggingMethodConfFile); - if (! $xmlConfig) { - throw new \Exception('simplexml_load_file failed : '.$sLoggingMethodConfFile); - } - if (! $xmlConfig->METHOD) { - throw new \Exception('no data METHOD found : '.$sLoggingMethodConfFile); - } - - foreach ($xmlConfig->METHOD as $METHOD) { - $id = ((string)$METHOD->ID); - $activated = ((boolean)$METHOD->ENABLED); - $loggerNameTech = ((string)$METHOD->LOGGER_NAME_TECH); - $loggerNameFunc = ((string)$METHOD->LOGGER_NAME_FUNC); - $logFormat = ((string)$METHOD->APPLI_LOG_FORMAT); - $codeMetier = ((string)$METHOD->CODE_METIER); - - array_push( - $logging_methods, - array( - 'ID' => $id, - 'ACTIVATED' => $activated, - 'LOGGER_NAME_TECH' => $loggerNameTech, - 'LOGGER_NAME_FUNC' => $loggerNameFunc, - 'LOG_FORMAT' => $logFormat, - 'CODE_METIER' => $codeMetier - ) - ); - } - - return $logging_methods; - } - - protected static function getConfFile(array $aArgs = []) { - if ( empty($_SESSION['config']['app_id']) ) { - $_SESSION['config']['app_id'] = 'maarch_entreprise'; - } - if ( - !empty($_SESSION['config']['corepath']) && !empty($_SESSION['custom_override_id']) - && file_exists($configFileLog4PHP = - $_SESSION['config']['corepath']. DIRECTORY_SEPARATOR . 'custom' - . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id'] - . DIRECTORY_SEPARATOR . 'apps' - . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'xml' - . DIRECTORY_SEPARATOR . 'log4php.xml' - )) { - return $configFileLog4PHP; - } - if (file_exists($configFileLog4PHP = - 'apps' - . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'xml' - . DIRECTORY_SEPARATOR . 'log4php.xml' - )) { - return $configFileLog4PHP; - } - return 'apps' - . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'xml' - . DIRECTORY_SEPARATOR . 'log4php.default.xml'; - } - - protected static function format_message(array &$aArgs) { - $aArgs['message'] = @$aArgs['message']; - switch (true) { - case is_object($aArgs['message']): - if ( $aArgs['message'] instanceof \Exception ) { - $e = $aArgs['message']; - $aArgs['code'] = $e->getCode(); - $aArgs['message'] = 'Exception: '.$e->getMessage(); - $aArgs['debug'] = $e->getTraceAsString(); - break; - } - $aArgs['message'] = '--object--'; - break; - case is_array($aArgs['message']): - $aArgs['message'] = '--array--'; - break; - default: - $aArgs['message'] = (string)$aArgs['message']; - break; - } - $aArgs['message'] = str_replace("\n", '\n', $aArgs['message']); - - // Old method : - $formatter = new functions(); - $aArgs['message'] = $formatter->wash_html( - $aArgs['message'], - '' - ); - $aArgs['message'] = Core_String_Service::wd_remove_accents($aArgs['message']); - - if(!empty($_SESSION['user']['UserId'])){ - $aArgs['message'] = '[' . $_SESSION['user']['UserId'] . '] ' . $aArgs['message']; - } - - return $aArgs; - } - protected static function logs(array $aArgs = []) { - // Initialisation du Logger : - Logger::configure( - self::getConfFile() - ); - if ( @$aArgs['class'] ) { - Logger::getLogger($aArgs['class']); - } - $aLoggingMethods = self::getLoggingMethod(); - - $aArgs = self::format_message($aArgs); - if ( @$aArgs['class'] ) { - $sLog .= "[class:{$aArgs['class']}]"; - Logger::getLogger($aArgs['class']); - } - - foreach ($aLoggingMethods as $logging_method) { - if ( ! $logging_method['ACTIVATED'] ) { - continue; - } - - if (isset($aArgs['isTech']) && $aArgs['isTech']) { - $logger = Logger::getLogger( - $logging_method['LOGGER_NAME_TECH'] - ); - } else { - if(!isset($logging_method['LOGGER_NAME_FUNC'])){ - $logging_method['LOGGER_NAME_FUNC'] = 'loggerFonctionnel'; - } - $logger = Logger::getLogger( - $logging_method['LOGGER_NAME_FUNC'] - ); - } - if ( empty($logger) ) { - throw new \Exception('logger not-loading', 1); - } - // Format : - $sLog = ''; - if ( @$aArgs['file'] ) { - $sLog .= "[file:{$aArgs['file']}]"; - } - if ( @$aArgs['class'] ) { - $sLog .= "[class:{$aArgs['class']}]"; - } - if ( @$aArgs['function'] ) { - $sLog .= "[function:{$aArgs['function']}]"; - } - if ( @$aArgs['code'] ) { - $aArgs['code'] = (int)$aArgs['code']; - $sLog .= "[code:{$aArgs['code']}]"; - } - - if(!isset($logging_method['CODE_METIER'])){ - $logging_method['CODE_METIER'] = 'SIPol'; - } - $sLog = str_replace('%CODE_METIER%', $logging_method['CODE_METIER'], "{$sLog}{$aArgs['message']}"); - - // Log : - switch ($aArgs['type']) { - case 'debug': - case _LEVEL_DEBUG: - $logger->debug($sLog); - break; - - case 'info': - case _LEVEL_INFO: - $logger->info($sLog); - break; - - case 'warning': - case _LEVEL_WARN: - $logger->warn($sLog); - break; - - case 'error': - case _LEVEL_ERROR: - $logger->error($sLog); - break; - - case _LEVEL_FATAL: - $logger->fatal($sLog); - break; - - default: - $logger->error($sLog); - } - } - return true; - } - public static function debug(array $aArgs = []) { - $aArgs['type'] = 'debug'; - return self::logs($aArgs); - } - public static function info(array $aArgs = []) { - $aArgs['type'] = 'info'; - return self::logs($aArgs); - } - public static function warning(array $aArgs = []) { - $aArgs['type'] = 'warning'; - return self::logs($aArgs); - } - public static function error(array $aArgs = []) { - $aArgs['type'] = 'error'; - return self::logs($aArgs); - } - public static function fatal(array $aArgs = []) { - $aArgs['type'] = _LEVEL_FATAL; - return self::logs($aArgs); - } - - /* - timestart : timestamp Debut - timeend : timestamp Fin - level : level log4php - message : message dans les logs - */ - public static function executionTimeLog($timestart, $timeend, $level, $message){ - if(empty($timeend)){ - $timeend = microtime(true); - } - $time = $timeend - $timestart; - - self::$level(['message' => $message.'. Done in ' . number_format($time, 3) . ' secondes.']); - - } -} - diff --git a/core/services/Modules.php b/core/services/Modules.php deleted file mode 100644 index b4129d12de0b9d21ecb01649132a11dbda530dcd..0000000000000000000000000000000000000000 --- a/core/services/Modules.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -/** -* @copyright 2016 capgemini -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core/services/ModulesAbstract.php'; - -class Core_Modules_Service extends Core_ModulesAbstract_Service { - // Do your stuff -} \ No newline at end of file diff --git a/core/services/ModulesAbstract.php b/core/services/ModulesAbstract.php deleted file mode 100644 index 5343ea8f4a58163bb92cf7dafd3f247eb0be441b..0000000000000000000000000000000000000000 --- a/core/services/ModulesAbstract.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php - -/** -* @copyright 2017 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core/services/Abstract.php'; - -class Core_ModulesAbstract_Service extends Core_Abstract_Service { - public static function getApiMethod() { - $aMethod = parent::getApiMethod(); - $aMethod['getList'] = 'getList'; - return $aMethod; - } - /** - * Renvoie la liste des modules - * @throw \Exception $e - * @param array $args - * @return array $aModules - **/ - public static function getList(array $args = []) { - if ( ! file_exists('modules') ) { - throw new \Exception('path modules not-found'); - } - $aDir = scandir('modules'); - $aModules = []; - foreach ($aDir as $dir) { - if ( '.'==$dir[0]) continue; - if ( !is_dir("modules/$dir") ) continue; - $aModules[$dir] = $dir; - } - return $aModules; - } - /** - * Renvoie la liste des services - * @param array $args - * - require : inclue directement la definition du service si ce n'ai pas fait - * @return array $aModules - **/ - public static function getServicesList(array $args = []) { - // Initialisation : - $aServices = []; - $aServices['apps'] = []; - // Recherche dans Apps : - foreach ([ - $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']."/apps/maarch_entreprise/services", - "apps/maarch_entreprise/services", - ] as $sPathModuleService) { - if ( is_dir($sPathModuleService) ) { - $aDir = scandir($sPathModuleService); - foreach ($aDir as $dir) { - if ( '.'==$dir[0]) continue; - if ( preg_match('/svn-commit/', $dir) ) continue; - if ( !is_file("$sPathModuleService/$dir") ) continue; - $sService = preg_replace('/\.php$/', '', $dir); - $sService = 'Apps_'.ucfirst($sService).'_Service'; - if ( !empty($aServices['apps'][$sService]) ) continue; // Déjà fait - if ( !class_exists($sService) && !empty($args['require']) ) require_once "$sPathModuleService/$dir"; - $aServices['apps'][$sService] = $sService; - } - } - } - if ( empty($aServices['apps']) ) { - unset($aServices['apps']); - } - // Recherche dans Core : - $aServices['core'] = []; - foreach ([ - $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']."/core/services", - "core/services", - ] as $sPathModuleService) { - if ( is_dir($sPathModuleService) ) { - $aDir = scandir($sPathModuleService); - foreach ($aDir as $dir) { - if ( '.'==$dir[0]) continue; - if ( preg_match('/svn-commit/', $dir) ) continue; - if ( !is_file("$sPathModuleService/$dir") ) continue; - $sService = preg_replace('/\.php$/', '', $dir); - $sService = 'Core_'.ucfirst($sService).'_Service'; - if ( !empty($aServices['core'][$sService]) ) continue; // Déjà fait - if ( !class_exists($sService) && !empty($args['require']) ) require_once "$sPathModuleService/$dir"; - $aServices['core'][$sService] = $sService; - } - } - } - if ( empty($aServices['core']) ) { - unset($aServices['core']); - } - // Recherche dans tous les modules : - $aModules = self::getList(); - foreach ($aModules as $sModule) { - // Recherche dans maarch + custom : - foreach ([ - $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']."/modules/{$sModule}/services", - "modules/{$sModule}/services", - ] as $sPathModuleService) { - if ( is_dir($sPathModuleService) ) { - $aDir = scandir($sPathModuleService); - foreach ($aDir as $dir) { - if ( '.'==$dir[0]) continue; - if ( preg_match('/svn-commit/', $dir) ) continue; - if ( !is_file("$sPathModuleService/$dir") ) continue; - $sService = preg_replace('/\.php$/', '', $dir); - $sService = ucfirst($sModule).'_'.ucfirst($sService).'_Service'; - if ( !empty($aServices[$sModule][$sService]) ) continue; // Déjà fait - if ( !class_exists($sService) && !empty($args['require']) ) require_once "$sPathModuleService/$dir"; - $aServices[$sModule][$sService] = $sService; - } - } - } - if ( empty($aServices[$sModule]) ) { - unset($aServices[$sModule]); - } - } - // Retour : - return $aServices; - } -} \ No newline at end of file diff --git a/core/services/Rest.php b/core/services/Rest.php deleted file mode 100644 index 44041a5a5b7bdd67d1997d44a0d71a4b3445e0a0..0000000000000000000000000000000000000000 --- a/core/services/Rest.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php - -/** -* @copyright 2017 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ -require_once 'core/services/Logs.php'; - -/** - * Service des gestion des appels rest - */ -class Core_Rest_Service { - /** - * Constructeur - */ - public function __construct() { - } - - /** - * Encodage en json - * @param array $json Liste d'arguments - * - string status [description] - * - string result [description] - * - string errors [description] - * - string debug [description] - */ - public function json(array $json) { - header('Content-Type: application/json'); - if ( !isset($json['status']) ) { - throw new \Exception('$oServiceRest->return([...]) : status not-isset'); - } - if ( !isset($json['result']) ) { - throw new \Exception('$oServiceRest->return([...]) : result not-isset'); - } - if ( !isset($json['errors']) ) { - throw new \Exception('$oServiceRest->return([...]) : error not-isset'); - } - if ( empty($json['debug']) ) { - $json['debug'] = null; - } - if ( is_array($json['result']) ) { - $json['result_count'] = count($json['result']); - } - echo json_encode($json); - exit; - } - - /** - * Renvoi avec succès des données encodées en json - * @param array $json Liste d'arguments - * - string status [description] - * - string result [description] - * - string errors [description] - * - string debug [description] - */ - public function returnSuccess(array $json) { - $this->json([ - 'status' => empty($json['status']) ? 0 : $json['status'], - 'result' => $json['result'], - 'errors' => [], - 'debug' => empty($json['debug'])? null : $json['debug'], - ]); - } - - /** - * Renvoi avec erreur des données encodées en json - * @param array $json Liste d'arguments - * - string status [description] - * - string result [description] - * - string errors [description] - * - string debug [description] - */ - public function returnError(array $json) { - if ( is_string($json['errors'])) { - $json['errors'] = [$json['errors']]; - } - $json['status'] = empty($json['status']) ? -1 : $json['status']; - $json['debug'] = empty($json['debug'])? null : $json['debug']; - Core_Logs_Service::error([ - 'message' => 'Exception : '.$json['errors'][0]."\n".$json['debug'], - 'code' => $json['status'], - 'file' => __FILE__, - ]); - $this->json([ - 'status' => $json['status'], - 'result' => false, - 'errors' => $json['errors'], - 'debug' => DEBUG ? $json['debug'] : null, - ]); - } - - public function returnWarning(array $json) { - if ( is_string($json['errors'])) { - $json['errors'] = [$json['errors']]; - } - $json['status'] = empty($json['status']) ? -1 : $json['status']; - $json['debug'] = empty($json['debug'])? null : $json['debug']; - Core_Logs_Service::warning([ - 'message' => 'Exception : '.$json['errors'][0]."\n".$json['debug'], - 'code' => $json['status'], - 'file' => __FILE__, - ]); - $this->json([ - 'status' => $json['status'], - 'result' => false, - 'errors' => $json['errors'], - 'debug' => DEBUG ? $json['debug'] : null, - ]); - } - -} diff --git a/core/services/String.php b/core/services/String.php deleted file mode 100644 index 54e7868b95da737657032eefde2b0c9a1499813c..0000000000000000000000000000000000000000 --- a/core/services/String.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -/** -* @copyright 2016 capgemini -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'StringAbstract.php'; - -class Core_String_Service extends Core_StringAbstract_Service { - // Do your stuff -} diff --git a/core/services/StringAbstract.php b/core/services/StringAbstract.php deleted file mode 100644 index 11e19b2c290365fef4015cb003fa091ef8ec085d..0000000000000000000000000000000000000000 --- a/core/services/StringAbstract.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/** -* @copyright 2016 capgemini -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'Abstract.php'; - -class Core_StringAbstract_Service extends Core_Abstract_Service { - - /** - * Delete accents - * - * @param $str (string) - * @param $charset = 'utf-8' (string) - * - * @return string $str - */ - public static function wd_remove_accents( - $str, - $charset ='utf-8' - ) - { - $str = htmlentities( - $str, - ENT_NOQUOTES, - "utf-8" - ); - $str = preg_replace( - '#\&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring)\;#', - '\1', - $str - ); - $str = preg_replace( - '#\&([A-za-z]{2})(?:lig)\;#', - '\1', - $str - ); - $str = preg_replace( - '#\&[^;]+\;#', - '', - $str - ); - - return $str; - } -} 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; } ?>