/** * Get lesson users * * This function returns a list with the students of all the lessons in which the current user has a professor role * <br/>Example: * <code> * $user = EfrontUserFactory :: factory('professor'); * $students = $user -> getProfessorStudents(); * </code> * * @return array A list of user logins * @since 3.5.0 * @access public */ public function getProfessorStudents() { $users = array(); $result = eF_getTableDataFlat("users_to_lessons", "lessons_ID", "archive=0 and users_LOGIN='******'login'] . "' and user_type in ('" . implode("','", array_keys(EfrontLessonUser::getProfessorRoles())) . "')"); if (!empty($result['lessons_ID'])) { $result = eF_getTableDataFlat("users_to_lessons as ul, users as u", "distinct ul.users_LOGIN", "ul.users_LOGIN=u.login and u.active=1 and ul.archive=0 and ul.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "') and ul.lessons_ID in (" . implode(",", $result['lessons_ID']) . ")"); $users = array_unique($result['users_LOGIN']); } return $users; }
/** * Get group courses * * This function returns the list of courses that are part of this group, including unassigned * * @param array $constraints The constraints for the query * @return array An array of EfrontCourse objects or course arrays * @since 3.6.2 * @access public */ public function getGroupCoursesAggregatingResultsIncludingUnassigned($constraints = array()) { !empty($constraints) or $constraints = array('archive' => false, 'active' => true); list($where, $limit, $orderby) = EfrontCourse::convertCourseConstraintsToSqlParameters($constraints); $select = "c.*, (rr.courses_ID is not null OR r.courses_ID is not null) as has_course,\n \t(select count( * ) from courses l where instance_source=c.id)\n \tas has_instances,\n \t(select count( * ) from lessons_to_courses cl, lessons l where cl.courses_ID=c.id and l.archive=0 and l.id=cl.lessons_ID)\n \tas num_lessons,\n \t(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and c.archive=0 and u.active!=0 and u.archive=0 and uc.archive=0 and u.login=uc.users_LOGIN and uc.user_type IN ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "'))\n \tas num_students"; if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $select .= ",(select count( * ) from module_hcd_course_offers_skill s where courses_ID=c.id)\n \t\tas num_skills"; } #cpp#endif //debug(); $result = eF_getTableData("courses c left outer join (select courses_ID from courses_to_groups where groups_ID=" . $this->group['id'] . ") r on c.id=r.courses_ID left outer join (select courses_ID,name,instance_source from courses c, courses_to_groups cg where c.id=cg.courses_ID and cg.groups_ID={$this->group['id']}) rr on rr.instance_source=c.id", $select, implode(" and ", $where), $orderby, $groupby, $limit); //debug(false); return EfrontCourse::convertDatabaseResultToCourseObjects($result); }
/** * Get lesson users * * This function returns an array with the lesson users. * <br/>Example: * <code> * $lesson = new EfrontLesson(32); //32 is a lesson id * $lessonUsers = $lesson -> getUsers(); //Get the lesson users * $nonLessonUsers = $lesson -> getNonUsers(); //Get the users that don't have the lesson, but are eligible to * </code> * The returned array keys match the users logins * * @param string $basicType The user's basic type in the lesson * @param boolean $refresh Whether to explicitly refresh the object cached data set * @return array A 2-dimensional array with lesson users per type, or a 1-dimensional array with lesson users of the specified type * @since 3.5.0 * @access public */ public function getUsers($basicType = false, $refresh = false) { if ($this->users === false || $refresh || $basicType) { //Make a database query only if the variable is not initialized, or it is explicitly asked $users = array(); if ($basicType && eF_checkParameter($basicType, 'alnum_general')) { $users = array(); if ($basicType == 'professor') { $roles = EfrontLessonUser::getProfessorRoles(); $roles = array_keys($roles); } else { if ($basicType == 'student') { $roles = EfrontLessonUser::getStudentRoles(); $roles = array_keys($roles); } else { $roles = $basicType; } } $result = eF_getTableData("users u, users_to_lessons ul", "u.*, ul.user_type as role, ul.from_timestamp, ul.completed, ul.to_timestamp as timestamp_completed", "u.user_type != 'administrator' and ul.archive = 0 and u.archive = 0 and ul.users_LOGIN = login and lessons_ID=" . $this->lesson['id'] . " and ul.user_type in ('" . implode("','", $roles) . "')"); } else { $result = eF_getTableData("users u, users_to_lessons ul", "u.*, ul.user_type as role, ul.from_timestamp, ul.completed, ul.to_timestamp as timestamp_completed", "u.user_type != 'administrator' and ul.archive = 0 and u.archive = 0 and ul.users_LOGIN = login and lessons_ID=" . $this->lesson['id']); } foreach ($result as $value) { $users[$value['login']] = array('login' => $value['login'], 'email' => $value['email'], 'name' => $value['name'], 'surname' => $value['surname'], 'basic_user_type' => $value['user_type'], 'user_type' => $value['user_type'], 'user_types_ID' => $value['user_types_ID'], 'role' => $value['role'], 'from_timestamp' => $value['from_timestamp'], 'active' => $value['active'], 'avatar' => $value['avatar'], 'completed' => $value['completed'], 'timestamp_completed' => $value['timestamp_completed'], 'partof' => 1); } if (!$basicType) { $this->users = $users; } } if ($basicType) { return $users; } else { return $this->users; } }
if (isset($_GET['edit_user_group'])) { $currentGroup = new EfrontGroup($_GET['edit_user_group']); $smarty->assign("T_CURRENT_GROUP", $currentGroup); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY $smarty->assign("T_STATS_LINK", array(array('text' => _STATISTICS, 'image' => "16x16/reports.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=statistics&option=groups&sel_group=" . $_GET['edit_user_group'], 'target' => '_self'))); } #cpp#endif if ($currentGroup->group['key_max_usage'] > 0) { $remainingKeyUsagesLabel = '(' . _REMAINING . ' ' . ($currentGroup->group['key_max_usage'] - $currentGroup->group['key_current_usage']) . '/' . $currentGroup->group['key_max_usage'] . ')'; } } isset($_GET['add_user_group']) ? $postTarget = 'add_user_group=1' : ($postTarget = "edit_user_group=" . $_GET['edit_user_group']); $form = new HTML_QuickForm("add_group_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=user_groups&{$postTarget}", "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $roles = EfrontLessonUser::getStudentRoles(true); //array_unshift($roles, _DONTUSEDEFAULTGROUP); $roles = array(0 => _DONTUSEDEFAULTGROUP) + $roles; $form->addElement('text', 'name', _GROUPNAME, 'class = "inputText"'); $form->addElement('text', 'description', _DESCRIPTION, 'class = "inputText"'); $form->addElement('static', 'sidenote', '<img src = "images/16x16/wizard.png" class = "ajaxHandle" alt = "' . _AUTOMATICALLYGENERATEGROUPKEY . '" title = "' . _AUTOMATICALLYGENERATEGROUPKEY . '" onclick = "$(\'unique_key_id\').value = \'' . md5(time()) . '\';"/>'); // timestamp guarantess uniqueness $form->addElement('text', 'unique_key', _UNIQUEGROUPKEY, 'class = "inputText" id="unique_key_id"'); $form->addElement('static', 'note', _UNIQUEGROUPKEYINFO); $form->addElement('text', 'key_max_usage', _MAXGROUPKEYUSAGE, 'class = "inputText"'); $form->addElement('static', 'note', _MAXGROUPKEYUSAGEINFO . ' ' . $remainingKeyUsagesLabel); $form->addElement('select', 'user_types_ID', _DEFAULTLEARNERTYPE, $roles, 'class = "inputText"'); $form->addElement('static', 'note', _DEFAULTLEARNERTYPEINFO . ' ' . $remainingKeyUsagesLabel); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') {
/** * Get user seen content in lesson * * This function calulates the content done by the specified student(s) in the * specified lesson. If $users is not specified, then information on all users and/or lessons * is calculated. * <br/>Example: * <code> * EfrontStats :: getStudentsSeenContent(3, 'jdoe'); //Get statistics for user jdoe in lesson 3 * EfrontStats :: getStudentsSeenContent(3, array('jdoe', 'george')); //Get statistics for users george and jdoe in lesson 3 * EfrontStats :: getStudentsSeenContent(3); //Get statistics for all users in lesson 3 * EfrontStats :: getStudentsSeenContent(); //Get statistics for all users in all lessons * </code> * The resulting array is of the form array(lesson id => array(login => array(done content))): * <code> * Array * ( * [32] => Array * ( * [jdoe] => Array * ( * [1415] => * [1417] => * [1416] => 50 * [1412] => * [1411] => * [1413] => * [1420] => 100 * ) * [george] => Array * ( * [1415] => * [1417] => * [1416] => 66 * [1412] => * [1408] => * [1409] => * [1410] => * [1420] => 30 * ) * ) * ) * </code> * * This means that: very lesson is an array, where every student has a corresponding array, in which the keys represent the units he has * completed. For content units, the array values are empty. For test units, the array values contain the * users's score. * * @param mixed $lessons An array of lesson ids or EfrontLesson objects. If false, all lessons are considered * @param mixed $users One or more optional user logins * @return array The seen content per user login * @since 3.5.0 * @access public * @static */ public static function getStudentsSeenContent($lessons = false, $users = false, $options = array()) { if ($lessons == false) { $lessons = eF_getTableDataFlat("lessons", "id"); $lessons = $lessons['id']; } else { if (!is_array($lessons)) { $lessons = array($lessons); } } foreach ($lessons as $key => $lesson) { if ($lesson instanceof EfrontLesson) { $lessons[$key] = $lesson->lesson['id']; } else { if (!eF_checkParameter($lesson, 'id')) { throw new EfrontLessonException(_INVALIDID, EfrontLessonException::INVALID_ID); } else { $lessons[$key] = $lesson; } } } if ($users != false) { !is_array($users) ? $users = array($users) : null; //Convert single login to array } else { $users = eF_getTableDataFlat("users", "login"); $users = $users['login']; } foreach ($users as $key => $user) { if ($user instanceof EfrontUser) { $users[$key] = $user->user['login']; } else { if (!eF_checkParameter($user, 'login')) { throw new EfrontLessonException(_INVALIDLOGIN, EfrontUserException::INVALID_LOGIN); } else { $users[$key] = $user; } } } if (sizeof($lessons) > 0 && sizeof($users) > 0) { $doneTests = array(); //debug_print_backtrace(); if (!isset($options['notests']) || !$options['notests']) { if (sizeof($users) <= 100) { $result = eF_getTableData("completed_tests ct, tests t", "ct.archive, ct.status, ct.score, ct.users_LOGIN, t.lessons_ID, t.content_ID, t.keep_best", "ct.status != 'deleted' and ct.status != 'incomplete' and t.id=ct.tests_ID and t.lessons_ID in (" . implode(",", $lessons) . ") and users_LOGIN in ('" . implode("','", $users) . "')"); } else { $result = eF_getTableData("completed_tests ct, tests t", "ct.archive, ct.status, ct.score, ct.users_LOGIN, t.lessons_ID, t.content_ID, t.keep_best", "ct.status != 'deleted' and ct.status != 'incomplete' and t.id=ct.tests_ID and t.lessons_ID in (" . implode(",", $lessons) . ")"); } foreach ($result as $value) { if ($value['keep_best'] && $value['status'] == 'passed') { $doneTests[$value['lessons_ID']][$value['users_LOGIN']][$value['content_ID']] = $value['score']; } elseif ($value['status'] != 'failed' && !$value['archive']) { $doneTests[$value['lessons_ID']][$value['users_LOGIN']][$value['content_ID']] = $value['score']; } } // } $result = eF_getTableData("users u, users_to_lessons ul", "u.login, ul.lessons_ID, ul.done_content", "ul.archive=0 and ul.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "') and u.login = ul.users_LOGIN and u.login in ('" . implode("','", $users) . "') and ul.lessons_ID in (" . implode(",", $lessons) . ")"); //$result = eF_getTableData("users u, users_to_lessons ul, user_types as ut", "u.login, ul.lessons_ID, ul.done_content", "(ul.user_type = 'student' OR (ul.user_type=ut.id AND ut.basic_user_type = 'student')) and u.login = ul.users_LOGIN"); //$result = eF_getTableData("users u, users_to_lessons ul", "u.login, ul.lessons_ID, ul.done_content", "ul.user_type = 'student' and u.login = ul.users_LOGIN"); $usersDoneContent = array(); foreach ($result as $value) { $usersDoneContent[$value['lessons_ID']][$value['login']] = unserialize($value['done_content']); } //Get lessons content, in case a done unit is not part of a lesson anymore or is inactive $result = eF_getTableData("content c", "id, lessons_ID", "lessons_ID in (" . implode(",", $lessons) . ") and active=1"); $lessonContent = array(); foreach ($result as $value) { $lessonContent[$value['lessons_ID']][] = $value['id']; } $resultScorm = eF_getTableData("scorm_data sd, content c", "c.ctg_type, c.lessons_ID, content_ID, users_LOGIN, lesson_status, score, minscore, maxscore, masteryscore", "c.id=sd.content_ID and c.lessons_ID in (" . implode(",", $lessons) . ") and sd.users_LOGIN in ('" . implode("','", $users) . "')"); foreach ($resultScorm as $key => $value) { if ($value['lesson_status'] == 'passed' || $value['lesson_status'] == 'completed') { if ($value['ctg_type'] == 'scorm') { $scormDoneContent[$value['lessons_ID']][$value['users_LOGIN']][$value['content_ID']] = ''; } elseif ($value['ctg_type'] == 'scorm_test') { if (is_numeric($value['minscore']) && is_numeric($value['maxscore'])) { $value['score'] = 100 * $value['score'] / ($value['minscore'] + $value['maxscore']); } else { $value['score'] = $value['score']; } $scormDoneContent[$value['lessons_ID']][$value['users_LOGIN']][$value['content_ID']] = $value['score']; } } else { //Remove this unit from the seen contents unit, since it is failed if (isset($usersDoneContent[$value['lessons_ID']][$value['users_LOGIN']][$value['content_ID']])) { unset($usersDoneContent[$value['lessons_ID']][$value['users_LOGIN']][$value['content_ID']]); } } } } foreach ($lessons as $lessonId) { !isset($usersDoneContent[$lessonId]) ? $usersDoneContent[$lessonId] = array() : null; foreach ($usersDoneContent[$lessonId] as $key => $value) { //Unserialize and preprocess values. This way, only the array keys contain the content id, while array values contain test scores (when the unit is a test). This way we may use array_sum to calculate the mean score at once) //if ($value) { !isset($usersDoneContent[$lessonId][$key]) || !is_array($usersDoneContent[$lessonId][$key]) ? $usersDoneContent[$lessonId][$key] = array() : null; foreach ($usersDoneContent[$lessonId][$key] as $k => $id) { if (!in_array($id, $lessonContent[$lessonId])) { unset($usersDoneContent[$lessonId][$key][$k]); } else { $usersDoneContent[$lessonId][$key][$k] = ''; } } if (isset($doneTests[$lessonId][$key])) { is_array($usersDoneContent[$lessonId][$key]) ? $usersDoneContent[$lessonId][$key] = $doneTests[$lessonId][$key] + $usersDoneContent[$lessonId][$key] : ($usersDoneContent[$lessonId][$key] = $doneTests[$lessonId][$key]); //We cannot use + for arrays, if one of them is not set. } if (isset($scormDoneContent[$lessonId][$key])) { is_array($usersDoneContent[$lessonId][$key]) ? $usersDoneContent[$lessonId][$key] = $scormDoneContent[$lessonId][$key] + $usersDoneContent[$lessonId][$key] : ($usersDoneContent[$lessonId][$key] = $scormDoneContent[$lessonId][$key]); } } foreach ($usersDoneContent[$lessonId] as $key => $value) { if (!$value || $users != false && !in_array($key, $users)) { //Filter out empty results or results not specified within $users array unset($usersDoneContent[$lessonId][$key]); } } if (empty($usersDoneContent[$lessonId])) { unset($usersDoneContent[$lessonId]); } } return $usersDoneContent; }
public function getRecipients() { $recipients_list = array(); if (isset($this->notification['send_conditions'])) { //echo $this -> notification['send_conditions']; if ($this->notification['send_conditions'] == "N;") { $recipients = eF_getTableData("users", "*", "active=1 and archive=0"); //sending_queue_msgs[$key]['recipients'] = _ALLUSERS; foreach ($recipients as $recipient) { $recipients_list[$recipient['login']] = $recipient; } } else { // the send_conditions field contains the information which identify the recipients // it is defined in .... //digests.php during the definition of the event notification $this->notification['send_conditions'] = unserialize($this->notification['send_conditions']); if ($this->notification['send_conditions'] == "supervisors") { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $recipients = eF_getTableData("module_hcd_employee_works_at_branch as meb, users as u", "u.*", "meb.users_login=u.login and u.active=1 and u.archive=0 and meb.supervisor=1"); foreach ($recipients as $recipient) { $recipients_list[$recipient['login']] = $recipient; } } #cpp#endif } elseif (is_array($this->notification['send_conditions'])) { $this->recipients = $this->notification['send_conditions']; // The recipients array definitely exists, due to constructor checks if (isset($this->recipients["lessons_ID"]) && $this->recipients["lessons_ID"]) { $lesson = new EfrontLesson($this->recipients["lessons_ID"]); if (isset($this->recipients["user_type"])) { // return lesson users of specific type $recipients = array(); foreach ($lesson->getUsers($this->recipients["user_type"]) as $value) { if ($value['active']) { $recipients[] = $value; } } } else { if (isset($this->recipients["completed"])) { // return lesson students according to whether they have completed the lesson or not $recipients = array(); foreach ($lesson->getUsersCompleted($this->recipients["completed"]) as $value) { if ($value['active']) { $recipients[] = $value; } } } else { // return all users $recipients = array(); foreach ($lesson->getUsers() as $value) { if ($value['active']) { $recipients[] = $value; } } } } } else { if (isset($this->recipients["courses_ID"])) { $entity_parts = explode("_", $this->notification['id_type_entity']); $notification_type = $entity_parts[1]; if ($this->recipients['user_type'] == "professor") { $completed_condition = " AND uc.user_type = 'professor'"; } else { if ($this->recipients['completed'] == "1") { $completed_condition = " AND completed = '1'"; } else { if ($this->recipients['completed'] == "2" || $notification_type == EfrontEvent::COURSE_PROGRAMMED_EXPIRY) { $completed_condition = " AND completed = '0' and uc.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "')"; } else { $completed_condition = ""; } } } if ($this->recipients['supervisor']) { if ($this->recipients['users_login']) { $editedUser = EfrontUserFactory::factory($this->recipients['users_login']); //new EfrontUser(); $editedEmployee = $editedUser->aspects['hcd']; $supervisors = $editedEmployee->getSupervisors(); $recipients = array(); foreach ($supervisors as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } } else { $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)"; //get course users' supervisors $result = eF_executeNew($query); $recipients = $result->getAll(); } } elseif ($this->recipients['immediate_supervisor']) { if ($this->recipients['users_login']) { $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and assigned=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')"); $recipients = array(); foreach ($result['users_LOGIN'] as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } $filtered_recipients = array(); if (!empty($recipients)) { $active_recipients = eF_getTableDataFlat("users", "login", "active=1 and archive=0 and login IN ('" . implode("','", array_keys($recipients)) . "')"); foreach ($active_recipients["login"] as $login) { $filtered_recipients[$login] = array("login" => $login); } $recipients = $filtered_recipients; } } else { $query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where ewb.assigned=1 and supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and ewb.assigned=1 and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)"; //get course users' supervisors $result = eF_executeNew($query); $recipients = $result->getAll(); } } else { $recipients = eF_getTableData("users_to_courses uc, users u", "u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID, uc.user_type as role", "u.active=1 and u.archive=0 and uc.archive=0 and uc.users_LOGIN = u.login and uc.courses_ID=" . $this->recipients["courses_ID"] . $completed_condition); } } else { if (isset($this->recipients['user_type'])) { $recipients = eF_getTableData("users", "*", "active=1 and archive=0 and user_type = '" . $this->recipients['user_type'] . "'"); } else { if (isset($this->recipients['entity_ID']) && isset($this->recipients['entity_category'])) { if ($this->recipients['entity_category'] == "survey") { $recipients = eF_getTableData("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and surveys_ID = '" . $this->recipients["entity_ID"] . "'"); $notified = eF_getTableDataFlat("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and users_to_surveys.last_post > 1 and surveys_ID = '" . $this->recipients["entity_ID"] . "'"); //$resDone = eF_getTableDataFlat("users_to_done_surveys", "users_LOGIN", "surveys_ID=".$this -> recipients["entity_ID"]); $usersToSent = array(); if (!empty($notified['login'])) { foreach ($recipients as $key => $value) { if (!in_array($value['login'], $notified['login'])) { $usersToSent[] = $value; //eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login']."' and surveys_ID='".$this -> recipients["entity_ID"]."'"); } } $recipients = $usersToSent; } foreach ($recipients as $key => $value) { // in order to include case empty($notified['login'] eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login'] . "' and surveys_ID='" . $this->recipients["entity_ID"] . "'"); } } else { if ($this->recipients['entity_category'] == "projects") { $recipients = eF_getTableData("users_to_projects JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and projects_ID = '" . $this->recipients["entity_ID"] . "'"); } } } else { if (isset($this->recipients["groups_ID"])) { $recipients = eF_getTableData("users_to_groups JOIN users ON users_login = users.login", "users.*", "users.active=1 and users.archive=0 and groups_ID = '" . $this->recipients["groups_ID"] . "'"); } else { if (isset($this->recipients['users_login'])) { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (isset($this->recipients['supervisor'])) { $editedUser = EfrontUserFactory::factory($this->recipients['users_login']); //new EfrontUser(); $editedEmployee = $editedUser->aspects['hcd']; $supervisors = $editedEmployee->getSupervisors(); $recipients = array(); foreach ($supervisors as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } } elseif (isset($this->recipients['immediate_supervisor'])) { $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')"); $recipients = array(); foreach ($result['users_LOGIN'] as $supervisor) { $recipients[$supervisor] = array("login" => $supervisor); } } else { $recipients = $this->recipients['users_login']; } } else { #cpp#else $recipients = $this->recipients['users_login']; } #cpp#endif } } } } } } foreach ($recipients as $recipient) { $recipients_list[$recipient['login']] = $recipient; } } else { if ($this->notification['recipient'] != "") { preg_match("/\\d+_(\\d+)/", $this->notification['id_type_entity'], $matches); if ($matches[1] == EfrontEvent::SYSTEM_ON_EMAIL_ACTIVATION) { //In this case, we want an inactive user to receive the email $user = eF_getTableData("users", "*", "archive=0 and login = '******'recipient'] . "'"); } else { $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'"); } if (!empty($user)) { $recipients_list[$this->notification['recipient']] = $user[0]; } } } } } else { if ($this->notification['recipient'] != "") { $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'"); if (!empty($user)) { $recipients_list[$this->notification['recipient']] = $user[0]; } } } return $recipients_list; }
private static function setCourseUserSelection(&$constraints = array()) { //$where[] = "uc.user_type in (" . explode(", ", array_keys(EfrontLessonUser::getStudentRoles())) . ")"; //"(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and u.archive=0 and u.active=1 and uc.archive=0 and u.login=uc.users_LOGIN and u.user_type='student') as num_students"; if (empty($constraints['table_filters'])) { return "(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and u.archive=0 and u.active=1 and uc.archive=0 and u.login=uc.users_LOGIN and uc.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "')) as num_students"; } else { list($where, $limit, $orderby) = EfrontCourse::convertCourseUserConstraintsToSqlParameters($constraints); $from = "users_to_courses uc, users u"; $from = EfrontCourse::appendTableFiltersUserConstraints($from, $constraints); $where[] = "uc.courses_ID=c.id"; $where[] = "u.archive=0"; $where[] = "u.login=uc.users_LOGIN"; $where[] = "u.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "')"; unset($constraints['table_filters']); // to avoid using the filters again in courses.... return "(select count(*) FROM " . $from . " WHERE " . implode(" AND ", $where) . ") as num_students"; } }
$constraints = array('table_filters' => $stats_filters); //$infoCourse -> course['num_students'] = sizeof($infoCourse -> getStudentUsers(false, $constraints)); //$infoCourse -> course['num_professors'] = sizeof($infoCourse -> getProfessorUsers(false, $constraints)); $infoCourse->course['category_path'] = $directionsPaths[$infoCourse->course['directions_ID']]; $smarty->assign("T_CURRENT_COURSE", $infoCourse); $smarty->assign("T_STATS_ENTITY_ID", $_GET['sel_course']); try { $result = eF_getTableData("user_times ut join users_to_courses uc on ut.users_LOGIN=uc.users_LOGIN and ut.courses_ID=uc.courses_ID", "sum(time) as sum, count(distinct uc.users_LOGIN) as count", "completed=1 and uc.archive=0 and ut.courses_ID=" . $infoCourse->course['id'], "", ""); if ($result[0]['sum']) { $smarty->assign("T_AVERAGE_COMPLETION_TIME", EfrontTimes::formatTimeForReporting($result[0]['sum'] / $result[0]['count'])); } $roles = EfrontLessonUser::getLessonsRoles(true); $smarty->assign("T_ROLES_ARRAY", $roles); $rolesBasic = EfrontLessonUser::getLessonsRoles(); $smarty->assign("T_BASIC_ROLES_ARRAY", $rolesBasic); $constraints = array('archive' => false, 'table_filters' => $stats_filters, 'condition' => 'r.course_user_type IN ("' . implode('","', array_keys(EfrontLessonUser::getStudentRoles())) . '")'); $numUsers = $infoCourse->countCourseUsersAggregatingResults($constraints); if ($numUsers) { $usersPerRole['student'] = $numUsers; } $constraints = array('archive' => false, 'table_filters' => $stats_filters, 'condition' => 'r.course_user_type IN ("' . implode('","', array_keys(EfrontLessonUser::getProfessorRoles())) . '")'); $numUsers = $infoCourse->countCourseUsersAggregatingResults($constraints); if ($numUsers) { $usersPerRole['professor'] = $numUsers; } $infoCourse->course['users_per_role'] = $usersPerRole; $infoCourse->course['num_users'] = array_sum($usersPerRole); $courseInstances = $infoCourse->getInstances(); $smarty->assign("T_COURSE_INSTANCES", $courseInstances); $smarty->assign("T_COURSE_HAS_INSTANCES", sizeof($courseInstances) > 1); $smarty->assign("T_DATASOURCE_SORT_BY", 0);