Skip to content

Commit

Permalink
Merge branch 'MDL-54973_master-fix' of git://github.com/dmonllao/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Aug 17, 2016
2 parents b4bb1e6 + df76292 commit 72d088f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
13 changes: 1 addition & 12 deletions message/classes/search/base_message.php
Expand Up @@ -43,17 +43,6 @@ abstract class base_message extends \core_search\base {
*/
protected static $levels = [CONTEXT_USER];

/**
* Returns recordset containing message records.
*
* @param int $modifiedfrom timestamp
* @return \moodle_recordset
*/
public function get_recordset_by_timestamp($modifiedfrom = 0) {
global $DB;
return $DB->get_recordset_select('message_read', 'timecreated >= ?', array($modifiedfrom), 'timecreated ASC');
}

/**
* Returns the document associated with this message record.
*
Expand Down Expand Up @@ -135,4 +124,4 @@ protected function get_current_other_users($doc) {
return $users;
}

}
}
22 changes: 19 additions & 3 deletions message/classes/search/message_received.php
Expand Up @@ -35,6 +35,22 @@
*/
class message_received extends base_message {

/**
* Returns recordset containing message records.
*
* @param int $modifiedfrom timestamp
* @return \moodle_recordset
*/
public function get_recordset_by_timestamp($modifiedfrom = 0) {
global $DB;

// We don't want to index messages received from noreply and support users.
$params = array('modifiedfrom' => $modifiedfrom, 'noreplyuser' => \core_user::NOREPLY_USER,
'supportuser' => \core_user::SUPPORT_USER);
return $DB->get_recordset_select('message_read', 'timecreated >= :modifiedfrom AND
useridto != :noreplyuser AND useridto != :supportuser', $params, 'timecreated ASC');
}

/**
* Returns the document associated with this message record.
*
Expand Down Expand Up @@ -64,8 +80,8 @@ public function check_access($id) {
return \core_search\manager::ACCESS_DELETED;
}

$userfrom = $DB->get_record('user', array('id' => $message->useridfrom));
$userto = $DB->get_record('user', array('id' => $message->useridto));
$userfrom = \core_user::get_user($message->useridfrom, 'id, deleted');
$userto = \core_user::get_user($message->useridto, 'id, deleted');

if (!$userfrom || !$userto || $userfrom->deleted || $userto->deleted) {
return \core_search\manager::ACCESS_DELETED;
Expand All @@ -82,4 +98,4 @@ public function check_access($id) {
return \core_search\manager::ACCESS_GRANTED;
}

}
}
22 changes: 19 additions & 3 deletions message/classes/search/message_sent.php
Expand Up @@ -34,6 +34,22 @@
*/
class message_sent extends base_message {

/**
* Returns recordset containing message records.
*
* @param int $modifiedfrom timestamp
* @return \moodle_recordset
*/
public function get_recordset_by_timestamp($modifiedfrom = 0) {
global $DB;

// We don't want to index messages sent by noreply and support users.
$params = array('modifiedfrom' => $modifiedfrom, 'noreplyuser' => \core_user::NOREPLY_USER,
'supportuser' => \core_user::SUPPORT_USER);
return $DB->get_recordset_select('message_read', 'timecreated >= :modifiedfrom AND
useridfrom != :noreplyuser AND useridfrom != :supportuser', $params, 'timecreated ASC');
}

/**
* Returns the document associated with this message record.
*
Expand Down Expand Up @@ -63,8 +79,8 @@ public function check_access($id) {
return \core_search\manager::ACCESS_DELETED;
}

$userfrom = $DB->get_record('user', array('id' => $message->useridfrom));
$userto = $DB->get_record('user', array('id' => $message->useridto));
$userfrom = \core_user::get_user($message->useridfrom, 'id, deleted');
$userto = \core_user::get_user($message->useridto, 'id, deleted');

if (!$userfrom || !$userto || $userfrom->deleted || $userto->deleted) {
return \core_search\manager::ACCESS_DELETED;
Expand All @@ -81,4 +97,4 @@ public function check_access($id) {
return \core_search\manager::ACCESS_GRANTED;
}

}
}

0 comments on commit 72d088f

Please sign in to comment.