Example #1
0
/** Function to check if the outlook user is permitted to perform the specified action
 * @param $module -- Module Name:: Type varchar
 * @param $actionname -- Action Name:: Type varchar
 * @param $recordid -- Record 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 isAllowed_Outlook($module, $action, $user_id, $record_id)
{
    global $log;
    $log->debug("Entering isAllowed_Outlook(" . $module . "," . $action . "," . $user_id . "," . $record_id . ") method ...");
    $permission = "no";
    if ($module == 'Users' || $module == 'Home' || $module == 'Administration' || $module == 'uploads' || $module == 'Settings' || $module == 'Calendar') {
        //These modules done have security
        $permission = "yes";
    } else {
        global $adb;
        global $current_user;
        $tabid = getTabid($module);
        $actionid = getActionid($action);
        $profile_id = fetchUserProfileId($user_id);
        $tab_per_Data = getAllTabsPermission($profile_id);
        $permissionData = getTabsActionPermission($profile_id);
        $defSharingPermissionData = getDefaultSharingAction();
        $others_permission_id = $defSharingPermissionData[$tabid];
        //Checking whether this vtiger_tab is allowed
        if ($tab_per_Data[$tabid] == 0) {
            $permission = 'yes';
            //Checking whether this action is allowed
            if ($permissionData[$tabid][$actionid] == 0) {
                $permission = 'yes';
                $rec_owner_id = '';
                if ($record_id != '' && $module != 'Faq') {
                    $rec_owner_id = getUserId($record_id);
                }
                if ($record_id != '' && $others_permission_id != '' && $module != 'Faq' && $rec_owner_id != 0) {
                    if ($rec_owner_id != $current_user->id) {
                        if ($others_permission_id == 0) {
                            if ($action == 'EditView' || $action == 'Delete') {
                                $permission = "no";
                            } else {
                                $permission = "yes";
                            }
                        } elseif ($others_permission_id == 1) {
                            if ($action == 'Delete') {
                                $permission = "no";
                            } else {
                                $permission = "yes";
                            }
                        } elseif ($others_permission_id == 2) {
                            $permission = "yes";
                        } elseif ($others_permission_id == 3) {
                            if ($action == 'DetailView' || $action == 'EditView' || $action == 'Delete') {
                                $permission = "no";
                            } else {
                                $permission = "yes";
                            }
                        }
                    } else {
                        $permission = "yes";
                    }
                }
            } else {
                $permission = "no";
            }
        } else {
            $permission = "no";
        }
    }
    $log->debug("Exiting isAllowed_Outlook method ...");
    return $permission;
}
/** Creates a file with all the user, user-role,user-profile, user-groups informations 
 * @param $userid -- user id:: Type integer
 * @returns user_privileges_userid file under the user_privileges directory
 */
function createUserPrivilegesfile($userid)
{
    global $root_directory;
    $handle = @fopen($root_directory . 'user_privileges/user_privileges_' . $userid . '.php', "w+");
    if ($handle) {
        $newbuf = '';
        $newbuf .= "<?php\n\n";
        $newbuf .= "\n";
        $newbuf .= "//This is the access privilege file\n";
        $user_focus = new Users();
        $user_focus->retrieve_entity_info($userid, "Users");
        $userInfo = array();
        $user_focus->column_fields["id"] = '';
        $user_focus->id = $userid;
        foreach ($user_focus->column_fields as $field => $value_iter) {
            $userInfo[$field] = $user_focus->{$field};
        }
        if ($user_focus->is_admin == 'on') {
            $newbuf .= "\$is_admin=true;\n";
            $newbuf .= "\n";
            $newbuf .= "\$user_info=" . constructSingleStringKeyValueArray($userInfo) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "?>";
            fputs($handle, $newbuf);
            fclose($handle);
            return;
        } else {
            $newbuf .= "\$is_admin=false;\n";
            $newbuf .= "\n";
            $globalPermissionArr = getCombinedUserGlobalPermissions($userid);
            $tabsPermissionArr = getCombinedUserTabsPermissions($userid);
            //$tabsPermissionArr=getCombinedUserTabsPermissions($userid);
            $actionPermissionArr = getCombinedUserActionPermissions($userid);
            $user_role = fetchUserRole($userid);
            $user_role_info = getRoleInformation($user_role);
            $user_role_parent = $user_role_info[$user_role][1];
            $userGroupFocus = new GetUserGroups();
            $userGroupFocus->getAllUserGroups($userid);
            $subRoles = getRoleSubordinates($user_role);
            $subRoleAndUsers = getSubordinateRoleAndUsers($user_role);
            $def_org_share = getDefaultSharingAction();
            $parentRoles = getParentRole($user_role);
            $newbuf .= "\$current_user_roles='" . $user_role . "';\n";
            $newbuf .= "\n";
            $newbuf .= "\$current_user_parent_role_seq='" . $user_role_parent . "';\n";
            $newbuf .= "\n";
            $newbuf .= "\$current_user_profiles=" . constructSingleArray(getUserProfile($userid)) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$profileGlobalPermission=" . constructArray($globalPermissionArr) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$profileTabsPermission=" . constructArray($tabsPermissionArr) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$profileActionPermission=" . constructTwoDimensionalArray($actionPermissionArr) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$current_user_groups=" . constructSingleArray($userGroupFocus->user_groups) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$subordinate_roles=" . constructSingleCharArray($subRoles) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$parent_roles=" . constructSingleCharArray($parentRoles) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$subordinate_roles_users=" . constructTwoDimensionalCharIntSingleArray($subRoleAndUsers) . ";\n";
            $newbuf .= "\n";
            $newbuf .= "\$user_info=" . constructSingleStringKeyValueArray($userInfo) . ";\n";
            $newbuf .= "?>";
            fputs($handle, $newbuf);
            fclose($handle);
        }
    }
}
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ********************************************************************************/
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];