/** * Return a list of all calendar events that should be presented to a user * that is not an administrator * * @param mixed $user A user login or an EfrontUser object * @return array A list of calendar events * @since 3.6.7 * @access public * @static */ public static function getCalendarEventsForNonAdministrator($user) { $user = EfrontUser::convertArgumentToUserLogin($user); $personalEvents = $globalEvents = $lessonEvents = $courseEvents = $groupEvents = $branchEvents = $subbranchEvents = array(); $result = eF_getTableData("calendar c", "c.*", "type = 'global' and foreign_ID=0"); foreach ($result as $value) { $globalEvents[$value['id']] = $value; } $result = eF_getTableData("lessons l, calendar ca, users_to_lessons ul", "ca.*, l.name", "ul.users_LOGIN='******' and ca.foreign_ID=ul.lessons_ID and ul.lessons_ID=l.id and l.archive=0 and ul.archive=0 and ca.type = 'lesson'"); foreach ($result as $value) { $lessonEvents[$value['id']] = $value; } $result = eF_getTableData("courses c, calendar ca, users_to_courses uc", "ca.*, c.name", "uc.users_LOGIN='******' and ca.foreign_ID=uc.courses_ID and uc.courses_ID=c.id and c.archive=0 and uc.archive=0 and ca.type = 'course'"); foreach ($result as $value) { $courseEvents[$value['id']] = $value; } $result = eF_getTableData("groups g, calendar ca, users_to_groups ug", "ca.*, g.name", "ug.users_LOGIN='******' and ca.foreign_ID=ug.groups_ID and ug.groups_ID=g.id and ca.type = 'group'"); foreach ($result as $value) { $groupEvents[$value['id']] = $value; } if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $result = eF_getTableData("module_hcd_branch b, calendar ca, module_hcd_employee_works_at_branch wb", "ca.*, b.name", "wb.users_LOGIN='******' and ca.foreign_ID=wb.branch_ID and b.branch_ID=wb.branch_ID and ca.type = 'branch'"); foreach ($result as $value) { $branchEvents[$value['id']] = $value; } $userParentBranches = array(); $branchesTree = new EfrontBranchesTree(); $result = eF_getTableData("module_hcd_employee_works_at_branch", "branch_ID", "users_login='******' and assigned=1"); foreach ($result as $value) { foreach ($branchesTree->getNodeAncestors($value['branch_ID']) as $node) { $userParentBranches[] = $node['branch_ID']; } } $userParentBranches = array_unique($userParentBranches); if (!empty($userParentBranches)) { $result = eF_getTableData("module_hcd_branch b, calendar ca", "ca.*, b.name", "ca.foreign_ID=b.branch_ID and b.branch_ID in (" . implode(",", $userParentBranches) . ") and ca.type = 'sub_branch'"); foreach ($result as $value) { $subbranchEvents[$value['id']] = $value; } } } #cpp#endif $personalEvents = self::getUserCalendarEvents($user); $userEvents = $personalEvents + $globalEvents + $lessonEvents + $courseEvents + $groupEvents + $branchEvents + $subbranchEvents; return $userEvents; }