Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moodle 2.2 Fixes #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion attendees.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
*/

$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_course_login($course);
require_course_login($course,true,$cm);

// Actions the user can perform
$can_view_attendees = has_capability('mod/facetoface:viewattendees', $context);
Expand Down
2 changes: 1 addition & 1 deletion cancelsignup.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
print_error('error:incorrectcoursemoduleid', 'facetoface');
}

require_course_login($course);
require_course_login($course,true,$cm);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('mod/facetoface:view', $context);

Expand Down
31 changes: 18 additions & 13 deletions editattendees.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,38 @@
</p>
</td>
<td valign="top">
<label for="addselect"><?php print_string('potentialusers', 'role', $usercount); ?></label>
<label for="addselect"><?php print_string('potentialusers', 'role', count($availableusers));?></label>
<br />
<select name="addselect[]" size="20" id="addselect" multiple="multiple"
onfocus="getElementById('assignform').add.disabled=false;
getElementById('assignform').remove.disabled=true;
getElementById('assignform').removeselect.selectedIndex=-1;">
<?php
$i=0;
if (!empty($searchtext)) {
echo "<optgroup label=\"$strsearchresults (" . $availableusers->_numOfRows . ")\">\n";
if (count($availableusers) > MAX_USERS_PER_PAGE) {
if (!empty($searchtext)) {
$a=new stdClass();
$a->count=count($availableusers);
$a->search=$searchtext;
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
.'<optgroup label="'.get_string('toomanyusersmatchsearch','',$a).'"><option></option></optgroup>'."\n";
} else {
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
}
} else if (!empty($searchtext)) {
echo "<optgroup label=\"$strsearchresults (" . count($availableusers) . ")\">\n";
foreach ($availableusers as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
$i++;
}
echo "</optgroup>\n";

} else {
if ($usercount > MAX_USERS_PER_PAGE) {
echo '<optgroup label="'.get_string('toomanytoshow').'"><option></option></optgroup>'."\n"
.'<optgroup label="'.get_string('trysearching').'"><option></option></optgroup>'."\n";
} else {
foreach ($availableusers as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
$i++;
}
foreach ($availableusers as $user) {
$fullname = fullname($user, true);
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
$i++;
}
}
if ($i==0) {
Expand Down
30 changes: 15 additions & 15 deletions editattendees.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
}

/// Check essential permissions
require_course_login($course);
require_course_login($course,true,$cm);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('mod/facetoface:viewattendees', $context);

/// Get some language strings
$strsearch = get_string('search');
$strshowall = get_string('showall');
$strshowall = get_string('showall','',get_string('users'));
$strsearchresults = get_string('searchresults');
$strfacetofaces = get_string('modulenameplural', 'facetoface');
$strfacetoface = get_string('modulename', 'facetoface');
Expand Down Expand Up @@ -145,19 +145,24 @@

/// Apply search terms
$searchtext = trim($searchtext);
$params=array();
if ($searchtext !== '') { // Search for a subset of remaining users
$LIKE = $DB->sql_ilike();
$FULLNAME = $DB->sql_fullname();

$selectsql = " AND ($FULLNAME $LIKE '%$searchtext%' OR
email $LIKE '%$searchtext%' OR
idnumber $LIKE '%$searchtext%' OR
username $LIKE '%$searchtext%') ";
$selectsql = " AND (" . $DB->sql_like($FULLNAME,':searchtext1') . " OR " .
$DB->sql_like('email',':searchtext2') . " OR " .
$DB->sql_like('idnumber',':searchtext3'). " OR " .
$DB->sql_like('username',':searchtext4'). ")";
$select .= $selectsql;
//Because moodle REQUIRES a 1:1 relationship between variables for some annoying reason
$params['searchtext1']="%$searchtext%";
$params['searchtext2']="%$searchtext%";
$params['searchtext3']="%$searchtext%";
$params['searchtext4']="%$searchtext%";
}

/// All non-signed up system users
$availableusers = $DB->get_recordset_sql('SELECT id, firstname, lastname, email
$availableusers = $DB->get_records_sql('SELECT id, firstname, lastname, email
FROM {user}
WHERE '.$select.'
AND id NOT IN
Expand All @@ -170,14 +175,11 @@
AND ss.statuscode >= '.MDL_F2F_STATUS_BOOKED.'
AND ss.superceded = 0
)
ORDER BY lastname ASC, firstname ASC');

$usercount = $DB->count_records_select('user', $select) - $existingcount;

ORDER BY lastname ASC, firstname ASC',$params);

// Get all signed up non-attendees
$nonattendees = 0;
$nonattendees_rs = $DB->get_recordset_sql(
$nonattendees_rs = $DB->get_records_sql(
"
SELECT
u.id,
Expand Down Expand Up @@ -225,8 +227,6 @@
/// Prints a form to add/remove users from the session
include('editattendees.html');

$nonattendees_rs->close();

if (!empty($errors)) {
$msg = '<p>';
foreach ($errors as $e) {
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require_course_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('mod/facetoface:view', $context);
$PAGE->set_pagelayout('incourse');

add_to_log($course->id, 'facetoface', 'view all', "index.php?id=$course->id");

Expand Down
Loading