예제 #1
0
파일: Utils.php 프로젝트: kduqi/corebos
function vtws_getUserAccessibleGroups($moduleId, $user)
{
    global $adb;
    require 'user_privileges/user_privileges_' . $user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $user->id . '.php';
    $tabName = getTabname($moduleId);
    if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[$moduleId] == 3 or $defaultOrgSharingPermission[$moduleId] == 0)) {
        $result = get_current_user_access_groups($tabName);
    } else {
        $result = get_group_options();
    }
    $groups = array();
    if ($result != null && $result != '' && is_object($result)) {
        $rowCount = $adb->num_rows($result);
        for ($i = 0; $i < $rowCount; $i++) {
            $nameArray = $adb->query_result_rowdata($result, $i);
            $groupId = $nameArray["groupid"];
            $groupName = $nameArray["groupname"];
            $groups[] = array('id' => $groupId, 'name' => $groupName);
        }
    }
    return $groups;
}
예제 #2
0
 protected function setupTemporaryTable($tableName, $tabId, $user, $parentRole, $userGroups)
 {
     $module = null;
     if (!empty($tabId)) {
         $module = getTabname($tabId);
     }
     $query = $this->getNonAdminAccessQuery($module, $user, $parentRole, $userGroups);
     $query = "create temporary table IF NOT EXISTS {$tableName}(id int(11) primary key, shared " . "int(1) default 0) ignore " . $query;
     $db = PearDatabase::getInstance();
     $result = $db->pquery($query, array());
     if (is_object($result)) {
         $query = "create temporary table IF NOT EXISTS {$tableName}(id int(11) primary key, shared " . "int(1) default 0) replace select 1, userid as id from vtiger_sharedcalendar where " . "sharedid = {$user->id}";
         $result = $db->pquery($query, array());
         if (is_object($result)) {
             return true;
         }
     }
     return false;
 }
예제 #3
0
function getRelatedListInfo($module)
{
    global $adb;
    $tabid = getTabid($module);
    $related_query = 'select * from vtiger_relatedlists ' . 'inner join vtiger_tab on vtiger_relatedlists.related_tabid = vtiger_tab.tabid and vtiger_tab.presence = 0 where vtiger_relatedlists.tabid = ? order by sequence';
    $relinfo = $adb->pquery($related_query, array($tabid));
    $noofrows = $adb->num_rows($relinfo);
    for ($i = 0; $i < $noofrows; $i++) {
        $res[$i]['name'] = $adb->query_result($relinfo, $i, 'name');
        $res[$i]['sequence'] = $adb->query_result($relinfo, $i, 'sequence');
        $label = $adb->query_result($relinfo, $i, 'label');
        $relatedModule = getTabname($adb->query_result($relinfo, $i, 'related_tabid'));
        $res[$i]['label'] = getTranslatedString($label, $relatedModule);
        $res[$i]['presence'] = $adb->query_result($relinfo, $i, 'presence');
        $res[$i]['tabid'] = $tabid;
        $res[$i]['id'] = $adb->query_result($relinfo, $i, 'relation_id');
    }
    return $res;
}
예제 #4
0
파일: utils.php 프로젝트: yunter/crm
/** Function to get parent record owner
 * @param $tabid -- tabid :: Type integer
 * @param $parModId -- parent module id :: Type integer
 * @param $record_id -- record id :: Type integer
 * @returns $parentRecOwner -- parentRecOwner:: Type integer
 */
