Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 public function process(Vtiger_Request $request)
 {
     PDFMaker_Debugger_Model::GetInstance()->Init();
     $adb = PearDatabase::getInstance();
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     $viewer = $this->getViewer($request);
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     list($oLabels, $languages) = $PDFMaker->GetCustomLabels();
     $currLang = array();
     foreach ($languages as $langId => $langVal) {
         if ($langVal["prefix"] == $currentLanguage) {
             $currLang["id"] = $langId;
             $currLang["name"] = $langVal["name"];
             $currLang["label"] = $langVal["label"];
             $currLang["prefix"] = $langVal["prefix"];
             break;
         }
     }
     $viewLabels = array();
     foreach ($oLabels as $lblId => $oLabel) {
         $viewLabels[$lblId]["key"] = $oLabel->GetKey();
         $viewLabels[$lblId]["lang_values"] = $oLabel->GetLangValsArr();
     }
     $viewer->assign("LABELS", $viewLabels);
     $viewer->assign("LANGUAGES", $languages);
     $viewer->assign("CURR_LANG", $currLang);
     $viewer->view('CustomLabels.tpl', 'PDFMaker');
 }
Esempio n. 3
0
 public static function vtranslateMenu($key, $module)
 {
     $language = Vtiger_Language_Handler::getLanguage();
     $moduleStrings = Vtiger_Language_Handler::getModuleStringsFromFile($language, 'Menu');
     if (array_key_exists($key, $moduleStrings['languageStrings'])) {
         return stripslashes($moduleStrings['languageStrings'][$key]);
     }
     return vtranslate($key, $module);
 }
Esempio n. 4
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["pcjpcgy"] = "current_user";
     global $root_directory;
     ${"GLOBALS"}["qnnpnmctvkh"] = "adb";
     ${"GLOBALS"}["sbwrerrdfpiq"] = "viewer";
     ${${"GLOBALS"}["pcjpcgy"]} = ${${"GLOBALS"}["enwvewqev"]} = Users_Record_Model::getCurrentUserModel();
     ${${"GLOBALS"}["myvnqjtagyw"]} = Vtiger_Language_Handler::getLanguage();
     ${${"GLOBALS"}["qnnpnmctvkh"]} = PearDatabase::getInstance();
     ${${"GLOBALS"}["sbwrerrdfpiq"]} = $this->getViewer(${${"GLOBALS"}["klrvtdauww"]});
     $viewer->assign("lastUrl", $_SESSION["_url_before_import"]);
     $viewer->view("ImporterStep3.tpl", "Workflow2");
 }
Esempio n. 5
0
 public function process(Vtiger_Request $request)
 {
     PDFMaker_Debugger_Model::GetInstance()->Init();
     $adb = PearDatabase::getInstance();
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     $viewer = $this->getViewer($request);
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     $sql = "SELECT * FROM vtiger_pdfmaker_productbloc_tpl";
     $result = $adb->pquery($sql, array());
     while ($row = $adb->fetchByAssoc($result)) {
         $templates[$row["id"]]["name"] = $row["name"];
         $templates[$row["id"]]["body"] = html_entity_decode($row["body"], ENT_QUOTES);
     }
     $viewer->assign("PB_TEMPLATES", $templates);
     $viewer->view('ProductBlocks.tpl', 'PDFMaker');
 }
 public function process(Vtiger_Request $request)
 {
     $current_user = $cu_model = Users_Record_Model::getCurrentUserModel();
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     $adb = PearDatabase::getInstance();
     $viewer = $this->getViewer($request);
     $module = $request->get('source_module');
     $crmid = (int) $request->get('record');
     $tabid = getTabid($module);
     $sidebar_id = intval($_REQUEST["sID"]);
     $sql = "SELECT content FROM vtiger_tools_sidebar WHERE id = " . intval($sidebar_id) . " AND tabid = " . $tabid;
     $result = $adb->query($sql);
     $sidebar = $adb->fetchByAssoc($result);
     \SwVtTools\VTEntity::setUser($current_user);
     $context = \SwVtTools\VTEntity::getForId($crmid, $_POST["return_module"]);
     $content = \SwVtTools\VTTemplate::parse(html_entity_decode($sidebar["content"], ENT_QUOTES, 'UTF-8'), $context);
     echo $content;
 }
Esempio n. 7
0
 public function process(Vtiger_Request $request)
 {
     $erkmdzn = "current_user";
     ${"GLOBALS"}["mikcukceq"] = "currentLanguage";
     $hiiwti = "cu_model";
     ${"GLOBALS"}["uamgnjdvbvfm"] = "viewer";
     ${$erkmdzn} = ${$hiiwti} = Users_Record_Model::getCurrentUserModel();
     ${${"GLOBALS"}["mikcukceq"]} = Vtiger_Language_Handler::getLanguage();
     ${${"GLOBALS"}["ussanpzh"]} = PearDatabase::getInstance();
     ${${"GLOBALS"}["uamgnjdvbvfm"]} = $this->getViewer(${${"GLOBALS"}["egducrxosoh"]});
     $jvnhnmr = "workflows";
     ${${"GLOBALS"}["qtdwase"]} = $request->get("source_module");
     ${${"GLOBALS"}["lmznaofkdcm"]} = new Workflow2();
     ${$jvnhnmr} = $objWorkflow->getWorkflowsForModule(${${"GLOBALS"}["qtdwase"]}, 1, "WF2_IMPORTER");
     $_SESSION["_url_before_import"] = $request->get("currentUrl");
     $viewer->assign("workflows", ${${"GLOBALS"}["gbtyficqodq"]});
     $viewer->view("ImporterStep1.tpl", "Workflow2");
 }
Esempio n. 8
0
 function editCustomLabel(Vtiger_Request $request)
 {
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     $viewer = $this->getViewer($request);
     $slabelid = $request->get('labelid');
     $slangid = $request->get('langid');
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     $moduleName = $request->getModule();
     $viewer->assign('MODULE', $moduleName);
     list($oLabels, $languages) = $PDFMaker->GetCustomLabels();
     $currLang = array();
     foreach ($languages as $langId => $langVal) {
         if ($langId == $slangid && $slangid != "" || $slangid == "" && $langVal["prefix"] == $currentLanguage) {
             $currLang["id"] = $langId;
             $currLang["name"] = $langVal["name"];
             $currLang["label"] = $langVal["label"];
             $currLang["prefix"] = $langVal["prefix"];
             break;
         }
     }
     if ($slangid == "") {
         $slangid = $currLang["id"];
     }
     $viewer->assign('LABELID', $slabelid);
     $viewer->assign('LANGID', $slangid);
     $viewLabels = array();
     foreach ($oLabels as $lblId => $oLabel) {
         if ($slabelid == $lblId) {
             $l_key = substr($oLabel->GetKey(), 2);
             $l_values = $oLabel->GetLangValsArr();
             //echo "id=".$currLang["id"];
             $viewer->assign("CUSTOM_LABEL_KEY", $l_key);
             $viewer->assign("CUSTOM_LABEL_VALUE", $l_values[$currLang["id"]]);
             break;
         }
     }
     $viewer->assign("CURR_LANG", $currLang);
     echo $viewer->view('EditCustomLabel.tpl', 'PDFMaker', true);
 }
Esempio n. 9
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["dpplygv"] = "module";
     $gdtleqjpkdsh = "crmid";
     ${"GLOBALS"}["auyafnnce"] = "waitingRST";
     $haauhnidlo = "sql";
     $ltqivoyu = "adb";
     $tislpkpngsol = "request";
     $itkrgfcibt = "waiting";
     $brgjuxus = "crmid";
     $ihjgddsfo = "cu_model";
     ${${"GLOBALS"}["pxuwujbkkm"]} = ${$ihjgddsfo} = Users_Record_Model::getCurrentUserModel();
     ${"GLOBALS"}["yemuhpxpdnq"] = "viewer";
     ${${"GLOBALS"}["kaqzwjtnc"]} = Vtiger_Language_Handler::getLanguage();
     ${$ltqivoyu} = PearDatabase::getInstance();
     ${${"GLOBALS"}["yemuhpxpdnq"]} = $this->getViewer(${$tislpkpngsol});
     ${${"GLOBALS"}["dpplygv"]} = $request->get("source_module");
     ${${"GLOBALS"}["nfzomvg"]} = (int) $request->get("crmid");
     $lpkmsdfy = "row";
     ${$haauhnidlo} = "SELECT\n                    *\n                FROM\n                    vtiger_wf_entityddata\n                WHERE\n                    vtiger_wf_entityddata.crmid = " . ${$gdtleqjpkdsh} . "";
     $jvcckdhwm = "waitingRST";
     ${${"GLOBALS"}["auyafnnce"]} = $adb->query(${${"GLOBALS"}["csoiribry"]}, true);
     ${$itkrgfcibt} = array();
     while (${$lpkmsdfy} = $adb->fetchByAssoc(${$jvcckdhwm})) {
         $qhlgfswqh = "row";
         $nhzoipi = "row";
         $kgtwmjpd = "row";
         ${"GLOBALS"}["zxbipozhknd"] = "row";
         ${$nhzoipi}["modified"] = DateTimeField::convertToUserFormat(${${"GLOBALS"}["zxbipozhknd"]}["modified"]);
         ${${"GLOBALS"}["llcomooxgjot"]}["value"] = @unserialize(html_entity_decode(${$qhlgfswqh}["value"]));
         ${${"GLOBALS"}["jyvlypyp"]}[] = ${$kgtwmjpd};
     }
     $viewer->assign("crmid", ${$brgjuxus});
     $viewer->assign("entityData", ${${"GLOBALS"}["jyvlypyp"]});
     $viewer->view("EntityData.tpl", "Workflow2");
 }
