Skip to content
Snippets Groups Projects
Commit 7d9eb59a authored by Prasad's avatar Prasad
Browse files

Merge branch '158706732' into 'master'

Fixes: Setting default values to save automatically with the record when it's saved from quick create

See merge request vtiger/vtigercrm!1110
parents 4467a935 102db66d
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment