getDocument(); $wa = $document->getWebAssetManager(); // Build the script $script = array(); $script[] = ' function jSelectUsers_'.$this->id.'(ids, count, object) {'; $script[] = ' document.getElementById("'.$this->id.'_ids").value = ids;'; $script[] = ' document.getElementById("'.$this->id.'_count").value = count;'; // $script[] = ' SqueezeBox.close();'; $script[] = ' $("#user-modal").modal("hide");'; $script[] = ' }'; // Add to document head $wa->addInlineScript(implode("\n", $script)); // Setup variables for display $html = array(); $eventid = isset($this->element['eventid']) ? (int)$this->element['eventid'] : 0; $link = 'index.php?option=com_jem&view=editevent&layout=chooseusers&tmpl=component&function=jSelectUsers_'.$this->id.'&a_id='.$eventid; // we expect a list of unique, non-zero numbers $ids = explode(',', $this->value); array_walk($ids, function(&$v, $k){$v = (int)$v;}); $ids = array_filter($ids); $ids = array_unique($ids); $idlist = implode(',', $ids); if (!empty($idlist)) { $db = Factory::getContainer()->get('DatabaseDriver'); $query = $db->getQuery(true); $query->select('COUNT(id)'); $query->from('#__users'); $query->where('id IN ('.$idlist.')'); $db->setQuery($query); // if ($error = $db->getErrorMsg()) { // \Joomla\CMS\Factory::getApplication()->enqueueMessage($error, 'warning'); // } try { $count = (int)$db->loadResult(); } catch (RuntimeException $e) { \Joomla\CMS\Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning'); } } else { $count = 0; } // if (empty($count)) { // $count = Text::_('COM_JEM_SELECT_USERS'); // } // $count = htmlspecialchars($count, ENT_QUOTES, 'UTF-8'); // The current contact input field $html[] = ' '; // The contact select button // $html[] = ' '. // Text::_('COM_JEM_SELECT').''; $html[] = HTMLHelper::_( 'bootstrap.renderModal', 'user-modal', array( 'url' => $link.'&'.Session::getFormToken().'=1', 'title' => Text::_('COM_JEM_SELECT'), 'width' => '800px', 'height' => '450px', 'footer' => '' ) ); $html[] =''; // class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = ''; $html[] = ''; return implode("\n", $html); } } ?>