Skip to content

Commit

Permalink
added: user group element, option to not prefill the element with the…
Browse files Browse the repository at this point in the history
… current users groups
  • Loading branch information
pollen8 committed Nov 25, 2013
1 parent d99c11c commit 58fedb6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
12 changes: 11 additions & 1 deletion plugins/fabrik_element/usergroup/forms/fields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@
type="listfields"
description="PLG_ELEMENT_USERGROUP_USER_ELEMENT_DESC"
label="PLG_ELEMENT_USERGROUP_USER_ELEMENT_LABEL" />


<field name="default_to_current_user_group"
type="radio"
class="btn-group"
default="1"
description="PLG_ELEMENT_USERGROUP_DEFAULT_TO_CURRENT_USER_GROUPS_DESC"
label="PLG_ELEMENT_USERGROUP_DEFAULT_TO_CURRENT_USER_GROUPS_LABEL">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

</fieldset>
</fields>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
PLG_ELEMENT_USERGROUP_HIDDEN_LABEL="Hidden"
PLG_ELEMENT_USERGROUP_USER_ELEMENT_DESC="Set which element contains the user id. Required if you want records to be editable."
PLG_ELEMENT_USERGROUP_USER_ELEMENT_LABEL="User element"
PLG_ELEMENT_USERGROUP_DEFAULT_TO_CURRENT_USER_GROUPS_DESC="If set to no, no value is pre-selected. If set to yes, the current logged in user's groups will be pre-assigned to this element's values"
PLG_ELEMENT_USERGROUP_DEFAULT_TO_CURRENT_USER_GROUPS_LABEL="Default to current user's groups"

This file was deleted.

This file was deleted.

Empty file.
17 changes: 13 additions & 4 deletions plugins/fabrik_element/usergroup/usergroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,19 @@ public function getDefaultValue($data = array())
{
if (!isset($this->_default))
{
$user = JFactory::getUser();
$this->_default = $user->get('groups');
$this->_default = array_values($this->_default);
$this->_default = json_encode($this->_default);
$params = $this->getParams();

if ($params->get('default_to_current_user_group', 1))
{
$user = JFactory::getUser();
$this->_default = $user->get('groups');
$this->_default = array_values($this->_default);
$this->_default = json_encode($this->_default);
}
else
{
$this->_default =json_encode(array());
}
}

return $this->_default;
Expand Down

0 comments on commit 58fedb6

Please sign in to comment.