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; }
public function getData() { global $current_user, $adb; if ($this->_isDummy) { return array(); } require_once 'include/Webservices/Retrieve.php'; if ($this->_data === false) { #$crmObj = CRMEntity::getInstance($this->_moduleName); #$this->_data = $crmObj; #$this->_data->id = $this->_id; #$this->_data->mode = "edit"; #$data = $this->_data; #$this->_data->retrieve_entity_info($this->_id, $this->_moduleName); $this->prepareTransfer(); try { global $current_user; $oldCurrentUser = $current_user; $current_user = $useUser; $focus = CRMEntity::getInstance($this->getModuleName()); $focus->id = $this->_id; $focus->mode = 'edit'; $focus->retrieve_entity_info($this->_id, $this->getModuleName()); $this->_data = $focus->column_fields; /* both values are irrelevant use ->id and ->getModuleName() */ unset($this->_data['record_id']); unset($this->_data['record_module']); $current_user = $oldCurrentUser; } catch (Exception $exp) { $current_user = $oldCurrentUser; if ($exp->getCode() == "DATABASE_QUERY_ERROR") { global $adb; $handleResult = $this->_handleDatabaseError($adb->database->_errorMsg); $this->_data = array(); } elseif ($exp->getCode() == "ACCESS_DENIED" && $exp->getMessage() == "Permission to perform the operation is denied") { $sql = "SELECT setype FROM vtiger_crmentity WHERE crmid = " . $this->_id; $checkTMP = $adb->query($sql); if ($adb->num_rows($checkTMP) == 0) { #Workflow2::error_handler(E_NONBREAK_ERROR, "Record ".$this->_id." don't exist in the database. Maybe you try to load data from a group?", $exp->getFile(), $exp->getLine()); $this->_data = array(); return array(); } if ($adb->query_result($checkTMP, 0, "setype") != $this->getModuleName()) { throw new \Exception("You want to get a field from " . $this->getModuleName() . " Module, but the ID is from module " . $adb->query_result($checkTMP, 0, "setype") . "."); $this->_data = array(); return array(); } $entity = VTEntity::getForId($this->_id); #if(empty($entit)) #var_dump($this->getModuleName()); #var_dump($this->_id); } else { #error_log("ERROR RETRIEVE ".$this->getWsId()." ".$exp->getMessage()); throw new $exp(); } } $this->afterTransfer(); if ($this->_moduleName == "Emails") { require_once "include/Zend/Json.php"; \Zend_Json::$useBuiltinEncoderDecoder = false; $sql = "SELECT * FROM vtiger_emaildetails WHERE emailid = " . $this->getId(); $result = $adb->query($sql); $to_email = $adb->query_result($result, 0, "to_email"); #if(VtUtils::is_utf8($to_email)) $to_email = utf8_encode($to_email); $this->_data["saved_to"] = implode(",", \Zend_Json::decode(html_entity_decode($to_email))); $this->_data["from_email"] = $adb->query_result($result, 0, "from_email"); } // Fix for vtiger bug if ($this->_moduleName == "SalesOrder" && $this->_data["enable_recurring"] == "0") { $this->_data["invoicestatus"] = "AutoCreated"; } } #return $this->_data->column_fields; return $this->_data; }