2013-04-23 11:47:57 +00:00
|
|
|
<div id="acl-wrapper">
|
2020-01-14 02:58:01 +00:00
|
|
|
<div class="panel-group" id="visibility-accordion-{{$input_group_id}}" role="tablist" aria-multiselectable="true">
|
2019-11-28 17:42:12 +00:00
|
|
|
<div class="panel panel-success">
|
2020-01-14 02:58:01 +00:00
|
|
|
<label class="panel-heading{{if $visibility != 'public'}} collapsed{{/if}}" id="visibility-public-heading-{{$input_group_id}}" aria-expanded="{{if $visibility == 'public'}}true{{else}}false{{/if}}">
|
|
|
|
<input type="radio" name="{{$input_names.visibility}}" id="visibility-public-{{$input_group_id}}" value="public" tabindex="14" {{if $visibility == 'public'}}checked{{/if}}>
|
2019-11-30 15:47:25 +00:00
|
|
|
<i class="fa fa-globe"></i> {{$public_title}}
|
|
|
|
</label>
|
2020-01-14 02:58:01 +00:00
|
|
|
<fieldset id="visibility-public-panel-{{$input_group_id}}" class="panel-collapse collapse{{if $visibility == 'public'}} in{{/if}}" role="tabpanel" aria-labelledby="visibility-public-heading-{{$input_group_id}}" {{if $visibility != 'public'}}disabled{{/if}}>
|
2019-11-28 17:42:12 +00:00
|
|
|
<div class="panel-body">
|
|
|
|
<p>{{$public_desc}}</p>
|
|
|
|
{{if $for_federation}}
|
2020-02-22 08:54:28 +00:00
|
|
|
{{if $jotnets_fields}}
|
2019-11-28 17:42:12 +00:00
|
|
|
{{if $jotnets_fields|count < 3}}
|
|
|
|
<div class="profile-jot-net">
|
|
|
|
{{else}}
|
|
|
|
<details class="profile-jot-net">
|
|
|
|
<summary>{{$jotnets_summary}}</summary>
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{foreach $jotnets_fields as $jotnets_field}}
|
|
|
|
{{if $jotnets_field.type == 'checkbox'}}
|
|
|
|
{{include file="field_checkbox.tpl" field=$jotnets_field.field}}
|
|
|
|
{{elseif $jotnets_field.type == 'select'}}
|
|
|
|
{{include file="field_select.tpl" field=$jotnets_field.field}}
|
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
|
|
|
|
|
|
|
{{if $jotnets_fields|count >= 3}}
|
|
|
|
</details>
|
|
|
|
{{else}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
{{/if}}
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
</div>
|
|
|
|
<div class="panel panel-info">
|
2020-01-14 02:58:01 +00:00
|
|
|
<label class="panel-heading{{if $visibility != 'custom'}} collapsed{{/if}}" id="visibility-custom-heading-{{$input_group_id}}" aria-expanded="{{if $visibility == 'custom'}}true{{else}}false{{/if}}">
|
|
|
|
<input type="radio" name="{{$input_names.visibility}}" id="visibility-custom-{{$input_group_id}}" value="custom" tabindex="15" {{if $visibility == 'custom'}}checked{{/if}}>
|
2019-11-30 15:47:25 +00:00
|
|
|
<i class="fa fa-lock"></i> {{$custom_title}}
|
|
|
|
</label>
|
2020-01-14 02:58:01 +00:00
|
|
|
<fieldset id="visibility-custom-panel-{{$input_group_id}}" class="panel-collapse collapse{{if $visibility == 'custom'}} in{{/if}}" role="tabpanel" aria-labelledby="visibility-custom-heading-{{$input_group_id}}" {{if $visibility != 'custom'}}disabled{{/if}}>
|
|
|
|
<input type="hidden" name="{{$input_names.group_allow}}" value="{{$group_allow}}"/>
|
|
|
|
<input type="hidden" name="{{$input_names.contact_allow}}" value="{{$contact_allow}}"/>
|
|
|
|
<input type="hidden" name="{{$input_names.group_deny}}" value="{{$group_deny}}"/>
|
|
|
|
<input type="hidden" name="{{$input_names.contact_deny}}" value="{{$contact_deny}}"/>
|
2019-11-28 17:42:12 +00:00
|
|
|
<div class="panel-body">
|
|
|
|
<p>{{$custom_desc}}</p>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2020-01-14 02:58:01 +00:00
|
|
|
<label for="acl_allow-{{$input_group_id}}">{{$allow_label}}</label>
|
|
|
|
<input type="text" class="form-control input-lg" id="acl_allow-{{$input_group_id}}">
|
2019-11-28 17:42:12 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2020-01-14 02:58:01 +00:00
|
|
|
<label for="acl_deny-{{$input_group_id}}">{{$deny_label}}</label>
|
|
|
|
<input type="text" class="form-control input-lg" id="acl_deny-{{$input_group_id}}">
|
2019-11-28 17:42:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
2013-04-23 11:47:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2019-11-28 17:42:12 +00:00
|
|
|
{{if $for_federation}}
|
|
|
|
<div class="form-group">
|
2020-01-14 02:58:01 +00:00
|
|
|
<label for="profile-jot-email" id="profile-jot-email-label-{{$input_group_id}}">{{$emailcc}}</label>
|
|
|
|
<input type="text" name="{{$input_names.emailcc}}" id="profile-jot-email-{{$input_group_id}}" class="form-control" title="{{$emtitle}}" />
|
2019-11-28 17:42:12 +00:00
|
|
|
</div>
|
2020-01-14 02:58:01 +00:00
|
|
|
<div id="profile-jot-email-end-{{$input_group_id}}"></div>
|
2019-03-25 02:40:50 +00:00
|
|
|
{{/if}}
|
2019-11-28 17:42:12 +00:00
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(function() {
|
2020-01-14 02:58:01 +00:00
|
|
|
let $acl_allow_input = $('#acl_allow-{{$input_group_id}}');
|
|
|
|
let $contact_allow_input = $('[name="{{$input_names.contact_allow}}"]');
|
|
|
|
let $group_allow_input = $('[name="{{$input_names.group_allow}}"]');
|
|
|
|
let $acl_deny_input = $('#acl_deny-{{$input_group_id}}');
|
|
|
|
let $contact_deny_input = $('[name="{{$input_names.contact_deny}}"]');
|
|
|
|
let $group_deny_input = $('[name="{{$input_names.group_deny}}"]');
|
|
|
|
let $visibility_public_panel = $('#visibility-public-panel-{{$input_group_id}}');
|
|
|
|
let $visibility_custom_panel = $('#visibility-custom-panel-{{$input_group_id}}');
|
|
|
|
let $visibility_public_radio = $('#visibility-public-{{$input_group_id}}');
|
|
|
|
let $visibility_custom_radio = $('#visibility-custom-{{$input_group_id}}');
|
2019-11-28 17:42:12 +00:00
|
|
|
|
|
|
|
// Frio specific
|
|
|
|
if ($.fn.collapse) {
|
2020-01-14 02:58:01 +00:00
|
|
|
$visibility_public_panel.collapse({parent: '#visibility-accordion-{{$input_group_id}}', toggle: false});
|
|
|
|
$visibility_custom_panel.collapse({parent: '#visibility-accordion-{{$input_group_id}}', toggle: false});
|
2019-11-28 17:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$visibility_public_radio.on('change', function (e) {
|
|
|
|
if ($.fn.collapse) {
|
|
|
|
$visibility_public_panel.collapse('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
$visibility_public_panel.prop('disabled', false);
|
|
|
|
$visibility_custom_panel.prop('disabled', true);
|
|
|
|
|
2020-01-14 02:58:01 +00:00
|
|
|
$('#visibility-public-panel-{{$input_group_id}} .profile-jot-net input[type=checkbox]').each(function() {
|
2019-11-28 17:42:12 +00:00
|
|
|
// Restores checkbox state if it had been saved
|
|
|
|
if ($(this).attr('data-checked') !== undefined) {
|
|
|
|
$(this).prop('checked', $(this).attr('data-checked') === 'true');
|
|
|
|
}
|
|
|
|
});
|
2020-01-14 02:58:01 +00:00
|
|
|
$('#visibility-public-panel-{{$input_group_id}} .profile-jot-net input').attr('disabled', false);
|
2019-11-28 17:42:12 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$visibility_custom_radio.on('change', function(e) {
|
|
|
|
if ($.fn.collapse) {
|
|
|
|
$visibility_custom_panel.collapse('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
$visibility_public_panel.prop('disabled', true);
|
|
|
|
$visibility_custom_panel.prop('disabled', false);
|
|
|
|
|
2020-01-14 02:58:01 +00:00
|
|
|
$('#visibility-public-panel-{{$input_group_id}} .profile-jot-net input[type=checkbox]').each(function() {
|
2019-11-28 17:42:12 +00:00
|
|
|
// Saves current checkbox state
|
|
|
|
$(this)
|
|
|
|
.attr('data-checked', $(this).prop('checked'))
|
|
|
|
.prop('checked', false);
|
|
|
|
});
|
2020-01-14 02:58:01 +00:00
|
|
|
$('#visibility-public-panel-{{$input_group_id}} .profile-jot-net input').attr('disabled', 'disabled');
|
2019-11-28 17:42:12 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Custom visibility tags inputs
|
|
|
|
let acl_groups = new Bloodhound({
|
|
|
|
local: {{$acl_groups|@json_encode nofilter}},
|
2019-12-07 10:50:15 +00:00
|
|
|
identify: function(obj) { return obj.type + '-' + obj.id.toString(); },
|
2019-11-28 17:42:12 +00:00
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name']),
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
});
|
|
|
|
let acl_contacts = new Bloodhound({
|
|
|
|
local: {{$acl_contacts|@json_encode nofilter}},
|
2019-12-07 10:50:15 +00:00
|
|
|
identify: function(obj) { return obj.type + '-' + obj.id.toString(); },
|
2019-11-28 17:42:12 +00:00
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']),
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
});
|
|
|
|
let acl = new Bloodhound({
|
|
|
|
local: {{$acl_list|@json_encode nofilter}},
|
2019-12-07 10:50:15 +00:00
|
|
|
identify: function(obj) { return obj.type + '-' + obj.id.toString(); },
|
2019-11-28 17:42:12 +00:00
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']),
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
2019-12-16 08:13:32 +00:00
|
|
|
sorter: function (itemA, itemB) {
|
|
|
|
if (itemA.name === itemB.name) {
|
|
|
|
return 0;
|
|
|
|
} else if (itemA.name > itemB.name) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
},
|
2019-11-28 17:42:12 +00:00
|
|
|
});
|
|
|
|
acl.initialize();
|
|
|
|
|
|
|
|
let suggestionTemplate = function (item) {
|
|
|
|
return '<div><img src="' + item.micro + '" alt="" style="float: left; width: auto; height: 2.8em; margin-right: 0.5em;"> <strong>' + item.name + '</strong><br /><em>' + item.addr + '</em></div>';
|
|
|
|
};
|
|
|
|
|
|
|
|
$acl_allow_input.tagsinput({
|
|
|
|
confirmKeys: [13, 44],
|
|
|
|
freeInput: false,
|
|
|
|
tagClass: function(item) {
|
|
|
|
switch (item.type) {
|
|
|
|
case 'group' : return 'label label-primary';
|
|
|
|
case 'contact' :
|
|
|
|
default:
|
|
|
|
return 'label label-info';
|
|
|
|
}
|
|
|
|
},
|
2019-12-07 10:50:15 +00:00
|
|
|
itemValue: function (item) { return item.type + '-' + item.id.toString(); },
|
2019-11-28 17:42:12 +00:00
|
|
|
itemText: 'name',
|
|
|
|
itemThumb: 'micro',
|
|
|
|
itemTitle: function(item) {
|
|
|
|
return item.addr;
|
|
|
|
},
|
|
|
|
typeaheadjs: {
|
|
|
|
name: 'contacts',
|
|
|
|
displayKey: 'name',
|
|
|
|
templates: {
|
|
|
|
suggestion: suggestionTemplate
|
|
|
|
},
|
|
|
|
source: acl.ttAdapter()
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$acl_deny_input
|
|
|
|
.tagsinput({
|
|
|
|
confirmKeys: [13, 44],
|
|
|
|
freeInput: false,
|
|
|
|
tagClass: function(item) {
|
|
|
|
switch (item.type) {
|
|
|
|
case 'group' : return 'label label-primary';
|
|
|
|
case 'contact' :
|
|
|
|
default:
|
|
|
|
return 'label label-info';
|
|
|
|
}
|
|
|
|
},
|
2019-12-07 10:50:15 +00:00
|
|
|
itemValue: function (item) { return item.type + '-' + item.id.toString(); },
|
2019-11-28 17:42:12 +00:00
|
|
|
itemText: 'name',
|
|
|
|
itemThumb: 'micro',
|
|
|
|
itemTitle: function(item) {
|
|
|
|
return item.addr;
|
|
|
|
},
|
|
|
|
typeaheadjs: {
|
|
|
|
name: 'contacts',
|
|
|
|
displayKey: 'name',
|
|
|
|
templates: {
|
|
|
|
suggestion: suggestionTemplate
|
|
|
|
},
|
|
|
|
source: acl.ttAdapter()
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Import existing ACL into the tags input fields.
|
|
|
|
|
2019-12-07 10:50:15 +00:00
|
|
|
$group_allow_input.val().split(',').forEach(function (group_id) {
|
|
|
|
$acl_allow_input.tagsinput('add', acl_groups.get('group-' + group_id)[0]);
|
2019-11-28 17:42:12 +00:00
|
|
|
});
|
2019-12-07 10:50:15 +00:00
|
|
|
$contact_allow_input.val().split(',').forEach(function (contact_id) {
|
|
|
|
$acl_allow_input.tagsinput('add', acl_contacts.get('contact-' + contact_id)[0]);
|
2019-11-28 17:42:12 +00:00
|
|
|
});
|
2019-12-07 10:50:15 +00:00
|
|
|
$group_deny_input.val().split(',').forEach(function (group_id) {
|
|
|
|
$acl_deny_input.tagsinput('add', acl_groups.get('group-' + group_id)[0]);
|
2019-11-28 17:42:12 +00:00
|
|
|
});
|
2019-12-07 10:50:15 +00:00
|
|
|
$contact_deny_input.val().split(',').forEach(function (contact_id) {
|
|
|
|
$acl_deny_input.tagsinput('add', acl_contacts.get('contact-' + contact_id)[0]);
|
2019-11-28 17:42:12 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Anti-duplicate callback + acl fields value generation
|
|
|
|
|
2020-01-14 02:58:01 +00:00
|
|
|
$acl_allow_input.on('itemAdded itemRemoved', function (event) {
|
|
|
|
if (event.type === 'itemAdded') {
|
|
|
|
// Removes duplicate in the opposite acl box
|
|
|
|
$acl_deny_input.tagsinput('remove', event.item);
|
|
|
|
}
|
2019-11-28 17:42:12 +00:00
|
|
|
|
|
|
|
// Update the real acl field
|
|
|
|
$group_allow_input.val('');
|
|
|
|
$contact_allow_input.val('');
|
|
|
|
[].forEach.call($acl_allow_input.tagsinput('items'), function (item) {
|
|
|
|
if (item.type === 'group') {
|
|
|
|
$group_allow_input.val($group_allow_input.val() + ',' + item.id);
|
|
|
|
} else {
|
|
|
|
$contact_allow_input.val($contact_allow_input.val() + ',' + item.id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-01-14 02:58:01 +00:00
|
|
|
$acl_deny_input.on('itemAdded itemRemoved', function (event) {
|
|
|
|
if (event.type === 'itemAdded') {
|
|
|
|
// Removes duplicate in the opposite acl box
|
|
|
|
$acl_allow_input.tagsinput('remove', event.item);
|
|
|
|
}
|
2015-06-25 16:57:42 +00:00
|
|
|
|
2019-11-28 17:42:12 +00:00
|
|
|
// Update the real acl field
|
|
|
|
$group_deny_input.val('');
|
|
|
|
$contact_deny_input.val('');
|
|
|
|
[].forEach.call($acl_deny_input.tagsinput('items'), function (item) {
|
|
|
|
if (item.type === 'group') {
|
|
|
|
$group_deny_input.val($group_allow_input.val() + ',' + item.id);
|
|
|
|
} else {
|
|
|
|
$contact_deny_input.val($contact_allow_input.val() + ',' + item.id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2013-04-23 11:47:57 +00:00
|
|
|
</script>
|