diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 515b71a74..efca30abf 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -96,6 +96,13 @@ class workspaceTools $stop = microtime(true); $final = $stop - $start; CLI::logging("<*> Backup log files Process took $final seconds.\n"); + + $start = microtime(true); + CLI::logging("> check Mafe Requirements...\n"); + $this->checkMafeRequirements($workSpace, $lang); + $stop = microtime(true); + $final = $stop - $start; + CLI::logging("<*> Check Mafe Requirements Process took $final seconds.\n"); } /** @@ -1440,5 +1447,44 @@ class workspaceTools } } } + + public function checkMafeRequirements ($workspace,$lang) { + $this->initPropel(true); + $pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client'); + if (empty($pmRestClient)) { + if (is_file(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info')) { + $SERVER_INFO = file_get_contents(PATH_DATA . 'sites/' . $workspace . '/'.'.server_info'); + $SERVER_INFO = unserialize($SERVER_INFO); + + $envFile = PATH_CONFIG . 'env.ini'; + $skin ='neoclassic'; + if (file_exists($envFile) ) { + $sysConf = System::getSystemConfiguration($envFile); + $lang = $sysConf['default_lang']; + $skin = $sysConf['default_skin']; + } + + $endpoint = sprintf( + '%s/sys%s/%s/%s/oauth2/grant', + $SERVER_INFO['HTTP_ORIGIN'], + $workspace, + $lang, + $skin + ); + + $oauthClients = new OauthClients(); + $oauthClients->setClientId('x-pm-local-client'); + $oauthClients->setClientSecret('179ad45c6ce2cb97cf1029e212046e81'); + $oauthClients->setClientName('PM Web Designer'); + $oauthClients->setClientDescription('ProcessMaker Web Designer App'); + $oauthClients->setClientWebsite('www.processmaker.com'); + $oauthClients->setRedirectUri($endpoint); + $oauthClients->save(); + } else { + eprintln("WARNING! No server info found!", 'red'); + } + } + } + } diff --git a/workflow/engine/controllers/installer.php b/workflow/engine/controllers/installer.php index adb927283..133e472c5 100755 --- a/workflow/engine/controllers/installer.php +++ b/workflow/engine/controllers/installer.php @@ -862,6 +862,26 @@ class Installer extends Controller $updatedConf['default_skin'] = $skinUri; $info->uri = PATH_SEP . 'sys' . $_REQUEST['workspace'] . PATH_SEP . $langUri . PATH_SEP . $skinUri . PATH_SEP . 'login' . PATH_SEP . 'login'; + //register PMDesigner Client + $http = (G::is_https() == true) ? 'https' : 'http'; + $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : ''); + + $endpoint = sprintf( + '%s://%s/sys%s/%s/%s/oauth2/grant', + $http, + $host, + $wf, + $langUri, + $skinUri + ); + + // inserting the outh_client + $query = sprintf( "USE %s;", $wf ); + $this->mysqlQuery( $query ); + $query = ( "INSERT INTO OAUTH_CLIENTS (CLIENT_ID,CLIENT_SECRET,CLIENT_NAME,CLIENT_DESCRIPTION,CLIENT_WEBSITE,REDIRECT_URI,USR_UID ) VALUES + ('x-pm-local-client','179ad45c6ce2cb97cf1029e212046e81','PM Web Designer','ProcessMaker Web Designer App','www.processmaker.com','" . $endpoint . "','00000000000000000000000000000001' )"); + $this->mysqlQuery( $query ); + $indexFileUpdated = true; if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) { $this->buildParternExtras($adminUsername, $adminPassword, $_REQUEST['workspace'], $langUri, $skinUri);