[Vtigercrm-commits] [vtiger development] #5251: Contact Assigned To Group Are Not Imported
vtiger development
vtiger-tickets at trac.vtiger.com
Wed Apr 2 11:31:41 EDT 2008
#5251: Contact Assigned To Group Are Not Imported
-------------------------+--------------------------------------------------
Reporter: prasad | Owner: developer
Type: defect | Status: new
Priority: unassigned | Milestone: 5.1.0
Component: vtigercrm | Version: 5.0.4
Resolution: | Keywords:
-------------------------+--------------------------------------------------
Comment (by prasad):
File: modules/Contacts/Contacts.php
In function get_contactsforol($user_name), the query is not taking care of
records assigned to the group to which user belongs:
{{{
$query = "select vtiger_contactdetails.contactid as id,
".implode(',',$column_table_lists)." from vtiger_contactdetails
inner join vtiger_crmentity on
vtiger_crmentity.crmid=vtiger_contactdetails.contactid
inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
left join vtiger_account on
vtiger_account.accountid=vtiger_contactdetails.accountid
left join vtiger_contactaddress on
vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
left join vtiger_contactsubdetails on
vtiger_contactsubdetails.contactsubscriptionid =
vtiger_contactdetails.contactid
LEFT JOIN vtiger_contactgrouprelation ON vtiger_contactdetails.contactid =
vtiger_contactgrouprelation.contactid
LEFT JOIN vtiger_groups ON vtiger_groups.groupname =
vtiger_contactgrouprelation.groupname
where vtiger_crmentity.deleted=0 and
vtiger_users.user_name='".$user_name."'";
}}}
I would like to suggest the following query instead:
{{{
$query = "(select vtiger_contactdetails.contactid as id,
".implode(',',$column_table_lists)." from vtiger_contactdetails
inner join vtiger_crmentity on
vtiger_crmentity.crmid=vtiger_contactdetails.contactid
inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
left join vtiger_account on
vtiger_account.accountid=vtiger_contactdetails.accountid
left join vtiger_contactaddress on
vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
left join vtiger_contactsubdetails on
vtiger_contactsubdetails.contactsubscriptionid =
vtiger_contactdetails.contactid
where vtiger_crmentity.deleted=0 and vtiger_users.user_name='$user_name')
union
(select vtiger_contactdetails.contactid as id,
".implode(',',$column_table_lists)."
from vtiger_contactdetails
inner join vtiger_crmentity on
vtiger_crmentity.crmid=vtiger_contactdetails.contactid
inner join vtiger_contactgrouprelation on vtiger_contactdetails.contactid
= vtiger_contactgrouprelation.contactid and
vtiger_contactgrouprelation.groupname in
(select groupname from vtiger_groups where groupid in (select groupid from
vtiger_user2role where userid in (select id from vtiger_users where
user_name = '$user_name'))) left join vtiger_account on
vtiger_account.accountid=vtiger_contactdetails.accountid
left join vtiger_contactaddress on
vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
left join vtiger_contactsubdetails on
vtiger_contactsubdetails.contactsubscriptionid =
vtiger_contactdetails.contactid
where vtiger_crmentity.deleted=0)";
}}}
--
Ticket URL: <http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/5251#comment:1>
vtiger development <http://trac.vtiger.com/>
vtigerCRM
More information about the vtigercrm-commits
mailing list