Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Freddy Daniel Rojas Valda
2014-10-03 12:31:13 -04:00
36 changed files with 342 additions and 370 deletions

View File

@@ -378,7 +378,7 @@ function evaluateFunction ($aGrid, $sExpresion)
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#WSLogin.28.29
*
* @param string(32) | $user | Username of the user | The username of the user who will login to ProcessMaker. All subsequent actions will be limited to the permissions of that user.
* @param string(32) | $pass | Password encrypted | The user's password encrypted as an MD5 hash with 'md5:' prepended.
* @param string(32) | $pass | Password encrypted | The user's password encrypted as an MD5 or SHA256 hash with '{hashType}:' prepended.
* @param string(32) | $endpoint="" | URI of the WSDL | The URI (address) of the WSDL definition of the ProcessMaker web services.
* @return string | $unique ID | Unique Id |The unique ID for the initiated session.
*
@@ -2849,7 +2849,7 @@ function PMFAddAttachmentToArray($arrayData, $index, $value, $suffix = " Copy({i
*
* @name PMFRemoveMask
* @label PMF Remove Mask
*
*
* @param string | $field | Value the field
* @param string | $separator | Separator of thousands (, or .)
* @param string | $currency | symbol of currency

View File

@@ -1189,7 +1189,7 @@ class wsBase
$arrayData = array ();
$arrayData["USR_USERNAME"] = $userName;
$arrayData["USR_PASSWORD"] = Bootstrap::hasPassword( $password );
$arrayData["USR_PASSWORD"] = Bootstrap::hashPassword( $password );
$arrayData["USR_FIRSTNAME"] = $firstName;
$arrayData["USR_LASTNAME"] = $lastName;
$arrayData["USR_EMAIL"] = $email;
@@ -1380,7 +1380,7 @@ class wsBase
}
if (! empty( $password )) {
$arrayData["USR_PASSWORD"] = Bootstrap::hasPassword( $password );
$arrayData["USR_PASSWORD"] = Bootstrap::hashPassword( $password );
}
//Update user

View File

