利用停止アカウントが手動登録に表示される

Re: 利用停止アカウントが手動登録に表示される

- Yuuki Murakami の投稿
返信数: 2

Yoshida様、ありがとうございます。

ソースを修正していました。
結果は以下の通りになりました。

1. student02とteacher02は利用停止にしているユーザですが、表示されています。

    画面の4名を全員追加すると

 

2. 利用停止にしているstudent02とteacher02は表示されなくなりました。

 

動きとしては問題ないと思いますが、1.の時点で「受験未登録ユーザ」の段階で
利用停止ユーザを表示させないようにする事は難しいでしょうか?

具体的には退学・除籍などで既に学校にいないユーザになるため、既に学校にいない
ユーザがなぜ表示されているかという問い合わせが質問させていただいた発端となります。

可能であれば1の段階で表示されないようにするのは難しいでしょうか?

質問ばかりして申し訳ありませんが、宜しくお願い致します。


Yuuki Murakami への返信

Re: 利用停止アカウントが手動登録に表示される

- Mitsuhiro Yoshida の投稿
画像 Developers 画像 Particularly helpful Moodlers 画像 Translators

大変失礼しました。ユーザ検索の関数 (find_users()) が未登録ユーザ用 (Enrol candidates) と登録済みユーザ用 (Enrolled users) の2箇所にありました。

大変お手数ですが、以下のプログラム修正をお試しください。

修正対象プログラム:
enrol/manual/locallib.php

修正箇所:
55行目

[ 修正前 ]
    public function find_users($search) {
        global $DB;
        // By default wherecondition retrieves all users except the deleted, not confirmed and guest.
        list($wherecondition, $params) = $this->search_sql($search, 'u');
        $params['enrolid'] = $this->enrolid;

        $fields      = 'SELECT ' . $this->required_fields_sql('u');
        $countfields = 'SELECT COUNT(1)';

        $sql = " FROM {user} u
            LEFT JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
                WHERE $wherecondition
                      AND ue.id IS NULL";

[ 修正後 ]
    public function find_users($search) {
        global $DB;
        // By default wherecondition retrieves all users except the deleted, not confirmed and guest.
        list($wherecondition, $params) = $this->search_sql($search, 'u');
        $params['enrolid'] = $this->enrolid;

        $fields      = 'SELECT ' . $this->required_fields_sql('u');
        $countfields = 'SELECT COUNT(1)';

        $wherecondition = "$wherecondition AND u.suspended = 0";
 
        $sql = " FROM {user} u
            LEFT JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
                WHERE $wherecondition
                      AND ue.id IS NULL";

------------------------------------------

修正箇所:
120行目

[ 修正前 ]
    public function find_users($search) {
        global $DB;
        // By default wherecondition retrieves all users except the deleted, not confirmed and guest.
        list($wherecondition, $params) = $this->search_sql($search, 'u');
        $params['enrolid'] = $this->enrolid;

        $fields      = 'SELECT ' . $this->required_fields_sql('u');
        $countfields = 'SELECT COUNT(1)';

        $sql = " FROM {user} u
                 JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
                WHERE $wherecondition";

[ 修正後 ]
    public function find_users($search) {
        global $DB;
        // By default wherecondition retrieves all users except the deleted, not confirmed and guest.
        list($wherecondition, $params) = $this->search_sql($search, 'u');
        $params['enrolid'] = $this->enrolid;

        $fields      = 'SELECT ' . $this->required_fields_sql('u');
        $countfields = 'SELECT COUNT(1)';

        $wherecondition = "$wherecondition AND u.suspended = 0";

        $sql = " FROM {user} u
                 JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
                WHERE $wherecondition";
Mitsuhiro Yoshida への返信

Re: 利用停止アカウントが手動登録に表示される

- Yuuki Murakami の投稿

Yoshida様、ありがとうございます。

今回の修正で受講未登録ユーザの方も利用停止アカウントは
非表示になりました。

本番サーバでも修正を行いたいと思います。

何度も対応していただき、ありがとうございました。

以上、宜しくお願い致します。