Esempio n. 1
0
/**
 * Get module names for which sharing access can be controlled.
 * NOTE: Ignore the standard modules which is already handled.
 */
function vtlib_getModuleNameForSharing()
{
    global $adb;
    $std_modules = array('Calendar', 'Leads', 'Accounts', 'Contacts', 'Potentials', 'HelpDesk', 'Campaigns', 'Quotes', 'PurchaseOrder', 'SalesOrder', 'Invoice', 'Events');
    $modulesList = getSharingModuleList($std_modules);
    return $modulesList;
}
Esempio n. 2
0
/**
 * Get module names for which sharing access can be controlled.
 * NOTE: Ignore the standard modules which is already handled.
 */
function vtlib_getModuleNameForSharing()
{
    $adb = PearDatabase::getInstance();
    $std_modules = array('Calendar', 'Leads', 'Accounts', 'Contacts', 'HelpDesk', 'Campaigns', 'Events');
    $modulesList = getSharingModuleList($std_modules);
    return $modulesList;
}
/** Function to populate the read/wirte Sharing permissions data of user/groups for the specified user into the database 
 * @param $userid -- user id:: Type integer
 */
function populateSharingtmptables($userid)
{
    global $adb;
    checkFileAccessForInclusion('user_privileges/sharing_privileges_' . $userid . '.php');
    require 'user_privileges/sharing_privileges_' . $userid . '.php';
    //Deleting from the existing vtiger_tables
    $table_arr = array('vtiger_tmp_read_user_sharing_per', 'vtiger_tmp_write_user_sharing_per', 'vtiger_tmp_read_group_sharing_per', 'vtiger_tmp_write_group_sharing_per', 'vtiger_tmp_read_user_rel_sharing_per', 'vtiger_tmp_write_user_rel_sharing_per', 'vtiger_tmp_read_group_rel_sharing_per', 'vtiger_tmp_write_group_rel_sharing_per');
    foreach ($table_arr as $tabname) {
        $query = "delete from " . $tabname . " where userid=?";
        $adb->pquery($query, array($userid));
    }
    // Look up for modules for which sharing access is enabled.
    $sharingArray = array('Emails');
    $otherModules = getSharingModuleList();
    $sharingArray = array_merge($sharingArray, $otherModules);
    foreach ($sharingArray as $module) {
        $module_sharing_read_permvar = $module . '_share_read_permission';
        $module_sharing_write_permvar = $module . '_share_write_permission';
        populateSharingPrivileges('USER', $userid, $module, 'read', ${$module_sharing_read_permvar});
        populateSharingPrivileges('USER', $userid, $module, 'write', ${$module_sharing_write_permvar});
        populateSharingPrivileges('GROUP', $userid, $module, 'read', ${$module_sharing_read_permvar});
        populateSharingPrivileges('GROUP', $userid, $module, 'write', ${$module_sharing_write_permvar});
    }
    //Populating Values into the temp related sharing tables
    foreach ($related_module_share as $rel_tab_id => $tabid_arr) {
        $rel_tab_name = getTabname($rel_tab_id);
        foreach ($tabid_arr as $taid) {
            $tab_name = getTabname($taid);
            $relmodule_sharing_read_permvar = $tab_name . '_' . $rel_tab_name . '_share_read_permission';
            $relmodule_sharing_write_permvar = $tab_name . '_' . $rel_tab_name . '_share_write_permission';
            populateRelatedSharingPrivileges('USER', $userid, $tab_name, $rel_tab_name, 'read', ${$relmodule_sharing_read_permvar});
            populateRelatedSharingPrivileges('USER', $userid, $tab_name, $rel_tab_name, 'write', ${$relmodule_sharing_write_permvar});
            populateRelatedSharingPrivileges('GROUP', $userid, $tab_name, $rel_tab_name, 'read', ${$relmodule_sharing_read_permvar});
            populateRelatedSharingPrivileges('GROUP', $userid, $tab_name, $rel_tab_name, 'write', ${$relmodule_sharing_write_permvar});
        }
    }
}
Esempio n. 4
0
/** Function to check if the currently logged in user has Write Access due to Sharing for the specified record
 * @param $module -- Module Name:: Type varchar
 * @param $actionid -- Action Id:: Type integer
 * @param $recordid -- Record Id:: Type integer
 * @param $tabid -- Tab Id:: Type integer
 * @returns yes or no. If Yes means this action is allowed for the currently logged in user. If no means this action is not allowed for the currently logged in user
 */
function isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id)
{
    $log = vglobal('log');
    $log->debug("Entering isReadWritePermittedBySharing(" . $module . "," . $tabid . "," . $actionid . "," . $record_id . ") method ...");
    $adb = PearDatabase::getInstance();
    $current_user = vglobal('current_user');
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $ownertype = '';
    $ownerid = '';
    $sharePer = 'no';
    $sharingModuleList = getSharingModuleList();
    if (!in_array($module, $sharingModuleList)) {
        $sharePer = 'no';
        return $sharePer;
    }
    $recordOwnerArr = getRecordOwnerId($record_id);
    foreach ($recordOwnerArr as $type => $id) {
        $ownertype = $type;
        $ownerid = $id;
    }
    $varname = $module . "_share_write_permission";
    $write_per_arr = ${$varname};
    if ($ownertype == 'Users') {
        //Checking the Write Sharing Permission Array in Role Users
        $write_role_per = $write_per_arr['ROLE'];
        foreach ($write_role_per as $roleid => $userids) {
            if (in_array($ownerid, $userids)) {
                $sharePer = 'yes';
                $log->debug("Exiting isReadWritePermittedBySharing method ...");
                return $sharePer;
            }
        }
        //Checking the Write Sharing Permission Array in Groups Users
        $write_grp_per = $write_per_arr['GROUP'];
        foreach ($write_grp_per as $grpid => $userids) {
            if (in_array($ownerid, $userids)) {
                $sharePer = 'yes';
                $log->debug("Exiting isReadWritePermittedBySharing method ...");
                return $sharePer;
            }
        }
    } elseif ($ownertype == 'Groups') {
        $write_grp_per = $write_per_arr['GROUP'];
        if (array_key_exists($ownerid, $write_grp_per)) {
            $sharePer = 'yes';
            $log->debug("Exiting isReadWritePermittedBySharing method ...");
            return $sharePer;
        }
    }
    //Checking for the Related Sharing Permission
    $relatedModuleArray = $related_module_share[$tabid];
    if (is_array($relatedModuleArray)) {
        foreach ($relatedModuleArray as $parModId) {
            $parRecordOwner = getParentRecordOwner($tabid, $parModId, $record_id);
            if (sizeof($parRecordOwner) > 0) {
                $parModName = getTabname($parModId);
                $rel_var = $parModName . "_" . $module . "_share_write_permission";
                $write_related_per_arr = ${$rel_var};
                $rel_owner_type = '';
                $rel_owner_id = '';
                foreach ($parRecordOwner as $rel_type => $rel_id) {
                    $rel_owner_type = $rel_type;
                    $rel_owner_id = $rel_id;
                }
                if ($rel_owner_type == 'Users') {
                    //Checking in Role Users
                    $write_related_role_per = $write_related_per_arr['ROLE'];
                    foreach ($write_related_role_per as $roleid => $userids) {
                        if (in_array($rel_owner_id, $userids)) {
                            $sharePer = 'yes';
                            $log->debug("Exiting isReadWritePermittedBySharing method ...");
                            return $sharePer;
                        }
                    }
                    //Checking in Group Users
                    $write_related_grp_per = $write_related_per_arr['GROUP'];
                    foreach ($write_related_grp_per as $grpid => $userids) {
                        if (in_array($rel_owner_id, $userids)) {
                            $sharePer = 'yes';
                            $log->debug("Exiting isReadWritePermittedBySharing method ...");
                            return $sharePer;
                        }
                    }
                } elseif ($rel_owner_type == 'Groups') {
                    $write_related_grp_per = $write_related_per_arr['GROUP'];
                    if (array_key_exists($rel_owner_id, $write_related_grp_per)) {
                        $sharePer = 'yes';
                        $log->debug("Exiting isReadWritePermittedBySharing method ...");
                        return $sharePer;
                    }
                }
            }
        }
    }
    $log->debug("Exiting isReadWritePermittedBySharing method ...");
    return $sharePer;
}
<?php

require_once 'include/database/PearDatabase.php';
require_once 'include/utils/UserInfoUtil.php';
require_once 'include/utils/utils.php';
global $mod_strings;
global $app_strings;
global $app_list_strings;
global $adb;
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$field_module = getSharingModuleList();
$allfields = array();
foreach ($field_module as $fld_module) {
    $fieldListResult = getDefOrgFieldList($fld_module);
    $noofrows = $adb->num_rows($fieldListResult);
    $language_strings = return_module_language($current_language, $fld_module);
    $allfields[$fld_module] = getStdOutput($fieldListResult, $noofrows, $language_strings, $profileid);
}
if ($_REQUEST['fld_module'] != '') {
    $smarty->assign("DEF_MODULE", $_REQUEST['fld_module']);
} else {
    $smarty->assign("DEF_MODULE", 'Leads');
}
/** Function to get the field label/permission array to construct the default orgnization field UI for the specified profile 
 * @param $fieldListResult -- mysql query result that contains the field label and uitype:: Type array
 * @param $mod_strings -- i18n language mod strings array:: Type array
 * @param $profileid -- profile id:: Type integer
 * @returns $standCustFld -- field label/permission array :: Type varchar
 *
//$custom_access['Emails'] = getSharingRuleList('Emails');
//Campaign Sharing
$custom_access['Campaigns'] = getSharingRuleList('Campaigns');
//Quotes Sharing
$custom_access['Quotes'] = getSharingRuleList('Quotes');
//Purchase Order Sharing
$custom_access['PurchaseOrder'] = getSharingRuleList('PurchaseOrder');
//Sales Order Sharing
$custom_access['SalesOrder'] = getSharingRuleList('SalesOrder');
//Invoice Sharing
$custom_access['Invoice'] = getSharingRuleList('Invoice');
//Document Sharing
$custom_access['Documents'] = getSharingRuleList('Documents');
// Look up for modules for which sharing access is enabled.
// NOTE: Accounts and Contacts has been couple, so we need to elimiate Contacts also
$othermodules = getSharingModuleList(array('Contacts'));
if (!empty($othermodules)) {
    foreach ($othermodules as $moduleresname) {
        if (!isset($custom_access[$moduleresname])) {
            $custom_access[$moduleresname] = getSharingRuleList($moduleresname);
        }
    }
}
uksort($custom_access, function ($a, $b) {
    return strtolower(getTranslatedString($a, $a)) < strtolower(getTranslatedString($b, $b)) ? -1 : 1;
});
$smarty->assign("MODSHARING", $custom_access);
/** returns the list of sharing rules for the specified module
 * @param $module -- Module Name:: Type varchar
 * @returns $access_permission -- sharing rules list info array:: Type array
 *