MDL-36941 core: convert existing api to use new table structure

Also deprecated the following functions -

1. message_move_userfrom_unread2read - It is not necessary
   for us to mark a message as read on user deletion.
2. message_get_blocked_users - Horrible logic used to
   determine if a user is blocked via reference on some
   randomly chosen 'isblocked' variable.
3. message_get_contacts - The same as above. This can be
   done in a much nicer way.
4. message_mark_message_read - We want two functions to do
   this to avoid confusing messages and notifications.
5. message_can_delete_message - This assumed the variable
   $message contained the 'useridto' property, which
   was present in the old table structure. We do not want
   future usages where a query is done on the new table
   and is simply passed as this won't contain this property.
6. message_delete_message - Same as above.
This commit is contained in:
Mark Nelson 2018-01-04 15:01:37 +08:00
parent 4cd439887a
commit 883ce42127
29 changed files with 1714 additions and 1096 deletions

View file

@ -33,7 +33,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class phpunit_message_sink {
/** @var array of records from message_read table */
/** @var array of records from messages table */
protected $messages = array();
/**
@ -48,7 +48,7 @@ class phpunit_message_sink {
/**
* To be called from phpunit_util only!
*
* @param stdClass $message record from message_read table
* @param stdClass $message record from messages table
*/
public function add_message($message) {
/* Number messages from 0. */
@ -58,7 +58,7 @@ class phpunit_message_sink {
/**
* Returns all redirected messages.
*
* The instances are records form the message_read table.
* The instances are records from the messages table.
* The array indexes are numbered from 0 and the order is matching
* the creation of events.
*

View file

@ -50,7 +50,7 @@ class phpunit_phpmailer_sink {
/**
* To be called from phpunit_util only!
*
* @param stdClass $message record from message_read table
* @param stdClass $message record from messages table
*/
public function add_message($message) {
/* Number messages from 0. */
@ -60,7 +60,7 @@ class phpunit_phpmailer_sink {
/**
* Returns all redirected messages.
*
* The instances are records form the message_read table.
* The instances are records from the messages table.
* The array indexes are numbered from 0 and the order is matching
* the creation of events.
*

View file

@ -714,7 +714,7 @@ class phpunit_util extends testing_util {
/**
* To be called from messagelib.php only!
*
* @param stdClass $message record from message_read table
* @param stdClass $message record from messages table
* @return bool true means send message, false means message "sent" to sink.
*/
public static function message_sent($message) {
@ -765,7 +765,7 @@ class phpunit_util extends testing_util {
/**
* To be called from messagelib.php only!
*
* @param stdClass $message record from message_read table
* @param stdClass $message record from messages table
* @return bool true means send message, false means message "sent" to sink.
*/
public static function phpmailer_sent($message) {