[Vtigercrm-commits] [vtiger-commits] r10845 - in /vtigercrm/branches/5.0.3/modules: Accounts/Merge.php Contacts/Merge.php HelpDesk/Merge.php Leads/Merge.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu May 10 18:14:53 EDT 2007
Author: jerrydgeorge
Date: Thu May 10 16:14:33 2007
New Revision: 10845
Log:
Field Level Security implemented in Merge.Fixes #3790
Modified:
vtigercrm/branches/5.0.3/modules/Accounts/Merge.php
vtigercrm/branches/5.0.3/modules/Contacts/Merge.php
vtigercrm/branches/5.0.3/modules/HelpDesk/Merge.php
vtigercrm/branches/5.0.3/modules/Leads/Merge.php
Modified: vtigercrm/branches/5.0.3/modules/Accounts/Merge.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Accounts/Merge.php (original)
+++ vtigercrm/branches/5.0.3/modules/Accounts/Merge.php Thu May 10 16:14:33 2007
@@ -94,7 +94,20 @@
//End setting vtiger_accountid=0 for the contacts which are deleted
//<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 6 and vtiger_field.block <> 75 order by vtiger_field.tablename";
+global $current_user;
+require('user_privileges/user_privileges_'.$current_user->id.'.php');
+if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users" || $module == "Emails")
+{
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 75 order by vtiger_field.tablename";
+}
+else
+{
+ $profileList = getCurrentUserProfileList();
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 75 AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList." GROUP BY vtiger_field.fieldid order by vtiger_field.tablename";
+ //Postgres 8 fixes
+ if( $adb->dbType == "pgsql")
+ $sql = fixPostgresQuery( $sql, $log, 0);
+}
$result = $adb->query($query1);
$y=$adb->num_rows($result);
@@ -172,6 +185,7 @@
left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+ left join vtiger_customerdetails on vtiger_contactdetails.contactid = vtiger_customerdetails.customerid
left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid
left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid
Modified: vtigercrm/branches/5.0.3/modules/Contacts/Merge.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Contacts/Merge.php (original)
+++ vtigercrm/branches/5.0.3/modules/Contacts/Merge.php Thu May 10 16:14:33 2007
@@ -78,36 +78,49 @@
}
//<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 6 and vtiger_field.block <> 75 order by vtiger_field.tablename";
-
+
+global $current_user;
+require('user_privileges/user_privileges_'.$current_user->id.'.php');
+if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users" || $module == "Emails")
+{
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 75 order by vtiger_field.tablename";
+}
+else
+{
+ $profileList = getCurrentUserProfileList();
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 75 AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList." GROUP BY vtiger_field.fieldid order by vtiger_field.tablename";
+ //Postgres 8 fixes
+ if( $adb->dbType == "pgsql")
+ $sql = fixPostgresQuery( $sql, $log, 0);
+}
$result = $adb->query($query1);
$y=$adb->num_rows($result);
for ($x=0; $x<$y; $x++)
{
- $tablename = $adb->query_result($result,$x,"tablename");
- $columnname = $adb->query_result($result,$x,"columnname");
- $modulename = $adb->query_result($result,$x,"name");
-
+ $tablename = $adb->query_result($result,$x,"tablename");
+ $columnname = $adb->query_result($result,$x,"columnname");
+ $modulename = $adb->query_result($result,$x,"name");
+
if($tablename == "crmentity")
- {
- if($modulename == "Accounts")
- {
- $tablename = "crmentityAccounts";
- }
- }
- $querycolumns[$x] = $tablename.".".$columnname;
- if($columnname == "smownerid")
- {
- if($modulename == "Accounts")
- {
+ {
+ if($modulename == "Accounts")
+ {
+ $tablename = "crmentityAccounts";
+ }
+ }
+ $querycolumns[$x] = $tablename.".".$columnname;
+ if($columnname == "smownerid")
+ {
+ if($modulename == "Accounts")
+ {
$querycolumns[$x]="concat(usersAccounts.last_name,' ',usersAccounts.first_name) as username";
- }
+ }
if($modulename == "Contacts")
- {
- $querycolumns[$x]="concat(vtiger_users.last_name,' ',vtiger_users.first_name) as usercname,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
- }
- }
+ {
+ $querycolumns[$x]="concat(vtiger_users.last_name,' ',vtiger_users.first_name) as usercname,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
+ }
+ }
if($columnname == "parentid")
{
$querycolumns[$x] = "accountAccounts.accountname";
@@ -120,23 +133,23 @@
{
$querycolumns[$x] = "contactdetailsContacts.lastname";
}
-
-
+
+
if($modulename == "Accounts")
- {
- $field_label[$x] = "ACCOUNT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
- }
-
+ {
+ $field_label[$x] = "ACCOUNT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
+ }
+
if($modulename == "Contacts")
- {
- $field_label[$x] = "CONTACT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
- if($columnname == "smownerid")
- {
- $field_label[$x] = $field_label[$x].",USER_FIRSTNAME,USER_LASTNAME,USER_USERNAME,USER_YAHOOID,USER_TITLE,USER_OFFICEPHONE,USER_DEPARTMENT,USER_MOBILE,USER_OTHERPHONE,USER_FAX,USER_EMAIL,USER_HOMEPHONE,USER_OTHEREMAIL,USER_PRIMARYADDRESS,USER_CITY,USER_STATE,USER_POSTALCODE,USER_COUNTRY";
- }
- }
-
-
+ {
+ $field_label[$x] = "CONTACT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
+ if($columnname == "smownerid")
+ {
+ $field_label[$x] = $field_label[$x].",USER_FIRSTNAME,USER_LASTNAME,USER_USERNAME,USER_YAHOOID,USER_TITLE,USER_OFFICEPHONE,USER_DEPARTMENT,USER_MOBILE,USER_OTHERPHONE,USER_FAX,USER_EMAIL,USER_HOMEPHONE,USER_OTHEREMAIL,USER_PRIMARYADDRESS,USER_CITY,USER_STATE,USER_POSTALCODE,USER_COUNTRY";
+ }
+ }
+
+
}
$csvheader = implode(",",$field_label);
//echo $csvheader;
@@ -152,6 +165,7 @@
inner join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
inner join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
inner join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+ inner join vtiger_customerdetails on vtiger_contactdetails.contactid = vtiger_customerdetails.customerid
left join vtiger_contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
left join vtiger_account as accountContacts on accountContacts.accountid = vtiger_contactdetails.accountid
left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
Modified: vtigercrm/branches/5.0.3/modules/HelpDesk/Merge.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/HelpDesk/Merge.php (original)
+++ vtigercrm/branches/5.0.3/modules/HelpDesk/Merge.php Thu May 10 16:14:33 2007
@@ -72,8 +72,21 @@
}
//<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (13,4,6) and vtiger_field.uitype <> 61 and (vtiger_field.tablename <>'CustomerDetails' and block <> 6 and block <> 75) and block <> 30 order by vtiger_field.tablename";
-
+
+global $current_user;
+require('user_privileges/user_privileges_'.$current_user->id.'.php');
+if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users" || $module == "Emails")
+{
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (13,4,6) and vtiger_field.uitype <> 61 and block <> 75 and block <> 30 order by vtiger_field.tablename";
+}
+else
+{
+ $profileList = getCurrentUserProfileList();
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid in (13,4,6) and vtiger_field.uitype <> 61 and block <> 75 and block <> 30 AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList." GROUP BY vtiger_field.fieldid order by vtiger_field.tablename";
+ //Postgres 8 fixes
+ if( $adb->dbType == "pgsql")
+ $sql = fixPostgresQuery( $sql, $log, 0);
+}
$result = $adb->query($query1);
$y=$adb->num_rows($result);
@@ -183,6 +196,7 @@
left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
+ left join vtiger_customerdetails on vtiger_contactdetails.contactid = vtiger_customerdetails.customerid
left join vtiger_contactdetails as contactdetailsContacts on contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
left join vtiger_account as accountContacts on accountContacts.accountid = vtiger_contactdetails.accountid
left join vtiger_users as usersContacts on usersContacts.id = crmentityContacts.smownerid
Modified: vtigercrm/branches/5.0.3/modules/Leads/Merge.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Leads/Merge.php (original)
+++ vtigercrm/branches/5.0.3/modules/Leads/Merge.php Thu May 10 16:14:33 2007
@@ -75,7 +75,22 @@
}
//<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select tablename,columnname,fieldlabel from vtiger_field where tabid=7 order by tablename";
+
+global $current_user;
+require('user_privileges/user_privileges_'.$current_user->id.'.php');
+if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users" || $module == "Emails")
+{
+ $query1="select tablename,columnname,fieldlabel from vtiger_field where tabid=7 order by tablename";
+}
+else
+{
+ $profileList = getCurrentUserProfileList();
+ $query1="select vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid in (7) AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN ".$profileList." GROUP BY vtiger_field.fieldid order by vtiger_field.tablename";
+ //Postgres 8 fixes
+ if( $adb->dbType == "pgsql")
+ $sql = fixPostgresQuery( $sql, $log, 0);
+}
+
$result = $adb->query($query1);
$y=$adb->num_rows($result);
More information about the vtigercrm-commits
mailing list