Esempio n. 10
0
 public function process(Vtiger_Request $request)
 {
     //Debugger::GetInstance()->Init();
     $AvailableRelModules = array("Accounts", "Contacts", "Leads", "Vendors");
     $current_user = $cu_model = Users_Record_Model::getCurrentUserModel();
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     $adb = PearDatabase::getInstance();
     $viewer = $this->getViewer($request);
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     if ($PDFMaker->CheckPermissions("DETAIL") == false) {
         $output = '<table border=0 cellspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
           <tr>
             <td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;text-align:center;">
               <strong>' . vtranslate("LBL_PERMISSION") . '</strong>
             </td>
           </tr>              		
           </table>';
         die($output);
     }
     $record = $request->get('record');
     $module = getSalesEntityType($record);
     $viewer->assign('MODULE', $module);
     $viewer->assign('ID', $record);
     $relfocus = CRMEntity::getInstance($module);
     $relfocus->id = $record;
     $relfocus->retrieve_entity_info($relfocus->id, $module);
     $relmodule = "";
     $relmodule_selid = "";
     if (in_array($module, $AvailableRelModules)) {
         $relmodule = $module;
         $relmodule_selid = $relfocus->id;
     } else {
         if (isset($relfocus->column_fields['account_id']) && $relfocus->column_fields['account_id'] != "" && $relfocus->column_fields['account_id'] != "0") {
             $relmodule = 'Accounts';
             $relmodule_selid = $relfocus->column_fields['account_id'];
         }
         if ($relmodule == "" && isset($relfocus->column_fields['related_to']) && $relfocus->column_fields['related_to'] != "" && $relfocus->column_fields['related_to'] != "0") {
             $relmodule_selid = $relfocus->column_fields['related_to'];
             $relmodule = getSalesEntityType($relmodule_selid);
             if (!in_array($relmodule, $AvailableRelModules)) {
                 $relmodule = $relmodule_selid = "";
             }
         }
         if ($relmodule == "" && isset($relfocus->column_fields['parent_id']) && $relfocus->column_fields['parent_id'] != "" && $relfocus->column_fields['parent_id'] != "0") {
             $relmodule_selid = $relfocus->column_fields['parent_id'];
             $relmodule = getSalesEntityType($relmodule_selid);
             if (!in_array($relmodule, $AvailableRelModules)) {
                 $relmodule = $relmodule_selid = "";
             }
         }
         if ($relmodule == "" && isset($relfocus->column_fields['contact_id']) && $relfocus->column_fields['contact_id'] != "" && $relfocus->column_fields['contact_id'] != "0") {
             $relmodule = 'Contacts';
             $relmodule_selid = $relfocus->column_fields['contact_id'];
         }
     }
     $viewer->assign('RELMODULE', $relmodule);
     $viewer->assign('RELMODULE_SELID', $relmodule_selid);
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     if (is_dir("modules/PDFMaker/resources/mpdf") && $PDFMaker->CheckPermissions("DETAIL")) {
         $viewer->assign("ENABLE_PDFMAKER", 'true');
     } else {
         $viewer->assign("ENABLE_PDFMAKER", "false");
     }
     if (is_dir("modules/EMAILMaker") && vtlib_isModuleActive('EMAILMaker')) {
         $module_tabid = getTabId($module);
         $res = $adb->pquery("SELECT * FROM vtiger_links WHERE tabid = ? AND linktype = ? AND linkurl LIKE ?", array($module_tabid, 'DETAILVIEWSIDEBARWIDGET', 'module=EMAILMaker&view=GetEMAILActions&record=%'));
         if ($adb->num_rows($res) > 0) {
             $viewer->assign("ENABLE_EMAILMAKER", 'true');
         }
     }
     $viewer->assign('PDFMAKER_MOD', return_module_language($currentLanguage, "PDFMaker"));
     if (!isset($_SESSION["template_languages"]) || $_SESSION["template_languages"] == "") {
         $temp_res = $adb->pquery("SELECT label, prefix FROM vtiger_language WHERE active = ?", array('1'));
         while ($temp_row = $adb->fetchByAssoc($temp_res)) {
             $template_languages[$temp_row["prefix"]] = $temp_row["label"];
         }
         $_SESSION["template_languages"] = $template_languages;
     }
     $viewer->assign('TEMPLATE_LANGUAGES', $_SESSION["template_languages"]);
     $viewer->assign('CURRENT_LANGUAGE', $currentLanguage);
     $viewer->assign('IS_ADMIN', is_admin($current_user));
     $templates = $PDFMaker->GetAvailableTemplates($module);
     if (count($templates) > 0) {
         $no_templates_exist = 0;
     } else {
         $no_templates_exist = 1;
     }
     $viewer->assign('CRM_TEMPLATES', $templates);
     $viewer->assign('CRM_TEMPLATES_EXIST', $no_templates_exist);
     //Action permission handling
     //edit and export
     $editAndExportAction = "1";
     if (isPermitted($module, "EditView", $record) == "no") {
         $editAndExportAction = "0";
     }
     //save as doc
     $saveDocAction = "1";
     if (isPermitted("Documents", "EditView") == "no") {
         $saveDocAction = "0";
     }
     //send email with pdf
     $sendEmailPDF = "1";
     if (isPermitted("Emails", "") == "no" && isPermitted("MailManager", "") == "no") {
         $sendEmailPDF = "0";
     }
     if (is_dir("modules/EMAILMaker") && vtlib_isModuleActive('EMAILMaker')) {
         if (isPermitted("EMAILMaker", "") == "no" && ($sendEmailPDF = "0")) {
             $sendEmailPDF = "0";
         } else {
             $sendEmailPDF = "1";
         }
     }
     $viewer->assign("EDIT_AND_EXPORT_ACTION", $editAndExportAction);
     $viewer->assign("SAVE_AS_DOC_ACTION", $saveDocAction);
     $viewer->assign("SEND_EMAIL_PDF_ACTION", $sendEmailPDF);
     $viewer->view("GetPDFActions.tpl", 'PDFMaker');
 }
