Skip to content
Snippets Groups Projects
Commit be13dffc authored by Uma's avatar Uma
Browse files

Fixes #1267 Record deletion will delete related emails and activites

parent 3e92d362
No related branches found
No related tags found
1 merge request!592Fixes #1267 Deleteing comments and activites on record deletion
No preview for this file type
......@@ -152,6 +152,7 @@ class RecycleBin_Module_Model extends Vtiger_Module_Model {
// Delete related mod comments
$this->deleteRelatedComments($recordIds);
$this->deleteRelatedEmails($recordIds);
// TODO - Remove records from module tables and other related stores.
$query = 'DELETE FROM vtiger_modtracker_basic WHERE crmid in(' . generateQuestionMarks($recordIds) . ')';
......@@ -256,4 +257,26 @@ class RecycleBin_Module_Model extends Vtiger_Module_Model {
$db->pquery($query, array($recordIds));
}
/**
* Function to remove emails related to given records
* NOTE : Still need to confirm
* @param type $recordIds
*/
public function deleteRelatedEmails($recordIds) {
$db = PearDatabase::getInstance();
/**
* we have to delete emails if email is related to any $recordIds and same email is
* not related to another record
*/
$query = "DELETE vtiger_crmentity.* FROM vtiger_crmentity INNER JOIN "
. "(SELECT vtiger_crmentity.crmid AS actid,vtiger_seactivityrel.crmid AS relid "
. "FROM vtiger_crmentity INNER JOIN vtiger_seactivityrel ON "
. "vtiger_seactivityrel.activityid=vtiger_crmentity.crmid "
. "GROUP BY vtiger_seactivityrel.activityid HAVING count(vtiger_seactivityrel.activityid) = 1)"
. " AS relationdata ON relationdata.actid=vtiger_crmentity.crmid "
. "WHERE relationdata.relid IN (" . generateQuestionMarks($recordIds) . ")";
$db->pquery($query, array($recordIds));
}
}
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