@@ -61,7 +61,7 @@ class workspaceTools
* @param bool $first true if this is the first workspace to be upgrade
*/
public function upgrade($first = false, $buildCacheView = false, $workSpace = SYS_SYS, $onedb = false, $lang = 'en')
{
{
$start = microtime(true);
CLI::logging("> Verify enterprise old...\n");
$this->verifyEnterprise($workSpace);
@@ -111,63 +111,63 @@ class workspaceTools
$final = $stop - $start;
CLI::logging("<*> Backup log files Process took $final seconds.\n");
CLI::logging("> Updating Files Manager...\n\n");
CLI::logging("> Updating Files Manager...\n\n");
$this->upgradeFilesManager($workSpace);
}
/**
* Function upgradeFilesManager
* access public
*/
public function upgradeFilesManager($workSpace) {
/**
* Function upgradeFilesManager
* access public
*/
public function upgradeFilesManager($workSpace) {
$this->initPropel(true);
$con = Propel::getConnection("root");
$stmt = $con->createStatement();
$sDirectory = glob(PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/*");
$sDirectoryPublic = glob(PATH_DATA . "sites/" . $workSpace . "/" . "public/*");
$files = array();
foreach($sDirectory as $mailTemplate) {
if (is_dir($mailTemplate)) {
$inner_files = listFiles($mailTemplate);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($mailTemplate)) {
array_push($files, $mailTemplate);
}
}
foreach($sDirectoryPublic as $publicFile) {
if (is_dir($publicFile)) {
$inner_files = listFiles($publicFile);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($publicFile)) {
array_push($files, $publicFile);
}
}
$sDir = PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/";
$sDirPublic = PATH_DATA . "sites/" . $workSpace . "/" . "public/";
foreach ($files as $aFile) {
if (strpos($aFile, $sDir) !== false){
$processUid = current(explode("/", str_replace($sDir,'',$aFile)));
} else {
$processUid = current(explode("/", str_replace($sDirPublic,'',$aFile)));
}
$sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'";
$appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
$fileUid = '';
foreach ($appRows as $row) {
$fileUid = $row["PRF_PATH"];
}
if ($fileUid !== $aFile) {
$sPkProcessFiles = G::generateUniqueID();
$sDate = date('Y-m-d H:i:s');
$sql = "INSERT INTO PROCESS_FILES (PRF_UID, PRO_UID, USR_UID, PRF_UPDATE_USR_UID,
PRF_PATH, PRF_TYPE, PRF_EDITABLE, PRF_CREATE_DATE, PRF_UPDATE_DATE)
VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '',
'".$aFile."', 'file', 'true', '".$sDate."', NULL)";
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
}
}
$con = Propel::getConnection("root");
$stmt = $con->createStatement();
$sDirectory = glob(PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/*");
$sDirectoryPublic = glob(PATH_DATA . "sites/" . $workSpace . "/" . "public/*");
$files = array();
foreach($sDirectory as $mailTemplate) {
if (is_dir($mailTemplate)) {
$inner_files = listFiles($mailTemplate);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($mailTemplate)) {
array_push($files, $mailTemplate);
}
}
foreach($sDirectoryPublic as $publicFile) {
if (is_dir($publicFile)) {
$inner_files = listFiles($publicFile);
if (is_array($inner_files)) $files = array_merge($files, $inner_files);
}
if (is_file($publicFile)) {
array_push($files, $publicFile);
}
}
$sDir = PATH_DATA . "sites/" . $workSpace . "/" . "mailTemplates/";
$sDirPublic = PATH_DATA . "sites/" . $workSpace . "/" . "public/";
foreach ($files as $aFile) {
if (strpos($aFile, $sDir) !== false){
$processUid = current(explode("/", str_replace($sDir,'',$aFile)));
} else {
$processUid = current(explode("/", str_replace($sDirPublic,'',$aFile)));
}
$sql = "SELECT PROCESS_FILES.PRF_PATH FROM PROCESS_FILES WHERE PROCESS_FILES.PRF_PATH='" . $aFile ."'";
$appRows = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
$fileUid = '';
foreach ($appRows as $row) {
$fileUid = $row["PRF_PATH"];
}
if ($fileUid !== $aFile) {
$sPkProcessFiles = G::generateUniqueID();
$sDate = date('Y-m-d H:i:s');
$sql = "INSERT INTO PROCESS_FILES (PRF_UID, PRO_UID, USR_UID, PRF_UPDATE_USR_UID,
PRF_PATH, PRF_TYPE, PRF_EDITABLE, PRF_CREATE_DATE, PRF_UPDATE_DATE)
VALUES ('".$sPkProcessFiles."', '".$processUid."', '00000000000000000000000000000001', '',
'".$aFile."', 'file', 'true', '".$sDate."', NULL)";
$stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
}
}
}
/**
@@ -223,20 +223,22 @@ class workspaceTools
}
private function resetDBInfoCallback($matches)
{
{
/* This function changes the values of defines while keeping their formatting
* intact.
* $matches will contain several groups:
* ((define('(<key>)2', ')1 (<value>)3 (');)4 )0
*/
$dbPrefix = array('DB_NAME' => 'wf_', 'DB_USER' => 'wf_', 'DB_RBAC_NAME' => 'wf_', 'DB_RBAC_USER' => 'wf_', 'DB_REPORT_NAME' => 'wf_', 'DB_REPORT_USER' => 'wf_');
$key = isset($matches['key']) ? $matches['key'] : $matches[2];
$value = isset($matches['value']) ? $matches['value'] : $matches[3];
if (!$this->onedb) {
if (array_search($key, array('DB_PASS', 'DB_RBAC_PASS', 'DB_REPORT_PASS'))) {
$value = $this->dbInfo['DB_PASS'];
}
if($this->onedb){
$dbPrefix = array('DB_NAME' => 'wf_', 'DB_USER' => 'wf_', 'DB_RBAC_NAME' => 'wf_', 'DB_RBAC_USER' => 'wf_', 'DB_REPORT_NAME' => 'wf_', 'DB_REPORT_USER' => 'wf_');
if (array_search($key, array('DB_PASS', 'DB_RBAC_PASS', 'DB_REPORT_PASS'))) {
$value = $this->dbInfo['DB_PASS'];
}
} else{
$dbPrefix = array('DB_NAME' => 'wf_', 'DB_USER' => 'wf_', 'DB_RBAC_NAME' => 'rb_', 'DB_RBAC_USER' => 'rb_', 'DB_REPORT_NAME' => 'rp_', 'DB_REPORT_USER' => 'rp_');
}
if (array_search($key, array('DB_HOST', 'DB_RBAC_HOST', 'DB_REPORT_HOST')) !== false) {
@@ -284,7 +286,7 @@ class workspaceTools
throw new Exception("Could not find db.php in the workspace");
}
$sDbFile = file_get_contents($this->dbPath);
if ($sDbFile === false) {
throw new Exception("Could not read database information from db.php");
} else {
@@ -294,7 +296,7 @@ class workspaceTools
$this->onedb = true;
}
}
/* Match all defines in the config file. Check updateDBCallback to know what
* keys are changed and what groups are matched.
* This regular expression will match any "define ('<key>', '<value>');"
@@ -538,7 +540,7 @@ class workspaceTools
* @param string $lang not currently used
*/
public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en")
{
{
$this->initPropel(true);
//require_once ('classes/model/AppCacheView.php');
@@ -552,19 +554,19 @@ class workspaceTools
//setup the appcacheview object, and the path for the sql files
$appCache = new AppCacheView();
$appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
$userGrants = $appCache->checkGrantsForUser(false);
$currentUser = $userGrants['user'];
$currentUserIsSuper = $userGrants['super'];
//if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user.
if (!$currentUserIsSuper) {
$appCache->checkGrantsForUser(true);
$appCache->setSuperForUser($currentUser);
$currentUserIsSuper = true;
}
CLI::logging("-> Creating tables \n");
//now check if table APPCACHEVIEW exists, and it have correct number of fields, etc.
$res = $appCache->checkAppCacheView();
@@ -572,7 +574,7 @@ class workspaceTools
CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table \n");
//Update APP_DELEGATION.DEL_LAST_INDEX data
$res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly);
CLI::logging("-> Verifying roles permissions in RBAC \n");
//Update table RBAC permissions
Bootstrap::LoadSystem( 'rbac' );
@@ -756,7 +758,7 @@ class workspaceTools
* @return array bool upgradeSchema for more information
*/
public function upgradeDatabase ($onedb = false, $checkOnly = false)
{
{
G::LoadClass("patch");
$this->initPropel( true );
p11835::$dbAdapter = $this->dbAdapter;
@@ -798,7 +800,7 @@ class workspaceTools
public function upgradeSchema($schema, $checkOnly = false, $rbac = false, $onedb = false)
{
$dbInfo = $this->getDBInfo();
if ($dbInfo['DB_NAME'] == $dbInfo['DB_RBAC_NAME']) {
$onedb = true;
} else {
@@ -1030,7 +1032,7 @@ class workspaceTools
}
$wfDsn = $fields['DB_ADAPTER'] . '://' . $fields['DB_USER'] . ':' . $fields['DB_PASS'] . '@' . $fields['DB_HOST'] . '/' . $fields['DB_NAME'];
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'],
//'Available Databases' => $fields['AVAILABLE_DB'],
'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE']
@@ -1260,6 +1262,7 @@ class workspaceTools
$lines = explode("\n", $script);
$previous = null;
$insert = false;
foreach ($lines as $j => $line) {
// Remove comments from the script
$line = trim($line);
@@ -1284,6 +1287,7 @@ class workspaceTools
$line = substr($line, 0, strrpos($line, ";"));
if (strrpos($line, "INSERT INTO") !== false) {
$insert = true;
if ($insert) {
$result = mysql_query("START TRANSACTION");
$insert = false;
@@ -1353,7 +1357,7 @@ class workspaceTools
$chmod = @chmod($filename, $perms);
if ($chgrp === false || $chmod === false || $chown === false) {
if (strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN') {
exec( 'icacls ' . $dirNameWin . '/grant Administrador:(D,WDAC) /T', $res );
exec( 'icacls ' . $filename . '/grant Administrador:(D,WDAC) /T', $res );
} else {
CLI::logging(CLI::error("Failed to set permissions for $filename") . "\n");
}
@@ -1445,9 +1449,9 @@ class workspaceTools
CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n");
}
$workspace = new workspaceTools($workspaceName);
if ($workspace->workspaceExists()) {
if ($overwrite) {
CLI::logging(CLI::warning("> Workspace $workspaceName already exist, overwriting!") . "\n");
} else {
@@ -1487,7 +1491,7 @@ class workspaceTools
if (!$link) {
throw new Exception('Could not connect to system database: ' . mysql_error());
}
$newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
foreach ($metadata->databases as $db) {
@@ -1502,7 +1506,7 @@ class workspaceTools
$versionOld = ( isset($version[0])) ? $version[0] : '';
CLI::logging(CLI::info("$versionOld < $versionPresent") . "\n");
if ( $versionOld < $versionPresent) {
if ( $versionOld < $versionPresent || strpos($versionPresent, "Branch")) {
$start = microtime(true);
CLI::logging("> Updating database...\n");
$workspace->upgradeDatabase();
@@ -1594,7 +1598,7 @@ class workspaceTools
}
public function checkMafeRequirements ($workspace,$lang) {
$this->initPropel(true);
$this->initPropel(true);
$pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client');
if (empty($pmRestClient)) {
if (is_file(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info')) {
@@ -1649,7 +1653,7 @@ class workspaceTools
$pathDirectoryEnterprise = PATH_CORE . 'plugins' . PATH_SEP . 'enterprise';
$pathFileEnterprise = PATH_CORE . 'plugins' . PATH_SEP . 'enterprise.php';
if (!file_exists($pathDirectoryEnterprise) && !file_exists(PATH_PLUGIN . 'enterprise.php')) {
if (!file_exists($pathDirectoryEnterprise) && !file_exists($pathFileEnterprise)) {
CLI::logging(" Without changes... \n");
return true;
}

View File

@@ -338,7 +338,7 @@ class CaseScheduler extends BaseCaseScheduler
$processId = $aRow["PRO_UID"];
$taskId = $aRow["TAS_UID"];
$client = new SoapClient( $defaultEndpoint );
$params = array ('userid' => $user,'password' => 'md5:' . $pass);
$params = array ('userid' => $user,'password' => Bootstrap::getPasswordHashType() . ':' . $pass);
$result = $client->__SoapCall( 'login', array ($params) );
eprint( " - Logging as user $user............." );
if ($result->status_code == 0) {
@@ -500,7 +500,7 @@ class CaseScheduler extends BaseCaseScheduler
$processId = $aRow["PRO_UID"];
$taskId = $aRow["TAS_UID"];
$client = new SoapClient( $defaultEndpoint );
$params = array ('userid' => $user,'password' => 'md5:' . $pass);
$params = array ('userid' => $user,'password' => Bootstrap::getPasswordHashType() . ':' . $pass);
$result = $client->__SoapCall( 'login', array ($params) );
eprint( " - Logging as user $user............." );
if ($result->status_code == 0) {

View File

@@ -601,7 +601,7 @@ class Process extends BaseProcess
}
}
public function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false)
public function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false, $userLogged = "")
{
require_once PATH_RBAC . "model/RbacUsers.php";
require_once "classes/model/ProcessCategory.php";
@@ -642,10 +642,13 @@ class Process extends BaseProcess
$oCriteria->addJoin( ProcessPeer::PRO_CREATE_USER, UsersPeer::USR_UID, Criteria::LEFT_JOIN );
$oCriteria->addJoin( ProcessPeer::PRO_CATEGORY, ProcessCategoryPeer::CATEGORY_UID, Criteria::LEFT_JOIN );
$oCriteria->add(
if ($userLogged != "") {
$oCriteria->add(
$oCriteria->getNewCriterion(ProcessPeer::PRO_TYPE_PROCESS, "PUBLIC", Criteria::EQUAL)->addOr(
$oCriteria->getNewCriterion(ProcessPeer::PRO_CREATE_USER, $_SESSION["USER_LOGGED"], Criteria::EQUAL))
);
$oCriteria->getNewCriterion(ProcessPeer::PRO_CREATE_USER, $userLogged, Criteria::EQUAL))
);
}
$this->tmpCriteria = clone $oCriteria;