/**
  * @param $context \Workflow\VTEntity
  * @return string
  */
 public function handleTask(&$context)
 {
     $regex = $this->get("regex", $context);
     $source = $this->get("source", $context);
     $index = $this->get("targetindex");
     $envVar = $this->get("env_var");
     $this->addStat("Source:" . $source);
     if (!empty($regex)) {
         try {
             @preg_match($regex, $source, $matches);
         } catch (Exception $exp) {
             Workflow2::error_handler(E_NONBREAK_ERROR, $exp->getMessage());
             return "no";
         }
         if (count($matches) >= $index) {
             $testresult = $matches[$index];
         } else {
             $testresult = "";
         }
     } else {
         $testresult = getTranslatedString("LBL_BEFORE_TEST_SET_REGEX", "Workflow2");
     }
     $context->setEnvironment($envVar, $testresult);
     return "yes";
 }
예제 #2
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["jhslxixksw"] = "id";
     $hbtbpmlh = "path";
     ${"GLOBALS"}["lxinqwn"] = "params";
     ${${"GLOBALS"}["yetinhmxt"]} = PearDatabase::getInstance();
     $ougpgodj = "filename";
     ${${"GLOBALS"}["lxinqwn"]} = $request->getAll();
     ${${"GLOBALS"}["jhslxixksw"]} = $request->get("id");
     $wdittud = "id";
     $hsnxkpbpjgl = "path";
     ${"GLOBALS"}["ospxotjg"] = "filename";
     ${$ougpgodj} = $request->get("filename");
     ${$hbtbpmlh} = vglobal("root_directory") . "/modules/Workflow2/tmp/download/" . ${$wdittud};
     if (!file_exists(${$hsnxkpbpjgl})) {
         \Workflow2::error_handler(E_ERROR, "File to download not found! You could download a file only one time!");
     }
     header("Pragma: public");
     ${"GLOBALS"}["bjnhsjrlsql"] = "path";
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: public");
     header("Content-Description: File Transfer");
     header("Content-type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"" . ${${"GLOBALS"}["ospxotjg"]} . "\"");
     header("Content-Transfer-Encoding: binary");
     header("Content-Length: " . filesize(${${"GLOBALS"}["bjnhsjrlsql"]}));
     @readfile(${${"GLOBALS"}["rxsnhyopph"]});
     @unlink(${${"GLOBALS"}["rxsnhyopph"]});
     exit;
 }
