Skip to content

Commit

Permalink
Ticket #3058 - Set Membership with time limit
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Dec 24, 2021
1 parent 92759f9 commit b67a645
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 28 deletions.
36 changes: 20 additions & 16 deletions inc/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,28 +669,32 @@ function bx_set_acl_level (iProfileId, iAclLevel, mixedLoadingElement) {
if(bLoading)
bx_loading($(mixedLoadingElement), true);

$.post(sUrlRoot + 'menu.php', {o:'sys_set_acl_level', profile_id: iProfileId, acl_level_id: iAclLevel, acl_card:iAclCard}, function(oData) {
if(bLoading)
bx_loading($(mixedLoadingElement), false);
$.post(sUrlRoot + 'menu.php', {o:'sys_set_acl_level', profile_id: iProfileId, level_id: iAclLevel, card:iAclCard}, function(oData) {
bx_on_set_acl_level(oData, mixedLoadingElement);
}, 'json');
}

if(oData.msg != undefined && oData.msg.length) {
bx_alert(oData.msg);
return;
}
function bx_on_set_acl_level(oData, oLoadingElement) {
if(typeof(oLoadingElement) != 'undefined')
bx_loading($(oLoadingElement), false);

if($(mixedLoadingElement).hasClass('bx-popup-applied'))
$(mixedLoadingElement).dolPopupHide().remove();
if(oData.msg != undefined && oData.msg.length) {
bx_alert(oData.msg);
return;
}

if(typeof(oData.card) == 'object')
for(var iField in oData.card) {
var oCard = $(oData.card[iField]);
$('#' + oCard.attr('id')).replaceWith(oCard.bxTime());
}
}, 'json');
if($(oLoadingElement).hasClass('bx-popup-applied'))
$(oLoadingElement).dolPopupHide().remove();

if(typeof(oData.card) == 'object')
for(var iField in oData.card) {
var oCard = $(oData.card[iField]);
$('#' + oCard.attr('id')).replaceWith(oCard.bxTime());
}
}

