Merge remote branch 'pm/master'

This commit is contained in:
Ronald Quenta
2015-07-06 17:15:22 -04:00
11 changed files with 155 additions and 89 deletions

View File

@@ -505,47 +505,52 @@ function run_workspace_backup($args, $opts) {
}
function run_workspace_restore($args, $opts) {
$filename = $args[0];
if (sizeof($args) > 0) {
G::verifyPath(PATH_DATA . 'upgrade', true);
$filename = $args[0];
if (strpos($filename, "/") === false && strpos($filename, '\\') === false) {
$filename = PATH_DATA . "backups/$filename";
if (!file_exists($filename) && substr_compare($filename, ".tar", -4, 4, true) != 0)
$filename .= ".tar";
}
$info = array_key_exists("info", $opts);
$lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';
$port = array_key_exists("port", $opts) ? $opts['port'] : '';
if ($info) {
workspaceTools::getBackupInfo($filename);
G::verifyPath(PATH_DATA . 'upgrade', true);
if (strpos($filename, "/") === false && strpos($filename, '\\') === false) {
$filename = PATH_DATA . "backups/$filename";
if (!file_exists($filename) && substr_compare($filename, ".tar", -4, 4, true) != 0)
$filename .= ".tar";
}
$info = array_key_exists("info", $opts);
$lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en';
$port = array_key_exists("port", $opts) ? $opts['port'] : '';
if ($info) {
workspaceTools::getBackupInfo($filename);
} else {
CLI::logging("Restoring from $filename\n");
$workspace = array_key_exists("workspace", $opts) ? $opts['workspace'] : NULL;
$overwrite = array_key_exists("overwrite", $opts);
$multiple = array_key_exists("multiple", $opts);
$dstWorkspace = isset($args[1]) ? $args[1] : null;
if(!empty($multiple)){
if(!Bootstrap::isLinuxOs()){
CLI::error("This is not a Linux enviroment, cannot use this multiple [-m] feature.\n");
return;
}
multipleFilesBackup::letsRestore ($filename,$workspace,$dstWorkspace,$overwrite);
}
else{
$anotherExtention = ".*"; //if there are files with and extra extention: e.g. <file>.tar.number
$multiplefiles = glob($filename . $anotherExtention);// example: //shared/workflow_data/backups/myWorkspace.tar.*
if(count($multiplefiles) > 0)
{
CLI::error("Processmaker found these files: .\n");
foreach($multiplefiles as $index => $value){
CLI::logging($value . "\n");
}
CLI::error("Please, you should use -m parameter to restore them.\n");
return;
}
workspaceTools::restore($filename, $workspace, $dstWorkspace, $overwrite, $lang, $port );
}
}
} else {
CLI::logging("Restoring from $filename\n");
$workspace = array_key_exists("workspace", $opts) ? $opts['workspace'] : NULL;
$overwrite = array_key_exists("overwrite", $opts);
$multiple = array_key_exists("multiple", $opts);
$dstWorkspace = isset($args[1]) ? $args[1] : null;
if(!empty($multiple)){
if(!Bootstrap::isLinuxOs()){
CLI::error("This is not a Linux enviroment, cannot use this multiple [-m] feature.\n");
return;
}
multipleFilesBackup::letsRestore ($filename,$workspace,$dstWorkspace,$overwrite);
}
else{
$anotherExtention = ".*"; //if there are files with and extra extention: e.g. <file>.tar.number
$multiplefiles = glob($filename . $anotherExtention);// example: //shared/workflow_data/backups/myWorkspace.tar.*
if(count($multiplefiles) > 0)
{
CLI::error("Processmaker found these files: .\n");
foreach($multiplefiles as $index => $value){
CLI::logging($value . "\n");
}
CLI::error("Please, you should use -m parameter to restore them.\n");
return;
}
workspaceTools::restore($filename, $workspace, $dstWorkspace, $overwrite, $lang, $port );
}
throw new Exception("No workspace specified for restore");
}
}

View File

@@ -594,7 +594,11 @@ class Cases
$aFields['CURRENT_USER'][]= $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname();
$aFields['TAS_UID'].= $value['TAS_UID'].'-';
}
$aFields['CURRENT_USER'] = implode(" - ", array_values($aFields['CURRENT_USER']));
$aFields['CURRENT_USER'] = implode(" - ", array_values($aFields['CURRENT_USER']));
$tasksArray = array_filter(explode("-",$aFields['TAS_UID']));
if(count($tasksArray) == 1) {
$aFields['TAS_UID'] = $tasksArray[0];
}
} else {
$oCurUser->load($aAppDel['USR_UID']);
$aFields['CURRENT_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname();

View File

@@ -14,14 +14,14 @@ class multipleFilesBackup
private $dir_to_compress = "";
private $filename = "backUpProcessMaker.tar";
private $fileSize = "1000";
// 1 GB by default.
// 1 GB by default.
private $sizeDescriptor = "m";
//megabytes
//megabytes
private $tempDirectories = array ();
/* Constructor
* @filename contains the path and filename of the comppress file(s).
* @size got the Max size of the compressed files, by default if the $size less to zero will mantains 1000 Mb as Max size.
/* Constructor
* @filename contains the path and filename of the comppress file(s).
* @size got the Max size of the compressed files, by default if the $size less to zero will mantains 1000 Mb as Max size.
*/
public function multipleFilesBackup ($filename, $size)
{
@@ -33,24 +33,24 @@ class multipleFilesBackup
}
}
/* Gets workspace information enough to make its backup.
/* Gets workspace information enough to make its backup.
* @workspace contains the workspace to be add to the commpression process.
*/
public function addToBackup ($workspace)
{
//verifing if workspace exists.
//verifing if workspace exists.
if (! $workspace->workspaceExists()) {
echo "Workspace {$workspace->name} not found\n";
return false;
}
//create destination path
//create destination path
if (! file_exists( PATH_DATA . "upgrade/" )) {
mkdir( PATH_DATA . "upgrade/" );
}
$tempDirectory = PATH_DATA . "upgrade/" . basename( tempnam( __FILE__, '' ) );
mkdir( $tempDirectory );
$metadata = $workspace->getMetadata();
CLI::logging( "Temporing up database...\n" );
CLI::logging( "Creating temporary files on database...\n" );
$metadata["databases"] = $workspace->exportDatabase( $tempDirectory );
$metadata["directories"] = array ("{$workspace->name}.files");
$metadata["version"] = 1;
@@ -65,8 +65,8 @@ class multipleFilesBackup
$this->tempDirectories[] = $tempDirectory;
}
/* Add a directory containing Db files or info files to be commpressed
* @directory the name and path of the directory to be add to the commpression process.
/* Add a directory containing Db files or info files to be commpressed
* @directory the name and path of the directory to be add to the commpression process.
*/
private function addDirToBackup ($directory)
{
@@ -75,37 +75,37 @@ class multipleFilesBackup
}
}
// Commpress the DB and files into a single or several files with numerical series extentions
// Commpress the DB and files into a single or several files with numerical series extentions
public function letsBackup ()
{
// creating command
// creating command
$CommpressCommand = "tar czv ";
$CommpressCommand .= $this->dir_to_compress;
$CommpressCommand .= "| split -b ";
$CommpressCommand .= $this->fileSize;
$CommpressCommand .= "m -d - ";
$CommpressCommand .= $this->filename . ".";
//executing command to create the files
//executing command to create the files
echo exec( $CommpressCommand );
//Remove leftovers dirs.
//Remove leftovers dirs.
foreach ($this->tempDirectories as $tempDirectory) {
CLI::logging( "Deleting: " . $tempDirectory . "\n" );
G::rm_dir( $tempDirectory );
}
}
/* Restore from file(s) commpressed by letsBackup function, into a temporary directory
* @ filename got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated.
* @ srcWorkspace contains the workspace to be restored.
* @ dstWorkspace contains the workspace to be overwriting.
* @ overwrite got the option true if the workspace will be overwrite.
/* Restore from file(s) commpressed by letsBackup function, into a temporary directory
* @ filename got the name and path of the compressed file(s), if there are many files with file extention as a numerical series, the extention should be discriminated.
* @ srcWorkspace contains the workspace to be restored.
* @ dstWorkspace contains the workspace to be overwriting.
* @ overwrite got the option true if the workspace will be overwrite.
*/
static public function letsRestore ($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true)
{
// Needed info:
// TEMPDIR /shared/workflow_data/upgrade/
// BACKUPS /shared/workflow_data/backups/
// Creating command cat myfiles_split.tgz_* | tar xz
// Needed info:
// TEMPDIR /shared/workflow_data/upgrade/
// BACKUPS /shared/workflow_data/backups/
// Creating command cat myfiles_split.tgz_* | tar xz
$DecommpressCommand = "cat " . $filename . ".* ";
$DecommpressCommand .= " | tar xzv";
@@ -116,13 +116,13 @@ class multipleFilesBackup
} else {
throw new Exception( "Could not create directory:" . $parentDirectory );
}
//Extract all backup files, including database scripts and workspace files
//Extract all backup files, including database scripts and workspace files
CLI::logging( "Restoring into " . $tempDirectory . "\n" );
chdir( $tempDirectory );
echo exec( $DecommpressCommand );
CLI::logging( "\nUncompressed into: " . $tempDirectory . "\n" );
//Search for metafiles in the new standard (the old standard would contain meta files.
//Search for metafiles in the new standard (the old standard would contain meta files.
$metaFiles = glob( $tempDirectory . "/*.meta" );
if (empty( $metaFiles )) {
$metaFiles = glob( $tempDirectory . "/*.txt" );

View File

@@ -150,20 +150,65 @@ TimeSeriesPresenter.prototype.historicData = function (indicator, periodicity, i
var graphData = [];
$.each(data, function(index, originalObject) {
var newObject = {datalabel: that.periodColumnName(periodicity, originalObject) + '/' + originalObject['YEAR'],
value: originalObject.VALUE
value: originalObject.VALUE,
period: that.periodColumnName(periodicity, originalObject),
year: originalObject.YEAR
}
graphData.push(newObject);
});
for (var y = initYear; y <= endYear; y++) {
var periodRunFrom = (y == initYear) ? initPeriod : 1;
var periodRunTo = (y == endYear) ? endPeriod : that.periodsInAYear(periodicity);
for (var p = periodRunFrom; p <= periodRunTo; p++) {
var results = $.grep(graphData,
function(obj) {
return (obj.year == y && obj.period == p);
});
if (results.length == 0) {
var newObject = { datalabel: p + '/' + y,
value: 0,
period: p,
year: y
};
graphData.push(newObject);
}
}
}
graphData = graphData.sort(function (a, b) {
return (a.year * 10 + a.period * 1) - (b.year * 10 + b.period * 1);
});
requestFinished.resolve(graphData);
});
return requestFinished.promise();
}
TimeSeriesPresenter.prototype.periodsInAYear = function (periodicity) {
var retval = "";
switch (periodicity * 1) {
case this.helper.ReportingPeriodicityEnum.MONTH:
retval = 12
break;
case this.helper.ReportingPeriodicityEnum.QUARTER:
retval = 4;
break;
case this.helper.ReportingPeriodicityEnum.SEMESTER:
retval = 2;
break;
case this.helper.ReportingPeriodicityEnum.YEAR:
retval = 1;
break;
}
if (retval == "") {
throw new Error("The periodicity " + periodicity + " is not supported.");
}
return retval;
}
TimeSeriesPresenter.prototype.periodColumnName = function (periodicity, object) {
var retval = "";
switch (periodicity*1) {
switch (periodicity * 1) {
case this.helper.ReportingPeriodicityEnum.MONTH:
retval = object.MONTH;
break;
@@ -251,16 +296,16 @@ TimeSeriesPresenter.prototype.periodEndDate = function (periodicity, period, yea
var retval = null;
switch (periodicity * 1) {
case this.helper.ReportingPeriodicityEnum.MONTH:
retval = new Date(year, period, 0);
retval = new Date(year, period, 0, 23,59,59);
break;
case this.helper.ReportingPeriodicityEnum.QUARTER:
retval = new Date(year, 3 * (period), 0);
retval = new Date(year, 3 * (period), 0, 23, 59, 59);
break;
case this.helper.ReportingPeriodicityEnum.SEMESTER:
retval = new Date(year, 6 * (period), 0);
retval = new Date(year, 6 * (period), 0, 23, 59, 59);
break;
case this.helper.ReportingPeriodicityEnum.YEAR:
retval = new Date(year, 11, 31);
retval = new Date(year, 11, 31, 23, 59, 59);
break;
}
if (retval == null) {

View File

@@ -18,7 +18,6 @@ $(document).ready(function() {
$('#comparisonBreadcrumb').find('li').remove()
$('#comparisonBreadcrumb')
.append ('<li><a class="bread-back-selector2" href="#"><i class="fa fa-chevron-left fa-fw"></i>Return to Indicator View</a>');
tsPresenter.historicData(
$('#indicatorList').val(),
$('#periodicityList').val(),
@@ -49,8 +48,8 @@ $(document).ready(function() {
showErrorBars: false
}
};
$('#indicatorsView').hide();
$('#scrollImg').hide();
$('#compareDiv').show();
var graph1 = new LineChart(data, graphParams1, null, null);
graph1.drawChart();
@@ -59,6 +58,7 @@ $(document).ready(function() {
$('body').on('click','.bread-back-selector2', function() {
$('#indicatorsView').show();
$('#scrollImg').show();
$('#compareDiv').hide();
});
});

View File

@@ -333,7 +333,7 @@ ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) {
};
var newObject3 = {
datalabel : originalObject.taskTitle,
value : originalObject.percentageTotalOnTime
value : 100 - (originalObject.percentageTotalOverdue + originalObject.percentageTotalAtRisk)
};
if (newObject1.value > 0) {

View File

@@ -350,16 +350,6 @@ $(document).ready(function() {
model.setPositionIndicator(dashboard);
});
/*-------------------------------clicks----------------------------*/
/*$('body').on('click','.btn-compare', function() {
presenter.getDashboardIndicators(window.currentDashboardId, defaultInitDate(), defaultEndDate())
.done(function(indicatorsVM) {
fillIndicatorWidgets(indicatorsVM);
loadIndicator(getFavoriteIndicator().id, defaultInitDate(), defaultEndDate());
});
});*/
$('#dashboardsList').on('click','.das-title-selector', function() {
var dashboardId = $(this).parent().data('dashboard-id');
window.currentDashboardId = dashboardId;
@@ -491,6 +481,9 @@ var initialDraw = function () {
}
var loadIndicator = function (indicatorId, initDate, endDate) {
$('#indicatorsView').show();
$('#scrollImg').show();
$('#compareDiv').hide();
if (indicatorId == null || indicatorId === undefined) {return;}
var builder = new WidgetBuilder();
window.currentIndicator = builder.getIndicatorLoadedById(indicatorId);
@@ -569,6 +562,7 @@ var fillDashboardsList = function (presenterData) {
window.loadedDashboards = presenterData;
for (key in presenterData) {
var dashboard = presenterData[key];
dashboard.title = dashboard.title.replace('&#39;', "'");
$('#dashboardsList').append(template(dashboard));
if (dashboard.isFavorite == 1) {
window.currentDashboardId = dashboard.id;

View File

@@ -169,6 +169,17 @@ try {
/* Redirect to next step */
unset( $_SESSION['bNoShowSteps'] );
/* Execute Before Triggers for first Task*/
$oStep = new Step;
$oStep = $oStep->loadByProcessTaskPosition($_SESSION['PROCESS'], $_SESSION['TASK'], 1);
if($oStep) {
$triggerFields["APP_DATA"] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $oStep->getStepTypeObj(), $oStep->getStepUidObj(), 'BEFORE', $aFields['APP_DATA'] );
$oCase->updateCase( $_SESSION['APPLICATION'], $triggerFields );
$_SESSION['beforeTriggersExecuted'] = true;
}
/*end Execute Before Triggers for first Task*/
$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] );
$sPage = $aNextStep['PAGE'];
G::header( 'location: ' . $sPage );

View File

@@ -159,7 +159,11 @@ if ($flagExecuteBeforeTriggers) {
if (! isset( $_SESSION['_NO_EXECUTE_TRIGGERS_'] )) {
//Execute before triggers - Start
$Fields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $_GET['TYPE'], $_GET['UID'], 'BEFORE', $Fields['APP_DATA'] );
if (!isset($_SESSION['beforeTriggersExecuted'])) {
$Fields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], $_GET['TYPE'], $_GET['UID'], 'BEFORE', $Fields['APP_DATA'] );
} else {
unset($_SESSION['beforeTriggersExecuted']);
}
//Execute before triggers - End
} else {
unset( $_SESSION['_NO_EXECUTE_TRIGGERS_'] );

View File

@@ -6,8 +6,12 @@ Ext.FlashComponent.EXPRESS_INSTALL_URL = '/images/expressinstall.swf';
// The Quicktips are used for the toolbar and Tree mouseover tooltips!
// Refresh treePanel
if (typeof(parent.timer) != 'undefined') {
parent.timer();
try {
if (typeof(parent.timer) != 'undefined') {
parent.timer();
}
} catch(theError) {
// This try-catch is for Zimbra error
}

View File

@@ -937,8 +937,7 @@ if (! defined( 'EXECUTE_BY_CRON' )) {
Bootstrap::LoadClass( 'sessions' );
$oSessions = new Sessions();
if ($aSession = $oSessions->verifySession( $_GET['sid'] )) {
$pathFile = $filter->validateInput('classes/model/Users.php','path');
require_once $pathFile;
require_once 'classes/model/Users.php';
$oUser = new Users();
$aUser = $oUser->load( $aSession['USR_UID'] );
$_SESSION['USER_LOGGED'] = $aUser['USR_UID'];