Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions administrator/components/com_users/views/users/tmpl/modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,29 @@
$enabledStates = array(0 => 'icon-publish', 1 => 'icon-unpublish');
$activatedStates = array(0 => 'icon-publish', 1 => 'icon-unpublish');
$userRequired = (int) $input->get('required', 0, 'int');

/**
* Mootools compatibility
*
* There is an extra option passed in the url for the iframe &ismoo=0 for the bootstraped field.
* By default the value will be 1 or defaults to mootools behaviour using function jSelectUser()
*
* This should be removed when mootools won't be shipped by Joomla.
*/
$isMoo = $input->getInt('ismoo', 1);

if ($isMoo)
{
$onClick = "window.parent.jSelectUser(this);window.parent.jQuery('.modal.in').modal('hide');";
}

?>
<div class="container-popup">
<form action="<?php echo JRoute::_('index.php?option=com_users&view=users&layout=modal&tmpl=component&groups=' . $input->get('groups', '', 'BASE64') . '&excluded=' . $input->get('excluded', '', 'BASE64')); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!$userRequired) : ?>
<div class="pull-left">
<button type="button" class="btn button-select" data-user-value="0" data-user-name="<?php echo $this->escape(JText::_('JLIB_FORM_SELECT_USER')); ?>"
data-user-field="<?php echo $this->escape($field);?>"><?php echo JText::_('JOPTION_NO_USER'); ?></button>&nbsp;
data-user-field="<?php echo $this->escape($field);?>" <?php if ($isMoo) : ?>value="" onclick="window.parent.jSelectUser(this)"<?php endif; ?>><?php echo JText::_('JOPTION_NO_USER'); ?></button>&nbsp;
</div>
<?php endif; ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
Expand Down Expand Up @@ -79,7 +95,7 @@
<tr class="row<?php echo $i % 2; ?>">
<td>
<a class="pointer button-select" href="#" data-user-value="<?php echo $item->id; ?>" data-user-name="<?php echo $this->escape($item->name); ?>"
data-user-field="<?php echo $this->escape($field);?>" onclick="if (window.parent) window.parent.jSelectUser(this);">
data-user-field="<?php echo $this->escape($field);?>" <?php if ($isMoo) : ?>onclick="<?php echo $onClick; ?>"<?php endif; ?>>
Copy link
Contributor Author

@dgrammatiko dgrammatiko Jun 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fedik onclick event isn't required for bootstrapped version, using the trick to pass a parameter to signify that the modal is bootstrapped we bring B/C even if there are mootools and bootstraped versions of the field in the same page.
Fast forward when joomla will completely remove mootools this parameter even if it exists will be ignored, so also future proof 😉

<?php echo $this->escape($item->name); ?>
</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// Set the link for the user selection page
$link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;required='
. ($required ? 1 : 0) . '&amp;field={field-user-id}'
. ($required ? 1 : 0) . '&amp;field={field-user-id}&amp;ismoo=0'
. (isset($groups) ? ('&amp;groups=' . base64_encode(json_encode($groups))) : '')
. (isset($excluded) ? ('&amp;excluded=' . base64_encode(json_encode($excluded))) : '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// Set the link for the user selection page
$link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;required='
. ($required ? 1 : 0) . '&amp;field={field-user-id}'
. ($required ? 1 : 0) . '&amp;field={field-user-id}&amp;ismoo=0'
. (isset($groups) ? ('&amp;groups=' . base64_encode(json_encode($groups))) : '')
. (isset($excluded) ? ('&amp;excluded=' . base64_encode(json_encode($excluded))) : '');

Expand Down