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

Merge branch 'RecycleBin_delte_Related' into 'master'

Fixes #1267 Deleteing comments and activites on record deletion

See merge request !592
parents 3e92d362 961a41c3
No related branches found
No related tags found
No related merge requests found
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,25 @@ class RecycleBin_Module_Model extends Vtiger_Module_Model {
$db->pquery($query, array($recordIds));
}
/**
* Function to remove emails related to given records
* @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