Merged in bugfix/PMC-985 (pull request #6988)
PMC-985 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -196,7 +196,7 @@ class FilesLogs extends Files
|
||||
*/
|
||||
private function size($size, $format = null)
|
||||
{
|
||||
$sizes = ['Bytes', 'Kbytes', 'Mbytes', 'Gbytes', 'Tbytes', 'Pbytes', 'Ebytes', 'Zbytes', 'Ybytes'];
|
||||
$sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
if ($format === null) {
|
||||
$format = ' % 01.2f % s';
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ abstract class Importer
|
||||
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW, $generateUidFromJs = null, $objectsToImport = '')
|
||||
{
|
||||
$this->prepare();
|
||||
$keepCreateDate = false;
|
||||
//Verify data
|
||||
switch ($option) {
|
||||
case self::IMPORT_OPTION_CREATE_NEW:
|
||||
@@ -126,6 +127,7 @@ abstract class Importer
|
||||
case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW:
|
||||
break;
|
||||
case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW:
|
||||
$keepCreateDate = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -258,12 +260,15 @@ abstract class Importer
|
||||
$this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0];
|
||||
|
||||
//Import
|
||||
if(!empty($generateUidFromJs)) {
|
||||
if (!empty($generateUidFromJs)) {
|
||||
$generateUid = $generateUidFromJs;
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
//Granular Import
|
||||
try {
|
||||
if ($generateUidFromJs || $keepCreateDate) {
|
||||
unset($this->importData["tables"]["workflow"]["process"]["PRO_CREATE_DATE"]);
|
||||
}
|
||||
if ($objectsToImport !== '') {
|
||||
$granularObj = new \ProcessMaker\BusinessModel\Migrator\GranularImporter();
|
||||
$newObjectArray = $objectsToImport;
|
||||
@@ -651,7 +656,9 @@ abstract class Importer
|
||||
}
|
||||
|
||||
unset($arrayWorkflowTables["process"]["PRO_CREATE_USER"]);
|
||||
unset($arrayWorkflowTables["process"]["PRO_CREATE_DATE"]);
|
||||
if ($generateUid) {
|
||||
unset($arrayWorkflowTables["process"]["PRO_CREATE_DATE"]);
|
||||
}
|
||||
unset($arrayWorkflowTables["process"]["PRO_UPDATE_DATE"]);
|
||||
|
||||
if ($flagDeleteCategory) {
|
||||
|
||||
14
workflow/engine/src/ProcessMaker/Model/BpmnProject.php
Normal file
14
workflow/engine/src/ProcessMaker/Model/BpmnProject.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BpmnProject extends Model
|
||||
{
|
||||
// Set our table name
|
||||
protected $table = 'BPMN_PROJECT';
|
||||
protected $primaryKey = 'PRJ_UID';
|
||||
// We do not have create/update timestamps for this table
|
||||
public $timestamps = false;
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Exception;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
@@ -39,4 +40,26 @@ class User extends Model
|
||||
{
|
||||
return User::find($usrUid)->groups()->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for the specified user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
* @throws Exception
|
||||
*/
|
||||
public function scopeUserFilters($query, array $filters)
|
||||
{
|
||||
if (!empty($filters['USR_ID'])) {
|
||||
$query->where('USR_ID', $filters['USR_ID']);
|
||||
} elseif (!empty($filters['USR_UID'])) {
|
||||
$query->where('USR_UID', $filters['USR_UID']);
|
||||
} else {
|
||||
throw new Exception("There are no filter for loading a user model");
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
50
workflow/engine/src/ProcessMaker/Util/helpers.php
Normal file → Executable file
50
workflow/engine/src/ProcessMaker/Util/helpers.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Str;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
/**
|
||||
* We will send a case note in the actions by email
|
||||
@@ -450,6 +451,29 @@ function replacePrefixes($outDocFilename, $prefix = '@=')
|
||||
return $outDocFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the abbreviation of directives used in the php.ini configuration
|
||||
*
|
||||
* @param string $size
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function changeAbbreviationOfDirectives($size)
|
||||
{
|
||||
$sizeValue = (int)$size;
|
||||
|
||||
switch (substr($size, -1)) {
|
||||
case 'K':
|
||||
return $sizeValue . 'KB';
|
||||
case 'M':
|
||||
return $sizeValue . 'MB';
|
||||
case 'G':
|
||||
return $sizeValue . 'GB';
|
||||
default:
|
||||
return $sizeValue . 'Bytes';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encoding header filename used in Content-Disposition
|
||||
*
|
||||
@@ -493,3 +517,29 @@ if (!function_exists('set_magic_quotes_runtime')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the USER table with the last login date
|
||||
*
|
||||
* @param array $userLog
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*
|
||||
* @see workflow/engine/methods/login/authentication.php
|
||||
*/
|
||||
function updateUserLastLogin($userLog, $keyLastLogin = 'LOG_INIT_DATE')
|
||||
{
|
||||
try {
|
||||
$filters = [];
|
||||
$filters['USR_UID'] = $userLog['USR_UID'];
|
||||
|
||||
$user = User::query();
|
||||
$user->userFilters($filters);
|
||||
$res = $user->update(['USR_LAST_LOGIN' => $userLog[$keyLastLogin]]);
|
||||
|
||||
return $res;
|
||||
} catch (Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user