Esempio n. 11
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["usmazo"] = "current_user";
     $cjplrqzb = "totalRows";
     $jmbuwsghix = "cu_model";
     global $root_directory;
     ${"GLOBALS"}["qcmpftauwm"] = "importParams";
     ${"GLOBALS"}["hzueven"] = "adb";
     ${${"GLOBALS"}["usmazo"]} = ${$jmbuwsghix} = Users_Record_Model::getCurrentUserModel();
     $pgtydkw = "importParams";
     ${${"GLOBALS"}["kxrlrmwghyk"]} = Vtiger_Language_Handler::getLanguage();
     ${${"GLOBALS"}["hzueven"]} = PearDatabase::getInstance();
     ${${"GLOBALS"}["xmnlixmhgl"]} = $this->getViewer(${${"GLOBALS"}["cugpxamyy"]});
     ${"GLOBALS"}["xlydlqxgmjov"] = "totalRows";
     ${${"GLOBALS"}["qshjglpj"]} = $request->get("source_module");
     $iqkuworgzsm = "rows";
     if (!empty($_POST["import_hash"])) {
         ${${"GLOBALS"}["wqmcrmilron"]} = new \Workflow\Importer($_POST["import_hash"]);
         $objImport->set("importParams", $_POST["param"]);
         $objImport->refreshTotalRows();
     } else {
         ${"GLOBALS"}["eybdyrrj"] = "objImport";
         ${"GLOBALS"}["ukbdrwhq"] = "root_directory";
         $lmuhxxydqv = "filePath";
         if (is_writable(${${"GLOBALS"}["ukbdrwhq"]} . "/test/")) {
             $dsdunearsbnp = "root_directory";
             $mjipikut = "root_directory";
             @mkdir(${$dsdunearsbnp} . "/test/Workflow2/", 0777, true);
             ${${"GLOBALS"}["vgacyh"]} = tempnam(${$mjipikut} . "/test/Workflow2/", "Importer");
             if (is_uploaded_file($_FILES["importfile"]["tmp_name"])) {
                 ${"GLOBALS"}["ohpsptnqk"] = "filePath";
                 move_uploaded_file($_FILES["importfile"]["tmp_name"], ${${"GLOBALS"}["ohpsptnqk"]});
             } else {
                 echo "ERROR: During Upload of File";
                 return;
             }
         } else {
             echo "ERROR: test directory not writable";
             return;
         }
         if (isset($_POST["importParam"])) {
             ${${"GLOBALS"}["zijjmocr"]} = $_POST["importParam"];
         } else {
             ${${"GLOBALS"}["zijjmocr"]} = array();
         }
         ${${"GLOBALS"}["eybdyrrj"]} = \Workflow\Importer::create(${$lmuhxxydqv}, $_POST["import_format"], ${${"GLOBALS"}["zijjmocr"]});
     }
     ${$iqkuworgzsm} = array($objImport->getNextRow(), $objImport->getNextRow(), $objImport->getNextRow(), $objImport->getNextRow(), $objImport->getNextRow());
     $objImport->resetPosition();
     ${${"GLOBALS"}["xlydlqxgmjov"]} = $objImport->getTotalRows(false);
     ${${"GLOBALS"}["qcmpftauwm"]} = $objImport->get("importParams");
     if (!empty(${$pgtydkw}["skipfirst"])) {
         ${${"GLOBALS"}["mpeepnnvjrc"]} -= 1;
     }
     $viewer->assign("found_rows", ${$cjplrqzb});
     $viewer->assign("rows", ${${"GLOBALS"}["rqdfnh"]});
     $viewer->assign("hash", $objImport->getHash());
     $viewer->assign("import_process", intval($_POST["import_process"]));
     $viewer->assign("importParams", $objImport->get("importParams"));
     $viewer->view("ImporterStep2.tpl", "Workflow2");
     return;
 }
Esempio n. 12
0
    public function process(Vtiger_Request $request)
    {
        $moduleName = $request->getModule();
        $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
        $for_module = $request->get('return_module');
        $recordIds = $this->getRecordsListFromRequest($request);
        $adb = PearDatabase::getInstance();
        PDFMaker_Debugger_Model::GetInstance()->Init();
        $PDFMaker = new PDFMaker_PDFMaker_Model();
        if ($PDFMaker->CheckPermissions("DETAIL") == false) {
            $close_img = vimage_path('close.gif');
            $output = '
                <table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
                <tr>
                      <td width="90%" align="left" class="genHeaderSmall" id="PDFListViewDivHandle" style="cursor:move;">' . vtranslate("LBL_PDF_ACTIONS", "PDFMaker") . '                 			
                      </td>
                      <td width="10%" align="right">
                              <a href="javascript:fninvsh(\'PDFListViewDiv\');"><img title="' . vtranslate("LBL_CLOSE") . '" alt="' . vtranslate("LBL_CLOSE") . '" src="' . $close_img . '" border="0"  align="absmiddle" /></a>
                      </td>
                </tr>
                </table>
                <table border=0 cellspacing=0 cellpadding=5 width=100% align=center>
                    <tr><td class="small">
                        <table border=0 cellspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
                        <tr>
                          <td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;text-align:center;">
                            <strong>' . vtranslate("LBL_PERMISSION_DENIED") . '</strong>
                          </td>
                        </tr>
                        <tr>
                                      <td class="dvtCellInfo" style="width:100%;" align="center">
                            <input type="button" class="crmbutton small cancel" value="' . vtranslate("LBL_CANCEL") . '" onclick="fninvsh(\'PDFListViewDiv\');" />      
                          </td>
                              </tr>      		
                        </table>
                    </td></tr>
                </table>
                ';
            die($output);
        }
        $_REQUEST['idslist'] = implode(";", $recordIds);
        $request->set('idlist', $_REQUEST['idslist']);
        //$language = $_SESSION['authenticated_user_language'];
        $current_language = Vtiger_Language_Handler::getLanguage();
        $templates = $PDFMaker->GetAvailableTemplates($for_module, true);
        $options = "";
        foreach ($templates as $templateid => $valArr) {
            if ($valArr["is_default"] == "2" || $valArr["is_default"] == "3") {
                $selected = ' selected="selected" ';
            } else {
                $selected = "";
            }
            $options .= '<option value="' . $templateid . '"' . $selected . '>' . $valArr['templatename'] . '</option>';
        }
        $template_output = "";
        $language_output = "";
        $generate_pdf = "";
        if ($options != "") {
            $template_output = '
		    <tr>
		  		<td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;">
		  			<select name="use_common_template" id="use_common_template" class="detailedViewTextBox" multiple style="width:90%;" size="5">
		        ' . $options . '
		        </select>
		  		</td>
				</tr>
		  ';
            $templates_select = '<select name="use_common_template" id="use_common_template" style="display: none;" id="fieldList" class="select2 row-fluid" multiple="true" size="5" data-validation-engine="validate[required]">
		        ' . $options . '
		        </select>';
            $temp_res = $adb->pquery("SELECT label, prefix FROM vtiger_language WHERE active=?", array("1"));
            while ($temp_row = $adb->fetchByAssoc($temp_res)) {
                $template_languages[$temp_row["prefix"]] = $temp_row["label"];
            }
            //LANGUAGES BLOCK
            if (count($template_languages) > 1) {
                $options = "";
                foreach ($template_languages as $prefix => $label) {
                    if ($current_language != $prefix) {
                        $options .= '<option value="' . $prefix . '">' . $label . '</option>';
                    } else {
                        $options .= '<option value="' . $prefix . '" selected="selected">' . $label . '</option>';
                    }
                }
                $language_output = '
		      <tr>
		  		<td class="dvtCellInfo" style="width:100%;">    	
		          <select name="template_language" id="template_language" class="detailedViewTextBox" style="width:90%;" size="1">
		  		    ' . $options . '
		          </select>
		  		</td>
		      </tr>';
                $languages_select = '<select name="template_language" id="template_language" class="select2 row-fluid" style="display: none;">
		  		    ' . $options . '
		          </select>';
            } else {
                foreach ($template_languages as $prefix => $label) {
                    $languages_select .= '<input type="hidden" name="template_language" id="template_language" value="' . $prefix . '"/>';
                }
            }
        } else {
            $template_output = '<tr>
		                		<td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;">
		                		  ' . vtranslate("CRM_TEMPLATES_DONT_EXIST", "PDFMaker");
            //   if(isPermitted("PDFMaker","EditView") == 'yes')
            if ($PDFMaker->CheckPermissions("EDIT")) {
                $template_output .= '<br />' . vtranslate("CRM_TEMPLATES_ADMIN", "PDFMaker") . '
		                      <a href="index.php?module=PDFMaker&action=EditPDFTemplate&return_module=' . $request->get("return_module") . '&parenttab=Tools" class="webMnu">' . vtranslate("TEMPLATE_CREATE_HERE", "PDFMaker") . '</a>';
            }
            $template_output .= '</td></tr>';
        }
        $viewer = $this->getViewer($request);
        //$viewer->assign('MODULE', $relmodule);
        //$viewer->assign('ID', $record);
        $viewer->assign('templates_select', $templates_select);
        $viewer->assign('languages_select', $languages_select);
        $viewer->assign('idslist', $_REQUEST['idslist']);
        $viewer->assign('relmodule', $request->get('return_module'));
        $viewer->view("ListViewSelect.tpl", 'PDFMaker');
    }
