/** * Get all properties of an Task * @var string $prj_uid. Uid for Process * @var string $act_uid. Uid for Activity * @var boolean $keyCaseToLower. Flag for case lower * * return object */ public function getProperties($prj_uid, $act_uid, $keyCaseToLower = false, $groupData = true) { try { $prj_uid = $this->validateProUid($prj_uid); $taskUid = $this->validateActUid($act_uid); //G::LoadClass("configuration"); require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.configuration.php"; $task = new \Task(); $arrayDataAux = $task->load($taskUid); //$arrayDataAux["INDEX"] = 0; //$arrayDataAux["IFORM"] = 1; //$arrayDataAux["LANG"] = SYS_LANG; //Assignment rules if ($arrayDataAux["TAS_ASSIGN_TYPE"] == "SELF_SERVICE") { $arrayDataAux["TAS_ASSIGN_TYPE"] = !empty($arrayDataAux["TAS_GROUP_VARIABLE"]) ? "SELF_SERVICE_EVALUATE" : $arrayDataAux["TAS_ASSIGN_TYPE"]; } //Timing control //Load Calendar Information $calendar = new \Calendar(); $calendarInfo = $calendar->getCalendarFor("", "", $taskUid); //If the function returns a DEFAULT calendar it means that this object doesn"t have assigned any calendar $arrayDataAux["TAS_CALENDAR"] = $calendarInfo["CALENDAR_APPLIED"] != "DEFAULT" ? $calendarInfo["CALENDAR_UID"] : ""; //Notifications $conf = new \Configurations(); $conf->loadConfig($x, "TAS_EXTRA_PROPERTIES", $taskUid, "", ""); $arrayDataAux["TAS_DEF_MESSAGE_TYPE"] = "text"; $arrayDataAux["TAS_DEF_MESSAGE_TEMPLATE"] = "alert_message.html"; if (isset($conf->aConfig["TAS_DEF_MESSAGE_TYPE"]) && isset($conf->aConfig["TAS_DEF_MESSAGE_TYPE"])) { $arrayDataAux["TAS_DEF_MESSAGE_TYPE"] = $conf->aConfig["TAS_DEF_MESSAGE_TYPE"]; $arrayDataAux["TAS_DEF_MESSAGE_TEMPLATE"] = $conf->aConfig["TAS_DEF_MESSAGE_TEMPLATE"]; } //Set data $arrayData = array(); $keyCase = $keyCaseToLower ? CASE_LOWER : CASE_UPPER; if (!$groupData) { $arrayData = array_change_key_case($arrayDataAux, $keyCase); return $arrayData; } //Definition $arrayData["DEFINITION"] = array_change_key_case(array("TAS_PRIORITY_VARIABLE" => $arrayDataAux["TAS_PRIORITY_VARIABLE"], "TAS_DERIVATION_SCREEN_TPL" => $arrayDataAux["TAS_DERIVATION_SCREEN_TPL"]), $keyCase); //Assignment Rules $arrayData["ASSIGNMENT_RULES"] = array_change_key_case(array("TAS_ASSIGN_TYPE" => $arrayDataAux["TAS_ASSIGN_TYPE"], "TAS_ASSIGN_VARIABLE" => $arrayDataAux["TAS_ASSIGN_VARIABLE"], "TAS_GROUP_VARIABLE" => $arrayDataAux["TAS_GROUP_VARIABLE"], "TAS_SELFSERVICE_TIMEOUT" => $arrayDataAux["TAS_SELFSERVICE_TIMEOUT"], "TAS_SELFSERVICE_TIME" => $arrayDataAux["TAS_SELFSERVICE_TIME"], "TAS_SELFSERVICE_TIME_UNIT" => $arrayDataAux["TAS_SELFSERVICE_TIME_UNIT"], "TAS_SELFSERVICE_TRIGGER_UID" => $arrayDataAux["TAS_SELFSERVICE_TRIGGER_UID"], "TAS_SELFSERVICE_EXECUTION" => $arrayDataAux["TAS_SELFSERVICE_EXECUTION"]), $keyCase); //Timing control $arrayData["TIMING_CONTROL"] = array_change_key_case(array("TAS_TRANSFER_FLY" => $arrayDataAux["TAS_TRANSFER_FLY"], "TAS_DURATION" => $arrayDataAux["TAS_DURATION"], "TAS_TIMEUNIT" => $arrayDataAux["TAS_TIMEUNIT"], "TAS_TYPE_DAY" => $arrayDataAux["TAS_TYPE_DAY"], "TAS_CALENDAR" => $arrayDataAux["TAS_CALENDAR"]), $keyCase); //Permissions $arrayData["PERMISSIONS"] = array_change_key_case(array("TAS_TYPE" => $arrayDataAux["TAS_TYPE"]), $keyCase); //Case Labels $arrayData["CASE_LABELS"] = array_change_key_case(array("TAS_DEF_TITLE" => $arrayDataAux["TAS_DEF_TITLE"], "TAS_DEF_DESCRIPTION" => $arrayDataAux["TAS_DEF_DESCRIPTION"]), $keyCase); //Notifications $arrayData["NOTIFICATIONS"] = array_change_key_case(array("SEND_EMAIL" => $arrayDataAux["TAS_SEND_LAST_EMAIL"], "TAS_DEF_SUBJECT_MESSAGE" => $arrayDataAux["TAS_DEF_SUBJECT_MESSAGE"], "TAS_DEF_MESSAGE_TYPE" => $arrayDataAux["TAS_DEF_MESSAGE_TYPE"], "TAS_DEF_MESSAGE" => $arrayDataAux["TAS_DEF_MESSAGE"], "TAS_DEF_MESSAGE_TEMPLATE" => $arrayDataAux["TAS_DEF_MESSAGE_TEMPLATE"]), $keyCase); $arrayData = array_change_key_case($arrayData, $keyCase); return $arrayData; } catch (Exception $e) { throw $e; } }
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = '') { try { $oConfiguration = new Configuration(); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails'); $oCriteria->add(ConfigurationPeer::OBJ_UID, ''); $oCriteria->add(ConfigurationPeer::PRO_UID, ''); $oCriteria->add(ConfigurationPeer::USR_UID, ''); $oCriteria->add(ConfigurationPeer::APP_UID, ''); if (ConfigurationPeer::doCount($oCriteria) == 0) { $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => '')); $aConfiguration = array(); } else { $aConfiguration = $oConfiguration->load('Emails', '', '', '', ''); if ($aConfiguration['CFG_VALUE'] != '') { $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]); $passwd = $aConfiguration["MESS_PASSWORD"]; $passwdDec = G::decrypt($passwd, "EMAILENCRYPT"); if (strpos($passwdDec, "hash:") !== false) { list($hash, $pass) = explode(":", $passwdDec); $passwd = $pass; } $aConfiguration["MESS_PASSWORD"] = $passwd; } else { $aConfiguration = array(); } } if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { return false; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($sCurrentTask); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } if ($sFrom == '') { $sFrom = '"ProcessMaker"'; } if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') { $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; } else { if ($aConfiguration['MESS_ENGINE'] == 'MAIL') { $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>'; } else { if ($aConfiguration['MESS_SERVER'] != '') { if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) { $sFrom .= ' <info@' . $sAux . '>'; } else { $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>'; } } else { $sFrom .= ' <*****@*****.**>'; } } } if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; if (isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE']) && $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') { $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP; $fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE']; if (!file_exists($fileTemplate)) { throw new Exception("Template file '{$fileTemplate}' does not exist."); } $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); } else { $sBody = nl2br(G::replaceDataField($aTaskInfo['TAS_DEF_MESSAGE'], $aFields)); } G::LoadClass('spool'); $oUser = new Users(); foreach ($aTasks as $aTask) { if (isset($aTask['USR_UID'])) { $aUser = $oUser->load($aTask['USR_UID']); $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; $oSpool = new spoolRun(); $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : '')); $oSpool->create(array('msg_uid' => '', 'app_uid' => $sApplicationUID, 'del_index' => $iDelegation, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending')); if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') { $oSpool->sendMail(); } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
public function getSystemDate($dateTime, $type='dateFormat') { $oConf = new Configurations(); $oConf->getFormats(); $dateFormat = $oConf->UserConfig['dateFormat']; $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); $creationDateMask = isset($oConf->aConfig[$type]) ? $oConf->aConfig[$type] : ''; $creationDateMask = ($creationDateMask == '') ? $dateFormat : $creationDateMask; if ($creationDateMask != '') { if (strpos($dateTime, ' ') !== false) { list ($date, $time) = explode(' ', $dateTime); list ($y, $m, $d) = explode('-', $date); list ($h, $i, $s) = explode(':', $time); $newCreation = ''; $maskTime = array('d' => '%d', 'D' => '%A', 'j' => '%d', 'l' => '%A', 'G' => '%I', 'g' => '%i', 'N' => '%u', 'S' => '%d', 'w' => '%w', 'z' => '%j', 'W' => '%W', 'F' => '%B', 'm' => '%m', 'M' => '%B', 'n' => '%m', 'o' => '%Y', 'Y' => '%Y', 'y' => '%g', 'a' => '%p', 'A' => '%p', 'g' => '%I', 'G' => '%H', 'h' => '%I', 'H' => '%H', 'i' => '%M', 's' => '%S'); $creationDateMask = trim($creationDateMask); if (strpos($creationDateMask, ' \\d\\e ') !== false) { $creationDateMask = str_replace(' \\d\\e ', ' [xx] ', $creationDateMask); } for ($j = 0; $j < strlen($creationDateMask); $j++) { if ($creationDateMask[$j] != ' ' && isset($maskTime[$creationDateMask[$j]])) { $newCreation .= $maskTime[$creationDateMask[$j]]; } else { $newCreation .= $creationDateMask[$j]; } } $langLocate = SYS_LANG; require_once 'model/Language.php'; $language = new language(); $lanLocation = $language->findLocationByLanId(SYS_LANG); $location = isset($lanLocation['LAN_LOCATION']) ? $lanLocation['LAN_LOCATION'] : ''; if (G::toLower(PHP_OS) == 'linux' || G::toLower(PHP_OS) == 'darwin') { if (SYS_LANG == 'es') { $langLocate = 'es_ES'; } else if (strlen(SYS_LANG) > 2) { $langLocate = str_replace('-', '_', SYS_LANG); } else if ($location != '') { $langLocate = SYS_LANG.'_'.$location; } else { $langLocate = 'en_US'; } } else { switch (SYS_LANG) { case 'es': case 'es_ES': $langLocate = 'ESN'; break; case 'pt': case 'pt-BR': $langLocate = 'PTB'; break; case 'en': case 'en-US': default: $langLocate = 'EST'; break; } } if (defined('PARTNER_FLAG')) { setlocale(LC_TIME, $langLocate); $dateTime = utf8_encode(strftime($newCreation, mktime($h, $i, $s, $m, $d, $y))); } else { setlocale(LC_TIME, $langLocate . ".utf8"); $dateTime = strftime($newCreation, mktime($h, $i, $s, $m, $d, $y)); } if (strpos($dateTime, ' ') !== false) { $dateTime = ucwords($dateTime); } if (strpos($dateTime, ' [xx] ') !== false) { $dateTime = str_replace('[xx]', ' de ', $dateTime); } } } return $dateTime; }
global $_DBArray; $_DBArray ['langOptions'] = $availableLangArray; G::LoadClass('configuration'); //BootStrap::LoadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); $myUrl = explode("/", $_SERVER["REQUEST_URI"]); if (isset($myUrl) && $myUrl != "") { $aFields["USER_LANG"] = $myUrl[2]; } else { $aFields["USER_LANG"] = isset($oConf->aConfig["login_defaultLanguage"])? $oConf->aConfig["login_defaultLanguage"] : SYS_LANG;
/** * It Renders content according to Part['Type'] * * @author Fernando Ontiveros Lira <*****@*****.**> * * @param intPos = 0 * @return void * */ public function RenderContent0($intPos = 0, $showXMLFormName = false) { global $G_FORM; global $G_TABLE; global $G_TMP_TARGET; global $G_OP_MENU; global $G_IMAGE_FILENAME; global $G_IMAGE_PARTS; global $_SESSION; //Changed from $HTTP_SESSION_VARS global $G_OBJGRAPH; //For graphLayout component $this->intPos = $intPos; $Part = $this->Parts[$intPos]; $this->publishType = $Part['Type']; switch ($this->publishType) { case 'externalContent': $G_CONTENT = new Content(); if ($Part['Content'] != "") { $G_CONTENT = G::LoadContent($Part['Content']); } G::LoadTemplateExternal($Part['Template']); break; case 'image': $G_IMAGE_FILENAME = $Part['File']; $G_IMAGE_PARTS = $Part['Data']; break; case 'appform': global $APP_FORM; $G_FORM = $APP_FORM; break; case 'xmlform': case 'dynaform': global $G_FORM; if ($Part['AbsolutePath']) { $sPath = $Part['AbsolutePath']; } else { if ($this->publishType == 'xmlform') { $sPath = PATH_XMLFORM; } else { $sPath = PATH_DYNAFORM; } } //if the xmlform file doesn't exists, then try with the plugins folders if (!is_file($sPath . $Part['File'] . '.xml')) { $aux = explode(PATH_SEP, $Part['File']); //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment if (count($aux) > 2) { //Subfolders $filename = array_pop($aux); $aux0 = implode(PATH_SEP, $aux); $aux = array(); $aux[0] = $aux0; $aux[1] = $filename; } if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($response = $oPluginRegistry->isRegisteredFolder($aux[0])) { if ($response !== true) { $sPath = PATH_PLUGINS . $response . PATH_SEP; } else { $sPath = PATH_PLUGINS; } } } } if (!class_exists($Part['Template']) || $Part['Template'] === 'xmlform') { $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, false); } else { eval('$G_FORM = new ' . $Part['Template'] . ' ( $Part[\'File\'] , "' . $sPath . '");'); } if ($this->publishType == 'dynaform' && ($Part['Template'] == 'xmlform' || $Part['Template'] == 'xmlform_preview')) { $dynaformShow = isset($G_FORM->printdynaform) && $G_FORM->printdynaform ? 'gulliver/dynaforms_OptionsPrint' : 'gulliver/dynaforms_Options'; $G_FORM->fields = G::array_merges(array('__DYNAFORM_OPTIONS' => new XmlForm_Field_XmlMenu(new Xml_Node('__DYNAFORM_OPTIONS', 'complete', '', array('type' => 'xmlmenu', 'xmlfile' => $dynaformShow, 'parentFormId' => $G_FORM->id)), SYS_LANG, PATH_XMLFORM, $G_FORM)), $G_FORM->fields); } //Needed to make ajax calls //The action in the form tag. if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->action = urlencode(G::encrypt($Part['Target'], URL_KEY)); } else { $G_FORM->action = $Part['Target']; } if (!(isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '')) { if ($this->publishType == 'dynaform') { $Part['ajaxServer'] = '../gulliver/defaultAjaxDynaform'; } else { $Part['ajaxServer'] = '../gulliver/defaultAjax'; } } if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } $G_FORM->setValues($Part['Data']); $G_FORM->setValues(array('G_FORM_ID' => $G_FORM->id)); //Asegurese de que no entre cuando $Part['Template']=="grid" //de hecho soo deberia usarse cuando $Part['Template']=="xmlform" if ($this->publishType == 'dynaform' && $Part['Template'] == "xmlform" || $Part['Template'] == "xmlform") { $G_FORM->values = G::array_merges(array('__DYNAFORM_OPTIONS' => isset($Part['Data']['__DYNAFORM_OPTIONS']) ? $Part['Data']['__DYNAFORM_OPTIONS'] : ''), $G_FORM->values); if (isset($G_FORM->nextstepsave)) { switch ($G_FORM->nextstepsave) { // this condition validates if the next step link is configured to Save and Go the next step or show a prompt case 'save': // Save and Next only if there are no required fields can submit the form. $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {document.getElementById("' . $G_FORM->id . '").submit();}return false;'; break; case 'prompt': // Show Prompt only if there are no required fields can submit the form. $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {if(dynaFormChanged(document.getElementsByTagName(\'form\').item(0))) {new leimnud.module.app.confirm().make({label:"@G::LoadTranslation(ID_DYNAFORM_SAVE_CHANGES)", action:function(){document.getElementById("' . $G_FORM->id . '").submit();}.extend(this), cancel:function(){window.location = getField("DYN_FORWARD").href;}.extend(this)});return false;} else {window.location = getField("DYN_FORWARD").href;return false;}}return false;'; break; } } } if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } // by default load the core template if ($Part['Template'] == 'xmlform_preview') { $Part['Template'] = 'xmlform'; } $template = PATH_CORE . 'templates/' . $Part['Template'] . '.html'; //erik: new feature, now templates such as xmlform.html can be personalized via skins if (defined('SYS_SKIN') && strtolower(SYS_SKIN) != 'classic') { // First, verify if the template exists on Custom skins path if (is_file(PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { $template = PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; //Second, verify if the template exists on base skins path } elseif (is_file(G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { $template = G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; } } //end new feature if ($Part['Template'] == 'grid') { print '<form class="formDefault">'; } $scriptCode = ''; if ($this->localMode != '') { // @# las modification by erik in 09/06/2008 $G_FORM->mode = $this->localMode; } print $G_FORM->render($template, $scriptCode); if ($Part['Template'] == 'grid') { print '</form>'; } $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addScriptFile($G_FORM->scriptURL); $oHeadPublisher->addScriptCode($scriptCode); /** * We've implemented the conditional show hide fields.. * * @author Erik A. Ortiz <*****@*****.**> * @date Fri Feb 19, 2009 */ if ($this->publishType == 'dynaform') { if (isset($_SESSION['CURRENT_DYN_UID']) || isset($_SESSION['CONDITION_DYN_UID'])) { require_once "classes/model/FieldCondition.php"; $oFieldCondition = new FieldCondition(); //This dynaform has show/hide field conditions if (isset($_SESSION['CURRENT_DYN_UID']) && $_SESSION['CURRENT_DYN_UID'] != '') { $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CURRENT_DYN_UID"]); //lsl } else { if (isset($_SESSION['CONDITION_DYN_UID']) && $_SESSION['CONDITION_DYN_UID'] != '') { $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CONDITION_DYN_UID"]); //lsl } } } } if (isset($ConditionalShowHideRoutines) && $ConditionalShowHideRoutines) { G::evalJScript($ConditionalShowHideRoutines); } break; case 'pagedtable': global $G_FORM; //if the xmlform file doesn't exists, then try with the plugins folders $sPath = PATH_XMLFORM; if (!is_file($sPath . $Part['File'])) { $aux = explode(PATH_SEP, $Part['File']); if (count($aux) == 2) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; } } } $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true); if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } $G_FORM->setValues($Part['Data']); if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } G::LoadSystem('pagedTable'); $oTable = new pagedTable(); $oTable->template = 'templates/' . $Part['Template'] . '.html'; $G_FORM->xmlform = ''; $G_FORM->xmlform->fileXml = $G_FORM->fileName; $G_FORM->xmlform->home = $G_FORM->home; $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; $G_FORM->values = array_merge($G_FORM->values, $Part['Data']); $oTable->setupFromXmlform($G_FORM); if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') { $oTable->ajaxServer = $Part['ajaxServer']; } /* Start Block: Load user configuration for the pagedTable */ G::LoadClass('configuration'); $objUID = $Part['File']; $conf = new Configurations(); $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', ''); $oTable->__OBJ_UID = $objUID; /* End Block */ /* Start Block: PagedTable Right Click */ G::LoadClass('popupMenu'); $pm = new popupMenu('gulliver/pagedTable_PopupMenu'); $pm->name = $oTable->id; $fields = array_keys($oTable->fields); foreach ($fields as $f) { switch (strtolower($oTable->fields[$f]['Type'])) { case 'javascript': case 'button': case 'private': case 'hidden': case 'cellmark': break; default: $label = $oTable->fields[$f]['Label'] != '' ? $oTable->fields[$f]['Label'] : $f; $label = str_replace("\n", ' ', $label); $pm->fields[$f] = new XmlForm_Field_popupOption(new Xml_Node($f, 'complete', '', array('label' => $label, 'type' => 'popupOption', 'launch' => $oTable->id . '.showHideField("' . $f . '")'))); $pm->values[$f] = ''; } } $sc = ''; $pm->values['PAGED_TABLE_ID'] = $oTable->id; print $pm->render(PATH_CORE . 'templates/popupMenu.html', $sc); /* End Block */ $oTable->renderTable(); /* Start Block: Load PagedTable Right Click */ print '<script type="text/javascript">'; print $sc; print 'loadPopupMenu_' . $oTable->id . '();'; print '</script>'; /* End Block */ break; case 'propeltable': global $G_FORM; //if the xmlform file doesn't exists, then try with the plugins folders if ($Part['AbsolutePath']) { $sPath = ''; } else { $sPath = PATH_XMLFORM; } if (!is_file($sPath . $Part['File'])) { $aux = explode(PATH_SEP, $Part['File']); //search in PLUGINS folder, probably the file is in plugin if (count($aux) == 2) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; } } //search in PATH_DYNAFORM folder if (!is_file($sPath . PATH_SEP . $Part['File'] . '.xml')) { $sPath = PATH_DYNAFORM; } } //PATH_DATA_PUBLIC ??? if (!file_exists($sPath . PATH_SEP . $Part['File'] . '.xml') && defined('PATH_DATA_PUBLIC')) { $sPath = PATH_DATA_PUBLIC; } $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true); if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } G::LoadClass('propelTable'); $oTable = new propelTable(); $oTable->template = $Part['Template']; $oTable->criteria = $Part['Content']; if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') { $oTable->ajaxServer = $Part['ajaxServer']; } if (!isset($G_FORM->xmlform)) { $G_FORM->xmlform = new stdclass(); } $G_FORM->xmlform->fileXml = $G_FORM->fileName; $G_FORM->xmlform->home = $G_FORM->home; if (!isset($G_FORM->xmlform->tree)) { $G_FORM->xmlform->tree = new stdclass(); } $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; if (is_array($Part['Data'])) { $G_FORM->values = array_merge($G_FORM->values, $Part['Data']); } $oTable->setupFromXmlform($G_FORM); /* Start Block: Load user configuration for the pagedTable */ G::LoadClass('configuration'); $objUID = $Part['File']; $conf = new Configurations($oTable); $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', ''); $oTable->__OBJ_UID = $objUID; //$oTable->__OBJ_UID = ''; /* End Block */ /* Start Block: PagedTable Right Click */ G::LoadClass('popupMenu'); $pm = new popupMenu('gulliver/pagedTable_PopupMenu'); $sc = $pm->renderPopup($oTable->id, $oTable->fields); /* End Block */ //krumo ( $Part ); if ($this->ROWS_PER_PAGE) { $oTable->rowsPerPage = $this->ROWS_PER_PAGE; } try { if (is_array($Part['Data'])) { $oTable->renderTable('', $Part['Data']); } else { $oTable->renderTable(); } print $sc; } catch (Exception $e) { $aMessage['MESSAGE'] = $e->getMessage(); $this->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage); } break; case 'panel-init': global $mainPanelScript; global $panelName; global $tabCount; //G::LoadThirdParty( 'pear/json', 'class.json' ); //$json = new Services_JSON(); $tabCount = 0; $panelName = $Part['Template']; $data = $Part['File']; if (!is_array($data)) { $data = array(); } $data = G::array_merges(array('title' => '', 'style' => array(), 'left' => 'getAbsoluteLeft(mycontent)', 'top' => 'getAbsoluteTop(mycontent)', 'width' => 700, 'height' => 600, 'drag' => true, 'close' => true, 'modal' => true, 'roll' => false, 'resize' => false, 'tabWidth' => 120, 'tabStep' => 3, 'blinkToFront' => true, 'tabSpace' => 10), $data); $mainPanelScript = 'var ' . $panelName . '={},' . $panelName . 'Tabs=[];' . 'leimnud.event.add(window,"load",function(){' . $panelName . ' = new leimnud.module.panel();' . 'var mycontent=document.getElementById("' . $this->publisherId . '[' . $intPos . ']");' . $panelName . '.options={' . 'size:{w:' . $data['width'] . ',h:' . $data['height'] . '},' . 'position:{x:' . $data['left'] . ',y:' . $data['top'] . '},' . 'title:"' . addcslashes($data['title'], '\\"') . '",' . 'theme:"processmaker",' . 'statusBar:true,' . 'headerBar:true,' . 'control:{' . ' close:' . ($data['close'] ? 'true' : 'false') . ',' . ' roll:' . ($data['roll'] ? 'true' : 'false') . ',' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' resize:' . ($data['resize'] ? 'true' : 'false') . '},' . 'fx:{' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' modal:' . ($data['modal'] ? 'true' : 'false') . ',' . ' blinkToFront:' . ($data['blinkToFront'] ? 'true' : 'false') . '}' . '};' . $panelName . '.setStyle=' . Bootstrap::json_encode($data['style']) . ';' . $panelName . '.tab={' . 'width:' . ($data['tabWidth'] + $data['tabSpace']) . ',' . 'optWidth:' . $data['tabWidth'] . ',' . 'step :' . $data['tabStep'] . ',' . 'options:[]' . '};'; print ' '; break; case 'panel-tab': global $tabCount; global $mainPanelScript; global $panelName; $onChange = $Part['Content']; $beforeChange = $Part['Data']; if (SYS_LANG == 'es') { $mainPanelScript = str_replace("120", "150", $mainPanelScript); } else { $mainPanelScript = str_replace("150", "120", $mainPanelScript); } $mainPanelScript .= $panelName . 'Tabs[' . $tabCount . ']=' . 'document.getElementById("' . $Part['File'] . '");' . $panelName . '.tab.options[' . $panelName . '.tab.options.length]=' . '{' . 'title :"' . addcslashes($Part['Template'], '\\"') . '",' . 'noClear :true,' . 'content :function(){' . ($beforeChange != '' ? 'if (typeof(' . $beforeChange . ')!=="undefined") {' . $beforeChange . '();}' : '') . $panelName . 'Clear();' . $panelName . 'Tabs[' . $tabCount . '].style.display="";' . ($onChange != '' ? 'if (typeof(' . $onChange . ')!=="undefined") {' . $onChange . '();}' : '') . '}.extend(' . $panelName . '),' . 'selected:' . ($tabCount == 0 ? 'true' : 'false') . '};'; $tabCount++; break; case 'panel-close': global $mainPanelScript; global $panelName; global $tabCount; $mainPanelScript .= $panelName . '.make();'; $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . '.addContent(' . $panelName . 'Tabs[r]);'; $mainPanelScript .= '});'; $mainPanelScript .= 'function ' . $panelName . 'Clear(){'; $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}'; $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addScriptCode($mainPanelScript); break; case 'blank': print ' '; break; case 'varform': global $G_FORM; $G_FORM = new Form(); G::LoadSystem("varform"); $xml = new varForm(); //$xml->parseFile ( ); $xml->renderForm($G_FORM, $Part['File']); $G_FORM->Values = $Part['Data']; $G_FORM->SetUp($Part['Target']); $G_FORM->width = 500; break; case 'table': $G_TMP_TARGET = $Part['Target']; $G_TABLE = G::LoadRawTable($Part['File'], $this->dbc, $Part['Data']); break; case 'menu': $G_TMP_TARGET = $Part['Target']; $G_OP_MENU = new Menu(); $G_OP_MENU->Load($Part['File']); break; case 'smarty': //To do: Please check it 26/06/07 $template = new Smarty(); $template->compile_dir = PATH_SMARTY_C; $template->cache_dir = PATH_SMARTY_CACHE; $template->config_dir = PATH_THIRDPARTY . 'smarty/configs'; $template->caching = false; $dataArray = $Part['Data']; // verify if there are templates folders registered, template and method folders are the same $folderTemplate = explode('/', $Part['Template']); $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($folderTemplate[0])) { $template->templateFile = PATH_PLUGINS . $Part['Template'] . '.html'; } else { $template->templateFile = PATH_TPL . $Part['Template'] . '.html'; } // last change to load the template, maybe absolute path was given if (!is_file($template->templateFile)) { $template->templateFile = strpos($Part['Template'], '.html') !== false ? $Part['Template'] : $Part['Template'] . '.html'; } //assign the variables and use the template $template $template->assign($dataArray); print $template->fetch($template->templateFile); break; case 'template': //To do: Please check it 26/06/07 if (gettype($Part['Data']) == 'array') { G::LoadSystem('template'); //template phpBB $template = new Template(); $template->set_filenames(array('body' => $Part['Template'] . '.html')); $dataArray = $Part['Data']; if (is_array($dataArray)) { foreach ($dataArray as $key => $val) { if (is_array($val)) { foreach ($val as $key_val => $val_array) { $template->assign_block_vars($key, $val_array); } } else { $template->assign_vars(array($key => $val)); } } } $template->pparse('body'); } if (gettype($Part['Data']) == 'object' && strtolower(get_class($Part['Data'])) == 'templatepower') { $Part['Data']->printToScreen(); } return; break; case 'view': case 'content': //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment $aux = explode(PATH_SEP, $Part['Template']); if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { //if the template doesn't exists, then try it with the plugins folders, after the normal Template $userTemplate = G::ExpandPath('templates') . $Part['Template']; $globalTemplate = PATH_TEMPLATE . $Part['Template']; if (!is_file($userTemplate) && !is_file($globalTemplate)) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $pluginTemplate = PATH_PLUGINS . $Part['Template'] . '.php'; include $pluginTemplate; } } } break; case 'graphLayout': //Added by JHL to render GraphLayout component $G_OBJGRAPH = $Part['Data']; $G_TMP_TARGET = $Part['Target']; $G_TMP_FILE = $Part['File']; break; } //krumo( $Part['Template'] ); //check if this LoadTemplate is used, byOnti 12th Aug 2008 G::LoadTemplate($Part['Template']); $G_TABLE = null; }
/** * get user preferences for default redirect * verifying if it has any preferences on configurations table */ public function _getDefaultLocation() { global $RBAC; G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], ''); //$baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/'; if (isset($_COOKIE['workspaceSkin'])) { $baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . $_COOKIE['workspaceSkin'] . '/'; } else { $baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/'; } $url = ''; if (sizeof($oConf->aConfig) > 0) { // this user has a configuration record // backward compatibility, because now, we don't have user and dashboard menu. if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') { $oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP'; } switch ($oConf->aConfig['DEFAULT_MENU']) { case 'PM_SETUP': if ($RBAC->userCanAccess('PM_SETUP') == 1) { $url = 'setup/main'; } break; case 'PM_FACTORY': if ($RBAC->userCanAccess('PM_FACTORY') == 1) { $url = 'processes/main'; } break; case 'PM_CASES': if ($RBAC->userCanAccess('PM_CASES') == 1) { $url = 'cases/main'; } break; case 'PM_USERS': if ($RBAC->userCanAccess('PM_USERS') == 1) { $url = 'setup/main'; } break; case 'PM_DASHBOARD': if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) { $url = 'dashboard/main'; } break; } } if (empty($url)) { if ($RBAC->userCanAccess('PM_FACTORY') == 1) { $url = 'processes/main'; } elseif ($RBAC->userCanAccess('PM_SETUP') == 1) { $url = 'setup/main'; } elseif ($RBAC->userCanAccess('PM_CASES') == 1) { $url = 'cases/main'; } elseif ($RBAC->userCanAccess('PM_USERS') == 1) { $url = 'setup/main'; } elseif ($RBAC->userCanAccess('PM_DASHBOARD') == 1) { $url = 'dashboard/dashboard'; } else { $url = 'users/myInfo'; } } return $baseUrl . $url; }
public function getConfigGmail() { $conf = new Configurations(); $conf->loadConfig($gmail, 'GOOGLE_API_SETTINGS', ''); return $conf; }
/** * Upgrade the AppCacheView table to the latest system version. * * This recreates the table and populates with data. * * @param bool $checkOnly only check if the upgrade is needed if true * @param string $lang not currently used */ public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en") { $this->initPropel(true); //require_once ('classes/model/AppCacheView.php'); //check the language, if no info in config about language, the default is 'en' G::LoadClass("configuration"); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $userGrants = $appCache->checkGrantsForUser(false); $currentUser = $userGrants['user']; $currentUserIsSuper = $userGrants['super']; //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper) { $appCache->checkGrantsForUser(true); $appCache->setSuperForUser($currentUser); $currentUserIsSuper = true; } CLI::logging("-> Creating tables \n"); //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. $res = $appCache->checkAppCacheView(); CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table \n"); //Update APP_DELEGATION.DEL_LAST_INDEX data $res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly); CLI::logging("-> Verifying roles permissions in RBAC \n"); //Update table RBAC permissions Bootstrap::LoadSystem( 'rbac' ); $RBAC = & RBAC::getSingleton(); $RBAC->initRBAC(); $result = $RBAC->verifyPermissions(); if (count($result) > 1) { foreach ($result as $item) { CLI::logging(" $item... \n"); } } else { CLI::logging(" All roles permissions already updated \n"); } CLI::logging("-> Creating triggers\n"); //now check if we have the triggers installed $triggers = array(); $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly); $triggers[] = $appCache->triggerSubApplicationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly); if ($fill) { CLI::logging("-> Rebuild Cache View with language $lang...\n"); //build using the method in AppCacheView Class $res = $appCache->fillAppCacheView($lang); } //set status in config table $confParams = Array('LANG' => $lang, 'STATUS' => 'active'); $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); // removing casesList configuration records. TODO: removing these lines that resets all the configurations records $oCriteria = new Criteria(); $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList"); $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN); ConfigurationPeer::doDelete($oCriteria); // end of reset //close connection if (substr(PHP_OS, 0, 3) != 'WIN') { $connection = Propel::getConnection( 'workflow' ); $sql_sleep = "SELECT * FROM information_schema.processlist WHERE command = 'Sleep' and user = SUBSTRING_INDEX(USER(),'@',1) and db = DATABASE() ORDER BY id;"; $stmt_sleep = $connection->createStatement(); $rs_sleep = $stmt_sleep->executeQuery( $sql_sleep, ResultSet::FETCHMODE_ASSOC ); while ($rs_sleep->next()) { $row_sleep = $rs_sleep->getRow(); $oStatement_sleep = $connection->prepareStatement( "kill ". $row_sleep['ID'] ); $oStatement_sleep->executeQuery(); } $sql_query = "SELECT * FROM information_schema.processlist WHERE user = SUBSTRING_INDEX(USER(),'@',1) and db = DATABASE() and time > 0 ORDER BY id;"; $stmt_query = $connection->createStatement(); $rs_query = $stmt_query->executeQuery( $sql_query, ResultSet::FETCHMODE_ASSOC ); while ($rs_query->next()) { $row_query = $rs_query->getRow(); $oStatement_query = $connection->prepareStatement( "kill ". $row_query['ID'] ); $oStatement_query->executeQuery(); } } }
/** * Upgrade the AppCacheView table to the latest system version. * * This recreates the table and populates with data. * * @param bool $checkOnly only check if the upgrade is needed if true * @param string $lang not currently used */ public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en") { $this->initPropel(true); //require_once ('classes/model/AppCacheView.php'); //check the language, if no info in config about language, the default is 'en' G::LoadClass("configuration"); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $userGrants = $appCache->checkGrantsForUser(false); $currentUser = $userGrants['user']; $currentUserIsSuper = $userGrants['super']; //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper) { $appCache->checkGrantsForUser(true); $appCache->setSuperForUser($currentUser); $currentUserIsSuper = true; } CLI::logging("-> Creating table\n"); //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. $res = $appCache->checkAppCacheView(); CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table\n"); //Update APP_DELEGATION.DEL_LAST_INDEX data $res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly); CLI::logging("-> Verifying roles permissions in RBAC \n"); //Update table RBAC permissions Bootstrap::LoadSystem('rbac'); $RBAC =& RBAC::getSingleton(); $RBAC->initRBAC(); $result = $RBAC->verifyPermissions(); if (count($result) > 1) { foreach ($result as $item) { CLI::logging(" {$item}... \n"); } } else { CLI::logging(" All roles permissions already updated \n"); } CLI::logging("-> Creating triggers\n"); //now check if we have the triggers installed $triggers = array(); $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly); $triggers[] = $appCache->triggerSubApplicationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly); if ($fill) { CLI::logging("-> Rebuild Cache View with language {$lang}...\n"); //build using the method in AppCacheView Class $res = $appCache->fillAppCacheView($lang); //set status in config table $confParams = array('LANG' => $lang, 'STATUS' => 'active'); } $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); // removing casesList configuration records. TODO: removing these lines that resets all the configurations records $oCriteria = new Criteria(); $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList"); $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN); ConfigurationPeer::doDelete($oCriteria); // end of reset }
/** * @param $action * @param $categoryUid * @param $userUid * @return array * @throws \PropelException */ public function getProcessList ($action, $categoryUid, $userUid) { //$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : null; //$categoryUid = isset( $_REQUEST['CATEGORY_UID'] ) ? $_REQUEST['CATEGORY_UID'] : null; //$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null; // global $oAppCache; $oAppCache = new \AppCacheView(); $processes = array (); $processes[] = array ('',G::LoadTranslation( 'ID_ALL_PROCESS' )); //get the list based in the action provided switch ($action) { case 'draft': $cProcess = $oAppCache->getDraftListCriteria( $userUid ); //fast enough break; case 'sent': $cProcess = $oAppCache->getSentListProcessCriteria( $userUid ); // fast enough break; case 'simple_search': case 'search': //in search action, the query to obtain all process is too slow, so we need to query directly to //process and content tables, and for that reason we need the current language in AppCacheView. G::loadClass( 'configuration' ); $oConf = new \Configurations(); $oConf->loadConfig( $x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '' ); $appCacheViewEngine = $oConf->aConfig; $lang = isset( $appCacheViewEngine['LANG'] ) ? $appCacheViewEngine['LANG'] : 'en'; $cProcess = new Criteria( 'workflow' ); $cProcess->clearSelectColumns(); $cProcess->addSelectColumn( \ProcessPeer::PRO_UID ); $cProcess->addSelectColumn( \ContentPeer::CON_VALUE ); if ($categoryUid) { $cProcess->add( \ProcessPeer::PRO_CATEGORY, $categoryUid ); } $del = DBAdapter::getStringDelimiter(); $conds = array (); $conds[] = array (ProcessPeer::PRO_UID,ContentPeer::CON_ID); $conds[] = array (ContentPeer::CON_CATEGORY,$del . 'PRO_TITLE' . $del); $conds[] = array (ContentPeer::CON_LANG,$del . $lang . $del); $cProcess->addJoinMC( $conds, Criteria::LEFT_JOIN ); $cProcess->add( ProcessPeer::PRO_STATUS, 'ACTIVE' ); $cProcess->addAscendingOrderByColumn(ContentPeer::CON_VALUE); $oDataset = ProcessPeer::doSelectRS( $cProcess ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array ($aRow['PRO_UID'],$aRow['CON_VALUE'] ); $oDataset->next(); } return print G::json_encode( $processes ); break; case 'unassigned': $cProcess = $oAppCache->getUnassignedListCriteria( $userUid ); break; case 'paused': $cProcess = $oAppCache->getPausedListCriteria( $userUid ); break; case 'to_revise': $cProcess = $oAppCache->getToReviseListCriteria( $userUid ); break; case 'to_reassign': $cProcess = $oAppCache->getToReassignListCriteria($userUid); break; case 'gral': $cProcess = $oAppCache->getGeneralListCriteria(); break; case 'todo': default: $cProcess = $oAppCache->getToDoListCriteria( $userUid ); //fast enough break; } //get the processes for this user in this action $cProcess->clearSelectColumns(); $cProcess->addSelectColumn( \AppCacheViewPeer::PRO_UID ); $cProcess->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE ); $cProcess->setDistinct( \AppCacheViewPeer::PRO_UID ); if ($categoryUid) { require_once 'classes/model/Process.php'; $cProcess->addAlias( 'CP', 'PROCESS' ); $cProcess->add( 'CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL ); $cProcess->addJoin( \AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN ); $cProcess->addAsColumn( 'CATEGORY_UID', 'CP.PRO_CATEGORY' ); } $cProcess->addAscendingOrderByColumn(\AppCacheViewPeer::APP_PRO_TITLE); $oDataset = \AppCacheViewPeer::doSelectRS( $cProcess, \Propel::getDbConnection('workflow_ro') ); $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array ($aRow['PRO_UID'],$aRow['APP_PRO_TITLE'] ); $oDataset->next(); } return $processes; }
/** * loadFields for email configuration * @autor Alvaro <*****@*****.**> */ public function loadFields() { G::loadClass('configuration'); $oConfiguration = new Configurations(); $oConfiguration->loadConfig($x, 'Emails', '', '', '', ''); $fields = $oConfiguration->aConfig; if (count($fields) > 0) { $this->success = count($fields) > 0; $passwd = $fields['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); if (strpos($passwdDec, 'hash:') !== false) { list($hash, $pass) = explode(":", $passwdDec); $fields['MESS_PASSWORD'] = $pass; } } $this->data = $fields; }
function getAllProcesses($start, $limit, $category = NULL, $processName = NULL) { require_once PATH_RBAC . "model/RbacUsers.php"; require_once "classes/model/ProcessCategory.php"; require_once "classes/model/Users.php"; $user = new RbacUsers(); $aProcesses = array(); $categories = array(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(ProcessPeer::PRO_UID); $oCriteria->addSelectColumn(ProcessPeer::PRO_PARENT); $oCriteria->addSelectColumn(ProcessPeer::PRO_STATUS); $oCriteria->addSelectColumn(ProcessPeer::PRO_CATEGORY); $oCriteria->addSelectColumn(ProcessPeer::PRO_CREATE_DATE); $oCriteria->addSelectColumn(ProcessPeer::PRO_CREATE_USER); $oCriteria->addSelectColumn(ProcessPeer::PRO_DEBUG); $oCriteria->addSelectColumn(UsersPeer::USR_UID); $oCriteria->addSelectColumn(UsersPeer::USR_USERNAME); $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID); $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME); $oCriteria->add(ProcessPeer::PRO_UID, '', Criteria::NOT_EQUAL); $oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL); if (isset($category)) { $oCriteria->add(ProcessPeer::PRO_CATEGORY, $category, Criteria::EQUAL); } $oCriteria->addJoin(ProcessPeer::PRO_CREATE_USER, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $oCriteria->addJoin(ProcessPeer::PRO_CATEGORY, ProcessCategoryPeer::CATEGORY_UID, Criteria::LEFT_JOIN); $this->tmpCriteria = clone $oCriteria; if ($start != '') { $oCriteria->setOffset($start); } if ($limit != '' && !isset($category) && !isset($processName)) { $oCriteria->setLimit($limit); } //execute a query to obtain numbers, how many cases there are by process $casesCnt = $this->getCasesCountInAllProcesses(); //execute the query $oDataset = ProcessPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $processes = array(); $uids = array(); while ($oDataset->next()) { $processes[] = $oDataset->getRow(); $uids[] = $processes[sizeof($processes) - 1]['PRO_UID']; } //process details will have the info about the processes $processesDetails = array(); //now get the labels for all process, using an array of Uids, $c = new Criteria('workflow'); //$c->add ( ContentPeer::CON_CATEGORY, 'PRO_TITLE', Criteria::EQUAL ); $c->add(ContentPeer::CON_LANG, defined('SYS_LANG') ? SYS_LANG : 'en', Criteria::EQUAL); $c->add(ContentPeer::CON_ID, $uids, Criteria::IN); $dt = ContentPeer::doSelectRS($c); $dt->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($dt->next()) { $row = $dt->getRow(); $processesDetails[$row['CON_ID']][$row['CON_CATEGORY']] = $row['CON_VALUE']; } G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); foreach ($processes as $process) { $proTitle = isset($processesDetails[$process['PRO_UID']]) && isset($processesDetails[$process['PRO_UID']]['PRO_TITLE']) ? $processesDetails[$process['PRO_UID']]['PRO_TITLE'] : ''; $proDescription = isset($processesDetails[$process['PRO_UID']]) && isset($processesDetails[$process['PRO_UID']]['PRO_DESCRIPTION']) ? $processesDetails[$process['PRO_UID']]['PRO_DESCRIPTION'] : ''; // verify if the title is already set on the current language if (trim($proTitle) == '') { // if not, then load the record to generate content for current language $proData = $this->load($process['PRO_UID']); $proTitle = $proData['PRO_TITLE']; $proDescription = $proData['PRO_DESCRIPTION']; } //filtering by $processName if (isset($processName) && $processName != '' && stripos($proTitle, $processName) === false) { continue; } $casesCountTotal = 0; if (isset($casesCnt[$process['PRO_UID']])) { foreach ($casesCnt[$process['PRO_UID']] as $item) { $casesCountTotal += $item; } } //get user format from configuration $userOwner = isset($oConf->aConfig['format']) ? $oConf->aConfig['format'] : ''; $creationDateMask = isset($oConf->aConfig['dateFormat']) ? $oConf->aConfig['dateFormat'] : ''; if ($userOwner != '') { $userOwner = str_replace('@userName', $process['USR_USERNAME'], $userOwner); $userOwner = str_replace('@firstName', $process['USR_FIRSTNAME'], $userOwner); $userOwner = str_replace('@lastName', $process['USR_LASTNAME'], $userOwner); if ($userOwner == " ( )") { $userOwner = '-'; } } else { $userOwner = $process['USR_FIRSTNAME'] . ' ' . $process['USR_LASTNAME']; } //get date format from configuration if ($creationDateMask != '') { list($date, $time) = explode(' ', $process['PRO_CREATE_DATE']); list($y, $m, $d) = explode('-', $date); list($h, $i, $s) = explode(':', $time); $process['PRO_CREATE_DATE'] = date($creationDateMask, mktime($h, $i, $s, $m, $d, $y)); } $process['PRO_CATEGORY_LABEL'] = trim($process['PRO_CATEGORY']) != '' ? $process['CATEGORY_NAME'] : G::LoadTranslation('ID_PROCESS_NO_CATEGORY'); $process['PRO_TITLE'] = $proTitle; $process['PRO_DESCRIPTION'] = $proDescription; $process['PRO_DEBUG'] = $process['PRO_DEBUG']; $process['PRO_DEBUG_LABEL'] = $process['PRO_DEBUG'] == "1" ? G::LoadTranslation('ID_ON') : G::LoadTranslation('ID_OFF'); $process['PRO_STATUS_LABEL'] = $process['PRO_STATUS'] == 'ACTIVE' ? G::LoadTranslation('ID_ACTIVE') : G::LoadTranslation('ID_INACTIVE'); $process['PRO_CREATE_USER_LABEL'] = $userOwner; $process['CASES_COUNT_TO_DO'] = isset($casesCnt[$process['PRO_UID']]['TO_DO']) ? $casesCnt[$process['PRO_UID']]['TO_DO'] : 0; $process['CASES_COUNT_COMPLETED'] = isset($casesCnt[$process['PRO_UID']]['COMPLETED']) ? $casesCnt[$process['PRO_UID']]['COMPLETED'] : 0; $process['CASES_COUNT_DRAFT'] = isset($casesCnt[$process['PRO_UID']]['DRAFT']) ? $casesCnt[$process['PRO_UID']]['DRAFT'] : 0; $process['CASES_COUNT_CANCELLED'] = isset($casesCnt[$process['PRO_UID']]['CANCELLED']) ? $casesCnt[$process['PRO_UID']]['CANCELLED'] : 0; $process['CASES_COUNT'] = $casesCountTotal; unset($process['PRO_CREATE_USER']); $aProcesses[] = $process; } usort($aProcesses, 'ordProcessByProTitle'); return $aProcesses; }
public function sendNotifications($taskUid, $arrayTask, $arrayData, $applicationUid, $delIndex, $from = '') { try { $arrayApplicationData = $this->loadCase($applicationUid); $arrayData['APP_NUMBER'] = $arrayApplicationData['APP_NUMBER']; if (!class_exists('System')) { G::LoadClass('system'); } $aConfiguration = System::getEmailConfiguration(); $msgError = ""; if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { $msgError = "The default configuration wasn't defined"; $aConfiguration['MESS_ENGINE'] = ''; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($taskUid); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } $from = G::buildFrom($aConfiguration, $from); if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $arrayData); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP; $swtplDefault = 0; $sBody = null; if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") { if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") { $swtplDefault = 1; } $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"]; if (!file_exists($fileTemplate)) { $tempale = PATH_CORE . "templates" . PATH_SEP . "mails" . PATH_SEP . "alert_message.html"; $copied = @copy($tempale, $fileTemplate); if ($copied) { $dataTemplate = array("prf_filename" => $conf["TAS_DEF_MESSAGE_TEMPLATE"], "prf_path" => $fileTemplate, "pro_uid" => $aTaskInfo["PRO_UID"], "usr_uid" => "00000000000000000000000000000001", "prf_uid" => G::generateUniqueID(), "prf_type" => "file", "prf_create_date" => date("Y-m-d H:i:s")); $filesManager = new ProcessMaker\BusinessModel\FilesManager(); $filesManager->addProcessFilesManagerInDb($dataTemplate); } else { throw new Exception("Template file \"{$fileTemplate}\" does not exist."); } } $sBody = file_get_contents($fileTemplate); } else { $sBody = nl2br($aTaskInfo['TAS_DEF_MESSAGE']); } G::LoadClass("tasks"); G::LoadClass("groups"); G::LoadClass("spool"); $task = new Tasks(); $group = new Groups(); $oUser = new Users(); foreach ($arrayTask as $aTask) { $sTo = null; $sCc = null; if (isset($aTask['DEL_INDEX'])) { $arrayData2 = $arrayData; $appDelegation = AppDelegationPeer::retrieveByPK($applicationUid, $aTask['DEL_INDEX']); if (!is_null($appDelegation)) { $arrayData2['TAS_TITLE'] = Content::load('TAS_TITLE', '', $appDelegation->getTasUid(), SYS_LANG); $arrayData2['DEL_TASK_DUE_DATE'] = $appDelegation->getDelTaskDueDate(); } } else { $arrayData2 = $arrayData; } if (isset($aTask['USR_UID']) && !empty($aTask['USR_UID'])) { $user = new \ProcessMaker\BusinessModel\User(); $arrayUserData = $user->getUser($aTask['USR_UID'], true); $arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2, trim($arrayUserData['USR_TIME_ZONE']) != '' ? trim($arrayUserData['USR_TIME_ZONE']) : \ProcessMaker\Util\System::getTimeZone()); } else { $arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2); } $sBody2 = G::replaceDataGridField($sBody, $arrayData2, false); switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { G::verifyPath($pathEmail, true); //Create if it does not exist $fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'); if (!file_exists($fileTemplate) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) { @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate); } $sBody2 = G::replaceDataField(file_get_contents($fileTemplate), $arrayData2); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayTaskUser = array(); $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } $criteria = new Criteria("workflow"); $criteria->addSelectColumn(UsersPeer::USR_UID); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_EMAIL); $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN); $rsCriteria = UsersPeer::doSelectRs($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $to = null; $cc = null; $sw = 1; while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; case "MULTIPLE_INSTANCE": $to = null; $cc = null; $sw = 1; $oDerivation = new Derivation(); $userFields = $oDerivation->getUsersFullNameFromArray($oDerivation->getAllUsersFromAnyTask($aTask["TAS_UID"])); if (isset($userFields)) { foreach ($userFields as $row) { $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; case "MULTIPLE_INSTANCE_VALUE_BASED": $aTaskNext = $oTask->load($aTask["TAS_UID"]); if (isset($aTaskNext["TAS_ASSIGN_VARIABLE"]) && !empty($aTaskNext["TAS_ASSIGN_VARIABLE"])) { $to = null; $cc = null; $sw = 1; $nextTaskAssignVariable = trim($aTaskNext["TAS_ASSIGN_VARIABLE"], " @#"); $arrayUsers = $arrayData[$nextTaskAssignVariable]; $oDerivation = new Derivation(); $userFields = $oDerivation->getUsersFullNameFromArray($arrayUsers); foreach ($userFields as $row) { $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $aUser = $oUser->load($aTask["USR_UID"]); $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">"; } break; } if ($sTo != null) { $oSpool = new spoolRun(); $oSpool->setConfig($aConfiguration); $oSpool->create(array("msg_uid" => "", 'app_uid' => $applicationUid, 'del_index' => $delIndex, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, 'app_msg_from' => $from, "app_msg_to" => $sTo, 'app_msg_body' => $sBody2, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_error" => $msgError)); if ($msgError == '') { if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") { $oSpool->sendMail(); } } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "") { try { $applicationData = $this->loadCase($sApplicationUID); $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"]; $oConfiguration = new Configuration(); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails'); $oCriteria->add(ConfigurationPeer::OBJ_UID, ''); $oCriteria->add(ConfigurationPeer::PRO_UID, ''); $oCriteria->add(ConfigurationPeer::USR_UID, ''); $oCriteria->add(ConfigurationPeer::APP_UID, ''); if (ConfigurationPeer::doCount($oCriteria) == 0) { $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => '')); $aConfiguration = array(); } else { $aConfiguration = $oConfiguration->load('Emails', '', '', '', ''); if ($aConfiguration['CFG_VALUE'] != '') { $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]); $passwd = $aConfiguration["MESS_PASSWORD"]; $passwdDec = G::decrypt($passwd, "EMAILENCRYPT"); $auxPass = explode('hash:', $passwdDec); if (count($auxPass) > 1) { if (count($auxPass) == 2) { $passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $aConfiguration["MESS_PASSWORD"] = $passwd; } else { $aConfiguration = array(); } } if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { return false; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($sCurrentTask); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } if ($sFrom == '') { $sFrom = '"ProcessMaker"'; } $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match); if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) { if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') { $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; } else { if ($aConfiguration['MESS_ENGINE'] == 'MAIL') { $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>'; } else { if ($aConfiguration['MESS_SERVER'] != '') { if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) { $sFrom .= ' <info@' . $sAux . '>'; } else { $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>'; } } else { $sFrom .= ' <*****@*****.**>'; } } } } if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP; $swtplDefault = 0; $sBody = null; if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") { if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") { $swtplDefault = 1; } $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"]; if (!file_exists($fileTemplate)) { throw new Exception("Template file \"{$fileTemplate}\" does not exist."); } $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields); } else { $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields)); } G::LoadClass("tasks"); G::LoadClass("groups"); G::LoadClass("spool"); $task = new Tasks(); $group = new Groups(); $oUser = new Users(); foreach ($aTasks as $aTask) { $sTo = null; $sCc = null; switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { G::verifyPath($pathEmail, true); //Create if it does not exist $fileTemplate = $pathEmail . "unassignedMessage.html"; if (!file_exists($fileTemplate)) { @copy(PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $fileTemplate); } $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayTaskUser = array(); $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } $criteria = new Criteria("workflow"); $criteria->addSelectColumn(UsersPeer::USR_UID); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_EMAIL); $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN); $rsCriteria = UsersPeer::doSelectRs($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $to = null; $cc = null; $sw = 1; while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . ($cc != null ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $aUser = $oUser->load($aTask["USR_UID"]); $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">"; } break; } if ($sTo != null) { $oSpool = new spoolRun(); if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') { $aConfiguration['MESS_RAUTH'] = 0; } else { $aConfiguration['MESS_RAUTH'] = 1; } $oSpool->setConfig(array("MESS_ENGINE" => $aConfiguration["MESS_ENGINE"], "MESS_SERVER" => $aConfiguration["MESS_SERVER"], "MESS_PORT" => $aConfiguration["MESS_PORT"], "MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"], "MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"], "SMTPAuth" => $aConfiguration["MESS_RAUTH"] == "1" ? true : false, "SMTPSecure" => isset($aConfiguration["SMTPSecure"]) ? $aConfiguration["SMTPSecure"] : "")); $oSpool->create(array("msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending")); if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") { $oSpool->sendMail(); } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
<?php $request = isset($_REQUEST['request']) ? $_REQUEST['request'] : null; switch ($request) { case 'getLangList': $Translations = G::getModel('Translation'); $result = new stdClass(); $result->rows = array(); $langs = $Translations->getTranslationEnvironments(); foreach ($langs as $lang) { $result->rows[] = array('LAN_ID' => $lang['LOCALE'], 'LAN_NAME' => $lang['LANGUAGE']); } print G::json_encode($result); break; case 'saveSettings': $memcache =& PMmemcached::getSingleton(defined('SYS_SYS') ? SYS_SYS : ''); G::LoadClass('configuration'); $conf = new Configurations(); $conf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); $conf->aConfig['login_enableForgotPassword'] = isset($_REQUEST['forgotPasswd']); $conf->aConfig['login_enableVirtualKeyboard'] = isset($_REQUEST['virtualKeyboad']); $conf->aConfig['login_defaultLanguage'] = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : 'en'; $conf->saveConfig('ENVIRONMENT_SETTINGS', ''); //remove from memcache when this value is updated/created $memcache->delete('flagForgotPassword'); $response->success = true; echo G::json_encode($response); break; }
public function editTaskProperties($sTaskUID = '', $iForm = 1, $iIndex = 0) { $sw_template = false; try { switch ($iForm) { case 1: $sFilename = 'tasks/tasks_Definition.xml'; break; case 2: $sFilename = 'tasks/tasks_AssignmentRules.xml'; break; case 3: $sFilename = 'tasks/tasks_TimingControl.xml'; break; case 4: $sFilename = 'tasks/tasks_Owner.xml'; break; case 5: $sFilename = 'tasks/tasks_Permissions.xml'; break; case 6: $sFilename = 'tasks/tasks_Labels.xml'; break; case 7: $sFilename = 'tasks/tasks_Notifications.xml'; break; default: //if the $iForm is not one of the defaults then search under Plugins for an extended property. By JHL Jan 18, 2011 $oPluginRegistry =& PMPluginRegistry::getSingleton(); $activePluginsForTaskProperties = $oPluginRegistry->getTaskExtendedProperties(); $oPM->taskOptions = array(); foreach ($activePluginsForTaskProperties as $key => $taskPropertiesInfo) { $id = $taskPropertiesInfo->sNamespace . "--" . $taskPropertiesInfo->sName; if ($id == $iForm) { $sFilename = $taskPropertiesInfo->sPage; $sw_template = true; } } //$sFilename = 'tasks/tasks_Owner.xml'; break; } $oTask = new Task(); $aFields = $oTask->load($sTaskUID); $aFields['INDEX'] = $iIndex; $aFields['IFORM'] = $iForm; $aFields['LANG'] = SYS_LANG; /** * Task Notifications * */ if ($iForm == 7 || $iForm == 1) { G::loadClass('processes'); $files = Processes::getProcessFiles($aFields['PRO_UID'], 'mail'); $templates = array(); $templates[] = 'dummy'; foreach ($files as $file) { $templates[] = array('FILE' => $file['filename'], 'NAME' => $file['filename']); } global $_DBArray; $_DBArray['_TEMPLATES1'] = $templates; $_SESSION['_DBArray'] = $_DBArray; if ($iForm == 7) { // Additional configuration G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aFields['TAS_UID'], '', ''); $conf = $oConf->aConfig; if (isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TYPE'])) { $aFields['TAS_DEF_MESSAGE_TYPE'] = $conf['TAS_DEF_MESSAGE_TYPE']; $aFields['TAS_DEF_MESSAGE_TEMPLATE'] = $conf['TAS_DEF_MESSAGE_TEMPLATE']; } } } if ($iForm == 3) { //Load Calendar Information $calendar = new Calendar(); $calendarObj = $calendar->getCalendarList(true, true); global $_DBArray; $_DBArray['availableCalendars'] = $calendarObj['array']; $_SESSION['_DBArray'] = $_DBArray; $calendarInfo = $calendar->getCalendarFor($sTaskUID, $sTaskUID, $sTaskUID); //If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar $aFields['TAS_CALENDAR'] = $calendarInfo['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo['CALENDAR_UID'] : ""; } if ($iForm == 2) { switch ($aFields["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": $aFields["TAS_ASSIGN_TYPE"] = !empty($aFields["TAS_GROUP_VARIABLE"]) ? "SELF_SERVICE_EVALUATE" : $aFields["TAS_ASSIGN_TYPE"]; break; } } global $G_PUBLISH; G::LoadClass('xmlfield_InputPM'); $G_PUBLISH = new Publisher(); if ($sw_template) { $G_PUBLISH->AddContent('view', $sFilename); } else { $G_PUBLISH->AddContent('xmlform', 'xmlform', $sFilename, '', $aFields); } G::RenderPage('publish', 'raw'); return true; } catch (Exception $oError) { throw $oError; } }
* 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. */ G::LoadClass("configuration"); $conf = new Configurations(); $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addExtJsScript("cases/main", false); //Adding a javascript file .js $oHeadPublisher->addContent("cases/main"); //Adding a html file .html. $keyMem = "USER_PREFERENCES" . $_SESSION["USER_LOGGED"]; $memcache =& PMmemcached::getSingleton(SYS_SYS); if (($arrayConfig = $memcache->get($keyMem)) === false) { $conf->loadConfig($x, "USER_PREFERENCES", "", "", $_SESSION["USER_LOGGED"], ""); $arrayConfig = $conf->aConfig; $memcache->set($keyMem, $arrayConfig, PMmemcached::ONE_HOUR); } $confDefaultOption = ""; if (isset($arrayConfig["DEFAULT_CASES_MENU"])) { //this user has a configuration record $confDefaultOption = $arrayConfig["DEFAULT_CASES_MENU"]; global $G_TMP_MENU; $oMenu = new Menu(); $oMenu->load("cases"); $defaultOption = ""; foreach ($oMenu->Id as $i => $id) { if ($id == $confDefaultOption) { $defaultOption = $oMenu->Options[$i]; break;
/** * Upgrade the AppCacheView table to the latest system version. * * This recreates the table and populates with data. * * @param bool $checkOnly only check if the upgrade is needed if true * @param string $lang not currently used */ public function upgradeCacheView($fill = true) { $this->initPropel(true); $lang = "en"; require_once 'classes/model/AppCacheView.php'; //check the language, if no info in config about language, the default is 'en' G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $userGrants = $appCache->checkGrantsForUser(false); $currentUser = $userGrants['user']; $currentUserIsSuper = $userGrants['super']; //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user. if (!$currentUserIsSuper) { $appCache->checkGrantsForUser(true); $appCache->setSuperForUser($currentUser); $currentUserIsSuper = true; } CLI::logging("-> Creating table\n"); //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc. $res = $appCache->checkAppCacheView(); CLI::logging("-> Creating triggers\n"); //now check if we have the triggers installed $triggers = array(); $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly); $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly); $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly); $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly); if ($fill) { CLI::logging("-> Rebuild Cache View\n"); //build using the method in AppCacheView Class $res = $appCache->fillAppCacheView($lang); //set status in config table $confParams = array('LANG' => $lang, 'STATUS' => 'active'); } $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); // removing casesList configuration records. TODO: removing these lines that resets all the configurations records $oCriteria = new Criteria(); $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList"); $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN); ConfigurationPeer::doDelete($oCriteria); // end of reset }
public function editTaskProperties($sTaskUID = '', $iForm = 1, $iIndex = 0) { $sw_template = false; try { switch ($iForm) { case 1: $sFilename = 'tasks/tasks_Definition.xml'; break; case 2: $sFilename = 'tasks/tasks_AssignmentRules.xml'; break; case 3: $sFilename = 'tasks/tasks_TimingControl.xml'; break; case 4: $sFilename = 'tasks/tasks_Owner.xml'; break; case 5: $sFilename = 'tasks/tasks_Permissions.xml'; break; case 6: $sFilename = 'tasks/tasks_Labels.xml'; break; case 7: $sFilename = 'tasks/tasks_Notifications.xml'; break; case 8: $sFilename = 'tasks/tasks_Consolidated.xml'; break; default: //if the $iForm is not one of the defaults then search under Plugins for an extended property. By JHL Jan 18, 2011 $oPluginRegistry = & PMPluginRegistry::getSingleton(); $activePluginsForTaskProperties = $oPluginRegistry->getTaskExtendedProperties(); foreach ($activePluginsForTaskProperties as $key => $taskPropertiesInfo) { $id = $taskPropertiesInfo->sNamespace . "--" . $taskPropertiesInfo->sName; if ($id == $iForm) { $sFilename = $taskPropertiesInfo->sPage; $sw_template = true; } } //$sFilename = 'tasks/tasks_Owner.xml'; break; } $oTask = new Task(); $aFields = $oTask->load($sTaskUID); $aFields['INDEX'] = $iIndex; $aFields['IFORM'] = $iForm; $aFields['LANG'] = SYS_LANG; /** * Task Notifications * */ if ($iForm == 7 || $iForm == 1) { G::loadClass('processes'); $files = Processes::getProcessFiles($aFields['PRO_UID'], 'mail'); $templates = array(); $templates[] = 'dummy'; foreach ($files as $file) { $templates[] = array('FILE' => $file['filename'], 'NAME' => $file['filename'] ); } global $_DBArray; $_DBArray['_TEMPLATES1'] = $templates; $_SESSION['_DBArray'] = $_DBArray; if ($iForm == 7) { // Additional configuration G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aFields['TAS_UID'], '', ''); $conf = $oConf->aConfig; if (isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TYPE'])) { $aFields['TAS_DEF_MESSAGE_TYPE'] = $conf['TAS_DEF_MESSAGE_TYPE']; $aFields['TAS_DEF_MESSAGE_TEMPLATE'] = $conf['TAS_DEF_MESSAGE_TEMPLATE']; } } } if ($iForm == 3) { //Load Calendar Information $calendar = new Calendar(); $calendarObj = $calendar->getCalendarList(true, true); global $_DBArray; $_DBArray['availableCalendars'] = $calendarObj['array']; $_SESSION['_DBArray'] = $_DBArray; $calendarInfo = $calendar->getCalendarFor($sTaskUID, $sTaskUID, $sTaskUID); //If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar $aFields['TAS_CALENDAR'] = $calendarInfo['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo['CALENDAR_UID'] : ""; } if ($iForm == 2) { switch ($aFields["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": $aFields["TAS_ASSIGN_TYPE"] = (!empty($aFields["TAS_GROUP_VARIABLE"])) ? "SELF_SERVICE_EVALUATE" : $aFields["TAS_ASSIGN_TYPE"]; break; } } if ($iForm == 8) { $oCaseConsolidated = CaseConsolidatedCorePeer::retrieveByPK($_SESSION["cDhTajE2T2lxSkhqMzZUTXVacWYyNcKwV3A4eWYybDdyb1p3"]["TAS_UID"]); if ((is_object($oCaseConsolidated)) && get_class($oCaseConsolidated) == "CaseConsolidated") { require_once ("classes/model/ReportTable.php"); $aFields["CON_STATUS"] = $oCaseConsolidated->getConStatus(); $aFields["DYN_UID"] = $oCaseConsolidated->getDynUid(); $aFields["REP_TAB_UID"] = $oCaseConsolidated->getRepTabUid(); $oReportTables = new ReportTable(); $oReportTables = $oReportTables->load($aFields["REP_TAB_UID"]); if (count($oReportTables)>0) { if ($oReportTables['REP_TAB_STATUS'] == 'ACTIVE') { $aFields["TABLE_NAME"] = $oReportTables['REP_TAB_NAME']; $aFields["TITLE"] = $oReportTables['REP_TAB_TITLE']; } } } $aFields["PRO_UID"] = $_SESSION["PROCESS"]; $aFields["TAS_UID"] = $_SESSION["cDhTajE2T2lxSkhqMzZUTXVacWYyNcKwV3A4eWYybDdyb1p3"]["TAS_UID"]; $aFields["SYS_LANG"] = SYS_LANG; $aFields['INDEX'] = 0; $aFields["TABLE_NAME_DEFAULT"] = "__" . $aFields["TAS_UID"]; $oCriteria = new Criteria("workflow"); $del = DBAdapter::getStringDelimiter(); $oCriteria->setDistinct(); $oCriteria->addSelectColumn(DynaformPeer::DYN_UID); $oCriteria->addSelectColumn(ContentPeer::CON_VALUE); $aConditions = array(); $aConditions[] = array(DynaformPeer::DYN_UID, ContentPeer::CON_ID); $aConditions[] = array(ContentPeer::CON_CATEGORY, $del . "DYN_TITLE" . $del); $aConditions[] = array(ContentPeer::CON_LANG, $del . "en" . $del); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(DynaformPeer::PRO_UID, $_SESSION["PROCESS"]); $oCriteria->add(DynaformPeer::DYN_TYPE, "grid"); $oCriteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE); $numRows = DynaformPeer::doCount($oCriteria); if ($numRows == 0) { $aFields['TITLE_ALERT'] = G::LoadTranslation('ID_ALERT'); $aFields['SUBTITLE_MESSAGE'] = G::LoadTranslation('ID_CONSOLIDATED_DYNAFORM_REQUIRED'); $sFilename = 'tasks/tasks_Consolidated_Error.xml'; } } global $G_PUBLISH; G::LoadClass('xmlfield_InputPM'); $G_PUBLISH = new Publisher(); if ($sw_template) { $G_PUBLISH->AddContent('view', $sFilename); } else { $G_PUBLISH->AddContent('xmlform', 'xmlform', $sFilename, '', $aFields); } G::RenderPage('publish', 'raw'); return true; } catch (Exception $oError) { throw ($oError); } }
public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "") { try { $applicationData = $this->loadCase($sApplicationUID); $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"]; if (!class_exists('System')) { G::LoadClass('system'); } $aConfiguration = System::getEmailConfiguration(); $msgError = ""; if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') { $msgError = "The default configuration wasn't defined"; $aConfiguration['MESS_ENGINE'] = ''; } //Send derivation notification - Start $oTask = new Task(); $aTaskInfo = $oTask->load($sCurrentTask); if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') { return false; } $sFrom = G::buildFrom($aConfiguration, $sFrom); if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') { $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields); } else { $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION'); } //erik: new behaviour for messages G::loadClass('configuration'); $oConf = new Configurations; $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); $conf = $oConf->aConfig; $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP; $swtplDefault = 0; $sBody = null; if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "" ) { if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") { $swtplDefault = 1; } $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"]; if (!file_exists($fileTemplate)) { throw (new Exception("Template file \"$fileTemplate\" does not exist.")); } $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields, false); } else { $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields, false)); } G::LoadClass("tasks"); G::LoadClass("groups"); G::LoadClass("spool"); $task = new Tasks(); $group = new Groups(); $oUser = new Users(); foreach ($aTasks as $aTask) { $sTo = null; $sCc = null; switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if ($swtplDefault == 1) { G::verifyPath($pathEmail, true); //Create if it does not exist $fileTemplate = $pathEmail . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'); if ((!file_exists($fileTemplate)) && file_exists(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'))) { @copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate); } $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); } if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayTaskUser = array(); $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } $criteria = new Criteria("workflow"); $criteria->addSelectColumn(UsersPeer::USR_UID); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_EMAIL); $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN); $rsCriteria = UsersPeer::doSelectRs($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $to = null; $cc = null; $sw = 1; while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $toAux = ( (($row["USR_FIRSTNAME"] != "") || ($row["USR_LASTNAME"] != "")) ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "" ) . "<" . $row["USR_EMAIL"] . ">"; if ($sw == 1) { $to = $toAux; $sw = 0; } else { $cc = $cc . (($cc != null) ? "," : null) . $toAux; } } $sTo = $to; $sCc = $cc; } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $aUser = $oUser->load($aTask["USR_UID"]); $sTo = ( (($aUser["USR_FIRSTNAME"] != "") || ($aUser["USR_LASTNAME"] != "")) ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "" ) . "<" . $aUser["USR_EMAIL"] . ">"; } break; } if ($sTo != null) { $oSpool = new spoolRun(); $oSpool->setConfig($aConfiguration); $oSpool->create(array( "msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_error" => $msgError )); if ($msgError == '') { if (($aConfiguration["MESS_BACKGROUND"] == "") || ($aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") ) { $oSpool->sendMail(); } } } } //Send derivation notification - End } catch (Exception $oException) { throw $oException; } }
/** * Login */ public function login() { require_once 'classes/model/LoginLog.php'; G::LoadClass('system'); G::loadClass('configuration'); $this->conf = new Configurations(); // getting posibles errors passed by GET method $this->getInUrlError(); if (!isset($_SESSION['G_MESSAGE'])) { $_SESSION['G_MESSAGE'] = ''; } if (!isset($_SESSION['G_MESSAGE_TYPE'])) { $_SESSION['G_MESSAGE_TYPE'] = ''; } $msg = $_SESSION['G_MESSAGE']; $msgType = $_SESSION['G_MESSAGE_TYPE']; if (!isset($_SESSION['FAILED_LOGINS'])) { $_SESSION['FAILED_LOGINS'] = 0; } $sFailedLogins = $_SESSION['FAILED_LOGINS']; if (isset($_SESSION['USER_LOGGED'])) { //close the session, if the current session_id was used in PM. $oCriteria = new Criteria('workflow'); $oCriteria->add(LoginLogPeer::LOG_SID, session_id()); $oCriteria->add(LoginLogPeer::USR_UID, isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '-'); $oCriteria->add(LoginLogPeer::LOG_STATUS, 'ACTIVE'); $oCriteria->add(LoginLogPeer::LOG_END_DATE, null, Criteria::ISNULL); $oDataset = LoginLogPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); if ($aRow) { if ($aRow['LOG_STATUS'] != 'CLOSED' && $aRow['LOG_END_DATE'] == null) { $weblog = new LoginLog(); $aLog['LOG_UID'] = $aRow['LOG_UID']; $aLog['LOG_STATUS'] = 'CLOSED'; $aLog['LOG_IP'] = $aRow['LOG_IP']; $aLog['LOG_SID'] = session_id(); $aLog['LOG_INIT_DATE'] = $aRow['LOG_INIT_DATE']; $aLog['LOG_END_DATE'] = date('Y-m-d H:i:s'); $aLog['LOG_CLIENT_HOSTNAME'] = $aRow['LOG_CLIENT_HOSTNAME']; $aLog['USR_UID'] = $aRow['USR_UID']; $weblog->update($aLog); } } //remove memcached session $this->memcache->delete('rbacSession' . session_id()); } else { // Execute SSO trigger $pluginRegistry =& PMPluginRegistry::getSingleton(); if (defined('PM_SINGLE_SIGN_ON')) { if ($pluginRegistry->existsTrigger(PM_SINGLE_SIGN_ON)) { if ($pluginRegistry->executeTriggers(PM_SINGLE_SIGN_ON, null)) { // Start new session @session_destroy(); session_start(); session_regenerate_id(); // Authenticate $result = $this->authentication(); if ($result->success) { // Redirect to landing page for the user G::header('Location: ' . $result->url); die; } } } } } //end log //start new session @session_destroy(); session_start(); session_regenerate_id(); if (strlen($msg) > 0) { $_SESSION['G_MESSAGE'] = $msg; } if (strlen($msgType) > 0) { $_SESSION['G_MESSAGE_TYPE'] = $msgType; } $_SESSION['FAILED_LOGINS'] = $sFailedLogins; $availableLangArray = $this->getLanguagesList(); G::LoadClass("serverConfiguration"); $sflag = 0; if (($nextBeatDate = $this->memcache->get('nextBeatDate')) === false) { //get the serverconf singleton, and check if we can send the heartbeat $oServerConf =& serverConf::getSingleton(); $sflag = $oServerConf->getHeartbeatProperty('HB_OPTION', 'HEART_BEAT_CONF'); $sflag = trim($sflag) != '' ? $sflag : '1'; //get date of next beat $nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE', 'HEART_BEAT_CONF'); $this->memcache->set('nextBeatDate', $nextBeatDate, 1 * 3600); } else { $sflag = '1'; } if ($sflag == '1' && (strtotime("now") > $nextBeatDate || is_null($nextBeatDate))) { //To do: we need to change to ExtJs $this->setJSVar('flagHeartBeat', 1); } else { $this->setJSVar('flagHeartBeat', 0); } if (($flagGettingStarted = $this->memcache->get('flagGettingStarted')) === false) { require_once 'classes/model/Configuration.php'; $oConfiguration = new Configuration(); $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::CFG_UID, 'getStarted'); $oCriteria->add(ConfigurationPeer::OBJ_UID, ''); $oCriteria->add(ConfigurationPeer::CFG_VALUE, '1'); $oCriteria->add(ConfigurationPeer::PRO_UID, ''); $oCriteria->add(ConfigurationPeer::USR_UID, ''); $oCriteria->add(ConfigurationPeer::APP_UID, ''); $flagGettingStarted = ConfigurationPeer::doCount($oCriteria); $this->memcache->set('flagGettingStarted', $flagGettingStarted, 8 * 3600); } $this->setJSVar('flagGettingStarted', $flagGettingStarted == 0); G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); $flagForgotPassword = isset($oConf->aConfig['login_enableForgotPassword']) ? $oConf->aConfig['login_enableForgotPassword'] : '******'; $this->includeExtJSLib('ux/virtualkeyboard'); $this->includeExtJS('main/login'); $this->setView('main/login'); $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); $forgotPasswd = isset($oConf->aConfig['login_enableForgotPassword']) ? $oConf->aConfig['login_enableForgotPassword'] : false; $virtualKeyboad = isset($oConf->aConfig['login_enableVirtualKeyboard']) ? $oConf->aConfig['login_enableVirtualKeyboard'] : false; $defaultLanguaje = isset($oConf->aConfig['login_defaultLanguage']) ? $oConf->aConfig['login_defaultLanguage'] : 'en'; $this->setJSVar('forgotPasswd', $forgotPasswd); $this->setJSVar('virtualKeyboad', $virtualKeyboad); $this->setJSVar('languages', $availableLangArray); $this->setJSVar('defaultLang', $defaultLanguaje); //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() if (($flyNotify = $this->getFlyNotify()) !== false) { $this->setJSVar('flyNotify', $flyNotify); } //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() if (isset($_GET['u'])) { $this->setJSVar('urlRequested', urldecode($_GET['u'])); } $this->setVar('logo_company', $this->getCompanyLogo()); $this->setVar('pmos_version', System::getVersion()); $footerText = 'Copyright © 2003-' . date('Y') . ' Colosa, Inc. All rights reserved.'; $adviseText = 'Supplied free of charge with no support, certification, warranty, maintenance nor indemnity by Colosa and its Certified Partners. '; $this->setVar('footer_text', $footerText); $this->setVar('advise_text', $adviseText); $loginScript = $this->getHeadPublisher()->getExtJsLibraries(); $loginScript .= $this->getHeadPublisher()->getExtJsScripts(); $this->setVar('login_script', $loginScript); $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript()); $this->setLayout('pm-modern-login'); $this->render(); }
public function getAllProcesses($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false, $userLogged = "") { require_once PATH_RBAC . "model/RbacUsers.php"; require_once "classes/model/ProcessCategory.php"; require_once "classes/model/Users.php"; $user = new RbacUsers(); $aProcesses = array(); $categories = array(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(ProcessPeer::PRO_UID); $oCriteria->addSelectColumn(ProcessPeer::PRO_PARENT); $oCriteria->addSelectColumn(ProcessPeer::PRO_STATUS); $oCriteria->addSelectColumn(ProcessPeer::PRO_TYPE); $oCriteria->addSelectColumn(ProcessPeer::PRO_CATEGORY); $oCriteria->addSelectColumn(ProcessPeer::PRO_UPDATE_DATE); $oCriteria->addSelectColumn(ProcessPeer::PRO_CREATE_DATE); $oCriteria->addSelectColumn(ProcessPeer::PRO_CREATE_USER); $oCriteria->addSelectColumn(ProcessPeer::PRO_DEBUG); $oCriteria->addSelectColumn(ProcessPeer::PRO_TYPE_PROCESS); $oCriteria->addSelectColumn(UsersPeer::USR_UID); $oCriteria->addSelectColumn(UsersPeer::USR_USERNAME); $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID); $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME); $oCriteria->add(ProcessPeer::PRO_UID, '', Criteria::NOT_EQUAL); $oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL); if ($reviewSubProcess) { $oCriteria->add(ProcessPeer::PRO_SUBPROCESS, '1', Criteria::NOT_EQUAL); } if (isset($category)) { $oCriteria->add(ProcessPeer::PRO_CATEGORY, $category, Criteria::EQUAL); } $oCriteria->addJoin(ProcessPeer::PRO_CREATE_USER, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $oCriteria->addJoin(ProcessPeer::PRO_CATEGORY, ProcessCategoryPeer::CATEGORY_UID, Criteria::LEFT_JOIN); if ($this->sort == "PRO_CREATE_DATE") { if ($this->dir == "DESC") { $oCriteria->addDescendingOrderByColumn(ProcessPeer::PRO_CREATE_DATE); } else { $oCriteria->addAscendingOrderByColumn(ProcessPeer::PRO_CREATE_DATE); } } if ($userLogged != "") { $oCriteria->add($oCriteria->getNewCriterion(ProcessPeer::PRO_TYPE_PROCESS, "PUBLIC", Criteria::EQUAL)->addOr($oCriteria->getNewCriterion(ProcessPeer::PRO_CREATE_USER, $userLogged, Criteria::EQUAL))); } $this->tmpCriteria = clone $oCriteria; //execute a query to obtain numbers, how many cases there are by process if ($counters) { $casesCnt = $this->getCasesCountInAllProcesses(); } // getting bpmn projects $c = new Criteria('workflow'); $c->addSelectColumn(BpmnProjectPeer::PRJ_UID); $ds = ProcessPeer::doSelectRS($c, Propel::getDbConnection('workflow_ro')); $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC); $bpmnProjects = array(); while ($ds->next()) { $row = $ds->getRow(); $bpmnProjects[] = $row['PRJ_UID']; } //execute the query $oDataset = ProcessPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $processes = array(); $uids = array(); while ($oDataset->next()) { $row = $oDataset->getRow(); $row["PROJECT_TYPE"] = $row["PRO_TYPE"] == "NORMAL" ? in_array($row["PRO_UID"], $bpmnProjects) ? "bpmn" : "classic" : $row["PRO_TYPE"]; $processes[] = $row; $uids[] = $processes[sizeof($processes) - 1]['PRO_UID']; } //process details will have the info about the processes $processesDetails = array(); //now get the labels for all process, using an array of Uids, $c = new Criteria('workflow'); //$c->add ( ContentPeer::CON_CATEGORY, 'PRO_TITLE', Criteria::EQUAL ); $c->add(ContentPeer::CON_LANG, defined('SYS_LANG') ? SYS_LANG : 'en', Criteria::EQUAL); $c->add(ContentPeer::CON_ID, $uids, Criteria::IN); $dt = ContentPeer::doSelectRS($c, Propel::getDbConnection('workflow_ro')); $dt->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($dt->next()) { $row = $dt->getRow(); $processesDetails[$row['CON_ID']][$row['CON_CATEGORY']] = $row['CON_VALUE']; } G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); foreach ($processes as $process) { $proTitle = isset($processesDetails[$process['PRO_UID']]) && isset($processesDetails[$process['PRO_UID']]['PRO_TITLE']) ? $processesDetails[$process['PRO_UID']]['PRO_TITLE'] : ''; $proDescription = isset($processesDetails[$process['PRO_UID']]) && isset($processesDetails[$process['PRO_UID']]['PRO_DESCRIPTION']) ? $processesDetails[$process['PRO_UID']]['PRO_DESCRIPTION'] : ''; $process["PRO_TYPE_PROCESS"] = $process["PRO_TYPE_PROCESS"] == "PUBLIC" ? G::LoadTranslation("ID_PUBLIC") : G::LoadTranslation("ID_PRIVATE"); // verify if the title is already set on the current language if (trim($proTitle) == '') { // if not, then load the record to generate content for current language $proData = $this->load($process['PRO_UID']); $proTitle = $proData['PRO_TITLE']; $proDescription = $proData['PRO_DESCRIPTION']; } //filtering by $processName if (isset($processName) && $processName != '' && stripos($proTitle, $processName) === false) { continue; } if ($counters) { $casesCountTotal = 0; if (isset($casesCnt[$process['PRO_UID']])) { foreach ($casesCnt[$process['PRO_UID']] as $item) { $casesCountTotal += $item; } } } //get user format from configuration $userOwner = isset($oConf->aConfig['format']) ? $oConf->aConfig['format'] : ''; $creationDateMask = isset($oConf->aConfig['dateFormat']) ? $oConf->aConfig['dateFormat'] : ''; if ($userOwner != '') { $userOwner = str_replace('@userName', $process['USR_USERNAME'], $userOwner); $userOwner = str_replace('@firstName', $process['USR_FIRSTNAME'], $userOwner); $userOwner = str_replace('@lastName', $process['USR_LASTNAME'], $userOwner); if ($userOwner == " ( )") { $userOwner = '-'; } } else { $userOwner = $process['USR_FIRSTNAME'] . ' ' . $process['USR_LASTNAME']; } //get date format from configuration if ($creationDateMask != '') { list($date, $time) = explode(' ', $process['PRO_CREATE_DATE']); list($y, $m, $d) = explode('-', $date); list($h, $i, $s) = explode(':', $time); $process['PRO_CREATE_DATE'] = date($creationDateMask, mktime($h, $i, $s, $m, $d, $y)); } $process['PRO_CATEGORY_LABEL'] = trim($process['PRO_CATEGORY']) != '' ? $process['CATEGORY_NAME'] : '- ' . G::LoadTranslation('ID_PROCESS_NO_CATEGORY') . ' -'; $process['PRO_TITLE'] = $proTitle; $process['PRO_DESCRIPTION'] = $proDescription; $process['PRO_DEBUG'] = $process['PRO_DEBUG']; $process['PRO_DEBUG_LABEL'] = $process['PRO_DEBUG'] == "1" ? G::LoadTranslation('ID_ON') : G::LoadTranslation('ID_OFF'); $process['PRO_STATUS_LABEL'] = $process['PRO_STATUS'] == 'ACTIVE' ? G::LoadTranslation('ID_ACTIVE') : G::LoadTranslation('ID_INACTIVE'); $process['PRO_CREATE_USER_LABEL'] = $userOwner; if ($counters) { $process['CASES_COUNT_TO_DO'] = isset($casesCnt[$process['PRO_UID']]['TO_DO']) ? $casesCnt[$process['PRO_UID']]['TO_DO'] : 0; $process['CASES_COUNT_COMPLETED'] = isset($casesCnt[$process['PRO_UID']]['COMPLETED']) ? $casesCnt[$process['PRO_UID']]['COMPLETED'] : 0; $process['CASES_COUNT_DRAFT'] = isset($casesCnt[$process['PRO_UID']]['DRAFT']) ? $casesCnt[$process['PRO_UID']]['DRAFT'] : 0; $process['CASES_COUNT_CANCELLED'] = isset($casesCnt[$process['PRO_UID']]['CANCELLED']) ? $casesCnt[$process['PRO_UID']]['CANCELLED'] : 0; $process['CASES_COUNT'] = $casesCountTotal; } unset($process['PRO_CREATE_USER']); $aProcesses[] = $process; } $memcache =& PMmemcached::getSingleton(SYS_SYS); if (isset($memcache) && $memcache->enabled == 1) { return $aProcesses; } if ($limit == '') { $limit = count($aProcesses); } if ($this->sort != "PRO_CREATE_DATE") { if ($this->dir == "ASC") { usort($aProcesses, array($this, "ordProcessAsc")); } else { usort($aProcesses, array($this, "ordProcessDesc")); } } return $aProcesses; }
/** * loadFields for email configuration * @autor Alvaro <*****@*****.**> */ public function loadFields() { G::loadClass('configuration'); $oConfiguration = new Configurations(); $oConfiguration->loadConfig($x, 'Emails', '', '', '', ''); $fields = $oConfiguration->aConfig; if (count($fields) > 0) { $this->success = count($fields) > 0; $passwd = $fields['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); $auxPass = explode('hash:', $passwdDec); if (count($auxPass) > 1) { if (count($auxPass) == 2) { $passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $fields['MESS_PASSWORD'] = $passwd; } $this->data = $fields; }
<?php require_once 'classes/model/AppCacheView.php'; $request = isset($_POST['request']) ? $_POST['request'] : (isset($_GET['request']) ? $_GET['request'] : null); switch ($request) { //check if the APP_CACHE VIEW table and their triggers are installed case 'info': $result = new stdClass(); $result->info = array(); //check the language, if no info in config about language, the default is 'en' G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; if (isset($appCacheViewEngine['LANG'])) { $lang = $appCacheViewEngine['LANG']; $status = strtoupper($appCacheViewEngine['STATUS']); } else { $confParams = array('LANG' => 'en', 'STATUS' => ''); $oConf->aConfig = $confParams; $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', ''); $lang = 'en'; $status = ''; } //get user Root from hash $result->info = array(); $result->error = false; //setup the appcacheview object, and the path for the sql files $appCache = new AppCacheView(); $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP); $res = $appCache->getMySQLVersion();
public function getSystemDate($dateTime) { $oConf = new Configurations(); $dateFormat = 'M d, Y'; $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); $creationDateMask = isset($oConf->aConfig['dateFormat']) ? $oConf->aConfig['dateFormat'] : ''; $creationDateMask = $creationDateMask == '' ? $dateFormat : $creationDateMask; if ($creationDateMask != '') { if (strpos($dateTime, ' ') !== false) { list($date, $time) = explode(' ', $dateTime); list($y, $m, $d) = explode('-', $date); list($h, $i, $s) = explode(':', $time); $dateTime = date($creationDateMask, mktime($h, $i, $s, $m, $d, $y)); } else { list($y, $m, $d) = explode('-', $dateTime); $newCreation = ''; $maskTime = array('d' => '%d', 'D' => '%A', 'j' => '%e', 'l' => '%A', 'N' => '%u', 'S' => '%d', 'w' => '%w', 'z' => '%j', 'W' => '%W', 'F' => '%B', 'm' => '%m', 'M' => '%B', 'n' => '%m', 'o' => '%Y', 'Y' => '%Y', 'y' => '%g', 'a' => '%P', 'A' => '%p', 'g' => '%l', 'G' => '%k', 'h' => '%I', 'H' => '%H', 'i' => '%M', 's' => '%S'); $creationDateMask = trim($creationDateMask); if (strpos($creationDateMask, ' \\d\\e ') !== false) { $creationDateMask = str_replace(' \\d\\e ', ' [xx] ', $creationDateMask); } for ($i = 0; $i < strlen($creationDateMask); $i++) { if ($creationDateMask[$i] != ' ' && isset($maskTime[$creationDateMask[$i]])) { $newCreation .= $maskTime[$creationDateMask[$i]]; } else { $newCreation .= $creationDateMask[$i]; } } $langLocate = SYS_LANG; if (G::toLower(PHP_OS) == 'linux' || G::toLower(PHP_OS) == 'darwin') { if (SYS_LANG == 'es') { $langLocate = 'es_ES'; } else { if (strlen(SYS_LANG) > 2) { $langLocate = str_replace('-', '_', SYS_LANG); } else { $langLocate = 'en_US'; } } } else { switch (SYS_LANG) { case 'es': case 'es_ES': $langLocate = 'ESN'; break; case 'pt': case 'pt-BR': $langLocate = 'PTB'; break; case 'en': case 'en-US': default: $langLocate = 'EST'; break; } } setlocale(LC_TIME, $langLocate); $dateTime = utf8_encode(strftime($newCreation, mktime(0, 0, 0, $m, $d, $y))); if (strpos($dateTime, ' ') !== false) { $dateTime = ucwords($dateTime); } if (strpos($dateTime, ' [xx] ') !== false) { $dateTime = str_replace('[xx]', ' de ', $dateTime); } } } return $dateTime; }
break; case 'userData': require_once 'classes/model/Users.php'; $_SESSION['CURRENT_USER'] = $_POST['USR_UID']; $oUser = new Users(); $aFields = $oUser->loadDetailed($_POST['USR_UID']); //Load Calendar options and falue for this user G::LoadClass('calendar'); $calendar = new Calendar(); $calendarInfo = $calendar->getCalendarFor($_POST['USR_UID'], $_POST['USR_UID'], $_POST['USR_UID']); //If the function returns a DEFAULT calendar it means that this object doesn't have assigned any calendar $aFields['USR_CALENDAR'] = $calendarInfo['CALENDAR_APPLIED'] != 'DEFAULT' ? $calendarInfo['CALENDAR_UID'] : ""; #verifying if it has any preferences on the configurations table G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], ''); $aFields['PREF_DEFAULT_MENUSELECTED'] = ''; $aFields['PREF_DEFAULT_CASES_MENUSELECTED'] = ''; if (sizeof($oConf->Fields) > 0) { // this user has a configuration record $aFields['PREF_DEFAULT_LANG'] = $oConf->aConfig['DEFAULT_LANG']; $aFields['PREF_DEFAULT_MENUSELECTED'] = isset($oConf->aConfig['DEFAULT_MENU']) ? $oConf->aConfig['DEFAULT_MENU'] : ''; $aFields['PREF_DEFAULT_CASES_MENUSELECTED'] = isset($oConf->aConfig['DEFAULT_CASES_MENU']) ? $oConf->aConfig['DEFAULT_CASES_MENU'] : ''; } else { switch ($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']) { case 'PROCESSMAKER_ADMIN': $aFields['PREF_DEFAULT_MENUSELECTED'] = 'PM_SETUP'; break; case 'PROCESSMAKER_OPERATOR': $aFields['PREF_DEFAULT_MENUSELECTED'] = 'PM_CASES'; break;
function getSystemDate($dateTime) { $oConf = new Configurations(); $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', ''); $creationDateMask = isset($oConf->aConfig['dateFormat']) ? $oConf->aConfig['dateFormat'] : ''; if ($creationDateMask != '') { if (strpos($dateTime, ' ') !== false) { list($date, $time) = explode(' ', $dateTime); list($y, $m, $d) = explode('-', $date); list($h, $i, $s) = explode(':', $time); $dateTime = date($creationDateMask, mktime($h, $i, $s, $m, $d, $y)); } else { list($y, $m, $d) = explode('-', $dateTime); $dateTime = date($creationDateMask, mktime(0, 0, 0, $m, $d, $y)); } } return $dateTime; }
function getProcessArray($action, $userUid) { global $oAppCache; $processes = array(); $processes[] = array("", G::LoadTranslation("ID_ALL_PROCESS")); switch ($action) { case "simple_search": case "search": //In search action, the query to obtain all process is too slow, so we need to query directly to //process and content tables, and for that reason we need the current language in AppCacheView. G::loadClass("configuration"); $oConf = new Configurations(); $oConf->loadConfig($x, "APP_CACHE_VIEW_ENGINE", "", "", "", ""); $appCacheViewEngine = $oConf->aConfig; $lang = isset($appCacheViewEngine["LANG"]) ? $appCacheViewEngine["LANG"] : "en"; $cProcess = new Criteria("workflow"); $cProcess->clearSelectColumns(); $cProcess->addSelectColumn(ProcessPeer::PRO_UID); $cProcess->addSelectColumn(ContentPeer::CON_VALUE); $del = DBAdapter::getStringDelimiter(); $conds = array(); $conds[] = array(ProcessPeer::PRO_UID, ContentPeer::CON_ID); $conds[] = array(ContentPeer::CON_CATEGORY, $del . "PRO_TITLE" . $del); $conds[] = array(ContentPeer::CON_LANG, $del . $lang . $del); $cProcess->addJoinMC($conds, Criteria::LEFT_JOIN); $cProcess->add(ProcessPeer::PRO_STATUS, "ACTIVE"); $oDataset = ProcessPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow["PRO_UID"], $aRow["CON_VALUE"]); $oDataset->next(); } return $processes; break; case "consolidated": default: $cProcess = $oAppCache->getToDoListCriteria($userUid); //fast enough break; } $cProcess->clearSelectColumns(); $cProcess->setDistinct(); $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID); $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE); $oDataset = AppCacheViewPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow["PRO_UID"], $aRow["APP_PRO_TITLE"]); $oDataset->next(); } return $processes; }
function getProcessArray($action, $userUid) { global $oAppCache; $processes = array(); $processes[] = array('', G::LoadTranslation('ID_ALL_PROCESS')); //get the list based in the action provided // G::pr($action);die; switch ($action) { case 'draft': $cProcess = $oAppCache->getDraftListCriteria($userUid); //fast enough break; case 'sent': $cProcess = $oAppCache->getSentListProcessCriteria($userUid); // fast enough break; case 'simple_search': case 'search': //in search action, the query to obtain all process is too slow, so we need to query directly to //process and content tables, and for that reason we need the current language in AppCacheView. G::loadClass('configuration'); $oConf = new Configurations(); $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', ''); $appCacheViewEngine = $oConf->aConfig; $lang = isset($appCacheViewEngine['LANG']) ? $appCacheViewEngine['LANG'] : 'en'; $cProcess = new Criteria('workflow'); $cProcess->clearSelectColumns(); $cProcess->addSelectColumn(ProcessPeer::PRO_UID); $cProcess->addSelectColumn(ContentPeer::CON_VALUE); $del = DBAdapter::getStringDelimiter(); $conds = array(); $conds[] = array(ProcessPeer::PRO_UID, ContentPeer::CON_ID); $conds[] = array(ContentPeer::CON_CATEGORY, $del . 'PRO_TITLE' . $del); $conds[] = array(ContentPeer::CON_LANG, $del . $lang . $del); $cProcess->addJoinMC($conds, Criteria::LEFT_JOIN); $cProcess->add(ProcessPeer::PRO_STATUS, 'ACTIVE'); $oDataset = ProcessPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow['PRO_UID'], $aRow['CON_VALUE']); $oDataset->next(); } return $processes; break; case 'unassigned': $cProcess = $oAppCache->getUnassignedListCriteria($userUid); break; case 'paused': $cProcess = $oAppCache->getPausedListCriteria($userUid); break; case 'to_revise': $cProcess = $oAppCache->getToReviseListCriteria($userUid); break; case 'to_reassign': $cProcess = $oAppCache->getToReassignListCriteria(); $cProcess->addAscendingOrderByColumn(AppCacheViewPeer::APP_PRO_TITLE); break; case 'gral': $cProcess = $oAppCache->getGeneralListCriteria(); $cProcess->addAscendingOrderByColumn(AppCacheViewPeer::APP_PRO_TITLE); break; case 'todo': default: $cProcess = $oAppCache->getToDoListCriteria($userUid); //fast enough break; } //get the processes for this user in this action $cProcess->clearSelectColumns(); $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID); $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE); $cProcess->setDistinct(AppCacheViewPeer::PRO_UID); $oDataset = AppCacheViewPeer::doSelectRS($cProcess); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $processes[] = array($aRow['PRO_UID'], $aRow['APP_PRO_TITLE']); $oDataset->next(); } return $processes; }