/** * @param $context \Workflow\VTEntity|\Workflow\VTInventoryEntity */ public function handleTask(&$context) { $referenceId = $context->getId(); Workflow2::$enableError = true; $parentRecordModel = Inventory_Record_Model::getInstanceById($referenceId); $currencyInfo = $parentRecordModel->getCurrencyInfo(); $taxes = $parentRecordModel->getProductTaxes(); $shippingTaxes = $parentRecordModel->getShippingTaxes(); $relatedProducts = $parentRecordModel->getProducts(); $recordModel = Vtiger_Record_Model::getCleanInstance('Invoice'); $recordModel->setRecordFieldValues($parentRecordModel); $recordModel->save(); $newId = $recordModel->getId(); $contextRecord = $context; /** * @var $newObj \Workflow\VTEntity|\Workflow\VTInventoryEntity */ $newObj = \Workflow\VTEntity::getForId($newId); $newObj->set('hdnTaxType', $parentRecordModel->get('hdnTaxType')); $newObj->importProductsFromRecord($relatedProducts, true); $setterMap = $this->get("setter"); $this->fieldSetter->apply($newObj, $setterMap, $contextRecord, $this); $newObj->save(); if ($this->get("redirectAfter") == "1") { $this->getWorkflow()->setSuccessRedirection("index.php?module=" . $newObj->getModuleName() . "&view=Detail&record=" . $newObj->getId()); } if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) { $newContext = VTEntity::getForId($newObj->getId(), $newObj->getModuleName()); $newContext->loadEnvironment($context->getEnvironment()); $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser()); $objWorkflow->isSubWorkflow(true); $objWorkflow->setContext($newContext); $objWorkflow->start(); } Workflow2::$enableError = true; }
protected function matchHandler($match) { ${"GLOBALS"}["xkaopqxzm"] = "match"; if (count(${${"GLOBALS"}["fzudcyrhgcof"]}) == 2) { if (${${"GLOBALS"}["fzudcyrhgcof"]}[0] == "\$current_user_id") { ${"GLOBALS"}["pcmwmi"] = "sql"; ${"GLOBALS"}["ikafodlyvv"] = "result"; global $current_user, $adb; ${${"GLOBALS"}["pcmwmi"]} = "SELECT id FROM vtiger_ws_entity WHERE name = 'Users'"; $qphgzkamlp = "wsTabId"; ${${"GLOBALS"}["ikafodlyvv"]} = $adb->query(${${"GLOBALS"}["tmrwyiij"]}); ${"GLOBALS"}["qtfuoyyj"] = "wsTabId"; ${$qphgzkamlp} = $adb->query_result(${${"GLOBALS"}["lpwetnmjxv"]}, 0, "id"); return ${${"GLOBALS"}["qtfuoyyj"]} . "x" . $current_user->id; } ${${"GLOBALS"}["tjyojamrs"]} = ${${"GLOBALS"}["fzudcyrhgcof"]}[1]; ${${"GLOBALS"}["mduamvfjsqip"]} = $this->_context->get(${${"GLOBALS"}["tjyojamrs"]}); if (${${"GLOBALS"}["mduamvfjsqip"]} === false) { $fhtdikgbwslw = "fieldname"; return "\$" . ${$fhtdikgbwslw}; } if (!empty(${${"GLOBALS"}["mduamvfjsqip"]})) { return ${${"GLOBALS"}["mduamvfjsqip"]}; } } elseif (substr(${${"GLOBALS"}["xkaopqxzm"]}[0], 0, 2) == "\$[") { $dijnlqw = "date"; $mqgzejwr = "parameter"; ${"GLOBALS"}["nmvdtxgwlrfi"] = "parameter"; ${"GLOBALS"}["ttjnpwjeoog"] = "function"; ${${"GLOBALS"}["nnvfnxph"]} = strtolower(${${"GLOBALS"}["fzudcyrhgcof"]}[3]); ${"GLOBALS"}["pwzsndhjqsu"] = "format"; ${"GLOBALS"}["smpvjojh"] = "time"; if (count(${${"GLOBALS"}["fzudcyrhgcof"]}) > 4 && ${${"GLOBALS"}["fzudcyrhgcof"]}[4] != "") { ${"GLOBALS"}["dpyjijot"] = "i"; $sotxthjssww = "parameter"; $cwegxum = "i"; ${"GLOBALS"}["abvuifgun"] = "i"; ${$sotxthjssww} = explode(",", ${${"GLOBALS"}["fzudcyrhgcof"]}[6]); for (${${"GLOBALS"}["abvuifgun"]} = 0; ${$cwegxum} < count(${${"GLOBALS"}["hcmotgp"]}); ${${"GLOBALS"}["dpyjijot"]}++) { ${"GLOBALS"}["grxhbqfel"] = "parameter"; $ligygcuopl = "i"; ${"GLOBALS"}["ndjfnng"] = "parameter"; ${${"GLOBALS"}["grxhbqfel"]}[${$ligygcuopl}] = trim(${${"GLOBALS"}["ndjfnng"]}[${${"GLOBALS"}["kmptlmxqx"]}], "'\" "); } } else { ${${"GLOBALS"}["hcmotgp"]} = false; } $jgqwmporwhlx = "parameter"; ${"GLOBALS"}["vrsthbowou"] = "time"; $rqvrwfirvnlx = "time"; ${"GLOBALS"}["bpcyoqq"] = "time"; ${"GLOBALS"}["ihnsia"] = "parameter"; ${"GLOBALS"}["fnrwpimqo"] = "parameter"; $jcrssxzdfxv = "parameter"; switch (${${"GLOBALS"}["ttjnpwjeoog"]}) { case "url": if (${$jcrssxzdfxv} != false && count(${${"GLOBALS"}["ihnsia"]}) > 0) { $mrpmif = "parameter"; $dqjrkbsn = "parameter"; $jzqqvbm = "parameter"; ${$dqjrkbsn}[0] = intval(${${"GLOBALS"}["hcmotgp"]}[0]); ${${"GLOBALS"}["xbpvinrmg"]} = VTEntity::getForId(${$mrpmif}[0]); global $site_URL; return ${${"GLOBALS"}["pvutchkhwqsg"]} . "/index.php?action=DetailView&module=" . $objTMP->getModuleName() . "&record=" . ${$jzqqvbm}[0]; } break; case "round": ${$jgqwmporwhlx}[0] = VTTemplate::parse(${${"GLOBALS"}["hcmotgp"]}[0], $this->_context); if (count(${${"GLOBALS"}["hcmotgp"]}) == 3 && ${${"GLOBALS"}["hcmotgp"]}[2] == "1") { ${"GLOBALS"}["alckvik"] = "return"; ${${"GLOBALS"}["alckvik"]} = \CurrencyField::convertToUserFormat(${${"GLOBALS"}["hcmotgp"]}[0]); } else { ${"GLOBALS"}["vlvxrxrbd"] = "return"; ${${"GLOBALS"}["vlvxrxrbd"]} = round(${${"GLOBALS"}["hcmotgp"]}[0], ${${"GLOBALS"}["hcmotgp"]}[1]); } return ${${"GLOBALS"}["eklrhak"]}; break; case "utctz": ${${"GLOBALS"}["nmvdtxgwlrfi"]}[0] = VTTemplate::parse(${${"GLOBALS"}["hcmotgp"]}[0], $this->_context); ${${"GLOBALS"}["eklrhak"]} = \DateTimeField::convertToDBTimeZone(${${"GLOBALS"}["hcmotgp"]}[0]); return $return->format("H:i:s"); break; case "dateformat": ${${"GLOBALS"}["hcmotgp"]}[0] = VTTemplate::parse(${${"GLOBALS"}["hcmotgp"]}[0], $this->_context); ${$rqvrwfirvnlx} = strtotime(${${"GLOBALS"}["hcmotgp"]}[0]); ${${"GLOBALS"}["gatkidfjf"]} = ${${"GLOBALS"}["hcmotgp"]}[1]; return date(${${"GLOBALS"}["gatkidfjf"]}, ${${"GLOBALS"}["bpcyoqq"]}); break; case "now": ${${"GLOBALS"}["pwzsndhjqsu"]} = "Y-m-d"; ${$dijnlqw} = \DateTimeField::convertToUserTimeZone(date("Y-m-d H:i:s")); ${${"GLOBALS"}["vrsthbowou"]} = strtotime($date->format("Y-m-d H:i:s")); if (${${"GLOBALS"}["fnrwpimqo"]} != false) { if (!empty(${${"GLOBALS"}["hcmotgp"]}[0])) { ${${"GLOBALS"}["okbxsjn"]} += intval(${${"GLOBALS"}["hcmotgp"]}[0]) * 86400; } if (!empty(${${"GLOBALS"}["hcmotgp"]}[1])) { ${"GLOBALS"}["ftrqsw"] = "parameter"; $mrgqelzfbcf = "format"; ${$mrgqelzfbcf} = ${${"GLOBALS"}["ftrqsw"]}[1]; } } return date(${${"GLOBALS"}["gatkidfjf"]}, ${${"GLOBALS"}["smpvjojh"]}); break; case "entityname": if (${$mqgzejwr} != false) { $cskxkqd = "parameter"; $hmnhgfaqeyo = "crmid"; $fcuyvjmvnnr = "parameter"; $gcsofxly = "parameter"; ${$fcuyvjmvnnr}[0] = VTTemplate::parse(${$gcsofxly}[0], $this->_context); if (is_array(${$cskxkqd}[0]) || is_object(${${"GLOBALS"}["hcmotgp"]}[0])) { ${"GLOBALS"}["fnlsgqesiuzo"] = "parameter"; throw new \Exception("Wrong input entityname: \$parameter=" . serialize(${${"GLOBALS"}["fnlsgqesiuzo"]}[0])); } ${"GLOBALS"}["bkvmzxylrca"] = "return"; ${"GLOBALS"}["vlrkemsbzk"] = "result"; if (strpos(${${"GLOBALS"}["hcmotgp"]}[0], "x") !== false) { $tatcdibmrbv = "crmid"; $wvomkbuc = "parameter"; ${$tatcdibmrbv} = explode("x", ${$wvomkbuc}[0]); $mpwtizdqou = "crmid"; ${${"GLOBALS"}["hchtdauhxls"]} = intval(${$mpwtizdqou}[1]); } else { ${"GLOBALS"}["shhwvpoq"] = "crmid"; ${${"GLOBALS"}["shhwvpoq"]} = intval(${${"GLOBALS"}["hcmotgp"]}[0]); } global $adb; ${${"GLOBALS"}["tmrwyiij"]} = "SELECT setype FROM vtiger_crmentity WHERE crmid=?"; ${${"GLOBALS"}["vlrkemsbzk"]} = $adb->pquery(${${"GLOBALS"}["tmrwyiij"]}, array(${${"GLOBALS"}["hchtdauhxls"]})); ${${"GLOBALS"}["ampkew"]} = $adb->fetchByAssoc(${${"GLOBALS"}["lpwetnmjxv"]}); ${${"GLOBALS"}["eklrhak"]} = getEntityName(${${"GLOBALS"}["ampkew"]}["setype"], array(${${"GLOBALS"}["hchtdauhxls"]})); return ${${"GLOBALS"}["bkvmzxylrca"]}[${$hmnhgfaqeyo}]; } else { return ""; } break; } } else { $kwkieejbxn = "full"; ${"GLOBALS"}["rvksgfjkohv"] = "matches"; ${"GLOBALS"}["jjauqvcq"] = "referenceModule"; $eyjfdznjzq = "referenceField"; ${"GLOBALS"}["ckvljbgm"] = "fieldname"; ${"GLOBALS"}["lzjihcwqljf"] = "referenceModule"; ${"GLOBALS"}["nijbiieuq"] = "match"; preg_match("/\\((\\w+) ?: \\(([_\\w]+)\\) (\\w+)\\)/", ${${"GLOBALS"}["nijbiieuq"]}[1], ${${"GLOBALS"}["vxkunswtk"]}); list(${$kwkieejbxn}, ${$eyjfdznjzq}, ${${"GLOBALS"}["jjauqvcq"]}, ${${"GLOBALS"}["ckvljbgm"]}) = ${${"GLOBALS"}["rvksgfjkohv"]}; if (${${"GLOBALS"}["ptyrsnuco"]} == "smownerid") { $oakmdiy = "referenceField"; ${$oakmdiy} = "assigned_user_id"; } if (${${"GLOBALS"}["lzjihcwqljf"]} === "__VtigerMeta__") { return $this->_getMetaValue(${${"GLOBALS"}["tjyojamrs"]}); } else { ${"GLOBALS"}["ewdyzm"] = "referenceModule"; $stlcjxh = "referenceField"; if (${$stlcjxh} != "current_user") { $conwshpzmoe = "referenceField"; ${"GLOBALS"}["utwbycs"] = "referenceField"; ${${"GLOBALS"}["itprpkcjk"]} = $this->_context->get(${$conwshpzmoe}); if (${${"GLOBALS"}["hncxzlio"]} == "Users" && ${${"GLOBALS"}["utwbycs"]} == "assigned_user_id") { $gcpjmebsqn = "values"; $lxcfhlasynj = "values"; ${${"GLOBALS"}["hustoopi"]} = $this->_context->getOwners(); ${$lxcfhlasynj} = $owner->get(${${"GLOBALS"}["tjyojamrs"]}); return implode(",", ${$gcpjmebsqn}); } if (empty(${${"GLOBALS"}["itprpkcjk"]})) { return ""; } } else { $mbxitu = "referenceId"; global $current_user; ${$mbxitu} = $current_user->id; } ${"GLOBALS"}["guyjkru"] = "fieldname"; ${"GLOBALS"}["xaflwfj"] = "referenceId"; ${${"GLOBALS"}["qoieougsqps"]} = VTEntity::getForId(${${"GLOBALS"}["xaflwfj"]}, ${${"GLOBALS"}["ewdyzm"]} == "Users" ? "Users" : false); return $entity->get(${${"GLOBALS"}["guyjkru"]}); } } }
public static function getQueueEntry($id = false) { $etxvhi = "id"; ${"GLOBALS"}["okpywhl"] = "sql"; $muhtijz = "removeFromQueue"; ${"GLOBALS"}["iubdeiy"] = "sql"; $gfpooucy = "id"; $xtdlril = "result"; global $adb; ${$muhtijz} = array(); ${${"GLOBALS"}["iubdeiy"]} = "SELECT *, vtiger_wf_queue.crmid as queue_crmid, vtiger_wf_queue.id as queue_id\n FROM vtiger_wf_queue\n INNER JOIN vtiger_wfp_blocks ON(vtiger_wfp_blocks.id = block_id)\n LEFT JOIN vtiger_crmentity ON(vtiger_crmentity.crmid = vtiger_wf_queue.crmid)\n WHERE " . (${$gfpooucy} !== false ? "vtiger_wf_queue.id = " . intval(${${"GLOBALS"}["fazahh"]}) : "nextStepTime < UTC_Timestamp() AND\n locked = 0 AND\n (\n vtiger_crmentity.deleted = 0 OR\n vtiger_crmentity.deleted IS NULL\n )\n AND vtiger_wf_queue.checkMode != 'running'") . " GROUP BY execID, block_id LIMIT 1"; ${"GLOBALS"}["ocnjsvqqlqa"] = "returns"; ${$xtdlril} = \Workflow\VtUtils::query(${${"GLOBALS"}["okpywhl"]}); ${${"GLOBALS"}["twyuvrvum"]} = array(); while (${${"GLOBALS"}["isqdglbip"]} = $adb->fetch_array(${${"GLOBALS"}["dnpzgnxsrrdc"]})) { $midtiify = "row"; ${"GLOBALS"}["buhvdwski"] = "row"; ${"GLOBALS"}["rnkppk"] = "returns"; ${${"GLOBALS"}["wphakn"]} = new \Users(); ${"GLOBALS"}["vqemxyqnium"] = "row"; $user->retrieveCurrentUserInfoFromFile(${$midtiify}["execution_user"]); ${"GLOBALS"}["wnlolbrfis"] = "row"; $fezxlytnrsh = "context"; $oyyadcolhg = "row"; $czdcipwmg = "workflow"; $yljopindof = "removeFromQueue"; ${"GLOBALS"}["jdxceujnsal"] = "objTask"; ${"GLOBALS"}["klwsotbkdu"] = "row"; if (!empty(${${"GLOBALS"}["isqdglbip"]}["setype"]) || ${${"GLOBALS"}["isqdglbip"]}["queue_crmid"] == "0") { ${"GLOBALS"}["rrkfgpxchhwk"] = "user"; ${"GLOBALS"}["kklogeva"] = "row"; ${"GLOBALS"}["gcufpisook"] = "context"; ${${"GLOBALS"}["gcufpisook"]} = VTEntity::getForId(intval(${${"GLOBALS"}["isqdglbip"]}["crmid"]), ${${"GLOBALS"}["kklogeva"]}["setype"], ${${"GLOBALS"}["rrkfgpxchhwk"]}); $context->loadEnvironment(@unserialize(html_entity_decode(${${"GLOBALS"}["isqdglbip"]}["environment"]))); } else { $gamcmhol = "sql"; ${"GLOBALS"}["oojbfcqtekm"] = "row"; ${$gamcmhol} = "DELETE FROM vtiger_wf_queue WHERE id = " . ${${"GLOBALS"}["oojbfcqtekm"]}["queue_id"]; \Workflow\VtUtils::query(${${"GLOBALS"}["fjvutiy"]}); continue; } ${$czdcipwmg} = new \Workflow\Main(${${"GLOBALS"}["buhvdwski"]}["workflow_id"], ${$fezxlytnrsh}, ${${"GLOBALS"}["wphakn"]}); ${"GLOBALS"}["eittbnwi"] = "row"; ${${"GLOBALS"}["slbroep"]} = \Workflow\Manager::getTaskHandler(${${"GLOBALS"}["eittbnwi"]}["type"], ${${"GLOBALS"}["isqdglbip"]}["block_id"], ${${"GLOBALS"}["tbpkfkvfo"]}); $objTask->setExecId(${${"GLOBALS"}["wnlolbrfis"]}["execid"]); $objTask->setWorkflowId(${${"GLOBALS"}["vqemxyqnium"]}["workflow_id"]); ${"GLOBALS"}["smhipkohm"] = "user"; ${${"GLOBALS"}["rnkppk"]}[] = array("queue_id" => ${${"GLOBALS"}["isqdglbip"]}["queue_id"], "delta" => base64_decode(${$oyyadcolhg}["delta"]), "id" => ${${"GLOBALS"}["isqdglbip"]}["workflow_id"], "context" => ${${"GLOBALS"}["wdposkwnkvui"]}, "user" => ${${"GLOBALS"}["smhipkohm"]}, "task" => ${${"GLOBALS"}["jdxceujnsal"]}); ${$yljopindof}[] = "('" . ${${"GLOBALS"}["klwsotbkdu"]}["execid"] . "', " . intval(${${"GLOBALS"}["isqdglbip"]}["block_id"]) . ")"; } if (count(${${"GLOBALS"}["ocnjsvqqlqa"]}) == 0) { ${${"GLOBALS"}["fjvutiy"]} = "SELECT *,\n vtiger_wf_queue.crmid as queue_crmid,\n vtiger_wf_queue.id as queue_id\n FROM vtiger_wf_queue\n INNER JOIN vtiger_wfp_blocks ON(vtiger_wfp_blocks.id = block_id)\n LEFT JOIN vtiger_wf_queue as queue2 ON(queue2.execID = vtiger_wf_queue.nextStepField)\n LEFT JOIN vtiger_crmentity ON(vtiger_crmentity.crmid = vtiger_wf_queue.crmid)\n WHERE\n vtiger_wf_queue.nextStepTime < UTC_Timestamp() AND\n vtiger_wf_queue.locked = 0 AND\n (\n vtiger_crmentity.deleted = 0 OR\n vtiger_crmentity.deleted IS NULL\n )\n AND vtiger_wf_queue.checkMode = 'running'\n AND queue2.id IS NULL\n GROUP BY vtiger_wf_queue.execID, vtiger_wf_queue.block_id LIMIT 1"; ${${"GLOBALS"}["dnpzgnxsrrdc"]} = \Workflow\VtUtils::query(${${"GLOBALS"}["fjvutiy"]}); $cikeyrcqk = "result"; ${"GLOBALS"}["mtgquvjvql"] = "row"; while (${${"GLOBALS"}["mtgquvjvql"]} = $adb->fetch_array(${$cikeyrcqk})) { $iidcmcduih = "row"; $psthrdq = "return"; ${$psthrdq}[] = self::getQueueEntry(${$iidcmcduih}["queue_id"]); } } ${"GLOBALS"}["uiqcbqjctnzm"] = "returns"; if (count(${${"GLOBALS"}["twyuvrvum"]}) > 0) { ${${"GLOBALS"}["fjvutiy"]} = "UPDATE vtiger_wf_queue SET locked = 1 WHERE (execid, block_id) IN (" . implode(",", ${${"GLOBALS"}["mxnpiug"]}) . ")"; ${"GLOBALS"}["ngdhjqwgosl"] = "sql"; \Workflow\VtUtils::query(${${"GLOBALS"}["ngdhjqwgosl"]}); date_default_timezone_set("UTC"); if (${${"GLOBALS"}["fazahh"]} === false) { echo "Continue " . count(${${"GLOBALS"}["twyuvrvum"]}) . " Workflows! [" . date("d.m.Y H:i:s") . "]" . "\n"; } } else { date_default_timezone_set("UTC"); ${"GLOBALS"}["jsolpy"] = "id"; if (${${"GLOBALS"}["jsolpy"]} === false) { echo "Nothing to do! [" . date("d.m.Y H:i:s") . "]"; } return false; } if (${$etxvhi} !== false) { ${"GLOBALS"}["txxttt"] = "returns"; return ${${"GLOBALS"}["txxttt"]}[0]; } return ${${"GLOBALS"}["uiqcbqjctnzm"]}; }
private function _nextCommand() { $return = ""; $this->_debug("[+] _nextCommand"); $this->_intend++; $nextToken = $this->_next(); if (is_string($nextToken)) { $this->_debug("[+] _runString \" " . $nextToken . " \""); } else { $this->_debug("[+] _runCommand (" . token_name($nextToken[0]) . ") [" . htmlentities($nextToken[1]) . "]"); } $this->_intend++; switch ($nextToken[0]) { case ";": # echo "Found ;"; # var_dump($return); #return $return; break; case T_IF: $return = $this->_run_if(); break; case T_FOREACH: $this->_run_foreach(); break; case T_ARRAY: $return = $this->_getFunctionParameters(); break; case T_VARIABLE: if ($this->_nextByReference == true) { $byRef = true; $this->_nextByReference = false; } else { $byRef = false; } $varName = substr($nextToken[1], 1); $tmpToken = $this->_next(false); $pointerSet = false; $varPointer = false; $addItem = false; if ($tmpToken == "[") { $keys = array(); $this->_debug('Array found'); while ($this->_next(false) == "[") { $this->_currentPos++; if ($this->_next(false) == "]") { $this->_currentPos++; $addItem = true; break; } $keys[] = $this->_getArrayKey(); } $pointerSet = true; $varPointer =& $this->_variables[$varName]; foreach ($keys as $key) { if (!is_array($varPointer)) { $varPointer = array(); } $pointerSet = true; $varPointer =& $varPointer[$key]; } if ($addItem == true) { if (!is_array(&$varPointer)) { $varPointer = array(); } array_push(&$varPointer, null); $pointerSet = true; $varPointer =& $varPointer[count($varPointer) - 1]; } } $tmpToken = $this->_next(false); // Wird eine Zuweisung if (!is_array($tmpToken) && $tmpToken == "=" || is_array($tmpToken) && in_array($tmpToken[0], array(T_PLUS_EQUAL, T_MINUS_EQUAL))) { $this->_debug(" # prepare Assignment [" . $varName . "]"); $this->_currentPos++; if (!is_array($tmpToken) || !in_array($tmpToken[0], array(T_PLUS_EQUAL, T_MINUS_EQUAL))) { $valueOfVariable = $this->_nextCommand(); } if (is_array($tmpToken) && in_array($tmpToken[0], array(T_PLUS_EQUAL, T_MINUS_EQUAL))) { if (!$pointerSet) { if (isset($this->_variables[$varName])) { $startvalue = $this->_variables[$varName]; $this->_debug(" # _getVariable [" . $varName . "] = " . $startvalue); } } else { $startvalue = $varPointer; $this->_debug(" # _getArrayVariable [" . $varName . "][" . implode("][", $keys) . "] = " . $startvalue); } } else { $startvalue = 0; } if (is_array($tmpToken) && $tmpToken[0] == T_MINUS_EQUAL) { $valueOfVariable = $startvalue - $this->_nextCommand(); } elseif (is_array($tmpToken) && $tmpToken[0] == T_PLUS_EQUAL) { $valueOfVariable = $startvalue + $this->_nextCommand(); } if ($varName == "disableFunctionlist" && $valueOfVariable == "1") { $this->_disableFunctionlist = true; } if (!$pointerSet) { $this->_debug(" # _setVariable [" . $varName . "] = " . serialize($valueOfVariable)); $this->_variables[$varName] = $valueOfVariable; } else { $this->_debug(" # _setArrayVariable [" . $varName . "][" . implode("][", $keys) . "] = " . serialize($valueOfVariable)); $varPointer = $valueOfVariable; } } elseif (isset($this->_variables[$varName]) || $pointerSet) { if (!$pointerSet) { if ($byRef == true) { $value =& $this->_variables[$varName]; } else { $value = $this->_variables[$varName]; } $this->_debug(" # _getVariable " . ($byRef == true ? "&" : "") . "[" . $varName . "] = " . $value); } else { if ($byRef == true) { $value =& $varPointer; } else { $value = $varPointer; } $this->_debug(" # _getArrayVariable " . ($byRef == true ? "&" : "") . "[" . $varName . "][" . implode("][", $keys) . "] = " . $value); } $return = $value; } elseif (is_array($tmpToken) && $tmpToken[0] == T_OBJECT_OPERATOR) { $this->_debug(" # _getValue from reference"); $this->_currentPos++; $moduleToken = $this->_next(false); if ($varName != "current_user") { /** * @var $reference VTEntity */ $reference = $this->_context->getReference($moduleToken[1], $varName); } else { global $current_user; /** * @var $reference VTEntity */ $reference = VTEntity::getForId($current_user->id, $moduleToken[1]); } $this->_currentPos++; $tmpToken = $this->_next(false); if (is_array($tmpToken) && $tmpToken[0] == T_OBJECT_OPERATOR) { $this->_currentPos++; $tmpToken = $this->_next(false); $this->_currentPos++; if ($reference instanceof VTEntity) { $return = $reference->get($tmpToken[1]); } else { #error_log("No Reference defined for $".$varName."->".$moduleToken[1]); throw new ExpressionException("No Reference defined for \$" . $varName . "->" . $moduleToken[1]); } } else { throw new ExpressionException("Error in ExpressionParser near \$" . $varName . "->" . $moduleToken[1]); } } else { $return = $this->_context->get($varName); $this->_debug(" # _getValue {$varName} = ('" . $return . "')"); } #var_dump($this->_variables); break; case T_DNUMBER: $return = $nextToken[1]; break; case T_STRING: if (defined($nextToken[1])) { $this->_debug(" # Constant Found"); $return = constant($nextToken[1]); } elseif (function_exists("VT_" . $nextToken[1])) { $this->_debug(" # Custom function"); // Methodennamen werden umgeschrieben um nur bestimmte Funktionen zuzulassen $methodName = "VT_" . $nextToken[1]; $parameter = $this->_getFunctionParameters(); $return = call_user_func_array($methodName, $parameter); } elseif ($this->_disableFunctionlist || in_array($nextToken[1], self::$WhitelistPHPfunctions) || substr($nextToken[1], 0, 3) == "str" || substr($nextToken[1], 0, 5) == "array" || substr($nextToken[1], 0, 3) == "wf_" || substr($nextToken[1], 0, 5) == "array") { $this->_debug(" # Whitelisted PHP Function"); $parameter = $this->_getFunctionParameters(); $return = call_user_func_array($nextToken[1], $parameter); } break; case "-": #$this->_currentPos++; $nextValue = $this->_next(); $return = -1 * $nextValue[1]; break; case "&": $this->_nextByReference = true; break; case "(": $return = $this->_nextCommand(); $this->_currentPos++; break; case ")": $this->_debug(" RETURN Brackets ['" . $return . "']"); $this->_intend--; return $return; break; case T_LNUMBER: $return = floatval($nextToken[1]); break; case T_CONSTANT_ENCAPSED_STRING: if ((substr($nextToken[1], 0, 1) == "'" || substr($nextToken[1], 0, 1) == '"') && substr($nextToken[1], -1, 1) == substr($nextToken[1], 0, 1)) { $nextToken[1] = trim($nextToken[1], "'" . '"'); } $return = $nextToken[1]; break; case T_RETURN: $return = $this->_nextCommand(); $this->_setReturn($return); break; case T_COMMENT: $return = $this->_nextCommand(); break; case T_IS_NOT_IDENTICAL: case T_IS_IDENTICAL: case T_IS_EQUAL: case T_IS_GREATER_OR_EQUAL: case T_IS_IDENTICAL: case T_IS_NOT_EQUAL: case T_IS_NOT_IDENTICAL: case T_IS_SMALLER_OR_EQUAL: $this->_currentPos--; $return = false; break; default: break; } $this->_debug(" potential next: " . $this->_next(false)); if ($this->_next(false) == ")") { #$this->_intend--; #return $return; } if ($this->_next(false) == ".") { $this->_currentPos++; $this->_debug("[ ] _foundCombination"); $return .= $this->_nextCommand(); } $this->_intend--; $tmpToken = $this->_next(false); if (in_array($tmpToken, array("+", "-", "*", "/", "^"))) { $this->_debug(" found Operation"); $this->_currentPos++; $valueOfVariable = $this->_nextCommand(); if (empty($return)) { $return = 0; } if (empty($valueOfVariable)) { $valueOfVariable = 0; } $this->_debug(" run Operation ('return " . $return . " " . $tmpToken . " " . $valueOfVariable . ";')"); $return = eval('return ' . $return . ' ' . $tmpToken . ' ' . $valueOfVariable . ';'); } $this->_intend--; $this->_debug("[-] _nextCommand ['" . htmlentities($return . "") . "']"); return $return; }
protected function matchHandler($match) { // Wenn count($match) == 2, dann nur $email und keine referenzierten Felder if (count($match) == 2) { // Special Variables if ($match[0] == '$current_user_id') { global $current_user, $adb; $sql = "SELECT id FROM vtiger_ws_entity WHERE name = 'Users'"; $result = $adb->query($sql); $wsTabId = $adb->query_result($result, 0, "id"); return $wsTabId . "x" . $current_user->id; } $fieldname = $match[1]; $fieldvalue = $this->_context->get($fieldname); if ($fieldvalue === false) { return '$' . $fieldname; } if (!empty($fieldvalue)) { return $fieldvalue; } // it is a global function } elseif (substr($match[0], 0, 2) == "\$[") { $function = strtolower($match[3]); if (count($match) > 4 && $match[4] != "") { $parameter = explode(",", $match[6]); for ($i = 0; $i < count($parameter); $i++) { $parameter[$i] = trim($parameter[$i], "'\" "); } } else { $parameter = false; } switch ($function) { case "url": if ($parameter != false && count($parameter) > 0) { $parameter[0] = intval($parameter[0]); $objTMP = VTEntity::getForId($parameter[0]); global $site_URL; return $site_URL . '/index.php?action=DetailView&module=' . $objTMP->getModuleName() . '&record=' . $parameter[0]; } break; case "now": $format = "Y-m-d"; $time = time(); if ($parameter != false) { if (!empty($parameter[0])) { $time += intval($parameter[0]) * 86400; } if (!empty($parameter[1])) { $format = $parameter[1]; } } return date($format, $time); break; case "entityname": if ($parameter != false) { $parameter[0] = VTTemplate::parse($parameter[0], $this->_context); if (strpos($parameter[0], "x") !== false) { $crmid = explode("x", $parameter[0]); $crmid = intval($crmid[1]); } else { $crmid = intval($parameter[0]); } global $adb; $sql = "SELECT setype FROM vtiger_crmentity WHERE crmid=?"; $result = $adb->pquery($sql, array($crmid)); $data = $adb->fetchByAssoc($result); $return = getEntityName($data['setype'], array($crmid)); return $return[$crmid]; } else { return ""; } break; } } else { preg_match('/\\((\\w+) ?: \\(([_\\w]+)\\) (\\w+)\\)/', $match[1], $matches); list($full, $referenceField, $referenceModule, $fieldname) = $matches; if ($referenceField == "smownerid") { $referenceField = "assigned_user_id"; } if ($referenceModule === '__VtigerMeta__') { return $this->_getMetaValue($fieldname); } else { if ($referenceField != "current_user") { $referenceId = $this->_context->get($referenceField); if ($referenceId == null) { return ""; } } else { global $current_user; $referenceId = $current_user->id; } $entity = VTEntity::getForId($referenceId, $referenceModule == "Users" ? "Users" : false); return $entity->get($fieldname); } } }