BUG 5978 Add getVersion to System class and use it instead of PM_VERSION
Instead of every page defining it's own PM_VERSION interpretation, there is now a single getVersion function in the System class to always get the right version.
This commit is contained in:
@@ -83,25 +83,45 @@ class System {
|
||||
return $aWorkspaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ProcessMaker version. If version-pmos.php is not found, try to
|
||||
* retrieve the version from git.
|
||||
*
|
||||
* @author Alexandre Rosenfeld <alexandre@colosa.com>
|
||||
* @return string system
|
||||
*/
|
||||
public static function getVersion() {
|
||||
if (! defined ( 'PM_VERSION' )) {
|
||||
if (file_exists ( PATH_METHODS . 'login/version-pmos.php' )) {
|
||||
include (PATH_METHODS . 'login/version-pmos.php');
|
||||
}
|
||||
else {
|
||||
$cmd = sprintf ("cd %s && git status | grep 'On branch' | awk '{print \"Branch: \" $4} '", PATH_TRUNK);
|
||||
if ( exec ( $cmd , $target) ) {
|
||||
$cmd = sprintf ("cd %s && git describe ", PATH_TRUNK);
|
||||
$commit = exec ( $cmd , $target);
|
||||
define ( 'PM_VERSION', implode(' ', $target) );
|
||||
}
|
||||
else
|
||||
define ( 'PM_VERSION', 'Development Version' );
|
||||
} else {
|
||||
$version = self::getVersionFromGit();
|
||||
if ($version === false)
|
||||
$version = 'Development Version';
|
||||
define ( 'PM_VERSION', $version );
|
||||
}
|
||||
}
|
||||
return PM_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the branch and tag information from a git repository.
|
||||
*
|
||||
* @author Alexandre Rosenfeld <alexandre@colosa.com>
|
||||
* @return string branch and tag information
|
||||
*/
|
||||
public static function getVersionFromGit($dir = NULL) {
|
||||
if ($dir == NULL)
|
||||
$dir = PATH_TRUNK;
|
||||
if (!file_exists("$dir/.git"))
|
||||
return false;
|
||||
if (exec("cd $dir && git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* \(.*\)$/(Branch \\1)/'", $target)) {
|
||||
exec("cd $dir && git describe", $target);
|
||||
return implode(' ', $target);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get system information
|
||||
*
|
||||
@@ -109,12 +129,6 @@ class System {
|
||||
* @return array with system information
|
||||
*/
|
||||
public static function getSysInfo() {
|
||||
if( file_exists(PATH_METHODS . 'login/version-pmos.php') ) {
|
||||
require_once (PATH_METHODS . 'login/version-pmos.php');
|
||||
} else {
|
||||
define('PM_VERSION', 'Development Version');
|
||||
}
|
||||
|
||||
$ipe = explode(" ", $_SERVER['SSH_CONNECTION']);
|
||||
|
||||
if( getenv('HTTP_CLIENT_IP') ) {
|
||||
@@ -157,7 +171,7 @@ class System {
|
||||
$Fields = array();
|
||||
$Fields['SYSTEM'] = $distro;
|
||||
$Fields['PHP'] = phpversion();
|
||||
$Fields['PM_VERSION'] = PM_VERSION;
|
||||
$Fields['PM_VERSION'] = self::getVersion();
|
||||
$Fields['SERVER_ADDR'] = $ipe[2]; //lookup($ipe[2]);
|
||||
$Fields['IP'] = $ipe[0]; //lookup($ipe[0]);
|
||||
|
||||
@@ -328,14 +342,7 @@ class System {
|
||||
}
|
||||
}
|
||||
|
||||
//now getting the current version of PM
|
||||
if( file_exists(PATH_METHODS . 'login/version-pmos.php') ) {
|
||||
include (PATH_METHODS . 'login/version-pmos.php');
|
||||
} else {
|
||||
define('PM_VERSION', '1.6-0-development');
|
||||
}
|
||||
|
||||
$pmVersion = explode('-', PM_VERSION);
|
||||
$pmVersion = explode('-', self::getVersion());
|
||||
array_shift($pmVersion);
|
||||
$patchVersion = explode('-', $this->sRevision);
|
||||
|
||||
|
||||
@@ -1931,7 +1931,8 @@ class wsBase
|
||||
$result->status_code = 0;
|
||||
$result->message = 'Sucessful';
|
||||
$result->timestamp = date ( 'Y-m-d H:i:s');
|
||||
$result->version = PM_VERSION;
|
||||
G::LoadClass("system");
|
||||
$result->version = System::getVersion();
|
||||
$result->operatingSystem = $redhat;
|
||||
$result->webServer = getenv('SERVER_SOFTWARE');
|
||||
$result->serverName = getenv('SERVER_NAME');
|
||||
|
||||
@@ -130,11 +130,7 @@ class webEntryProxy extends HttpProxyController
|
||||
|
||||
//return $params;
|
||||
|
||||
if (file_exists ( PATH_METHODS . 'login/version-pmos.php' )) {
|
||||
include_once (PATH_METHODS . 'login/version-pmos.php');
|
||||
} else {
|
||||
define ( 'PM_VERSION', 'Dev.' );
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
$pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP;
|
||||
G::mk_dir ( $pathProcess, 0777 );
|
||||
@@ -193,7 +189,7 @@ class webEntryProxy extends HttpProxyController
|
||||
$template->assign ( 'dynaform', $dynTitle );
|
||||
$template->assign ( 'timestamp', date ( 'l jS \of F Y h:i:s A' ) );
|
||||
$template->assign ( 'ws', SYS_SYS );
|
||||
$template->assign ( 'version', PM_VERSION );
|
||||
$template->assign ( 'version', System::getVersion() );
|
||||
|
||||
$fileName = $pathProcess . $dynTitle . 'Post.php';
|
||||
file_put_contents ( $fileName, $template->getOutputContent () );
|
||||
|
||||
@@ -97,13 +97,11 @@ if(isset($_POST['action'])) {
|
||||
G::LoadCLass('net');
|
||||
$net = new NET(G::getIpAddress());
|
||||
|
||||
if( !defined("PM_VERSION")){
|
||||
define('PM_VERSION', 'development');
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
$META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n".
|
||||
" @Ver: 1.0 Oct-2009\n".
|
||||
" @Processmaker version: ".PM_VERSION."\n".
|
||||
" @Processmaker version: ".System::getVersion()."\n".
|
||||
" -------------------------------------------------------\n".
|
||||
" @Export Date: ".date("l jS \of F Y h:i:s A")."\n".
|
||||
" @Server address: ".getenv('SERVER_NAME')." (".getenv('SERVER_ADDR').")\n".
|
||||
@@ -237,9 +235,7 @@ if(isset($_POST['function'])) {
|
||||
|
||||
G::LoadCLass('net');
|
||||
$net = new NET(G::getIpAddress());
|
||||
if( !defined("PM_VERSION")){
|
||||
define('PM_VERSION', 'development');
|
||||
}
|
||||
G::LoadClass("system");
|
||||
$EXPORT_TRACEBACK = Array();
|
||||
foreach ($tables as $uid) {
|
||||
$aTable = new additionalTables();
|
||||
|
||||
@@ -11,11 +11,7 @@ $sWE_USR = $oData->WE_USR;
|
||||
|
||||
$withWS = $sWE_TYPE == 'WS';
|
||||
|
||||
if (file_exists ( PATH_METHODS . 'login/version-pmos.php' )) {
|
||||
include_once (PATH_METHODS . 'login/version-pmos.php');
|
||||
} else {
|
||||
define ( 'PM_VERSION', 'Dev.' );
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
try {
|
||||
$pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP;
|
||||
@@ -87,7 +83,7 @@ try {
|
||||
$template->assign ( 'dynaform', $dynTitle );
|
||||
$template->assign ( 'timestamp', date ( 'l jS \of F Y h:i:s A' ) );
|
||||
$template->assign ( 'ws', SYS_SYS );
|
||||
$template->assign ( 'version', PM_VERSION );
|
||||
$template->assign ( 'version', System::getVersion() );
|
||||
|
||||
$fileName = $pathProcess . $dynTitle . 'Post.php';
|
||||
file_put_contents ( $fileName, $template->getOutputContent () );
|
||||
|
||||
@@ -75,13 +75,7 @@ function file_get_conditional_contents($szURL){
|
||||
function buildData(){
|
||||
G::LoadClass ( 'serverConfiguration' );
|
||||
$oServerConf = & serverConf::getSingleton ();
|
||||
if (! defined ( 'PM_VERSION' )) {
|
||||
if (file_exists ( PATH_METHODS . 'login/version-pmos.php' )) {
|
||||
require_once (PATH_METHODS . 'login/version-pmos.php');
|
||||
} else {
|
||||
define ( 'PM_VERSION', 'Development Version' );
|
||||
}
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
$os = '';
|
||||
if (file_exists ( '/etc/redhat-release' )) {
|
||||
@@ -106,7 +100,7 @@ $oServerConf = & serverConf::getSingleton ();
|
||||
$params ['os'] = $os;
|
||||
$params ['webserver'] = getenv ( 'SERVER_SOFTWARE' );
|
||||
$params ['php'] = phpversion ();
|
||||
$params ['pmVersion'] = PM_VERSION;
|
||||
$params ['pmVersion'] = System::getVersion();
|
||||
if(class_exists('pmLicenseManager')){
|
||||
$params ['pmProduct'] = 'PMEE';
|
||||
}else{
|
||||
|
||||
@@ -35,13 +35,7 @@ G::LoadSystem('i18n_po');
|
||||
//$timer = new Benchmark_Timer();
|
||||
//$timer->start();
|
||||
|
||||
if (!defined('PM_VERSION')) {
|
||||
if (file_exists ( PATH_METHODS . 'login/version-pmos.php')) {
|
||||
include (PATH_METHODS . 'login/version-pmos.php');
|
||||
} else {
|
||||
define('PM_VERSION', 'Development Version');
|
||||
}
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
//creating the .po file
|
||||
if( ! isset($_GET['LOCALE']) )
|
||||
@@ -79,7 +73,7 @@ if( ! isset($langRecord['LAN_NAME']) )
|
||||
$sLanguage = $langRecord['LAN_NAME'];
|
||||
|
||||
//setting headers
|
||||
$poFile->addHeader('Project-Id-Version' , 'ProcessMaker ' . PM_VERSION);
|
||||
$poFile->addHeader('Project-Id-Version' , 'ProcessMaker ' . System::getVersion());
|
||||
$poFile->addHeader('POT-Creation-Date' , '');
|
||||
$poFile->addHeader('PO-Revision-Date' , date('Y-m-d H:i:s'));
|
||||
$poFile->addHeader('Last-Translator' , '');
|
||||
|
||||
@@ -89,11 +89,9 @@ try {
|
||||
$oClass->iPMVersion = 0;
|
||||
}
|
||||
if ($oClass->iPMVersion > 0) {
|
||||
if (!defined('PM_VERSION')) {
|
||||
define('PM_VERSION', 0);
|
||||
}
|
||||
if (PM_VERSION > 0) {
|
||||
if ($oClass->iPMVersion > PM_VERSION) {
|
||||
G::LoadClass("system");
|
||||
if (System::getVersion() > 0) {
|
||||
if ($oClass->iPMVersion > System::getVersion()) {
|
||||
//throw new Exception('This plugin needs version ' . $oClass->iPMVersion . ' or higher of ProcessMaker');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,14 +117,7 @@ switch ($RBAC->userCanAccess('PM_SETUP'))
|
||||
break;
|
||||
}
|
||||
|
||||
//get the current process
|
||||
if (file_exists(PATH_METHODS . 'login/version-pmos.php'))
|
||||
{
|
||||
include(PATH_METHODS . 'login/version-pmos.php');
|
||||
}
|
||||
else {
|
||||
define('PM_VERSION', '1.2.2740');
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
$id = $_GET['id'];
|
||||
|
||||
@@ -156,7 +149,7 @@ switch ($RBAC->userCanAccess('PM_SETUP'))
|
||||
$fields['className'] = $id;
|
||||
$fields['version'] = $oConf->version;
|
||||
$fields['description'] = $oConf->description;
|
||||
$fields['PMversion'] = PM_VERSION;
|
||||
$fields['PMversion'] = System::getVersion();
|
||||
savePluginFile ( 'skinPluginMainClass' , $pathHome . $id . '.php', $fields );
|
||||
|
||||
savePluginFile ( 'skinPluginClass' , $pathBase . 'class.' . $id . '.php', $fields );
|
||||
|
||||
@@ -54,14 +54,7 @@ switch ($RBAC->userCanAccess('PM_SETUP'))
|
||||
break;
|
||||
}
|
||||
|
||||
//get the current process
|
||||
if (file_exists(PATH_METHODS . 'login/version-pmos.php'))
|
||||
{
|
||||
include('version-pmos.php');
|
||||
}
|
||||
else {
|
||||
define('PM_VERSION', '1.8.320');
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
$id = strip_tags ( str_replace ( ' ', '_', trim ($_POST['form']['NAME']) ) );
|
||||
$desc = $_POST['form']['DESCRIPTION'];
|
||||
|
||||
@@ -63,16 +63,9 @@ if( $access != 1 ){
|
||||
$G_ID_MENU_SELECTED = 'SETUP';
|
||||
$G_ID_SUB_MENU_SELECTED = 'UPGRADE';
|
||||
|
||||
if ( !defined ( 'PM_VERSION' ) ) {
|
||||
if (file_exists(PATH_METHODS . 'login/version-pmos.php')) {
|
||||
include(PATH_METHODS . 'login/version-pmos.php');
|
||||
}
|
||||
else {
|
||||
define('PM_VERSION', 'Development Version');
|
||||
}
|
||||
}
|
||||
G::LoadClass("system");
|
||||
|
||||
$Fields['PM_VERSION'] = PM_VERSION;
|
||||
$Fields['PM_VERSION'] = System::getVersion();
|
||||
$Fields['MAX_FILE_SIZE'] = $uploadMaxSize . " (" . $UPLOAD_MAX_SIZE . ") ";
|
||||
|
||||
$G_PUBLISH = new Publisher;
|
||||
|
||||
Reference in New Issue
Block a user