Esempio n. 13
0
 public function process(Vtiger_Request $request)
 {
     ${"GLOBALS"}["kdeehlyv"] = "TMPworkflows";
     $seemluoths = "viewer";
     $iqrmjuou = "module";
     $oonrwkg = "result";
     $wnxmbyrsjd = "cu_model";
     ${"GLOBALS"}["ujmqtir"] = "current_user";
     $wmcoewcu = "sql";
     ${"GLOBALS"}["sfolfu"] = "workflows";
     $laqtnyra = "ImportWorkflows";
     ${"GLOBALS"}["szyrcsxqnjwy"] = "adb";
     ${"GLOBALS"}["cjryuofsmx"] = "result";
     ${"GLOBALS"}["lyqxydcxb"] = "TMPworkflows";
     $pkqxigbjog = "objWorkflow";
     $nphxkxzqhk = "module";
     ${"GLOBALS"}["awnfeqq"] = "currentLanguage";
     ${${"GLOBALS"}["ujmqtir"]} = ${$wnxmbyrsjd} = Users_Record_Model::getCurrentUserModel();
     ${${"GLOBALS"}["awnfeqq"]} = Vtiger_Language_Handler::getLanguage();
     ${${"GLOBALS"}["szyrcsxqnjwy"]} = PearDatabase::getInstance();
     ${$seemluoths} = $this->getViewer(${${"GLOBALS"}["uxdtkwefwwne"]});
     ${${"GLOBALS"}["dfxtdqgbgfq"]} = $request->get("src_module");
     ${${"GLOBALS"}["kdeehlyv"]} = Workflow2::getWorkflowsForModule(${${"GLOBALS"}["dfxtdqgbgfq"]});
     ${${"GLOBALS"}["sfolfu"]} = array();
     foreach (${${"GLOBALS"}["lyqxydcxb"]} as ${${"GLOBALS"}["gajgjhlo"]}) {
         $abvdowpqhmj = "crmid";
         $ljtimwygf = "workflow";
         ${${"GLOBALS"}["fdbmbwylgb"]} = new \Workflow\Main(${${"GLOBALS"}["gajgjhlo"]}["id"]);
         if ((${$ljtimwygf}["authmanagement"] == "0" || $objWorkflow->checkAuth("view")) && $objWorkflow->checkExecuteCondition(${$abvdowpqhmj})) {
             $cerwfumx = "workflows";
             ${$cerwfumx}[] = ${${"GLOBALS"}["gajgjhlo"]};
         }
     }
     ${$pkqxigbjog} = new Workflow2();
     $cfnbmosu = "sql";
     ${$laqtnyra} = $objWorkflow->getWorkflowsForModule(${$nphxkxzqhk}, 1, "WF2_IMPORTER");
     $ksukmmns = "buttons";
     if (count(${${"GLOBALS"}["fjfxaoqcd"]}) == 0) {
         $viewer->assign("hide_importer", true);
     } else {
         $viewer->assign("hide_importer", false);
     }
     $crjxzwpi = "module";
     $viewer->assign("isAdmin", $current_user->is_admin == "on");
     $viewer->assign("workflows", ${${"GLOBALS"}["ahtwyzverq"]});
     $viewer->assign("source_module", ${${"GLOBALS"}["dfxtdqgbgfq"]});
     $jspfvd = "viewer";
     ${${"GLOBALS"}["kwlufmsfbzr"]} = new \Workflow\FrontendManager();
     ${${"GLOBALS"}["pkuntpkws"]} = $frontendManager->getByPosition(${$iqrmjuou}, "sidebar", ${${"GLOBALS"}["ipaeblf"]});
     ${$cfnbmosu} = "SELECT * FROM vtiger_wf_frontend_config WHERE module = ?";
     ${$oonrwkg} = $adb->pquery(${$wmcoewcu}, array(${$crjxzwpi}));
     if ($adb->num_rows(${${"GLOBALS"}["cjryuofsmx"]}) > 0) {
         $zsffethlyc = "result";
         ${"GLOBALS"}["bvsncmu"] = "frontendconfig";
         ${${"GLOBALS"}["bvsncmu"]} = $adb->fetchByAssoc(${$zsffethlyc});
         $viewer->assign("show_listview", ${${"GLOBALS"}["vwafnyh"]}["hide_listview"] == "0");
     } else {
         $viewer->assign("show_listview", true);
     }
     $viewer->assign("buttons", ${$ksukmmns});
     \Workflow\Sidebar::assignMessages(-1, ${$jspfvd});
     $viewer->view("SidebarListWidget.tpl", "Workflow2");
 }
Esempio n. 14
0
 function preProcess(Vtiger_Request $request, $display = true)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $viewer = $this->getViewer($request);
     $viewer->assign('PAGETITLE', $this->getPageTitle($request));
     $viewer->assign('HEADER_SCRIPTS', $this->getHeaderScripts($request));
     $viewer->assign('STYLES', $this->getHeaderCss($request));
     $viewer->assign('SKIN_PATH', Vtiger_Theme::getCurrentUserThemePath());
     $viewer->assign('LANGUAGE_STRINGS', $this->getJSLanguageStrings($request));
     $viewer->assign('HTMLLANG', Vtiger_Language_Handler::getShortLanguageName());
     $viewer->assign('LANGUAGE', Vtiger_Language_Handler::getLanguage());
     if ($display) {
         $this->preProcessDisplay($request);
     }
 }
