function run_create_translation($args, $opts) { G::LoadSystem('inputfilter'); $filter = new InputFilter(); $opts = $filter->xssFilterHard($opts); $args = $filter->xssFilterHard($args); $rootDir = realpath(__DIR__."/../../../../"); $app = new Maveriks\WebApplication(); $app->setRootDir($rootDir); $loadConstants = false; $workspaces = get_workspaces_from_args($args); $lang = array_key_exists("lang", $opts) ? $opts['lang'] : 'en'; $translation = new Translation(); CLI::logging("Updating labels Mafe ...\n"); foreach ($workspaces as $workspace) { try { echo "Updating labels for workspace " . pakeColor::colorize($workspace->name, "INFO") . "\n"; $translation->generateTransaltionMafe($lang); } catch (Exception $e) { echo "Errors upgrading labels for workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"; } } CLI::logging("Create successful\n"); }
function run_flush_cache($args, $opts) { $rootDir = realpath(__DIR__."/../../../../"); $app = new Maveriks\WebApplication(); $app->setRootDir($rootDir); $loadConstants = false; $workspaces = get_workspaces_from_args($args); if (! defined("PATH_C")) { die("ERROR: seems processmaker is not properly installed (System constants are missing).".PHP_EOL); } CLI::logging("Flush ".pakeColor::colorize("system", "INFO")." cache ... "); G::rm_dir(PATH_C); G::mk_dir(PATH_C, 0777); echo "DONE" . PHP_EOL; foreach ($workspaces as $workspace) { echo "Flush workspace " . pakeColor::colorize($workspace->name, "INFO") . " cache ... "; G::rm_dir($workspace->path . "/cache"); G::mk_dir($workspace->path . "/cache", 0777); G::rm_dir($workspace->path . "/cachefiles"); G::mk_dir($workspace->path . "/cachefiles", 0777); echo "DONE" . PHP_EOL; } }
function run_database_generate_self_service_by_value($args, $opts) { G::LoadSystem('inputfilter'); $filter = new InputFilter(); $opts = $filter->xssFilterHard($opts); $args = $filter->xssFilterHard($args); try { $arrayWorkspace = get_workspaces_from_args($args); foreach ($arrayWorkspace as $value) { $workspace = $value; try { echo "Generating the table \"self-service by value\" for " . pakeColor::colorize($workspace->name, "INFO") . "\n"; $workspace->appAssignSelfServiceValueTableGenerateData(); } catch (Exception $e) { echo "Errors generating the table \"self-service by value\" of workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"; } echo "\n"; } echo "Done!\n"; } catch (Exception $e) { echo CLI::error($e->getMessage()) . "\n"; } }
function database_upgrade($command, $args) { $workspaces = get_workspaces_from_args($args); $checkOnly = strcmp($command, "check") == 0; foreach ($workspaces as $workspace) { if ($checkOnly) { print_r("Checking database in " . pakeColor::colorize($workspace->name, "INFO") . "\n"); } else { print_r("Upgrading database in " . pakeColor::colorize($workspace->name, "INFO") . "\n"); } try { $changes = $workspace->upgradeDatabase($checkOnly); if ($changes != false) { if ($checkOnly) { echo "> " . pakeColor::colorize("Run upgrade", "INFO") . "\n"; echo " Tables (add = " . count($changes['tablesToAdd']); echo ", alter = " . count($changes['tablesToAlter']) . ") "; echo "- Indexes (add = " . count($changes['tablesWithNewIndex']) . ""; echo ", alter = " . count($changes['tablesToAlterIndex']) . ")\n"; } else { echo "-> Schema fixed\n"; } } else { echo "> OK\n"; } } catch (Exception $e) { echo "> Error: " . CLI::error($e->getMessage()) . "\n"; } } }
function runStructureDirectories($command, $args) { $workspaces = get_workspaces_from_args($command); $count = count($workspaces); $errors = false; $countWorkspace = 0; foreach ($workspaces as $index => $workspace) { try { $countWorkspace++; CLI::logging("Updating workspaces ({$countWorkspace}/{$count}): " . CLI::info($workspace->name) . "\n"); $workspace->updateStructureDirectories($workspace->name); $workspace->close(); } catch (Exception $e) { CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); $errors = true; } } }
function run_upgrade($command, $args) { CLI::logging("UPGRADE", PROCESSMAKER_PATH . "upgrade.log"); CLI::logging("Checking files integrity...\n"); //setting flag to true to check into sysGeneric.php $flag = G::isPMUnderUpdating(1); //start to upgrade $checksum = System::verifyChecksum(); if ($checksum === false) { CLI::logging(CLI::error("checksum.txt not found, integrity check is not possible") . "\n"); if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) { CLI::logging("Upgrade failed\n"); $flag = G::isPMUnderUpdating(0); die; } } else { if (!empty($checksum['missing'])) { CLI::logging(CLI::error("The following files were not found in the installation:") . "\n"); foreach ($checksum['missing'] as $missing) { CLI::logging(" {$missing}\n"); } } if (!empty($checksum['diff'])) { CLI::logging(CLI::error("The following files have modifications:") . "\n"); foreach ($checksum['diff'] as $diff) { CLI::logging(" {$diff}\n"); } } if (!(empty($checksum['missing']) || empty($checksum['diff']))) { if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) { CLI::logging("Upgrade failed\n"); $flag = G::isPMUnderUpdating(0); die; } } } CLI::logging("Clearing cache...\n"); if (defined('PATH_C')) { G::rm_dir(PATH_C); G::mk_dir(PATH_C, 0777); } $workspaces = get_workspaces_from_args($command); $count = count($workspaces); $first = true; $errors = false; $countWorkspace = 0; $buildCacheView = array_key_exists("buildACV", $args); foreach ($workspaces as $index => $workspace) { if (!defined("SYS_SYS")) { define("SYS_SYS", $workspace->name); } if (!defined("PATH_DATA_SITE")) { define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP); } try { $countWorkspace++; CLI::logging("Upgrading workspaces ({$countWorkspace}/{$count}): " . CLI::info($workspace->name) . "\n"); $workspace->upgrade($first, $buildCacheView, $workspace->name); $workspace->close(); $first = false; } catch (Exception $e) { CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); $errors = true; } } // SAVE Upgrades/Patches $arrayPatch = glob(PATH_TRUNK . 'patch-*'); if ($arrayPatch) { foreach ($arrayPatch as $value) { if (file_exists($value)) { // copy content the patch $names = pathinfo($value); $nameFile = $names['basename']; $contentFile = file_get_contents($value); $contentFile = preg_replace("[\n|\r|\n\r]", '', $contentFile); CLI::logging($contentFile . ' installed (' . $nameFile . ')', PATH_DATA . 'log/upgrades.log'); // move file of patch $newFile = PATH_DATA . $nameFile; G::rm_dir($newFile); copy($value, $newFile); G::rm_dir($value); } } } else { CLI::logging('ProcessMaker ' . System::getVersion() . ' installed', PATH_DATA . 'log/upgrades.log'); } //Safe upgrade for JavaScript files CLI::logging("\nSafe upgrade for files cached by the browser\n\n"); G::browserCacheFilesSetUid(); //Status if ($errors) { CLI::logging("Upgrade finished but there were errors upgrading workspaces.\n"); CLI::logging(CLI::error("Please check the log above to correct any issues.") . "\n"); } else { CLI::logging("Upgrade successful\n"); } //setting flag to false $flag = G::isPMUnderUpdating(0); }
function run_upgrade($command, $args) { CLI::logging("UPGRADE", PROCESSMAKER_PATH . "upgrade.log"); CLI::logging("Checking files integrity...\n"); //setting flag to true to check into sysGeneric.php $flag = G::isPMUnderUpdating(1); //start to upgrade $checksum = System::verifyChecksum(); if ($checksum === false) { CLI::logging(CLI::error("checksum.txt not found, integrity check is not possible") . "\n"); if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) { CLI::logging("Upgrade failed\n"); die; } } else { if (!empty($checksum['missing'])) { CLI::logging(CLI::error("The following files were not found in the installation:") . "\n"); foreach ($checksum['missing'] as $missing) { CLI::logging(" {$missing}\n"); } } if (!empty($checksum['diff'])) { CLI::logging(CLI::error("The following files have modifications:") . "\n"); foreach ($checksum['diff'] as $diff) { CLI::logging(" {$diff}\n"); } } if (!(empty($checksum['missing']) || empty($checksum['diff']))) { if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) { CLI::logging("Upgrade failed\n"); die; } } } CLI::logging("Clearing cache...\n"); if (defined('PATH_C')) { rm_dir(PATH_C, true); } $workspaces = get_workspaces_from_args($command); $count = count($workspaces); $first = true; $errors = false; $buildCacheView = array_key_exists("buildACV", $args); foreach ($workspaces as $index => $workspace) { try { CLI::logging("Upgrading workspaces ({$index}/{$count}): " . CLI::info($workspace->name) . "\n"); $workspace->upgrade($first, $buildCacheView, $workspace->name); $workspace->close(); $first = false; } catch (Exception $e) { CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n"); $errors = true; } } if ($errors) { CLI::logging("Upgrade finished but there were errors upgrading workspaces.\n"); CLI::logging(CLI::error("Please check the log above to correct any issues.") . "\n"); } else { CLI::logging("Upgrade successful\n"); } //setting flag to false $flag = G::isPMUnderUpdating(0); }