ユーザのメールフラグを変更すると、そのユーザはMoodleからのメールを受信できなくなったり、受信できるようになったりします。MoodleにはCLIスクリプトが含まれており、一度に1人または複数のユーザのメールフラグを変更できます。また、メールフラグがオフかオンかの現在の状態を表示することもできます。このスクリプトの使用例としては、メール転送エージェント(例:postfix)のログファイルをスキャンし、そこで報告されているメールアドレスを抽出する処理の自動化が考えられます。メールが無効であったり、配信を拒否されたりした場合、そのアドレスをCLIスクリプトの引数として渡してemailstopフラグを変更し、そのユーザがそれ以上メールを受信しないようにできます。
CLIスクリプトemailstop.phpは、Moodleインストールのadmin/cliにあります。
使用できるコマンドライン引数は次のとおりです:
-h, --help Print out a help screen that mentions all possible agruments that can be set. -e, --email=email Specify a user by email, separate many users by comma. -i, --id=id Specify a user by the internal database id, separate many ids by comma. -q, --quiet Do not print anything out to stdout. The success of the script can still be controlled by the exit code. -s, --stop=0|1|off|on Set a new value for emailstop flag -u, --username=username Specify user by username, separate many users by comma.
1人または複数のユーザを指定するには、-e、-i、-uのいずれか1つのオプションだけを使用できます。便宜上、複数のユーザを一度に設定でき、その場合はカンマで区切る必要があります(例:php admin/cli/emailstop.php -u=student1,student2,student3)。
-qパラメータを指定すると、stdoutへの出力がすべて抑止されます。そのため、-s引数を付けずに-qを使用しても、あまり意味がありません。
呼び出し例:
$ php admin/cli/emailstop.php --email=student1@example.org --stop=1 -q
メールアドレスがstudent1@example.orgのユーザのメール受信を無効にします。出力は生成されません。
$ php admin/cli/emailstop.php --email=student1@example.org
メールアドレスがstudent1@example.orgのユーザのemailstopフラグの状態を表示します。