Esempio n. 15
0
    public function process(Vtiger_Request $request)
    {
        PDFMaker_Debugger_Model::GetInstance()->Init();
        $simple_html_dom_file = $this->getSimpleHtmlDomFile();
        require_once $simple_html_dom_file;
        $default_charset = vglobal('default_charset');
        $adb = PearDatabase::getInstance();
        $relmodule = $request->get("formodule");
        $viewer = $this->getViewer($request);
        // get ids
        if ($request->get("idslist") != "") {
            //generating from listview
            $Records = explode(";", rtrim($request->get("idslist"), ";"));
        } elseif ($request->get('record') != '') {
            $Records = array($request->get("record"));
        } elseif ($request->get('return_id') != '') {
            $Records = array($request->get("return_id"));
        }
        $viewer->assign("RECORDS", implode(';', $Records));
        // get selected templates id array
        $commontemplateids = trim($request->get("commontemplateid"), ";");
        $Templateids = explode(";", $commontemplateids);
        $viewer->assign("COMMONTEMPLATEIDS", $commontemplateids);
        // get selected templates array
        $sql = "SELECT * FROM vtiger_pdfmaker WHERE templateid IN (" . generateQuestionMarks($Templateids) . ")";
        $result = $adb->pquery($sql, $Templateids);
        $num_rows = $adb->num_rows($result);
        $template_select = '';
        if ($num_rows > 1) {
            $template_select .= "<select onChange='changeTemplate(this.value);'>";
            while ($row = $adb->fetchByAssoc($result)) {
                if ($st == "") {
                    $st = $row['templateid'];
                }
                $template_select .= "<option value='" . $row['templateid'] . "'>" . $row['filename'] . "</option>";
            }
            $template_select .= "</select>";
        } else {
            $st = $adb->query_result($result, 0, "templateid");
            $template_select .= $adb->query_result($result, 0, "filename");
        }
        $viewer->assign("TEMPLATE_SELECT", $template_select);
        $viewer->assign("ST", $st);
        // get content of templates
        $PDFMaker = new PDFMaker_PDFMaker_Model('PDFMaker');
        $PDFContents = array();
        //require_once("modules/PDFMaker/InventoryPDF.php");
        foreach ($Records as $record) {
            $record_model = Vtiger_Record_Model::getInstanceById($record);
            $focus = $record_model->entity;
            foreach ($Templateids as $templateid) {
                $PDFContent = new PDFMaker_PDFContent_Model($templateid, $relmodule, $focus, $request->get("language"));
                $pdf_content = $PDFContent->getContent();
                $body_html = $pdf_content["body"];
                $body_html = str_replace("#LISTVIEWBLOCK_START#", "", $body_html);
                $body_html = str_replace("#LISTVIEWBLOCK_END#", "", $body_html);
                $PDFContents[$templateid]["header"] = $pdf_content["header"];
                $PDFContents[$templateid]["body"] = $body_html;
                $PDFContents[$templateid]["footer"] = $pdf_content["footer"];
            }
        }
        $pdf_divs = '';
        foreach ($PDFContents as $templateid => $templatedata) {
            $sections = array("body", "header", "footer");
            foreach ($sections as $val) {
                if ($templatedata[$val] != "") {
                    /*
                    $html = str_get_html($templatedata[$val]);
                    
                    $textTags = $html->find('text');
                    foreach ($textTags as $text) {
                        $text->outertext = str_replace("  ", "&nbsp;&nbsp;", $text->outertext);
                        $text->outertext = str_replace("&nbsp; ", "&nbsp;&nbsp;", $text->outertext);
                    }
                    $templatedata[$val] = htmlentities($html->save(), ENT_QUOTES, $default_charset);
                    */
                    $templatedata[$val] = htmlentities($templatedata[$val], ENT_QUOTES, $default_charset);
                }
            }
            $pdf_divs .= '<div style="display:none;" id="body_div' . $templateid . '"> 
		         <textarea name="body' . $templateid . '" id="body' . $templateid . '" style="width:90%;height:700px" class=small tabindex="5">' . $templatedata["body"] . '</textarea>
		       </div>
		
		       <div style="display:none;" id="header_div' . $templateid . '"> 
		         <textarea name="header' . $templateid . '" id="header' . $templateid . '" style="width:90%;height:700px" class=small tabindex="5">' . $templatedata["header"] . '</textarea>
		       </div>
		 
		       <div style="display:none;" id="footer_div' . $templateid . '"> 
		         <textarea name="footer' . $templateid . '" id="footer' . $templateid . '" style="width:90%;height:700px" class=small tabindex="5">' . $templatedata["footer"] . '</textarea>
		       </div>';
            $pdf_divs .= '<script type="text/javascript">
                            jQuery(document).ready(function(){
		          	CKEDITOR.replace( \'body' . $templateid . '\', {height: \'300\'});
                                CKEDITOR.replace( \'header' . $templateid . '\', {height: \'300\'});
                                CKEDITOR.replace( \'footer' . $templateid . '\', {height: \'300\'});
                                })
		         </script>';
        }
        $viewer->assign("PDF_DIVS", $pdf_divs);
        $language = Vtiger_Language_Handler::getLanguage();
        $mod_strings = Vtiger_Language_Handler::getModuleStringsFromFile($language, "Documents");
        $pdf_strings = Vtiger_Language_Handler::getModuleStringsFromFile($language, "PDFMaker");
        $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername";
        $res = $adb->pquery($sql, array());
        $options = "";
        for ($i = 0; $i < $adb->num_rows($res); $i++) {
            $fid = $adb->query_result($res, $i, "folderid");
            $fldr_name = $adb->query_result($res, $i, "foldername");
            $options .= '<option value="' . $fid . '">' . $fldr_name . '</option>';
        }
        $viewer->assign("FOLDER_OPTIONS", $options);
        $viewer->view('EditAndExport.tpl', 'PDFMaker');
    }
Esempio n. 16
0
 function process(Vtiger_Request $request)
 {
     Vtiger_Session::init();
     // Better place this here as session get initiated
     //skipping the csrf checking for the forgot(reset) password
     if ($request->get('mode') != 'reset' && $request->get('action') != 'Login') {
         require_once 'libraries/csrf-magic/csrf-magic.php';
     }
     // TODO - Get rid of global variable $current_user
     // common utils api called, depend on this variable right now
     $currentUser = $this->getLogin();
     vglobal('current_user', $currentUser);
     global $default_language;
     vglobal('default_language', $default_language);
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     vglobal('current_language', $currentLanguage);
     $module = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     if ($currentUser && $qualifiedModuleName) {
         $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $qualifiedModuleName);
         vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
     }
     if ($currentUser) {
         $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage);
         vglobal('app_strings', $moduleLanguageStrings['languageStrings']);
     }
     $view = $request->get('view');
     $action = $request->get('action');
     $response = false;
     try {
         if ($this->isInstalled() === false && $module != 'Install') {
             header('Location:index.php?module=Install&view=Index');
             exit;
         }
         if (empty($module)) {
             if ($this->hasLogin()) {
                 $defaultModule = vglobal('default_module');
                 if (!empty($defaultModule) && $defaultModule != 'Home') {
                     $module = $defaultModule;
                     $qualifiedModuleName = $defaultModule;
                     $view = 'List';
                     if ($module == 'Calendar') {
                         // To load MyCalendar instead of list view for calendar
                         //TODO: see if it has to enhanced and get the default view from module model
                         $view = 'Calendar';
                     }
                 } else {
                     $module = 'Home';
                     $qualifiedModuleName = 'Home';
                     $view = 'DashBoard';
                 }
             } else {
                 $module = 'Users';
                 $qualifiedModuleName = 'Settings:Users';
                 $view = 'Login';
             }
             $request->set('module', $module);
             $request->set('view', $view);
         }
         if (!empty($action)) {
             $componentType = 'Action';
             $componentName = $action;
         } else {
             $componentType = 'View';
             if (empty($view)) {
                 $view = 'Index';
             }
             $componentName = $view;
         }
         $handlerClass = Vtiger_Loader::getComponentClassName($componentType, $componentName, $qualifiedModuleName);
         $handler = new $handlerClass();
         if ($handler) {
             vglobal('currentModule', $module);
             // Ensure handler validates the request
             $handler->validateRequest($request);
             if ($handler->loginRequired()) {
                 $this->checkLogin($request);
             }
             //TODO : Need to review the design as there can potential security threat
             $skipList = array('Users', 'Home', 'CustomView', 'Import', 'Export', 'Inventory', 'Vtiger', 'PriceBooks', 'Migration', 'Install');
             if (!in_array($module, $skipList) && stripos($qualifiedModuleName, 'Settings') === false) {
                 $this->triggerCheckPermission($handler, $request);
             }
             // Every settings page handler should implement this method
             if (stripos($qualifiedModuleName, 'Settings') === 0 || $module == 'Users') {
                 $handler->checkPermission($request);
             }
             $notPermittedModules = array('ModComments', 'Integration', 'DashBoard');
             if (in_array($module, $notPermittedModules) && $view == 'List') {
                 header('Location:index.php?module=Home&view=DashBoard');
             }
             $this->triggerPreProcess($handler, $request);
             /** EventHandler START */
             list($handler, $request) = EventHandler_Module_Model::do_filter(array("vtiger.filter.process." . strtolower($module . '.' . $componentName . "." . $componentType) . ".before", "vtiger.filter.process." . strtolower($componentName . "." . $componentType) . ".before"), array($handler, $request));
             /** EventHandler ENDE */
             $response = $handler->process($request);
             /** EventHandler START */
             list($handler, $request) = EventHandler_Module_Model::do_filter(array("vtiger.filter.process." . strtolower($module . '.' . $componentName . "." . $componentType) . ".after", "vtiger.filter.process." . strtolower($componentName . "." . $componentType) . ".after"), array($handler, $request));
             /** EventHandler ENDE */
             $this->triggerPostProcess($handler, $request);
         } else {
             throw new AppException(vtranslate('LBL_HANDLER_NOT_FOUND'));
         }
     } catch (Exception $e) {
         if ($view) {
             // Log for developement.
             error_log($e->getTraceAsString(), E_NOTICE);
             $viewer = new Vtiger_Viewer();
             $viewer->assign('MESSAGE', $e->getMessage());
             $viewer->view('OperationNotPermitted.tpl', 'Vtiger');
         } else {
             $response = new Vtiger_Response();
             $response->setEmitType(Vtiger_Response::$EMIT_JSON);
             $response->setError($e->getMessage());
         }
     }
     /** EventHandler START */
     EventHandler_Module_Model::do_action("vtiger.process.finish", array($module, $componentName, $componentType));
     EventHandler_Module_Model::do_action("vtiger.process." . strtolower($module . '.' . $componentName . "." . $componentType) . ".finish", array($module, $componentName, $componentType));
     /** EventHandler ENDE */
     if ($response) {
         $response->emit();
     }
 }
Esempio n. 17
0
 /**
  * Function sends mail
  */
 public function send()
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $rootDirectory = vglobal('root_directory');
     $mailer = Emails_Mailer_Model::getInstance();
     $mailer->IsHTML(true);
     $fromEmail = $this->getFromEmailAddress();
     $replyTo = $currentUserModel->get('email1');
     $userName = $currentUserModel->getName();
     // To eliminate the empty value of an array
     $toEmailInfo = array_filter($this->get('toemailinfo'));
     $toMailNamesList = array_filter($this->get('toMailNamesList'));
     foreach ($toMailNamesList as $id => $emailData) {
         foreach ($emailData as $key => $email) {
             if ($toEmailInfo[$id]) {
                 array_push($toEmailInfo[$id], $email['value']);
             }
         }
     }
     $emailsInfo = array();
     foreach ($toEmailInfo as $id => $emails) {
         foreach ($emails as $key => $value) {
             array_push($emailsInfo, $value);
         }
     }
     $toFieldData = array_diff(explode(',', $this->get('saved_toid')), $emailsInfo);
     $toEmailsData = array();
     $i = 1;
     foreach ($toFieldData as $value) {
         $toEmailInfo['to' . $i++] = array($value);
     }
     $attachments = $this->getAttachmentDetails();
     $status = false;
     // Merge Users module merge tags based on current user.
     $mergedDescription = getMergedDescription($this->get('description'), $currentUserModel->getId(), 'Users');
     foreach ($toEmailInfo as $id => $emails) {
         $mailer->reinitialize();
         $mailer->ConfigSenderInfo($fromEmail, $userName, $replyTo);
         $old_mod_strings = vglobal('mod_strings');
         $description = $this->get('description');
         $parentModule = $this->getEntityType($id);
         if ($parentModule) {
             $currentLanguage = Vtiger_Language_Handler::getLanguage();
             $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $parentModule);
             vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
             if ($parentModule != 'Users') {
                 // Apply merge for non-Users module merge tags.
                 $description = getMergedDescription($mergedDescription, $id, $parentModule);
             } else {
                 // Re-merge the description for user tags based on actual user.
                 $description = getMergedDescription($description, $id, 'Users');
                 vglobal('mod_strings', $old_mod_strings);
             }
         }
         if (strpos($description, '$logo$')) {
             $description = str_replace('$logo$', "<img src='cid:logo' />", $description);
             $logo = true;
         }
         foreach ($emails as $email) {
             $mailer->Body = $description;
             $mailer->Signature = str_replace(array('\\r\\n', '\\n'), '<br>', $currentUserModel->get('signature'));
             if ($mailer->Signature != '') {
                 $mailer->Body .= '<br><br>' . decode_html($mailer->Signature);
             }
             $mailer->Subject = $this->get('subject');
             $mailer->AddAddress($email);
             //Adding attachments to mail
             if (is_array($attachments)) {
                 foreach ($attachments as $attachment) {
                     $fileNameWithPath = $rootDirectory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
                     if (is_file($fileNameWithPath)) {
                         $mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
                     }
                 }
             }
             if ($logo) {
                 //While sending email template and which has '$logo$' then it should replace with company logo
                 $company = Settings_Vtiger_CompanyDetails_Model::getInstance();
                 $logo = $company->getLogoPath('logoname');
                 $mailer->AddEmbeddedImage(dirname(__FILE__) . '/../../../' . $logo, 'logo', 'logo.jpg', 'base64', 'image/jpg');
             }
             $ccs = array_filter(explode(',', $this->get('ccmail')));
             $bccs = array_filter(explode(',', $this->get('bccmail')));
             if (!empty($ccs)) {
                 foreach ($ccs as $cc) {
                     $mailer->AddCC($cc);
                 }
             }
             if (!empty($bccs)) {
                 foreach ($bccs as $bcc) {
                     $mailer->AddBCC($bcc);
                 }
             }
         }
         $status = $mailer->Send(true);
         if (!$status) {
             $status = $mailer->getError();
         } else {
             $mailString = $mailer->getMailString();
             $mailBoxModel = MailManager_Mailbox_Model::activeInstance();
             $folderName = $mailBoxModel->folder();
             if (!empty($folderName) && !empty($mailString)) {
                 $connector = MailManager_Connector_Connector::connectorWithModel($mailBoxModel, '');
                 imap_append($connector->mBox, $connector->mBoxUrl . $folderName, $mailString, "\\Seen");
             }
         }
     }
     return $status;
 }
