Ejemplo n.º 1
0
function getReadEntityIds($module)
{
    global $log;
    $log->debug("Entering getReadEntityIds(" . $module . ") method ...");
    global $current_user;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $tab_id = getTabid($module);
    if ($module == "Leads") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_leaddetails\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_leaddetails.leadid\n\t\t\tLEFT JOIN vtiger_groups\n                 ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0\n\t\t\tAND vtiger_leaddetails.converted = 0 ";
    } elseif ($module == "Accounts") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_account\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_account.accountid\n\t\t\tLEFT JOIN vtiger_groups\n                ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    } elseif ($module == "Potentials") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_potential\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_potential.potentialid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    } elseif ($module == "Contacts") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_contactdetails\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_contactdetails.contactid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    } elseif ($module == "Products") {
        $query = "SELECT DISTINCT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_products\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_products.productid\n\t\t\tLEFT JOIN vtiger_seproductsrel\n\t\t\t\tON vtiger_seproductsrel.productid = vtiger_products.productid\n\t\t\tWHERE vtiger_crmentity.deleted = 0\n\t\t\tAND (vtiger_seproductsrel.crmid IS NULL\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Leads') . ")\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Accounts') . ")\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Potentials') . ")\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Contacts') . ")) ";
    } elseif ($module == "PurchaseOrder") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_purchaseorder\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    } elseif ($module == "SalesOrder") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_salesorder\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid\n\t\t\tLEFT JOIN vtiger_groups\n                ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    } elseif ($module == "Invoice") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_invoice\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_invoice.invoiceid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    } elseif ($module == "Quotes") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t        FROM vtiger_quotes\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t        ON vtiger_crmentity.crmid = vtiger_quotes.quoteid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t        ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    } elseif ($module == "HelpDesk") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_troubletickets\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid";
        $query .= getNonAdminAccessControlQuery($module, $current_user);
        $query .= "WHERE vtiger_crmentity.deleted = 0 ";
    }
    $log->debug("Exiting getReadEntityIds method ...");
    return $query;
}
Ejemplo n.º 2
0
function getReadEntityIds($module)
{
    global $log;
    $log->debug("Entering getReadEntityIds(" . $module . ") method ...");
    global $current_user;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $tab_id = getTabid($module);
    if ($module == "Leads") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_leaddetails\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_leaddetails.leadid\n\t\t\tLEFT JOIN vtiger_groups\n                 ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0\n\t\t\tAND vtiger_leaddetails.converted = 0 ";
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "Accounts") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_account\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_account.accountid\n\t\t\tLEFT JOIN vtiger_groups\n                ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 ";
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "Potentials") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_potential\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_potential.potentialid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 ";
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "Contacts") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_contactdetails\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_contactdetails.contactid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 ";
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "Products") {
        $query = "SELECT DISTINCT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_products\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_products.productid\n\t\t\tLEFT JOIN vtiger_seproductsrel\n\t\t\t\tON vtiger_seproductsrel.productid = vtiger_products.productid\n\t\t\tWHERE vtiger_crmentity.deleted = 0\n\t\t\tAND (vtiger_seproductsrel.crmid IS NULL\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Leads') . ")\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Accounts') . ")\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Potentials') . ")\n\t\t\t\tOR vtiger_seproductsrel.crmid IN (" . getReadEntityIds('Contacts') . ")) ";
    }
    if ($module == "PurchaseOrder") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_purchaseorder\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 ";
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "SalesOrder") {
        //Query modified to sort by assigned to
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_salesorder\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid\n\t\t\tLEFT JOIN vtiger_groups\n                ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 " . $where;
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "Invoice") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_invoice\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_invoice.invoiceid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 " . $where;
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "Quotes") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t        FROM vtiger_quotes\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t        ON vtiger_crmentity.crmid = vtiger_quotes.quoteid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t        ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 " . $where;
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    if ($module == "HelpDesk") {
        $query = "SELECT vtiger_crmentity.crmid\n\t\t\tFROM vtiger_troubletickets\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tWHERE vtiger_crmentity.deleted = 0 " . $where;
        if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3) {
            $sec_parameter = getListViewSecurityParameter($module);
            $query .= $sec_parameter;
        }
    }
    $log->debug("Exiting getReadEntityIds method ...");
    return $query;
}