New check update for modules
This commit is contained in:
parent
69aa5553f5
commit
7794927a64
@ -518,11 +518,13 @@ if ($mode == 'common' || $mode == 'commonkanban') {
|
||||
|
||||
print $deschelp;
|
||||
|
||||
$moreforfilter = '<div class="valignmiddle">';
|
||||
$moreforfilter = '<div class="valignmiddle ">';
|
||||
|
||||
$moreforfilter .= '<div class="floatright right pagination"><ul><li>';
|
||||
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'common' ? '' : ' btnTitleSelected')));
|
||||
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'commonkanban' ? '' : ' btnTitleSelected')));
|
||||
$moreforfilter .= '<div class="floatright right pagination --module-list"><ul><li>';
|
||||
$moreforfilter .= dolGetButtonTitle($langs->trans('CheckForModuleUpdate'), $langs->trans('CheckForModuleUpdateHelp'), 'fa fa-check-double ', $_SERVER["PHP_SELF"].'?action=checklastversion&token='.newToken().'&mode='.$mode.$param, '', 1, array('morecss'=>'reposition'));
|
||||
$moreforfilter .= '</li><li>'.dolGetButtonTitleSeparator();
|
||||
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', ($mode == 'commonkanban' ? 2 : 1), array('morecss'=>'reposition'));
|
||||
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', ($mode == 'common' ? 2 : 1), array('morecss'=>'reposition'));
|
||||
$moreforfilter .= '</li></ul></div>';
|
||||
|
||||
//$moreforfilter .= '<div class="floatright center marginrightonly hideonsmartphone" style="padding-top: 3px"><span class="paddingright">'.$moreinfo.'</span> '.$moreinfo2.'</div>';
|
||||
@ -583,7 +585,7 @@ if ($mode == 'common' || $mode == 'commonkanban') {
|
||||
// Show list of modules
|
||||
$oldfamily = '';
|
||||
$linenum = 0;
|
||||
|
||||
$numOfModuleToUpdate = 0;
|
||||
foreach ($orders as $key => $value) {
|
||||
$linenum++;
|
||||
$tab = explode('_', $value);
|
||||
@ -591,6 +593,8 @@ if ($mode == 'common' || $mode == 'commonkanban') {
|
||||
$module_position = $tab[2];
|
||||
|
||||
$modName = $filename[$key];
|
||||
|
||||
/** @var DolibarrModules $objMod */
|
||||
$objMod = $modules[$modName];
|
||||
|
||||
//print $objMod->name." - ".$key." - ".$objMod->version."<br>";
|
||||
@ -856,7 +860,7 @@ if ($mode == 'common' || $mode == 'commonkanban') {
|
||||
|
||||
if ($mode == 'commonkanban') {
|
||||
// Output Kanban
|
||||
print $objMod->getKanbanView($codeenabledisable, $codetoconfig);
|
||||
print $objMod->getKanbanView($codeenabledisable, $codetoconfig, $action == 'checklastversion'?1:0);
|
||||
} else {
|
||||
print '<tr class="oddeven">'."\n";
|
||||
if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) {
|
||||
@ -894,15 +898,14 @@ if ($mode == 'common' || $mode == 'commonkanban') {
|
||||
// Version
|
||||
print '<td class="center nowrap" width="120px">';
|
||||
print $versiontrans;
|
||||
if (!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)) { // This is a bad practice to activate a synch external access during building of a page. 1 external module can hang the application.
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
if (!empty($objMod->url_last_version)) {
|
||||
$newversion = getURLContent($objMod->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
|
||||
if (isset($newversion['content'])) {
|
||||
if (version_compare($newversion['content'], $versiontrans) > 0) {
|
||||
print " <span class='butAction' title='".$langs->trans('LastStableVersion')."'>".$newversion['content']."</span>";
|
||||
}
|
||||
}
|
||||
if (!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE) || $action == 'checklastversion') { // This is a bad practice to activate a synch external access during building of a page. 1 external module can hang the application.
|
||||
$checkRes = $objMod->checkForUpdate();
|
||||
if ($checkRes > 0) {
|
||||
setEventMessage($objMod->getName().' : '.$versiontrans.' -> '.$objMod->lastVersion);
|
||||
print ' <span class="badge badge-success" title="'.dol_escape_htmltag($langs->trans('LastStableVersion')).'">'.$objMod->lastVersion.'</span>';
|
||||
}
|
||||
elseif ($checkRes < 0) {
|
||||
setEventMessage($objMod->getName().' '.$langs->trans('CheckVersionFail'), 'warnings');
|
||||
}
|
||||
}
|
||||
print "</td>\n";
|
||||
|
||||
@ -9710,6 +9710,16 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
|
||||
return '<div class="inline-block divButAction"><'.$tag.' '.$compiledAttributes.'>'.$html.'</'.$tag.'></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add space between dolGetButtonTitle
|
||||
*
|
||||
* @return string html of title separator
|
||||
*/
|
||||
function dolGetButtonTitleSeparator($moreClass = "")
|
||||
{
|
||||
return '<span class="button-title-separator '.$moreClass.'" ></span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function dolGetButtonTitle : this kind of buttons are used in title in list
|
||||
*
|
||||
@ -9718,7 +9728,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
|
||||
* @param string $iconClass class for icon element (Example: 'fa fa-file')
|
||||
* @param string $url the url for link
|
||||
* @param string $id attribute id of button
|
||||
* @param int $status 0 no user rights, 1 active, -1 Feature Disabled, -2 disable Other reason use helpText as tooltip
|
||||
* @param int $status 0 no user rights, 1 active, 2 current action or selected, -1 Feature Disabled, -2 disable Other reason use helpText as tooltip
|
||||
* @param array $params various params for future : recommended rather than adding more function arguments
|
||||
* @return string html button
|
||||
*/
|
||||
@ -9753,7 +9763,10 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u
|
||||
$useclassfortooltip = 0;
|
||||
}
|
||||
|
||||
if ($status <= 0) {
|
||||
if ($status == 2) {
|
||||
$attr['class'] .= ' btnTitleSelected';
|
||||
}
|
||||
elseif ($status <= 0) {
|
||||
$attr['class'] .= ' refused';
|
||||
|
||||
$attr['href'] = '';
|
||||
|
||||
@ -192,6 +192,18 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
*/
|
||||
public $version;
|
||||
|
||||
/**
|
||||
* Module last version
|
||||
* @var string $lastVersion
|
||||
*/
|
||||
public $lastVersion = '';
|
||||
|
||||
/**
|
||||
* true indicate this module need update
|
||||
* @var bool $needUpdate
|
||||
*/
|
||||
public $needUpdate = false;
|
||||
|
||||
/**
|
||||
* @var string Module description (short text)
|
||||
*
|
||||
@ -2215,10 +2227,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
* @param string $codetoconfig HTML code to go to config page
|
||||
* @return string HTML code of Kanban view
|
||||
*/
|
||||
public function getKanbanView($codeenabledisable = '', $codetoconfig = '')
|
||||
public function getKanbanView($codeenabledisable = '', $codetoconfig = '', $checkUpdate = false)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if ($this->isCoreOrExternalModule() == 'external' && $checkUpdate) {
|
||||
$this->checkForUpdate();
|
||||
}
|
||||
|
||||
// Define imginfo
|
||||
$imginfo = "info";
|
||||
if ($this->isCoreOrExternalModule() == 'external') {
|
||||
@ -2239,8 +2255,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
$versiontrans .= 'warning';
|
||||
}
|
||||
|
||||
$versiontrans .= ' --need-update classfortooltip';
|
||||
print '
|
||||
<div class="box-flex-item info-box-module'.(empty($conf->global->$const_name) ? ' info-box-module-disabled' : '').($this->isCoreOrExternalModule() == 'external' ? ' info-box-module-external' : '').'">
|
||||
<div class="box-flex-item info-box-module'
|
||||
.(empty($conf->global->$const_name) ? ' --disabled' : '')
|
||||
.($this->isCoreOrExternalModule() == 'external' ? ' --external' : '')
|
||||
.($this->needUpdate ? ' --need-update' : '')
|
||||
.'">
|
||||
<div class="info-box info-box-sm info-box-module">
|
||||
<div class="info-box-icon'.(empty($conf->global->$const_name) ? '' : ' info-box-icon-module-enabled'.($versiontrans ? ' info-box-icon-module-warning' : '')).'">';
|
||||
|
||||
@ -2258,7 +2279,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
}
|
||||
|
||||
if ($this->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) {
|
||||
print '<span class="info-box-icon-version'.($versiontrans ? ' '.$versiontrans : '').'" title="'.$langs->trans("Version").' '.$this->getVersion(1).'">';
|
||||
|
||||
$versionTitle = $langs->trans("Version").' '.$this->getVersion(1);
|
||||
if ($this->needUpdate){
|
||||
$versionTitle.= '<br/>'.$langs->trans('ModuleUpdateAvailable').' : '.$this->lastVersion;
|
||||
}
|
||||
|
||||
print '<span class="info-box-icon-version'.($versiontrans ? ' '.$versiontrans : '').'" title="'.dol_escape_js($versionTitle).'" >';
|
||||
print $this->getVersion(1);
|
||||
print '</span>';
|
||||
}
|
||||
@ -2287,4 +2314,29 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
|
||||
</div><!-- /.info-box -->
|
||||
</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* check for module update
|
||||
* @return int <0 if Error, 0 == no update needed, >0 if need update
|
||||
*/
|
||||
function checkForUpdate(){
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
if (!empty($this->url_last_version)) {
|
||||
$lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
|
||||
if (isset($lastVersion['content'])) {
|
||||
$this->lastVersion = $lastVersion['content'];
|
||||
if (version_compare($lastVersion['content'], $this->version) > 0) {
|
||||
$this->needUpdate = true;
|
||||
return 1;
|
||||
}else{
|
||||
$this->needUpdate = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2121,4 +2121,7 @@ YouShouldDisablePHPFunctions=You should disable PHP functions
|
||||
IfCLINotRequiredYouShouldDisablePHPFunctions=Except if you need to run system commands (for the module Scheduled job, or to run the external command line Anti-virus for example), you shoud disable PHP functions
|
||||
NoWritableFilesFoundIntoRootDir=No writable files or directories of the common programs were found into your root directory (Good)
|
||||
RecommendedValueIs=Recommended: %s
|
||||
ARestrictedPath=A restricted path
|
||||
ARestrictedPath=A restricted path
|
||||
CheckForModuleUpdate=Check for modules updates
|
||||
CheckForModuleUpdateHelp=Check for modules updates.<br/>This action will connect to modules editors to check if a new version is available.
|
||||
ModuleUpdateAvailable=An update is available for this module
|
||||
|
||||
@ -296,3 +296,4 @@ WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connec
|
||||
WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here.
|
||||
ErrorActionCommPropertyUserowneridNotDefined=User's owner is required
|
||||
ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary
|
||||
CheckVersionFail=Version check fail
|
||||
|
||||
@ -279,6 +279,11 @@ div.pagination li:first-child a.btnTitle{
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.button-title-separator{
|
||||
display: inline-block;
|
||||
clear: both;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.imgforviewmode {
|
||||
color: #aaa;
|
||||
|
||||
@ -9,10 +9,14 @@ if (!defined('ISLOADEDBYSTEELSHEET')) {
|
||||
* -------------------
|
||||
*/
|
||||
|
||||
.info-box-module-external span.info-box-icon-version {
|
||||
.info-box-module.--external span.info-box-icon-version {
|
||||
background: #bbb;
|
||||
}
|
||||
|
||||
.info-box-module.--external.--need-update span.info-box-icon-version{
|
||||
background: #bc9525;
|
||||
}
|
||||
|
||||
.info-box {
|
||||
display: block;
|
||||
position: relative;
|
||||
@ -153,7 +157,7 @@ a.info-box-text-a i.fa.fa-exclamation-triangle {
|
||||
-webkit-transition: opacity 0.5s, visibility 0s 0.5s;
|
||||
transition: opacity 0.5s, visibility 0s 0.5s;
|
||||
}
|
||||
.box-flex-item.info-box-module.info-box-module-disabled {
|
||||
.box-flex-item.info-box-module.--disabled {
|
||||
/* opacity: 0.6; */
|
||||
}
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) {
|
||||
}
|
||||
|
||||
|
||||
.info-box-module-external span.info-box-icon-version {
|
||||
.info-box-module.--external span.info-box-icon-version {
|
||||
background: #bbb;
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ a.info-box-text-a i.fa.fa-exclamation-triangle {
|
||||
transition: opacity 0.5s, visibility 0s 0.5s;
|
||||
}
|
||||
|
||||
.box-flex-item.info-box-module.info-box-module-disabled {
|
||||
.box-flex-item.info-box-module.--disabled {
|
||||
/* opacity: 0.6; */
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user