/**
  * Get lesson users based on the specified constraints, but include unassigned users as well.
  * Assigned users have the flag 'has_lesson' set to 1
  *
  * @param array $constraints The constraints for the query
  * @return array An array of EfrontUser objects
  * @since 3.6.2
  * @access public
  */
 public function getLessonUsersIncludingUnassigned($constraints = array())
 {
     !empty($constraints) or $constraints = array('archive' => false, 'active' => true);
     list($where, $limit, $orderby) = EfrontUser::convertUserConstraintsToSqlParameters($constraints);
     $where[] = "user_type != 'administrator'";
     $select = "u.*, r.lessons_ID is not null as has_lesson, r.completed,r.score, r.from_timestamp as active_in_lesson, r.role";
     $from = "users u left outer join (select completed,score,lessons_ID,from_timestamp,users_LOGIN,user_type as role from users_to_lessons where lessons_ID='" . $this->lesson['id'] . "' and archive=0) r on u.login=r.users_LOGIN";
     if (G_VERSIONTYPE == 'enterprise') {
         #cpp#ifdef ENTERPRISE
         if (isset($constraints['branch']) && $constraints['branch']) {
             $from .= " JOIN module_hcd_employee_works_at_branch ON module_hcd_employee_works_at_branch.users_login = u.login";
         }
         if (isset($constraints['jobs']) && $constraints['jobs']) {
             $from .= " LEFT OUTER JOIN module_hcd_employee_has_job_description ON module_hcd_employee_has_job_description.users_login = u.login JOIN module_hcd_job_description ON module_hcd_job_description.job_description_ID = module_hcd_employee_has_job_description.job_description_ID";
         }
     }
     #cpp#endif
     $result = eF_getTableData($from, $select, implode(" and ", $where), $orderby, false, $limit);
     if (!isset($constraints['return_objects']) || $constraints['return_objects'] == true) {
         return EfrontUser::convertDatabaseResultToUserObjects($result);
     } else {
         return EfrontUser::convertDatabaseResultToUserArray($result);
     }
 }
 /**
  * Get course users based on the specified constraints, but include unassigned users as well. If the course
  * has instances, then propagate user status in the mother course
  *
  * @param array $constraints The constraints for the query
  * @return array An array of EfrontUser objects
  * @since 3.6.2
  * @access public
  */
 public function getCourseUsersAggregatingResultsIncludingUnassigned($constraints = array())
 {
     !empty($constraints) or $constraints = array('archive' => false, 'active' => true);
     list($where, $limit, $orderby) = EfrontUser::convertUserConstraintsToSqlParameters($constraints);
     $from = "users u left outer join\n\t\t\t\t\t(select users_LOGIN,max(score) as score, max(completed) as completed, 1 as has_course from\n\t\t\t\t\t\t(select uc.user_type as role, uc.score,uc.completed,uc.users_LOGIN from courses c left outer join users_to_courses uc on uc.courses_ID=c.id where (c.id=" . $this->course['id'] . " or c.instance_source=" . $this->course['id'] . ") and uc.archive=0) foo\n\t\t\t\t\tgroup by users_LOGIN) r on u.login=r.users_login";
     $result = eF_getTableData($from, "u.*, r.*", implode(" and ", $where), $orderby, $groupby, $limit);
     if (!isset($constraints['return_objects']) || $constraints['return_objects'] == true) {
         return EfrontUser::convertDatabaseResultToUserObjects($result);
     } else {
         return EfrontUser::convertDatabaseResultToUserArray($result);
     }
 }
Example #3
0
 /**
  * Get group users based on the specified constraints, but include unassigned users as well.
  * Assigned users have the flag 'has_group' set to 1
  *
  * @param array $constraints The constraints for the query
  * @return array An array of EfrontUser objects or user arrays
  * @since 3.6.2
  * @access public
  */
 public function getGroupUsersIncludingUnassigned($constraints = array())
 {
     !empty($constraints) or $constraints = array('archive' => false, 'active' => true);
     list($where, $limit, $orderby) = EfrontUser::convertUserConstraintsToSqlParameters($constraints);
     $result = eF_getTableData("users u left outer join users_to_groups ug on ug.users_LOGIN=u.login and ug.groups_ID=" . $this->group['id'], "u.login,u.active,u.user_type,u.user_types_ID,u.name,u.surname,u.email, ug.groups_ID is not null as has_group", implode(" and ", $where), $orderby, "", $limit);
     if (!isset($constraints['return_objects']) || $constraints['return_objects'] == true) {
         return EfrontUser::convertDatabaseResultToUserObjects($result);
     } else {
         return $result;
     }
 }