function getParentRecordOwner($tabid, $parModId, $record_id)
{
    global $log;
    $log->debug("Entering getParentRecordOwner(" . $tabid . "," . $parModId . "," . $record_id . ") method ...");
    $parentRecOwner = array();
    $parentTabName = getTabname($parModId);
    $relTabName = getTabname($tabid);
    $fn_name = "get" . $relTabName . "Related" . $parentTabName;
    $ent_id = $fn_name($record_id);
    if ($ent_id != '') {
        $parentRecOwner = getRecordOwnerId($ent_id);
    }
    $log->debug("Exiting getParentRecordOwner method ...");
    return $parentRecOwner;
}
/** 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});
        }
    }
}
예제 #6
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;
}
예제 #7
0
 protected function setupTemporaryTable($tableName, $tabId, $user, $parentRole, $userGroups)
 {
     $module = null;
     if (!empty($tabId)) {
         $module = getTabname($tabId);
     }
     $query = $this->getNonAdminAccessQuery($module, $user, $parentRole, $userGroups);
     $query = "create temporary table IF NOT EXISTS {$tableName}(id int(11) primary key, shared " . "int(1) default 0) ignore " . $query;
     $db = PearDatabase::getInstance();
     $result = $db->pquery($query, array());
     if (is_object($result)) {
         $query = "REPLACE INTO {$tableName} (id) SELECT userid as id FROM vtiger_sharedcalendar WHERE sharedid = ?";
         $result = $db->pquery($query, array($user->id));
         //For newly created users, entry will not be there in vtiger_sharedcalendar table
         //so, consider the users whose having the calendarsharedtype is public
         $query = "REPLACE INTO {$tableName} (id) SELECT id FROM vtiger_users WHERE calendarsharedtype = ?";
         $result = $db->pquery($query, array('public'));
         if (is_object($result)) {
             return true;
         }
     }
     return false;
 }
예제 #8
0
function setupCalendar4YouTemporaryTable($tableName, $tabId, $userid, $parentRole, $userGroups)
{
    global $adb;
    $module = null;
    if (!empty($tabId)) {
        $module = getTabname($tabId);
    }
    $query = getCalendar4YouNonAdminAccessQuery($module, $userid, $parentRole, $userGroups);
    $query = "create temporary table IF NOT EXISTS {$tableName}(id int(11) primary key, shared " . "int(1) default 0) ignore " . $query;
    $result = $adb->pquery($query, array());
    if (is_object($result)) {
        $query = "create temporary table IF NOT EXISTS {$tableName}(id int(11) primary key, shared " . "int(1) default 0) replace select 1, userid as id from vtiger_sharedcalendar where " . "sharedid = {$userid}";
        $result = $adb->pquery($query, array());
        if (is_object($result)) {
            return true;
        }
    }
    return false;
}
require_once 'include/utils/utils.php';
require_once 'include/utils/UserInfoUtil.php';
global $mod_strings;
global $app_strings;
global $app_list_strings;
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty = new vtigerCRM_Smarty();
$defSharingPermissionData = getDefaultSharingAction();
$access_privileges = array();
$row = 1;
foreach ($defSharingPermissionData as $tab_id => $def_perr) {
    $entity_name = getTabname($tab_id);
    if ($tab_id == 6) {
        $cont_name = getTabname(4);
        $entity_name .= ' & ' . $cont_name;
    }
    $entity_perr = getDefOrgShareActionName($def_perr);
    $access_privileges[] = $entity_name;
    $access_privileges[] = $entity_perr;
    if ($entity_perr != 'Private') {
        $access_privileges[] = $mod_strings['LBL_DESCRIPTION_' . $entity_perr] . $app_strings[$entity_name];
    } else {
        $access_privileges[] = $mod_strings['LBL_USR_CANNOT_ACCESS'] . $app_strings[$entity_name];
    }
    $row++;
}
$access_privileges = array_chunk($access_privileges, 3);
usort($access_privileges, function ($a, $b) {
    $moda = $a[0] == 'Accounts & Contacts' ? 'Accounts' : $a[0];
예제 #10
0
            foreach ($action_array as $action_id => $act_per) {
                $action_name = getActionname($action_id);
                $tab_util_act_per = $action_array[$action_id];
                $tab_util_per = getDisplayOutput($tab_util_act_per, $tabid, $action_id);
                $util[] = $action_name;
                $util[] = $tab_util_per;
            }
            $util = array_chunk($util, 2);
            $util = array_chunk($util, 3);
            $privilege_util[$tabid] = $util;
        }
    } else {
        $act_utility_arry = getTabsUtilityActionPermission(1);
        foreach ($act_utility_arry as $tabid => $action_array) {
            $util = array();
            $entity_name = getTabname($tabid);
            $no_of_actions = sizeof($action_array);
            foreach ($action_array as $action_id => $act_per) {
                $action_name = getActionname($action_id);
                $tab_util_act_per = $action_array[$action_id];
                $tab_util_per = getDisplayOutput(0, $tabid, $action_id);
                $util[] = $action_name;
                $util[] = $tab_util_per;
            }
            $util = array_chunk($util, 2);
            $util = array_chunk($util, 3);
            $privilege_util[$tabid] = $util;
        }
    }
}
$smarty->assign("UTILITIES_PRIV", $privilege_util);