diff --git a/modules/Events/actions/SaveAjax.php b/modules/Events/actions/SaveAjax.php index f6bd8e50cd9b16c42e2bc9ee9ccb479f4c1944fa..59e24882cd5d7d216edabd04723b0e44d30e9af0 100644 --- a/modules/Events/actions/SaveAjax.php +++ b/modules/Events/actions/SaveAjax.php @@ -160,6 +160,27 @@ class Events_SaveAjax_Action extends Events_Save_Action { $this->setRecurrenceInfo($recordModel); } + // Setting default values to save automatically with the record when it's saved from quick create. + $moduleName = $request->getModule(); + $moduleModel = Vtiger_Module_Model::getInstance($moduleName); + $fieldModelList = $moduleModel->getFields(); + foreach ($fieldModelList as $fieldName => $fieldModel) { + + if ($request->has($fieldName)) { + $fieldValue = $request->get($fieldName, null); + } else { + $fieldValue = $fieldModel->getDefaultFieldValue(); + } + $fieldValue = $this->purifyCkeditorField($fieldName, $fieldValue); + if ($fieldValue !== null) { + if (!is_array($fieldValue)) { + $fieldValue = trim($fieldValue); + } + $fieldValue = Vtiger_Util_Helper::validateFieldValue($fieldValue, $fieldModel); + $recordModel->set($fieldName, $fieldValue); + } + } + $startDate = $request->get('date_start'); if (!empty($startDate)) { //Start Date and Time values @@ -214,4 +235,14 @@ class Events_SaveAjax_Action extends Events_Save_Action { return $recordModel; } + public function purifyCkeditorField($fieldName, $fieldValue) { + $ckeditorFields = array('commentcontent', 'notecontent', 'signature'); + if((in_array($fieldName, $ckeditorFields)) && $fieldValue !== null){ + $purifiedContent = vtlib_purify(decode_html($fieldValue)); + // Purify malicious html event attributes + $fieldValue = purifyHtmlEventAttributes(decode_html($purifiedContent),true); + } + return $fieldValue; + } + }