MDL-23927 do not use = 'guest' because we have CFG->siteguest AND it matches any other username with accents and different case in MySQL

This commit is contained in:
Petr Skoda 2010-08-25 08:56:07 +00:00
parent 629e12fd81
commit b3df176457
10 changed files with 29 additions and 26 deletions

View file

@ -67,7 +67,7 @@ class enrolment_plugin_authorize
echo $OUTPUT->heading(get_string('choosemethod', 'enrol_authorize'));
}
if ($USER->username == 'guest') { // only real guest user, not for users with guest role
if (isguestuser()) { // only real guest user, not for users with guest role
$curcost = get_course_cost($course);
echo '<div class="mdl-align">';
echo '<p>'.get_string('paymentrequired').'</p>';

View file

@ -257,11 +257,11 @@ class course_enrolment_manager {
* @return array Array(totalusers => int, users => array)
*/
public function get_potential_users($enrolid, $search='', $searchanywhere=false, $page=0, $perpage=25) {
global $DB;
global $DB, $CFG;
// Add some additional sensible conditions
$tests = array("u.username <> 'guest'", 'u.deleted = 0', 'u.confirmed = 1');
$params = array();
$tests = array("id <> :guestid", 'u.deleted = 0', 'u.confirmed = 1');
$params = array('guestid' => $CFG->siteguest);
if (!empty($search)) {
$conditions = array('u.firstname','u.lastname');
$ilike = ' ' . $DB->sql_ilike();
@ -307,11 +307,11 @@ class course_enrolment_manager {
* @return array
*/
public function search_other_users($search='', $searchanywhere=false, $page=0, $perpage=25) {
global $DB;
global $DB, $CFG;
// Add some additional sensible conditions
$tests = array("u.username <> 'guest'", 'u.deleted = 0', 'u.confirmed = 1');
$params = array();
$tests = array("u.id <> :guestid", 'u.deleted = 0', 'u.confirmed = 1');
$params = array('guestid'=>$CFG->siteguest);
if (!empty($search)) {
$conditions = array('u.firstname','u.lastname');
$ilike = ' ' . $DB->sql_ilike();

View file

@ -310,7 +310,7 @@ class enrol_mnet_mnetservice_enrol {
* @return array
*/
public function course_enrolments($courseid, $roles=null) {
global $DB;
global $DB, $CFG;
if (!$client = get_mnet_remote_client()) {
die('Callable via XML-RPC only');
@ -323,11 +323,12 @@ class enrol_mnet_mnetservice_enrol {
JOIN {role} r ON e.roleid = r.id
WHERE u.mnethostid = :mnethostid
AND e.courseid = :courseid
AND u.username != 'guest'
AND u.id <> :guestid
AND u.confirmed = 1
AND u.deleted = 0";
$params['mnethostid'] = $client->id;
$params['courseid'] = $courseid;
$params['guestid'] = $CFG->siteguest;
if (!is_null($roles)) {
if (!is_array($roles)) {

View file

@ -160,7 +160,7 @@ class enrol_paypal_plugin extends enrol_plugin {
echo '<p>'.get_string('nocost', 'enrol_paypal').'</p>';
} else {
if ($USER->username == 'guest') { // force login only for guest user, not real users with guest role
if (isguestuser()) { // force login only for guest user, not real users with guest role
if (empty($CFG->loginhttps)) {
$wwwroot = $CFG->wwwroot;
} else {