} else {
            $permission_value = 1;
        }
        $update_query = "update vtiger_profile2standardpermissions set permissions=? where tabid=? and Operation=? and profileid=?";
        $adb->pquery($update_query, array($permission_value, $tab_id, $action_id, $profileid));
        if ($tab_id == 9) {
            $update_query = "update vtiger_profile2standardpermissions set permissions=? where tabid=16 and Operation=? and profileid=?";
            $adb->pquery($update_query, array($permission_value, $action_id, $profileid));
        }
    }
}
//Update Profile 2 utility
for ($i = 0; $i < $num_act_util_per; $i++) {
    $tab_id = $adb->query_result($act_utility_result, $i, "tabid");
    $action_id = $adb->query_result($act_utility_result, $i, "activityid");
    $action_name = getActionname($action_id);
    $request_var = $tab_id . '_' . $action_name;
    $permission = $_REQUEST[$request_var];
    if ($permission == 'on') {
        $permission_value = 0;
    } else {
        $permission_value = 1;
    }
    $update_query = "update vtiger_profile2utility set permission=? where tabid=? and activityid=? and profileid=?";
    $adb->pquery($update_query, array($permission_value, $tab_id, $action_id, $profileid));
}
$modArr = getModuleAccessArray();
foreach ($modArr as $fld_module => $fld_label) {
    $fieldListResult = getProfile2FieldList($fld_module, $profileid);
    $noofrows = $adb->num_rows($fieldListResult);
    $tab_id = getTabid($fld_module);
Exemplo n.º 2
0
/** Function to check if the currently logged in 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 isPermitted($module, $actionname, $record_id = '')
{
    $log = vglobal('log');
    $log->debug("Entering isPermitted(" . $module . "," . $actionname . "," . $record_id . ") method ...");
    $adb = PearDatabase::getInstance();
    $current_user = vglobal('current_user');
    global $seclog;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $permission = 'no';
    if (($module == 'Users' || $module == 'Home' || $module == 'uploads') && $_REQUEST['parenttab'] != 'Settings') {
        //These modules dont have security right now
        $permission = 'yes';
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Checking the Access for the Settings Module
    if ($module == 'Settings' || $module == 'Administration' || $module == 'System' || $_REQUEST['parenttab'] == 'Settings') {
        if (!$is_admin) {
            $permission = 'no';
        } else {
            $permission = 'yes';
        }
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Retreiving the Tabid and Action Id
    $tabid = getTabid($module);
    $actionid = getActionid($actionname);
    $checkModule = $module;
    if ($checkModule == 'Events') {
        $checkModule = 'Calendar';
    }
    if (vtlib_isModuleActive($checkModule)) {
        //Checking whether the user is admin
        if ($is_admin) {
            $permission = 'yes';
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
        //If no actionid, then allow action is vtiger_tab permission is available
        if ($actionid === '') {
            if ($profileTabsPermission[$tabid] == 0) {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
            } else {
                $permission = 'no';
            }
            return $permission;
        }
        $action = getActionname($actionid);
        //Checking for view all permission
        if ($profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
            if ($actionid == 3 || $actionid == 4) {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        }
        //Checking for edit all permission
        if ($profileGlobalPermission[2] == 0) {
            if ($actionid == 3 || $actionid == 4 || $actionid == 0 || $actionid == 1) {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        }
        //Checking for vtiger_tab permission
        if ($profileTabsPermission[$tabid] != 0) {
            $permission = 'no';
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
        //Checking for Action Permission
        if (strlen($profileActionPermission[$tabid][$actionid]) < 1 && $profileActionPermission[$tabid][$actionid] == '') {
            $permission = 'yes';
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
        if ($profileActionPermission[$tabid][$actionid] != 0 && $profileActionPermission[$tabid][$actionid] != '') {
            $permission = 'no';
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
        //Checking and returning true if recorid is null
        if ($record_id == '') {
            $permission = 'yes';
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
        //If modules is Products,Vendors,Faq,PriceBook then no sharing
        if ($record_id != '') {
            if (getTabOwnedBy($module) == 1) {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        }
        //Retreiving the RecordOwnerId
        $recOwnType = '';
        $recOwnId = '';
        $recordOwnerArr = getRecordOwnerId($record_id);
        $shownerids = Vtiger_SharedOwner_UIType::getSharedOwners($record_id, $module);
        foreach ($recordOwnerArr as $type => $id) {
            $recOwnType = $type;
            $recOwnId = $id;
        }
        //Retreiving the default Organisation sharing Access
        $others_permission_id = $defaultOrgSharingPermission[$tabid];
        if (in_array($current_user->id, $shownerids) || count(array_intersect($shownerids, $current_user_groups)) > 0) {
            $permission = 'yes';
            $log->debug('Exiting isPermitted method ... - Shared Owner');
            return $permission;
        }
        if ($recOwnType == 'Users') {
            //Checking if the Record Owner is the current User
            if ($current_user->id == $recOwnId) {
                $permission = 'yes';
                $log->debug('Exiting isPermitted method ...');
                return $permission;
            }
            //Checking if the Record Owner is the Subordinate User
            foreach ($subordinate_roles_users as $roleid => $userids) {
                if (in_array($recOwnId, $userids)) {
                    $permission = 'yes';
                    $log->debug('Exiting isPermitted method ...');
                    return $permission;
                }
            }
        } elseif ($recOwnType == 'Groups') {
            //Checking if the record owner is the current user's group
            if (in_array($recOwnId, $current_user_groups)) {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        }
        $role = getRoleInformation($current_user->roleid);
        if (($actionid == 3 || $actionid == 4) && $role['previewrelatedrecord'] != 0 || ($actionid == 0 || $actionid == 1) && $role['editrelatedrecord'] != 0) {
            $parentRecord = Users_Privileges_Model::getParentRecord($record_id, $module, $role['previewrelatedrecord']);
            if ($parentRecord) {
                $recordMetaData = Vtiger_Functions::getCRMRecordMetadata($parentRecord);
                if ($role['permissionsrelatedfield'] == 0) {
                    $relatedPermission = $current_user->id == $recordMetaData['smownerid'];
                } else {
                    if ($role['permissionsrelatedfield'] == 1) {
                        $relatedPermission = in_array($current_user->id, Vtiger_SharedOwner_UIType::getSharedOwners($parentRecord, $recordMetaData['setype']));
                    } else {
                        if ($role['permissionsrelatedfield'] == 2) {
                            $relatedPermission = $current_user->id == $recordMetaData['smownerid'] || in_array($current_user->id, Vtiger_SharedOwner_UIType::getSharedOwners($parentRecord, $recordMetaData['setype']));
                        }
                    }
                }
                if ($relatedPermission) {
                    $permission = 'yes';
                    $log->debug('Exiting isPermitted method ... - Parent Record Owner');
                    return $permission;
                }
            }
        }
        //Checking for Default Org Sharing permission
        if ($others_permission_id == 0) {
            if ($actionid == 1 || $actionid == 0) {
                $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id);
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            } elseif ($actionid == 2) {
                $permission = 'no';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            } else {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        } elseif ($others_permission_id == 1) {
            if ($actionid == 2) {
                $permission = 'no';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            } else {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        } elseif ($others_permission_id == 2) {
            $permission = 'yes';
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } elseif ($others_permission_id == 3) {
            if ($actionid == 3 || $actionid == 4) {
                $permission = isReadPermittedBySharing($module, $tabid, $actionid, $record_id);
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            } elseif ($actionid == 0 || $actionid == 1) {
                if ($module == 'Calendar') {
                    $permission = 'no';
                } else {
                    $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id);
                }
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            } elseif ($actionid == 2) {
                $permission = 'no';
                return $permission;
            } else {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        } else {
            $permission = 'yes';
        }
    } else {
        $permission = 'no';
    }
    $log->debug("Exiting isPermitted method ...");
    return $permission;
}
Exemplo n.º 3
0
/** Function to check if the currently logged in 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 isPermitted($module, $actionname, $record_id = '')
{
    global $log;
    $log->debug("Entering isPermitted(" . $module . "," . $actionname . "," . $record_id . ") method ...");
    global $adb;
    global $current_user;
    global $seclog;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $parenttab = empty($_REQUEST['parenttab']) ? '' : vtlib_purify($_REQUEST['parenttab']);
    $permission = "no";
    if (($module == 'Users' || $module == 'Home' || $module == 'uploads') && $parenttab != 'Settings') {
        //These modules dont have security right now
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Checking the Access for the Settings Module
    if ($module == 'Settings' || $module == 'Administration' || $parenttab == 'Settings') {
        if (!$is_admin) {
            $permission = "no";
        } else {
            $permission = "yes";
        }
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Checking whether the user is admin
    if ($is_admin) {
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Retreiving the Tabid and Action Id
    $tabid = getTabid($module);
    $actionid = getActionid($actionname);
    //If no actionid, then allow action is vtiger_tab permission is available
    if ($actionid === '') {
        if ($profileTabsPermission[$tabid] == 0) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
        } else {
            $permission = "no";
        }
        return $permission;
    }
    $action = getActionname($actionid);
    //Checking for view all permission
    if ($profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
        if ($actionid == 3 || $actionid == 4) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Checking for edit all permission
    if ($profileGlobalPermission[2] == 0) {
        if ($actionid == 3 || $actionid == 4 || $actionid == 0 || $actionid == 1) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Checking for vtiger_tab permission
    if ($profileTabsPermission[$tabid] != 0) {
        $permission = "no";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    if (!isset($profileActionPermission[$tabid][$actionid]) && $action == 'Export') {
        return "no";
    }
    //Checking for Action Permission
    if (strlen($profileActionPermission[$tabid][$actionid]) < 1 && $profileActionPermission[$tabid][$actionid] == '') {
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    if ($profileActionPermission[$tabid][$actionid] != 0 && $profileActionPermission[$tabid][$actionid] != '') {
        $permission = "no";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Checking and returning true if recorid is null
    if ($record_id == '') {
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //If modules is Products,Vendors,Faq,PriceBook then no sharing
    if ($record_id != '') {
        if (getTabOwnedBy($module) == 1) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Retreiving the RecordOwnerId
    $recOwnType = '';
    $recOwnId = '';
    $recordOwnerArr = getRecordOwnerId($record_id);
    foreach ($recordOwnerArr as $type => $id) {
        $recOwnType = $type;
        $recOwnId = $id;
    }
    //Retreiving the default Organisation sharing Access
    $others_permission_id = $defaultOrgSharingPermission[$tabid];
    if ($recOwnType == 'Users') {
        //Checking if the Record Owner is the current User
        if ($current_user->id == $recOwnId) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
        //Checking if the Record Owner is the Subordinate User
        foreach ($subordinate_roles_users as $roleid => $userids) {
            if (in_array($recOwnId, $userids)) {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        }
    } elseif ($recOwnType == 'Groups') {
        //Checking if the record owner is the current user's group
        if (in_array($recOwnId, $current_user_groups)) {
            $permission = 'yes';
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Checking for Default Org Sharing permission
    if ($others_permission_id == 0) {
        if ($actionid == 1 || $actionid == 0) {
            if ($module == 'Calendar') {
                if ($recOwnType == 'Users') {
                    $permission = isCalendarPermittedBySharing($record_id);
                } else {
                    $permission = 'no';
                }
            } else {
                $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id);
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } elseif ($actionid == 2) {
            $permission = "no";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } else {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    } elseif ($others_permission_id == 1) {
        if ($actionid == 2) {
            $permission = "no";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } else {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    } elseif ($others_permission_id == 2) {
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    } elseif ($others_permission_id == 3) {
        if ($actionid == 3 || $actionid == 4) {
            if ($module == 'Calendar') {
                if ($recOwnType == 'Users') {
                    $permission = isCalendarPermittedBySharing($record_id);
                } else {
                    $permission = 'no';
                }
            } else {
                $permission = isReadPermittedBySharing($module, $tabid, $actionid, $record_id);
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } elseif ($actionid == 0 || $actionid == 1) {
            if ($module == 'Calendar') {
                $permission = 'no';
            } else {
                $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id);
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } elseif ($actionid == 2) {
            $permission = "no";
            return $permission;
        } else {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    } else {
        $permission = "yes";
    }
    $log->debug("Exiting isPermitted method ...");
    return $permission;
}
Exemplo n.º 4
0
/** Function to getQuickCreate for a given tabid
 * @param $tabid -- tab id :: Type string
 * @param $actionid -- action id :: Type integer
 * @returns $QuickCreateForm -- QuickCreateForm :: Type boolean
 */
function getQuickCreate($tabid, $actionid)
{
    global $log;
    $log->debug("Entering getQuickCreate(" . $tabid . "," . $actionid . ") method ...");
    $module = getTabModuleName($tabid);
    $actionname = getActionname($actionid);
    $QuickCreateForm = 'true';
    $perr = isPermitted($module, $actionname);
    if ($perr == 'no') {
        $QuickCreateForm = 'false';
    }
    $log->debug("Exiting getQuickCreate method ...");
    return $QuickCreateForm;
}
Exemplo n.º 5
0
/** returns html check box code based on the input id
 * @param $id -- Role Name:: Type varchar
 * @returns $value -- html check box code:: Type varcha:w
 */
function getDisplayOutput($id, $tabid, $actionid)
{
    if ($actionid == '') {
        $name = $tabid . '_tab';
        $ckbox_id = 'tab_chk_com_' . $tabid;
        $jsfn = 'hideTab(' . $tabid . ')';
    } else {
        $temp_name = getActionname($actionid);
        $name = $tabid . '_' . $temp_name;
        $ckbox_id = 'tab_chk_' . $actionid . '_' . $tabid;
        if ($actionid == 1) {
            $jsfn = 'unSelectCreate(' . $tabid . ')';
        } elseif ($actionid == 4) {
            $jsfn = 'unSelectView(' . $tabid . ')';
        } elseif ($actionid == 2) {
            $jsfn = 'unSelectDelete(' . $tabid . ')';
        } else {
            $ckbox_id = $tabid . '_field_util_' . $actionid;
            $jsfn = 'javascript:';
        }
    }
    if ($id == '' && $id != 0) {
        $value = '';
    } elseif ($id == 0) {
        $value = '<input type="checkbox" onClick="' . $jsfn . ';" id="' . $ckbox_id . '" name="' . $name . '" checked>';
    } elseif ($id == 1) {
        $value = '<input type="checkbox" onClick="' . $jsfn . ';" id="' . $ckbox_id . '" name="' . $name . '">';
    }
    return $value;
}
Exemplo n.º 6
0
/** Function to check if the currently logged in 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 _vtisPermitted($module, $actionname, $record_id = '')
{
    global $log, $adb, $current_user, $seclog;
    $log->debug("Entering isPermitted(" . $module . "," . $actionname . "," . $record_id . ") method ...");
    if (strpos($record_id, 'x') > 0) {
        // is webserviceid
        list($void, $record_id) = explode('x', $record_id);
    }
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $parenttab = empty($_REQUEST['parenttab']) ? '' : vtlib_purify($_REQUEST['parenttab']);
    $permission = "no";
    if (($module == 'Users' || $module == 'Home' || $module == 'uploads') && $parenttab != 'Settings') {
        //These modules dont have security right now
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Checking the Access for the Settings Module
    if ($module == 'Settings' || $module == 'Administration' || $parenttab == 'Settings') {
        if (!$is_admin) {
            $permission = "no";
        } else {
            $permission = "yes";
        }
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Checking whether the user is admin
    if ($is_admin) {
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Retreiving the Tabid and Action Id
    $tabid = getTabid($module);
    $actionid = getActionid($actionname);
    //If no actionid, then allow action is vtiger_tab permission is available
    if ($actionid === '') {
        if ($profileTabsPermission[$tabid] == 0) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
        } else {
            $permission = "no";
        }
        return $permission;
    }
    $action = getActionname($actionid);
    //Checking for view all permission
    if ($profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
        if ($actionid == 3 || $actionid == 4) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Checking for edit all permission
    if ($profileGlobalPermission[2] == 0) {
        if ($actionid == 3 || $actionid == 4 || $actionid == 0 || $actionid == 1) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Checking for vtiger_tab permission
    if ($profileTabsPermission[$tabid] != 0) {
        $permission = "no";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    if (!isset($profileActionPermission[$tabid][$actionid]) && ($action == 'Export' || $action == 'Import')) {
        return "no";
    }
    //Checking for Action Permission
    if (strlen($profileActionPermission[$tabid][$actionid]) < 1 && $profileActionPermission[$tabid][$actionid] == '') {
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    if ($profileActionPermission[$tabid][$actionid] != 0 && $profileActionPermission[$tabid][$actionid] != '') {
        $permission = "no";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //Checking and returning true if recorid is null
    if ($record_id == '') {
        $permission = "yes";
        $log->debug("Exiting isPermitted method ...");
        return $permission;
    }
    //If modules is Faq or PriceBook then no sharing
    if ($record_id != '') {
        if (getTabOwnedBy($module) == 1) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Retreiving the RecordOwnerId
    $recOwnType = '';
    $recOwnId = '';
    $recordOwnerArr = getRecordOwnerId($record_id);
    foreach ($recordOwnerArr as $type => $id) {
        $recOwnType = $type;
        $recOwnId = $id;
    }
    //Retreiving the default Organisation sharing Access
    $others_permission_id = $defaultOrgSharingPermission[$tabid];
    if ($recOwnType == 'Users') {
        $wfs = new VTWorkflowManager($adb);
        $racbr = $wfs->getRACRuleForRecord($module, $record_id);
        //Checking if the Record Owner is the current User
        if ($current_user->id == $recOwnId) {
            if ($actionname != 'EditView' and $actionname != 'Delete' and $actionname != 'DetailView' and $actionname != 'CreateView' or (!$racbr or $racbr->hasDetailViewPermissionTo($actionname, true))) {
                $permission = 'yes';
            } else {
                $permission = 'no';
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
        //Checking if the Record Owner is the Subordinate User
        foreach ($subordinate_roles_users as $roleid => $userids) {
            if (in_array($recOwnId, $userids)) {
                $permission = 'yes';
                $log->debug("Exiting isPermitted method ...");
                return $permission;
            }
        }
        if ($racbr !== false and $racbr->hasDetailViewPermissionTo($actionname, false)) {
            $log->debug("Exiting isPermitted method via RAC User...");
            return 'yes';
        }
    } elseif ($recOwnType == 'Groups') {
        //Checking if the record owner is the current user's group
        if (in_array($recOwnId, $current_user_groups)) {
            $wfs = new VTWorkflowManager($adb);
            $racbr = $wfs->getRACRuleForRecord($module, $record_id);
            if ($actionname != 'EditView' and $actionname != 'Delete' and $actionname != 'DetailView' and $actionname != 'CreateView' or (!$racbr or $racbr->hasDetailViewPermissionTo($actionname))) {
                $permission = 'yes';
            } else {
                $permission = 'no';
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    }
    //Checking for Default Org Sharing permission
    if ($others_permission_id == 0) {
        if ($actionid == 1 || $actionid == 0) {
            if ($module == 'Calendar') {
                if ($recOwnType == 'Users') {
                    $permission = isCalendarPermittedBySharing($record_id);
                } else {
                    $permission = 'no';
                }
            } else {
                $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id);
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } elseif ($actionid == 2) {
            $permission = "no";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } else {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    } elseif ($others_permission_id == 1) {
        if ($actionid == 2) {
            $permission = "no";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } else {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    } elseif ($others_permission_id == 2) {
        $wfs = new VTWorkflowManager($adb);
        $racbr = $wfs->getRACRuleForRecord($module, $record_id);
        if ($actionname != 'EditView' and $actionname != 'Delete' and $actionname != 'DetailView' and $actionname != 'CreateView' or (!$racbr or $racbr->hasDetailViewPermissionTo($actionname))) {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    } elseif ($others_permission_id == 3) {
        if ($actionid == 3 || $actionid == 4) {
            if ($module == 'Calendar') {
                if ($recOwnType == 'Users') {
                    $permission = isCalendarPermittedBySharing($record_id);
                } else {
                    $permission = 'no';
                }
            } else {
                $wfs = new VTWorkflowManager($adb);
                $racbr = $wfs->getRACRuleForRecord($module, $record_id);
                if ($racbr) {
                    if ($actionid == 3 and !$racbr->hasListViewPermissionTo('retrieve')) {
                        return 'no';
                    } elseif ($actionid == 4 and !$racbr->hasDetailViewPermissionTo('retrieve')) {
                        return 'no';
                    }
                }
                $permission = isReadPermittedBySharing($module, $tabid, $actionid, $record_id);
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } elseif ($actionid == 0 || $actionid == 1) {
            if ($module == 'Calendar') {
                $permission = 'no';
            } else {
                $wfs = new VTWorkflowManager($adb);
                $racbr = $wfs->getRACRuleForRecord($module, $record_id);
                if ($racbr) {
                    if ($actionid == 0 and !$racbr->hasDetailViewPermissionTo('create')) {
                        return 'no';
                    } elseif ($actionid == 1 and !$racbr->hasDetailViewPermissionTo('update')) {
                        return 'no';
                    }
                }
                $permission = isReadWritePermittedBySharing($module, $tabid, $actionid, $record_id);
            }
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        } elseif ($actionid == 2) {
            $permission = "no";
            return $permission;
        } else {
            $permission = "yes";
            $log->debug("Exiting isPermitted method ...");
            return $permission;
        }
    } else {
        $permission = "yes";
    }
    $log->debug("Exiting isPermitted method ...");
    return $permission;
}