Esempio n. 18
0
 /**
  * Function sends mail
  */
 public function send()
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $rootDirectory = vglobal('root_directory');
     $mailer = Emails_Mailer_Model::getInstance();
     $mailer->IsHTML(true);
     $fromEmail = $this->getFromEmailAddress();
     $replyTo = $currentUserModel->get('email1');
     $userName = $currentUserModel->getName();
     // To eliminate the empty value of an array
     $toEmailInfo = array_filter($this->get('toemailinfo'));
     $toMailNamesList = array_filter($this->get('toMailNamesList'));
     foreach ($toMailNamesList as $id => $emailData) {
         foreach ($emailData as $key => $email) {
             if ($toEmailInfo[$id]) {
                 array_push($toEmailInfo[$id], $email['value']);
             }
         }
     }
     $emailsInfo = array();
     foreach ($toEmailInfo as $id => $emails) {
         foreach ($emails as $key => $value) {
             array_push($emailsInfo, $value);
         }
     }
     $toFieldData = array_diff(explode(',', $this->get('saved_toid')), $emailsInfo);
     $toEmailsData = array();
     $i = 1;
     foreach ($toFieldData as $value) {
         $toEmailInfo['to' . $i++] = array($value);
     }
     $attachments = $this->getAttachmentDetails();
     $status = false;
     // Merge Users module merge tags based on current user.
     $mergedDescription = getMergedDescription($this->get('description'), $currentUserModel->getId(), 'Users');
     $mergedSubject = getMergedDescription($this->get('subject'), $currentUserModel->getId(), 'Users');
     foreach ($toEmailInfo as $id => $emails) {
         $mailer->reinitialize();
         $mailer->ConfigSenderInfo($fromEmail, $userName, $replyTo);
         $old_mod_strings = vglobal('mod_strings');
         $description = $this->get('description');
         $subject = $this->get('subject');
         $parentModule = $this->getEntityType($id);
         if ($parentModule) {
             $currentLanguage = Vtiger_Language_Handler::getLanguage();
             $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $parentModule);
             vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
             if ($parentModule != 'Users') {
                 // Apply merge for non-Users module merge tags.
                 $description = getMergedDescription($mergedDescription, $id, $parentModule);
                 $subject = getMergedDescription($mergedSubject, $id, $parentModule);
             } else {
                 // Re-merge the description for user tags based on actual user.
                 $description = getMergedDescription($description, $id, 'Users');
                 $subject = getMergedDescription($mergedSubject, $id, 'Users');
                 vglobal('mod_strings', $old_mod_strings);
             }
         }
         if (strpos($description, '$logo$')) {
             $description = str_replace('$logo$', "<img src='cid:logo' />", $description);
             $logo = true;
         }
         foreach ($emails as $email) {
             $mailer->Body = '';
             if ($parentModule) {
                 $mailer->Body = $this->getTrackImageDetails($id, $this->isEmailTrackEnabled());
             }
             $mailer->Body .= $description;
             $mailer->Signature = str_replace(array('\\r\\n', '\\n'), '<br>', $currentUserModel->get('signature'));
             if ($mailer->Signature != '') {
                 $mailer->Body .= '<br><br>' . decode_html($mailer->Signature);
             }
             $mailer->Subject = $subject;
             $mailer->AddAddress($email);
             //Adding attachments to mail
             if (is_array($attachments)) {
                 foreach ($attachments as $attachment) {
                     $fileNameWithPath = $rootDirectory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
                     if (is_file($fileNameWithPath)) {
                         $mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
                     }
                 }
             }
             if ($logo) {
                 //While sending email template and which has '$logo$' then it should replace with company logo
                 $mailer->AddEmbeddedImage(dirname(__FILE__) . '/../../../layouts/vlayout/skins/images/logo_mail.jpg', 'logo', 'logo.jpg', 'base64', 'image/jpg');
             }
             $ccs = array_filter(explode(',', $this->get('ccmail')));
             $bccs = array_filter(explode(',', $this->get('bccmail')));
             if (!empty($ccs)) {
                 // SalesPlatform.ru begin
                 foreach ($ccs as $cc) {
                     $mailer->AddCC($idn->encode($cc));
                 }
                 //$mailer->AddCC($cc);
                 // SalesPlatform.ru end
             }
             if (!empty($bccs)) {
                 // SalesPlatform.ru begin
                 foreach ($bccs as $bcc) {
                     $mailer->AddBCC($idn->encode($bcc));
                 }
                 //$mailer->AddBCC($bcc);
                 // SalesPlatform.ru end
             }
         }
         // SalesPlatform.ru begin
         $idn = new idna_convert();
         $query = "select * from vtiger_systems where server_type=?";
         $params = array('email');
         //SalesPlatform begin fix bug
         $adb = PearDatabase::getInstance();
         //SalesPaltform.ru end
         $result = $adb->pquery($query, $params);
         $server_username = $adb->query_result($result, 0, 'server_username');
         $from_name_db = $adb->query_result($result, 0, 'from_name');
         $server_port = $adb->query_result($result, 0, 'server_port');
         $server_tls = $adb->query_result($result, 0, 'server_tls');
         if ($server_username != '') {
             $server_username = $idn->encode($server_username);
             $mailer->Username = $server_username;
         }
         if (isset($from_name_db) && $from_name_db != '') {
             $mailer->FromName = decode_html($from_name_db);
         }
         $from_email = $adb->query_result($result, 0, 'from_email_field');
         if ($from_email != '') {
             $mailer->From = $idn->encode($from_email);
         }
         if (!empty($server_port) && $server_port != 0) {
             $mailer->Port = $server_port;
         }
         if (!empty($server_tls) && $server_tls != 'no') {
             $mailer->SMTPSecure = $server_tls;
         }
         $use_sendmail = $adb->query_result($result, 0, 'use_sendmail');
         if ($use_sendmail == "on") {
             $mailer->IsSendmail();
         } else {
             $mailer->IsSMTP();
         }
         // SalesPlatform.ru end
         $status = $mailer->Send(true);
         if (!$status) {
             $status = $mailer->getError();
         } else {
             $mailString = $mailer->getMailString();
             $mailBoxModel = MailManager_Mailbox_Model::activeInstance();
             $folderName = $mailBoxModel->folder();
             if (!empty($folderName) && !empty($mailString)) {
                 $connector = MailManager_Connector_Connector::connectorWithModel($mailBoxModel, '');
                 imap_append($connector->mBox, $connector->mBoxUrl . $folderName, $mailString, "\\Seen");
             }
         }
     }
     return $status;
 }
