public function remove($oauthClientId) { $cnn = Propel::getConnection(OauthClientsPeer::DATABASE_NAME); try { $oclient = OauthClientsPeer::retrieveByPK($oauthClientId); if (!is_null($oclient)) { $cnn->begin(); $result = $oclient->delete(); $cnn->commit(); return $result; } else { throw new Exception("The row \"{$oauthClientId}\" in table OAUTH_CLIENTS doesn't exist!"); } } catch (Exception $e) { $cnn->rollback(); throw $e; } }
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')) { $_CSERVER = $_SERVER; unset($_CSERVER['REQUEST_TIME']); unset($_CSERVER['REMOTE_PORT']); $cput = serialize($_CSERVER); file_put_contents(PATH_DATA . 'sites/' . $workspace . '/' . '.server_info', $cput); } 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', isset($SERVER_INFO['HTTP_ORIGIN']) ? $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'); } } }
public function registerPMDesignerClient() { $result = array(); try { $pmRestClient = OauthClientsPeer::retrieveByPK('x-pm-local-client'); if (!empty($pmRestClient)) { $pmRestClient->delete(); } $http = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; $lang = defined('SYS_LANG') ? SYS_LANG : 'en'; $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : ''); $endpoint = sprintf('%s://%s/sys%s/%s/%s/oauth2/grant', $http, $host, SYS_SYS, $lang, SYS_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(); $result['success'] = true; $result['message'] = ''; } catch (Exception $e) { $result['success'] = false; $result['message'] = $e->getMessage(); } return $result; }