/** * @covers G::is_https * @todo Implement testIs_https(). */ public function testIs_https() { $this->assertFalse(G::is_https()); $_SERVERÍ„['HTTPS'] = ''; $this->assertFalse(G::is_https()); $_SERVER['HTTPS'] = 'on'; $this->assertTrue(G::is_https()); }
public function sendActionsByEmail($data) { try { // Validations try { if (!is_object($data)) { throw new Exception('The parameter $data is null.'); } if (!isset($data->TAS_UID)) { throw new Exception('The parameter $data->TAS_UID is null.'); } if (!isset($data->APP_UID)) { throw new Exception('The parameter $data->APP_UID is null.'); } if (!isset($data->DEL_INDEX)) { throw new Exception('The parameter $data->DEL_INDEX is null.'); } if (!isset($data->USR_UID)) { throw new Exception('The parameter $data->USR_UID is null.'); } if ($data->TAS_UID == '') { throw new Exception('The parameter $data->TAS_UID is empty.'); } if ($data->APP_UID == '') { throw new Exception('The parameter $data->APP_UID is empty.'); } if ($data->DEL_INDEX == '') { throw new Exception('The parameter $data->DEL_INDEX is empty.'); } if ($data->USR_UID == '') { throw new Exception('The parameter $data->USR_UID is empty.'); } } catch(Exception $e) { echo $e->getMessage().' Please contact to your system administrator.'; die; } G::LoadClass('pmFunctions'); $emailSetup = getEmailConfiguration(); if (!empty($emailSetup)) { require_once 'classes/model/AbeConfiguration.php'; G::LoadClass('case'); $cases = new Cases(); $caseFields = $cases->loadCase($data->APP_UID); $criteria = new Criteria(); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_UID); $criteria->addSelectColumn(AbeConfigurationPeer::PRO_UID); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TYPE); $criteria->addSelectColumn(AbeConfigurationPeer::TAS_UID); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TEMPLATE); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_DYN_TYPE); $criteria->addSelectColumn(AbeConfigurationPeer::DYN_UID); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_EMAIL_FIELD); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_ACTION_FIELD); $criteria->addSelectColumn(AbeConfigurationPeer::ABE_SUBJECT_FIELD); $criteria->addSelectColumn(DynaformPeer::DYN_CONTENT); $criteria->addJoin( AbeConfigurationPeer::DYN_UID, DynaformPeer::DYN_UID, Criteria::LEFT_JOIN ); $criteria->add(AbeConfigurationPeer::PRO_UID, $caseFields['PRO_UID']); $criteria->add(AbeConfigurationPeer::TAS_UID, $data->TAS_UID); $result = AbeConfigurationPeer::doSelectRS($criteria); $result->setFetchmode(ResultSet::FETCHMODE_ASSOC); $result->next(); if ($configuration = $result->getRow()) { $configuration['ABE_EMAIL_FIELD'] = str_replace('@@', '', $configuration['ABE_EMAIL_FIELD']); if ($configuration['ABE_EMAIL_FIELD'] != '' && isset($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']])) { $email = trim($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']]); } else { require_once 'classes/model/Users.php'; $userInstance = new Users(); $userInfo = $userInstance->getAllInformation($data->USR_UID); $email = $userInfo['mail']; } if ($email != '') { $subject = G::replaceDataField( $configuration['ABE_SUBJECT_FIELD'], $caseFields['APP_DATA'] ); if($subject == ''){ $subject = $caseFields['APP_TITLE']; } // Create require_once 'classes/model/AbeRequests.php'; $abeRequest = array(); $abeRequest['ABE_REQ_UID'] = ''; $abeRequest['ABE_UID'] = $configuration['ABE_UID']; $abeRequest['APP_UID'] = $data->APP_UID; $abeRequest['DEL_INDEX'] = $data->DEL_INDEX; $abeRequest['ABE_REQ_SENT_TO'] = $email; $abeRequest['ABE_REQ_SUBJECT'] = $subject; $abeRequest['ABE_REQ_BODY'] = ''; $abeRequest['ABE_REQ_ANSWERED'] = 0; $abeRequest['ABE_REQ_STATUS'] = 'PENDING'; try { $abeRequestsInstance = new AbeRequests(); $abeRequest['ABE_REQ_UID'] = $abeRequestsInstance->createOrUpdate($abeRequest); } catch (Exception $error) { throw $error; } if ($configuration['ABE_TYPE'] != '') { // Email $_SESSION['CURRENT_DYN_UID'] = $configuration['DYN_UID']; $scriptCode = ''; // foreach ($dynaform->fields as $fieldName => $field) { // if ($field->type == 'submit') { // unset($dynaform->fields[$fieldName]); // } // } $__ABE__ = ''; $link = (G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/ActionsByEmail'; switch ($configuration['ABE_TYPE']) { case 'LINK': // $__ABE__ .= $dynaform->render(PATH_FEATURES . 'actionsByEmail/xmlform.html', $scriptCode) . '<br />'; $__ABE__ .= '<a href="' . $link . 'DataForm?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&DYN_UID=' . G::encrypt($configuration['DYN_UID'], URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Please complete this form</a>'; break; // coment case 'FIELD': $variableService = new \ProcessMaker\Services\Api\Project\Variable(); $variables = $variableService->doGetVariables($caseFields['PRO_UID']); $field = new stdClass(); $field->label = 'Test'; $field->type = 'dropdown'; $field->options = array(); $actionField = str_replace('@@', '', $configuration['ABE_ACTION_FIELD']); $dynaform = $configuration['DYN_UID']; $variables = G::json_decode($configuration['DYN_CONTENT'], true); if(isset($variables['items'][0]['items'])){ $fields = $variables['items'][0]['items']; foreach ($fields as $key => $value) { foreach($value as $var){ G::pr($var); if(isset($var['variable'])){ if ($var['variable'] == $actionField) { $field->label = $var['label']; $field->type = $var['type']; $values = $var['options']; foreach ($values as $val){ $field->options[$val['value']] = $val['value']; } } } } } } G::LoadClass('pmDynaform'); $obj = new pmDynaform($configuration['DYN_UID']); $configuration['CURRENT_DYNAFORM'] = $configuration['DYN_UID']; $file = $obj->printPmDynaformAbe($configuration); $__ABE__ .= $file; $__ABE__ .= '<strong>' . $field->label . '</strong><br /><table align="left" border="0"><tr>'; switch ($field->type) { case 'dropdown': case 'radiogroup': $index = 1; $__ABE__.='<br /><td><table align="left" cellpadding="2"><tr>'; foreach ($field->options as $optValue => $optName) { $__ABE__ .= '<td align="center"><a style="text-decoration: none; color: #000; background-color: #E5E5E5; '; $__ABE__ .= 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#EFEFEF, endColorstr=#BCBCBC); '; $__ABE__ .= 'background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), #BCBCBC); '; $__ABE__ .= 'background-image: -webkit-linear-gradient(top, #EFEFEF, #BCBCBC); '; $__ABE__ .= 'background-image: -moz-linear-gradient(top, #EFEFEF, #BCBCBC); background-image: -ms-linear-gradient(top, #EFEFEF, #BCBCBC); '; $__ABE__ .= 'background-image: -o-linear-gradient(top, #EFEFEF, #BCBCBC); border: 1px solid #AAAAAA; '; $__ABE__ .= 'border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); '; $__ABE__ .= 'font-family: Arial,serif; font-size: 9pt; font-weight: 400; line-height: 14px; margin: 2px 0; padding: 2px 7px; '; $__ABE__ .= 'text-decoration: none; text-transform: capitalize;" href="' .urldecode(urlencode($link)). '?ACTION='.G::encrypt('processABE', URL_KEY).'&APP_UID='; $__ABE__ .= G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY); $__ABE__ .= '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($optValue, URL_KEY); $__ABE__ .= '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank" >' . $optName; $__ABE__ .= '</a></td>' . (($index % 5 == 0) ? '</tr><tr>' : ' '); $index++; } $__ABE__.='</tr></table></td>'; break; case 'yesno': $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)). '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(1, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_YES_VALUE') . '</a></td>'; $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)) . '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(0, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_NO_VALUE') . '</a></td>'; break; case 'checkbox': $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Check</a></td>'; $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Uncheck</a></td>'; break; } $__ABE__ .= '</tr></table>'; break; } $__ABE__ = preg_replace('/\<img src=\"\/js\/maborak\/core\/images\/(.+?)\>/', '' , $__ABE__); $__ABE__ = preg_replace('/\<input\b[^>]*\/>/', '' , $__ABE__); $__ABE__ = preg_replace('/<select\b[^>]*>(.*?)<\/select>/is', "", $__ABE__); $__ABE__ = preg_replace('/align=\"center\"/', '' , $__ABE__); $__ABE__ = preg_replace('/class="tableGrid_view" /', 'class="tableGrid_view" width="100%" ', $__ABE__); $caseFields['APP_DATA']['__ABE__'] = $__ABE__; G::LoadClass("Users"); $user = new Users(); $userDetails = $user->loadDetails($data->PREVIOUS_USR_UID); $emailFrom = $userDetails["USR_EMAIL"]; G::LoadClass('wsBase'); $wsBaseInstance = new wsBase(); $result = $wsBaseInstance->sendMessage($data->APP_UID, $emailFrom, $email, '', '', $subject, $configuration['ABE_TEMPLATE'], $caseFields['APP_DATA'], ''); $abeRequest['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR'); $body = ''; $messageSent = executeQuery('SELECT `APP_MSG_BODY` FROM `APP_MESSAGE` ORDER BY `APP_MSG_SEND_DATE` DESC LIMIT 1'); if (!empty($messageSent) && is_array($messageSent)) { $body = $messageSent[1]['APP_MSG_BODY']; } $abeRequest['ABE_REQ_BODY'] = $body; // Update try { $abeRequestsInstance = new AbeRequests(); $abeRequestsInstance->createOrUpdate($abeRequest); } catch (Exception $error) { throw $error; } } } } } } catch (Exception $error) { throw $error; } }
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(G::LoadTranslation('ID_TASK') . "'" . $TaskFields['TAS_TITLE'] . "'" . G::LoadTranslation('ID_NOT_HAVE_USERS')); } $http = G::is_https() ? "https://" : "http://"; $sContent = ''; $infoProcess = new Process(); $resultProcess = $infoProcess->load($sPRO_UID); 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";
* * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ /** * process_SchedulerValidate_User * validates if the username and password are valid data and if the user assigned * to the process and task has the rights and persmissions required to create a cron task */ $sWS_USER = trim($_REQUEST['USERNAME']); $sWS_PASS = trim($_REQUEST['PASSWORD']); if (G::is_https()) { $http = 'https://'; } else { $http = 'http://'; } $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; @($client = new SoapClient($endpoint)); $user = $sWS_USER; $pass = $sWS_PASS; $params = array('userid' => $user, 'password' => $pass); $result = $client->__SoapCall('login', array($params)); $fields['status_code'] = $result->status_code; $fields['message'] = 'ProcessMaker WebService version: ' . $result->version . "\n" . $result->message; $fields['version'] = $result->version; $fields['time_stamp'] = $result->timestamp; $messageCode = $result->message;
public function createMySQLWorkspace () { G::LoadSystem('inputfilter'); $filter = new InputFilter(); ini_set( 'max_execution_time', '0' ); $info = new StdClass(); $info->result = false; $info->message = ''; $info->canRedirect = true; $db_hostname = trim( $_REQUEST['db_hostname'] ); $db_port = trim( $_REQUEST['db_port'] ); $db_port = $filter->validateInput($db_port); $db_username = trim( $_REQUEST['db_username'] ); $db_username = $filter->validateInput($db_username); $db_password = trim( $_REQUEST['db_password'] ); $db_password = $filter->validateInput($db_password); $wf = trim( $_REQUEST['wfDatabase'] ); $rb = trim( $_REQUEST['wfDatabase'] ); $rp = trim( $_REQUEST['wfDatabase'] ); $workspace = trim( $_REQUEST['workspace'] ); $pathConfig = trim( $_REQUEST['pathConfig'] ); $pathLanguages = trim( $_REQUEST['pathLanguages'] ); $pathPlugins = trim( $_REQUEST['pathPlugins'] ); $pathShared = trim( $_REQUEST['pathShared'] ); $pathXmlforms = trim( $_REQUEST['pathXmlforms'] ); $adminPassword = trim( $_REQUEST['adminPassword'] ); $adminPassword = $filter->validateInput($adminPassword); $adminUsername = trim( $_REQUEST['adminUsername'] ); $adminUsername = $filter->validateInput($adminUsername); $deleteDB = ($_REQUEST['deleteDB'] == 'true'); $userLogged = (isset($_REQUEST['userLogged']) ? ($_REQUEST['userLogged'] == 'true') : false); $userLogged = $filter->validateInput($userLogged); if (substr( $pathShared, - 1 ) != '/') { $pathShared .= '/'; } $this->installLog( '-------------------------------------------' ); $this->installLog( G::LoadTranslation('ID_CREATING_WORKSPACE', SYS_LANG, Array($workspace))); try { $db_host = ($db_port != '' && $db_port != 3306) ? $db_hostname . ':' . $db_port : $db_hostname; $db_host = $filter->validateInput($db_host); $db_username = $filter->validateInput($db_username); $db_password = $filter->validateInput($db_password); $this->link = @mysql_connect( $db_host, $db_username, $db_password ); $this->installLog( G::LoadTranslation('ID_CONNECT_TO_SERVER', SYS_LANG, Array($db_hostname, $db_port, $db_username ) )); if ($deleteDB) { $q = sprintf( 'DROP DATABASE IF EXISTS %s;', $wf, $wf ); $this->mysqlQuery( $q ); } // CREATE databases wf_workflow, rb_workflow and rp_workflow $q = sprintf( 'CREATE DATABASE IF NOT EXISTS %s;', $wf, $wf ); $this->mysqlQuery( $q ); // CREATE users and GRANT Privileges $wf_workpace = $wf; $rb_workpace = $wf; $rp_workpace = $wf; if (!$userLogged) { $wfPass = G::generate_password( 12 ); $this->setGrantPrivilegesMySQL( $wf, $wfPass, $wf, $db_hostname ); $this->setGrantPrivilegesMySQL( $rb, $wfPass, $wf, $db_hostname ); $this->setGrantPrivilegesMySQL( $rp, $wfPass, $wf, $db_hostname ); } else { $wfPass = $db_password; $rbPass = $db_password; $rpPass = $db_password; $wf = $db_username; $rb = $db_username; $rp = $db_username; } // Generate the db.php file and folders $pathSharedSites = $pathShared; $path_site = $pathShared . "/sites/" . $workspace . "/"; $db_file = $path_site . "db.php"; @mkdir( $path_site, 0777, true ); @mkdir( $path_site . "files/", 0777, true ); @mkdir( $path_site . "mailTemplates/", 0777, true ); @mkdir( $path_site . "public/", 0777, true ); @mkdir( $path_site . "reports/", 0777, true ); @mkdir( $path_site . "xmlForms", 0777, true ); $dbText = "<?php\n"; $dbText .= sprintf( "// Processmaker configuration\n" ); $dbText .= sprintf( " define ('DB_ADAPTER', '%s' );\n", 'mysql' ); $dbText .= sprintf( " define ('DB_HOST', '%s' );\n", $db_host ); $dbText .= sprintf( " define ('DB_NAME', '%s' );\n", $wf_workpace ); $dbText .= sprintf( " define ('DB_USER', '%s' );\n", $wf ); $dbText .= sprintf( " define ('DB_PASS', '%s' );\n", $wfPass ); $dbText .= sprintf( " define ('DB_RBAC_HOST', '%s' );\n", $db_host ); $dbText .= sprintf( " define ('DB_RBAC_NAME', '%s' );\n", $wf_workpace ); $dbText .= sprintf( " define ('DB_RBAC_USER', '%s' );\n", $wf ); $dbText .= sprintf( " define ('DB_RBAC_PASS', '%s' );\n", $wfPass ); $dbText .= sprintf( " define ('DB_REPORT_HOST', '%s' );\n", $db_host ); $dbText .= sprintf( " define ('DB_REPORT_NAME', '%s' );\n", $wf_workpace ); $dbText .= sprintf( " define ('DB_REPORT_USER', '%s' );\n", $wf ); $dbText .= sprintf( " define ('DB_REPORT_PASS', '%s' );\n", $wfPass ); if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) { $dbText .= "\n"; $dbText .= " define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG')) ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG']:'false')) . ");\n"; if ($this->systemName != '') { $dbText .= " define ('SYSTEM_NAME', '" . $this->systemName . "');\n"; } } $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array($db_file) )); file_put_contents( $db_file, $dbText ); // Generate the databases.php file $databases_file = $path_site . 'databases.php'; $dbData = sprintf( "\$dbAdapter = '%s';\n", 'mysql' ); $dbData .= sprintf( "\$dbHost = '%s';\n", $db_host ); $dbData .= sprintf( "\$dbName = '%s';\n", $wf_workpace ); $dbData .= sprintf( "\$dbUser = '******';\n", $wf ); $dbData .= sprintf( "\$dbPass = '******';\n", $wfPass ); $dbData .= sprintf( "\$dbRbacHost = '%s';\n", $db_host ); $dbData .= sprintf( "\$dbRbacName = '%s';\n", $wf_workpace ); $dbData .= sprintf( "\$dbRbacUser = '******';\n", $wf ); $dbData .= sprintf( "\$dbRbacPass = '******';\n", $wfPass ); $dbData .= sprintf( "\$dbReportHost = '%s';\n", $db_host ); $dbData .= sprintf( "\$dbReportName = '%s';\n", $wf_workpace ); $dbData .= sprintf( "\$dbReportUser = '******';\n", $wf ); $dbData .= sprintf( "\$dbReportPass = '******';\n", $wfPass ); $databasesText = str_replace( '{dbData}', $dbData, @file_get_contents( PATH_HOME . 'engine/templates/installer/databases.tpl' ) ); $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array($databases_file) )); file_put_contents( $databases_file, $databasesText ); // Execute scripts to create and populates databases $query = sprintf( "USE %s;", $wf_workpace ); $this->mysqlQuery( $query ); $this->mysqlFileQuery( PATH_RBAC_HOME . 'engine/data/mysql/schema.sql' ); $this->mysqlFileQuery( PATH_RBAC_HOME . 'engine/data/mysql/insert.sql' ); $query = sprintf( "USE %s;", $wf_workpace ); $this->mysqlQuery( $query ); $this->mysqlFileQuery( PATH_HOME . 'engine/data/mysql/schema.sql' ); $this->mysqlFileQuery( PATH_HOME . 'engine/data/mysql/insert.sql' ); if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) { $this->setPartner(); //$this->setConfiguration(); } // Create the triggers if (file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql' )) { $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql' ) ); $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql' ) ); $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql' ) ); $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql' ) ); $this->mysqlQuery(@file_get_contents(PATH_HOME . "engine/methods/setup/setupSchemas/triggerSubApplicationInsert.sql")); $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql' ) ); $this->mysqlQuery( "INSERT INTO `CONFIGURATION` ( `CFG_UID`, `CFG_VALUE` ) VALUES ( 'APP_CACHE_VIEW_ENGINE', '" . mysql_real_escape_string( serialize( array ('LANG' => 'en','STATUS' => 'active' ) ) ) . "' )" ); $this->mysqlQuery("INSERT INTO EMAIL_SERVER(MESS_UID, MESS_ENGINE) VALUES('" . \ProcessMaker\Util\Common::generateUID() . "', 'MAIL')"); } // Change admin user $query = sprintf( "USE %s;", $wf_workpace ); $this->mysqlQuery( $query ); $query = sprintf( "UPDATE USERS SET USR_USERNAME = '******', USR_LASTNAME = '%s', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, $adminUsername, G::encryptOld( $adminPassword ) ); $this->mysqlQuery( $query ); $query = sprintf( "UPDATE RBAC_USERS SET USR_USERNAME = '******', USR_LASTNAME = '%s', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, $adminUsername, G::encryptOld( $adminPassword ) ); $this->mysqlQuery( $query ); // Write the paths_installed.php file (contains all the information configured so far) if (! file_exists( FILE_PATHS_INSTALLED )) { $sh = G::encryptOld( filemtime( PATH_GULLIVER . '/class.g.php' ) ); $h = G::encrypt( $db_hostname . $sh . $db_username . $sh . $db_password, $sh ); $dbText = "<?php\n"; $dbText .= sprintf( " define('PATH_DATA', '%s');\n", $pathShared ); $dbText .= sprintf( " define('PATH_C', '%s');\n", $pathShared . 'compiled/' ); $dbText .= sprintf( " define('HASH_INSTALLATION', '%s');\n", $h ); $dbText .= sprintf( " define('SYSTEM_HASH', '%s');\n", $sh ); $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array(FILE_PATHS_INSTALLED) )); file_put_contents( FILE_PATHS_INSTALLED, $dbText ); } /** * AppCacheView Build */ define( 'HASH_INSTALLATION', $h ); define( 'SYSTEM_HASH', $sh ); define( 'PATH_DB', $pathShared . 'sites' . PATH_SEP ); define( 'SYS_SYS', $workspace ); require_once ("propel/Propel.php"); Propel::init( PATH_CORE . "config/databases.php" ); $con = Propel::getConnection( 'workflow' ); require_once ('classes/model/AppCacheView.php'); $lang = 'en'; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles( PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP ); //Update APP_DELEGATION.DEL_LAST_INDEX data $res = $appCache->updateAppDelegationDelLastIndex($lang, true); //APP_DELEGATION INSERT $res = $appCache->triggerAppDelegationInsert( $lang, true ); //APP_DELEGATION Update $res = $appCache->triggerAppDelegationUpdate( $lang, true ); //APPLICATION UPDATE $res = $appCache->triggerApplicationUpdate( $lang, true ); //APPLICATION DELETE $res = $appCache->triggerApplicationDelete( $lang, true ); //SUB_APPLICATION INSERT $res = $appCache->triggerSubApplicationInsert($lang, false); //CONTENT UPDATE $res = $appCache->triggerContentUpdate( $lang, true ); //build using the method in AppCacheView Class $res = $appCache->fillAppCacheView( $lang ); //end AppCacheView Build //erik: for new env conf handling G::loadClass( 'system' ); $envFile = PATH_CONFIG . 'env.ini'; // getting configuration from env.ini $sysConf = System::getSystemConfiguration( $envFile ); $langUri = 'en'; if (isset($sysConf['default_lang'])) { $langUri = $sysConf['default_lang']; } $skinUri = 'neoclassic'; if (isset($sysConf['default_skin'])) { $skinUri = $sysConf['default_skin']; } $updatedConf['default_lang'] = $langUri; $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, $workspace, $langUri, $skinUri ); // inserting the outh_client if (!$userLogged) { $query = sprintf( "USE %s;", $wf ); } else { $query = sprintf( "USE %s;", trim( $_REQUEST['wfDatabase']) ); } $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); } else { try { G::update_php_ini( $envFile, $updatedConf ); } catch (Exception $e) { $info->result = false; $info->message = G::LoadTranslation('ID_PROCESSMAKER_WRITE_CONFIG_INDEX', SYS_LANG, Array($envFile)); $info->message .= G::LoadTranslation('ID_PROCESSMAKER_UI_NOT_INSTALL'); $this->installLog( G::LoadTranslation('ID_INSTALL_BUT_ERROR', SYS_LANG, Array('env.ini'))); return $info; } try { // update the main index file $indexFileUpdated = System::updateIndexFile(array('lang' => 'en','skin' => $updatedConf['default_skin'])); } catch (Exception $e) { $info->result = false; $info->message = G::LoadTranslation('ID_PROCESSMAKER_WRITE_CONFIG_INDEX', SYS_LANG, Array(PATH_HTML . "index.html.")); $info->message .= G::LoadTranslation('ID_PROCESSMAKER_UI_NOT_INSTALL'); $this->installLog( G::LoadTranslation('ID_INSTALL_BUT_ERROR', SYS_LANG, Array('index.html'))); return $info; } } $this->installLog( G::LoadTranslation('ID_INDEX_FILE_UPDATED', SYS_LANG, Array($indexFileUpdated, $sysConf['default_lang'],$sysConf['default_skin']))); $this->installLog( G::LoadTranslation('ID_INSTALL_SUCESS') ); $info->result = true; $info->message = G::LoadTranslation('ID_INSTALL_SUCESS'); $info->messageFinish = G::LoadTranslation('ID_PROCESSMAKER_SUCCESS_INSTALLED', SYS_LANG, Array($workspace));; } catch (Exception $e) { $info->canRedirect = false; $info->result = false; $info->message = $e->getMessage(); } return $info; }
/** * Function render * * @author David S. Callizaya S. <*****@*****.**> * @access public * @param string value * @return string */ public function render($value = null, $owner = null, $rowId = null, $row = -1, $therow = -1) { $permission = false; $url = null; switch ($owner->type) { case "xmlform": $pmtype = $this->NSFieldType(); break; case "grid": $pmtype = $this->NSGridType(); break; } if (isset($_SESSION["APPLICATION"]) && isset($_SESSION["USER_LOGGED"]) && isset($_SESSION["TASK"]) && isset($this->input) && $this->input != null && $this->mode == "view") { require_once "classes/model/AppDocument.php"; G::LoadClass("case"); $case = new Cases(); $arrayField = $case->loadCase($_SESSION["APPLICATION"]); $arrayPermission = $case->getAllObjects($arrayField["PRO_UID"], $_SESSION["APPLICATION"], $_SESSION["TASK"], $_SESSION["USER_LOGGED"]); $criteria = new Criteria(); $criteria->add(AppDocumentPeer::APP_DOC_UID, $arrayPermission["INPUT_DOCUMENTS"], Criteria::IN); switch ($owner->type) { case "xmlform": break; case "grid": $criteria->add(AppDocumentPeer::APP_DOC_FIELDNAME, $owner->name . "_" . $row . "_" . $this->name); break; } $criteria->addDescendingOrderByColumn(AppDocumentPeer::APP_DOC_CREATE_DATE); $rsCriteria = AppDocumentPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $sw = 0; while ($rsCriteria->next() && $sw == 0) { $row = $rsCriteria->getRow(); if ($row["DOC_UID"] == $this->input) { $permission = true; $url = (G::is_https() ? "https://" : "http://") . $_SERVER["HTTP_HOST"] . dirname($_SERVER["REQUEST_URI"]) . "/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"]; $sw = 1; } } } $html1 = null; $html2 = null; $mode = $this->mode == "view" ? " disabled=\"disabled\"" : null; $styleDisplay = null; if ($this->mode == "view") { if ($permission) { $html1 = "<a href=\"" . $url . "\"" . ($owner->type == "grid" ? " class=\"tableOption\" style=\"color: #006699; text-decoration: none; font-weight: normal;\"" : null) . ">"; $html2 = "</a>"; } $html1 = $html1 . $value; $styleDisplay = "display: none;"; } $html = $html1 . "<input type=\"file\" " . $pmtype . " id=\"form" . $rowId . "[" . $this->name . "]\" name=\"form" . $rowId . "[" . $this->name . "]\" value=\"" . $value . "\" class=\"module_app_input___gray_file\" style=\"" . $styleDisplay . "\"" . $mode . " " . $this->NSRequiredValue() . " />" . $html2; if (isset($this->input) && $this->input != null) { require_once "classes/model/InputDocument.php"; try { $indoc = new InputDocument(); $aDoc = $indoc->load($this->input); $aDoc["INP_DOC_TITLE"] = isset($aDoc["INP_DOC_TITLE"]) ? $aDoc["INP_DOC_TITLE"] : null; $html = $html . "<label><img src=\"/images/inputdocument.gif\" width=\"22px\" width=\"22px\" alt=\"\" /><font size=\"1\">(" . trim($aDoc["INP_DOC_TITLE"]) . ")</font></label>"; } catch (Exception $e) { //Then the input document doesn"t exits, id referencial broken $html = $html . " <font color=\"red\"><img src=\"/images/alert_icon.gif\" width=\"16px\" width=\"16px\" alt=\"\" /><font size=\"1\">(" . G::loadTranslation("ID_INPUT_DOC_DOESNT_EXIST") . ")</font></font>"; } } $html = $html . $this->renderHint(); return $html; }
/** * make_site * * @return array $test */ private function make_site() { $test = $this->create_site_test(); if ($test["created"] == true || $this->options["advanced"]["ao_db_drop"] == true) { /* Check if the hostname is local (localhost or 127.0.0.1) */ $islocal = (strcmp(substr($this->options['database']['hostname'], 0, strlen('localhost')), 'localhost') === 0) || (strcmp(substr($this->options['database']['hostname'], 0, strlen('127.0.0.1')), '127.0.0.1') === 0); $this->wf_site_name = $wf = $this->options['advanced']['ao_db_wf']; $this->rbac_site_name = $rb = $this->options['advanced']['ao_db_rb']; $this->report_site_name = $rp = $this->options['advanced']['ao_db_rp']; $schema = "schema.sql"; $values = "insert.sql"; if ($this->options['advanced']['ao_db_drop'] === true) { //Delete workspace directory if exists //Drop databases $this->run_query("DROP DATABASE IF EXISTS " . $wf, "Drop database $wf"); } $this->run_query("CREATE DATABASE IF NOT EXISTS " . $wf . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $wf"); if ($this->cc_status == 1) { $host = ($islocal) ? "localhost" : "%"; $this->run_query("GRANT ALL PRIVILEGES ON `$wf`.* TO $wf@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $wf on database $wf"); } /* Dump schema workflow && data */ $this->log("Import database schema:\n"); $myPortA = explode(":", $this->options['database']['hostname']); if (count($myPortA) < 2) { $myPortA[1] = "3306"; } $myPort = $myPortA[1]; $this->options['database']['hostname'] = $myPortA[0]; mysql_select_db($wf, $this->connection_database); $pws = PATH_WORKFLOW_MYSQL_DATA . $schema; $qws = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $schema, $this->connection_database); $this->log($qws, isset($qws['errors'])); $qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database); $this->log($qwv, isset($qwv['errors'])); $http = (G::is_https() == true) ? 'https' : 'http'; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : ''); $workspace = $this->options['name']; $endpoint = sprintf( '%s://%s/sys%s/%s/%s/oauth2/grant', $http, $host, $workspace, $lang, SYS_SKIN ); // inserting the outh_client $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->run_query( $query ); /* Dump schema rbac && data */ $pws = PATH_RBAC_MYSQL_DATA . $schema; mysql_select_db($rb, $this->connection_database); $qrs = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $schema, $this->connection_database); $this->log($qrs, isset($qrs['errors'])); $qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $values, $this->connection_database); $this->log($qrv, isset($qrv['errors'])); mysql_select_db($wf, $this->connection_database); require_once ("propel/Propel.php"); require_once ('classes/model/AppCacheView.php'); $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup/setupSchemas/'); $triggers = $appCache->getTriggers("en"); $this->log("Create 'cases list cache' triggers"); foreach ($triggers as $triggerName => $trigger) { $this->run_query($trigger, "-> Trigger $triggerName"); } $path_site = $this->options['path_data'] . "/sites/" . $this->options['name'] . "/"; $db_file = $path_site . "db.php"; @mkdir($path_site, 0777, true); @mkdir($path_site . "files/", 0777, true); @mkdir($path_site . "mailTemplates/", 0777, true); @mkdir($path_site . "public/", 0777, true); @mkdir($path_site . "reports/", 0777, true); @mkdir($path_site . "xmlForms", 0777, true); $db_text = "<?php\n" . "// Processmaker configuration\n" . "define ('DB_ADAPTER', 'mysql' );\n" . "define ('DB_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_NAME', '" . $wf . "' );\n" . "define ('DB_USER', '" . (($this->cc_status == 1) ? $wf : $this->options['database']['username']) . "' );\n" . "define ('DB_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_RBAC_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_RBAC_NAME', '" . $rb . "' );\n" . "define ('DB_RBAC_USER', '" . (($this->cc_status == 1) ? $rb : $this->options['database']['username']) . "' );\n" . "define ('DB_RBAC_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_REPORT_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_REPORT_NAME', '" . $rp . "' );\n" . "define ('DB_REPORT_USER', '" . (($this->cc_status == 1) ? $rp : $this->options['database']['username']) . "' );\n" . "define ('DB_REPORT_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n"; if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) { $db_text .= "define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG') && PARTNER_FLAG != '') ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG']:'false')) . ");\n"; if (defined('SYSTEM_NAME')) { $db_text .= " define ('SYSTEM_NAME', '" . SYSTEM_NAME . "');\n"; } } $db_text .="?>"; $fp = @fopen($db_file, "w"); $this->log("Create: " . $db_file . " => " . ((!$fp) ? $fp : "OK") . "\n", $fp === false); $ff = @fputs($fp, $db_text, strlen($db_text)); $this->log("Write: " . $db_file . " => " . ((!$ff) ? $ff : "OK") . "\n", $ff === false); fclose($fp); $this->setPartner(); $this->setAdmin(); $querySql = "INSERT INTO EMAIL_SERVER(MESS_UID, MESS_ENGINE) VALUES('" . \ProcessMaker\Util\Common::generateUID() . "', 'MAIL')"; $this->run_query($querySql); } return $test; }
public function listNewWebEntry($sProcessUID, $sEventUID) { try { global $G_PUBLISH; global $G_FORM; $G_PUBLISH = new Publisher(); require_once 'classes/model/Event.php'; $oEvent = new Event(); $arlink = ''; $oEvent = EventPeer::retrieveByPK($sEventUID); if (!is_null($oEvent)) { $oData = $oEvent->load($sEventUID); $dynTitle = ''; $dynUid = ''; $task_name = ''; $usr_uid_evn = $oEvent->getEvnConditions(); if ($oData['EVN_ACTION'] != '' && $oData['EVN_ACTION'] != 'WEB_ENTRY') { require_once 'classes/model/Content.php'; require_once 'classes/model/Task.php'; require_once 'classes/model/Dynaform.php'; $oContent = new Content(); $dynTitle = $oContent->load('DYN_TITLE', '', $oData['EVN_ACTION'], 'en'); $task_uid = $oEvent->getEvnTasUidTo(); $dyn = new Dynaform(); $dyn->load($oData['EVN_ACTION']); $dynUid = $dyn->getDynUid(); $task = new Task(); $task->load($task_uid); $task_name = $task->getTasTitle(); if (G::is_https()) { $http = 'https://'; } else { $http = 'http://'; } $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sProcessUID . '/'; $row = array(); $c = 0; /* $oTask = new Task ( ); $TaskFields = $oTask->kgetassigType ( $sProcessUID , $tas=''); */ $TaskFields['TAS_ASSIGN_TYPE'] = ''; //$row [] = array ('W_TITLE' => '', 'W_DELETE' => '', 'TAS_ASSIGN_TYPE' => $TaskFields ['TAS_ASSIGN_TYPE'] ); if (is_dir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID)) { $dir = opendir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID); $dynTitle = str_replace(' ', '_', str_replace('/', '_', $dynTitle)); $arlink = $link . $dynTitle . '.php'; //$arlink = "<a href='" . $alink . "' target='blank'><font color='#9999CC'>" . $alink . "</font></a>"; } } } $row = array('W_LINK' => $arlink, 'DYN_TITLE' => $dynTitle, 'TAS_TITLE' => $task_name, 'USR_UID' => $usr_uid_evn, 'DYN_UID' => $dynUid); // $oJSON = new Services_JSON ( ); // $tmpData = $oJSON->encode( $row ) ; // $tmpData = str_replace("\\/","/",'{success:true,data:'.$tmpData.'}'); // unescape the slashes // $result = $tmpData; $result = array(); $result['success'] = true; $result['data'] = $row; return $result; } catch (Exception $oError) { throw $oError; } }
function save($params) { require_once 'classes/model/Event.php'; global $G_FORM; $sPRO_UID = $params->pro_uid; $sEVN_UID = $params->evn_uid; $sDYNAFORM = $params->initDyna; $sWS_USER = trim($params->username); $sWS_PASS = trim($params->password); $sWS_ROUNDROBIN = ''; $sWE_USR = ''; $xDYNA = $params->dynaform; if ($xDYNA != '') { $pro_uid = $params->pro_uid; $filename = $xDYNA; $filename = $filename . '.php'; unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $pro_uid . PATH_SEP . $filename); unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $pro_uid . PATH_SEP . str_replace(".php", "Post", $filename) . ".php"); } //return $params; G::LoadClass("system"); $pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP; G::mk_dir($pathProcess, 0777); $oEvent = new Event(); $oEvent->load($sEVN_UID); $sTASKS = $oEvent->getEvnTasUidTo(); $oTask = new Task(); $oTask->load($sTASKS); $tas_title = $oTask->getTasTitle(); if (G::is_https()) { $http = 'https://'; } else { $http = 'http://'; } $sContent = ''; $SITE_PUBLIC_PATH = ''; if (file_exists($SITE_PUBLIC_PATH . '')) { } 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 exists. $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'] = $sEVN_UID; $aDataEvent['EVN_RELATED_TO'] = 'MULTIPLE'; $aDataEvent['EVN_ACTION'] = $sDYNAFORM; $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; $output = $oEvent->update($aDataEvent); $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; $this->success = true; $this->msg = G::LoadTranslation('ID_WEB_ENTRY_SUCCESS_NEW'); $this->W_LINK = $link; $this->TAS_TITLE = $tas_title; $this->DYN_TITLE = $dynTitle; $this->USR_UID = $sWS_USER; }
/** * Get data of a Web Entry from a record * * @param array $record Record * * return array Return an array with data Web Entry */ public function getWebEntryDataFromRecord(array $record) { try { if ($record["WE_METHOD"] == "WS") { $http = \G::is_https() ? "https://" : "http://"; $url = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $record["PRO_UID"]; $record["WE_DATA"] = $url . "/" . $record["WE_DATA"]; } $conf = new \Configurations(); $confEnvSetting = $conf->getFormats(); $dateTime = new \DateTime($record["WE_CREATE_DATE"]); $webEntryCreateDate = $dateTime->format($confEnvSetting["dateFormat"]); $webEntryUpdateDate = ""; if (!empty($record["WE_UPDATE_DATE"])) { $dateTime = new \DateTime($record["WE_UPDATE_DATE"]); $webEntryUpdateDate = $dateTime->format($confEnvSetting["dateFormat"]); } return array($this->getFieldNameByFormatFieldName("WE_UID") => $record["WE_UID"], $this->getFieldNameByFormatFieldName("TAS_UID") => $record["TAS_UID"], $this->getFieldNameByFormatFieldName("DYN_UID") => $record["DYN_UID"], $this->getFieldNameByFormatFieldName("USR_UID") => $record["USR_UID"] . "", $this->getFieldNameByFormatFieldName("WE_TITLE") => $record["WE_TITLE"] . "", $this->getFieldNameByFormatFieldName("WE_DESCRIPTION") => $record["WE_DESCRIPTION"] . "", $this->getFieldNameByFormatFieldName("WE_METHOD") => $record["WE_METHOD"], $this->getFieldNameByFormatFieldName("WE_INPUT_DOCUMENT_ACCESS") => (int) $record["WE_INPUT_DOCUMENT_ACCESS"], $this->getFieldNameByFormatFieldName("WE_DATA") => $record["WE_DATA"], $this->getFieldNameByFormatFieldName("WE_CREATE_USR_UID") => $record["WE_CREATE_USR_UID"], $this->getFieldNameByFormatFieldName("WE_UPDATE_USR_UID") => $record["WE_UPDATE_USR_UID"] . "", $this->getFieldNameByFormatFieldName("WE_CREATE_DATE") => $webEntryCreateDate, $this->getFieldNameByFormatFieldName("WE_UPDATE_DATE") => $webEntryUpdateDate); } catch (\Exception $e) { throw $e; } }
function checkCredentials($params) { require_once 'classes/model/Event.php'; require_once 'classes/model/Users.php'; require_once 'classes/model/TaskUser.php'; require_once 'classes/model/GroupUser.php'; $sPRO_UID = $params->PRO_UID; $sEVN_UID = $params->EVN_UID; $sWS_USER = trim($params->WS_USER); $sWS_PASS = trim($params->WS_PASS); if (G::is_https()) { $http = 'https://'; } else { $http = 'http://'; } $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; @($client = new SoapClient($endpoint)); $user = $sWS_USER; $pass = $sWS_PASS; $parameters = array('userid' => $user, 'password' => $pass); $result = $client->__SoapCall('login', array($parameters)); $fields['status_code'] = $result->status_code; $fields['message'] = 'ProcessMaker WebService version: ' . $result->version . "\n" . $result->message; $fields['version'] = $result->version; $fields['time_stamp'] = $result->timestamp; $messageCode = true; $message = $result->message; G::LoadClass('Task'); //G::LoadClass ( 'Event' ); G::LoadClass('User'); G::LoadClass('TaskUser'); G::LoadClass('Groupwf'); $event = new Event(); $event->load($sEVN_UID); $sTASKS = $event->getEvnTasUidTo(); $task = new Task(); $task->load($sTASKS); $sTASKS_SEL = $task->getTasTitle(); if (!class_exists('GroupUser')) { G::LoadClass('GroupUser'); } // if the user has been authenticated, then check if has the rights or // permissions to create the webentry if ($result->status_code == 0) { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(UsersPeer::USR_UID); $oCriteria->addSelectColumn(TaskUserPeer::USR_UID); $oCriteria->addSelectColumn(TaskUserPeer::TAS_UID); $oCriteria->addJoin(TaskUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $oCriteria->add(TaskUserPeer::TAS_UID, $sTASKS); $oCriteria->add(UsersPeer::USR_USERNAME, $sWS_USER); //$oCriteria->add(TaskUserPeer::TU_RELATION,1); $userIsAssigned = TaskUserPeer::doCount($oCriteria); // if the user is not assigned directly, maybe a have the task a group with the user if ($userIsAssigned < 1) { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(UsersPeer::USR_UID); $oCriteria->addJoin(UsersPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN); $oCriteria->addJoin(GroupUserPeer::GRP_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN); $oCriteria->add(TaskUserPeer::TAS_UID, $sTASKS); $oCriteria->add(UsersPeer::USR_USERNAME, $sWS_USER); $userIsAssigned = GroupUserPeer::doCount($oCriteria); if (!($userIsAssigned >= 1)) { $messageCode = false; $message = "The User \"" . $sWS_USER . "\" doesn't have the task \"" . $sTASKS_SEL . "\" assigned."; } } } else { $messageCode = false; } $this->success = $messageCode; $this->msg = $message; }
/** * Get data of a WebEntry-Event from a record * * @param array $record Record * * return array Return an array with data WebEntry-Event */ public function getWebEntryEventDataFromRecord(array $record) { try { if ($record["WEE_WE_UID"] . "" != "") { $http = \G::is_https() ? "https://" : "http://"; $url = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $record["PRJ_UID"]; $record["WEE_WE_URL"] = $url . "/" . $record["WEE_WE_URL"]; } return array($this->getFieldNameByFormatFieldName("WEE_UID") => $record["WEE_UID"], $this->getFieldNameByFormatFieldName("EVN_UID") => $record["EVN_UID"], $this->getFieldNameByFormatFieldName("ACT_UID") => $record["ACT_UID"], $this->getFieldNameByFormatFieldName("DYN_UID") => $record["DYN_UID"], $this->getFieldNameByFormatFieldName("USR_UID") => $record["USR_UID"], $this->getFieldNameByFormatFieldName("WEE_TITLE") => $record["WEE_TITLE"], $this->getFieldNameByFormatFieldName("WEE_DESCRIPTION") => $record["WEE_DESCRIPTION"] . "", $this->getFieldNameByFormatFieldName("WEE_URL") => $record["WEE_WE_URL"] . "", $this->getFieldNameByFormatFieldName("WEE_STATUS") => $record["WEE_STATUS"]); } catch (\Exception $e) { throw $e; } }
/** * User Login * * @param string $username Username * @param string $password Password * * return object Return object $response * $response->status_code, 0 when User has been authenticated, any number otherwise * $response->message, message */ public function userLogin($username, $password) { try { $http = \G::is_https() ? "https://" : "http://"; $client = new \SoapClient($http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/wsdl2"); $params = array("userid" => $username, "password" => Bootstrap::hashPassword($password, '', true)); $response = $client->login($params); return $response; } catch (\Exception $e) { throw $e; } }