/** * Gets the value of the key . First it will check whether specified key is a property if not it * will get from normal data attribure from base class * @param <string> $key - property or key name * @return <object> */ public function get($key) { if (property_exists($this, $key)) { return $this->{$key}; } return parent::get($key); }
function get($key) { $value = parent::get($key); if ($key === 'content' && $_REQUEST['view'] == 'Detail') { return Vtiger_Functions::removeHtmlTags(array('link', 'style', 'a', 'img', 'script', 'base'), decode_html($value)); } if ($key === 'uid' || $key === 'content') { return decode_html($value); } return $value; }
public function saveRecord(Vtiger_Record_Model $recordModel) { $moduleName = $this->get('name'); $focus = CRMEntity::getInstance($moduleName); $fields = $focus->column_fields; foreach ($fields as $fieldName => $fieldValue) { $fieldValue = $recordModel->get($fieldName); if (is_array($fieldValue)) { $focus->column_fields[$fieldName] = $fieldValue; } else { if ($fieldValue !== null) { if (in_array($fieldName, array('header_content', 'content', 'footer_content'))) { $focus->column_fields[$fieldName] = $fieldValue; } else { $focus->column_fields[$fieldName] = decode_html($fieldValue); } } } } $focus->mode = $recordModel->get('mode'); $focus->id = $recordModel->getId(); $focus->save($moduleName); return $recordModel->setId($focus->id); }
/** * Function to set data of parent record model to this record * @param Vtiger_Record_Model $parentRecordModel * @return Inventory_Record_Model */ public function setParentRecordData(Vtiger_Record_Model $parentRecordModel) { $userModel = Users_Privileges_Model::getCurrentUserPrivilegesModel(); $moduleName = $parentRecordModel->getModuleName(); $data = array(); $fieldMappingList = $parentRecordModel->getInventoryMappingFields(); foreach ($fieldMappingList as $fieldMapping) { $parentField = $fieldMapping['parentField']; $inventoryField = $fieldMapping['inventoryField']; $fieldModel = Vtiger_Field_Model::getInstance($parentField, Vtiger_Module_Model::getInstance($moduleName)); if ($fieldModel->getPermissions()) { $data[$inventoryField] = $parentRecordModel->get($parentField); } else { $data[$inventoryField] = $fieldMapping['defaultValue']; } } return $this->setData($data); }
/** * Save attachments from the email and add it to the module record. * @global PearDataBase $db * @global String $root_directory * @param MailManager_Message_Model $mailrecord * @param String $basemodule * @param Vtiger_Record_Model $recordModel */ public function __SaveAttachements($mailrecord, $basemodule, $recordModel) { $db = PearDatabase::getInstance(); // If there is no attachments return if (!$mailrecord->_attachments) { return; } $userid = $recordModel->get('assigned_user_id'); $recordId = $recordModel->getId(); $setype = "{$basemodule} Attachment"; $date_var = $db->formatDate(date('YmdHis'), true); foreach ($mailrecord->_attachments as $filename => $filecontent) { if (empty($filecontent)) { continue; } $attachid = $db->getUniqueId('vtiger_crmentity'); $description = $filename; $usetime = $db->formatDate($date_var, true); $db->pquery("INSERT INTO vtiger_crmentity(crmid, smcreatorid, smownerid,\n\t\t\t\tmodifiedby, setype, description, createdtime, modifiedtime, presence, deleted)\n\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array($attachid, $userid, $userid, $userid, $setype, $description, $usetime, $usetime, 1, 0)); $issaved = $this->__SaveAttachmentFile($attachid, $filename, $filecontent); if ($issaved) { // To compute file size & type $attachRes = $db->pquery("SELECT * FROM vtiger_attachments WHERE attachmentsid = ?", array($attachid)); if ($db->num_rows($attachRes)) { $filePath = $db->query_result($attachRes, 0, 'path'); $completeFilePath = vglobal('root_directory') . $filePath . $attachid . '_' . $filename; if (file_exists($completeFilePath)) { $fileSize = filesize($completeFilePath); $mimetype = MailAttachmentMIME::detect($completeFilePath); } } // Link file attached to emails also, for it to appear on email's page if (!empty($recordId) && !empty($attachid)) { $this->relateAttachment($recordId, $attachid); } } } }
/** * Function to delete a given record model of the current module * @param Vtiger_Record_Model $recordModel */ public function deleteRecord($recordModel) { $moduleName = $this->get('name'); $focus = CRMEntity::getInstance($moduleName); $focus->trash($moduleName, $recordModel->getId()); if (method_exists($focus, 'transferRelatedRecords')) { if ($recordModel->get('transferRecordIDs')) { $focus->transferRelatedRecords($moduleName, $recordModel->get('transferRecordIDs'), $recordModel->getId()); } } }
/** * Function to delete a given record model of the current module * @param Vtiger_Record_Model $recordModel */ public function deleteRecord($recordModel) { $moduleName = $this->get('name'); $focus = CRMEntity::getInstance($moduleName); $focus->trash($moduleName, $recordModel->getId()); if (method_exists($focus, 'transferRelatedRecords')) { if ($recordModel->get('transferRecordIDs')) { $focus->transferRelatedRecords($moduleName, $recordModel->get('transferRecordIDs'), $recordModel->getId()); } } vimport('~~modules/com_vtiger_workflow/include.inc'); vimport('~~modules/com_vtiger_workflow/VTEntityMethodManager.inc'); $wfs = new VTWorkflowManager(PearDatabase::getInstance()); $workflows = $wfs->getWorkflowsForModule($moduleName, VTWorkflowManager::$ON_DELETE); if (count($workflows)) { $wsId = vtws_getWebserviceEntityId($moduleName, $recordModel->getId()); $entityCache = new VTEntityCache(Users_Record_Model::getCurrentUserModel()); $entityData = $entityCache->forId($wsId); foreach ($workflows as $id => $workflow) { if ($workflow->evaluate($entityCache, $entityData->getId())) { $workflow->performTasks($entityData); } } } }
function get($key) { $value = parent::get($key); if ($key === 'notecontent') { return decode_html($value); } return $value; }