Index: modules/Calendar/CalendarCommon.php =================================================================== --- modules/Calendar/CalendarCommon.php (revision 559) +++ modules/Calendar/CalendarCommon.php (revision 560) @@ -59,6 +59,28 @@ } /** + * @param $sharedid integer - userid + * @param $module string + * @param $permission string - read|write + * @return array(integer) - userids + */ +function getSharedDataUsers($sharedid, $module, $permission) +{ + $userids = array(); + global $adb; + require "user_privileges/sharing_privileges_${sharedid}.php"; + $varname = "${module}_share_${permission}_permission"; + $perms = $$varname; + if ($perms['ROLE']) { + $userids = array_merge($userids, call_user_func_array('array_merge', $perms['ROLE'])); + } + if ($perms['GROUP']) { + $userids = array_merge($userids, call_user_func_array('array_merge', $perms['GROUP'])); + } + return $userids; +} + +/** * To get userid and username of all vtiger_users except the current user * @param $id -- The user id :: Type integer * @returns $user_details -- Array in the following format: Index: modules/Settings/OrgSharingDetailView.php =================================================================== --- modules/Settings/OrgSharingDetailView.php (revision 559) +++ modules/Settings/OrgSharingDetailView.php (revision 560) @@ -47,6 +47,8 @@ $smarty->assign("DEFAULT_SHARING", $access_privileges); $custom_access = array(); +$custom_access['Calendar'] = getSharingRuleList('Calendar'); + //Lead Sharing $custom_access['Leads'] = getSharingRuleList('Leads'); Index: modules/Users/CreateUserPrivilegeFile.php =================================================================== --- modules/Users/CreateUserPrivilegeFile.php (revision 559) +++ modules/Users/CreateUserPrivilegeFile.php (revision 560) @@ -162,6 +162,15 @@ $newbuf .= "\$related_module_share=".constructTwoDimensionalValueArray($relModSharArr).";\n\n"; + //Constructing Calendar Sharing Rules + $calendar_share_per_array=getUserModuleSharingObjects("Calendar",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); + $calendar_share_read_per=$calendar_share_per_array['read']; + $calendar_share_write_per=$calendar_share_per_array['write']; + $calendar_sharingrule_members=$calendar_share_per_array['sharingrules']; + + $newbuf .= "\$Calendar_share_read_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($calendar_share_read_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($calendar_share_read_per['GROUP']).");\n\n"; + $newbuf .= "\$Calendar_share_write_permission=array('ROLE'=>".constructTwoDimensionalCharIntSingleValueArray($calendar_share_write_per['ROLE']).",'GROUP'=>".constructTwoDimensionalValueArray($calendar_share_write_per['GROUP']).");\n\n"; + //Constructing Lead Sharing Rules $lead_share_per_array=getUserModuleSharingObjects("Leads",$userid,$def_org_share,$current_user_roles,$parent_roles,$current_user_groups); $lead_share_read_per=$lead_share_per_array['read']; @@ -1533,7 +1542,7 @@ } //Populating Values into the tmp sharing tables - $sharingArray=Array('Leads','Accounts','Contacts','Potentials','HelpDesk','Emails','Campaigns','Quotes','PurchaseOrder','SalesOrder','Invoice'); + $sharingArray=Array('Calendar', 'Leads','Accounts','Contacts','Potentials','HelpDesk','Emails','Campaigns','Quotes','PurchaseOrder','SalesOrder','Invoice'); foreach($sharingArray as $module) { populateSharingPrivileges('USER',$userid,$module,'read'); Index: include/utils/UserInfoUtil.php =================================================================== --- include/utils/UserInfoUtil.php (revision 559) +++ include/utils/UserInfoUtil.php (revision 560) @@ -4176,11 +4176,15 @@ elseif($module == 'Calendar') { require_once('modules/Calendar/CalendarCommon.php'); + $condition = ""; $shared_ids = getSharedCalendarId($current_user->id); if(isset($shared_ids) && $shared_ids != '') $condition = " or (vtiger_crmentity.smownerid in($shared_ids) and vtiger_activity.visibility = 'Public')"; - else - $condition = null; + $access_ids = getSharedDataUsers($current_user->id, $module, 'read'); + if ($access_ids) { + $access_ids = implode(",", $access_ids); + $condition .= " OR vtiger_crmentity.smownerid IN ($access_ids)"; + } $sec_query .= " and (vtiger_crmentity.smownerid in($current_user->id) $condition or vtiger_crmentity.smownerid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$current_user_parent_role_seq."::%')"; if(sizeof($current_user_groups) > 0)