Esempio n. 19
0
 function preProcess(Vtiger_Request $request, $display = true)
 {
     $moduleName = $request->getModule();
     $viewer = $this->getViewer($request);
     $viewer->assign('PAGETITLE', $this->getPageTitle($request));
     $viewer->assign('BREADCRUMB_TITLE', $this->getBreadcrumbTitle($request));
     $viewer->assign('HEADER_SCRIPTS', $this->getHeaderScripts($request));
     $viewer->assign('STYLES', $this->getHeaderCss($request));
     $viewer->assign('SKIN_PATH', Vtiger_Theme::getCurrentUserThemePath());
     $viewer->assign('LAYOUT_PATH', 'layouts' . '/' . Yeti_Layout::getActiveLayout());
     $viewer->assign('LANGUAGE_STRINGS', $this->getJSLanguageStrings($request));
     $viewer->assign('HTMLLANG', Vtiger_Language_Handler::getShortLanguageName());
     $viewer->assign('LANGUAGE', Vtiger_Language_Handler::getLanguage());
     $viewer->assign('SHOW_BODY_HEADER', $this->showBodyHeader());
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('VIEW', $request->get('view'));
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('PARENT_MODULE', $request->get('parent'));
     if ($display) {
         $this->preProcessDisplay($request);
     }
 }
Esempio n. 20
0
 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";
 }
Esempio n. 21
0
 public function process(Vtiger_Request $request)
 {
     $ovoodkiokzvf = "cu_model";
     $reyhvptvyl = "sql";
     ${"GLOBALS"}["tbhhwi"] = "current_user";
     ${${"GLOBALS"}["tbhhwi"]} = ${$ovoodkiokzvf} = Users_Record_Model::getCurrentUserModel();
     $fmivvfyl = "currentLanguage";
     ${"GLOBALS"}["bhgpydrruuti"] = "module";
     ${"GLOBALS"}["fvwjvmicvg"] = "viewer";
     $bwydxjijyuko = "request";
     $dtcicumpi = "row";
     $zxuljoxze = "sql";
     ${$fmivvfyl} = Vtiger_Language_Handler::getLanguage();
     $ahuziprigd = "result";
     $jfnnufy = "crmid";
     ${"GLOBALS"}["oewskmjg"] = "module";
     ${${"GLOBALS"}["bctcwzwr"]} = PearDatabase::getInstance();
     $yvsdkkymncwr = "waitingRST";
     ${"GLOBALS"}["jzipbnwt"] = "crmid";
     $lylgtfgrnf = "waitingRST";
     ${${"GLOBALS"}["fvwjvmicvg"]} = $this->getViewer(${$bwydxjijyuko});
     ${${"GLOBALS"}["bhgpydrruuti"]} = $request->get("source_module");
     ${${"GLOBALS"}["tjndrz"]} = (int) $request->get("record");
     if (${${"GLOBALS"}["ouahvk"]} == "Events") {
         $ilvwhpykw = "module";
         ${$ilvwhpykw} = "Calendar";
     }
     $inyaxscqqtrd = "waiting";
     ${"GLOBALS"}["dswhemd"] = "module";
     ${${"GLOBALS"}["alvjlol"]} = Workflow2::getWorkflowsForModule(${${"GLOBALS"}["ouahvk"]});
     $llkjiwsxj = "module";
     $fnfyuskkd = "workflow";
     ${${"GLOBALS"}["tndywt"]} = array();
     foreach (${${"GLOBALS"}["alvjlol"]} as ${$fnfyuskkd}) {
         $iwogovyptmri = "workflow";
         ${"GLOBALS"}["bctvoft"] = "workflow";
         ${"GLOBALS"}["ghogwrdq"] = "objWorkflow";
         ${${"GLOBALS"}["ghogwrdq"]} = new \Workflow\Main(${${"GLOBALS"}["bctvoft"]}["id"]);
         ${"GLOBALS"}["wlrgageide"] = "crmid";
         if ((${$iwogovyptmri}["authmanagement"] == "0" || $objWorkflow->checkAuth("view")) && $objWorkflow->checkExecuteCondition(${${"GLOBALS"}["wlrgageide"]})) {
             ${"GLOBALS"}["dqmhkhkjgng"] = "workflow";
             ${${"GLOBALS"}["tndywt"]}[] = ${${"GLOBALS"}["dqmhkhkjgng"]};
         }
     }
     ${$zxuljoxze} = "SELECT vtiger_wf_settings.title, vtiger_wf_settings.authmanagement, vtiger_wfp_blocks.text, vtiger_wf_queue.nextStepTime, vtiger_wf_queue.workflow_id, vtiger_wf_queue.crmid, vtiger_wf_queue.execID, vtiger_wf_queue.block_id\n                FROM\n                    vtiger_wf_queue\n                    INNER JOIN vtiger_wf_settings ON(vtiger_wf_settings.id = vtiger_wf_queue.workflow_id)\n                    INNER JOIN vtiger_wfp_blocks ON(vtiger_wfp_blocks.id = vtiger_wf_queue.block_id)\n                WHERE vtiger_wf_queue.crmid = " . ${${"GLOBALS"}["jzipbnwt"]} . "";
     ${$lylgtfgrnf} = $adb->query(${${"GLOBALS"}["ikjiyio"]}, true);
     ${$inyaxscqqtrd} = array();
     $miablnvp = "sql";
     ${"GLOBALS"}["gajholdtee"] = "buttons";
     while (${$dtcicumpi} = $adb->fetchByAssoc(${$yvsdkkymncwr})) {
         ${${"GLOBALS"}["etweqtftj"]}[] = ${${"GLOBALS"}["pdmbilkwen"]};
     }
     ${$reyhvptvyl} = "SELECT * FROM vtiger_wf_frontend_config WHERE module = ?";
     ${$ahuziprigd} = $adb->pquery(${$miablnvp}, array(${${"GLOBALS"}["oewskmjg"]}));
     ${"GLOBALS"}["yeivnisennf"] = "frontendManager";
     if ($adb->num_rows(${${"GLOBALS"}["bloomad"]}) > 0) {
         ${"GLOBALS"}["trovrelooyjo"] = "result";
         ${"GLOBALS"}["hlrngfkuv"] = "frontendconfig";
         ${${"GLOBALS"}["fkhbco"]} = $adb->fetchByAssoc(${${"GLOBALS"}["trovrelooyjo"]});
         $viewer->assign("show_listview", ${${"GLOBALS"}["hlrngfkuv"]}["hide_listview"] == "0");
     } else {
         $viewer->assign("show_listview", true);
     }
     \Workflow\Sidebar::assignMessages(${${"GLOBALS"}["tjndrz"]}, ${${"GLOBALS"}["vjuhfvsmt"]});
     $viewer->assign("isAdmin", $current_user->is_admin == "on");
     $viewer->assign("waiting", ${${"GLOBALS"}["etweqtftj"]});
     $viewer->assign("workflows", ${${"GLOBALS"}["tndywt"]});
     $viewer->assign("source_module", ${$llkjiwsxj});
     $viewer->assign("crmid", ${${"GLOBALS"}["tjndrz"]});
     ${${"GLOBALS"}["yeivnisennf"]} = new \Workflow\FrontendManager();
     ${${"GLOBALS"}["gajholdtee"]} = $frontendManager->getByPosition(${${"GLOBALS"}["dswhemd"]}, "sidebar", ${$jfnnufy});
     $viewer->assign("buttons", ${${"GLOBALS"}["cbmsxefyh"]});
     $viewer->view("SidebarWidget.tpl", "Workflow2");
 }
