diff --git a/build.php b/build.php deleted file mode 100644 index 2932cfb64..000000000 --- a/build.php +++ /dev/null @@ -1,37 +0,0 @@ - Appearance & Behavior -> Keymap, search for ProcessMaker, open the context - * menu of the option and select Add Keyboard Shortcut, use whatever shortcut you want, for example Alt+b - * - * If you need help: php build.php --help - * - */ -include_once('class.Build.php'); -use Build\Utils\ProcessMakerPhpBuilderHelper; - -$phpBuilder = new ProcessMakerPhpBuilderHelper(); -$phpBuilder->utils->echoContent("Config finished, start deploying..."); -$phpBuilder->buildAll(); diff --git a/class.Build.php b/class.Build.php deleted file mode 100644 index ae16e6f58..000000000 --- a/class.Build.php +++ /dev/null @@ -1,1490 +0,0 @@ -utils = new PhpBuilderUtils(); - $this->versions = new Versions(); - $this->parameters = $this->getConfig(false); - - return $this->parameters; - } - - /** - * Get Function of class key - * @param string $key - * @return $value - */ - public function __get($key) - { - return $this->$key; - } - - /** - * Set Function of class key - * @param string $key - * @param string $value - * - */ - public function __set($key, $value) - { - $this->$key = $value; - } - - /** - * Get Config and configure Class variables from Arguments - * @param $clean - * @return array - */ - public function getConfig($clean) - { - $config = $this->utils->readArguments(); - // Show Help - if (isset($config['help'])) { - $this->utils->exitCode(4); - } - $baseDir = "./"; - if (defined('PATH_TRUNK')) { - $baseDir = PATH_TRUNK; - $this->utils->silentMode = true; - } - $this->baseDir = empty($config['base_dir']) ? $baseDir : $config['base_dir']; - $this->publicDir = $this->baseDir . "/workflow/public_html"; - $this->buildTempDir = $this->baseDir . "/shared/buildTemp"; - $this->logDir = $this->baseDir . "/shared/log"; - if (defined('PATH_DATA')) { - $this->logDir = PATH_DATA . "log"; - $this->buildTempDir = PATH_DATA . "buildTemp"; - } - $this->utils->__set("logDir", $this->logDir); - $this->utils->refreshDir($this->buildTempDir); - if (!file_exists($this->publicDir)) { - $this->utils->exitCode(5); - } - // Check mode dev or prod, by default prod - $this->mode = (empty($config['mode'])) ? 'prod' : strtolower($config['mode']); - $this->extension = (empty($config['extension'])) ? false : true; - $this->theme = (empty($config['theme'])) ? 'mafe' : $config['theme']; - - switch ($this->mode) { - case 'prod': - $this->utils->echoContent("Running Production mode."); - $this->dir['targetDir'] = $this->publicDir . "/lib"; - break; - case 'dev': - $this->utils->echoContent("Running Developer mode."); - $this->dir['targetDir'] = $config['publicDir'] . "/lib-dev"; - break; - default: - $this->utils->exitCode(6); - break; - } - $this->dir['pmUIFontsDir'] = $this->dir['targetDir'] . "/fonts"; - - // Config Directories - $this->dir['jsTargetDir'] = $this->dir['targetDir'] . "/js"; - $this->dir['cssTargetDir'] = $this->dir['targetDir'] . "/css"; - $this->dir['cssImagesTargetDir'] = $this->dir['cssTargetDir'] . "/images"; - $this->dir['imgTargetDir'] = $this->dir['targetDir'] . "/img"; - - $this->dir['pmUIDir'] = $this->dir['targetDir'] . "/pmUI"; - $this->dir['mafeDir'] = $this->dir['targetDir'] . "/mafe"; - $this->dir['pmdynaformDir'] = $this->dir['targetDir'] . "/pmdynaform"; - - // TODO This clean function must be used only if we need to remove cache from a rake build; - // don't use it for now - if ($clean) { - $this->utils->echoContent("Preparing dirs..."); - $this->utils->prepare_dirs($this->dir); - } - // After delete add this - $this->dir['baseDir'] = $this->baseDir; - $this->dir['publicDir'] = $this->publicDir . "/workflow/public_html"; - $this->dir['extensionDir'] = (empty($config['extensionDir'])) ? $this->baseDir . "workflow/engine/plugins" : $config['extensionDir']; - - return $config; - } - - /** - * Main Build Function - */ - public function buildAll() - { - $this->buildPmUi(); - $this->buildMafe(); - $this->buildPMDynaform(); - - $hashVendors = $this->versions->pmui_hash . "-" . $this->versions->mafe_hash; - // Building minified JS Files - $mafeCompresedFile = $this->dir['targetDir'] . "/js"; - $files = $this->utils->getJsIncludeFiles(); - $this->utils->minifyFiles("mafe-$hashVendors", 'js', $files, $this->dir['baseDir'] . "/", - $mafeCompresedFile . "/", false); - - // Building minified CSS - $mafeCompresedFile = $this->dir['targetDir'] . "/css"; - $files = $this->utils->getCssIncludeFiles(); - $this->utils->minifyFiles("mafe-$hashVendors", 'css', $files, $this->dir['baseDir'] . "/", - $mafeCompresedFile . "/", false); - - //Create build-hash file - $this->utils->echoContent("Create File: buildhash"); - $this->utils->writeToFile("buildhash", $this->dir['targetDir'], $hashVendors, true); - - //Create versions file - $this->utils->echoContent("Create File: versions"); - $versionsContent = json_encode($this->versions); - $this->utils->writeToFile("versions", $this->dir['targetDir'], $versionsContent, true); - $this->cleanUp(); - $this->utils->exitCode(0); - } - - /** - * Builds PMUI - * @return array|Exception - */ - public function buildPmUi() - { - try { - $this->utils->echoHeader("Building PMUI Library"); - // Return Values - $response = array(); - $response['success'] = false; - $response['js'] = ""; - $response['css'] = ""; - $response['customjs'] = false; - $response['customcss'] = false; - $response['hash'] = ""; - $response['version'] = ""; - - $source = $this->dir['baseDir'] . "/vendor/colosa/pmUI"; - $target = $this->dir['targetDir']; - $pmUIDir = $target . "/pmUI"; - $pmUIFontsDir = $target . "/fonts"; - $jsTargetDir = $target . "/js"; - $cssTargetDir = $target . "/css"; - $imgTargetDir = $target . "/img"; - //first hash - $vh = $this->utils->getHash($source); - $this->versions->pmui_hash = $vh['hash']; - - $version = file_get_contents($source . '/VERSION.txt'); - $this->versions->pmui_ver = $version; - $response['version'] = $version; - - $themeDir = $this->dir['baseDir'] . "/vendor/colosa/MichelangeloFE/themes/"; - $themeDir = $themeDir . $this->theme; - - $this->utils->echoContent("1.- Copying lib files into: $pmUIDir"); - $this->utils->copy("$source/build/js/pmui-$version.js", "$pmUIDir/pmui.min.js"); - $this->utils->copy("$themeDir/build/pmui-$this->theme.css", "$pmUIDir/pmui.min.css"); - $this->utils->recCopy("$themeDir/build/images", "$target/css/images"); - $this->utils->recCopy("$source/img", $imgTargetDir); - - $this->utils->echoContent("2.- Copying lib files into: $jsTargetDir"); - $this->utils->copy("$source/libraries/restclient/restclient-min.js", "$jsTargetDir/restclient.min.js"); - - $this->utils->echoContent("3.- Copying font files into: $pmUIFontsDir"); - $this->utils->recCopy("$source/themes/$this->theme/fonts", $pmUIFontsDir); - - $this->utils->echoFooter("PMUI Build Finished!"); - $response['success'] = true; - - return $response; - } catch (Exception $e) { - $this->utils->exitCode(8, $e); - - return $e; - } - } - - /** - * Builds MAFE Files - * @return array|Exception - */ - function buildMafe() - { - try { - $this->utils->echoHeader("Building PM Michelangelo FE"); - - $target = $this->dir['targetDir']; - $source = $this->baseDir . "/vendor/colosa/MichelangeloFE"; - $buildTempDir = $this->buildTempDir . "/vendor/colosa/MichelangeloFE"; - $mafeDir = $target . "/mafe"; - $jsTargetDir = $target . "/js"; - $cssTargetDir = $target . "/css"; - $imgTargetDir = $target . "/img"; - - $response = array(); - $response['success'] = false; - $response['js'] = ""; - $response['css'] = ""; - $response['customjs'] = false; - $response['customcss'] = false; - $response['hash'] = ""; - - $vh = $this->utils->getHash($source); - $this->versions->mafe_hash = $vh['hash']; - $this->versions->mafe_ver = $vh['version'] . '.' . $vh['hash']; - - // Loads all plugins - $pluginDir = $this->extension ? $this->utils->getExtensionsDirArray($this->dir['extensionDir']) : false; - if ($this->extension) { - // Loads all enabled Plugins - $pluginAdd = "/colosa/MichelangeloFE"; - if (!empty($this->enabledExtensions)) { - $pluginDir = $this->utils->prependPluginDir($this->enabledExtensions, $this->dir['extensionDir']); - } - $pluginDir = $this->utils->appendPluginDir($pluginDir, $pluginAdd); - - } - - $buildConfig = $source . "/config/build.json"; - $mafeSources = file_get_contents($buildConfig); - $mafeConfig = $this->utils->json_clean_decode($mafeSources); - foreach ($mafeConfig as $lib) { - $this->utils->minifyByConfig($lib, $source, $buildTempDir, false, $pluginDir); - } - - //Compress App Files - $appBuildConfig = $source . "/config/applications.json"; - $appMafeSources = file_get_contents($appBuildConfig); - $appConfig = $this->utils->json_clean_decode($appMafeSources); - foreach ($appConfig as $lib) { - $this->utils->minifyByConfig($lib, $source, $buildTempDir, false, $pluginDir); - } - - // Copying files to mafe Dir - $this->utils->echoContent("Copying files into: $mafeDir"); - $this->utils->recCopy($source . "/lib/jQueryUI/images/", $cssTargetDir . "/images/"); - //Compiled Libraries from buildTemp directory - $this->utils->copyIfExist($source, "/build/js/designer.js", $mafeDir, "/designer.min.js", $buildTempDir); - $this->utils->copyIfExist($source, "/build/js/mafe.js", $mafeDir, "/mafe.min.js", $buildTempDir); - $this->utils->copyIfExist($source, "/build/css/mafe.css", $mafeDir, "/mafe.min.css", $buildTempDir); - - $this->utils->recCopy($source . "/img", $imgTargetDir); - // IMPROVEMENT Register files that have been copied to $imgTargetdir as a plugin consequence - if ($pluginDir) { - foreach ($pluginDir as $row) { - $this->utils->recCopy($row . "/img", $imgTargetDir); - } - } - - $this->utils->echoContent("Copying files into: $jsTargetDir"); - - $this->utils->copy($source . "/lib/wz_jsgraphics/wz_jsgraphics.js", $jsTargetDir . "/wz_jsgraphics.js"); - $this->utils->copy($source . "/lib/jQuery/jquery-1.10.2.min.js", $jsTargetDir . "/jquery-1.10.2.min.js"); - $this->utils->copy($source . "/lib/underscore/underscore-min.js", $jsTargetDir . "/underscore-min.js"); - $this->utils->copy($source . "/lib/jQueryUI/jquery-ui-1.10.3.custom.min.js", - $jsTargetDir . "/jquery-ui-1.10.3.custom.min.js"); - $this->utils->copy($source . "/lib/jQueryLayout/jquery.layout.min.js", - $jsTargetDir . "/jquery.layout.min.js"); - $this->utils->copy($source . "/lib/modernizr/modernizr.js", $jsTargetDir . "/modernizr.js"); - - $this->utils->recCopy($source . "/src/formDesigner/img/", $target . "/img"); - $this->utils->echoFooter("Michelangelo FE Build Finished"); - $response['success'] = true; - - return $response; - } catch (Exception $e) { - $this->utils->exitCode(9, $e); - - return $e; - } - - } - - /** - * Builds PMDynaform, not implemented yet - * temporally gets hash and version for main file Versions - * Take a look of buildPMDynaform of PHPBuilderUtils to improve this function - * @return Exception|null - */ - function buildPMDynaform() - { - try { - $target = $this->dir['targetDir']; - $source = $this->baseDir . "/vendor/colosa/pmDynaform"; - $vh = $this->utils->getHash($source); - $this->versions->pmdynaform_hash = $vh['hash']; - $this->versions->pmdynaform_ver = $vh['version'] . "." . $vh['hash']; - - $response = null; - - return $response; - } catch (Exception $e) { - $this->utils->exitCode(10, $e); - - return $e; - } - } - - /** - * Clean up function after build - * - */ - function cleanUp() - { - try { - $this->utils->delTree($this->buildTempDir); - } catch (Exception $e) { - $this->utils->log($e); - } - } -} - -/** - * Class PhpBuilderUtils - * Php Builder Utils has methods as recursive copy, write and minify files - */ -class PhpBuilderUtils -{ - /** - * Extension config File Directory location. - * - * @var string - */ - public $extensionsJsConfig; - public $logger; - public $logDir; - public $pathSep; - - /** - * Class constructor. - * - */ - public function __construct() - { - $this->extensionsJsConfig = ""; - $this->silentMode = false; - $this->logger = array(); - $this->logDir = ""; - if (defined('PATH_SEP')) { - $this->pathSep = PATH_SEP; - } else { - $this->pathSep = "/"; - } - } - - /** - * Get Function of class key - * @param string $key - * @return $value - */ - public function __get($key) - { - return $this->$key; - } - - /** - * Set Function of class key - * @param string $key - * @param string $value - * - */ - public function __set($key, $value) - { - $this->$key = $value; - } - - /** - * Logger function. - * - * @param mixed $e - */ - public function log($e) - { - $this->logger[] = $e; - } - - /** - * Recursive copy of directories, - * can be updated with compare values and overwrite if newer - * @param string $src Source directory - * @param string $dst Target directory - * @param bool $delete Deletes directory first, copy after delete - * - */ - function recCopy($src, $dst, $delete = false) - { - if ($delete && file_exists($dst)) { - $this->delTree($dst); - } - if (is_dir($src)) { - if (!file_exists($dst) && is_writable($dst)) { - mkdir($dst); - } else { - $this->log("File doesn't exist or directory is not writable, file: $dst \n"); - } - $files = scandir($src); - foreach ($files as $file) { - if ($file != "." && $file != "..") { - $this->recCopy("$src/$file", "$dst/$file"); - } - } - } else { - $this->copy($src, $dst); - } - } - - public function copy($src, $dst) - { - try { - if (file_exists($src) && is_writable($dst)) { - copy($src, $dst); - } else { - $this->log("File doesn't exist or directory is not writable, file: $dst \n"); - } - } catch (Exception $e) { - $this->log($e); - } - } - - /** - * Copy tmp File if exists, else copy file from source - * - * @param $source - * @param $file - * @param $dest - * @param $destFile - * @param $tmp - */ - function copyIfExist($source, $file, $dest, $destFile, $tmp) - { - if (file_exists($tmp . $file)) { - $this->copy($tmp . $file, $dest . $destFile); - } else { - $this->copy($source . $file, $dest . $destFile); - } - } - - /** - * Force write file if directory doesn't exist - * - * @param $dir - * @param $contents - */ - function file_force_contents($dir, $contents) - { - $parts = explode($this->pathSep, $dir); - $file = array_pop($parts); - $dir = ''; - foreach ($parts as $part) { - if (!is_dir($dir .= $part . $this->pathSep)) { - mkdir($dir, 0777, true); - } - } - $this->file_put_contents($this->pathSep . $file, $dir, $contents); - } - - public function file_put_contents($file, $dir = "", $contents) - { - $dst = $dir . $file; - try { - if (is_writable($dir)) { - file_put_contents($dst, $contents); - } else { - $this->log("Cannot write file, check directory permissions, file: $dst \n"); - } - } catch (Exception $e) { - $this->log($e); - } - } - - /** - * Clean decode of json string, removes comment lines - * @param string $json Json string being decoded - * @param bool $assoc When TRUE return as associative array - * @param int $depth User specified recursion depth - * @param int $options Decode options - * @return mixed Value encoded in Json, False and Null - * - */ - function json_clean_decode($json, $assoc = false, $depth = 512, $options = 0) - { - // Search and remove comments like /* */ and // - $json = preg_replace("#(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|([\s\t]//.*)|(^//.*)#", '', $json); - - if (version_compare(phpversion(), '5.4.0', '>=')) { - $json = json_decode($json, $assoc, $depth, $options); - } elseif (version_compare(phpversion(), '5.3.0', '>=')) { - $json = json_decode($json, $assoc, $depth); - } else { - $json = json_decode($json, $assoc); - } - - return $json; - } - - /** - * Clean up directories - * @param array $dirs Array of directories to remove and create - * - */ - - function prepare_dirs($dirs) - { - foreach ($dirs as $dir) { - $this->refreshDir($dir, true); - } - } - - /** - * Clean up directories - * @param string $dir Directory to remove and create - * @param bool $showDetail When TRUE echoes directory create action - * - */ - function refreshDir($dir, $showDetail = false) - { - if (is_writable($dir)) { - $this->delTree($dir); - } elseif (!file_exists($dir)) { - //todo check conditionals - } else { - $this->exitCode(7, $dir); - } - //Todo change the permissions here - mkdir($dir, 0777); - if ($showDetail) { - $this->echoContent("Create: $dir"); - } - } - - /** - * Delete a tree directory structure - * @param array $dir Directories - * @return bool True if success, otherwise False - */ - function delTree($dir) - { - $files = array_diff(scandir($dir), array('.', '..')); - foreach ($files as $file) { - (is_dir("$dir/$file")) ? $this->delTree("$dir/$file") : unlink("$dir/$file"); - } - - return rmdir($dir); - } - - /** - * Echo content - * @param string $content String to show - * - */ - function echoContent($content) - { - if (!$this->silentMode) { - echo "$content\n"; - } - } - - /** - * Echo content with Format - * @param string $content String to show - * - */ - function echoHeader($content) - { - if (!$this->silentMode) { - echo "\n\e[1;34m$content\033[0m\n"; - } - } - - /** - * Echo content with Format - * @param string $content String to show - * - */ - function echoFooter($content) - { - if (!$this->silentMode) { - echo "\n\e[1;32m$content\033[0m\n"; - } - } - - /** - * Echo content with Format - * @param string $content String to show - * - */ - function echoError($content = "Error") - { - echo "\n\e[1;31m$content\033[0m\n"; - } - - /** - * Echo content with Format - * @param string $content String to show - * - */ - function echoWarning($content = "Please review files") - { - if (!$this->silentMode) { - echo "\n\e[1;33m$content\033[0m\n"; - } - } - - /** - * Write String to file - * @param string $filename String with filename, please include extension - * @param string $directory Directory of file - * @param string $contents Content to be written - * @param bool $overwrite Replace or append content to file, True when you want to overwrite it - * - */ - function writeToFile($filename, $directory, $contents, $overwrite = true) - { - $current = file_exists($directory . "/" . $filename) ? file_get_contents($directory . "/" . $filename) : ""; - if (!$overwrite) { - $current .= $contents; - } else { - $current = $contents; - } - $this->file_put_contents("/$filename", $directory, $current); - } - - /** - * Recursive add a directory content to zip file - * @param mixed $zip - * @param String $dir Directory - * @param String $base Base directory - * @return mixed - */ - function addDirectoryToZip($zip, $dir, $base) - { - $newFolder = str_replace($base, '', $dir); - $zip->addEmptyDir($newFolder); - foreach (glob($dir . '/*') as $file) { - if (is_dir($file)) { - $zip = $this->addDirectoryToZip($zip, $file, $base); - } else { - $newFile = str_replace($base, '', $file); - $zip->addFile($file, $newFile); - } - } - - return $zip; - } - - /** - * Returns Directory as array from all extensions. - * @param String $baseDir Base dir of a Process Maker Installation - * @return array - */ - function getExtensionsDirArray($baseDir) - { - return $this->directoryToArray($baseDir, false, true, false); - } - - /** - * Returns directory files as array without .. and . - * @param String $directory - * @return array - */ - function dirContent($directory) - { - return array_diff(scandir($directory), array('..', '.')); - } - - /** - * Get an array that represents directory tree - * @param string $directory Directory path - * @param bool $recursive Include sub directories - * @param bool $listDirs Include directories on listing - * @param bool $listFiles Include files on listing - * @param regex $exclude Exclude paths that matches this regex - * @return array $arrayItems Directory tree - */ - function directoryToArray($directory, $recursive = true, $listDirs = false, $listFiles = true, $exclude = '') - { - $arrayItems = array(); - $skipByExclude = false; - if (!file_exists($directory)) { - return $arrayItems; - } - $handle = opendir($directory); - if ($handle) { - while (false !== ($file = readdir($handle))) { - preg_match("/(^(([\.]){1,2})$|(\.(svn|git|md))|(Thumbs\.db|\.DS_STORE))$/iu", $file, $skip); - if ($exclude) { - preg_match($exclude, $file, $skipByExclude); - } - if (!$skip && !$skipByExclude) { - if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) { - if ($recursive) { - $arrayItems = array_merge($arrayItems, - $this->directoryToArray($directory . DIRECTORY_SEPARATOR . $file, $recursive, $listDirs, - $listFiles, $exclude)); - } - if ($listDirs) { - $file = $directory . DIRECTORY_SEPARATOR . $file; - $arrayItems[] = $file; - } - } else { - if ($listFiles) { - $file = $directory . DIRECTORY_SEPARATOR . $file; - $arrayItems[] = $file; - } - } - } - } - closedir($handle); - } - - return $arrayItems; - } - - /** - * Minify files by read config of json file, use this with PMUI and MAFE build.json - * - * @param Object $lib Config read from build.json - * @param String $source Source directory - * @param String $target Target directory - * @param bool $addMinExt When TRUE, adds '.min' before extension - * @param bool $addPluginFiles When TRUE, search from extensions folders to append to build file - */ - function minifyByConfig($lib, $source, $target, $addMinExt = false, $addPluginFiles = false) - { - // Todo Please standardize target_dir or target_to from config files - $target_dir = !empty($lib->target_dir) ? $lib->target_dir : $lib->target_to; - $sourceFrom = ""; - if (!empty($lib->target_from)) { - $sourceFrom = $lib->target_from . "/"; - if ($addPluginFiles) { - $addPluginFiles = $this->appendPluginDir($addPluginFiles, "/" . $sourceFrom); - } - } - $files = $lib->files; - if ($addMinExt) { - $lib->name = $lib->name . ".min"; - } - switch ($lib->extension) { - case "js": - $this->echoContent("Building Js File"); - $this->minifyFiles($lib->name, 'js', $files, $source . "/" . $sourceFrom, $target . "/$target_dir", - $addPluginFiles); - break; - case "css": - $this->echoContent("Building Css File"); - $this->minifyFiles($lib->name, 'css', $files, $source . "/", $target . "/$target_dir", $addPluginFiles); - break; - default: - $this->echoWarning('No extension defined or usable to build file'); - break; - } - } - - /** - * Build minified file from files - * TODO Include a minifier as else statement - * @param String $name Filename of target - * @param String $extension Extension of file (css, js) - * @param Array $files Array with names of files to include into build file - * @param String $basePath Source directory to search files - * @param String $targetPath Target directory to save build file - * @param bool $addPlugin When TRUE, includes files from Plugin-Extensions folders - * @param bool $minify When TRUE, minify the files, NOT INCLUDED YET. - * @return bool|mixed|string - */ - function minifyFiles($name, $extension, $files, $basePath, $targetPath, $addPlugin = false, $minify = false) - { - if (!$minify) { - $minifiedPath = $targetPath . $name . "." . $extension; - $content = ""; - $content = $content . $this->joinFiles($basePath, $files, $addPlugin); - $this->file_force_contents($minifiedPath, $content); - - return $content; - } - - return false; - } - - /** - * Appends Plugin-Extension Directory to every file in - * @param Array $pluginDir - * @param String $pluginAdd - * @return Array - */ - function appendPluginDir($pluginDir, $pluginAdd) - { - foreach ($pluginDir as $key => $row) { - $pluginDir[$key] = $row . $pluginAdd; - } - - return $pluginDir; - } - - /** - * Prepend Plugin-Extension Directory to every file in - * @param Array $pluginDir - * @param String $baseDir - * @return Array - */ - function prependPluginDir($pluginDir, $baseDir) - { - foreach ($pluginDir as $key => $row) { - $pluginDir[$key] = $baseDir . '/' . $row; - } - - return $pluginDir; - } - - /** - * Join files into one - * @param string $baseDir Base file of Directory - * @param array $files file source array - * @param bool $plugin When True, searches for extensions files - * @param string $separator Custom file separator - * @return string $content File contents - */ - function joinFiles($baseDir, $files, $plugin = false, $separator = "\n") - { - $content = ""; - foreach ($files as $file) { - $content = $content . file_get_contents("$baseDir/$file") . $separator; - if ($plugin && is_array($plugin)) { - foreach ($plugin as $row) { - if (file_exists("$row/$file")) { - $content = $content . file_get_contents("$row/$file") . $separator; - $this->echoWarning("Custom code added for: $row/$file"); - } - } - } - } - - return $content; - } - - /** - * Get hash and version of repositories - * @param string $source Base directory of repository - * @return array $values with hash and version of repository - */ - function getHash($source) - { - $values = []; - $values['hash'] = substr(md5($source), 0, 7); - $values['version'] = '1.0.0'; - - return $values; - } - - /** - * Get Git hash and version of repositories - * @param string $source Base directory of repository - * @return array $values with hash and version of repository - */ - function getGitHash($source) - { - $cwd = getcwd(); - chdir($source); - exec('git rev-parse --short HEAD', $hashes); - exec('git rev-parse --abbrev-ref HEAD', $version); - chdir($cwd); - $values = []; - $values['hash'] = !empty($hashes[0]) ? $hashes[0] : ''; - $values['version'] = !empty($version[0]) ? $version[0] : ''; - - return $values; - } - - /** - * Shows help - */ - function showHelpDerp() - { - echo <<echoFooter("-- DONE --"); - break; - case 4: - $this->showHelpDerp(); - break; - case 5: - $this->echoContent("This ain't no Process Maker install directory mate"); - $this->echoContent("Please check if your executing this file into processmaker"); - $this->echoContent("Pro tip: You can also specify the base dir with: --base_dir=\"path/to/processmaker\""); - break; - case 6: - $this->echoContent("Mode doesn't exist pal. Use prod or dev mode."); - break; - case 7: - $this->echoError("Error. Directory $contents is not writable, please check permissions."); - break; - case 8: - $this->echoError("Error when building PMUI, please review logs."); - $this->echoContent($contents); - break; - case 9: - $this->echoError("Error when building MAFE, please review logs."); - $this->echoContent($contents); - break; - case 10: - $this->echoError("Error when building MAFE, please review logs."); - $this->echoContent($contents); - break; - default: - $this->echoContent("Exit Code Not found, exit anyway lol"); - break; - } - $this->writeToFile("build.log", $this->logDir, $this->logger); - exit($code); - } - - /** - * Read arguments Helper - * @return array - */ - public function readArguments() - { - // Read arguments - global $argv; - if (!isset($config)) { - $config = array(); - } - if (isset($argv)) { - foreach ($argv as $arg) { - if (substr($arg, 0, 2) == '--') { - $arg = substr($arg, 2, strlen($arg)); - } - if (substr($arg, 0, 1) == '-') { - $arg = substr($arg, 1, strlen($arg)); - } - $params = explode('=', $arg); - if (count($params) > 1) { - $config[$params[0]] = $params[1]; - } else { - $config[$params[0]] = true; - } - } - } - - return $config; - } - - /** - * Include files to minify, this array is a copy from rake include files - * @return array - */ - function getJsIncludeFiles() - { - - $includeFiles = [ - "workflow/public_html/lib/js/wz_jsgraphics.js", - "workflow/public_html/lib/js/jquery-1.10.2.min.js", - "workflow/public_html/lib/js/underscore-min.js", - "workflow/public_html/lib/js/jquery-ui-1.10.3.custom.min.js", - "workflow/public_html/lib/js/jquery.layout.min.js", - "workflow/public_html/lib/js/modernizr.js", - "workflow/public_html/lib/js/restclient.min.js", - "workflow/public_html/lib/pmUI/pmui.min.js", - "workflow/public_html/lib/mafe/mafe.min.js", - "workflow/public_html/lib/mafe/designer.min.js", - "gulliver/js/tinymce/jscripts/tiny_mce/tiny_mce.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmGrids/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmSimpleUploader/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/visualchars/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/xhtmlxtras/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/wordcount/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/visualblocks/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/template/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/visualblocks/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/style/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/save/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/tabfocus/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/searchreplace/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/media/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/lists/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/example/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/pagebreak/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/example_dependency/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/fullpage/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/layer/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/legacyoutput/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/fullscreen/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/iespell/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/inlinepopups/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/autoresize/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/contextmenu/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/advlist/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/autolink/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/directionality/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/editor_template.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/advhr/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin.js", - "gulliver/js/tinymce/jscripts/tiny_mce/plugins/nonbreaking/editor_plugin.js", - "gulliver/js/codemirror/lib/codemirror.js", - "gulliver/js/codemirror/addon/hint/show-hint.js", - "gulliver/js/codemirror/addon/hint/javascript-hint.js", - "gulliver/js/codemirror/addon/hint/sql-hint.js", - "gulliver/js/codemirror/addon/hint/php-hint.js", - "gulliver/js/codemirror/addon/hint/html-hint.js", - "gulliver/js/codemirror/mode/javascript/javascript.js", - "gulliver/js/codemirror/addon/edit/matchbrackets.js", - "gulliver/js/codemirror/mode/htmlmixed/htmlmixed.js", - "gulliver/js/codemirror/mode/xml/xml.js", - "gulliver/js/codemirror/mode/css/css.js", - "gulliver/js/codemirror/mode/clike/clike.js", - "gulliver/js/codemirror/mode/php/php.js", - "gulliver/js/codemirror/mode/sql/sql.js", - ]; - - return $includeFiles; - } - - /** - * Include files to minify, this array is a copy from rake include files - * @return array - */ - function getCssIncludeFiles() - { - return [ - "gulliver/js/codemirror/lib/codemirror.css", - "gulliver/js/codemirror/addon/hint/show-hint.css", - "workflow/public_html/lib/pmUI/pmui.min.css", - "workflow/public_html/lib/mafe/mafe.min.css", - ]; - } - - /** - * pmUITheme config helper, from ruby config file - * @return array - */ - function pmUIThemeConfigRB() - { - return [ - 'http_path' => "/", - 'css_dir' => "./css", - 'sass_dir' => "./src/sass", - 'images_dir' => "./img", - 'javascripts_dir' => "./src", - 'http_generated_images_path' => "../img", - 'http_fonts_path' => '../fonts', - ]; - } - - /** - * Build PMDynaform Wannabe, - * TODO USE IT AS BASE TO A REAL DYNAFORM BUILDER, SCRIPT IS NOT COMPLETE - * @param $home - * @param $target - * @param $mode - */ - function buildPmdynaform($home, $target, $mode) - { - $source = $home . "/vendor/colosa/pmDynaform"; - - $this->echoHeader("Building PmDynaform Library"); - - $pmdynaformDir = $target . "/pmdynaform"; - - if (!file_exists("$pmdynaformDir/build")) { - mkdir("$pmdynaformDir/build", 0777); - } - $this->recCopy("$source/build", "$pmdynaformDir/build", false); - if (!file_exists("$pmdynaformDir/libs")) { - mkdir("$pmdynaformDir/libs", 0777); - } - $this->recCopy("$source/libs", "$pmdynaformDir/libs", false); - $config = file_get_contents($source . "/config/templates.json"); - $config = $this->json_clean_decode($config); - $template = ""; - - foreach ($config as $tmp) { - - $s = $this->joinFiles($source, $tmp->files); - $template = $template . $s; - } - - // todo review something else within Dynaform - - $this->echoFooter("PMUI Dynaform Finished!"); - } - - /** - * Build PMDynaformZip Wannabe, - * TODO USE IT AS BASE TO A REAL DYNAFORMZIP BUILDER - * @param $home - * @param $target - * @param $mode - */ - function buildPmdynaformZip($home, $target, $mode) - { - $source = $home . "/vendor/colosa/pmDynaform"; - - $this->echoHeader("Building Compress Zip Library"); - // if ($mode == "dev"){ - $minified = [ - "src/language/en.js", - "src/PMDynaform.js", - "src/core/Selector.js", - "src/core/Utils.js", - "src/core/Mask.js", - "src/core/Validators.js", - "src/core/Project.js", - "src/core/Formula.js", - "src/core/PMRest.js", - "src/core/TransformJSON.js", - "src/core/FileStream.js", - "src/core/FullScreen.js", - "src/core/Script.js", - "src/util/ArrayList.js", - "src/extends/core/ProjectMobile.js", - "src/implements/WebServiceManager.js", - "src/extends/core/ProcessFlow.js", - "src/extends/core/ProcessFlowIOS.js", - "src/extends/core/FormsHandler.js", - "src/extends/core/DataLocalManager.js", - "src/extends/views/MediaElement.js", - "src/proxy/RestProxy.js", - "src/views/Validator.js", - "src/views/Panel.js", - "src/views/FormPanel.js", - "src/views/Field.js", - "src/views/Grid.js", - "src/views/GridMobile.js", - "src/views/Button.js", - "src/views/DropDown.js", - "src/views/Radio.js", - "src/views/Submit.js", - "src/views/TextArea.js", - "src/views/Text.js", - "src/views/File.js", - "src/views/CheckBox.js", - "src/views/CheckGroup.js", - "src/views/Suggest.js", - "src/views/Link.js", - "src/views/Label.js", - "src/views/Title.js", - "src/views/Empty.js", - "src/views/Hidden.js", - "src/views/Image.js", - "src/views/SubForm.js", - "src/views/GeoMap.js", - "src/views/Annotation.js", - "src/views/Datetime.js", - "src/views/PanelField.js", - "src/extends/views/ScannerCode.js", - "src/extends/views/Signature.js", - "src/extends/views/Geo.js", - "src/extends/views/FileMobile.js", - "src/models/Validator.js", - "src/models/Panel.js", - "src/models/FormPanel.js", - "src/models/Field.js", - "src/models/Grid.js", - "src/models/Button.js", - "src/models/DropDown.js", - "src/models/Radio.js", - "src/models/Submit.js", - "src/models/TextArea.js", - "src/models/Text.js", - "src/models/File.js", - "src/models/CheckBox.js", - "src/models/CheckGroup.js", - "src/models/Datetime.js", - "src/models/Suggest.js", - "src/models/Link.js", - "src/models/Label.js", - "src/models/Title.js", - "src/models/Empty.js", - "src/models/Hidden.js", - "src/models/Image.js", - "src/models/SubForm.js", - "src/models/GeoMap.js", - "src/models/Annotation.js", - "src/extends/models/ScannerCode.js", - "src/extends/models/Signature.js", - "src/extends/models/Geo.js", - "src/extends/models/FileMobile.js", - "src/models/PanelField.js", - "src/extends/core/get_scripts.js" - ]; - $index = [ - 'appMobile/form-dev.html', - "src/templates/template.html", - "src/templates/controls.html", - "src/templates/GridTemplate.html", - "src/templates/GeoMapTemplate.html", - "src/templates/annotation.html", - "src/templates/Qrcode_mobile.html", - "src/templates/Signature_mobile.html", - "src/templates/GeoMobile.html", - "src/templates/FileMobile.html", - "src/templates/PanelField.html", - 'appMobile/form-dev2.html' - ]; - - $dev = $source . "/build-dev"; - $css = $dev . "/css"; - $js = $dev . "/js"; - $img = $dev . "/img"; - $libs = $dev . "/libs"; - - - $this->refreshDir($dev); - $this->refreshDir($css); - $this->refreshDir($js); - $this->refreshDir($img); - $this->refreshDir($libs); - $this->recCopy($source . "/fonts", $css . "/fonts", false); - - $this->minifyFiles('pmDynaform', 'js', $minified, $source . "/", $dev . "/js/", false); - $this->recCopy($source . "/libs", $dev . "/libs", false); - $this->copy($source . "/appMobile/appBuild.js", $dev . "/appBuild.js"); - $this->copy($source . "/img/geoMap.jpg", $dev . "/geoMap.jpg"); - $htmlFile = $this->joinFiles($source, $index); - $this->file_put_contents("/index.html", $dev, $htmlFile); - - $cssmin = [ - "libs/bootstrap-3.1.1/css/bootstrap.min.css", - "libs/datepicker/bootstrap-datetimepicker.css", - "css/pmDynaform.css" - ]; - $minified = [ - "libs/jquery/jquery-1.11.js", - "libs/bootstrap-3.1.1/js/bootstrap.min.js", - "libs/datepicker/bootstrap-datetimepicker.js", - "libs/underscore/underscore-1.6.js", - "libs/backbone/backbone-min.js", - "libs/restclient/restclient.js", - "js/pmDynaform.js" - ]; - $index = [ - "appMobile/form-prod.html", - "src/templates/template.html", - "src/templates/controls.html", - "src/templates/GridTemplate.html", - "src/templates/GeoMapTemplate.html", - "src/templates/annotation.html", - "src/templates/Qrcode_mobile.html", - "src/templates/Signature_mobile.html", - "src/templates/GeoMobile.html", - "src/templates/FileMobile.html", - "src/templates/PanelField.html", - "appMobile/form-prod2.html" - ]; - - $prod = $source . "/build-prod"; - $zipProd = $source . "/build-prod-zip"; - $css = $prod . "/css"; - $js = $prod . "/js"; - $img = $prod . "/img"; - - $this->refreshDir($prod); - $this->refreshDir($css); - $this->refreshDir($js); - $this->refreshDir($img); - - $this->recCopy($source . "/fonts", $css . "/fonts", false); - $this->recCopy($dev . "/libs/bootstrap-3.1.1/fonts/", $prod . "/fonts/", false); - - - $this->minifyFiles('pmDynaform.min', 'css', $cssmin, $dev . "/", $prod . "/css/", false); - $this->minifyFiles('pmDynaform.min', 'js', $minified, $dev . "/", $prod . "/js/", false); - - $this->copy($source . "/appMobile/appBuild.js", $prod . "/appBuild.js"); - $this->copy($source . "/img/geoMap.jpg", $prod . "/geoMap.jpg"); - $this->recCopy($source . "/img", $prod . "/img", false); - $htmlFile = $this->joinFiles($source, $index); - $this->file_put_contents("/index.html", $prod, $htmlFile); - - - // Create Zip File - $this->refreshDir($zipProd); - $directoryToZip = $source . "/build-prod"; - $outputFile = "$zipProd/build-prod.zip"; - $zipFile = new ZipArchive(); - $zipFile->open($outputFile, ZipArchive::CREATE | ZipArchive::OVERWRITE); - $zipFile = $this->addDirectoryToZip($zipFile, $prod, $directoryToZip); - $zipFile->close(); - if (file_exists($outputFile)) { - copy($outputFile, $target . "/build-prod.zip"); - } - $this->echoFooter("PMUI Dynaform Zip Finished!"); - } -} - -/** - * Class Versions - * Helper to easy build Versions file - */ -class Versions -{ - public $pmui_ver = ""; - public $pmui_hash = ""; - public $mafe_ver = ""; - public $mafe_hash = ""; - public $pmdynaform_ver = ""; - public $pmdynaform_hash = ""; - - /** - * Get Function of class key - * @param string $key - * @return $value - */ - public function __get($key) - { - return $this->$key; - } - - /** - * Set Function of class key - * @param string $key - * @param string $value - * - */ - public function __set($key, $value) - { - $this->$key = $value; - } -} diff --git a/composer.lock b/composer.lock index d222efc71..f9ac617c7 100644 --- a/composer.lock +++ b/composer.lock @@ -55,7 +55,7 @@ "source": { "type": "git", "url": "git@bitbucket.org:colosa/michelangelofe.git", - "reference": "e0c591a07201ebfa2582a819680a1a25a1fdf719" + "reference": "cc19932a095b2232bef7998d2c90b2408ad9be19" }, "require": { "colosa/pmui": "release/3.2-dev" @@ -66,7 +66,7 @@ "keywords": [ "js app ProcessMaker" ], - "time": "2017-03-11 01:50:42" + "time": "2017-04-11 15:29:24" }, { "name": "colosa/pmDynaform", @@ -74,7 +74,7 @@ "source": { "type": "git", "url": "git@bitbucket.org:colosa/pmdynaform.git", - "reference": "e0c2d7b6b50331dacb30f31118c8546edca32007" + "reference": "17ac424d4f51c42c7812fdc117948eef45bddce8" }, "type": "library", "description": "JS Library to render ProcessMaker Dynaforms", @@ -82,7 +82,7 @@ "keywords": [ "js lib ProcessMaker Dynaforms" ], - "time": "2017-03-11 02:03:24" + "time": "2017-04-11 15:29:14" }, { "name": "colosa/pmUI", @@ -610,16 +610,16 @@ }, { "name": "symfony/config", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "06ce6bb46c24963ec09323da45d0f4f85d3cecd2" + "reference": "35b7dfa089d7605eb1fdd46281b3070fb9f38750" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/06ce6bb46c24963ec09323da45d0f4f85d3cecd2", - "reference": "06ce6bb46c24963ec09323da45d0f4f85d3cecd2", + "url": "https://api.github.com/repos/symfony/config/zipball/35b7dfa089d7605eb1fdd46281b3070fb9f38750", + "reference": "35b7dfa089d7605eb1fdd46281b3070fb9f38750", "shasum": "" }, "require": { @@ -662,20 +662,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2017-03-01T18:13:50+00:00" + "time": "2017-04-04T15:24:26+00:00" }, { "name": "symfony/console", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "81508e6fac4476771275a3f4f53c3fee9b956bfa" + "reference": "86407ff20855a5eaa2a7219bd815e9c40a88633e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/81508e6fac4476771275a3f4f53c3fee9b956bfa", - "reference": "81508e6fac4476771275a3f4f53c3fee9b956bfa", + "url": "https://api.github.com/repos/symfony/console/zipball/86407ff20855a5eaa2a7219bd815e9c40a88633e", + "reference": "86407ff20855a5eaa2a7219bd815e9c40a88633e", "shasum": "" }, "require": { @@ -723,7 +723,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-03-04T11:00:12+00:00" + "time": "2017-04-03T20:37:06+00:00" }, { "name": "symfony/debug", @@ -784,16 +784,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "efdbeefa454a41154fd99a6f0489f0e9cb46c497" + "reference": "14b9d8ae69ac4c74e8f05fee7e0a57039b99c81e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/efdbeefa454a41154fd99a6f0489f0e9cb46c497", - "reference": "efdbeefa454a41154fd99a6f0489f0e9cb46c497", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/14b9d8ae69ac4c74e8f05fee7e0a57039b99c81e", + "reference": "14b9d8ae69ac4c74e8f05fee7e0a57039b99c81e", "shasum": "" }, "require": { @@ -843,20 +843,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2017-02-28T12:31:05+00:00" + "time": "2017-04-03T22:14:48+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "bb4ec47e8e109c1c1172145732d0aa468d967cd0" + "reference": "88b65f0ac25355090e524aba4ceb066025df8bd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bb4ec47e8e109c1c1172145732d0aa468d967cd0", - "reference": "bb4ec47e8e109c1c1172145732d0aa468d967cd0", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/88b65f0ac25355090e524aba4ceb066025df8bd2", + "reference": "88b65f0ac25355090e524aba4ceb066025df8bd2", "shasum": "" }, "require": { @@ -903,7 +903,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-02-21T08:33:48+00:00" + "time": "2017-04-03T20:37:06+00:00" }, { "name": "symfony/filesystem", @@ -1065,16 +1065,16 @@ }, { "name": "symfony/translation", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "b538355bc99db2ec7cc35284ec76d92ae7d1d256" + "reference": "047e97a64d609778cadfc76e3a09793696bb19f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/b538355bc99db2ec7cc35284ec76d92ae7d1d256", - "reference": "b538355bc99db2ec7cc35284ec76d92ae7d1d256", + "url": "https://api.github.com/repos/symfony/translation/zipball/047e97a64d609778cadfc76e3a09793696bb19f1", + "reference": "047e97a64d609778cadfc76e3a09793696bb19f1", "shasum": "" }, "require": { @@ -1125,20 +1125,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2017-03-04T12:20:59+00:00" + "time": "2017-03-21T21:39:01+00:00" }, { "name": "symfony/yaml", - "version": "v2.8.18", + "version": "v2.8.19", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "2a7bab3c16f6f452c47818fdd08f3b1e49ffcf7d" + "reference": "286d84891690b0e2515874717e49360d1c98a703" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/2a7bab3c16f6f452c47818fdd08f3b1e49ffcf7d", - "reference": "2a7bab3c16f6f452c47818fdd08f3b1e49ffcf7d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/286d84891690b0e2515874717e49360d1c98a703", + "reference": "286d84891690b0e2515874717e49360d1c98a703", "shasum": "" }, "require": { @@ -1174,7 +1174,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-03-01T18:13:50+00:00" + "time": "2017-03-20T09:41:44+00:00" } ], "aliases": [], diff --git a/gulliver/js/grid/core/grid.js b/gulliver/js/grid/core/grid.js index b386a0120..f1e4eebd7 100644 --- a/gulliver/js/grid/core/grid.js +++ b/gulliver/js/grid/core/grid.js @@ -563,6 +563,7 @@ var G_Grid = function(oForm, sGridName){ case 'textarea': //TEXTAREA aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea'); if (aObjects){ + aObjects[0].value = ''; aObjects[0].className = "module_app_input___gray"; newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]'); diff --git a/gulliver/js/maborak/core/maborak.js b/gulliver/js/maborak/core/maborak.js index a4c74b37b..ed51edd17 100644 --- a/gulliver/js/maborak/core/maborak.js +++ b/gulliver/js/maborak/core/maborak.js @@ -1345,7 +1345,7 @@ break;case'hidden':if((attributes.gridtype!="yesno"&&attributes.gridtype!="dropd newID=aObjects[n].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[n].id=newID;aObjects[n].name=newID;} break;case'button':if(aObjects[n].onclick){var onclickevn=new String(aObjects[n].onclick);eval('aObjects[n].onclick = '+onclickevn.replace(/\[1\]/g,'\['+currentRow+'\]')+';');} break;case"file":aObjects[n].value="";break;}}} -aObjects=null;break;case'textarea':aObjects=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');if(aObjects){aObjects[0].className="module_app_input___gray";newID=aObjects[0].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[0].id=newID;aObjects[0].name=newID;attributes=elementAttributesNS(aObjects[0],'pm');if(attributes.defaultvalue!=''&&typeof attributes.defaultvalue!='undefined'){defaultValue=attributes.defaultvalue;}else{defaultValue='';} +aObjects=null;break;case'textarea':aObjects=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');if(aObjects){aObjects[0].value='';aObjects[0].className="module_app_input___gray";newID=aObjects[0].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[0].id=newID;aObjects[0].name=newID;attributes=elementAttributesNS(aObjects[0],'pm');if(attributes.defaultvalue!=''&&typeof attributes.defaultvalue!='undefined'){defaultValue=attributes.defaultvalue;}else{defaultValue='';} aObjects[0].innerHTML=defaultValue;} aObjects=null;break;case'select':aObjects=oNewRow.getElementsByTagName('td')[i].getElementsByTagName('select');if(aObjects){newID=aObjects[0].id.replace(/\[1\]/g,'\['+currentRow+'\]');aObjects[0].id=newID;aObjects[0].name=newID;var oNewSelect=this.cloneElement(aObjects[0]);oNewSelect.id=newID;oNewSelect.name=newID;attributes=elementAttributesNS(aObjects[0],'pm');if(attributes.defaultvalue!=''&&typeof attributes.defaultvalue!='undefined'){defaultValue=attributes.defaultvalue;}else{defaultValue='';} var aDependents=this.allDependentFields.split(',');sObject=this.getObjectName(newID);var sw=false;for(x=0;xcaseSchedulerCron($sNow, $log, 1); + $oCaseScheduler->caseSchedulerCron($runDate, $log, 1); foreach ($log as $value) { $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron"))); @@ -660,6 +661,35 @@ function executeScheduledCases($sNow=null) } } +function runDateForScheduledCases($sNow) { + global $arraySystemConfiguration; + + $runDate = isset($sNow)? $sNow : date('Y-m-d H:i:s'); + + $systemUtcTimeZone = false; + /*----------------------------------********---------------------------------*/ + if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) { + $systemUtcTimeZone = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1; + } + /*----------------------------------********---------------------------------*/ + + if ($systemUtcTimeZone) { + if (isset($sNow)) { + //as the $sNow param that comes from the command line doesn't specicy a time zone + //we assume that the user set this time using the server time zone so we use the gmdate + //function to convert it + $currentTimeZone = date_default_timezone_get(); + date_default_timezone_set($arraySystemConfiguration['time_zone']); + $runDate = gmdate('Y-m-d H:i:s', strtotime($sNow)); + date_default_timezone_set($currentTimeZone); + } + else { + $runDate = gmdate('Y-m-d H:i:s'); + } + } + return $runDate; +} + function executeUpdateAppTitle() { try { diff --git a/workflow/engine/classes/class.actionsByEmailCore.php b/workflow/engine/classes/class.actionsByEmailCore.php index 05255c2f1..0e769ac0c 100644 --- a/workflow/engine/classes/class.actionsByEmailCore.php +++ b/workflow/engine/classes/class.actionsByEmailCore.php @@ -80,7 +80,7 @@ class actionsByEmailCoreClass extends PMPlugin $emailServer = new \ProcessMaker\BusinessModel\EmailServer(); - $emailSetup = ($dataAbe['ABE_EMAIL_SERVER_UID'] != '') ? + $emailSetup = (!is_null(\EmailServerPeer::retrieveByPK($dataAbe['ABE_EMAIL_SERVER_UID']))) ? $emailServer->getEmailServer($dataAbe['ABE_EMAIL_SERVER_UID'], true) : $emailServer->getEmailServerDefault(); @@ -158,7 +158,13 @@ class actionsByEmailCoreClass extends PMPlugin $envSkin = defined("SYS_SKIN") ? SYS_SKIN : $conf->getConfiguration('SKIN_CRON', ''); $envHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : SERVER_NAME; $envProtocol = defined("REQUEST_SCHEME") && REQUEST_SCHEME === "https"; - $envPort = (SERVER_PORT . "" != "80") ? ":" . SERVER_PORT : ""; + if (isset($_SERVER['SERVER_PORT'])) { + $envPort = ($_SERVER['SERVER_PORT'] != "80") ? ":" . $_SERVER['SERVER_PORT'] : ""; + } else if (defined('SERVER_PORT')) { + $envPort = (SERVER_PORT . "" != "80") ? ":" . SERVER_PORT : ""; + } else { + $envPort = ""; // Empty by default + } if (!empty($envPort) && strpos($envHost, $envPort) === false) { $envHost = $envHost . $envPort; } diff --git a/workflow/engine/classes/class.derivation.php b/workflow/engine/classes/class.derivation.php index 816505a2c..716954179 100644 --- a/workflow/engine/classes/class.derivation.php +++ b/workflow/engine/classes/class.derivation.php @@ -1249,15 +1249,7 @@ class Derivation break; } - $rouPreType = ""; - $rouPreTask = ""; $taskNextDelNextDelRouType = $arrayTaskNextDelNextDel["ROU_TYPE"]; - - if(isset($arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TYPE"]) && isset($arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TASK"])){ - $rouPreType = $arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TYPE"]; - $rouPreTask = $arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TASK"]; - } - $nextDelegationsAux[++$i] = array( "TAS_UID" => $arrayTaskNextDelNextDel["NEXT_TASK"]["TAS_UID"], "USR_UID" => $arrayTaskNextDelNextDel["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"], @@ -1265,8 +1257,8 @@ class Derivation "TAS_DEF_PROC_CODE" => $arrayTaskNextDelNextDel["NEXT_TASK"]["TAS_DEF_PROC_CODE"], "DEL_PRIORITY" => "", "TAS_PARENT" => $arrayTaskNextDelNextDel["NEXT_TASK"]["TAS_PARENT"], - "ROU_PREVIOUS_TYPE" => $rouPreType, - "ROU_PREVIOUS_TASK" => $rouPreTask + "ROU_PREVIOUS_TYPE" => isset($arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TYPE"]) ? $arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TYPE"] : '', + "ROU_PREVIOUS_TASK" => isset($arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TASK"]) ? $arrayTaskNextDelNextDel["NEXT_TASK"]["ROU_PREVIOUS_TASK"] : '' ); } @@ -1614,8 +1606,8 @@ class Derivation 'TAS_DEF_PROC_CODE' => $aDeriveTask['NEXT_TASK']['TAS_DEF_PROC_CODE'], 'DEL_PRIORITY' => 3, 'TAS_PARENT' => $aDeriveTask['NEXT_TASK']['TAS_PARENT'], - 'ROU_PREVIOUS_TYPE' => $aDeriveTask['NEXT_TASK']['ROU_PREVIOUS_TYPE'], - 'ROU_PREVIOUS_TASK' => $aDeriveTask['NEXT_TASK']['ROU_PREVIOUS_TASK'] + 'ROU_PREVIOUS_TYPE' => isset($aDeriveTask['NEXT_TASK']['ROU_PREVIOUS_TYPE']) ? $aDeriveTask['NEXT_TASK']['ROU_PREVIOUS_TYPE'] : '', + 'ROU_PREVIOUS_TASK' => isset($aDeriveTask['NEXT_TASK']['ROU_PREVIOUS_TASK']) ? $aDeriveTask['NEXT_TASK']['ROU_PREVIOUS_TASK'] : '' ); } $currentDelegation2 = array( diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index 0061dcb78..69ac27afa 100644 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -1900,22 +1900,6 @@ class PMPluginRegistry str_replace(["\n", "\r", "\t"], ' ', file_get_contents($path . $pluginFile)) ); } - - /** - * Use this for extensions - * - * @return array with namespace and plugin folder - */ - public function getEnabledPlugins() - { - $enabledPlugins = array(); - foreach ($this->_aPluginDetails as $row) { - if ($row->enabled) { - $enabledPlugins[$row->sNamespace] = $row->sPluginFolder; - } - } - return $enabledPlugins; - } /** * Registry in an array routes for js or css files. diff --git a/workflow/engine/classes/class.pmDynaform.php b/workflow/engine/classes/class.pmDynaform.php index a334cf880..5bfe623b6 100644 --- a/workflow/engine/classes/class.pmDynaform.php +++ b/workflow/engine/classes/class.pmDynaform.php @@ -823,6 +823,9 @@ class pmDynaform public function getDatabaseProvider($dbConnection) { + if ($dbConnection === "workflow" || $dbConnection === "rbac" || $dbConnection === "rp") { + return "mysql"; + } if ($this->databaseProviders === null) { $a = new Criteria("workflow"); $a->addSelectColumn(DbSourcePeer::DBS_UID); diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index c608d430b..21cd3f060 100644 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -2533,7 +2533,7 @@ function PMFRedirectToStep ($sApplicationUID, $iDelegation, $sStepType, $sStepUi * Returns a list of the next assigned users to a case. * * @name PMFGetNextAssignedUser - * @label PMFGet Next Assigned User + * @label PMF Get Next Assigned User * * @param string(32) | $application | Case ID | Id of the case * @param string(32) | $task | Task ID | Id of the task @@ -2598,7 +2598,7 @@ function PMFGetNextAssignedUser ($application, $task, $delIndex = null, $userUid * @label PMF Get User Email Address * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFGetUserEmailAddress.28.29 * - * @param string(32) or Array | $id | Case ID | Id of the case. + * @param string(32) or Array | $id | List of Recipients | which can be a mixture of user IDs, group IDs, variable names or email addresses * @param string(32) | $APP_UID = null | Application ID | Id of the Application. * @param string(32) | $prefix = "usr" | prefix | Id of the task. * @return array | $aRecipient | Array of the Recipient | Return an Array of the Recipient. diff --git a/workflow/engine/classes/class.wsBase.php b/workflow/engine/classes/class.wsBase.php index 7744da3b3..7399e15bc 100644 --- a/workflow/engine/classes/class.wsBase.php +++ b/workflow/engine/classes/class.wsBase.php @@ -2156,10 +2156,74 @@ class wsBase return $result; } } + /** + * Execute the trigger defined in the steps + * This function is used when the case is derived from abe, Soap, PMFDerivateCase + * + * @param array $appData contain all the information about the case + * @param string $tasUid + * @param string $stepType + * @param string $stepUidObj + * @param string $triggerType + * @param string $labelAssigment + * @return string $varTriggers + */ + function executeTriggerFromDerivate($appData, $tasUid, $stepType, $stepUidObj, $triggerType, $labelAssigment = '') + { + $varTriggers = ""; + $oCase = new Cases(); + + //Execute triggers before assignment + $aTriggers = $oCase->loadTriggers($tasUid, $stepType, $stepUidObj, $triggerType); + + if (count( $aTriggers ) > 0) { + $varTriggers = $varTriggers . "
".$labelAssigment."
"; + + $oPMScript = new PMScript(); + + foreach ($aTriggers as $aTrigger) { + //Set variables + $params = new stdClass(); + $params->appData = $appData; + + if ($this->stored_system_variables) { + $params->option = "STORED SESSION"; + $params->SID = $this->wsSessionId; + } + + $appFields["APP_DATA"] = array_merge($appData, G::getSystemConstants($params)); + + //PMScript + $oPMScript->setFields( $appFields['APP_DATA'] ); + $bExecute = true; + + if ($aTrigger['ST_CONDITION'] !== '') { + $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); + $bExecute = $oPMScript->evaluate(); + } + + if ($bExecute) { + $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); + $oPMScript->execute(); + + $trigger = TriggersPeer::retrieveByPk($aTrigger["TRI_UID"]); + $varTriggers = $varTriggers . " - " . nl2br(htmlentities($trigger->getTriTitle(), ENT_QUOTES)) . "
"; + + $appFields['APP_DATA'] = $oPMScript->aFields; + unset($appFields['APP_STATUS']); + unset($appFields['APP_PROC_STATUS']); + unset($appFields['APP_PROC_CODE']); + unset($appFields['APP_PIN']); + $oCase->updateCase($caseId, $appFields); + } + } + } + return $varTriggers; + } /** - * derivate Case moves the case to the next task in the process according to the routing rules - * + * Derivate Case moves the case to the next task in the process according to the routing rules + * This function is used from: action by email, web entry, PMFDerivateCase, Mobile * @param string $userId * @param string $caseId * @param string $delIndex @@ -2178,10 +2242,10 @@ class wsBase $_SESSION["INDEX"] = $delIndex; $_SESSION["USER_LOGGED"] = $userId; + //Define variables $sStatus = 'TO_DO'; - $varResponse = ''; - $varTriggers = "\n"; + $previousAppData = array(); if ($delIndex == '') { $oCriteria = new Criteria( 'workflow' ); @@ -2216,18 +2280,10 @@ class wsBase return $result; } - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( AppDelayPeer::APP_UID ); - $oCriteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX ); - $oCriteria->add( AppDelayPeer::APP_TYPE, '' ); - $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'PAUSE' )->addOr( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'CANCEL' ) ) ); - $oCriteria->addAscendingOrderByColumn( AppDelayPeer::APP_ENABLE_ACTION_DATE ); - $oDataset = AppDelayPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRow = $oDataset->getRow(); - - if (is_array( $aRow )) { + //Validate if the case is paused or cancelled + $oAppDelay = new AppDelay(); + $aRow = $oAppDelay->getCasesCancelOrPaused($caseId); + if (is_array($aRow)) { if (isset( $aRow['APP_DISABLE_ACTION_USER'] ) && $aRow['APP_DISABLE_ACTION_USER'] != 0 && isset( $aRow['APP_DISABLE_ACTION_DATE'] ) && $aRow['APP_DISABLE_ACTION_DATE'] != '') { $result = new wsResponse( 19, G::LoadTranslation( 'ID_CASE_IN_STATUS' ) . " " . $aRow['APP_TYPE'] ); @@ -2258,101 +2314,18 @@ class wsBase global $oPMScript; + if (isset($oPMScript->aFields['APPLICATION']) && ($oPMScript->aFields['APPLICATION'] != $caseId)) { + $previousAppData = $oPMScript->aFields; + } + + $varTriggers = "\n"; + //Execute triggers before assignment if ($bExecuteTriggersBeforeAssignment) { - //Execute triggers before assignment - $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 1, 'BEFORE' ); - - if (count( $aTriggers ) > 0) { - $varTriggers = $varTriggers . "
-= Before Assignment =-
"; - - $oPMScript = new PMScript(); - - foreach ($aTriggers as $aTrigger) { - //Set variables - $params = new stdClass(); - $params->appData = $appFields["APP_DATA"]; - - if ($this->stored_system_variables) { - $params->option = "STORED SESSION"; - $params->SID = $this->wsSessionId; - } - - $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); - - //PMScript - $oPMScript->setFields( $appFields['APP_DATA'] ); - $bExecute = true; - - if ($aTrigger['ST_CONDITION'] !== '') { - $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); - $bExecute = $oPMScript->evaluate(); - } - - if ($bExecute) { - $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); - $oPMScript->execute(); - - $trigger = TriggersPeer::retrieveByPk($aTrigger["TRI_UID"]); - $varTriggers = $varTriggers . " - " . nl2br(htmlentities($trigger->getTriTitle(), ENT_QUOTES)) . "
"; - - //$appFields = $oCase->loadCase( $caseId ); - $appFields['APP_DATA'] = $oPMScript->aFields; - unset($appFields['APP_STATUS']); - unset($appFields['APP_PROC_STATUS']); - unset($appFields['APP_PROC_CODE']); - unset($appFields['APP_PIN']); - $oCase->updateCase( $caseId, $appFields ); - } - } - } + $varTriggers .= $this->executeTriggerFromDerivate($appFields["APP_DATA"], $appdel['TAS_UID'], 'ASSIGN_TASK', -1, 'BEFORE', "-= Before Assignment =-"); } - //Execute triggers before derivation BEFORE_ROUTING - $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 2, 'BEFORE' ); - - if (count( $aTriggers ) > 0) { - $varTriggers .= "-= Before Derivation =-
"; - - $oPMScript = new PMScript(); - - foreach ($aTriggers as $aTrigger) { - //Set variables - $params = new stdClass(); - $params->appData = $appFields["APP_DATA"]; - - if ($this->stored_system_variables) { - $params->option = "STORED SESSION"; - $params->SID = $this->wsSessionId; - } - - $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); - - //PMScript - $oPMScript->setFields( $appFields['APP_DATA'] ); - $bExecute = true; - - if ($aTrigger['ST_CONDITION'] !== '') { - $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); - $bExecute = $oPMScript->evaluate(); - } - - if ($bExecute) { - $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); - $oPMScript->execute(); - - $oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] ); - $varTriggers .= " - " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "
"; - //$appFields = $oCase->loadCase( $caseId ); - $appFields['APP_DATA'] = $oPMScript->aFields; - unset($appFields['APP_STATUS']); - unset($appFields['APP_PROC_STATUS']); - unset($appFields['APP_PROC_CODE']); - unset($appFields['APP_PIN']); - //$appFields['APP_DATA']['APPLICATION'] = $caseId; - $oCase->updateCase( $caseId, $appFields ); - } - } - } + //Execute triggers before routing + $varTriggers .= $this->executeTriggerFromDerivate($appFields["APP_DATA"], $appdel['TAS_UID'], 'ASSIGN_TASK', -2, 'BEFORE', "-= Before Derivation =-"); $oDerivation = new Derivation(); if (!empty($tasks)) { @@ -2396,8 +2369,8 @@ class wsBase $nodeNext['TAS_DEF_PROC_CODE'] = $val['NEXT_TASK']['TAS_DEF_PROC_CODE']; $nodeNext['DEL_PRIORITY'] = $appdel['DEL_PRIORITY']; $nodeNext['TAS_PARENT'] = $val['NEXT_TASK']['TAS_PARENT']; - $nodeNext['ROU_CONDITION'] = $val['ROU_CONDITION']; - + $nodeNext['ROU_PREVIOUS_TYPE'] = (isset($val['NEXT_TASK']['ROU_PREVIOUS_TYPE'])) ? $val['NEXT_TASK']['ROU_PREVIOUS_TYPE'] : ''; + $nodeNext['ROU_PREVIOUS_TASK'] = (isset($val['NEXT_TASK']['ROU_PREVIOUS_TASK'])) ? $val['NEXT_TASK']['ROU_PREVIOUS_TASK'] : ''; $nextDelegations[] = $nodeNext; $varResponse = $varResponse . (($varResponse != '') ? ',' : '') . $val['NEXT_TASK']['TAS_TITLE'] . $usrasgdUserName; } @@ -2408,27 +2381,26 @@ class wsBase $appFields['TAS_UID'] = $derive['TAS_UID']; } - $row = array (); - $oCriteria = new Criteria( 'workflow' ); - $del = DBAdapter::getStringDelimiter(); - $oCriteria->addSelectColumn( RoutePeer::ROU_TYPE ); - $oCriteria->addSelectColumn( RoutePeer::ROU_NEXT_TASK ); - $oCriteria->add( RoutePeer::TAS_UID, $appdel['TAS_UID'] ); - $oDataset = TaskPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - - while ($aRow = $oDataset->getRow()) { - $row[] = array('ROU_TYPE' => $aRow['ROU_TYPE'], 'ROU_NEXT_TASK' => $aRow['ROU_NEXT_TASK']); - $oDataset->next(); - } + //Get from the route information the nextTask + $nextTaskUid = $appdel['TAS_UID']; + $nextRouteType = ''; + do { + $oRoute = new \Route(); + $nextRouteTask = $oRoute->getNextRouteByTask($nextTaskUid); + $prefix = ''; + if (isset($nextRouteTask['ROU_NEXT_TASK'])) { + $nextTaskUid = $nextRouteTask['ROU_NEXT_TASK']; + $nextRouteType = $nextRouteTask['ROU_TYPE']; + $prefix = substr($nextTaskUid, 0, 4); + } + } while ($prefix == 'gtg-'); $aCurrentDerivation = array ( 'APP_UID' => $caseId, 'DEL_INDEX' => $delIndex, 'APP_STATUS' => $sStatus, 'TAS_UID' => $appdel['TAS_UID'], - 'ROU_TYPE' => $row[0]['ROU_TYPE'] + 'ROU_TYPE' => $nextRouteType ); //We define some parameters in the before the derivation @@ -2436,66 +2408,19 @@ class wsBase $oDerivation->beforeDerivate( $aData, $nextDelegations, - $row[0]['ROU_TYPE'], + $nextRouteType, $aCurrentDerivation ); $appFields = $oCase->loadCase( $caseId ); - //Execute triggers after derivation - $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 2, 'AFTER' ); - - if (count( $aTriggers ) > 0) { - - //Set variables - $params = new stdClass(); - $params->appData = $appFields["APP_DATA"]; - - if ($this->stored_system_variables) { - $params->option = "STORED SESSION"; - $params->SID = $this->wsSessionId; - } - - $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); - - //PMScript - $oPMScript = new PMScript(); - $oPMScript->setFields( $appFields['APP_DATA'] ); - - $varTriggers .= "-= After Derivation =-
"; - - foreach ($aTriggers as $aTrigger) { - $bExecute = true; - - if ($aTrigger['ST_CONDITION'] !== '') { - $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); - $bExecute = $oPMScript->evaluate(); - } - - if ($bExecute) { - $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); - $oPMScript->execute(); - - $oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] ); - $varTriggers .= " - " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "
"; - //$appFields = $oCase->loadCase($caseId); - $appFields['APP_DATA'] = $oPMScript->aFields; - //$appFields['APP_DATA']['APPLICATION'] = $caseId; - //$appFields = $oCase->loadCase($caseId); - unset($appFields['APP_STATUS']); - unset($appFields['APP_PROC_STATUS']); - unset($appFields['APP_PROC_CODE']); - unset($appFields['APP_PIN']); - $oCase->updateCase( $caseId, $appFields ); - } - } - } + //Execute triggers after routing + $varTriggers .= $this->executeTriggerFromDerivate($appFields["APP_DATA"], $appdel['TAS_UID'], 'ASSIGN_TASK', -2, 'AFTER', "-= After Derivation =-"); $sFromName = ""; if ($userId != "") { $user = new Users(); - $arrayUserData = $user->load($userId); if (trim($arrayUserData["USR_EMAIL"]) == "") { @@ -2507,15 +2432,9 @@ class wsBase $oCase->sendNotifications( $appdel['TAS_UID'], $nextDelegations, $appFields['APP_DATA'], $caseId, $delIndex, $sFromName ); - //Save data - Start - //$appFields = $oCase->loadCase($caseId); - //$oCase->updateCase($caseId, $appFields); - //Save data - End - - $oProcess = new Process(); $oProcessFieds = $oProcess->Load( $appFields['PRO_UID'] ); - //here dubug mode in web entry + //here debug mode in web entry if (isset( $oProcessFieds['PRO_DEBUG'] ) && $oProcessFieds['PRO_DEBUG']) { @@ -2528,7 +2447,7 @@ class wsBase $res = $result->getPayloadArray(); - //now fill the array of AppDelegationPeer + //Now fill the array of AppDelegationPeer $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX ); $oCriteria->addSelectColumn( AppDelegationPeer::USR_UID ); @@ -2546,7 +2465,6 @@ class wsBase while ($oDataset->next()) { $aAppDel = $oDataset->getRow(); - $oUser = new Users(); try { @@ -2566,7 +2484,7 @@ class wsBase $taskName = ''; } - // execute events + //Execute events $eventPro = $_SESSION["PROCESS"]; $eventApp = $caseId; $eventInd = $aAppDel['DEL_INDEX']; @@ -2574,8 +2492,7 @@ class wsBase $oEvent = new Event(); $oEvent->createAppEvents( $eventPro, $eventApp, $eventInd, $eventTas ); - // end events - + //End events $currentUser = new stdClass(); $currentUser->userId = $aAppDel['USR_UID']; @@ -2592,6 +2509,10 @@ class wsBase $g->sessionVarRestore(); + if (!empty($previousAppData)) { + $oPMScript->aFields = $previousAppData; + } + return $res; } catch (Exception $e) { $result = new wsResponse( 100, $e->getMessage() ); diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index fa9bb02c1..d8e6bd482 100644 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -145,6 +145,13 @@ class workspaceTools $final = $stop - $start; CLI::logging("<*> Check Mafe Requirements Process took $final seconds.\n"); + $start = microtime(true); + CLI::logging("> Updating Triggers...\n"); + $this->updateTriggers(true, $lang); + $stop = microtime(true); + $final = $stop - $start; + CLI::logging("<*> Updating Triggers Process took $final seconds.\n"); + $start = microtime(true); CLI::logging("> Backup log files...\n"); $this->backupLogFiles(); @@ -2591,10 +2598,10 @@ class workspaceTools LEFT JOIN ' . $this->dbName . '.USERS ON CUR_USER.USR_UID = USERS.USR_UID LEFT JOIN ' . $this->dbName . '.TASK ON CUR_USER.TAS_UID = TASK.TAS_UID) USERS_VALUES SET - LPL.DEL_CURRENT_USR_USERNAME = USERS_VALUES.USR_USERNAME, - LPL.DEL_CURRENT_USR_FIRSTNAME = USERS_VALUES.USR_FIRSTNAME, - LPL.DEL_CURRENT_USR_LASTNAME = USERS_VALUES.USR_LASTNAME, - LPL.DEL_CURRENT_TAS_TITLE = USERS_VALUES.TAS_TITLE + LPL.DEL_CURRENT_USR_USERNAME = IFNULL(USERS_VALUES.USR_USERNAME, \'\'), + LPL.DEL_CURRENT_USR_FIRSTNAME = IFNULL(USERS_VALUES.USR_FIRSTNAME, \'\'), + LPL.DEL_CURRENT_USR_LASTNAME = IFNULL(USERS_VALUES.USR_LASTNAME, \'\'), + LPL.DEL_CURRENT_TAS_TITLE = IFNULL(USERS_VALUES.TAS_TITLE, \'\') WHERE LPL.APP_UID = USERS_VALUES.APP_UID'; $con = Propel::getConnection("workflow"); $stmt = $con->createStatement(); @@ -2613,6 +2620,7 @@ class workspaceTools $delaycriteria->addSelectColumn(AppCacheViewPeer::USR_UID); $delaycriteria->addSelectColumn(AppCacheViewPeer::APP_STATUS); $delaycriteria->addSelectColumn(AppCacheViewPeer::TAS_UID); + $delaycriteria->addSelectColumn(AppCacheViewPeer::DEL_DELEGATE_DATE); $delaycriteria->addJoin( AppCacheViewPeer::APP_UID, AppDelayPeer::APP_UID . ' AND ' . AppCacheViewPeer::DEL_INDEX . ' = ' . AppDelayPeer::APP_DEL_INDEX, Criteria::INNER_JOIN ); $delaycriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, "0", CRITERIA::EQUAL); @@ -3784,4 +3792,14 @@ class workspaceTools } } + /** + * Updating triggers + * @param $flagRecreate + * @param $lang + */ + public function updateTriggers($flagRecreate, $lang) + { + $this->initPropel(true); + $this->upgradeTriggersOfTables($flagRecreate, $lang); + } } diff --git a/workflow/engine/classes/model/AppDelay.php b/workflow/engine/classes/model/AppDelay.php index 56a4e5179..d2aa9dc85 100644 --- a/workflow/engine/classes/model/AppDelay.php +++ b/workflow/engine/classes/model/AppDelay.php @@ -112,5 +112,25 @@ class AppDelay extends BaseAppDelay return false; } } + + /** + * Verify if the case is Paused or cancelled + * + * @param $appUid string + * @return $oDataset array + */ + public function getCasesCancelOrPaused($appUid) + { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( AppDelayPeer::APP_UID ); + $oCriteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX ); + $oCriteria->add( AppDelayPeer::APP_UID, $appUid ); + $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'PAUSE' )->addOr( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'CANCEL' ) ) ); + $oCriteria->addAscendingOrderByColumn( AppDelayPeer::APP_ENABLE_ACTION_DATE ); + $oDataset = AppDelayPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + return $oDataset->getRow(); + } } diff --git a/workflow/engine/classes/model/Route.php b/workflow/engine/classes/model/Route.php index ff6775c6f..f50a24062 100644 --- a/workflow/engine/classes/model/Route.php +++ b/workflow/engine/classes/model/Route.php @@ -384,4 +384,23 @@ class Route extends BaseRoute $this->updateRouteOrder($accountsArray); } } + + /** + * Get the route for the specific task + * + * @param $tasUid string + * @return $nextRoute array + */ + public function getNextRouteByTask($tasUid) + { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( RoutePeer::ROU_TYPE ); + $oCriteria->addSelectColumn( RoutePeer::ROU_NEXT_TASK ); + $oCriteria->add( RoutePeer::TAS_UID, $tasUid ); + $oDataset = TaskPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $row = $oDataset->getRow(); + return (is_array($row)) ? $row : array(); + } } diff --git a/workflow/engine/methods/cases/casesSaveDataView.php b/workflow/engine/methods/cases/casesSaveDataView.php index 149b10ddc..1f0d77bf7 100644 --- a/workflow/engine/methods/cases/casesSaveDataView.php +++ b/workflow/engine/methods/cases/casesSaveDataView.php @@ -61,7 +61,7 @@ $_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] = count( $triggers ); $_SESSION['TRIGGER_DEBUG']['TIME'] = G::toUpper(G::loadTranslation('ID_AFTER')); if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) { - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); + $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE'); $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = $triggers; } diff --git a/workflow/engine/methods/cases/cases_Derivate.php b/workflow/engine/methods/cases/cases_Derivate.php index b7fee6e51..aa8daeb7d 100644 --- a/workflow/engine/methods/cases/cases_Derivate.php +++ b/workflow/engine/methods/cases/cases_Derivate.php @@ -100,7 +100,7 @@ try { //save trigger variables for debugger $_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof( $triggers ); $_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = G::toUpper(G::loadTranslation('ID_BEFORE')); - $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); + $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE'); $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers; $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_EXECUTION_TIME'] = $oCase->arrayTriggerExecutionTime; $arrayInfoTriggerExecutionTime = []; @@ -171,7 +171,7 @@ try { $_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof( $triggers ); $_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = G::toUpper(G::loadTranslation('ID_AFTER')); - $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); + $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE'); $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers; $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_EXECUTION_TIME'] = $oCase->arrayTriggerExecutionTime; $arrayInfoTriggerExecutionTimeAux = []; diff --git a/workflow/engine/methods/cases/cases_SaveData.php b/workflow/engine/methods/cases/cases_SaveData.php index 30c3e5cc7..1598396e8 100644 --- a/workflow/engine/methods/cases/cases_SaveData.php +++ b/workflow/engine/methods/cases/cases_SaveData.php @@ -166,7 +166,7 @@ try { $_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] = count( $triggers ); $_SESSION['TRIGGER_DEBUG']['TIME'] = G::toUpper(G::loadTranslation('ID_AFTER')); if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) { - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); + $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE'); $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = $triggers; $oProcess = new Process(); $oProcessFieds = $oProcess->Load( $_SESSION['PROCESS'] ); diff --git a/workflow/engine/methods/cases/cases_SaveDocument.php b/workflow/engine/methods/cases/cases_SaveDocument.php index f461fbec6..2cd53b388 100644 --- a/workflow/engine/methods/cases/cases_SaveDocument.php +++ b/workflow/engine/methods/cases/cases_SaveDocument.php @@ -90,7 +90,7 @@ $_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] = count($arrayTrigger); $_SESSION["TRIGGER_DEBUG"]["TIME"] = "AFTER"; if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { - $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = $case->getTriggerNames($arrayTrigger); + $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = array_column($arrayTrigger, 'TRI_TITLE'); $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = $arrayTrigger; } diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index 8c01c6b5d..4a79402f1 100644 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -209,7 +209,7 @@ if ($flagExecuteBeforeTriggers) { $_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] = count( $triggers ); $_SESSION['TRIGGER_DEBUG']['TIME'] = G::toUpper(G::loadTranslation('ID_BEFORE')); if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) { - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); + $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = array_column($triggers, 'TRI_TITLE'); $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = $triggers; } diff --git a/workflow/engine/methods/setup/pluginsChange.php b/workflow/engine/methods/setup/pluginsChange.php index 687fa4ef8..581f1de7b 100644 --- a/workflow/engine/methods/setup/pluginsChange.php +++ b/workflow/engine/methods/setup/pluginsChange.php @@ -21,8 +21,6 @@ * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ -include_once (PATH_TRUNK."/class.Build.php"); -use Build\Utils\ProcessMakerPhpBuilderHelper; // lets display the items $pluginFile = $_GET['id']; @@ -88,16 +86,6 @@ if ($handle = opendir( PATH_PLUGINS )) { } } closedir( $handle ); - - /** - * Calls PMExtensionClass Builder to include Plugins changes. - */ - $phpBuilder = new ProcessMakerPhpBuilderHelper(); - $phpBuilder->enabledExtensions = $oPluginRegistry->getEnabledPlugins(); - if (!empty($phpBuilder->enabledExtensions)) { - $phpBuilder->extension = true; - } - $phpBuilder->buildAll(); } //$oPluginRegistry->showArrays(); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index 0426def6b..5e0d328a7 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -944,6 +944,12 @@ class InputDocument //***Validating the file allowed extensions*** $res = \G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $arrayFileName[$i], $arrayFileTmpName[$i]); if ($res->status == 0) { + //The value of the variable "_label" is cleared because the file load failed. + //The validation of the die command should be improved. + if (isset($aData["APP_DATA"][$item . "_label"]) && !empty($aData["APP_DATA"][$item . "_label"])) { + unset($aData["APP_DATA"][$item . "_label"]); + $caseInstance->updateCase($appUid, $aData); + } $message = $res->message; \G::SendMessageText($message, "ERROR"); $backUrlObj = explode("sys" . SYS_SYS, $_SERVER['HTTP_REFERER']); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/EmailServer.php b/workflow/engine/src/ProcessMaker/BusinessModel/EmailServer.php index 3a88dfdc4..aa7e9e480 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/EmailServer.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/EmailServer.php @@ -473,13 +473,15 @@ class EmailServer $arrayResult[$arrayMailTestName[1]] = $this->testConnectionByStep($arrayDataAux); $arrayResult[$arrayMailTestName[1]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_VERIFYING_MAIL"); - if ((int)($arrayData["MESS_TRY_SEND_INMEDIATLY"]) == 1) { + if ((int)($arrayData["MESS_TRY_SEND_INMEDIATLY"]) == 1 && $arrayData['MAIL_TO'] != '') { $arrayResult[$arrayMailTestName[2]] = $this->testConnectionByStep($arrayData); $arrayResult[$arrayMailTestName[2]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"])); } break; case "PHPMAILER": - for ($step = 1; $step <= 5; $step++) { + $numSteps = ($arrayData['MAIL_TO'] != '') ? count($arrayPhpMailerTestName) : + count($arrayPhpMailerTestName) - 1; + for ($step = 1; $step <= $numSteps; $step++) { $arrayResult[$arrayPhpMailerTestName[$step]] = $this->testConnectionByStep($arrayData, $step); switch ($step) { diff --git a/workflow/engine/templates/cases/main.js b/workflow/engine/templates/cases/main.js index 0091081ce..a025d78aa 100644 --- a/workflow/engine/templates/cases/main.js +++ b/workflow/engine/templates/cases/main.js @@ -272,7 +272,6 @@ Ext.onReady(function(){ triggerStore = new Ext.data.GroupingStore({ reader: reader, - sortInfo:{field: 'name', direction: "ASC"}, groupField:'execution_time', groupDir: 'DESC', proxy: new Ext.data.HttpProxy({url: 'debug_triggers?r='+Math.random()}) diff --git a/workflow/engine/templates/processes/main.js b/workflow/engine/templates/processes/main.js index d5630ec97..f2580a500 100644 --- a/workflow/engine/templates/processes/main.js +++ b/workflow/engine/templates/processes/main.js @@ -388,7 +388,13 @@ Ext.onReady(function(){ exportImportProcessObjects('export'); } } - ] + ], + listeners: { + "click": function (obj, e) + { + obj.showMenu(); + } + } }; exportProcessOption = granularExportProcessOption; } else {