예제 #3
0
 public function handleTask(&$context)
 {
     /* Insert here source code to execute the task */
     global $adb;
     $documentId = $context->get("id");
     if (strpos($documentId, 'x') !== false) {
         $TMP = explode("x", $documentId);
         $documentId = $TMP[1];
     }
     $context->save();
     $sql = "SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = " . $documentId;
     $result = $adb->query($sql, true);
     $fileid = $adb->query_result($result, 0, "attachmentsid");
     $pathQuery = $adb->pquery("select path, name from vtiger_attachments where attachmentsid = ?", array($fileid), true);
     $filepath = "../../../" . $adb->query_result($pathQuery, 0, 'path');
     $filename = $adb->query_result($pathQuery, 0, 'name');
     $saved_filename = $fileid . "_" . utf8_encode(html_entity_decode(html_entity_decode($filename)));
     $path = realpath(dirname(__FILE__) . "/" . $filepath . $saved_filename);
     $create_dir = $this->get("create_dir");
     #var_dump($path);exit();
     //        $sql = "SELECT * FROM
     //                vtiger_attachments
     //            INNER JOIN vtiger_seattachmentsrel ON(vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid)
     //            INNER JOIN vtiger_notes ON(vtiger_notes.notesid = vtiger_seattachmentsrel.crmid)
     //        WHERE vtiger_attachments.attachmentsid = ".intval($attachmentid);
     //        $result = $adb->query($sql);
     try {
         $this->initDropbox();
         #$tmp = tempnam('/tmp', 'dropbox');
         #$data = 'This file was uploaded using the Dropbox API!';
         #file_put_contents($tmp, $data);
         $directory = $this->get("filepath");
         self::$dropbox->setRoot("dropbox");
         if (!empty($create_dir)) {
             $parser = new VTWfExpressionParser($create_dir, $context, false);
             # Last Parameter = DEBUG
             try {
                 $parser->run();
             } catch (\Workflow\ExpressionException $exp) {
                 Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             $newDir = $parser->getReturn();
             $found = self::$dropbox->search($newDir, $directory);
             if (empty($found["body"]) || count($found["body"]) == 0) {
                 self::$dropbox->create($directory);
             }
             $directory = $directory . "/" . $newDir;
         }
         $put = self::$dropbox->putFile($path, $newDir . "/" . $filename, $directory);
     } catch (Exception $exp) {
         Workflow2::error_handler(E_NONBREAK_ERROR, $exp->getMessage(), $exp->getFile(), $exp->getLine());
     }
     return "yes";
 }
예제 #4
0
 public function handleTask(&$context)
 {
     $conditions = $this->get("condition");
     $parser = new \Workflow\ExpressionParser($conditions, $context, false);
     # Last Parameter = DEBUG
     try {
         $parser->run();
     } catch (\Workflow\ExpressionException $exp) {
         \Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
     }
     $return = $parser->getReturn();
     if ($return != "yes" && $return != "no") {
         $return = "no";
     }
     return $return;
 }
 public function handleTask(&$context)
 {
     /* Insert here source code to execute the task */
     $products = $context->exportInventory();
     $products = $products['listitems'];
     $checked = new \Workflow\ConditionCheck();
     $logger = new \Workflow\ConditionLogger();
     $conditions = $this->get('condition');
     $expression = $this->get('expression');
     $environment = $context->getEnvironment();
     foreach ($products as $product) {
         $productContext = \Workflow\VTEntity::getForId($product['productid'], 'Products');
         $productContext->loadEnvironment($environment);
         $checked->setLogger($logger);
         $return = $checked->check($conditions, $productContext);
         $logs = $logger->getLogs();
         $logs[] = "Complete Result: " . intval($return);
         $this->setStat($logs);
         $logger->clearLogs();
         if ($return == true) {
             $parser = new \Workflow\ExpressionParser($expression, $productContext, false);
             # Last Parameter = DEBUG
             $parser->setVariable('quantity', $product['quantity']);
             $parser->setVariable('unitprice', $product['unitprice']);
             $parser->setVariable('discount_amount', $product['discount_amount']);
             $parser->setVariable('discount_percent', $product['discount_percent']);
             try {
                 $parser->run();
             } catch (\Workflow\ExpressionException $exp) {
                 Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             $environment = $productContext->getEnvironment();
             if ($parser->getReturn() === 'stop') {
                 break;
             }
         }
     }
     $context->loadEnvironment($environment);
     return "yes";
 }
예제 #6
0
 public function handleTask(&$context)
 {
     global $adb;
     if (defined("WF_DEMO_MODE") && constant("WF_DEMO_MODE") == true) {
         return "yes";
     }
     $query = $this->get("query", $context);
     $envVar = $this->get("envvar", $context);
     if (empty($envVar)) {
         Workflow2::error_handler(E_NONBREAK_ERROR, "You must configure an environment variable in this block to get the correct result.");
     }
     $oldDieOnError = $adb->dieOnError;
     $adb->dieOnError = false;
     $this->addStat($query);
     try {
         $result = $adb->query($query, false);
         $errorNo = $adb->database->ErrorNo();
         if (!empty($errorNo)) {
             Workflow2::error_handler(E_NONBREAK_ERROR, $adb->database->ErrorMsg());
         } else {
             if (!empty($envVar)) {
                 if ($adb->num_rows($result) > 0) {
                     $row = $adb->fetchByAssoc($result);
                     $context->setEnvironment($envVar, $row);
                 }
             }
         }
         # need vtiger Database to reset Selected DB in the case the query changed this
         global $dbconfig;
         $adb->database->SelectDB($dbconfig['db_name']);
     } catch (Exception $exp) {
         Workflow2::error_handler(E_NONBREAK_ERROR, $exp->getMessage());
     }
     $adb->dieOnError = $oldDieOnError;
     return "yes";
 }
 /**
  * @param $context \Workflow\VTEntity
  * @return string
  */
 public function handleTask(&$context)
 {
     global $adb;
     $currentTime = microtime(true);
     $benchmark = array();
     if ($this->get("search_module") == -1) {
         return "no";
     }
     $found_rows = $this->get("found_rows");
     if (empty($found_rows) || $found_rows == -1) {
         $found_rows = 1;
     }
     $parts = explode("#~#", $this->get("search_module"));
     $functionName = $parts[0];
     $related_module = VtUtils::getModuleName($parts[1]);
     $logger = new \Workflow\ConditionLogger();
     $objMySQL = new \Workflow\ConditionMysql($related_module, $context);
     $objMySQL->setLogger($logger);
     $main_module = \CRMEntity::getInstance($related_module);
     #$sqlTables = $main_module->generateReportsQuery($related_module);
     if ($related_module == "Calendar") {
         #$sqlTables .= " LEFT JOIN vtiger_seactivityrel ON(vtiger_seactivityrel.activityid = vtiger_crmentity.crmid)";
     }
     $sqlCondition = $objMySQL->parse($this->get("condition"));
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $sqlTables = $objMySQL->generateTables();
     if (strlen($sqlCondition) > 3) {
         $sqlCondition .= " AND vtiger_crmentity.deleted = 0";
     } else {
         $sqlCondition .= " vtiger_crmentity.deleted = 0";
     }
     $logs = $logger->getLogs();
     $this->setStat($logs);
     $sqlCondition .= " GROUP BY vtiger_crmentity.crmid ";
     $idColumn = $main_module->table_name . "." . $main_module->table_index;
     $sqlQuery = "SELECT {$idColumn} as `idCol` " . $sqlTables . " WHERE " . (strlen($sqlCondition) > 3 ? $sqlCondition : "");
     $sortField = $this->get("sort_field");
     if (!empty($sortField) && $sortField != -1) {
         $sortField = VtUtils::getColumnName($sortField);
         $sortDirection = $this->get("sortDirection");
         $sqlQuery .= " ORDER BY " . $sortField . " " . $sortDirection;
     }
     $numRows = $this->get("found_rows");
     if (!empty($numRows) && $numRows != -1) {
         $sqlQuery .= " LIMIT " . $found_rows;
     }
     #var_dump(nl2br($sqlQuery));exit();
     $this->addStat("MySQL Query: " . $sqlQuery);
     $result = $adb->query($sqlQuery);
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $this->addStat("num Rows: " . $adb->num_rows($result));
     # If no records are found, fo other way
     if ($adb->num_rows($result) == 0) {
         return "no";
     }
     $environment = $context->getEnvironment();
     while ($row = $adb->fetchByAssoc($result)) {
         $expression = $this->get("expression");
         if (!empty($expression)) {
             $tmpContext = \Workflow\VTEntity::getForId($row["idcol"], $related_module);
             $tmpContext->loadEnvironment($environment);
             $parser = new \Workflow\ExpressionParser($expression, $tmpContext, false);
             # Last Parameter = DEBUG
             try {
                 $parser->run();
             } catch (ExpressionException $exp) {
                 Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             $environment = $tmpContext->getEnvironment();
         }
     }
     # while
     $newTime = microtime(true);
     $benchmark[] = round($newTime - $currentTime, 3);
     $currentTime = $newTime;
     $context->loadEnvironment($environment);
     $this->addStat("Benchmark: " . implode("/", $benchmark));
     return "yes";
 }
 public function handleTask(&$context)
 {
     $setterMap = $this->get("setter");
     $globalMap = $this->get("global");
     $products = $this->get("product");
     $shippingCost = 0;
     $newModule = $this->get("new_module");
     if (empty($newModule)) {
         $this->addStat("NO Configuration set");
         return "yes";
     }
     /**
      * @var $newObj \Workflow\VTInventoryEntity
      */
     $newObj = \Workflow\VTEntity::create($newModule);
     try {
         foreach ($setterMap as $setter) {
             if (!empty($setter["field"]) && $setter["field"] == "currency_id") {
                 $setter["value"] = vtws_getWebserviceEntityId("Currency", $setter["value"]);
             }
             if ($setter["mode"] == "function") {
                 $parser = new VTWfExpressionParser($setter["value"], $context, false);
                 # Last Parameter = DEBUG
                 try {
                     $parser->run();
                 } catch (\Workflow\ExpressionException $exp) {
                     Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
                 }
                 $newValue = $parser->getReturn();
             } else {
                 $setter["value"] = \Workflow\VTTemplate::parse($setter["value"], $context);
                 $newValue = $setter["value"];
             }
             $this->addStat("`" . $setter["field"] . "` = '" . $newValue . "'");
             if ($setter["field"] == "hdnS_H_Amount") {
                 $shippingCost = $newValue;
             }
             #            var_dump($setter["field"], $newValue);
             $newObj->set($setter["field"], $newValue);
         }
     } catch (Exception $e) {
         var_dump($e);
         // ONLY ERROR
     }
     try {
         $newObj->save();
     } catch (WebServiceException $exp) {
         // Somethink is wrong with the values. missing mandatory fields?
     }
     $context->setEnvironment("new_record_id", $newObj->getWsId(), $this);
     if ($this->get("redirectAfter") == "1") {
         $this->getWorkflow()->setSuccessRedirection($newObj->getDetailUrl());
     }
     $groupTaxes = array();
     $shipTaxes = array();
     foreach ($globalMap as $globalKey => $globalValue) {
         $globalValue = \Workflow\VTTemplate::parse($globalValue, $context);
         if (strpos($globalKey, "_group_percentage") !== false) {
             $groupTaxes[$globalKey] = $globalValue;
         }
         if (strpos($globalKey, "_sh_percent") !== false) {
             $shipTaxes[$globalKey] = $globalValue;
         }
         $this->addStat("`" . $globalKey . "` = '" . $globalValue . "'");
     }
     $newObj->setGroupTaxes($groupTaxes);
     $newObj->setShipTaxes($shipTaxes);
     $newObj->setShippingCost($shippingCost);
     $newObj->save();
     $newObj = $this->_productchooser->addProducts2Entity($this->get('product'), $context, $newObj);
     $newObj->save();
     if ($this->get("exec_workflow") !== "" && $this->get("exec_workflow") != -1) {
         $newContext = \Workflow\VTEntity::getForId($newObj->getId(), $newObj->getModuleName());
         $objWorkflow = new \Workflow\Main($this->get("exec_workflow"), false, $context->getUser());
         $newContext->loadEnvironment($context->getEnvironment());
         $objWorkflow->setContext($newContext);
         $objWorkflow->isSubWorkflow(true);
         $objWorkflow->start();
     }
     Workflow2::$enableError = true;
     return 'yes';
 }
예제 #9
0
 /**
  * @param $context \Workflow\VTEntity
  * @return mixed
  */
 public function handleTask(&$context)
 {
     global $adb, $current_user;
     global $current_language;
     if (defined("WF_DEMO_MODE") && constant("WF_DEMO_MODE") == true) {
         return "yes";
     }
     if (!class_exists("Workflow_PHPMailer")) {
         require_once "modules/Workflow2/phpmailer/class.phpmailer.php";
     }
     #$result = $adb->query("select user_name, email1, email2 from vtiger_users where id=1");
     #$from_email = "*****@*****.**";
     #$from_name  = "Stefan Warnat";
     $module = $context->getModuleName();
     $et = new \Workflow\VTTemplate($context);
     $to_email = $et->render(trim($this->get("recepient")), ",");
     #
     $connected = $this->getConnectedObjects("Absender");
     if (count($connected) > 0) {
         $from_name = trim($connected[0]->get("first_name") . " " . $connected[0]->get("last_name"));
         $from_email = $connected[0]->get("email1");
     } else {
         $from_name = $et->render(trim($this->get("from_name")), ",");
         #
         $from_email = $et->render(trim($this->get("from_mail")), ",");
         #
     }
     $cc = $et->render(trim($this->get("emailcc")), ",");
     #
     $bcc = $et->render(trim($this->get("emailbcc")), ",");
     #
     /**
      * Connected BCC Objects
      * @var $connected
      */
     $connected = $this->getConnectedObjects("BCC");
     $bccs = $connected->get("email1");
     if (count($bccs) > 0) {
         $bcc = array($bcc);
         foreach ($bccs as $bccTMP) {
             $bcc[] = $bccTMP;
         }
         $bcc = trim(implode(",", $bcc), ",");
     }
     if (strlen(trim($to_email, " \t\n,")) == 0 && strlen(trim($cc, " \t\n,")) == 0 && strlen(trim($bcc, " \t\n,")) == 0) {
         return "yes";
     }
     $storeid = trim($this->get("storeid", $context));
     if (empty($storeid) || $storeid == -1 || !is_numeric($storeid)) {
         $storeid = $context->getId();
     }
     $embeddedImages = array();
     $content = $this->get("content");
     $subject = $this->get("subject");
     #$subject = utf8_decode($subject);
     #$content = utf8_encode($content);
     $content = html_entity_decode(str_replace(" ", " ", $content), ENT_QUOTES, "UTF-8");
     #$subject = html_entity_decode(str_replace(" ", " ", $subject), ENT_QUOTES, "UTF-8");
     $subject = $et->render(trim($subject));
     $content = $et->render(trim($content));
     $mailtemplate = $this->get("mailtemplate");
     if (!empty($mailtemplate) && $mailtemplate != -1) {
         if (strpos($mailtemplate, 's#') === false) {
             $sql = "SELECT * FROM vtiger_emailtemplates WHERE templateid = " . intval($mailtemplate);
             $result = $adb->query($sql);
             $mailtemplate = $adb->fetchByAssoc($result);
             $content = str_replace('$mailtext', $content, html_entity_decode($mailtemplate["body"], ENT_COMPAT, 'UTF-8'));
             $content = Vtiger_Functions::getMergedDescription($content, $context->getId(), $context->getModuleName());
         } else {
             $parts = explode('#', $mailtemplate);
             switch ($parts[1]) {
                 case 'emailmaker':
                     $templateid = $parts[2];
                     $sql = 'SELECT body, subject FROM vtiger_emakertemplates WHERE templateid = ?';
                     $result = $adb->pquery($sql, array($templateid));
                     $EMAILContentModel = \EMAILMaker_EMAILContent_Model::getInstance($this->getModuleName(), $context->getId(), $current_language, $context->getId(), $this->getModuleName());
                     $EMAILContentModel->setSubject($adb->query_result($result, 0, 'subject'));
                     $EMAILContentModel->setBody($adb->query_result($result, 0, 'body'));
                     $EMAILContentModel->getContent(true);
                     $embeddedImages = $EMAILContentModel->getEmailImages();
                     $subject = $EMAILContentModel->getSubject();
                     $content = $EMAILContentModel->getBody();
                     break;
             }
         }
     }
     #$content = htmlentities($content, ENT_NOQUOTES, "UTF-8");
     if (getTabid('Emails') && vtlib_isModuleActive('Emails')) {
         require_once 'modules/Emails/Emails.php';
         $focus = new Emails();
         $focus->column_fields["assigned_user_id"] = \Workflow\VTEntity::getUser()->id;
         $focus->column_fields["activitytype"] = "Emails";
         $focus->column_fields["date_start"] = date("Y-m-d");
         $focus->column_fields["parent_id"] = $storeid;
         $focus->column_fields["email_flag"] = "SAVED";
         $focus->column_fields["subject"] = $subject;
         $focus->column_fields["description"] = $content;
         $focus->column_fields["from_email"] = $from_email;
         $focus->column_fields["saved_toid"] = '["' . str_replace(',', '","', trim($to_email, ",")) . '"]';
         $focus->column_fields["ccmail"] = $cc;
         $focus->column_fields["bccmail"] = $bcc;
         $focus->save("Emails");
         $this->_mailRecord = $focus;
         #error_log("eMail:".$emailID);
         $emailID = $focus->id;
     } else {
         $emailID = "";
     }
     $attachments = json_decode($this->get("attachments"), true);
     if (is_array($attachments) && count($attachments) > 0) {
         // Module greifen auf Datenbank zurück. Daher vorher speichern!
         $context->save();
         foreach ($attachments as $key => $value) {
             if ($value == false) {
                 continue;
             }
             if (is_string($value)) {
                 $value = array($value, false, array());
             }
             // legacy check
             if (strpos($key, 'document#') === 0) {
                 $key = 's#' . $key;
             }
             if (strpos($key, 's#') === 0) {
                 $tmpParts = explode('#', $key, 2);
                 $specialAttachments = \Workflow\Attachment::getAttachments($tmpParts[1], $value, $context, \Workflow\Attachment::MODE_NOT_ADD_NEW_ATTACHMENTS);
                 foreach ($specialAttachments as $attachment) {
                     if ($attachment[0] === 'ID') {
                         $this->attachByAttachmentId($attachment[1]);
                     } elseif ($attachment[0] === 'PATH') {
                         $this->attachFile($attachment[1], $attachment[2], $attachment[3]);
                     }
                 }
             } else {
                 $file = \Workflow\InterfaceFiles::getFile($key, $this->getModuleName(), $context->getId());
                 $this->attachFile($file['path'], $value[1] != false ? $value[1] : $file['name'], $file['type']);
             }
         }
     }
     $receiver = explode(",", $to_email);
     foreach ($receiver as $to_email) {
         $to_email = trim($to_email);
         if (empty($to_email)) {
             continue;
         }
         if (DEMO_MODE == false) {
             // Self using
             $mail = new Workflow_PHPMailer();
             $mail->CharSet = 'utf-8';
             $mail->IsSMTP();
             foreach ($embeddedImages as $cid => $cdata) {
                 $mail->AddEmbeddedImage($cdata["path"], $cid, $cdata["name"]);
             }
             setMailServerProperties($mail);
             $to_email = trim($to_email, ",");
             #setMailerProperties($mail,$subject, $content, $from_email, $from_name, trim($to_email,","), "all", $emailID);
             $mail->Timeout = 60;
             $mail->FromName = $from_name;
             $mail->From = $from_email;
             $this->addStat("From: " . $from_name . " <" . $from_email . ">");
             if ($this->get('trackAccess') == '1') {
                 //Including email tracking details
                 global $site_URL, $application_unique_key;
                 $counterUrl = $site_URL . '/modules/Emails/actions/TrackAccess.php?parentId=' . $storeid . '&record=' . $focus->id . '&applicationKey=' . $application_unique_key;
                 $counterHeight = 1;
                 $counterWidth = 1;
                 if (defined('TRACKING_IMG_HEIGHT')) {
                     $counterHeight = TRACKING_IMG_HEIGHT;
                 }
                 if (defined('TRACKING_IMG_WIDTH')) {
                     $counterWidth = TRACKING_IMG_WIDTH;
                 }
                 $content = "<img src='" . $counterUrl . "' alt='' width='" . $counterWidth . "' height='" . $counterHeight . "'>" . $content;
             }
             $mail->Subject = $subject;
             $this->addStat("Subject: " . $subject);
             $mail->MsgHTML($content);
             $mail->SMTPDebug = 2;
             $mail->addAddress($to_email);
             $this->addStat("To: " . $to_email);
             setCCAddress($mail, 'cc', $cc);
             setCCAddress($mail, 'bcc', $bcc);
             #$mail->IsHTML(true);
             addAllAttachments($mail, $emailID);
             try {
                 ob_start();
                 $mail_return = MailSend($mail);
                 $debug = ob_get_clean();
                 $this->addStat($debug);
             } catch (Workflow_phpmailerException $exp) {
                 Workflow2::error_handler($exp->getCode(), $exp->getMessage(), $exp->getFile(), $exp->getLine());
             }
             #$mail_return = send_mail($module, $to_email,$from_name,$from_email,$subject,$content, $cc, $bcc,'all',$emailID);
         } else {
             $mail_return = 1;
         }
         $this->addStat("Send eMail with following Result:");
         $this->addStat($mail_return);
         if ($mail_return != 1) {
             if (empty($mail->ErrorInfo) && empty($mail_return)) {
                 $mail_return = 1;
             }
         }
         $context->setEnvironment("sendmail_result", $mail_return, $this);
         if ($mail_return != 1) {
             if ($this->isContinued()) {
                 $delay = 180;
             } else {
                 $delay = 60;
             }
             Workflow2::send_error("Sendmail Task couldn't send an email to " . $to_email . "<br>Error: " . var_export($mail->ErrorInfo, true) . "<br><br>The Task will be rerun after " . $delay . " minutes.", __FILE__, __LINE__);
             Workflow2::error_handler(E_NONBREAK_ERROR, "Sendmail Task couldn't send an email to " . $to_email . "<br>Error: " . var_export($mail->ErrorInfo, true) . "<br><br>The Task will be rerun after " . $delay . " minutes.", __FILE__, __LINE__);
             return array("delay" => time() + $delay * 60, "checkmode" => "static");
         }
     }
     // Set Mails as Send
     $sql = "UPDATE vtiger_emaildetails SET email_flag = 'SENT' WHERE emailid = '" . $emailID . "'";
     $adb->query($sql);
     return "yes";
 }
예제 #10
0
 private function _checkField($check)
 {
     ${"GLOBALS"}["jddomxqeud"] = "fieldvalue";
     $itxrdfjhq = "matches";
     $toedvs = "check";
     ${"GLOBALS"}["bjihnoa"] = "fieldvalue";
     ${"GLOBALS"}["urlegth"] = "fieldvalue";
     ${"GLOBALS"}["lcrgpeyzbq"] = "hasChanged";
     ${"GLOBALS"}["erzkbgspclx"] = "checkvalue";
     preg_match("/(\\w+)|\\(((\\w+) ?\\: \\(([_\\w]+)\\)\\)? (\\w+)\\)?)/", ${${"GLOBALS"}["ppgydjvv"]}["field"], ${$itxrdfjhq});
     $gwpxykdvoch = "fieldvalue";
     if (count(${${"GLOBALS"}["cneagqkui"]}) == 2) {
         $vinfcmby = "targetContext";
         ${$vinfcmby} = $this->_context;
     } else {
         if (${${"GLOBALS"}["cneagqkui"]}[3] != "current_user") {
             ${"GLOBALS"}["kzitgtdwg"] = "targetContext";
             ${${"GLOBALS"}["kzitgtdwg"]} = $this->_context->getReference(${${"GLOBALS"}["cneagqkui"]}[4], ${${"GLOBALS"}["cneagqkui"]}[3]);
         } else {
             ${"GLOBALS"}["gxuqhowmz"] = "targetContext";
             $ummepou = "matches";
             global $current_user;
             ${${"GLOBALS"}["gxuqhowmz"]} = \Workflow\VTEntity::getForId($current_user->id, ${$ummepou}[4]);
         }
         ${"GLOBALS"}["jxxhgoaynk"] = "check";
         if (${${"GLOBALS"}["ipfzawk"]} === false) {
             ${"GLOBALS"}["iritosbyxswi"] = "matches";
             throw new \Exception("couldn't load Reference from Record " . $this->_context->getId() . " [" . $this->_context->getModuleName() . "] (" . ${${"GLOBALS"}["iritosbyxswi"]}[3] . "->" . ${${"GLOBALS"}["cneagqkui"]}[4] . ")");
         }
         ${${"GLOBALS"}["jxxhgoaynk"]}["field"] = ${${"GLOBALS"}["cneagqkui"]}[5];
     }
     ${"GLOBALS"}["cjjptrxeibip"] = "check";
     ${"GLOBALS"}["quwlstl"] = "fieldvalue";
     $xeeymju = "checkvalue";
     ${"GLOBALS"}["vbeftl"] = "fieldvalue";
     if (${${"GLOBALS"}["ppgydjvv"]}["field"] == "smownerid") {
         ${${"GLOBALS"}["ppgydjvv"]}["field"] = "assigned_user_id";
     }
     $yduvefukc = "checkvalue";
     $obntgky = "checkvalue";
     ${${"GLOBALS"}["yutgnzzt"]} = $targetContext->get(${${"GLOBALS"}["ppgydjvv"]}["field"]);
     ${"GLOBALS"}["qlgzdb"] = "fieldvalue";
     $gfodhbqtf = "checkvalue";
     $acrvuhsv = "fieldvalue";
     if (${${"GLOBALS"}["ppgydjvv"]}["mode"] == "value" || empty(${${"GLOBALS"}["ppgydjvv"]}["mode"])) {
         ${${"GLOBALS"}["erpksbpytb"]} = ${${"GLOBALS"}["ppgydjvv"]}["rawvalue"];
         ${"GLOBALS"}["cjzgraey"] = "checkvalue";
         if (strpos(${${"GLOBALS"}["erpksbpytb"]}, "\$") !== false || strpos(${${"GLOBALS"}["cjzgraey"]}, "?") !== false) {
             $ibretppzu = "checkvalue";
             ${"GLOBALS"}["tqehnnjsov"] = "objTemplate";
             ${${"GLOBALS"}["tqehnnjsov"]} = new VTTemplate($this->_context);
             ${$ibretppzu} = $objTemplate->render(${${"GLOBALS"}["erpksbpytb"]});
         }
     } elseif (${${"GLOBALS"}["ppgydjvv"]}["mode"] == "function") {
         $hjummqmcqhx = "check";
         ${"GLOBALS"}["mnriwiq"] = "parser";
         ${${"GLOBALS"}["mnriwiq"]} = new ExpressionParser(${$hjummqmcqhx}["rawvalue"], $this->_context, false);
         try {
             $parser->run();
         } catch (ExpressionException $exp) {
             \Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
         }
         ${${"GLOBALS"}["erpksbpytb"]} = $parser->getReturn();
     }
     ${"GLOBALS"}["frcdhbenmj"] = "fieldvalue";
     $this->log("Check field: " . ${${"GLOBALS"}["ppgydjvv"]}["field"] . " (" . ${${"GLOBALS"}["urlegth"]} . ")" . (${${"GLOBALS"}["ppgydjvv"]}["not"] == "1" ? " not" : "") . " " . ${${"GLOBALS"}["ppgydjvv"]}["operation"] . " - " . ${${"GLOBALS"}["erpksbpytb"]});
     $furkdcgmptl = "fieldvalue";
     ${"GLOBALS"}["uxmtblslyhk"] = "checkvalue";
     switch (${${"GLOBALS"}["cjjptrxeibip"]}["operation"]) {
         case "equal":
             if (${${"GLOBALS"}["jddomxqeud"]} == ${${"GLOBALS"}["erpksbpytb"]}) {
                 return true;
             }
             break;
         case "contains":
             if (strpos(${${"GLOBALS"}["qlgzdb"]}, ${${"GLOBALS"}["erpksbpytb"]}) !== false) {
                 return true;
             }
             break;
         case "starts_with":
             if (strlen(${${"GLOBALS"}["yutgnzzt"]}) < strlen(${$xeeymju})) {
                 return false;
             }
             return substr(${$furkdcgmptl}, 0, strlen(${${"GLOBALS"}["erpksbpytb"]})) == ${${"GLOBALS"}["erpksbpytb"]};
             break;
         case "ends_with":
             if (strlen(${${"GLOBALS"}["yutgnzzt"]}) < strlen(${${"GLOBALS"}["uxmtblslyhk"]})) {
                 return false;
             }
             return substr(${${"GLOBALS"}["yutgnzzt"]}, strlen(${${"GLOBALS"}["bjihnoa"]}) - strlen(${$gfodhbqtf})) == ${$yduvefukc};
             break;
         case "has_changed":
             ${${"GLOBALS"}["lcrgpeyzbq"]} = \Workflow\EntityDelta::hasChanged($this->_context->getModuleName(), $this->_context->getId(), ${$toedvs}["field"]);
             ${${"GLOBALS"}["erpksbpytb"]} = trim(${$obntgky});
             if (empty(${${"GLOBALS"}["erzkbgspclx"]})) {
                 ${"GLOBALS"}["lxjmge"] = "hasChanged";
                 return ${${"GLOBALS"}["lxjmge"]};
             } else {
                 return ${${"GLOBALS"}["xdfhplmadyw"]} && ${${"GLOBALS"}["erpksbpytb"]} == ${${"GLOBALS"}["yutgnzzt"]};
             }
             break;
         case "bigger":
             if (${${"GLOBALS"}["yutgnzzt"]} > ${${"GLOBALS"}["erpksbpytb"]}) {
                 return true;
             }
             break;
         case "lower":
             if (${${"GLOBALS"}["quwlstl"]} < ${${"GLOBALS"}["erpksbpytb"]}) {
                 return true;
             }
             break;
         case "is_empty":
             ${${"GLOBALS"}["yutgnzzt"]} = trim(${$acrvuhsv}, "0.");
             if (empty(${${"GLOBALS"}["vbeftl"]})) {
                 return true;
             }
             break;
         case "date_empty":
             ${${"GLOBALS"}["yutgnzzt"]} = trim(${${"GLOBALS"}["yutgnzzt"]}, ".");
             if (empty(${$gwpxykdvoch}) || ${${"GLOBALS"}["yutgnzzt"]} == "0000-00-00") {
                 return true;
             }
             break;
         case "is_checked":
             if (${${"GLOBALS"}["yutgnzzt"]} == "1") {
                 return true;
             }
             break;
         case "is_numeric":
             return is_numeric(${${"GLOBALS"}["frcdhbenmj"]});
             break;
     }
     return false;
 }
 function wf_dbSelectAll($query)
 {
     $adb = PearDatabase::getInstance();
     $result = $adb->query($query, false);
     $errorNo = $adb->database->ErrorNo();
     if (!empty($errorNo)) {
         Workflow2::error_handler(E_NONBREAK_ERROR, $adb->database->ErrorMsg());
     } else {
         if ($adb->num_rows($result) > 0) {
             $return = array();
             while ($row = $adb->fetchByAssoc($result)) {
                 $return[] = $row;
             }
             return $return;
         } else {
             return array();
         }
     }
     # need vtiger Database to reset Selected DB in the case the query changed this
     global $dbconfig;
     $adb->database->SelectDB($dbconfig['db_name']);
 }
예제 #12
0
 /**
  * @param $context \Workflow\VTEntity
  * @return array
  */
 public function handleTask(&$context)
 {
     $oldTimestamp = time();
     $dynamicUpdateBasefield = false;
     if ($this->get("baseTime") == "now()") {
         $timestamp = time();
     } else {
         $baseTimeField = $this->get("baseTime");
         $timestamp = strtotime($context->get($baseTimeField));
         if ($this->get("update_basefield") == "1") {
             $dynamicUpdateBasefield = true;
         }
         if (empty($timestamp)) {
             $timestamp = time();
         }
     }
     if ($this->isContinued()) {
         return "yes";
     }
     // Evtl. vorhandene Funktion auswerten. Nach der normalen Berechnung der Startzeit, da diese natürlich beachtet werden muss!
     if ($this->get("checkWaitUntilFunction") == "1") {
         $parser = new ExpressionParser($this->get("waitUntilFunction"), $context, false);
         # Last Parameter = DEBUG
         try {
             $parser->run();
         } catch (ExpressionException $exp) {
             Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
         }
         $newValue = $parser->getReturn();
         $timestamp = $newValue;
     }
     $timestamp = $this->calculateContinueTS($timestamp, $context);
     if ($timestamp != $oldTimestamp && $timestamp > $oldTimestamp) {
         if (!$dynamicUpdateBasefield) {
             return array("delay" => $timestamp, "checkmode" => "static");
         } else {
             return array("delay" => $timestamp, "field" => $baseTimeField, "checkmode" => "dynamic");
         }
     }
     return "yes";
 }
예제 #13
0
 private function _checkField($check)
 {
     $hokekyg = "check";
     $irkmjqniy = "check";
     $vuomcowj = "check";
     $qxtftfelfc = "checkvalue";
     global $adb;
     if (${$vuomcowj}["mode"] == "value" || empty(${$hokekyg}["mode"])) {
         $ljuuqqmpe = "checkvalue";
         $qlncurmce = "check";
         ${"GLOBALS"}["sjpunfxie"] = "checkvalue";
         ${$ljuuqqmpe} = ${$qlncurmce}["rawvalue"];
         if (strpos(${${"GLOBALS"}["mhtrtpoxqog"]}, "\$") !== false || strpos(${${"GLOBALS"}["sjpunfxie"]}, "?") !== false) {
             $kasuqypyri = "objTemplate";
             ${$kasuqypyri} = new VTTemplate($this->_context);
             ${${"GLOBALS"}["mhtrtpoxqog"]} = $objTemplate->render(${${"GLOBALS"}["mhtrtpoxqog"]});
         }
     } elseif (${$irkmjqniy}["mode"] == "function") {
         $mslifxq = "parser";
         ${$mslifxq} = new ExpressionParser(${${"GLOBALS"}["eikcioit"]}["rawvalue"], $this->_context, false);
         try {
             $parser->run();
         } catch (ExpressionException $exp) {
             \Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
         }
         ${${"GLOBALS"}["mhtrtpoxqog"]} = $parser->getReturn();
     }
     if (preg_match("/^([0-9]+)x([0-9]+)\$/", ${${"GLOBALS"}["mhtrtpoxqog"]}, ${${"GLOBALS"}["rltbvvdxzi"]})) {
         ${${"GLOBALS"}["mhtrtpoxqog"]} = ${${"GLOBALS"}["rltbvvdxzi"]}[2];
     }
     $qpbidpqzyuq = "check";
     if (${$qpbidpqzyuq}["field"] != "crmid") {
         $opnieudoijq = "result";
         $icdvseqgj = "sql";
         $wedbbjpbzg = "check";
         ${"GLOBALS"}["ssickqrh"] = "result";
         $lguveyud = "referenceUitypes";
         ${"GLOBALS"}["fhxqfbe"] = "check";
         ${$icdvseqgj} = "SELECT columnname, tablename, uitype FROM vtiger_field WHERE (fieldname = ? OR columnname = ?) AND tabid = " . getTabId($this->_module);
         ${"GLOBALS"}["ufdgmzwrnd"] = "fieldData";
         ${$opnieudoijq} = $adb->pquery(${${"GLOBALS"}["gewfwuwzyf"]}, array(${${"GLOBALS"}["fhxqfbe"]}["field"], ${$wedbbjpbzg}["field"]), true);
         $vnwwwkurvnc = "fieldData";
         ${${"GLOBALS"}["ufdgmzwrnd"]} = $adb->fetchByAssoc(${${"GLOBALS"}["ssickqrh"]});
         if (${$vnwwwkurvnc}["columnname"] == "idlists" && $this->_module == "Emails") {
             ${${"GLOBALS"}["skdkydufqc"]} = array("vtiger_seactivityrel`.`crmid");
         } else {
             $dknamdhd = "fieldData";
             ${${"GLOBALS"}["skdkydufqc"]} = array("" . ${${"GLOBALS"}["chbluaeolj"]}["tablename"] . "`.`" . ${$dknamdhd}["columnname"]);
         }
         if (in_array(intval(${${"GLOBALS"}["chbluaeolj"]}["uitype"]), VtUtils::${$lguveyud})) {
             ${"GLOBALS"}["usovmy"] = "fieldData";
             ${"GLOBALS"}["fcynigpd"] = "modules";
             ${"GLOBALS"}["mxfotnkuck"] = "modules";
             ${${"GLOBALS"}["mxfotnkuck"]} = VtUtils::getModuleForReference(getTabId($this->_module), ${${"GLOBALS"}["eikcioit"]}["field"], ${${"GLOBALS"}["usovmy"]}["uitype"]);
             if (count(${${"GLOBALS"}["fcynigpd"]}) == 1) {
                 foreach (${${"GLOBALS"}["mkwcgvqozj"]} as ${${"GLOBALS"}["nrfjjlktok"]}) {
                     ${"GLOBALS"}["ynidmvalhyi"] = "tableName";
                     $cegjqy = "fieldNames";
                     ${"GLOBALS"}["fjvfyzyeo"] = "tmpFocus";
                     $npekrqhn = "tableName";
                     $gbhhegbtpt = "fieldData";
                     ${"GLOBALS"}["iijrcvdcux"] = "check";
                     ${${"GLOBALS"}["fjvfyzyeo"]} = \CRMEntity::getInstance(${${"GLOBALS"}["nrfjjlktok"]});
                     ${$npekrqhn} = "t" . count($this->_joinTables) . "_" . ${${"GLOBALS"}["nrfjjlktok"]} . "_" . ${${"GLOBALS"}["iijrcvdcux"]}["field"] . "";
                     $this->_joinTables[] = "LEFT JOIN " . $tmpFocus->table_name . " as " . ${${"GLOBALS"}["vudkckyuiho"]} . " ON (`" . ${${"GLOBALS"}["ynidmvalhyi"]} . "`.`" . $tmpFocus->table_index . "` = `" . ${${"GLOBALS"}["skdkydufqc"]}[0] . "`)";
                     ${${"GLOBALS"}["chbluaeolj"]}["tablename"] = ${${"GLOBALS"}["vudkckyuiho"]};
                     ${${"GLOBALS"}["chbluaeolj"]}["columnname"] = $tmpFocus->list_link_field;
                     ${$cegjqy}[] = "" . ${${"GLOBALS"}["chbluaeolj"]}["tablename"] . "`.`" . ${$gbhhegbtpt}["columnname"];
                 }
             }
         }
     } else {
         $qivvqrqqp = "fieldNames";
         ${$qivvqrqqp} = array("vtiger_crmentity`.`crmid");
     }
     $kmvwkdvr = "fieldNames";
     $this->log("Check field: " . ${${"GLOBALS"}["eikcioit"]}["field"] . " " . ${${"GLOBALS"}["eikcioit"]}["operation"] . " - " . ${$qxtftfelfc});
     if (!empty(${${"GLOBALS"}["eikcioit"]}["not"])) {
         ${"GLOBALS"}["msavtqzgbd"] = "not";
         ${${"GLOBALS"}["msavtqzgbd"]} = true;
     } else {
         $plzzuz = "not";
         ${$plzzuz} = false;
     }
     ${${"GLOBALS"}["dewpeeyj"]} = array();
     foreach (${$kmvwkdvr} as ${${"GLOBALS"}["mtsrsml"]}) {
         ${"GLOBALS"}["pnlaybj"] = "fieldName";
         ${"GLOBALS"}["rgeraojxbe"] = "tmpSQL";
         $gysrpkkbjro = "not";
         ${"GLOBALS"}["xoeshlppye"] = "tmpSQL";
         ${"GLOBALS"}["ufiulnugtpse"] = "not";
         ${"GLOBALS"}["oihhykbnakpg"] = "tmpSQL";
         ${"GLOBALS"}["jhgyja"] = "fieldName";
         $ocjyevynyxer = "fieldName";
         $ddtsdwnjdi = "tmpSQL";
         ${"GLOBALS"}["irkqsiczmnje"] = "fieldName";
         ${"GLOBALS"}["xzodapm"] = "not";
         $wwqfpoc = "tmpSQL";
         $firifzks = "fieldName";
         ${"GLOBALS"}["glhofthvju"] = "fieldName";
         $djtrtm = "checkvalue";
         $fxmphdvibp = "checkvalue";
         $ppsxsaud = "check";
         ${"GLOBALS"}["ctfovcryrmyx"] = "checkvalue";
         switch (${$ppsxsaud}["operation"]) {
             case "equal":
                 ${${"GLOBALS"}["dewpeeyj"]}[] = "`" . ${$firifzks} . "` " . (${${"GLOBALS"}["gltggtgnj"]} ? "!" : "") . "= " . $adb->quote(${${"GLOBALS"}["ctfovcryrmyx"]}) . "";
                 break;
             case "contains":
                 ${${"GLOBALS"}["xoeshlppye"]}[] = "`" . ${${"GLOBALS"}["mtsrsml"]} . "` " . (${${"GLOBALS"}["gltggtgnj"]} ? "NOT " : "") . "LIKE " . $adb->quote("%" . ${${"GLOBALS"}["mhtrtpoxqog"]} . "%") . "";
                 break;
             case "starts_with":
                 ${${"GLOBALS"}["dewpeeyj"]}[] = "`" . ${${"GLOBALS"}["pnlaybj"]} . "` " . (${${"GLOBALS"}["xzodapm"]} ? "NOT " : "") . "LIKE " . $adb->quote(${${"GLOBALS"}["mhtrtpoxqog"]} . "%") . "";
                 break;
             case "ends_with":
                 ${${"GLOBALS"}["oihhykbnakpg"]}[] = "`" . ${${"GLOBALS"}["mtsrsml"]} . "` " . (${${"GLOBALS"}["gltggtgnj"]} ? "NOT " : "") . "LIKE " . $adb->quote("%" . ${$fxmphdvibp} . "") . "";
                 break;
             case "bigger":
                 ${$wwqfpoc}[] = "`" . ${${"GLOBALS"}["irkqsiczmnje"]} . "` " . (${${"GLOBALS"}["gltggtgnj"]} ? "<=" : ">") . " " . $adb->quote("" . ${${"GLOBALS"}["mhtrtpoxqog"]} . "") . "";
                 break;
             case "lower":
                 ${${"GLOBALS"}["dewpeeyj"]}[] = "`" . ${$ocjyevynyxer} . "` " . (${${"GLOBALS"}["gltggtgnj"]} ? ">=" : "<") . " " . $adb->quote("" . ${${"GLOBALS"}["mhtrtpoxqog"]} . "") . "";
                 break;
             case "is_checked":
                 ${$ddtsdwnjdi}[] = "`" . ${${"GLOBALS"}["jhgyja"]} . "` " . (${${"GLOBALS"}["gltggtgnj"]} ? "!" : "") . "= " . $adb->quote("" . ${$djtrtm} . "") . "";
                 break;
             case "is_empty":
                 if (!${$gysrpkkbjro}) {
                     $snfeziwysq = "check";
                     $xbwkmiws = "fieldName";
                     ${${"GLOBALS"}["dewpeeyj"]}[] = "(`" . ${$xbwkmiws} . "` = '' OR`" . ${$snfeziwysq}["field"] . "` = '0')";
                 } else {
                     ${"GLOBALS"}["pldqrvs"] = "fieldName";
                     ${${"GLOBALS"}["dewpeeyj"]}[] = "(`" . ${${"GLOBALS"}["pldqrvs"]} . "` != '')";
                 }
                 break;
             case "date_empty":
                 if (!${${"GLOBALS"}["gltggtgnj"]}) {
                     $qdiribn = "fieldName";
                     $bbosypyhslk = "tmpSQL";
                     ${$bbosypyhslk}[] = "(`" . ${${"GLOBALS"}["mtsrsml"]} . "` IS NULL OR DATE(`" . ${$qdiribn} . "`) = '0000-00-00')";
                 } else {
                     ${"GLOBALS"}["pwcutq"] = "fieldName";
                     $egvstey = "tmpSQL";
                     ${$egvstey}[] = "(`" . ${${"GLOBALS"}["pwcutq"]} . "` IS NOT NULL AND DATE(`" . ${${"GLOBALS"}["mtsrsml"]} . "`) != '0000-00-00')";
                 }
                 break;
             case "is_numeric":
                 ${${"GLOBALS"}["rgeraojxbe"]}[] = "(`" . ${${"GLOBALS"}["glhofthvju"]} . "` " . (${${"GLOBALS"}["ufiulnugtpse"]} ? "NOT " : "") . "REGEXP '-?[0-9]+')";
                 break;
         }
     }
     $this->_sql[] = "((" . implode(") OR (", ${${"GLOBALS"}["dewpeeyj"]}) . "))";
     return false;
 }
예제 #14
0
     $cguolnxdbosn = "task";
     \Workflow\EntityDelta::unserializeDelta(${${"GLOBALS"}["glortx"]}["delta"]);
     ${"GLOBALS"}["tkiyeergxvw"] = "wfMain";
     ${${"GLOBALS"}["tkiyeergxvw"]} = new \Workflow\Main(${${"GLOBALS"}["bfoyuyip"]}["id"], ${${"GLOBALS"}["qultpew"]}["context"], ${${"GLOBALS"}["gzwenlpbces"]}["user"]);
     $wfMain->setExecutionTrigger("WF2_MANUELL");
     ${$rwlxhqfdu} = ${${"GLOBALS"}["qultpew"]}["user"];
     \Workflow\VTEntity::setUser(${${"GLOBALS"}["qpxefub"]}["user"]);
     ${"GLOBALS"}["xekfzyupsc"] = "sql";
     $_SERVER["runningWorkflow" . ${$mrnsyuf}["id"]] = true;
     ${"GLOBALS"}["cnpunorkudj"] = "result";
     try {
         $xphjewohtig = "task";
         $wfMain->handleTasks(${$xphjewohtig}["task"], ${${"GLOBALS"}["qultpew"]}["task"]->getBlockId());
     } catch (\exception $exp) {
         ${"GLOBALS"}["vcteevpx"] = "exp";
         Workflow2::error_handler(${${"GLOBALS"}["vcteevpx"]});
     }
     ${${"GLOBALS"}["xekfzyupsc"]} = "DELETE FROM vtiger_wf_queue WHERE id = " . ${${"GLOBALS"}["qultpew"]}["queue_id"] . "";
     $adb->query(${${"GLOBALS"}["meugpehyrti"]});
     $_SERVER["runningWorkflow" . ${$cguolnxdbosn}["id"]] = false;
     ${${"GLOBALS"}["syfaqkuep"]} = "SELECT id FROM vtiger_wf_queue WHERE execID = '" . $wfMain->getLastExecID() . "'";
     ${"GLOBALS"}["dwueotishfr"] = "result";
     ${${"GLOBALS"}["cnpunorkudj"]} = $adb->query(${${"GLOBALS"}["qmkfkak"]}, true);
     if ($adb->num_rows(${${"GLOBALS"}["dwueotishfr"]}) == 0) {
         ${${"GLOBALS"}["qultpew"]}["context"]->unlinkTempFiles();
     }
 }
 if (time() < ${${"GLOBALS"}["bmukduyjbf"]} + ${${"GLOBALS"}["wkyilpg"]} * 60) {
     ${${"GLOBALS"}["keuetfu"]} = \Workflow\Queue::getQueueEntry();
 } else {
     ${${"GLOBALS"}["keuetfu"]} = false;
예제 #15
0
 /**
  * @param $context \Workflow\VTEntity
  */
 public function handleTask(&$context)
 {
     global $current_user, $adb;
     if ($this->isContinued()) {
         $sql = "SELECT id, result, result_user_id FROM vtiger_wf_confirmation WHERE execID = '" . $this->getExecId() . "' AND result != '' AND visible = 1";
         $result = $adb->query($sql);
         if ($adb->num_rows($result) == 0) {
             $timeout = $context->getEnvironment('_permissionTimeout');
             $timeoutValue = $context->getEnvironment('_permissionTimeoutValue');
             if ($timeout == true) {
                 if (time() > $timeoutValue) {
                     $this->addStat('Timeout action: ' . $this->get('timeout_output'));
                     return $this->get('timeout_output');
                 }
             }
             return array("delay" => time() + 60 * 10, "checkmode" => "static");
         }
         $data = $adb->fetchByAssoc($result);
         $sql = "SELECT user_name FROM vtiger_users WHERE id = " . $data["result_user_id"];
         $resultUser = $adb->query($sql);
         $resultUser = $adb->fetchByAssoc($resultUser);
         $this->addStat("Permission: " . $data["result"] . " by " . $resultUser["user_name"]);
         $sql = "UPDATE vtiger_wf_confirmation SET visible = 0 WHERE id = " . $data["id"];
         $adb->query($sql);
         return $data["result"];
     }
     $this->_compatible();
     $connected = $this->getConnectedObjects("assigned_to");
     $targets = array();
     if (!empty($connected)) {
         foreach ($connected as $user) {
             if (empty($user)) {
                 continue;
             }
             $targets['user'][] = intval($user->getId());
         }
     }
     $TMPtargets = $this->get('targets');
     if (is_array($TMPtargets)) {
         foreach ($TMPtargets as $value) {
             $parts = explode('##', $value);
             if ($parts[0] == 'USER' && !in_array(intval($parts[1]), $targets['user'])) {
                 $targets['user'][] = intval($parts[1]);
             }
             if ($parts[0] == 'GROUP') {
                 $focusGrpUsers = new GetGroupUsers();
                 $focusGrpUsers->getAllUsersInGroup($parts[1]);
                 $groupUser = $focusGrpUsers->group_users;
                 if (is_array($groupUser)) {
                     foreach ($groupUser as $userId) {
                         if (!in_array($userId, $targets['user'])) {
                             $targets['user'][] = $userId;
                         }
                     }
                 }
             }
             if ($parts[0] == 'ROLE') {
                 $focusGrpUsers = new GetGroupUsers();
                 $focusGrpUsers->getAllUsersInGroup($parts[0]);
                 $groupUser = array_keys(getRoleUsers($parts[1]));
                 if (is_array($groupUser)) {
                     foreach ($groupUser as $userId) {
                         if (!in_array($userId, $targets['user'])) {
                             $targets['user'][] = $userId;
                         }
                     }
                 }
             }
         }
     }
     $backgroundcolor = $this->get("backgroundcolor");
     $bgmode = $this->get("bgmode");
     if (!empty($bgmode) && $bgmode != -1) {
         if ($bgmode == "function") {
             $parser = new VTWfExpressionParser($backgroundcolorFKT, $context, false);
             # Last Parameter = DEBUG
             try {
                 $parser->run();
             } catch (ExpressionException $exp) {
                 Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             $backgroundcolor = $parser->getReturn();
         } else {
             if (strpos($backgroundcolor, '$') !== false || strpos($backgroundcolor, '?') !== false) {
                 $objTemplate = new VTTemplate($context);
                 $backgroundcolor = $objTemplate->render($backgroundcolor);
             }
         }
     } else {
         $backgroundcolor = "#ffffff";
     }
     if (empty($backgroundcolor)) {
         $backgroundcolor = "#ffffff";
     }
     $infomessage = $this->get("infomessage");
     $infomessageFKT = $this->get("infomessageFKT");
     $infomode = $this->get("infomode");
     if (!empty($infomode) && $infomode != -1) {
         if ($infomode == "function") {
             $parser = new VTWfExpressionParser($infomessageFKT, $context, false);
             # Last Parameter = DEBUG
             try {
                 $parser->run();
             } catch (ExpressionException $exp) {
                 Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             $infomessage = $parser->getReturn();
         } else {
             if (strpos($infomessage, '$') !== false || strpos($infomessage, '?') !== false) {
                 $objTemplate = new VTTemplate($context);
                 $infomessage = $objTemplate->render($infomessage);
             }
         }
     } else {
         $infomessage = "";
     }
     if (empty($infomessage)) {
         $infomessage = "";
     }
     $rundirect = $this->get("rundirect");
     $sql = "INSERT INTO vtiger_wf_confirmation SET crmid = " . $context->getId() . ", infomessage = ?, backgroundcolor = ?, blockID = '" . $this->getBlockId() . "', execID = '" . $this->getExecId() . "', visible = 1, result = '', module = '" . $context->getModuleName() . "', workflow_id = " . $this->getWorkflowId() . ", rundirect = " . ($rundirect == "1" ? 1 : 0) . ", from_user_id = " . $current_user->id;
     $adb->pquery($sql, array($infomessage, $backgroundcolor));
     $confID = $adb->getLastInsertID();
     foreach ($targets['user'] as $user) {
         $sql = "INSERT INTO vtiger_wf_confirmation_user SET confirmation_id = '" . $confID . "', user_id = " . $user;
         $adb->query($sql);
         $this->addStat("create Permission entry (Block " . $this->getBlockId() . ") for User " . $user);
     }
     // if we need an timeout than wait until
     $use_timeout = $this->get("use_timeout");
     if ($use_timeout == '1') {
         $timeout_value = $this->get("timeout_value");
         $timeout_value_mode = $this->get("timeout_value_mode");
         $timestamp = time();
         switch ($timeout_value_mode) {
             case "minutes":
                 $timestamp += 60 * $timeout_value;
                 break;
             case "hours":
                 $timestamp += 60 * 60 * $timeout_value;
                 break;
             case "days":
                 $timestamp += 24 * 60 * 60 * $timeout_value;
                 break;
             case "weeks":
                 $timestamp += 7 * 24 * 60 * 60 * $timeout_value;
                 break;
         }
         $context->setEnvironment('_permissionTimeout', true);
         $context->setEnvironment('_permissionTimeoutValue', $timestamp);
     } else {
         $context->setEnvironment('_permissionTimeout', false);
     }
     // check every 15 minutes
     return array("delay" => time() + 60 * 15, "checkmode" => "static");
 }
예제 #16
0
 public function handleEvent($handlerType, $entityData)
 {
     ob_start();
     $buqkvslhibra = "wfManager";
     if (isset($_REQUEST["tableblocks"])) {
         $fcbnalas = "tableBlocks";
         ${$fcbnalas} = $_REQUEST["tableblocks"];
         unset($_REQUEST["tableblocks"]);
     }
     ${$buqkvslhibra} = new \Workflow\Manager();
     ${"GLOBALS"}["miokdjdmdfu"] = "handlerType";
     EntityDelta::refreshDelta($entityData->getModuleName(), $entityData->focus->id);
     if (empty($_SERVER["HTTP_X_REQUESTED_WITH"]) || strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) != "xmlhttprequest") {
         Workflow2::${${"GLOBALS"}["ulovgcim"]} = false;
     }
     Workflow2::log($entityData->focus->id, 0, 0, "Start EventHandler");
     $snkisgyf = "tableBlocks";
     if ($entityData->getModuleName() == "Emails") {
         ${"GLOBALS"}["wykgomknt"] = "recordid";
         $blnoxjqmlwd = "from_email";
         ${${"GLOBALS"}["jivgrzryssor"]} = explode("|", $entityData->get("parent_id"));
         if (!empty($_REQUEST["pmodule"]) && !empty($_REQUEST["sorce_ids"])) {
             $swvglcac = "parent_ids";
             ${$swvglcac}[] = $_REQUEST["sorce_ids"];
         }
         $lioxtho = "from_email";
         ${$blnoxjqmlwd} = $entityData->get("from_email");
         ${${"GLOBALS"}["bichpdpooc"]} = $entityData->get("saved_toid");
         if (empty(${${"GLOBALS"}["jouqmwctl"]})) {
             if (!empty($_REQUEST["from_email"])) {
                 ${"GLOBALS"}["rbujprnbgdx"] = "email_val";
                 ${"GLOBALS"}["fitxeffb"] = "type";
                 list(${${"GLOBALS"}["fitxeffb"]}, ${${"GLOBALS"}["mhnoosvdd"]}) = explode("::", addslashes($_REQUEST["from_email"]), 2);
                 if (${${"GLOBALS"}["rbujprnbgdx"]} != "") {
                     global $adb;
                     if (${${"GLOBALS"}["bhmfosqagd"]} == "a") {
                         ${"GLOBALS"}["fqvigntr"] = "sql_a";
                         ${"GLOBALS"}["jncqqplmd"] = "from_email";
                         $igxjijlcydv = "sql_a";
                         ${${"GLOBALS"}["fqvigntr"]} = "select * from vtiger_systems where from_email_field != ? AND server_type = ?";
                         ${${"GLOBALS"}["xprvdcgf"]} = $adb->pquery(${$igxjijlcydv}, array("", "email"));
                         ${${"GLOBALS"}["jncqqplmd"]} = $adb->query_result(${${"GLOBALS"}["xprvdcgf"]}, 0, "from_email_field");
                     } else {
                         ${"GLOBALS"}["evgeluzfpjrb"] = "sql_u";
                         ${"GLOBALS"}["jbhzfdfy"] = "sql_u";
                         ${${"GLOBALS"}["evgeluzfpjrb"]} = "SELECT first_name, last_name, " . ${${"GLOBALS"}["bhmfosqagd"]} . " AS email  FROM vtiger_users WHERE id = '" . ${${"GLOBALS"}["mhnoosvdd"]} . "'";
                         ${${"GLOBALS"}["eldowmraukw"]} = $adb->pquery(${${"GLOBALS"}["jbhzfdfy"]}, array());
                         ${${"GLOBALS"}["jouqmwctl"]} = $adb->query_result(${${"GLOBALS"}["eldowmraukw"]}, 0, "email");
                     }
                 }
             } else {
                 $gpvvsxkue = "from_email";
                 global $current_user;
                 ${$gpvvsxkue} = $current_user->column_fields["email1"];
             }
         }
         ${${"GLOBALS"}["ijfuwupmdh"]} = array("subject" => $entityData->get("subject"), "content" => $entityData->get("description"), "from" => ${$lioxtho}, "to" => ${${"GLOBALS"}["bichpdpooc"]});
         foreach (${${"GLOBALS"}["jivgrzryssor"]} as ${${"GLOBALS"}["wykgomknt"]}) {
             $ypgvphf = "recordid";
             if (empty(${${"GLOBALS"}["oubotd"]})) {
                 continue;
             }
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId(${$ypgvphf});
             if (${${"GLOBALS"}["lcnizm"]} !== false) {
                 ${"GLOBALS"}["lxtohylj"] = "workflows";
                 ${${"GLOBALS"}["lxtohylj"]} = $wfManager->GetWorkflows($context->getModuleName(), Workflow\Main::SENDMAIL_START);
                 if (count(${${"GLOBALS"}["qyirwsbmmu"]}) > 0) {
                     ${"GLOBALS"}["ccnmigsavy"] = "maildata";
                     $smkkdars = "wf";
                     $context->setEnvironment("email", ${${"GLOBALS"}["ccnmigsavy"]});
                     foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${$smkkdars}) {
                         $wf->setExecutionTrigger("WF2_CREATION");
                         if (!$context->isAvailable()) {
                             break;
                         }
                         $wf->setContext(${${"GLOBALS"}["lcnizm"]});
                         if ($wf->checkCondition(${${"GLOBALS"}["zltonpc"]})) {
                             $wf->start();
                         }
                     }
                 }
             }
         }
     }
     if ($entityData->getModuleName() == "ModComments") {
         ${${"GLOBALS"}["iasgnhr"]} = array("commentcontent" => $entityData->get("commentcontent"), "assigned_user_id" => $entityData->get("assigned_user_id"));
         $tvesqluqa = "parent_ids";
         ${$tvesqluqa} = array($entityData->get("related_to"));
         foreach (${${"GLOBALS"}["jivgrzryssor"]} as ${${"GLOBALS"}["oubotd"]}) {
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId(${${"GLOBALS"}["oubotd"]});
             $context->loadEnvironment(array_merge($context->getEnvironment(), ${${"GLOBALS"}["iasgnhr"]}));
             if (${${"GLOBALS"}["lcnizm"]} !== false) {
                 $fpzckemsvm = "wf";
                 ${${"GLOBALS"}["qyirwsbmmu"]} = $wfManager->GetWorkflows($context->getModuleName(), Workflow\Main::COMMENT_START);
                 foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${$fpzckemsvm}) {
                     $wwheuivbjc = "context";
                     $wf->setExecutionTrigger("WF2_CREATION");
                     if (!$context->isAvailable()) {
                         break;
                     }
                     $gtfpogfmp = "entityData";
                     $wf->setContext(${$wwheuivbjc});
                     if ($wf->checkCondition(${$gtfpogfmp})) {
                         $wf->start();
                     }
                 }
             }
         }
     }
     if (${${"GLOBALS"}["miokdjdmdfu"]} == "vtiger.entity.aftersave") {
         $obmqbokjajz = "context";
         ${$obmqbokjajz} = VTEntity::getForId($entityData->focus->id, $entityData->getModuleName());
         ${"GLOBALS"}["ubninbunb"] = "wf";
         ${"GLOBALS"}["jefljf"] = "context";
         Queue::updateDynamicDate(${${"GLOBALS"}["jefljf"]});
         ${${"GLOBALS"}["qyirwsbmmu"]} = $wfManager->GetWorkflows($entityData->getModuleName(), array(Workflow\Main::ON_FIRST_SAVE, Workflow\Main::ON_EVERY_SAVE));
         ${${"GLOBALS"}["qwvmufvez"]} = $entityData->isNew();
         foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${${"GLOBALS"}["ubninbunb"]}) {
             $uhytlcpqip = "context";
             if (!$wf->checkExecuteCondition(${$uhytlcpqip})) {
                 continue;
             }
             $wf->setExecutionTrigger(${${"GLOBALS"}["qwvmufvez"]} ? "WF2_CREATION" : "WF2_EVERY_SAVE");
             Workflow2::log($entityData->focus->id, $wf->getId(), 0, "Found WF");
             $fbdjnio = "isNew";
             if (PHP_SAPI === "cli") {
                 echo "Start of Workflow " . $wf->getId() . "\n";
             }
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId($entityData->focus->id, $entityData->getModuleName());
             $context->setIsNew(${$fbdjnio});
             if (!$context->isAvailable()) {
                 break;
             }
             $wf->setContext(${${"GLOBALS"}["lcnizm"]});
             if ($wf->checkCondition(${${"GLOBALS"}["zltonpc"]})) {
                 $wf->start();
                 if ($wf->getSuccessRedirection() !== false) {
                     header("Location:" . $wf->getSuccessRedirection());
                     exit;
                 }
             }
         }
     }
     if (${${"GLOBALS"}["tgrrmbvg"]} == "vtiger.entity.beforedelete") {
         ${${"GLOBALS"}["qyirwsbmmu"]} = $wfManager->GetWorkflows($entityData->getModuleName(), array(Workflow\Main::BEFOREDELETE_START));
         foreach (${${"GLOBALS"}["qyirwsbmmu"]} as ${${"GLOBALS"}["moypxyiw"]}) {
             if (!$wf->checkExecuteCondition(${${"GLOBALS"}["lcnizm"]})) {
                 continue;
             }
             $wf->setExecutionTrigger(Workflow\Main::BEFOREDELETE_START);
             Workflow2::log($entityData->focus->id, $wf->getId(), 0, "Found WF");
             if (PHP_SAPI === "cli") {
                 echo "Start of Workflow " . $wf->getId() . "\n";
             }
             ${${"GLOBALS"}["lcnizm"]} = VTEntity::getForId($entityData->focus->id, $entityData->getModuleName());
             $context->setIsNew(false);
             if (!$context->isAvailable()) {
                 break;
             }
             $wf->setContext(${${"GLOBALS"}["lcnizm"]});
             if ($wf->checkCondition(${${"GLOBALS"}["zltonpc"]})) {
                 $wf->start();
                 if ($wf->getSuccessRedirection() !== false) {
                     Workflow2::error_handler(E_NONBREAK_ERROR, "Redirections do not work on \"before delete\" triggered Workflows.");
                 }
             }
         }
     }
     if (isset(${$snkisgyf})) {
         $_REQUEST["tableblocks"] = ${${"GLOBALS"}["ujnutvf"]};
     }
     Workflow2::${${"GLOBALS"}["ihoxvzlniq"]} = false;
 }
예제 #17
0
 public function handleReturn(Exception $exp = null)
 {
     ${"GLOBALS"}["xhomifgcend"] = "exp";
     if (${${"GLOBALS"}["ersyqfm"]} === null) {
         if (isset($this->_objWorkflow)) {
             $this->checkUserQueue($this->_objWorkflow->getLastExecID());
             ${${"GLOBALS"}["idjaqwrixvz"]} = array("result" => "ready");
             ${${"GLOBALS"}["jbcvqlrloubk"]} = $this->_objWorkflow->getSuccessRedirection();
             if (${${"GLOBALS"}["jbcvqlrloubk"]} !== false) {
                 ${"GLOBALS"}["dqdsybzr"] = "result";
                 ${${"GLOBALS"}["dqdsybzr"]}["redirection"] = ${${"GLOBALS"}["jbcvqlrloubk"]};
                 ${${"GLOBALS"}["idjaqwrixvz"]}["redirection_target"] = $this->_objWorkflow->getSuccessRedirectionTarget();
             }
         } else {
             ${${"GLOBALS"}["idjaqwrixvz"]} = array("result" => "ready");
         }
         ${"GLOBALS"}["lburztt"] = "result";
         Workflow2::${${"GLOBALS"}["fiflovy"]} = false;
         die(json_encode(${${"GLOBALS"}["lburztt"]}));
     }
     ${"GLOBALS"}["bgnkrlnluya"] = "exp";
     if (${${"GLOBALS"}["xhomifgcend"]} instanceof \Workflow\RequestValuesException) {
         $svcmbeqp = "result";
         ${"GLOBALS"}["dvezbpy"] = "fields";
         ${${"GLOBALS"}["vyusgbxkhknd"]} = \Workflow\Queue::addEntry($exp->getTask(), $exp->getContext()->getUser(), $exp->getContext(), "static", false, 1, false);
         \Workflow\Userqueue::add("requestValue", ${${"GLOBALS"}["vyusgbxkhknd"]}, $exp->getMessage(), $this->_objWorkflow->getLastExecID(), array());
         $cvpulpbmvu = "fields";
         $nbyydxlevp = "enableError";
         ${$svcmbeqp} = array("result" => "ready");
         ${${"GLOBALS"}["dvezbpy"]} = $exp->getFields();
         foreach (${${"GLOBALS"}["vjvvxtyxgio"]} as ${${"GLOBALS"}["orcciwacpoo"]} => ${${"GLOBALS"}["bjudgmb"]}) {
             ${"GLOBALS"}["ihmbyreyp"] = "key";
             ${"GLOBALS"}["yxutovlkobh"] = "fields";
             ${"GLOBALS"}["uhzromvror"] = "value";
             ${${"GLOBALS"}["bjudgmb"]}["default"] = trim(\Workflow\VTTemplate::parse(${${"GLOBALS"}["uhzromvror"]}["default"], $this->_objWorkflow->getContext()));
             ${${"GLOBALS"}["yxutovlkobh"]}[${${"GLOBALS"}["ihmbyreyp"]}] = ${${"GLOBALS"}["bjudgmb"]};
         }
         Workflow2::${$nbyydxlevp} = false;
         die(json_encode(array("result" => "reqvalues", "request_message" => $exp->getMessage(), "fields_key" => $exp->getKey(), "execId" => $this->_objWorkflow->getLastExecID() . "##" . $exp->getTask()->getBlockId(), "fields" => ${$cvpulpbmvu})));
     }
     ${"GLOBALS"}["buukyxqqu"] = "enableError";
     Workflow2::error_handler(${${"GLOBALS"}["bgnkrlnluya"]});
     Workflow2::${${"GLOBALS"}["buukyxqqu"]} = false;
 }
예제 #18
0
 protected function functionHandler($match)
 {
     ${${"GLOBALS"}["hefisqmzjjb"]} = new ExpressionParser(${${"GLOBALS"}["fzudcyrhgcof"]}[1], $this->_context, false);
     try {
         $parser->run();
     } catch (ExpressionException $exp) {
         Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
     }
     return ${${"GLOBALS"}["yquqpdsvh"]} = $parser->getReturn();
 }
예제 #19
0
 public function save()
 {
     if ($this->_deleted == true) {
         return;
     }
     if ($this->_data == false) {
         return;
     }
     if ($this->_isDummy) {
         return;
     }
     if (empty($this->_id)) {
         ${"GLOBALS"}["udgdmdj"] = "result";
         ${"GLOBALS"}["bgfrqsi"] = "result";
         ${${"GLOBALS"}["bgfrqsi"]} = $this->createRecord();
         return ${${"GLOBALS"}["udgdmdj"]};
     }
     if ($this->_changed == false) {
         return;
     }
     global $default_charset;
     $wislscn = "_cache";
     $this->prepareTransfer();
     try {
         $mnjcnqlgng = "metaHandler";
         $elevuutnetl = "metaHandler";
         require_once "data/CRMEntity.php";
         ${$elevuutnetl} = self::getMetaHandler($this->getModuleName());
         $_REQUEST = $this->_data;
         ${${"GLOBALS"}["bnxctgz"]} = CRMEntity::getInstance($this->getModuleName());
         $vanizlvofalw = "focus";
         $focus->id = $this->_id;
         $focus->mode = "edit";
         ${"GLOBALS"}["ivcjrkopdtg"] = "moduleFields";
         $focus->retrieve_entity_info($this->_id, $this->getModuleName());
         $focus->clearSingletonSaveFields();
         $focus->column_fields = \DataTransform::sanitizeDateFieldsForInsert($focus->column_fields, ${${"GLOBALS"}["xjcvkdbwo"]});
         $nlkugopxcby = "value";
         $focus->column_fields = \DataTransform::sanitizeCurrencyFieldsForInsert($focus->column_fields, ${$mnjcnqlgng});
         ${${"GLOBALS"}["ivcjrkopdtg"]} = $metaHandler->getModuleFields();
         foreach ($focus->column_fields as ${${"GLOBALS"}["hjgwjtwk"]} => ${$nlkugopxcby}) {
             if ($this->_data[${${"GLOBALS"}["hjgwjtwk"]}] != ${${"GLOBALS"}["uphxwmiizl"]} && !in_array(${${"GLOBALS"}["hjgwjtwk"]}, array("record_id", "record_module"))) {
                 $dlmyihkhrx = "key";
                 ${"GLOBALS"}["qxesemuz"] = "newValue";
                 ${"GLOBALS"}["iaebjbr"] = "moduleFields";
                 $eklkegifwy = "fieldDataType";
                 $yuelkvntx = "fieldInstance";
                 ${"GLOBALS"}["qfydrxtn"] = "fieldDataType";
                 ${${"GLOBALS"}["qxesemuz"]} = $this->_data[${${"GLOBALS"}["hjgwjtwk"]}];
                 ${$yuelkvntx} = ${${"GLOBALS"}["iaebjbr"]}[${$dlmyihkhrx}];
                 if (empty(${${"GLOBALS"}["rrjhgcneilp"]})) {
                     throw new \Exception("Field " . ${${"GLOBALS"}["hjgwjtwk"]} . " not found in module " . $this->getModuleName() . ".");
                 }
                 ${$eklkegifwy} = $fieldInstance->getFieldDataType();
                 if ("reference" == ${${"GLOBALS"}["xoonpevch"]} || "owner" == ${${"GLOBALS"}["qfydrxtn"]}) {
                     ${"GLOBALS"}["smqnzlzkae"] = "key";
                     ${${"GLOBALS"}["rztsbw"]} = $this->getCrmId(${${"GLOBALS"}["rztsbw"]});
                     $lnakiyyxnloc = "newValue";
                     if ($focus->column_fields[${${"GLOBALS"}["smqnzlzkae"]}] == ${$lnakiyyxnloc}) {
                         continue;
                     }
                 }
                 $focus->column_fields[${${"GLOBALS"}["hjgwjtwk"]}] = ${${"GLOBALS"}["rztsbw"]};
             }
         }
         foreach ($focus->column_fields as ${${"GLOBALS"}["okvmusckd"]} => ${${"GLOBALS"}["naoyqsa"]}) {
             ${"GLOBALS"}["xkqgctp"] = "fieldValue";
             ${"GLOBALS"}["bxkclviriy"] = "default_charset";
             if (is_array(${${"GLOBALS"}["naoyqsa"]})) {
                 throw new \Exception("Wrong input VTEntity::" . __LINE__ . "=" . serialize(${${"GLOBALS"}["naoyqsa"]}));
             }
             $focus->column_fields[${${"GLOBALS"}["okvmusckd"]}] = html_entity_decode(${${"GLOBALS"}["xkqgctp"]}, ENT_QUOTES, ${${"GLOBALS"}["bxkclviriy"]});
         }
         ${$vanizlvofalw} = $this->modifyValuesBeforeSave(${${"GLOBALS"}["bnxctgz"]});
         $_REQUEST["file"] = "";
         $_REQUEST["ajxaction"] = "";
         ${${"GLOBALS"}["djwhrrnnsjk"]} = $_REQUEST["action"];
         $_REQUEST["action"] = "";
         $focus->isLineItemUpdate = false;
         $focus->save($this->getModuleName());
     } catch (\Exception $exp) {
         if ($exp->getCode() == "DATABASE_QUERY_ERROR") {
             $nhkvwsu = "handleResult";
             global $adb;
             ${$nhkvwsu} = $this->_handleDatabaseError($adb->database->_errorMsg);
             return;
         }
         if ($exp->getCode() == "MANDATORY_FIELDS_MISSING") {
             ${"GLOBALS"}["xkshfsxwf"] = "handleResult";
             ${"GLOBALS"}["gmokooantx"] = "handleResult";
             ${${"GLOBALS"}["gmokooantx"]} = $this->_handleMandatoryError(${${"GLOBALS"}["jvdhxqdu"]});
             if (${${"GLOBALS"}["xkshfsxwf"]} !== false) {
                 return;
             }
         }
         \Workflow2::error_handler($exp->getCode(), $exp->getMessage(), $exp->getFile(), $exp->getLine());
     }
     $this->afterTransfer();
     $this->_changed = false;
     $_FILES = ${${"GLOBALS"}["rednnyjghpl"]};
     unset(VTEntity::${$wislscn}[VTEntity::$_user->id][$this->_id]);
     if (!$this instanceof VTInventoryEntity) {
         $this->_data = false;
     }
 }
예제 #20
0
 public function getFieldValueArray(VTEntity $context, $setterMap)
 {
     ${"GLOBALS"}["qpcsskrqcb"] = "return";
     ${"GLOBALS"}["ikjailgh"] = "setterMap";
     $lmbjulm = "setter";
     ${${"GLOBALS"}["qpcsskrqcb"]} = array();
     foreach (${${"GLOBALS"}["ikjailgh"]} as ${$lmbjulm}) {
         ${"GLOBALS"}["ysgijyp"] = "newValue";
         $nlfnkhvbsydm = "setter";
         ${"GLOBALS"}["jesowuvsevc"] = "setter";
         if (empty(${$nlfnkhvbsydm}["field"])) {
             continue;
         }
         $myyyzqb = "return";
         if (${${"GLOBALS"}["wfwvejp"]}["mode"] == "function") {
             $xcgpolcxqi = "newValue";
             $wghopoiw = "context";
             ${"GLOBALS"}["exnpxogkqow"] = "setter";
             ${${"GLOBALS"}["gnwthoyzmyc"]} = new \Workflow\ExpressionParser(${${"GLOBALS"}["exnpxogkqow"]}["value"], ${$wghopoiw}, false);
             try {
                 $parser->run();
             } catch (ExpressionException $exp) {
                 \Workflow2::error_handler(E_EXPRESSION_ERROR, $exp->getMessage(), "", "");
             }
             ${$xcgpolcxqi} = $parser->getReturn();
         } else {
             ${"GLOBALS"}["epyviwg"] = "setter";
             $oybfubfnlh = "setter";
             ${"GLOBALS"}["fijedwsppbdr"] = "context";
             $ikxlqgdidh = "setter";
             ${"GLOBALS"}["dpxascgg"] = "newValue";
             ${$oybfubfnlh}["value"] = \Workflow\VTTemplate::parse(${$ikxlqgdidh}["value"], ${${"GLOBALS"}["fijedwsppbdr"]});
             ${${"GLOBALS"}["dpxascgg"]} = ${${"GLOBALS"}["epyviwg"]}["value"];
         }
         ${$myyyzqb}[${${"GLOBALS"}["jesowuvsevc"]}["field"]] = ${${"GLOBALS"}["ysgijyp"]};
     }
     return ${${"GLOBALS"}["tkmmiwpj"]};
 }
예제 #21
0
 public static function logSQLError($error, $sqlQuery = '')
 {
     if (!empty(${${"GLOBALS"}["eljokyfpbss"]})) {
         $ckvkssrxrk = "sqlQuery";
         \Workflow2::error_handler(E_ERROR, "Database Error in Query " . ${$ckvkssrxrk}, "", "");
     }
 }