Esempio n. 22
0
 function process(Vtiger_Request $request)
 {
     vglobal('log', LoggerManager::getLogger('System'));
     Vtiger_Session::init();
     $forceSSL = vglobal('forceSSL');
     if ($forceSSL && !Vtiger_Functions::getBrowserInfo()->https) {
         header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
     }
     // Better place this here as session get initiated
     //skipping the csrf checking for the forgot(reset) password
     $csrfProtection = vglobal('csrfProtection');
     if ($csrfProtection) {
         if ($request->get('mode') != 'reset' && $request->get('action') != 'Login') {
             require_once 'libraries/csrf-magic/csrf-magic.php';
         }
         require_once 'config/csrf_config.php';
     }
     // TODO - Get rid of global variable $current_user
     // common utils api called, depend on this variable right now
     $currentUser = $this->getLogin();
     vglobal('current_user', $currentUser);
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     vglobal('current_language', $currentLanguage);
     $module = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     if ($currentUser && $qualifiedModuleName) {
         $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $qualifiedModuleName);
         vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
     }
     if ($currentUser) {
         $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage);
         vglobal('app_strings', $moduleLanguageStrings['languageStrings']);
     }
     $view = $request->get('view');
     $action = $request->get('action');
     $response = false;
     try {
         if ($this->isInstalled() === false && $module != 'Install') {
             header('Location:install/Install.php');
             exit;
         }
         if (empty($module)) {
             if ($this->hasLogin()) {
                 $defaultModule = vglobal('default_module');
                 if (!empty($defaultModule) && $defaultModule != 'Home') {
                     $module = $defaultModule;
                     $qualifiedModuleName = $defaultModule;
                     $view = 'List';
                     if ($module == 'Calendar') {
                         // To load MyCalendar instead of list view for calendar
                         //TODO: see if it has to enhanced and get the default view from module model
                         $view = 'Calendar';
                     }
                 } else {
                     $module = 'Home';
                     $qualifiedModuleName = 'Home';
                     $view = 'DashBoard';
                 }
             } else {
                 $module = 'Users';
                 $qualifiedModuleName = 'Settings:Users';
                 $view = 'Login';
             }
             $request->set('module', $module);
             $request->set('view', $view);
         }
         if (!empty($action)) {
             $componentType = 'Action';
             $componentName = $action;
         } else {
             $componentType = 'View';
             if (empty($view)) {
                 $view = 'Index';
             }
             $componentName = $view;
         }
         $handlerClass = Vtiger_Loader::getComponentClassName($componentType, $componentName, $qualifiedModuleName);
         $handler = new $handlerClass();
         if ($handler) {
             vglobal('currentModule', $module);
             $csrfProtection = vglobal('csrfProtection');
             if ($csrfProtection) {
                 // Ensure handler validates the request
                 $handler->validateRequest($request);
             }
             if ($handler->loginRequired()) {
                 $this->checkLogin($request);
             }
             //TODO : Need to review the design as there can potential security threat
             $skipList = array('Users', 'Home', 'CustomView', 'Import', 'Export', 'Inventory', 'Vtiger', 'PriceBooks', 'Migration', 'Install');
             if (!in_array($module, $skipList) && stripos($qualifiedModuleName, 'Settings') === false) {
                 $this->triggerCheckPermission($handler, $request);
             }
             // Every settings page handler should implement this method
             if (stripos($qualifiedModuleName, 'Settings') === 0 || $module == 'Users') {
                 $handler->checkPermission($request);
             }
             $notPermittedModules = array('ModComments', 'Integration', 'DashBoard');
             if (in_array($module, $notPermittedModules) && $view == 'List') {
                 header('Location:index.php?module=Home&view=DashBoard');
             }
             $this->triggerPreProcess($handler, $request);
             $response = $handler->process($request);
             $this->triggerPostProcess($handler, $request);
         } else {
             throw new AppException(vtranslate('LBL_HANDLER_NOT_FOUND'));
         }
     } catch (Exception $e) {
         if ($view) {
             // Log for developement.
             error_log($e->getTraceAsString(), E_NOTICE);
             Vtiger_Functions::throwNewException($e->getMessage());
         } else {
             $response = new Vtiger_Response();
             $response->setEmitType(Vtiger_Response::$EMIT_JSON);
             $response->setError($e->getMessage());
             //Vtiger_Functions::throwNewException($e->getMessage());
         }
     }
     if ($response) {
         $response->emit();
     }
 }
Esempio n. 23
0
 /**
  * Function sends mail
  */
 public function send()
 {
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $rootDirectory = vglobal('root_directory');
     $mailer = Emails_Mailer_Model::getInstance();
     $mailer->IsHTML(true);
     $fromEmail = $this->getFromEmailAddress();
     $replyTo = $currentUserModel->get('email1');
     $userName = $currentUserModel->getName();
     // To eliminate the empty value of an array
     $toEmailInfo = array_filter($this->get('toemailinfo'));
     $attachments = $this->getAttachmentDetails();
     $status = false;
     // Merge Users module merge tags based on current user.
     $mergedDescription = getMergedDescription($this->get('description'), $currentUserModel->getId(), 'Users');
     foreach ($toEmailInfo as $id => $emails) {
         $parentModule = $this->getEntityType($id);
         $mailer->reinitialize();
         $mailer->ConfigSenderInfo($fromEmail, $userName, $replyTo);
         $old_mod_strings = vglobal('mod_strings');
         $currentLanguage = Vtiger_Language_Handler::getLanguage();
         $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $parentModule);
         vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
         if ($parentModule != 'Users') {
             // Apply merge for non-Users module merge tags.
             $description = getMergedDescription($mergedDescription, $id, $parentModule);
         } else {
             // Re-merge the description for user tags based on actual user.
             $description = getMergedDescription($this->get('description'), $id, 'Users');
         }
         vglobal('mod_strings', $old_mod_strings);
         if (strpos($description, '$logo$')) {
             $description = str_replace('$logo$', "<img src='cid:logo' />", $description);
             $logo = true;
         }
         foreach ($emails as $email) {
             $mailer->Body = $this->getTrackImageDetails($id, $this->isEmailTrackEnabled());
             $mailer->Body .= $description;
             $mailer->Signature = str_replace(array('\\r\\n', '\\n'), '<br>', $currentUserModel->get('signature'));
             if ($mailer->Signature != '') {
                 $mailer->Body .= decode_html($mailer->Signature);
             }
             $mailer->Subject = $this->get('subject');
             $mailer->AddAddress($email);
             //Adding attachments to mail
             if (is_array($attachments)) {
                 foreach ($attachments as $attachment) {
                     $fileNameWithPath = $rootDirectory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
                     if (is_file($fileNameWithPath)) {
                         $mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
                     }
                 }
             }
             if ($logo) {
                 //While sending email template and which has '$logo$' then it should replace with company logo
                 $mailer->AddEmbeddedImage(vimage_path('logo_mail.jpg'), 'logo', 'logo.jpg', 'base64', 'image/jpg');
             }
             $ccs = array_filter(explode(',', $this->get('ccmail')));
             $bccs = array_filter(explode(',', $this->get('bccmail')));
             if (!empty($ccs)) {
                 foreach ($ccs as $cc) {
                     $mailer->AddCC($cc);
                 }
             }
             if (!empty($bccs)) {
                 foreach ($bccs as $bcc) {
                     $mailer->AddBCC($bcc);
                 }
             }
         }
         $status = $mailer->Send(true);
         if (!$status) {
             $status = $mailer->getError();
         }
     }
     return $status;
 }
Esempio n. 24
-9
 function captureNow($request)
 {
     $currentLanguage = Vtiger_Language_Handler::getLanguage();
     $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage);
     vglobal('app_strings', $moduleLanguageStrings['languageStrings']);
     $returnURL = false;
     try {
         if (!vtlib_isModuleActive('Webforms')) {
             throw new Exception('webforms is not active');
         }
         $webform = Webforms_Model::retrieveWithPublicId(vtlib_purify($request['publicid']));
         if (empty($webform)) {
             throw new Exception("Webform not found.");
         }
         $returnURL = $webform->getReturnUrl();
         $roundrobin = $webform->getRoundrobin();
         // Retrieve user information
         $user = CRMEntity::getInstance('Users');
         $user->id = $user->getActiveAdminId();
         $user->retrieve_entity_info($user->id, 'Users');
         // Prepare the parametets
         $parameters = array();
         $webformFields = $webform->getFields();
         foreach ($webformFields as $webformField) {
             if ($webformField->getDefaultValue() != null) {
                 $parameters[$webformField->getFieldName()] = decode_html($webformField->getDefaultValue());
             } else {
                 $webformNeutralizedField = html_entity_decode($webformField->getNeutralizedField(), ENT_COMPAT, "UTF-8");
                 if (is_array(vtlib_purify($request[$webformNeutralizedField]))) {
                     $fieldData = implode(" |##| ", vtlib_purify($request[$webformNeutralizedField]));
                 } else {
                     $fieldData = vtlib_purify($request[$webformNeutralizedField]);
                     $fieldData = decode_html($fieldData);
                 }
                 $parameters[$webformField->getFieldName()] = stripslashes($fieldData);
             }
             if ($webformField->getRequired()) {
                 if (!isset($parameters[$webformField->getFieldName()])) {
                     throw new Exception("Required fields not filled");
                 }
             }
         }
         if ($roundrobin) {
             $ownerId = $webform->getRoundrobinOwnerId();
             $ownerType = vtws_getOwnerType($ownerId);
             $parameters['assigned_user_id'] = vtws_getWebserviceEntityId($ownerType, $ownerId);
         } else {
             $ownerId = $webform->getOwnerId();
             $ownerType = vtws_getOwnerType($ownerId);
             $parameters['assigned_user_id'] = vtws_getWebserviceEntityId($ownerType, $ownerId);
         }
         // Create the record
         $record = vtws_create($webform->getTargetModule(), $parameters, $user);
         $this->sendResponse($returnURL, 'ok');
         return;
     } catch (Exception $e) {
         $this->sendResponse($returnURL, false, $e->getMessage());
         return;
     }
 }