useAssets(); // get the latest message(s) for the administrators $messages = $chat->getMessages( (new VBOChatSearch) ->forCategories($this->involvedCategories) ->sender(0, false) ->limit(1) ); if ($messages) { $watch_data = [ 'message_id' => $messages[0]->getID(), ]; // return the data to watch for notifications return (object) $watch_data; } return null; } /** * @inheritDoc */ public function getWidgetDetails() { // get common widget details from parent abstract class $details = parent::getWidgetDetails(); // append the modal rendering information $details['modal'] = [ 'add_class' => 'vbo-modal-large', ]; return $details; } /** * @inheritDoc */ public function render(?VBOMultitaskData $data = null) { // increase widget's instance counter static::$instance_counter++; // check whether the widget is being rendered via AJAX when adding it through the customizer $is_ajax = $this->isAjaxRendering(); // generate a unique ID for the widget wrapper instance $wrapper_instance = !$is_ajax ? static::$instance_counter : rand(); $wrapper_id = 'vbo-widget-admin-chat-' . $wrapper_instance; // get the chat mediator $chat = VBOFactory::getChatMediator(); // multitask data event identifier for clearing intervals $js_intvals_id = ''; $chat_context = null; if ($data && $data->isModalRendering()) { // access Multitask data $js_intvals_id = $data->getModalJsIdentifier(); // access context alias and id, if any $context_alias = $data->get('context_alias', '') ?: $this->options()->get('context_alias', ''); $context_id = $data->get('context_id', 0) ?: $this->options()->get('context_id', 0); if ($context_alias && $context_id) { // build chat for the given context $chat_context = $chat->createContext($context_alias, $context_id); } } /** * @see Keep the inline styling on the HTML elements for the JS functions to work properly. */ ?>