$status = USER_TEACHER; } else { $stat = Database::get()->querySingle("SELECT status FROM course_user\n WHERE user_id = ?d AND\n course_id = ?d", $uid, $course_id); if ($stat) { $status = $stat->status; } else { // the department manager has rights to the courses of his department(s) if ($is_departmentmanage_user && $is_usermanage_user && !$is_power_user && !$is_admin && isset($course_code)) { require_once 'include/lib/hierarchy.class.php'; require_once 'include/lib/course.class.php'; require_once 'include/lib/user.class.php'; $treeObj = new Hierarchy(); $courseObj = new Course(); $userObj = new User(); $atleastone = false; $subtrees = $treeObj->buildSubtrees($userObj->getDepartmentIds($uid)); $depIds = $courseObj->getDepartmentIds($course_id); foreach ($depIds as $depId) { if (in_array($depId, $subtrees)) { $atleastone = true; break; } } if ($atleastone) { $status = 1; $is_course_admin = true; $_SESSION['courses'][$course_code] = USER_DEPARTMENTMANAGER; } } } }
} } if (!empty($email)) { $criteria[] = 'email LIKE ?s'; $terms[] = '%' . $email . '%'; if ($search == 'inactive') { $criteria[] = 'expires_at < ' . DBHelper::timeAfter(); } // Department search $depqryadd = ''; $dep = isset($_POST['department']) ? intval($_POST['department']) : 0; if ($dep || isDepartmentAdmin()) { $depqryadd = ', user_department'; $subs = array(); if ($dep) { $subs = $tree->buildSubtrees(array($dep)); } else { if (isDepartmentAdmin()) { $subs = $user->getDepartmentIds($uid); } } $count = 0; foreach ($subs as $key => $id) { $terms[] = $id; validateNode($id, isDepartmentAdmin()); $count++; } $pref = $c ? 'a' : 'user'; $criteria[] = $pref . '.user.id = user_department.user'; $criteria[] = 'department IN (' . array_fill(0, $count, '?s') . ')'; }
$terms = array(); if (!empty($searchtitle)) { $query .= ' AND title LIKE ?s'; $terms[] = '%' . $searchtitle . '%'; } if (!empty($searchcode)) { $query .= ' AND (course.code LIKE ?s OR public_code LIKE ?s)'; $terms[] = '%' . $searchcode . '%'; $terms[] = '%' . $searchcode . '%'; } if ($searchtype != "-1") { $query .= ' AND visible = ?d'; $terms[] = $searchtype; } if ($searchfaculte) { $subs = $tree->buildSubtrees(array($searchfaculte)); $ids = 0; foreach ($subs as $key => $id) { $terms[] = $id; $ids++; } $query .= ' AND hierarchy.id IN (' . implode(', ', array_fill(0, $ids, '?d')) . ')'; } if (isset($_GET['reg_flag']) and !empty($_GET['date'])) { $query .= ' AND created ' . ($_GET['reg_flag'] == 1 ? '>=' : '<=') . ' ?s'; $date_created_at = DateTime::createFromFormat("d-m-Y H:i", $_GET['date']); $terms[] = $date_created_at->format("Y-m-d H:i:s"); } // Datatables internal search $filter_terms = array(); if (!empty($_GET['sSearch'])) {
} } } else { // department exists $numofcourses = getdepnumcourses($fc); if (count($tree->buildRootsArray()) > 1) { $tool_content .= $tree->buildRootsSelectForm($fc); } $tool_content .= "<form action='{$_SERVER['SCRIPT_NAME']}' method='post'>"; $tool_content .= "<table class='table-default'>\n <tr><th><a name='top'></a>{$langFaculty}: " . $tree->getFullPath($fc, false, $_SERVER['SCRIPT_NAME'] . '?fc=') . "\n </th></tr></table><br />"; if ($numofcourses > 0) { $tool_content .= expanded_faculte($fc, $uid); $tool_content .= "<br /><div align='right'><input class='btn btn-primary' type='submit' name='submit' value='{$langRegistration}' /> </div>"; } else { $tool_content .= $tree->buildDepartmentChildrenNavigationHtml($fc, 'courses'); $subTrees = $tree->buildSubtrees(array($fc)); if (count($subTrees) <= 1) { // is leaf $tool_content .= "<br /><div class=alert1>{$langNoCoursesAvailable}</div>\n"; } } $tool_content .= "</form>"; } // end of else (department exists) } $tool_content .= "<script type='text/javascript'>\$(course_list_init);\nvar themeimg = '" . js_escape($themeimg) . "';\nvar lang = {\n unCourse: '" . js_escape($langUnCourse) . "',\n cancel: '" . js_escape($langCancel) . "',\n close: '" . js_escape($langClose) . "',\n unregCourse: '" . js_escape($langUnregCourse) . "',\n reregisterImpossible: '" . js_escape("{$langConfirmUnregCours} {$m['unsub']}") . "',\n invalidCode: '" . js_escape($langInvalidCode) . "',\n};</script>"; load_js('tools.js'); draw($tool_content, 1, null, $head_content); function getfacfromfc($dep_id) { $fac = Database::get()->querySingle("SELECT name FROM hierarchy WHERE id = ?d", intval($dep_id));
// preload all nodes $allnodes = array(); Database::get()->queryFunc("select * from hierarchy order by lft", function($row) use (&$allnodes) { $allnodes[] = $row; }); // preload all user's nodes $usernodes = array(); if ($uid) { $usernodes = $user->getDepartmentNodes($uid); } // initialize vars $defs = (is_array($defaults)) ? $defaults : array(intval($defaults)); $subdefs = ($allow_only_defaults) ? $tree->buildSubtrees($defs, $allnodes) : array(); $suballowed = ($allowables != null) ? $tree->buildSubtrees($allowables, $allnodes) : null; $excludeLft = 0; $excludeRgt = 0; $fetchNodeById = "select * from hierarchy where id = ?d"; if ($requestId <= 0) { $nodes = $tree->buildRootsArray(); foreach ($tree_array as $key => $value) { $data[] = array( "id" => $key, "text" => $value ); } } else {