} } } $smarty->assign("T_BASIC_ROLES_ARRAY", $rolesBasic); if (isset($_GET['ajax']) && $_GET['ajax'] == 'courseUsersTable') { //pr($studentRoles); $smarty->assign("T_DATASOURCE_COLUMNS", array('login', 'active_in_course', 'completed', 'to_timestamp', 'score', 'issued_certificate', 'expire_certificate', 'operations')); $smarty->assign("T_DATASOURCE_SORT_BY", 0); $constraints = array('archive' => false, 'active' => true) + createConstraintsFromSortedTable(); $constraints['condition'] = "uc.user_type in ('" . implode("','", $studentRoles) . "')"; if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $stats_filters = array(); $branches = array($_SESSION['s_current_branch']); $branchesTree = new EfrontBranchesTree(); $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($branchesTree->getNodeChildren($_SESSION['s_current_branch'])), RecursiveIteratorIterator::SELF_FIRST)); foreach ($iterator as $key => $value) { $branches[] = $key; } $stats_filters[] = array("table" => "module_hcd_employee_works_at_branch as filter_eb", "joinField" => "filter_eb.users_LOGIN", "condition" => "(filter_eb.branch_ID in (" . implode(",", $branches) . ") AND filter_eb.assigned = 1)"); $constraints['table_filters'] = $stats_filters; } $users = $currentCourse->getCourseUsers($constraints); $totalEntries = $currentCourse->countCourseUsers($constraints); $smarty->assign("T_TABLE_SIZE", $totalEntries); foreach ($users as $key => $value) { $users[$key]->user['issued_certificate'] = $value->user['issued_certificate']; $expire_certificateTimestamp = ""; if ($value->user['issued_certificate']) { $issuedData = unserialize($value->user['issued_certificate']); $users[$key]->user['serial_number'] = $issuedData['serial_number'];
$stats_filters[] = array("table" => "module_hcd_employee_works_at_branch as filter_eb", "joinField" => "filter_eb.users_LOGIN", "condition" => "(filter_eb.branch_ID in (" . implode(",", $branches) . ") AND filter_eb.assigned = 1)"); } } else { $branches_array = explode(",", $_GET['branch_filter']); $flag = 1; foreach ($branches_array as $value) { $flag = $flag && eF_checkParameter($value, 'id'); } if ($flag) { if (!$_GET['subbranches']) { $stats_filters[] = array("table" => "module_hcd_employee_works_at_branch as filter_eb", "joinField" => "filter_eb.users_LOGIN", "condition" => "(filter_eb.branch_ID in (" . implode(",", $branches_array) . ") AND filter_eb.assigned = 1)"); } else { $branches = $branches_array; $branchesTree = new EfrontBranchesTree(); foreach ($branches_array as $branch) { $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($branchesTree->getNodeChildren($branch)), RecursiveIteratorIterator::SELF_FIRST)); foreach ($iterator as $key => $value) { $branches[] = $key; } } $branches = array_unique($branches); $stats_filters[] = array("table" => "module_hcd_employee_works_at_branch as filter_eb", "joinField" => "filter_eb.users_LOGIN", "condition" => "(filter_eb.branch_ID in (" . implode(",", $branches) . ") AND filter_eb.assigned = 1)"); } } } } else { if ($currentEmployee->isSupervisor()) { $isProfessor = false; if (isset($_GET['sel_course']) && $currentUser->hasCourse($_GET['sel_course'])) { $roles = EfrontUser::getRoles(); if ($roles[$currentUser->getUserTypeInCourse($_GET['sel_course'])] == 'professor') {
private static function addWhereConditionToCourseConstraints($constraints) { $where = array(); if (isset($constraints['archive'])) { $constraints['archive'] ? $where[] = 'c.archive!=0' : ($where[] = 'c.archive=0'); } if (isset($constraints['active'])) { $constraints['active'] ? $where[] = 'c.active=1' : ($where[] = 'c.active=0'); } if (isset($constraints['instance'])) { if ($constraints['instance'] === true) { $where[] = 'c.instance_source!=0'; } else { if ($constraints['instance'] == false) { $where[] = 'c.instance_source=0'; } else { if (eF_checkParameter($constraints['instance'], 'id')) { $where[] = '(c.instance_source=' . $constraints['instance'] . ' or c.id=' . $constraints['instance'] . ')'; } } } } if (isset($constraints['filter']) && eF_checkParameter($constraints['filter'], 'text')) { $constraints['filter'] = trim(urldecode($constraints['filter']), "||||"); $result = eF_describeTable("courses"); $tableFields = array(); foreach ($result as $value) { $tableFields[] = "c." . $value['Field'] . ' like "%' . $constraints['filter'] . '%"'; } $where[] = "(" . implode(" OR ", $tableFields) . ")"; } if (isset($constraints['condition'])) { $where[] = $constraints['condition']; } if (isset($constraints['table_filters'])) { foreach ($constraints['table_filters'] as $constraint) { $where[] = $constraint['condition']; } } if (isset($constraints['branch_url']) && defined('G_BRANCH_URL') && G_BRANCH_URL) { $tree = new EfrontBranchesTree(); $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($tree->getNodeChildren($_SESSION['s_current_branch'])), RecursiveIteratorIterator::SELF_FIRST)); $subbranches[] = $_SESSION['s_current_branch']; foreach ($iterator as $key => $value) { $subbranches[] = $key; } $where[] = 'cb.branches_ID in (' . implode(',', $subbranches) . ')'; } return $where; }