public function changePassword($request) { $request = new Vtiger_Request($request); $viewer = Vtiger_Viewer::getInstance(); $userName = $request->get('username'); $newPassword = $request->get('password'); $confirmPassword = $request->get('confirmPassword'); $shortURLID = $request->get('shorturl_id'); $secretHash = $request->get('secret_hash'); $shortURLModel = Vtiger_ShortURL_Helper::getInstance($shortURLID); $secretToken = $shortURLModel->handler_data['secret_token']; $validateData = array('username' => $userName, 'secret_token' => $secretToken, 'secret_hash' => $secretHash); $valid = $shortURLModel->compareEquals($validateData); if ($valid) { $userId = getUserId_Ol($userName); $user = Users::getActiveAdminUser(); $wsUserId = vtws_getWebserviceEntityId('Users', $userId); vtws_changePassword($wsUserId, '', $newPassword, $confirmPassword, $user); } else { $viewer->assign('ERROR', true); } $shortURLModel->delete(); $viewer->assign('USERNAME', $userName); $viewer->assign('PASSWORD', $newPassword); $viewer->view('FPLogin.tpl', 'Users'); }
protected function _getFile($id, $moduleName, $crmid) { $current_user = \Users_Record_Model::getCurrentUserModel(); $useUser = \Users::getActiveAdminUser(); $oldUser = vglobal('current_user'); vglobal('current_user', $useUser); $tmpFilename = $this->_getTmpFilename(); $mpdf = ""; $language = $current_user->language; if (empty($language)) { $language = \Vtiger_Language_Handler::getLanguage(); } $Records = array($crmid); // $request = $_REQUEST; // $_REQUEST['search'] = true; //$_REQUEST['submode'] = true; \Vtiger_Loader::autoLoad('PDFMaker_PDFMaker_Model'); $PDFMaker = new \PDFMaker_PDFMaker_Model(); $name = $PDFMaker->GetPreparedMPDF($mpdf, $Records, array($id), $moduleName, $language); $name = $PDFMaker->generate_cool_uri($name); if ($name != "") { $name = $name . ".pdf"; } $mpdf->Output($tmpFilename); vglobal('current_user', $oldUser); $filetype = "application/pdf"; //$_REQUEST = $request; return array('path' => $tmpFilename, 'name' => $name, 'type' => $filetype); }
public function step1(Vtiger_Request $request) { $currentUser = Users_Record_Model::getCurrentUserModel(); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $qualifiedModuleName = $request->getModule(false); $recordId = $request->get('record'); if ($recordId) { $workflowModel = Settings_Workflows_Record_Model::getInstance($recordId); $viewer->assign('RECORDID', $recordId); $viewer->assign('MODULE_MODEL', $workflowModel->getModule()); $viewer->assign('MODE', 'edit'); } else { $workflowModel = Settings_Workflows_Record_Model::getCleanInstance($moduleName); $selectedModule = $request->get('source_module'); if (!empty($selectedModule)) { $viewer->assign('SELECTED_MODULE', $selectedModule); } } $db = PearDatabase::getInstance(); $workflowManager = new VTWorkflowManager($db); $viewer->assign('MAX_ALLOWED_SCHEDULED_WORKFLOWS', $workflowManager->getMaxAllowedScheduledWorkflows()); $viewer->assign('SCHEDULED_WORKFLOW_COUNT', $workflowManager->getScheduledWorkflowsCount()); $viewer->assign('WORKFLOW_MODEL', $workflowModel); $viewer->assign('ALL_MODULES', Settings_Workflows_Module_Model::getSupportedModules()); $viewer->assign('TRIGGER_TYPES', Settings_Workflows_Module_Model::getTriggerTypes()); $viewer->assign('MODULE', $moduleName); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->assign('CURRENT_USER', $currentUser); $admin = Users::getActiveAdminUser(); $viewer->assign('ACTIVE_ADMIN', $admin); $viewer->view('Step1.tpl', $qualifiedModuleName); }
function processMap($arguments) { global $adb, $current_user; $xml = $this->getXMLContent(); $entityId = $arguments[0]; $holduser = $current_user; $current_user = Users::getActiveAdminUser(); // evaluate condition as admin user $entity = new VTWorkflowEntity($current_user, $entityId); $current_user = $holduser; if (isset($xml->expression)) { $testexpression = (string) $xml->expression; $parser = new VTExpressionParser(new VTExpressionSpaceFilter(new VTExpressionTokenizer($testexpression))); $expression = $parser->expression(); $exprEvaluater = new VTFieldExpressionEvaluater($expression); $exprEvaluation = $exprEvaluater->evaluate($entity); } elseif (isset($xml->function)) { list($void, $entity->data['record_id']) = explode('x', $entity->data['id']); $entity->data['record_module'] = $entity->getModuleName(); $function = (string) $xml->function->name; $testexpression = '$exprEvaluation = ' . $function . '('; foreach ($xml->function->parameters->parameter as $k => $v) { if (isset($entity->data[(string) $v])) { $testexpression .= "'" . $entity->data[(string) $v] . "',"; } else { $testexpression .= "'" . (string) $v . "',"; } } $testexpression = trim($testexpression, ',') . ');'; eval($testexpression); } return $exprEvaluation; }
/** * Push the admin user on to the user stack * and make it the $current_user * */ function adminUser() { $user = Users::getActiveAdminUser(); global $current_user; if (empty(self::$userStack) || count(self::$userStack) == 0) { self::$loggedInUser = $current_user; } array_push(self::$userStack, $current_user); $current_user = $user; return $user; }
public function changePassword($request) { $request = new Vtiger_Request($request); $viewer = Vtiger_Viewer::getInstance(); $username = $request->get('username'); $newPassword = $request->get('password'); $confirmPassword = $request->get('confirmPassword'); $userId = getUserId_Ol($username); $user = Users::getActiveAdminUser(); $wsUserId = vtws_getWebserviceEntityId('Users', $userId); vtws_changePassword($wsUserId, '', $newPassword, $confirmPassword, $user); $viewer->assign('USERNAME', $username); $viewer->assign('PASSWORD', $newPassword); $viewer->view('FPLogin.tpl', 'Users'); }
/** * @param $context \Workflow\VTEntity */ public function getAllChildAttachmentIds($context) { $adb = \PearDatabase::getInstance(); $oldUser = vglobal('current_user'); vglobal('current_user', \Users::getActiveAdminUser()); $model = \Vtiger_Module_Model::getInstance($context->getModuleName()); $query = $model->getRelationQuery($context->getId(), 'get_attachments', \Vtiger_Module_Model::getInstance('Documents')); $parts = explode('FROM', $query, 2); $query = 'SELECT vtiger_attachments.attachmentsid as id FROM ' . $parts[1]; $result = $adb->query($query); $ids = array(); while ($row = $adb->fetchByAssoc($result)) { $this->addAttachmentRecord('ID', $row['id']); } vglobal('current_user', $oldUser); }
function createInvoice($salesorder_id) { require_once 'include/utils/utils.php'; require_once 'modules/SalesOrder/SalesOrder.php'; require_once 'modules/Invoice/Invoice.php'; require_once 'modules/Users/Users.php'; global $log, $adb; global $current_user; // Payment duration in days $payment_duration_values = array('net 01 day' => '1', 'net 05 days' => '5', 'net 07 days' => '7', 'net 10 days' => '10', 'net 15 days' => '15', 'net 30 days' => '30', 'net 45 days' => '45', 'net 60 days' => '60'); if (!$current_user) { $current_user = Users::getActiveAdminUser(); } $so_focus = new SalesOrder(); $so_focus->id = $salesorder_id; $so_focus->retrieve_entity_info($salesorder_id, "SalesOrder"); foreach ($so_focus->column_fields as $fieldname => $value) { $so_focus->column_fields[$fieldname] = decode_html($value); } $focus = new Invoice(); // This will only fill in the basic columns from SO to Invoice and also Update the SO id in new Invoice $focus = getConvertSoToInvoice($focus, $so_focus, $salesorder_id); // Pick up the Payment due date based on the Configuration in SO $payment_duration = $so_focus->column_fields['payment_duration']; $due_duration = $payment_duration_values[trim(strtolower($payment_duration))]; $durationinsec = mktime(0, 0, 0, date('m'), date('d') + $due_duration, date('Y')); // Cleanup focus object, to duplicate the Invoice. $focus->id = ''; $focus->mode = ''; $focus->column_fields['invoicestatus'] = $so_focus->column_fields['invoicestatus']; $focus->column_fields['invoicedate'] = date('Y-m-d'); $focus->column_fields['duedate'] = date('Y-m-d', $durationinsec); // Additional SO fields to copy -> Invoice field name mapped to equivalent SO field name $invoice_so_fields = array('txtAdjustment' => 'txtAdjustment', 'hdnSubTotal' => 'hdnSubTotal', 'hdnGrandTotal' => 'hdnGrandTotal', 'hdnTaxType' => 'hdnTaxType', 'hdnDiscountPercent' => 'hdnDiscountPercent', 'hdnDiscountAmount' => 'hdnDiscountAmount', 'hdnS_H_Amount' => 'hdnS_H_Amount', 'assigned_user_id' => 'assigned_user_id', 'currency_id' => 'currency_id', 'conversion_rate' => 'conversion_rate'); foreach ($invoice_so_fields as $invoice_field => $so_field) { $focus->column_fields[$invoice_field] = $so_focus->column_fields[$so_field]; } $focus->_salesorderid = $salesorder_id; $focus->_recurring_mode = 'recurringinvoice_from_so'; $focus->save("Invoice"); }
/** * Create new Email record (and link to given record) including attachments * @global Users $current_user * @global PearDataBase $adb * @param MailManager_Message_Model $mailrecord * @param String $module * @param CRMEntity $linkfocus * @return Integer */ function __CreateNewEmail($mailrecord, $module, $linkfocus) { global $current_user, $adb; if (!$current_user) { $current_user = Users::getActiveAdminUser(); } $handler = vtws_getModuleHandlerFromName('Emails', $current_user); $meta = $handler->getMeta(); if ($meta->hasWriteAccess() != true) { return false; } $focus = new Emails(); $focus->column_fields['activitytype'] = 'Emails'; $focus->column_fields['subject'] = $mailrecord->_subject; if (!empty($module)) { $focus->column_fields['parent_type'] = $module; } if (!empty($linkfocus->id)) { $focus->column_fields['parent_id'] = "{$linkfocus->id}@-1|"; } $focus->column_fields['description'] = $mailrecord->getBodyHTML(); $focus->column_fields['assigned_user_id'] = $current_user->id; $focus->column_fields["date_start"] = date('Y-m-d', $mailrecord->_date); $focus->column_fields["email_flag"] = 'MailManager'; $from = $mailrecord->_from[0]; $to = $mailrecord->_to[0]; $cc = !empty($mailrecord->_cc) ? implode(',', $mailrecord->_cc) : ''; $bcc = !empty($mailrecord->_bcc) ? implode(',', $mailrecord->_bcc) : ''; //emails field were restructured and to,bcc and cc field are JSON arrays $focus->column_fields['from_email'] = $from; $focus->column_fields['saved_toid'] = $to; $focus->column_fields['ccmail'] = $cc; $focus->column_fields['bccmail'] = $bcc; $focus->save('Emails'); $emailid = $focus->id; // TODO: Handle attachments of the mail (inline/file) $this->__SaveAttachements($mailrecord, 'Emails', $focus); return $emailid; }
/** * Initilizate commerce operation controller. * @param String $assignedUserName * @param String $userKey */ public function __construct($assignedUserName) { $this->restUser = Users::getActiveAdminUser(); $this->assignedUserReference = $this->getUserReference($assignedUserName); }
public function handleTask(&$context) { $adb = \PearDatabase::getInstance(); if (!getTabid('PDFMaker') || !vtlib_isModuleActive('PDFMaker')) { throw new \Exception('PDFMaker Extension not found!'); } /* Insert here source code to execute the task */ $recordChooser = $this->get('recordChooser'); if (empty($recordChooser) || $recordChooser == -1) { throw new \Exception('You need to configure the PDFMaker Integraion.'); } $recordIds = array(); if ($recordChooser === 'current') { $recordIds = array($context->getId()); $moduleName = $this->getModuleName(); } else { $currentTime = microtime(true); $benchmark = array(); $parts = explode("#~#", $this->get("search_module")); $related_module = VtUtils::getModuleName($parts[1]); $moduleName = $related_module; $logger = new \Workflow\ConditionLogger(); $objMySQL = new \Workflow\ConditionMysql($related_module, $context); $objMySQL->setLogger($logger); $main_module = \CRMEntity::getInstance($related_module); $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; } $this->addStat("MySQL Query: " . $sqlQuery); $result = $adb->query($sqlQuery, true); $newTime = microtime(true); $benchmark[] = round($newTime - $currentTime, 3); $this->addStat("num Rows: " . $adb->num_rows($result)); # If no records are found, fo other way if ($adb->num_rows($result) == 0) { return "yes"; } $this->addStat("Benchmark: " . implode("/", $benchmark)); while ($row = $adb->fetchByAssoc($result)) { $recordIds[] = $row['idcol']; } } $context->save(); $useUser = Users::getActiveAdminUser(); $oldUser = vglobal('current_user'); vglobal('current_user', $useUser); $PDFMaker = new PDFMaker_PDFMaker_Model(); $dl = Vtiger_Language_Handler::getLanguage(); $mpdf = ""; $copies = $this->get('copies'); if ($copies == -1 || empty($copies)) { $copies = 1; } $templateids = array(); for ($i = 0; $i < $copies; $i++) { $templateids = array_merge($templateids, $this->get("template")); } $filename = $PDFMaker->GetPreparedMPDF($mpdf, $recordIds, $templateids, $moduleName, $dl, ''); if (strpos($filename, '.pdf') === false) { $filename .= '.pdf'; } // $filename = $PDFMaker->generate_cool_uri($filename); $tmpfile = tempnam(sys_get_temp_dir(), 'WfTmp'); @unlink($tmpfile); $mpdf->Output($tmpfile); $overwriteFilename = $this->get("filename", $context); if ($overwriteFilename != -1 && !empty($overwriteFilename)) { $filename = $overwriteFilename; } \Workflow\FileAction::doActions($this->get('resultaction'), $tmpfile, $filename, $context, $recordIds, $this->getWorkflow()); vglobal('current_user', $oldUser); return "yes"; }
public static function error_handler($errno = "", $errstr = "", $errfile = "", $errline = "") { $zxslshktqz = "html"; ${"GLOBALS"}["xboekqcqm"] = "errno"; ${"GLOBALS"}["mfgxjg"] = "html"; ${"GLOBALS"}["glxgfbgigzku"] = "html"; $uedscllpsvlr = "typestr"; $thmqjfmfpw = "typestr"; ${"GLOBALS"}["dkqevjsalgi"] = "errno"; ${"GLOBALS"}["juewps"] = "typestr"; global $current_user; ${"GLOBALS"}["nlobacmlu"] = "html"; if (error_reporting() == 0) { } if (${${"GLOBALS"}["dkqevjsalgi"]} === 8) { return; } ${"GLOBALS"}["tpuuspn"] = "errstr"; if (is_object(${${"GLOBALS"}["twoweeievgm"]})) { ${"GLOBALS"}["pxzbxjo"] = "errfile"; $tpchwbjnrtz = "errstr"; ${${"GLOBALS"}["jsvfdsfh"]} = $errno->getLine(); ${${"GLOBALS"}["pxzbxjo"]} = $errno->getFile(); $rlyjxlj = "errno"; ${$tpchwbjnrtz} = $errno->getMessage(); ${${"GLOBALS"}["gqqzlivz"]} = $errno->getTrace(); ${$rlyjxlj} = E_ERROR; } ${"GLOBALS"}["lqwwegyxqvq"] = "errno"; ${"GLOBALS"}["wwhducoegfhj"] = "errline"; ${"GLOBALS"}["oonyfhjc"] = "typestr"; ${"GLOBALS"}["ikskblbjdyqm"] = "typestr"; ${${"GLOBALS"}["nnxpesshwam"]} = \PearDatabase::getInstance(); if (!empty($adb->database->_connectionID->error)) { $drfqzsarfm = "errstr"; ${$drfqzsarfm} .= "<br/><br/>" . $adb->database->_connectionID->error; ${${"GLOBALS"}["pmliottx"]} .= serialize(${${"GLOBALS"}["nnxpesshwam"]}); } ${"GLOBALS"}["mxrwfqjv"] = "currentBlockObj"; ${"GLOBALS"}["epitxtaom"] = "html"; ${"GLOBALS"}["kqrcfjwiiaaf"] = "html"; if (Workflow2::${${"GLOBALS"}["lyksdalu"]} == false) { return false; } $boxfsxrhhy = "html"; switch (${${"GLOBALS"}["twoweeievgm"]}) { case "REFERENCE_INVALID": case "MANDATORY_FIELDS_MISSING": case "ACCESS_DENIED": ${${"GLOBALS"}["lywuyikoio"]} = ${${"GLOBALS"}["twoweeievgm"]}; break; case E_ERROR: ${${"GLOBALS"}["lywuyikoio"]} = "E_ERROR"; break; case E_PARSE: ${${"GLOBALS"}["lywuyikoio"]} = "E_PARSE"; break; case E_CORE_ERROR: ${${"GLOBALS"}["lywuyikoio"]} = "E_CORE_ERROR"; break; case E_CORE_WARNING: ${${"GLOBALS"}["lywuyikoio"]} = "E_CORE_WARNING"; break; case E_COMPILE_ERROR: ${${"GLOBALS"}["juewps"]} = "E_COMPILE_ERROR"; break; case E_CORE_WARNING: ${$uedscllpsvlr} = "E_COMPILE_WARNING"; break; case E_USER_ERROR: ${${"GLOBALS"}["ikskblbjdyqm"]} = "E_USER_ERROR"; break; case E_USER_WARNING: ${${"GLOBALS"}["oonyfhjc"]} = "E_USER_WARNING"; break; case E_RECOVERABLE_ERROR: ${${"GLOBALS"}["lywuyikoio"]} = "E_RECOVERABLE_ERROR"; break; case E_EXPRESSION_ERROR: ${$thmqjfmfpw} = "E_EXPRESSION_ERROR"; break; case E_NONBREAK_ERROR: ${${"GLOBALS"}["lywuyikoio"]} = "E_NONBREAK_ERROR"; break; default: return true; } ${${"GLOBALS"}["mfgxjg"]} = "<html>"; ${${"GLOBALS"}["glxgfbgigzku"]} .= "<body style='font-family:Arial;'>"; ${$zxslshktqz} .= "<h2>Workflow2 Error occurred [" . Workflow2::VERSION . "]</h2>"; ${${"GLOBALS"}["bcgwqrfkwi"]} .= "<table style='font-size:14px;font-family:Courier;'>"; ${$boxfsxrhhy} .= "<tr><td width=100>ERROR:</td><td><strong>" . ${${"GLOBALS"}["lywuyikoio"]} . "</strong></td></tr>"; ${${"GLOBALS"}["epitxtaom"]} .= "<tr><td>LOCATION:</td><td><em>" . ${${"GLOBALS"}["nkwnskowfm"]} . " [" . ${${"GLOBALS"}["wwhducoegfhj"]} . "]</td></tr>"; ${${"GLOBALS"}["nlobacmlu"]} .= "<tr><td>Last Block:</td><td><em>" . Workflow2::${${"GLOBALS"}["gzmpicl"]} . "</td></tr>"; if (is_object(Workflow2::${${"GLOBALS"}["mxrwfqjv"]})) { $xoibeexo = "wfId"; $iupfnkgskt = "currentBlock"; $heerhomdboi = "currentBlock"; ${"GLOBALS"}["dspzbdt"] = "wfId"; ${${"GLOBALS"}["dspzbdt"]} = Workflow2::$currentBlockObj->getWorkflowId(); ${${"GLOBALS"}["bcgwqrfkwi"]} .= "<tr><td>Current Block:</td><td><a href='" . vglobal("site_URL") . "/index.php?module=Workflow2&view=Config&parent=Settings&workflow=" . ${$xoibeexo} . "'>WF " . Workflow2::$currentBlockObj->getWorkflowId() . "</a> - <a href='" . vglobal("site_URL") . "/index.php?module=Workflow2&parent=Settings&view=TaskConfig&taskid=" . Workflow2::${$heerhomdboi} . "'><em>Block " . Workflow2::${$iupfnkgskt} . "</a></td></tr>"; } else { $yxnhgamlo = "currentBlock"; ${${"GLOBALS"}["bcgwqrfkwi"]} .= "<tr><td>Current Block:</td><td><a href='" . vglobal("site_URL") . "/index.php?module=Workflow2&parent=Settings&view=TaskConfig&taskid=" . Workflow2::${$yxnhgamlo} . "'><em>Block " . Workflow2::${${"GLOBALS"}["hjepztr"]} . "</a></td></tr>"; } ${${"GLOBALS"}["bcgwqrfkwi"]} .= "</table>"; ${${"GLOBALS"}["bcgwqrfkwi"]} .= "<br>"; ${${"GLOBALS"}["kqrcfjwiiaaf"]} .= ${${"GLOBALS"}["tpuuspn"]}; if ($current_user->is_admin == "on") { ${${"GLOBALS"}["bcgwqrfkwi"]} .= "<br><br><pre>" . substr(print_r(isset(${${"GLOBALS"}["gqqzlivz"]}) ? ${${"GLOBALS"}["gqqzlivz"]} : debug_backtrace(), true), 0, 10000) . "</pre>"; } ${${"GLOBALS"}["bcgwqrfkwi"]} .= "</body>"; ${${"GLOBALS"}["bcgwqrfkwi"]} .= "</html>"; if (${${"GLOBALS"}["xboekqcqm"]} != E_NONBREAK_ERROR) { echo "<br><br><strong>The Systemadministrator has been notified!</strong>"; if (php_sapi_name() == "cli" && empty($_SERVER["REMOTE_ADDR"])) { $wztouxewoxg = "html"; echo strip_tags(str_replace("</tr>", "\n", ${$wztouxewoxg})); } else { echo ${${"GLOBALS"}["bcgwqrfkwi"]}; } } if (is_object(self::${${"GLOBALS"}["tbqjwgajpr"]})) { ${"GLOBALS"}["hgcpks"] = "sql"; $ltrvirquaxf = "typestr"; ${"GLOBALS"}["rullypv"] = "errstr"; ${${"GLOBALS"}["hgcpks"]} = "INSERT INTO vtiger_wf_errorlog SET block_id = " . intval(Workflow2::${${"GLOBALS"}["hjepztr"]}) . ", text = ?, workflow_id = ?"; global $adb; $adb->pquery(${${"GLOBALS"}["wpvlkaycsb"]}, array(${$ltrvirquaxf} . " # " . ${${"GLOBALS"}["rullypv"]}, self::$currentBlockObj->getWorkflowId())); } set_include_path(dirname(__FILE__) . "/../../" . PATH_SEPARATOR . get_include_path()); if (defined("ERROR_HANDLER")) { if (constant("ERROR_HANDLER") == "email") { $uctwsbxmn = "errorMail"; ${$uctwsbxmn} = constant("ERROR_HANDLER_VALUE"); ${"GLOBALS"}["zvrlosxm"] = "errorMail"; if (empty(${${"GLOBALS"}["zvrlosxm"]})) { ${${"GLOBALS"}["vlxqookbyem"]} = \Users::getActiveAdminUser(); ${${"GLOBALS"}["dhlyfml"]} = $adminUser->column_fields["email1"]; } } elseif (constant("ERROR_HANDLER") == "file") { ${"GLOBALS"}["knmrkjltmi"] = "currentBlock"; error_log(${${"GLOBALS"}["pmliottx"]} . " # - # Block: " . Workflow2::${${"GLOBALS"}["knmrkjltmi"]} . " # -\n", 3, constant("ERROR_HANDLER_VALUE")); } } if (!defined("WF_DEMO_MODE") || constant("WF_DEMO_MODE") != true) { ${"GLOBALS"}["wxiehnwe"] = "errorMail"; require_once "modules/Emails/mail.php"; $xfidny = "to_email"; if (!class_exists("Workflow_PHPMailer")) { require_once "modules/Workflow2/phpmailer/class.phpmailer.php"; } ${"GLOBALS"}["rwxevbhvzdl"] = "errorMail"; ${$xfidny} = trim(${${"GLOBALS"}["wxiehnwe"]}, ","); $jhhssnhww = "html"; ${${"GLOBALS"}["buscjzx"]} = array(); if (strpos(${${"GLOBALS"}["chwolsutzxsr"]}, ";") !== false) { $wikeps = "mails"; ${$wikeps} = explode(";", ${${"GLOBALS"}["chwolsutzxsr"]}); $oiuuxhhtyoh = "address"; $npqvob = "mails"; foreach (${$npqvob} as ${$oiuuxhhtyoh}) { $lixdtmhjtqhr = "to"; ${$lixdtmhjtqhr}[] = ${${"GLOBALS"}["tqpkvmfwbj"]}; } } else { $xywinhspgvrz = "to_email"; ${${"GLOBALS"}["buscjzx"]}[] = ${$xywinhspgvrz}; } send_mail("Workflow2", ${${"GLOBALS"}["chwolsutzxsr"]}, "Workflow Designer", ${${"GLOBALS"}["rwxevbhvzdl"]}, "Workflow2 Error occurred", ${$jhhssnhww}); } if (wfIsCli()) { return true; } if (${${"GLOBALS"}["lqwwegyxqvq"]} != E_NONBREAK_ERROR) { exit; } return true; }
/** * Function parse the value based on the condition * @param <Array> $condition * @return <String> */ function _parseValueForDate($condition) { $value = $condition['value']; $operation = $condition['operation']; // based on the admin users time zone, since query generator expects datetime at user timezone global $default_timezone; $admin = Users::getActiveAdminUser(); $adminTimeZone = $admin->time_zone; @date_default_timezone_set($adminTimeZone); switch ($operation) { case 'less than days ago': //between current date and (currentdate - givenValue) $days = $condition['value']; $value = date('Y-m-d', strtotime('-' . $days . ' days')) . ',' . date('Y-m-d', strtotime('+1 day')); break; case 'more than days ago': // less than (current date - givenValue) $days = $condition['value'] - 1; $value = date('Y-m-d', strtotime('-' . $days . ' days')); break; case 'in less than': // between current date and future date(current date + givenValue) $days = $condition['value'] + 1; $value = date('Y-m-d', strtotime('-1 day')) . ',' . date('Y-m-d', strtotime('+' . $days . ' days')); break; case 'in more than': // greater than future date(current date + givenValue) $days = $condition['value'] - 1; $value = date('Y-m-d', strtotime('+' . $days . ' days')); break; case 'days ago': $days = $condition['value']; $value = date('Y-m-d', strtotime('-' . $days . ' days')); break; case 'days later': $days = $condition['value']; $value = date('Y-m-d', strtotime('+' . $days . ' days')); break; case 'is today': $value = date('Y-m-d'); break; case 'less than hours before': $hours = $condition['value']; $value = date('Y-m-d H:i:s', strtotime('-' . $hours . ' hours')) . ',' . date('Y-m-d H:i:s'); break; case 'less than hours later': $hours = $condition['value']; $value = date('Y-m-d H:i:s') . ',' . date('Y-m-d H:i:s', strtotime('+' . $hours . ' hours')); break; case 'more than hours later': $hours = $condition['value']; $value = date('Y-m-d H:i:s', strtotime('+' . $hours . ' hours')); break; case 'more than hours before': $hours = $condition['value']; $value = date('Y-m-d H:i:s', strtotime('-' . $hours . ' hours')); break; } @date_default_timezone_set($default_timezone); return $value; }
protected function prepareTransfer() { $hkhfzxsbj = "currentModule"; global $current_user, $oldCurrentUser, $currentModule; ${"GLOBALS"}["ybgepj"] = "useUser"; $this->_oldRequest = $_REQUEST; $this->_oldCurrentModule = ${${"GLOBALS"}["fwxvuaqo"]}; $urxnjluymyx = "useUser"; ${"GLOBALS"}["dryxalq"] = "current_user"; ${"GLOBALS"}["uozffdadnv"] = "current_user"; unset($_REQUEST); $_REQUEST = $this->_saveRequest; ${$urxnjluymyx} = \Users::getActiveAdminUser(); ${${"GLOBALS"}["jrrnjbpw"]} = ${${"GLOBALS"}["dryxalq"]}; ${${"GLOBALS"}["uozffdadnv"]} = ${${"GLOBALS"}["ybgepj"]}; ${$hkhfzxsbj} = $this->getModuleName(); $_REQUEST["ajxaction"] = "DETAILVIEW"; $_REQUEST["search"] = true; $_REQUEST["submode"] = true; unset($_REQUEST["tableblocks"]); VTEntity::$_user->currency_decimal_separator = "."; VTEntity::$_user->currency_grouping_separator = ""; VTEntity::$_user->column_fields["currency_decimal_separator"] = "."; VTEntity::$_user->column_fields["currency_grouping_separator"] = ""; $current_user->currency_decimal_separator = "."; $current_user->currency_grouping_separator = ""; $current_user->column_fields["currency_decimal_separator"] = "."; $current_user->column_fields["currency_grouping_separator"] = ""; if ($this->getModuleName() == "Contacts") { $_FILES = array("index" => array("name" => "", "size" => 0)); } }
/** * Function returns the commentor Model (Users Model) * @return <Vtiger_Record_Model> */ public function getCommentedByModel() { $customer = $this->get('customer'); if (!empty($customer)) { return Vtiger_Record_Model::getInstanceById($customer, 'Contacts'); } else { $commentedBy = $this->get('smownerid'); if ($commentedBy) { $commentedByModel = Vtiger_Record_Model::getInstanceById($commentedBy, 'Users'); if (empty($commentedByModel->entity->column_fields['user_name'])) { $activeAdmin = Users::getActiveAdminUser(); $commentedByModel = Vtiger_Record_Model::getInstanceById($activeAdmin->id, 'Users'); } return $commentedByModel; } } return false; }
public static function getScheduledReports() { $adb = PearDatabase::getInstance(); $default_timezone = vglobal('default_timezone'); // set the time zone to the admin's time zone, this is needed so that the scheduled reprots will be triggered // at admin's time zone rather than the systems time zone. This is specially needed for Hourly and Daily scheduled reports $admin = Users::getActiveAdminUser(); $adminTimeZone = $admin->time_zone; @date_default_timezone_set($adminTimeZone); $currentTimestamp = date("Y-m-d H:i:s"); @date_default_timezone_set($default_timezone); $result = $adb->pquery("SELECT reportid FROM vtiger_schedulereports WHERE next_trigger_time = '' || next_trigger_time <= ?", array($currentTimestamp)); $scheduledReports = array(); $noOfScheduledReports = $adb->num_rows($result); for ($i = 0; $i < $noOfScheduledReports; ++$i) { $recordId = $adb->query_result($result, $i, 'reportid'); $scheduledReports[] = self::getInstanceById($recordId); } return $scheduledReports; }
public static function getActiveAdminCurrentDateTime() { global $default_timezone; $admin = Users::getActiveAdminUser(); $adminTimeZone = $admin->time_zone; @date_default_timezone_set($adminTimeZone); $date = date('Y-m-d H:i:s'); @date_default_timezone_set($default_timezone); return $date; }
public function save() { if ($this->_deleted == true) { return; } if ($this->_data == false) { return; } if ($this->_isDummy) { return; } if (empty($this->_id)) { $result = $this->createRecord(); return $result; } if (VTEntity::$_user === false || VTEntity::$_user->is_admin != "on") { $useUser = Users::getActiveAdminUser(); } else { $useUser = VTEntity::$_user; } $oldFiles = $_FILES; require_once "include/Webservices/Update.php"; if ($this->_changed == false) { return; } // I must prevent $ajaxSave to come true in vtws_update. This will remove all date fields ! unset($_FILES); #$oldA = $_REQUEST['file']; #$oldB = $_REQUEST['action']; #$_REQUEST['file'] = "VTEntitiy"; #$_REQUEST['action'] = "WebServiceSave"; global $current_user, $default_charset; $oldCurrentUser = $current_user; $current_user = $useUser; $this->prepareTransfer(); try { require_once 'data/CRMEntity.php'; $metaHandler = self::getMetaHandler($this->getModuleName()); $focus = CRMEntity::getInstance($this->getModuleName()); $focus->id = $this->_id; $focus->mode = 'edit'; $focus->retrieve_entity_info($this->_id, $this->getModuleName()); $focus->clearSingletonSaveFields(); $focus->column_fields = \DataTransform::sanitizeDateFieldsForInsert($focus->column_fields, $metaHandler); $focus->column_fields = \DataTransform::sanitizeCurrencyFieldsForInsert($focus->column_fields, $metaHandler); $moduleFields = $metaHandler->getModuleFields(); foreach ($focus->column_fields as $key => $value) { if ($this->_data[$key] != $value && !in_array($key, array('record_id', 'record_module'))) { //var_dump($key, $this->_data[$key], $value); $newValue = $this->_data[$key]; $fieldInstance = $moduleFields[$key]; if (empty($fieldInstance)) { throw new \Exception('Field ' . $key . ' not found in module ' . $this->getModuleName() . '.'); } $fieldDataType = $fieldInstance->getFieldDataType(); if ('reference' == $fieldDataType || 'owner' == $fieldDataType) { $newValue = $this->getCrmId($newValue); if ($focus->column_fields[$key] == $newValue) { continue; } } //var_dump('set'); $focus->column_fields[$key] = $newValue; } } foreach ($focus->column_fields as $fieldName => $fieldValue) { $focus->column_fields[$fieldName] = html_entity_decode($fieldValue, ENT_QUOTES, $default_charset); } $_REQUEST['file'] = ''; $_REQUEST['ajxaction'] = ''; // Added as Mass Edit triggers workflow and date and currency fields are set to user format // When saving the information in database saveentity API should convert to database format // and save it. But it converts in database format only if that date & currency fields are // changed(massedit) other wise they wont be converted thereby changing the values in user // format, CRMEntity.php line 474 has the login to check wheather to convert to database format $actionName = $_REQUEST['action']; $_REQUEST['action'] = ''; // For workflows update field tasks is deleted all the lineitems. $focus->isLineItemUpdate = false; $focus->save($this->getModuleName()); //// Reverting back the action name as there can be some dependencies on this. //$_REQUEST['action'] = $actionName; //$result = vtws_update($this->_data, $useUser); $current_user = $oldCurrentUser; } catch (Exception $exp) { $current_user = $oldCurrentUser; if ($exp->getCode() == "DATABASE_QUERY_ERROR") { global $adb; $handleResult = $this->_handleDatabaseError($adb->database->_errorMsg); return; } if ($exp->getCode() == "MANDATORY_FIELDS_MISSING") { $handleResult = $this->_handleMandatoryError($exp); if ($handleResult !== false) { return; } } throw $exp; } $this->afterTransfer(); $this->_changed = false; $_FILES = $oldFiles; }
* Module : Template script to import a CSV file into a module * Version : 1.0 * Author : Alan Bell, from Libertus. Shared on the vtiger CRM developer's list * Notes from author: * Note this script reads in a csv file with the separator a semi-colon. * For large imports I break the csv file into multiple files of say 50,000 each and then call * this script from a bash shell script wrapper which does something like this: * for FILE in ${FILES} * do * php -f write-csv.php ${FILEPATH}${FILE} * done *************************************************************************************************/ // Turn on debugging level $Vtiger_Utils_Log = true; include_once 'vtlib/Vtiger/Module.php'; $current_user = Users::getActiveAdminUser(); $file = $argv[1]; if (!file_exists($file) || !is_readable($file)) { echo "No suitable file specified" . PHP_EOL; die; } function csv_to_array($file = '', $length = 0, $delimiter = ';') { $header = NULL; $data = array(); if (($handle = fopen($file, 'r')) !== FALSE) { while (($row = fgetcsv($handle, $length, $delimiter)) !== FALSE) { if (!$header) { $header = $row; } else { $data[] = array_combine($header, $row);
/** * @param $context VTEntity */ public function handleTask(&$context) { if (!getTabid('PDFMaker') || !vtlib_isModuleActive('PDFMaker')) { return 'yes'; } global $adb, $current_user, $log, $root_directory; // PDFMaker greift auf Datenbank zurück. Daher zuerst speichern! $context->save(); $userId = $context->get('assigned_user_id'); if ($userId === null) { $userId = vtws_getWebserviceEntityId('Users', 1); } $moduleName = $context->getModuleName(); $id = $context->getId(); list($id2, $assigned_user_id) = explode("x", $userId); $parentid = $id; require_once 'modules/Documents/Documents.php'; $focus = new \Documents(); $focus->parentid = $parentid; $modFocus = $context->getInternalObject(); $templateid = $this->template; $this->folder = 1; $foldername = $adb->getOne("SELECT foldername FROM vtiger_attachmentsfolder WHERE folderid='" . $this->folder . "'", 0, "foldername"); $fieldname = $adb->getOne("SELECT fieldname FROM vtiger_field WHERE uitype=4 AND tabid=" . getTabId($moduleName), 0, "fieldname"); /* new PDFMaker Routine */ $PDFMaker = new PDFMaker_PDFMaker_Model(); if (isset($modFocus->column_fields[$fieldname]) && $modFocus->column_fields[$fieldname] != "") { $file_name = $PDFMaker->generate_cool_uri($modFocus->column_fields[$fieldname]) . ".pdf"; } else { $file_name = generate_cool_uri($foldername . "_" . $templateid . $focus->parentid . date("ymdHi")) . ".pdf"; } $this->addStat("Attach Document '" . $file_name . "'"); $docTitle = $this->get("documenttitle", $context); $docDescr = $this->get("documentdescr", $context); $focus->column_fields['notes_title'] = $docTitle; $focus->column_fields['assigned_user_id'] = $assigned_user_id; $focus->column_fields['filename'] = $file_name; $focus->column_fields['notecontent'] = $docDescr; $focus->column_fields['filetype'] = 'application/pdf'; $focus->column_fields['filesize'] = ''; $focus->column_fields['filelocationtype'] = 'I'; $focus->column_fields['fileversion'] = ''; $focus->column_fields['filestatus'] = 'on'; $focus->column_fields['folderid'] = $this->get("folderid"); $focus->save('Documents'); $language = $current_user->language; $request = $_REQUEST; $_REQUEST['search'] = true; $_REQUEST['submode'] = true; if ($current_user->is_admin != "on") { $useUser = Users::getActiveAdminUser(); } else { $useUser = $current_user; } $oldCurrentUser = $current_user; $current_user = $useUser; $dummyRequest = new Vtiger_Request(array()); $PDFMaker->createPDFAndSaveFile($dummyRequest, $this->get("template"), $focus, $modFocus, $file_name, $this->getModuleName(), $language); $current_user = $oldCurrentUser; $_REQUEST = $request; /* new PDFMaker Routine */ $overwriteFilename = $this->get("filename", $context); if ($overwriteFilename != -1 && !empty($overwriteFilename)) { global $root_directory; $sql = "SELECT attachmentsid FROM vtiger_seattachmentsrel WHERE crmid = " . $focus->id . " ORDER BY attachmentsid DESC LIMIT 1"; $result = $adb->query($sql); if ($adb->num_rows($result) > 0) { $attachmentsid = $adb->query_result($result, 0, "attachmentsid"); $attRst = $adb->query("SELECT * FROM vtiger_attachments WHERE attachmentsid = " . $attachmentsid); $attachment = $adb->fetchByAssoc($attRst); $oldFilename = $root_directory . "/" . $attachment["path"] . $attachmentsid . "_" . $attachment["name"]; $newFilename = $root_directory . "/" . $attachment["path"] . $attachmentsid . "_" . $overwriteFilename; @rename($oldFilename, $newFilename); $adb->pquery("UPDATE vtiger_attachments SET name = ? WHERE attachmentsid = " . $attachmentsid, array($overwriteFilename)); $adb->pquery("UPDATE vtiger_notes SET filename = ? WHERE notesid = " . $focus->id, array($overwriteFilename)); } $file_name = $foldername . "_" . $overwriteFilename; } $_REQUEST = $request; if ($this->get("createrel") === "1") { $sql = "INSERT INTO vtiger_senotesrel SET crmid = " . $context->getId() . ", notesid = " . $focus->id; $adb->query($sql); } else { $sql = "DELETE FROM vtiger_senotesrel WHERE crmid = " . $context->getId() . " AND notesid = " . $focus->id; $adb->query($sql); } $newContext = \Workflow\VTEntity::getForId($focus->id, "Documents"); if ($this->get("workflow") !== "") { $objWorkflow = new \Workflow\Main($this->get("workflow"), false, $context->getUser()); $objWorkflow->setContext($newContext); $objWorkflow->isSubWorkflow(true); $objWorkflow->start(); } $context->setEnvironment("new_record_id", $newContext->getWsId(), $this); return "yes"; }
function VT520_queryGeneratorMigration() { $db = PearDatabase::getInstance(); $sql = "delete from vtiger_cvadvfilter where columnname IS NULL or columnname='';"; $db->pquery($sql, array()); $user = Users::getActiveAdminUser(); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvcolumnlist on vtiger_customview.cvid=vtiger_cvcolumnlist.cvid where entitytype !=" . "'Accounts' and columnname like 'vtiger_account:accountname:accountname%';"; VT520_migrateCustomview($sql, 'Accounts', $user, VT520_updateCVColumnList); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvcolumnlist on vtiger_customview.cvid=vtiger_cvcolumnlist.cvid where entitytype !=" . "'Contacts' and columnname like 'vtiger_contactdetails:lastname:lastname:%';"; VT520_migrateCustomview($sql, 'Contacts', $user, VT520_updateCVColumnList); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvcolumnlist on vtiger_customview.cvid=vtiger_cvcolumnlist.cvid where entitytype not in " . "('Products','HelpDesk','Faq') and columnname like 'vtiger_products:productname:productname%';"; VT520_migrateCustomview($sql, 'Products', $user, VT520_updateCVColumnList); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvcolumnlist on vtiger_customview.cvid=vtiger_cvcolumnlist.cvid where entitytype not in " . "('Products','HelpDesk','Faq') and columnname like 'vtiger_quotes:quoteid:quote_id%';"; VT520_migrateCustomview($sql, 'SalesOrder', $user, VT520_updateCVColumnList); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvadvfilter on vtiger_customview.cvid=vtiger_cvadvfilter.cvid where entitytype !=" . "'Accounts' and columnname like 'vtiger_account:accountname:accountname%';"; VT520_migrateCustomview($sql, 'Accounts', $user, VT520_updateADVColumnList); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvadvfilter on vtiger_customview.cvid=vtiger_cvadvfilter.cvid where entitytype !=" . "'Contacts' and columnname like 'vtiger_contactdetails:lastname:lastname:%';"; VT520_migrateCustomview($sql, 'Contacts', $user, VT520_updateADVColumnList); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvadvfilter on vtiger_customview.cvid=vtiger_cvadvfilter.cvid where entitytype not in " . "('Products','HelpDesk','Faq') and columnname like 'vtiger_products:productname:productname%';"; VT520_migrateCustomview($sql, 'Products', $user, VT520_updateADVColumnList); $sql = "select vtiger_customview.cvid,columnindex,entitytype from vtiger_customview inner join " . "vtiger_cvcolumnlist on vtiger_customview.cvid=vtiger_cvcolumnlist.cvid where entitytype not in " . "('Products','HelpDesk','Faq') and columnname like 'vtiger_quotes:quoteid:quote_id%';"; VT520_migrateCustomview($sql, 'SalesOrder', $user, VT520_updateADVColumnList); $tabId = getTabid('Contacts'); $sql = "select fieldid from vtiger_field where tabid=? and fieldname='birthday';"; $params = array($tabId); $result = $db->pquery($sql, $params); $it = new SqlResultIterator($db, $result); $fieldId = null; foreach ($it as $row) { $fieldId = $row->fieldid; } if (!empty($fieldId)) { $sql = "update vtiger_field set typeofdata = 'D~O' where fieldid=?;"; $params = array($fieldId); $result = $db->pquery($sql, $params); } else { echo ' <tr width="100%"> <td width="25%">Failure</td> <td width="5%"><font color="red"> F </font></td> <td width="70%">Failed to change typeofdata of birthday field</td> </tr>'; } $tabId = getTabid('Documents'); $sql = "select fieldid from vtiger_field where tabid=? and fieldname='filesize';"; $params = array($tabId); $result = $db->pquery($sql, $params); $it = new SqlResultIterator($db, $result); $fieldId = null; foreach ($it as $row) { $fieldId = $row->fieldid; } if (!empty($fieldId)) { $sql = "update vtiger_field set typeofdata = 'I~O' where fieldid=?;"; $params = array($fieldId); $result = $db->pquery($sql, $params); } else { echo ' <tr width="100%"> <td width="25%">Failure</td> <td width="5%"><font color="red"> F </font></td> <td width="70%">Failed to change typeofdata of filesize field</td> </tr>'; } }
function deleteInvoice($salesorder_id = 0) { # require_once('include/utils/utils.php'); require_once 'modules/Invoice/Invoice.php'; # require_once('modules/Users/Users.php'); global $adb, $log; global $current_user; if (!$current_user) { $current_user = Users::getActiveAdminUser(); } //End if $log =& LoggerManager::getLogger('RecurringInvoice'); $log->debug("invoked RecurringInvoice"); $sql = " SELECT invoiceid, salesorderid FROM `vtiger_invoice` "; $sql .= " INNER JOIN `vtiger_crmentity` ON `invoiceid` = `crmid` "; $sql .= " WHERE TRUE "; if ($salesorder_id !== 0) { $sql .= " AND `salesorderid` = {$salesorder_id} "; } $sql .= " AND `vtiger_invoice`.`division` = '{$_POST['division']}' "; $sql .= " AND `invoicedate` >= '" . $_POST[first_date] . "' "; #請求日 $sql .= " AND `invoicedate` <= '" . $_POST[end_date] . "' "; #請求日 $sql .= " AND `deleted` = 0 "; $sql .= " AND `invoicestatus` = '自動作成' "; $sql .= " AND `invoicestatus` NOT IN ('上長確認済','営業確認済') "; print $sql . "<br />"; # exit; $result = $adb->pquery($sql, array()); $no_of_invoice = $adb->num_rows($result); $focus = new Invoice(); for ($i = 0; $i < $no_of_invoice; $i++) { $invoice_id = $adb->query_result($result, $i, 'invoiceid'); $focus->trash("Invoice", $invoice_id); # print "<p>$invoice_id : 削除完了です。</p>"; } //End for }
function step1(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $record = $request->get('record'); $reportModel = Reports_Record_Model::getCleanInstance($record); if (!$reportModel->has('folderid')) { $reportModel->set('folderid', $request->get('folder')); } $data = $request->getAll(); foreach ($data as $name => $value) { $reportModel->set($name, $value); } $modulesList = $reportModel->getModulesList(); if (!empty($record)) { $viewer->assign('MODE', 'edit'); } else { $firstModuleName = reset($modulesList); if ($firstModuleName) { $reportModel->setPrimaryModule($firstModuleName); } $viewer->assign('MODE', ''); } $reportModuleModel = $reportModel->getModule(); $reportFolderModels = $reportModuleModel->getFolders(); $relatedModules = $reportModel->getReportRelatedModules(); foreach ($relatedModules as $primaryModule => $relatedModuleList) { $translatedRelatedModules = array(); foreach ($relatedModuleList as $relatedModuleName) { $translatedRelatedModules[$relatedModuleName] = vtranslate($relatedModuleName, $relatedModuleName); } $relatedModules[$primaryModule] = $translatedRelatedModules; } $currentUserModel = Users_Record_Model::getCurrentUserModel(); $viewer->assign('SCHEDULEDREPORTS', $reportModel->getScheduledReport()); $viewer->assign('MODULELIST', $modulesList); $viewer->assign('RELATED_MODULES', $relatedModules); $viewer->assign('REPORT_MODEL', $reportModel); $viewer->assign('REPORT_FOLDERS', $reportFolderModels); $viewer->assign('RECORD_ID', $record); $viewer->assign('MODULE', $moduleName); $viewer->assign('CURRENT_USER', $currentUserModel); $viewer->assign('ROLES', Settings_Roles_Record_Model::getAll()); $admin = Users::getActiveAdminUser(); $viewer->assign('ACTIVE_ADMIN', $admin); if ($request->get('isDuplicate')) { $viewer->assign('IS_DUPLICATE', true); } $viewer->view('Step1.tpl', $moduleName); }
public function handleTask(&$context) { $adb = \PearDatabase::getInstance(); /* Insert here source code to execute the task */ $format = $this->get('fileformat'); $fields = $this->get('fields'); $tmpfile = tempnam(sys_get_temp_dir(), 'CSV'); @unlink($tmpfile); $source = $this->get('source'); if ($source == -1 || $source == 'envid') { $env = $context->getEnvironment($this->get('recordlistid')); } elseif ($source == 'customview') { $search_module = $this->get("search_module"); $parts = explode("#~#", $search_module); $searchModuleName = $parts[0]; $queryGenerator = new \QueryGenerator($searchModuleName, \Users::getActiveAdminUser()); $queryGenerator->initForCustomViewById($this->get('customviewsource')); $query = $queryGenerator->getQuery(); $parts = preg_split('/FROM/i', $query); $sqlQuery = 'SELECT vtiger_crmentity.crmid as id_col FROM ' . $parts[1]; $result = $adb->query($sqlQuery, true); $this->addStat("num Rows: " . $adb->num_rows($result)); while ($row = $adb->fetchByAssoc($result)) { $recordids[] = $row["id_col"]; } $env = array('moduleName' => $searchModuleName, 'ids' => $recordids); } $moduleName = $env['moduleName']; $ids = $env['ids']; $filename = $this->get('filename', $context); switch ($format) { case 'csv': $file = fopen($tmpfile, 'w'); $headline = $this->get('insertheadline'); if ($headline == '1') { $headline = array(); foreach ($fields as $field) { $headline[] = $field['label']; } fputcsv($file, $headline, ';'); } foreach ($ids as $id) { $record = \Workflow\VTEntity::getForId($id, $moduleName); $tmp = array(); foreach ($fields as $field) { $tmp[] = \Workflow\VTTemplate::parse($field['field'], $record); } fputcsv($file, $tmp, ';'); } fclose($file); break; case 'excel': require_once $this->getAdditionalPath('phpexcel') . 'PHPExcel.php'; // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set document properties $objPHPExcel->getProperties()->setCreator("Workflow Designer")->setLastModifiedBy("Workflow Designer")->setTitle("Workflow Designer Export")->setSubject("Workflow Designer Export"); $headline = $this->get('insertheadline'); $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $currentROW = 1; if ($headline == '1') { $headline = array(); foreach ($fields as $field) { $headline[] = $field['label']; } $objPHPExcel->setActiveSheetIndex(0)->fromArray(array($headline), NULL, 'A1'); $currentROW++; } foreach ($ids as $id) { $record = \Workflow\VTEntity::getForId($id, $moduleName); $tmp = array(); foreach ($fields as $field) { $tmp[] = \Workflow\VTTemplate::parse($field['value'], $record); } $objPHPExcel->getActiveSheet()->fromArray($tmp, '', 'A' . $currentROW); $currentROW++; } $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save($tmpfile); break; } \Workflow\FileAction::doActions($this->get('resultaction'), $tmpfile, $filename, $context, $context->getId(), $this->getWorkflow()); @unlink($tmpfile); return "yes"; }
/** * @param $context \Workflow\VTEntity * @return string */ public function handleTask(&$context) { global $adb; if ($this->get("search_module") == -1) { return "no"; } $found_rows = $this->get("found_rows"); if (empty($found_rows) || $found_rows == -1) { $found_rows = 1; } $recordsource = $this->get('recordsource'); if (empty($recordsource) || $recordsource == -1) { $recordsource = 'condition'; } $parts = explode("#~#", $this->get("search_module")); $functionName = $parts[0]; $related_module = VtUtils::getModuleName($parts[1]); $recordids = array(); if ($recordsource == 'condition') { require_once 'modules/Workflow2/VTConditionMySql.php'; $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); $sqlCondition = $objMySQL->parse($this->get("condition")); $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); $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"); $sqlQuery .= ' GROUP BY crmid '; if (!empty($sortField) && $sortField != -1) { $sortDirection = $this->get("sortDirection"); $sortField = VtUtils::getColumnName($sortField); $sqlQuery .= " ORDER BY " . $sortField . " " . $sortDirection; } $numRows = $this->get("found_rows"); if (!empty($numRows) && $numRows != -1) { $sqlQuery .= " LIMIT " . $found_rows; } $this->addStat("MySQL Query: " . $sqlQuery); $result = $adb->query($sqlQuery, true); $this->addStat("num Rows: " . $adb->num_rows($result)); while ($row = $adb->fetchByAssoc($result)) { $recordids[] = $row["idcol"]; } } if ($recordsource == 'customview') { $queryGenerator = new \QueryGenerator($related_module, \Users::getActiveAdminUser()); $queryGenerator->initForCustomViewById($this->get('customviewsource')); $query = $queryGenerator->getQuery(); $parts = preg_split('/FROM/i', $query); $sqlQuery = 'SELECT vtiger_crmentity.crmid as id_col FROM ' . $parts[1]; $result = $adb->query($sqlQuery, true); $this->addStat("num Rows: " . $adb->num_rows($result)); while ($row = $adb->fetchByAssoc($result)) { $recordids[] = $row["id_col"]; } } $filterbyproduct = $this->get('filterbyproduct'); if ($filterbyproduct === 'yes') { $products = $this->get('products'); if (!empty($products)) { $sql = 'SELECT id FROM vtiger_inventoryproductrel WHERE id IN (' . generateQuestionMarks($recordids) . ') AND productid = ? GROUP BY id'; $recordids[] = $products; $result = $adb->pquery($sql, $recordids); $recordids = array(); while ($row = $adb->fetchByAssoc($result)) { $recordids[] = $row['id']; } } } $workflow_id = $this->get("workflow_id"); if (!empty($workflow_id)) { foreach ($recordids as $recordId) { $tmpContext = \Workflow\VTEntity::getForId($recordId, $related_module); $tmpContext->clearEnvironment(); $tmpContext->loadEnvironment($context->getEnvironment()); $obj = new \Workflow\Main($workflow_id, false, $context->getUser()); $obj->setExecutionTrigger($this->getWorkflow()->getExecutionTrigger()); $obj->setContext($tmpContext); $obj->isSubWorkflow(true); $obj->start(); if ($obj->getSuccessRedirection() != false) { $this->getWorkflow()->setSuccessRedirection($obj->getSuccessRedirection()); $this->getWorkflow()->setSuccessRedirectionTarget($obj->getSuccessRedirectionTarget()); } $env = $this->get("env"); if ($env !== -1 && !empty($env["result_environments"])) { $oldEnv = $context->getEnvironment($env["result_environments"]); $oldEnv[] = $tmpContext->getEnvironment(); $context->setEnvironment("result_environments", $oldEnv, $this); } } } return "yes"; }
/** function used to get the Quotes/Invoice pdf * @param int $id - id -id * return string $output - pd link value */ function get_pdf($id, $block, $customerid, $sessionid) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); global $currentModule, $mod_strings, $app_strings, $app_list_strings; $log->debug("Entering customer portal function get_pdf"); $isPermitted = check_permission($customerid, $block, $id); if ($isPermitted == false) { return array("#NOT AUTHORIZED#"); } if (!validateSession($customerid, $sessionid)) { return null; } require_once "config/config.php"; $current_user = Users::getActiveAdminUser(); $currentModule = $block; $current_language = vglobal('current_language'); $app_strings = return_application_language($current_language); $app_list_strings = return_app_list_strings_language($current_language); $mod_strings = return_module_language($current_language, $currentModule); $_REQUEST['record'] = $id; $_REQUEST['savemode'] = 'file'; $sequenceNo = getModuleSequenceNumber($block, $id); $filenamewithpath = 'storage/Products/' . $id . '_' . $block . '_' . $sequenceNo . '.pdf'; if (file_exists($filenamewithpath) && filesize($filenamewithpath) != 0) { unlink($filenamewithpath); } checkFileAccessForInclusion("modules/{$block}/CreatePDF.php"); include "modules/{$block}/CreatePDF.php"; if (file_exists($filenamewithpath) && filesize($filenamewithpath) != 0) { //we have to pass the file content $filecontents[] = base64_encode(file_get_contents($filenamewithpath)); unlink($filenamewithpath); // TODO: Delete the file to avoid public access. } else { $filecontents = "failure"; } $log->debug("Exiting customer portal function get_pdf"); return $filecontents; }
public static function getAdminUser() { return Users::getActiveAdminUser(); }
/** * Create new Email record (and link to given record) including attachements */ function __CreateNewEmail($mailrecord, $module, $linkfocus) { global $current_user, $adb; if (!$current_user) { $current_user = Users::getActiveAdminUser(); } $focus = new Emails(); $focus->column_fields['parent_type'] = $module; $focus->column_fields['activitytype'] = 'Emails'; $focus->column_fields['parent_id'] = "{$linkfocus->id}@-1|"; $focus->column_fields['subject'] = $mailrecord->_subject; $focus->column_fields['description'] = $mailrecord->getBodyHTML(); $focus->column_fields['assigned_user_id'] = $linkfocus->column_fields['assigned_user_id']; $focus->column_fields["date_start"] = date('Y-m-d', $mailrecord->_date); $focus->column_fields["email_flag"] = 'MAILSCANNER'; $from = $mailrecord->_from[0]; $to = $mailrecord->_to[0]; $cc = !empty($mailrecord->_cc) ? implode(',', $mailrecord->_cc) : ''; $bcc = !empty($mailrecord->_bcc) ? implode(',', $mailrecord->_bcc) : ''; $flag = ''; // 'SENT'/'SAVED' //emails field were restructured and to,bcc and cc field are JSON arrays $focus->column_fields['from_email'] = $from; $focus->column_fields['saved_toid'] = $to; $focus->column_fields['ccmail'] = $cc; $focus->column_fields['bccmail'] = $bcc; $focus->save('Emails'); $emailid = $focus->id; $this->log("Created [{$focus->id}]: {$mailrecord->_subject} linked it to " . $linkfocus->id); // TODO: Handle attachments of the mail (inline/file) $this->__SaveAttachements($mailrecord, 'Emails', $focus); return $emailid; }
public function handle($data) { $iuehdakvoje = "ipParts"; ${"GLOBALS"}["unilynnueob"] = "environment"; $ycodjgp = "redirect"; ${"GLOBALS"}["lpnulgd"] = "response"; ${"GLOBALS"}["mvxrxro"] = "ipParts"; $wghwmdry = "ip"; $lwrykskv = "ipParts"; $ryudrroeulb = "adb"; ${"GLOBALS"}["xlirlgfme"] = "ipParts"; ${"GLOBALS"}["atmyvwso"] = "ipParts"; ${"GLOBALS"}["hirbqakfku"] = "ipParts"; ${"GLOBALS"}["hrwkpguwax"] = "ipParts"; $zelgofezen = "executionMode"; $ibhtcitid = "executionMode"; ${$ryudrroeulb} = PearDatabase::getInstance(); ${${"GLOBALS"}["rmrewmoru"]} = $_SERVER["REMOTE_ADDR"]; ${${"GLOBALS"}["xlirlgfme"]} = explode(".", ${$wghwmdry}); ${${"GLOBALS"}["ytoiwy"]} = "SELECT * FROM vtiger_wf_http_limits_ips WHERE `ip` LIKE '" . ${${"GLOBALS"}["otplryj"]}[0] . ".%' OR `ip` LIKE '" . ${${"GLOBALS"}["atmyvwso"]}[0] . "." . ${${"GLOBALS"}["otplryj"]}[1] . ".%' OR `ip` LIKE '" . ${${"GLOBALS"}["hrwkpguwax"]}[0] . "." . ${${"GLOBALS"}["hirbqakfku"]}[1] . "." . ${$iuehdakvoje}[2] . ".%' OR `ip` LIKE '" . ${${"GLOBALS"}["otplryj"]}[0] . "." . ${${"GLOBALS"}["mvxrxro"]}[1] . "." . ${${"GLOBALS"}["otplryj"]}[2] . "." . ${$lwrykskv}[3] . "%'"; ${${"GLOBALS"}["zlijsv"]} = $adb->query(${${"GLOBALS"}["ytoiwy"]}); if ($adb->num_rows(${${"GLOBALS"}["zlijsv"]}) == 0) { $mnyrtecg = "ip"; die("ACCESS_DENIED for " . ${$mnyrtecg}); } else { $ywpnubj = "accessCheckResult"; $psnscwubwfj = "row"; while (${$psnscwubwfj} = $adb->fetchByAssoc(${$ywpnubj})) { $ntiiyfpbov = "ip"; $fsgwwvvoi = "row"; if (${${"GLOBALS"}["bjowfug"]}["ip"] == ${$ntiiyfpbov}) { $iiriyjh = "row"; $this->_addPermissionLimitID(${$iiriyjh}["limit_id"]); } elseif (preg_match("/\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b/", ${$fsgwwvvoi}["ip"])) { continue; } elseif (\Workflow\IPCheck::ip_in_range(${${"GLOBALS"}["rmrewmoru"]}, ${${"GLOBALS"}["bjowfug"]}["ip"])) { $this->_addPermissionLimitID(${${"GLOBALS"}["bjowfug"]}["limit_id"]); } } } if (count($this->_access) == 0) { $tbzoxrju = "ip"; die("ACCESS_DENIED for " . ${$tbzoxrju}); } ${${"GLOBALS"}["huhdmgofik"]} = intval($_REQUEST["record_id"]); $zvfkgvoegv = "record_id"; ${$ibhtcitid} = "none"; ${"GLOBALS"}["kybozx"] = "key"; if (!empty(${$zvfkgvoegv})) { ${"GLOBALS"}["hrlijwlhcn"] = "context"; ${${"GLOBALS"}["hrlijwlhcn"]} = \Workflow\VTEntity::getForId(${${"GLOBALS"}["huhdmgofik"]}); } else { $xvhpmjj = "context"; ${$xvhpmjj} = \Workflow\VTEntity::getDummy(); } if (!empty($_REQUEST["workflow_trigger"])) { ${"GLOBALS"}["xctyelrs"] = "moduleName"; ${"GLOBALS"}["yqkcoxdf"] = "result"; ${${"GLOBALS"}["gfryhuwwv"]} = $_REQUEST["workflow_trigger"]; ${${"GLOBALS"}["xctyelrs"]} = $_REQUEST["module"]; ${${"GLOBALS"}["ktxrdqs"]} = getTabid(${${"GLOBALS"}["ftxydrclssf"]}); if (empty(${${"GLOBALS"}["ktxrdqs"]})) { die("MODULE_NOT_FOUND"); } $nbjyypn = "trigger"; ${"GLOBALS"}["kguaplly"] = "sql"; ${"GLOBALS"}["kigvfsullx"] = "sql"; ${${"GLOBALS"}["kguaplly"]} = "SELECT id, `key` FROM vtiger_wf_trigger WHERE `key` = ? AND deleted = 0 AND custom = 1"; ${"GLOBALS"}["osommxjcsyi"] = "result"; ${${"GLOBALS"}["osommxjcsyi"]} = $adb->pquery(${${"GLOBALS"}["kigvfsullx"]}, array(${${"GLOBALS"}["gfryhuwwv"]})); if ($adb->num_rows(${${"GLOBALS"}["yqkcoxdf"]}) == 0) { die("TRIGGER_NOT_FOUND"); } else { $lburvvv = "trigger"; ${"GLOBALS"}["yicgxdyyt"] = "executionMode"; ${"GLOBALS"}["qkwltubetoqt"] = "result"; ${${"GLOBALS"}["yicgxdyyt"]} = "trigger"; ${$lburvvv} = $adb->query_result(${${"GLOBALS"}["qkwltubetoqt"]}, 0, "key"); } if (!in_array(${$nbjyypn}, $this->_access["trigger"])) { ${"GLOBALS"}["trjabrrpbx"] = "ip"; die("ACCESS_DENIED for " . ${${"GLOBALS"}["trjabrrpbx"]}); } } if (!empty($_REQUEST["workflow_id"])) { $xmhjbyf = "result"; ${"GLOBALS"}["olldewfcyyph"] = "workflow_id"; ${"GLOBALS"}["xbvnzv"] = "record_id"; ${"GLOBALS"}["ajdhuvevtz"] = "sql"; ${${"GLOBALS"}["uauipqs"]} = intval($_REQUEST["workflow_id"]); ${${"GLOBALS"}["ajdhuvevtz"]} = "SELECT id, title FROM vtiger_wf_settings WHERE id = ? AND active = 1"; $ymdspopx = "values"; ${${"GLOBALS"}["qfzfncwih"]} = array(${${"GLOBALS"}["olldewfcyyph"]}); if (!empty(${${"GLOBALS"}["xbvnzv"]})) { ${"GLOBALS"}["dvocdfmhiudc"] = "values"; ${${"GLOBALS"}["ytoiwy"]} .= " AND module_name = ?"; ${${"GLOBALS"}["dvocdfmhiudc"]}[] = $context->getModuleName(); } ${${"GLOBALS"}["ylgtydnyihg"]} = $adb->pquery(${${"GLOBALS"}["ytoiwy"]}, ${$ymdspopx}, true); if ($adb->num_rows(${$xmhjbyf}) == 0) { die("WORKFLOW_NOT_FOUND"); } else { ${"GLOBALS"}["eqjbaqoa"] = "workflow_id"; ${${"GLOBALS"}["gfuwwgd"]} = "id"; ${${"GLOBALS"}["eqjbaqoa"]} = $adb->query_result(${${"GLOBALS"}["ylgtydnyihg"]}, 0, "id"); } if (!in_array(${${"GLOBALS"}["uauipqs"]}, $this->_access["id"])) { ${"GLOBALS"}["xettocrqrd"] = "ip"; die("ACCESS_DENIED for " . ${${"GLOBALS"}["xettocrqrd"]}); } } if (${$zelgofezen} == "none") { die("You must specify workflow_trigger or workflow_id"); } $uzssajc = "user"; unset($_REQUEST["id"]); unset($_REQUEST["record_id"]); unset($_REQUEST["workflow_trigger"]); ${"GLOBALS"}["emwrrxerow"] = "environment"; unset($_REQUEST["workflow_id"]); unset($_REQUEST["module"]); ${${"GLOBALS"}["unilynnueob"]} = array(); foreach ($_REQUEST as ${${"GLOBALS"}["kybozx"]} => ${${"GLOBALS"}["dqqzxcrvdif"]}) { ${"GLOBALS"}["bqlddraey"] = "environment"; ${${"GLOBALS"}["bqlddraey"]}[${${"GLOBALS"}["trlypsbsmpu"]}] = $this->strip_tags_deep(${${"GLOBALS"}["dqqzxcrvdif"]}); } $context->loadEnvironment(${${"GLOBALS"}["emwrrxerow"]}); if (!empty($_FILES)) { ${"GLOBALS"}["akrrrvsfekjk"] = "filekey"; foreach ($_FILES as ${${"GLOBALS"}["akrrrvsfekjk"]} => ${${"GLOBALS"}["jsgnxbqw"]}) { ${"GLOBALS"}["srxobtcs"] = "file"; $prnnmlzg = "file"; $context->addTempFile(${$prnnmlzg}["tmp_name"], ${${"GLOBALS"}["behmwxmdhewk"]}, ${${"GLOBALS"}["srxobtcs"]}["name"]); } } ${${"GLOBALS"}["inzmevwvq"]} = Users::getActiveAdminUser(); \Workflow\VTEntity::setUser(${$uzssajc}); ob_start(); if (${${"GLOBALS"}["gfuwwgd"]} == "id") { ${"GLOBALS"}["xbhpjnuesvy"] = "workflow_id"; ${"GLOBALS"}["xdizreur"] = "context"; ${${"GLOBALS"}["uxfgwct"]} = new \Workflow\Main(${${"GLOBALS"}["xbhpjnuesvy"]}, false, ${${"GLOBALS"}["inzmevwvq"]}); $objWorkflow->setContext(${${"GLOBALS"}["xdizreur"]}); $objWorkflow->start(); $rugpwzh = "redirect"; ${$rugpwzh} = $objWorkflow->getSuccessRedirection(); } if (${${"GLOBALS"}["gfuwwgd"]} == "trigger") { ${"GLOBALS"}["buepdhri"] = "wfManager"; $dkllbyi = "trigger"; $vmbyvjusnw = "moduleName"; $elubssx = "workflows"; ${${"GLOBALS"}["buepdhri"]} = new \Workflow\Manager(); ${"GLOBALS"}["ztxpyfldus"] = "workflows"; ${${"GLOBALS"}["dfkeynth"]} = $wfManager->GetWorkflows(${$vmbyvjusnw}, ${$dkllbyi}); if (is_array(${$elubssx}) && count(${${"GLOBALS"}["ztxpyfldus"]}) > 0) { ${"GLOBALS"}["fdpphxg"] = "workflows"; $jdseehx = "wf"; foreach (${${"GLOBALS"}["fdpphxg"]} as ${$jdseehx}) { $hviqvlaxyaqh = "tmpRedirect"; ${"GLOBALS"}["mgliozkdag"] = "context"; if (!$context->isAvailable()) { break; } $wf->setContext(${${"GLOBALS"}["mgliozkdag"]}); $wf->start(); ${${"GLOBALS"}["ajehahie"]} = $wf->getSuccessRedirection(); if (!empty(${$hviqvlaxyaqh})) { ${"GLOBALS"}["baxyrwouy"] = "redirect"; ${${"GLOBALS"}["baxyrwouy"]} = ${${"GLOBALS"}["ajehahie"]}; } } } } ${${"GLOBALS"}["yeqmruvbnw"]} = ob_get_clean(); echo json_encode(array("result" => "ok", "response" => ${${"GLOBALS"}["lpnulgd"]}, "redirect" => ${$ycodjgp})); }
public function getReports4YouOwnerUser($user_id = "") { global $current_user; if ($user_id != "") { $user = new Users(); $user->retrieveCurrentUserInfoFromFile($user_id); } else { $user = Users::getActiveAdminUser(); } $current_user = $user; return $user; }