processmaker如何将Process无须登录的Web Entry改为必须登录并与CAS集成做单点的Web App
来源:互联网 发布:中兴笔试编程题 编辑:程序博客网 时间:2024/06/10 17:26
废话少说,直接上干货
修改$pm/workflow/engine/methods/processes/processes_webEntryGenerate.php,原来是:
<?phpglobal $G_FORM;$sPRO_UID = $oData->PRO_UID;$sTASKS = $oData->TASKS;$sDYNAFORM = $oData->DYNAFORM;$sWE_TYPE = $oData->WE_TYPE;$sWS_USER = $oData->WS_USER;$sWS_PASS = $oData->WS_PASS;$sWS_ROUNDROBIN = $oData->WS_ROUNDROBIN;$sWE_USR = $oData->WE_USR;$withWS = $sWE_TYPE == 'WS';G::LoadClass("system");try { $pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP; G::mk_dir ( $pathProcess, 0777 ); $oTask = new Task ( ); $TaskFields = $oTask->load ( $sTASKS ); $WE_EVN_UID = $oTask->getStartingEvent($sTASKS); if ($TaskFields['TAS_ASSIGN_TYPE'] != 'BALANCED') { throw (new Exception ( "The task '" . $TaskFields['TAS_TITLE'] . "' doesn't have a valid assignment type. The task needs to have a 'Cyclical Assignment'." )); } G::LoadClass ( 'tasks' ); $oTask = new Tasks ( ); $user = $oTask->assignUsertoTask ( $sTASKS ); if ($user == 0) { throw (new Exception ( "The task '" . $TaskFields['TAS_TITLE'] . "' doesn't have users." )); } if (G::is_https ()) $http = 'https://'; else $http = 'http://'; $sContent = ''; if ($withWS) { //creating sys.info; $SITE_PUBLIC_PATH = ''; if (file_exists ( $SITE_PUBLIC_PATH . '' )) {} //creating the first file require_once 'classes/model/Dynaform.php'; $oDynaform = new Dynaform ( ); $aDynaform = $oDynaform->load ( $sDYNAFORM ); $dynTitle = str_replace ( ' ', '_', str_replace ( '/', '_', $aDynaform['DYN_TITLE'] ) ); $sContent = "<?php\n"; $sContent .= "global \$_DBArray;\n"; $sContent .= "if (!isset(\$_DBArray)) {\n"; $sContent .= " \$_DBArray = array();\n"; $sContent .= "}\n"; $sContent .= "\$_SESSION['PROCESS'] = '" . $sPRO_UID . "';\n"; $sContent .= "\$_SESSION['CURRENT_DYN_UID'] = '" . $sDYNAFORM . "';\n"; $sContent .= "\$G_PUBLISH = new Publisher;\n"; $sContent .= "\$G_PUBLISH->AddContent('dynaform', 'xmlform', '" . $sPRO_UID . '/' . $sDYNAFORM . "', '', array(), '" . $dynTitle . 'Post.php' . "');\n"; $sContent .= "G::RenderPage('publish', 'blank');"; file_put_contents ( $pathProcess . $dynTitle . '.php', $sContent ); //creating the second file, the post file who receive the post form. $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl'; $template = new TemplatePower ( $pluginTpl ); $template->prepare (); $template->assign ( 'wsdlUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2' ); $template->assign ( 'wsUploadUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/upload' ); $template->assign ( 'processUid', $sPRO_UID ); $template->assign ( 'dynaformUid', $sDYNAFORM ); $template->assign ( 'taskUid', $sTASKS ); $template->assign ( 'wsUser', $sWS_USER ); $template->assign ( 'wsPass', 'md5:' . md5 ( $sWS_PASS ) ); $template->assign ( 'wsRoundRobin', $sWS_ROUNDROBIN ); if($sWE_USR == "2"){ $template->assign ( 'USR_VAR', "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;" ); } else { $template->assign ( 'USR_VAR', '$USR_UID = -1;' ); } $template->assign ( 'dynaform', $dynTitle ); $template->assign ( 'timestamp', date ( 'l jS \of F Y h:i:s A' ) ); $template->assign ( 'ws', SYS_SYS ); $template->assign ( 'version', System::getVersion() ); $fileName = $pathProcess . $dynTitle . 'Post.php'; file_put_contents ( $fileName, $template->getOutputContent () ); //creating the third file, only if this wsClient.php file doesn't exist. $fileName = $pathProcess . 'wsClient.php'; $pluginTpl = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . 'ws' . PATH_SEP . 'wsClient.php'; if ( file_exists ($fileName) ) { if( filesize($fileName) != filesize($pluginTpl) ){ @copy($fileName, $pathProcess . 'wsClient.php.bck'); @unlink($fileName); $template = new TemplatePower ( $pluginTpl ); $template->prepare (); file_put_contents ( $fileName, $template->getOutputContent () ); } } else { $template = new TemplatePower ( $pluginTpl ); $template->prepare (); file_put_contents ( $fileName, $template->getOutputContent () ); } require_once 'classes/model/Event.php'; $oEvent = new Event ( ); $aDataEvent = array(); $aDataEvent['EVN_UID'] = $WE_EVN_UID; //$oData->WE_EVN_UID; $aDataEvent['EVN_RELATED_TO'] = 'MULTIPLE'; $aDataEvent['EVN_ACTION'] = $sDYNAFORM; $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; $output = $oEvent->update($aDataEvent); //Show link $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; print $link; //print "\n<a href='$link' target='_new' > $link </a>"; } else { $G_FORM = new Form ( $sPRO_UID . '/' . $sDYNAFORM, PATH_DYNAFORM, SYS_LANG, false ); $G_FORM->action = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/cases_StartExternal.php'; $scriptCode = ''; $scriptCode = $G_FORM->render ( PATH_CORE . 'templates/' . 'xmlform' . '.html', $scriptCode ); $scriptCode = str_replace ( '/controls/', $http . $_SERVER['HTTP_HOST'] . '/controls/', $scriptCode ); $scriptCode = str_replace ( '/js/maborak/core/images/', $http . $_SERVER['HTTP_HOST'] . '/js/maborak/core/images/', $scriptCode ); //render the template $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentry.tpl'; $template = new TemplatePower ( $pluginTpl ); $template->prepare (); require_once 'classes/model/Step.php'; $oStep = new Step(); $sUidGrids = $oStep->lookingforUidGrids($sPRO_UID,$sDYNAFORM); $template->assign ( 'siteUrl', $http . $_SERVER['HTTP_HOST'] ); $template->assign ( 'sysSys', SYS_SYS ); $template->assign ( 'sysLang', SYS_LANG ); $template->assign ( 'sysSkin', SYS_SKIN ); $template->assign ( 'processUid', $sPRO_UID ); $template->assign ( 'dynaformUid', $sDYNAFORM ); $template->assign ( 'taskUid', $sTASKS ); $template->assign ( 'dynFileName', $sPRO_UID . '/' . $sDYNAFORM ); $template->assign ( 'formId', $G_FORM->id ); $template->assign ( 'scriptCode', $scriptCode ); if(sizeof($sUidGrids)>0){ foreach($sUidGrids as $k => $v){ $template->newBlock( 'grid_uids' ); $template->assign ( 'siteUrl', $http . $_SERVER['HTTP_HOST'] ); $template->assign ( 'gridFileName', $sPRO_UID . '/' . $v ); } } print_r ( '<textarea cols="70" rows="20">' . htmlentities ( str_replace ( '</body>', '</form></body>', str_replace ( '</form>', '', $template->getOutputContent () ) ) ) . '</textarea>' ); }} catch ( Exception $e ) { $G_PUBLISH = new Publisher ( ); $aMessage['MESSAGE'] = $e->getMessage (); $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); G::RenderPage ( 'publish', 'raw' );}改为:
<?phpglobal $G_FORM;$sPRO_UID = $oData->PRO_UID;$sTASKS = $oData->TASKS;$sDYNAFORM = $oData->DYNAFORM;$sWE_TYPE = $oData->WE_TYPE;$sWS_USER = $oData->WS_USER;$sWS_PASS = $oData->WS_PASS;$sWS_ROUNDROBIN = $oData->WS_ROUNDROBIN;$sWE_USR = $oData->WE_USR;$withWS = $sWE_TYPE == 'WS';G::LoadClass("system");try { $pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP; G::mk_dir ( $pathProcess, 0777 ); $oTask = new Task ( ); $TaskFields = $oTask->load ( $sTASKS ); $WE_EVN_UID = $oTask->getStartingEvent($sTASKS); if ($TaskFields['TAS_ASSIGN_TYPE'] != 'BALANCED') { throw (new Exception ( "The task '" . $TaskFields['TAS_TITLE'] . "' doesn't have a valid assignment type. The task needs to have a 'Cyclical Assignment'." )); } G::LoadClass ( 'tasks' ); $oTask = new Tasks ( ); $user = $oTask->assignUsertoTask ( $sTASKS ); if ($user == 0) { throw (new Exception ( "The task '" . $TaskFields['TAS_TITLE'] . "' doesn't have users." )); } if (G::is_https ()) $http = 'https://'; else $http = 'http://'; $sContent = ''; if ($withWS) { //creating sys.info; $SITE_PUBLIC_PATH = ''; if (file_exists ( $SITE_PUBLIC_PATH . '' )) {} //creating the first file require_once 'classes/model/Dynaform.php'; $oDynaform = new Dynaform ( ); $aDynaform = $oDynaform->load ( $sDYNAFORM ); $dynTitle = str_replace ( ' ', '_', str_replace ( '/', '_', $aDynaform['DYN_TITLE'] ) ); $sContent = "<?php\n"; ////////////////////////////////////////////////////////////////////////////////////////////// $sContent .= "if ( ! isset( \$_SESSION['SSOUSER_NAME'] ) ) {\n"; $sContent .= " require_once (\"CAS-1.3.2/CAS.php\");\n"; $sContent .= " require_once (\"CAS-1.3.2/config.php\");\n"; $sContent .= " phpCAS::client(CAS_VERSION_2_0, CAS_SERVER_IP, 8443, 'cas', false);\n"; $sContent .= " phpCAS::setNoCasServerValidation();\n"; $sContent .= " phpCAS::forceAuthentication();\n"; $sContent .= " if ( phpCAS::isAuthenticated() == true )\n"; $sContent .= " \$casAuth = CASAuthIsTrue;\n"; $sContent .= " \$_SESSION['SSOUSER_NAME'] = phpCAS::getUser();\n"; $sContent .= " \$_SESSION['SSOUSER_PASS'] = \$casAuth;\n"; $sContent .= "}\n\n"; ////////////////////////////////////////////////////////////////////////////////////////////// $sContent .= "global \$_DBArray;\n"; $sContent .= "if (!isset(\$_DBArray)) {\n"; $sContent .= " \$_DBArray = array();\n"; $sContent .= "}\n"; $sContent .= "\$_SESSION['PROCESS'] = '" . $sPRO_UID . "';\n"; $sContent .= "\$_SESSION['CURRENT_DYN_UID'] = '" . $sDYNAFORM . "';\n"; $sContent .= "\$G_PUBLISH = new Publisher;\n"; $sContent .= "\$G_PUBLISH->AddContent('dynaform', 'xmlform', '" . $sPRO_UID . '/' . $sDYNAFORM . "', '', array(), '" . $dynTitle . 'Post.php' . "');\n"; $sContent .= "G::RenderPage('publish', 'blank');"; file_put_contents ( $pathProcess . $dynTitle . '.php', $sContent ); //creating the second file, the post file who receive the post form. $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl'; $template = new TemplatePower ( $pluginTpl ); $template->prepare (); $template->assign ( 'wsdlUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2' ); $template->assign ( 'wsUploadUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/upload' ); $template->assign ( 'processUid', $sPRO_UID ); $template->assign ( 'dynaformUid', $sDYNAFORM ); $template->assign ( 'taskUid', $sTASKS ); $template->assign ( 'wsUser', $sWS_USER ); $template->assign ( 'wsPass', 'md5:' . md5 ( $sWS_PASS ) ); $template->assign ( 'wsRoundRobin', $sWS_ROUNDROBIN ); if($sWE_USR == "2"){ $template->assign ( 'USR_VAR', "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;" ); } else { $template->assign ( 'USR_VAR', '$USR_UID = -1;' ); } $template->assign ( 'dynaform', $dynTitle ); $template->assign ( 'timestamp', date ( 'l jS \of F Y h:i:s A' ) ); $template->assign ( 'ws', SYS_SYS ); $template->assign ( 'version', System::getVersion() ); $fileName = $pathProcess . $dynTitle . 'Post.php'; file_put_contents ( $fileName, $template->getOutputContent () ); //creating the third file, only if this wsClient.php file doesn't exist. $fileName = $pathProcess . 'wsClient.php'; $pluginTpl = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . 'ws' . PATH_SEP . 'wsClient.php'; if ( file_exists ($fileName) ) { if( filesize($fileName) != filesize($pluginTpl) ){ @copy($fileName, $pathProcess . 'wsClient.php.bck'); @unlink($fileName); $template = new TemplatePower ( $pluginTpl ); $template->prepare (); file_put_contents ( $fileName, $template->getOutputContent () ); } } else { $template = new TemplatePower ( $pluginTpl ); $template->prepare (); file_put_contents ( $fileName, $template->getOutputContent () ); } require_once 'classes/model/Event.php'; $oEvent = new Event ( ); $aDataEvent = array(); $aDataEvent['EVN_UID'] = $WE_EVN_UID; //$oData->WE_EVN_UID; $aDataEvent['EVN_RELATED_TO'] = 'MULTIPLE'; $aDataEvent['EVN_ACTION'] = $sDYNAFORM; $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; $output = $oEvent->update($aDataEvent); //Show link $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; print $link; //print "\n<a href='$link' target='_new' > $link </a>"; } else { $G_FORM = new Form ( $sPRO_UID . '/' . $sDYNAFORM, PATH_DYNAFORM, SYS_LANG, false ); $G_FORM->action = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/cases_StartExternal.php'; $scriptCode = ''; $scriptCode = $G_FORM->render ( PATH_CORE . 'templates/' . 'xmlform' . '.html', $scriptCode ); $scriptCode = str_replace ( '/controls/', $http . $_SERVER['HTTP_HOST'] . '/controls/', $scriptCode ); $scriptCode = str_replace ( '/js/maborak/core/images/', $http . $_SERVER['HTTP_HOST'] . '/js/maborak/core/images/', $scriptCode ); //render the template $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentry.tpl'; $template = new TemplatePower ( $pluginTpl ); $template->prepare (); require_once 'classes/model/Step.php'; $oStep = new Step(); $sUidGrids = $oStep->lookingforUidGrids($sPRO_UID,$sDYNAFORM); $template->assign ( 'siteUrl', $http . $_SERVER['HTTP_HOST'] ); $template->assign ( 'sysSys', SYS_SYS ); $template->assign ( 'sysLang', SYS_LANG ); $template->assign ( 'sysSkin', SYS_SKIN ); $template->assign ( 'processUid', $sPRO_UID ); $template->assign ( 'dynaformUid', $sDYNAFORM ); $template->assign ( 'taskUid', $sTASKS ); $template->assign ( 'dynFileName', $sPRO_UID . '/' . $sDYNAFORM ); $template->assign ( 'formId', $G_FORM->id ); $template->assign ( 'scriptCode', $scriptCode ); if(sizeof($sUidGrids)>0){ foreach($sUidGrids as $k => $v){ $template->newBlock( 'grid_uids' ); $template->assign ( 'siteUrl', $http . $_SERVER['HTTP_HOST'] ); $template->assign ( 'gridFileName', $sPRO_UID . '/' . $v ); } } print_r ( '<textarea cols="70" rows="20">' . htmlentities ( str_replace ( '</body>', '</form></body>', str_replace ( '</form>', '', $template->getOutputContent () ) ) ) . '</textarea>' ); }} catch ( Exception $e ) { $G_PUBLISH = new Publisher ( ); $aMessage['MESSAGE'] = $e->getMessage (); $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); G::RenderPage ( 'publish', 'raw' );}
注释之间的代码就是新加的,文件其他部分不用改。it's enough! 当然,要做到如此简单就实现,之前的准备工作(见processmaker在与cas做SSO集成时需要做的修改,)必须要做充分了!
- processmaker如何将Process无须登录的Web Entry改为必须登录并与CAS集成做单点的Web App
- 在 Web 项目中应用 Apache Shiro 并集成 CAS 单点登录
- 使用cas做单点登录,web.xml配置
- CZTZ-JavaEE Web应用开发平台介绍之四--与CAS单点登录集成
- 单点登录cas与权限管理框架shiro集成------普通web项目方式
- 单点登录cas与权限管理框架shiro集成------普通web项目方式
- processmaker在与cas做SSO集成时需要做的修改
- Web单点登录的实现
- 将CAS 单点登录协议由https改为http
- Web 单点登录系统 JA-SIG CAS
- java cas 单点登录web.xml配置
- Web 单点登录系统 JA-SIG CAS
- java cas 单点登录web.xml配置
- 将 Web 服务用于电子交易的单点登录
- cas 单点登录使用spring集成的ShaPasswordEncoder实现
- 单点登录cas的使用
- CAS的单点登录原理
- CAS 实现的单点登录
- dp+计数 poj-1037-A decorative fence
- 求质量分布均匀的n边形的重心
- 让AngelScript运行起来
- 2013 杭州赛区邀请赛
- 链表的头指针在函数里修改怎么没有用?
- processmaker如何将Process无须登录的Web Entry改为必须登录并与CAS集成做单点的Web App
- CSS实例(八):不用图片实现宽度、高度自定的圆角矩形
- APP STORE 付费验证(IAP)服务端验证全过程
- HDU1978How Many Ways 记忆化dfs+dp
- [企业开源系列]后起之秀Facebook凭什么挑战互联网霸主Google?
- [C语言]菜鸟一些理解—变量常量
- 3.5 字符串操作
- cocos2d-x for android:CCSprite 精灵动画
- XML 的 约束 :DTD 、 Schema