/**
* Set ACL badge for specified content
* Set badge for specified content
* @param sModule - current module for content
* @param iContentId - content id to set badge for
* @param iBadgeId - badge id to assign to a given content
Expand Down
28 changes: 24 additions & 4 deletions install/sql/system.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3287,7 +3287,8 @@ INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_att
('sys_privacy_group_custom', 'system', '_sys_form_ps_group_custom', 'privacy.php', '', 'do_submit', 'sys_privacy_groups_custom', 'id', '', '', '', 0, 1, 'BxTemplPrivacyFormGroupCustom', ''),
('sys_labels', 'system', '_sys_form_labels', 'label.php', '', 'do_submit', '', '', '', '', '', 0, 1, 'BxTemplLabelForm', ''),
('sys_wiki', 'system', '_sys_form_wiki', '', '', 'do_submit', 'sys_pages_wiki_blocks', 'id', '', '', '', 0, 1, 'BxTemplFormWiki', ''),
('sys_manage', 'system', '_sys_form_manage', '', '', 'a:2:{i:0;s:7:"do_send";i:1;s:9:"do_submit";}', '', '', '', '', '', 0, 1, '', '');
('sys_manage', 'system', '_sys_form_manage', '', '', 'a:2:{i:0;s:7:"do_send";i:1;s:9:"do_submit";}', '', '', '', '', '', 0, 1, '', ''),
('sys_acl', 'system', '_sys_form_acl', '', '', 'do_submit', '', '', '', '', '', 0, 1, '', '');

CREATE TABLE IF NOT EXISTS `sys_form_displays` (
`id` int(11) NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -3327,7 +3328,8 @@ INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `v
('sys_labels_select', 'system', 'sys_labels', '_sys_form_labels_display_select', 0),
('sys_wiki_edit', 'system', 'sys_wiki', '_sys_form_display_wiki_edit', 0),
('sys_wiki_translate', 'system', 'sys_wiki', '_sys_form_display_wiki_translate', 0),
('sys_manage_approve', 'system', 'sys_manage', '_sys_form_display_manage_approve', 0);
('sys_manage_approve', 'system', 'sys_manage', '_sys_form_display_manage_approve', 0),
('sys_acl_set', 'system', 'sys_acl', '_sys_form_display_acl_set', 0);


CREATE TABLE IF NOT EXISTS `sys_form_inputs` (
Expand Down Expand Up @@ -3488,7 +3490,17 @@ INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `c
('sys_manage', 'system', 'controls', '', 'do_send,do_submit,do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
('sys_manage', 'system', 'do_send', '_sys_form_manage_input_do_send', '', 0, 'submit', '_sys_form_manage_input_sys_do_send', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
('sys_manage', 'system', 'do_submit', '_sys_form_manage_input_do_submit', '', 0, 'submit', '_sys_form_manage_input_sys_do_submit', '', '', 0, 0, 0, 'a:1:{s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', '', '', '', '', '', 0, 0),
('sys_manage', 'system', 'do_cancel', '_sys_form_manage_input_do_cancel', '', 0, 'button', '_sys_form_manage_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:5:"class";s:22:"bx-def-margin-sec-left";s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";}', '', '', '', '', '', '', '', 0, 0);
('sys_manage', 'system', 'do_cancel', '_sys_form_manage_input_do_cancel', '', 0, 'button', '_sys_form_manage_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:5:"class";s:22:"bx-def-margin-sec-left";s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";}', '', '', '', '', '', '', '', 0, 0),

('sys_acl', 'system', 'profile_id', '', '', 0, 'hidden', '_sys_form_acl_input_sys_profile_id', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 0, 0),
('sys_acl', 'system', 'card', '', '', 0, 'hidden', '_sys_form_acl_input_sys_card', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 0, 0),
('sys_acl', 'system', 'level_id', '', '', 0, 'radio_set', '_sys_form_acl_input_sys_level_id', '_sys_form_acl_input_level_id', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
('sys_acl', 'system', 'duration', '', '', 0, 'text', '_sys_form_acl_input_sys_duration', '_sys_form_acl_input_duration', '_sys_form_acl_input_duration_inf', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
('sys_acl', 'system', 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
('sys_acl', 'system', 'do_submit', '_sys_form_acl_input_do_submit', '', 0, 'submit', '_sys_form_acl_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
('sys_acl', 'system', 'do_cancel', '_sys_form_acl_input_do_cancel', '', 0, 'button', '_sys_form_acl_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:5:"class";s:22:"bx-def-margin-sec-left";s:7:"onclick";s:65:"$(this).parents(''.bx-popup-applied:visible:first'').dolPopupHide()";}', '', '', '', '', '', '', '', 0, 0);




CREATE TABLE IF NOT EXISTS `sys_form_inputs_privacy` (
Expand Down Expand Up @@ -3694,7 +3706,15 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
('sys_manage_approve', 'controls', 2147483647, 1, 3),
('sys_manage_approve', 'do_send', 2147483647, 1, 4),
('sys_manage_approve', 'do_submit', 2147483647, 1, 5),
('sys_manage_approve', 'do_cancel', 2147483647, 1, 6);
('sys_manage_approve', 'do_cancel', 2147483647, 1, 6),

('sys_acl_set', 'profile_id', 2147483647, 1, 1),
('sys_acl_set', 'card', 2147483647, 1, 2),
('sys_acl_set', 'level_id', 2147483647, 1, 3),
('sys_acl_set', 'duration', 2147483647, 1, 4),
('sys_acl_set', 'controls', 2147483647, 1, 5),
('sys_acl_set', 'do_submit', 2147483647, 1, 6),
('sys_acl_set', 'do_cancel', 2147483647, 1, 7);


CREATE TABLE `sys_form_fields_ids` (
Expand Down
12 changes: 12 additions & 0 deletions modules/boonex/english/data/langs/system/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,18 @@ If it is not enabled then please consider implement this optimization, since it
<string name="_sys_form_manage_input_do_submit_approve"><![CDATA[Approve]]></string>
<string name="_sys_form_manage_input_sys_do_cancel"><![CDATA[Cancel]]></string>
<string name="_sys_form_manage_input_do_cancel"><![CDATA[Cancel]]></string>
<string name="_sys_form_acl"><![CDATA[ACL form]]></string>
<string name="_sys_form_display_acl_set"><![CDATA[ACL form: Set]]></string>
<string name="_sys_form_popup_acl_set"><![CDATA[Set Membership]]></string>
<string name="_sys_form_acl_input_sys_level_id"><![CDATA[Level]]></string>
<string name="_sys_form_acl_input_level_id"><![CDATA[Level]]></string>
<string name="_sys_form_acl_input_sys_duration"><![CDATA[Duration]]></string>
<string name="_sys_form_acl_input_duration"><![CDATA[Duration]]></string>
<string name="_sys_form_acl_input_duration_inf"><![CDATA[In days. Leave empty for lifetime]]></string>
<string name="_sys_form_acl_input_sys_do_submit"><![CDATA[Submit]]></string>
<string name="_sys_form_acl_input_do_submit"><![CDATA[Submit]]></string>
<string name="_sys_form_acl_input_sys_do_cancel"><![CDATA[Cancel]]></string>
<string name="_sys_form_acl_input_do_cancel"><![CDATA[Cancel]]></string>
<string name="_sys_form_paceholder_profiles_suggestions"><![CDATA[Type name here...]]></string>
<string name="_sys_form_ps_group_custom"><![CDATA[Privacy: Custom group]]></string>
<string name="_sys_form_display_ps_gc_manage"><![CDATA[Privacy: Manage custom group display]]></string>
Expand Down
2 changes: 1 addition & 1 deletion modules/boonex/organizations/install/sql/enable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
('bx_organizations_view_actions', 'bx_organizations', 'profile-friend-add', '_bx_orgs_menu_item_title_system_befriend', '{title_add_friend}', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_friends\', \'add\', \'{profile_id}\')', '', 'user-plus', '', 0, 2147483647, '', 1, 0, 1, 10),
('bx_organizations_view_actions', 'bx_organizations', 'profile-relation-add', '_bx_orgs_menu_item_title_system_relation_add', '_bx_orgs_menu_item_title_relation_add', 'javascript:void(0)', 'bx_menu_popup(''sys_add_relation'', window, {}, {profile_id: {profile_id}});', '', 'sync', '', 0, 2147483647, '', 1, 0, 1, 15),
('bx_organizations_view_actions', 'bx_organizations', 'profile-subscribe-add', '_bx_orgs_menu_item_title_system_subscribe', '_bx_orgs_menu_item_title_subscribe', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'check', '', 0, 2147483647, '', 1, 0, 1, 20),
('bx_organizations_view_actions', 'bx_organizations', 'profile-set-acl-level', '_sys_menu_item_title_system_set_acl_level', '_sys_menu_item_title_set_acl_level', 'javascript:void(0)', 'bx_menu_popup(''sys_set_acl_level'', window, {}, {profile_id: {profile_id}});', '', 'certificate', '', 0, 2147483647, '', 1, 0, 1, 30),
('bx_organizations_view_actions', 'bx_organizations', 'profile-set-acl-level', '_sys_menu_item_title_system_set_acl_level', '_sys_menu_item_title_set_acl_level', 'javascript:void(0)', 'bx_menu_popup(''sys_set_acl_level'', window, {id:{value:''sys_acl_set_{profile_id}'', force:true}, closeOnOuterClick: false, removeOnClose: true, displayMode: ''box'', cssClass: ''''}, {profile_id: {profile_id}});', '', 'certificate', '', 0, 2147483647, '', 1, 0, 1, 30),
('bx_organizations_view_actions', 'bx_organizations', 'profile-set-badges', '_sys_menu_item_title_system_set_badges', '_sys_menu_item_title_set_badges', 'javascript:void(0)', 'bx_menu_popup(''sys_set_badges'', window, {}, {module: ''bx_organizations'', content_id: {content_id}});', '', 'check-circle', '', 0, 192, 'a:2:{s:6:"module";s:16:"bx_organizations";s:6:"method";s:19:"is_badges_avaliable";}', 1, 0, 1, 40),
('bx_organizations_view_actions', 'bx_organizations', 'profile-actions-more', '_bx_orgs_menu_item_title_system_more_actions', '_bx_orgs_menu_item_title_more_actions', 'javascript:void(0)', 'bx_menu_popup(''bx_organizations_view_actions_more'', this, {}, {profile_id:{profile_id}});', '', 'cog', 'bx_organizations_view_actions_more', 1, 2147483647, '', 1, 0, 1, 9999);

Expand Down
2 changes: 1 addition & 1 deletion modules/boonex/persons/install/sql/enable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
('bx_persons_view_actions', 'bx_persons', 'profile-friend-add', '_bx_persons_menu_item_title_system_befriend', '{title_add_friend}', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_friends\', \'add\', \'{profile_id}\')', '', 'user-plus', '', 0, 2147483647, '', 1, 0, 10),
('bx_persons_view_actions', 'bx_persons', 'profile-relation-add', '_bx_persons_menu_item_title_system_relation_add', '_bx_persons_menu_item_title_relation_add', 'javascript:void(0)', 'bx_menu_popup(''sys_add_relation'', window, {}, {profile_id: {profile_id}});', '', 'sync', '', 0, 2147483647, '', 1, 0, 15),
('bx_persons_view_actions', 'bx_persons', 'profile-subscribe-add', '_bx_persons_menu_item_title_system_subscribe', '_bx_persons_menu_item_title_subscribe', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'check', '', 0, 2147483647, '', 1, 0, 20),
('bx_persons_view_actions', 'bx_persons', 'profile-set-acl-level', '_sys_menu_item_title_system_set_acl_level', '_sys_menu_item_title_set_acl_level', 'javascript:void(0)', 'bx_menu_popup(''sys_set_acl_level'', window, {}, {profile_id: {profile_id}});', '', 'certificate', '', 0, 2147483647, '', 1, 0, 30),
('bx_persons_view_actions', 'bx_persons', 'profile-set-acl-level', '_sys_menu_item_title_system_set_acl_level', '_sys_menu_item_title_set_acl_level', 'javascript:void(0)', 'bx_menu_popup(''sys_set_acl_level'', window, {id:{value:''sys_acl_set_{profile_id}'', force:true}, closeOnOuterClick: false, removeOnClose: true, displayMode: ''box'', cssClass: ''''}, {profile_id: {profile_id}});', '', 'certificate', '', 0, 2147483647, '', 1, 0, 30),
('bx_persons_view_actions', 'bx_persons', 'profile-set-badges', '_sys_menu_item_title_system_set_badges', '_sys_menu_item_title_set_badges', 'javascript:void(0)', 'bx_menu_popup(''sys_set_badges'', window, {}, {module: ''bx_persons'', content_id: {content_id}});', '', 'check-circle', '', 0, 192, 'a:2:{s:6:"module";s:10:"bx_persons";s:6:"method";s:19:"is_badges_avaliable";}', 1, 0, 30),
('bx_persons_view_actions', 'bx_persons', 'profile-actions-more', '_bx_persons_menu_item_title_system_more_actions', '_bx_persons_menu_item_title_more_actions', 'javascript:void(0)', 'bx_menu_popup(''bx_persons_view_actions_more'', this, {}, {profile_id:{profile_id}});', '', 'cog', 'bx_persons_view_actions_more', 1, 2147483647, '', 1, 0, 9999);

Expand Down
12 changes: 12 additions & 0 deletions modules/boonex/russian/data/langs/system/ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,18 @@
<string name="_sys_form_manage_input_do_submit_approve"><![CDATA[Одобрить]]></string>
<string name="_sys_form_manage_input_sys_do_cancel"><![CDATA[Отмена]]></string>
<string name="_sys_form_manage_input_do_cancel"><![CDATA[Отмена]]></string>
<string name="_sys_form_acl"><![CDATA[Форма уровней доступа]]></string>
<string name="_sys_form_display_acl_set"><![CDATA[Форма уровней доступа: Установить]]></string>
<string name="_sys_form_popup_acl_set"><![CDATA[Установить уровень доступа]]></string>
<string name="_sys_form_acl_input_sys_level_id"><![CDATA[Уровень]]></string>
<string name="_sys_form_acl_input_level_id"><![CDATA[Уровень]]></string>
<string name="_sys_form_acl_input_sys_duration"><![CDATA[Продолжительность]]></string>
<string name="_sys_form_acl_input_duration"><![CDATA[Продолжительность]]></string>
<string name="_sys_form_acl_input_duration_inf"><![CDATA[В днях. Оставьте пустым для неограниченного уровня.]]></string>
<string name="_sys_form_acl_input_sys_do_submit"><![CDATA[Выполнить]]></string>
<string name="_sys_form_acl_input_do_submit"><![CDATA[Выполнить]]></string>
<string name="_sys_form_acl_input_sys_do_cancel"><![CDATA[Отмена]]></string>
<string name="_sys_form_acl_input_do_cancel"><![CDATA[Отмена]]></string>
<string name="_sys_form_paceholder_profiles_suggestions"><![CDATA[Введите имя...]]></string>
<string name="_sys_form_ps_group_custom"><![CDATA[Конфиденциальность: Пользовательская группа]]></string>
<string name="_sys_form_display_ps_gc_manage"><![CDATA[Конфиденциальность: Управлять пользовательской группой]]></string>
Expand Down
26 changes: 26 additions & 0 deletions template/acl_set.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="bx-acl-set">
<div class="bx-acl-set-cnt">
__form__
<script language="javascript">
$(document).ready(function () {
var oForm = $("#__form_id__");
if($('#sys-acl-profile-__profile_id__').length > 0)
oForm.find("[name = 'card']").val(1);

oForm.ajaxForm({
dataType: "json",
beforeSubmit: function (oFormData, jqForm, options) {
bx_loading($("#__form_id__"), true);
},
success: function (oData) {
var oForm = $("#__form_id__");

oForm.parents(".bx-popup-applied:visible:first").dolPopupHide();

bx_on_set_acl_level(oData, oForm);
}
});
});
</script>
</div>
</div>
Loading

0 comments on commit b67a645

Please sign in to comment.