|
|
|
@ -112,7 +112,7 @@
|
|
|
|
|
// Custom properties
|
|
|
|
|
/**
|
|
|
|
|
* @var string[] $string_tags
|
|
|
|
|
* String tags originally applied to room.
|
|
|
|
|
* String tags from external sources originally applied to room.
|
|
|
|
|
*/
|
|
|
|
|
private array $string_tags = [];
|
|
|
|
|
|
|
|
|
@ -120,9 +120,11 @@
|
|
|
|
|
* @var CommunityTag[] $tags
|
|
|
|
|
* Tag-based information from multiple sources.
|
|
|
|
|
*
|
|
|
|
|
* Not valid in fetching phase.
|
|
|
|
|
*
|
|
|
|
|
* Custom attribute.
|
|
|
|
|
*/
|
|
|
|
|
private array $tags = [];
|
|
|
|
|
private ?array $tags = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string $language_flag;
|
|
|
|
@ -157,10 +159,16 @@
|
|
|
|
|
if ($suppress_processing) return;
|
|
|
|
|
|
|
|
|
|
$this->language_flag = $details['language_flag'] ?? $this->get_language_flag();
|
|
|
|
|
$this->extract_tags_from_description();
|
|
|
|
|
$this->tags = isset($details['tags'])
|
|
|
|
|
? CommunityTag::from_details_array($details['tags'])
|
|
|
|
|
: $this->get_derived_tags();
|
|
|
|
|
if (!isset($details['tags'])) {
|
|
|
|
|
// Fetching phase.
|
|
|
|
|
// String tags are added, object tags are on-demand only.
|
|
|
|
|
$this->tags = null;
|
|
|
|
|
$this->extract_tags_from_description();
|
|
|
|
|
} else {
|
|
|
|
|
// Post fetching phase.
|
|
|
|
|
// Fetched & derived object tags are loaded and used.
|
|
|
|
|
$this->tags = CommunityTag::from_details_array($details['tags']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -240,6 +248,7 @@
|
|
|
|
|
public function jsonSerialize(): array {
|
|
|
|
|
$details = get_object_vars($this);
|
|
|
|
|
unset($details['server']);
|
|
|
|
|
$details['tags'] = $this->get_room_tags();
|
|
|
|
|
return $details;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -418,21 +427,14 @@
|
|
|
|
|
* @param string[] $tags
|
|
|
|
|
*/
|
|
|
|
|
public function add_tags(array $tags) {
|
|
|
|
|
$new_string_tags = [];
|
|
|
|
|
foreach ($tags as $tag) {
|
|
|
|
|
if (str_contains($this->token, "mathnodes")) {
|
|
|
|
|
log_debug("new tag: '$tag'");
|
|
|
|
|
}
|
|
|
|
|
if (strlen(trim($tag)) == 0) continue;
|
|
|
|
|
$this->string_tags[] = $tag;
|
|
|
|
|
if ($this->parse_language_tag($tag)) continue;
|
|
|
|
|
$new_string_tags[] = $tag;
|
|
|
|
|
$this->string_tags[] = $tag;
|
|
|
|
|
}
|
|
|
|
|
$new_tags = CommunityTag::from_user_tags($new_string_tags);
|
|
|
|
|
$this->tags = CommunityTag::dedupe_tags([
|
|
|
|
|
...$this->tags,
|
|
|
|
|
...$new_tags
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -637,6 +639,15 @@
|
|
|
|
|
return $this->string_tags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return CommunityTag[]
|
|
|
|
|
*/
|
|
|
|
|
private function get_user_tags(): array {
|
|
|
|
|
return CommunityTag::dedupe_tags(
|
|
|
|
|
CommunityTag::from_user_tags($this->string_tags),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the derived tags associated with this room.
|
|
|
|
|
* @return CommunityTag[] Array of tags.
|
|
|
|
@ -649,9 +660,7 @@
|
|
|
|
|
*/
|
|
|
|
|
$derived_tags = [];
|
|
|
|
|
|
|
|
|
|
$USERS_PER_STAFF_WARNING = CommunityRoom::USERS_PER_STAFF_WARNING;
|
|
|
|
|
|
|
|
|
|
if (in_array($this->get_room_identifier(), $ROOMS_USED_BY_PROJECT)) {
|
|
|
|
|
if ($this->matched_by_list($ROOMS_USED_BY_PROJECT)) {
|
|
|
|
|
$derived_tags[] = ReservedTags::used_by_project();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -696,7 +705,7 @@
|
|
|
|
|
* @return CommunityTag[] Array of tags.
|
|
|
|
|
*/
|
|
|
|
|
function get_room_tags(): array {
|
|
|
|
|
return $this->tags;
|
|
|
|
|
return [...$this->get_derived_tags(), ...$this->get_user_tags()];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|