MDL-63280 core: removed 'message_conversation_area' table
These new fields have been added to the 'message_conversations' table.
This commit is contained in:
+43
-62
@@ -76,12 +76,12 @@ class api {
|
||||
/**
|
||||
* The state for an enabled conversation area.
|
||||
*/
|
||||
const MESSAGE_CONVERSATION_AREA_ENABLED = 1;
|
||||
const MESSAGE_CONVERSATION_ENABLED = 1;
|
||||
|
||||
/**
|
||||
* The state for a disabled conversation area.
|
||||
*/
|
||||
const MESSAGE_CONVERSATION_AREA_DISABLED = 0;
|
||||
const MESSAGE_CONVERSATION_DISABLED = 0;
|
||||
|
||||
/**
|
||||
* Handles searching for messages in the message area.
|
||||
@@ -1469,10 +1469,18 @@ class api {
|
||||
*
|
||||
* @param int $type The type of conversation
|
||||
* @param int[] $userids The array of users to add to the conversation
|
||||
* @param string $name The name of the conversation
|
||||
* @param string|null $name The name of the conversation
|
||||
* @param int $enabled Determines if the conversation is created enabled or disabled
|
||||
* @param string|null $component Defines the Moodle component which the conversation belongs to, if any
|
||||
* @param string|null $itemtype Defines the type of the component
|
||||
* @param int|null $itemid The id of the component
|
||||
* @param int|null $contextid The id of the context
|
||||
* @return \stdClass
|
||||
*/
|
||||
public static function create_conversation(int $type, array $userids, string $name = null) {
|
||||
public static function create_conversation(int $type, array $userids, string $name = null,
|
||||
int $enabled = self::MESSAGE_CONVERSATION_ENABLED, string $component = null,
|
||||
string $itemtype = null, int $itemid = null, int $contextid = null) {
|
||||
|
||||
global $DB;
|
||||
|
||||
// Sanity check.
|
||||
@@ -1489,7 +1497,13 @@ class api {
|
||||
if ($type == self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL) {
|
||||
$conversation->convhash = helper::get_conversation_hash($userids);
|
||||
}
|
||||
$conversation->component = $component;
|
||||
$conversation->itemtype = $itemtype;
|
||||
$conversation->itemid = $itemid;
|
||||
$conversation->contextid = $contextid;
|
||||
$conversation->enabled = $enabled;
|
||||
$conversation->timecreated = time();
|
||||
$conversation->timemodified = $conversation->timecreated;
|
||||
$conversation->id = $DB->insert_record('message_conversations', $conversation);
|
||||
|
||||
// Add users to this conversation.
|
||||
@@ -1986,39 +2000,6 @@ class api {
|
||||
return $DB->count_records('message_conversation_members', ['conversationid' => $convid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create message conversation area.
|
||||
*
|
||||
* @param string $component Defines the Moodle component which the area was added to
|
||||
* @param string $itemtype Defines the type of the component
|
||||
* @param int $itemid The id of the component
|
||||
* @param int $contextid The id of the context
|
||||
* @param string $name The main name of the area
|
||||
* @param int $enabled Enable or disable the conversation area
|
||||
* @return \stdClass
|
||||
*/
|
||||
public static function create_conversation_area(string $component, string $itemtype, int $itemid, int $contextid, string $name,
|
||||
int $enabled = self::MESSAGE_CONVERSATION_AREA_DISABLED) {
|
||||
global $DB;
|
||||
|
||||
// Create a conversation.
|
||||
$conversation = self::create_conversation(self::MESSAGE_CONVERSATION_TYPE_GROUP, array(), $name);
|
||||
|
||||
// Create a conversation area.
|
||||
$conversationarea = new \stdClass;
|
||||
$conversationarea->conversationid = $conversation->id;
|
||||
$conversationarea->component = $component;
|
||||
$conversationarea->itemtype = $itemtype;
|
||||
$conversationarea->itemid = $itemid;
|
||||
$conversationarea->contextid = $contextid;
|
||||
$conversationarea->enabled = $enabled;
|
||||
$conversationarea->timecreated = time();
|
||||
$conversationarea->timemodified = $conversationarea->timecreated;
|
||||
$conversationarea->id = $DB->insert_record('message_conversation_area', $conversationarea);
|
||||
|
||||
return $conversationarea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether or not a conversation area is enabled.
|
||||
*
|
||||
@@ -2031,30 +2012,30 @@ class api {
|
||||
public static function is_conversation_area_enabled(string $component, string $itemtype, int $itemid, int $contextid) : bool {
|
||||
global $DB;
|
||||
|
||||
return $DB->record_exists('message_conversation_area',
|
||||
return $DB->record_exists('message_conversations',
|
||||
[
|
||||
'itemid' => $itemid,
|
||||
'contextid' => $contextid,
|
||||
'component' => $component,
|
||||
'itemtype' => $itemtype,
|
||||
'enabled' => self::MESSAGE_CONVERSATION_AREA_ENABLED
|
||||
'enabled' => self::MESSAGE_CONVERSATION_ENABLED
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get conversation area.
|
||||
* Get conversation by area.
|
||||
*
|
||||
* @param string $component Defines the Moodle component which the area was added to.
|
||||
* @param string $itemtype Defines the type of the component.
|
||||
* @param int $itemid The id of the component.
|
||||
* @param int $contextid The id of the context.
|
||||
* @return object message_conversation_area.
|
||||
* @param int $itemid The id of the component.
|
||||
* @param int $contextid The id of the context.
|
||||
* @return \stdClass
|
||||
*/
|
||||
public static function get_conversation_area(string $component, string $itemtype, int $itemid, int $contextid) {
|
||||
public static function get_conversation_by_area(string $component, string $itemtype, int $itemid, int $contextid) {
|
||||
global $DB;
|
||||
|
||||
return $DB->get_record('message_conversation_area',
|
||||
return $DB->get_record('message_conversations',
|
||||
[
|
||||
'itemid' => $itemid,
|
||||
'contextid' => $contextid,
|
||||
@@ -2065,41 +2046,41 @@ class api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable a conversation area.
|
||||
* Enable a conversation.
|
||||
*
|
||||
* @param int $conversationareaid The id of a conversation area.
|
||||
* @param int $conversationid The id of the conversation.
|
||||
* @return void
|
||||
*/
|
||||
public static function enable_conversation_area(int $conversationareaid) {
|
||||
public static function enable_conversation(int $conversationid) {
|
||||
global $DB;
|
||||
|
||||
$conversationarea = new \stdClass();
|
||||
$conversationarea->id = $conversationareaid;
|
||||
$conversationarea->enabled = self::MESSAGE_CONVERSATION_AREA_ENABLED;
|
||||
$conversationarea->timemodified = time();
|
||||
$DB->update_record('message_conversation_area', $conversationarea);
|
||||
$conversation = new \stdClass();
|
||||
$conversation->id = $conversationid;
|
||||
$conversation->enabled = self::MESSAGE_CONVERSATION_ENABLED;
|
||||
$conversation->timemodified = time();
|
||||
$DB->update_record('message_conversations', $conversation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable a conversation area.
|
||||
* Disable a conversation.
|
||||
*
|
||||
* @param int $conversationareaid The id of a conversation area.
|
||||
* @param int $conversationid The id of the conversation.
|
||||
* @return void
|
||||
*/
|
||||
public static function disable_conversation_area(int $conversationareaid) {
|
||||
public static function disable_conversation(int $conversationid) {
|
||||
global $DB;
|
||||
|
||||
$conversationarea = new \stdClass();
|
||||
$conversationarea->id = $conversationareaid;
|
||||
$conversationarea->enabled = self::MESSAGE_CONVERSATION_AREA_DISABLED;
|
||||
$conversationarea->timemodified = time();
|
||||
$DB->update_record('message_conversation_area', $conversationarea);
|
||||
$conversation = new \stdClass();
|
||||
$conversation->id = $conversationid;
|
||||
$conversation->enabled = self::MESSAGE_CONVERSATION_DISABLED;
|
||||
$conversation->timemodified = time();
|
||||
$DB->update_record('message_conversations', $conversation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the name of a conversation.
|
||||
*
|
||||
* @param int $conversationid The id of a conversation.
|
||||
* @param int $conversationid The id of a conversation.
|
||||
* @param string $name The main name of the area
|
||||
* @return void
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user