Skip to content

Commit

Permalink
IOMAD: Correctly detect all courses selection. Fixes moodle#85
Browse files Browse the repository at this point in the history
  • Loading branch information
thepurpleblob authored and turf212 committed Apr 25, 2014
1 parent 2d10189 commit 03ff779
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions blocks/iomad_company_admin/iomad_courses_form.php
Expand Up @@ -223,7 +223,7 @@

$companyids = $DB->get_records_menu('company', array(), 'id, name');
$companyids['none'] = get_string('nocompany', 'block_iomad_company_admin');
$companyids['0'] = get_string('allcourses', 'block_iomad_company_admin');
$companyids['all'] = get_string('allcourses', 'block_iomad_company_admin');
ksort($companyids);
$companyselect = new single_select($linkurl, 'company', $companyids, $company);
$companyselect->label = get_string('company', 'block_iomad_company_admin');
Expand All @@ -243,6 +243,14 @@
$sql = "SELECT * from {course} WHERE $select
id not in (select courseid from {company_course})";
$courses = $DB->get_records_sql($sql);
} else if ($company == 'all') {
// Get every course.
if (!empty($search)) {
$select = "fullname like '%$search%' AND id!=1";
} else {
$select = "id != 1";
}
$courses = $DB->get_records_select('course', $select);
} else {
// Get the courses belonging to that company only.
if (!empty($search)) {
Expand All @@ -254,14 +262,6 @@
cc.companyid=$company AND cc.courseid = c.id $select";
$courses = $DB->get_records_sql($sql);
}
} else {
// Get every course.
if (!empty($search)) {
$select = "fullname like '%$search%' AND id!=1";
} else {
$select = "id != 1";
}
$courses = $DB->get_records_select('course', $select);
}

// Display the table.
Expand Down

0 comments on commit 03ff779

Please sign in to comment.