Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit a2672b3

Browse files
author
Charles Marion
committed
BUG: refs #134 Fixed group and user tabs in community management page
1 parent 8fc9195 commit a2672b3

File tree

6 files changed

+196
-90
lines changed

6 files changed

+196
-90
lines changed

core/controllers/CommunityController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ function manageAction()
205205

206206
$this->view->isAdmin = $this->Community->policyCheck($communityDao, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
207207
$this->view->json['community'] = $communityDao->toArray();
208+
$this->view->json['community']['moderatorGroup'] = $moderator_group->toArray();
209+
$this->view->json['community']['memberGroup'] = $group_member->toArray();
208210
$this->view->json['community']['message']['delete'] = $this->t('Delete');
209211
$this->view->json['community']['message']['deleteMessage'] = $this->t('Do you really want to delete this community? It cannot be undo.');
210212
$this->view->json['community']['message']['deleteGroupMessage'] = $this->t('Do you really want to delete this group? It cannot be undo.');

core/models/base/CommunityModelBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function __construct()
4040
'admin_group' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Group', 'parent_column' => 'admingroup_id', 'child_column' => 'group_id'),
4141
'moderator_group' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Group', 'parent_column' => 'moderatorgroup_id', 'child_column' => 'group_id'),
4242
'invitations' => array('type' => MIDAS_ONE_TO_MANY, 'model' => 'CommunityInvitation', 'parent_column' => 'community_id', 'child_column' => 'community_id'),
43+
'groups' => array('type' => MIDAS_ONE_TO_MANY, 'model' => 'Group', 'parent_column' => 'community_id', 'child_column' => 'community_id'),
4344
'member_group' => array('type' => MIDAS_MANY_TO_ONE, 'model' => 'Group', 'parent_column' => 'membergroup_id', 'child_column' => 'group_id'),
4445
'feeds' => array('type' => MIDAS_MANY_TO_MANY, 'model' => 'Feed', 'table' => 'feed2community', 'parent_column' => 'community_id', 'child_column' => 'feed_id'),
4546
);

core/models/pdo/GroupModel.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ function removeUser($group, $user)
6868
{
6969
throw new Zend_Exception("Should be an user.");
7070
}
71+
72+
$community = $group->getCommunity();
73+
$groupMember = $community->getMemberGroup();
74+
if($groupMember->getKey() == $group->getKey())
75+
{
76+
$communityGroups = $community->getGroups();
77+
foreach($communityGroups as $cgroup)
78+
{
79+
if($cgroup->getKey() != $groupMember->getKey())
80+
{
81+
$this->removeUser($cgroup, $user);
82+
}
83+
}
84+
}
85+
7186
$this->database->removeLink('users', $group, $user);
7287
} // end function removeUser
7388

core/public/js/community/community.manage.js

Lines changed: 83 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ $(document).ready(function() {
1010
$('div.genericCommunities').show();
1111
$('div.genericStats').show();
1212
$('div.viewInfo').hide();
13+
$('div.memberSelection').hide();
14+
$('div.groupUsersSelection').hide();
1315
$('div.viewAction').hide();
16+
$('td.tdUser input').removeAttr('checked');
1417
}
1518
});
1619
$("#tabsGeneric").show();
@@ -50,10 +53,10 @@ $(document).ready(function() {
5053
{
5154
"sScrollY": "100px",
5255
"bScrollCollapse": true,
53-
"bPaginate": false,
56+
"bPaginate": true,
5457
"bLengthChange": false,
5558
"bFilter": false,
56-
"bSort": false,
59+
"bSort": true,
5760
"bInfo": false,
5861
"bAutoWidth": true ,
5962
"oLanguage": {
@@ -75,7 +78,7 @@ $(document).ready(function() {
7578
$("table#browseTable").show();
7679

7780
initDragAndDrop();
78-
81+
$('td.tdUser input').removeAttr('checked');
7982
});
8083

8184

@@ -183,6 +186,8 @@ function init()
183186

184187
$('a#createGroupLink').click(function()
185188
{
189+
$('div.groupUsersSelection').hide();
190+
$('td.tdUser input').removeAttr('checked');
186191
$('div.MainDialogContent').html('');
187192
$('div.MainDialogContent').html('');
188193
$('div#createGroupFrom').find('input[name=groupId]').val('0');
@@ -211,13 +216,8 @@ function init()
211216
$('div.groupList').hide();
212217
var id=$(this).attr('groupid');
213218
$('div#groupList_'+ id).show();
214-
$('div#memberList td.tdUser').show();
215-
$('td.tdUser input').attr('checked','');
219+
$('td.tdUser input').removeAttr('checked');
216220
groupSelected=id;
217-
$('div#groupList_'+ id+' input').each(function()
218-
{
219-
$('div#memberList td.userid_'+$(this).attr('userid')).hide();
220-
});
221221
});
222222

223223
$('td.tdUser input').click(function()
@@ -278,26 +278,23 @@ var memberSelected=new Array();
278278
function initCheckboxSelection()
279279
{
280280
$('td#userGroupSelected').html('');
281-
$('td#userMemberSelected').html('');
281+
$('.memberSelection').hide();
282+
$('.groupUsersSelection').hide();
282283
groupUsersSelected=new Array();
283284
memberSelected=new Array();
284285
$('div.groupMemberList input:checked').each(function()
285286
{
286287
groupUsersSelected.push($(this).attr('userid'));
288+
$('.groupUsersSelection').show();
287289
});
288290
$('div.communityMemberList input:checked').each(function()
289291
{
290292
memberSelected.push($(this).attr('userid'));
293+
$('.memberSelection').show();
291294
});
292-
if(groupUsersSelected.length>0)
293-
{
294-
$('td#userGroupSelected').html(groupUsersSelected.length+' user(s) selected<br/><a href="javascript:;" id="removeUserLink">Remove users From Group</a>');
295-
}
296-
if(memberSelected.length>0)
297-
{
298-
$('td#userMemberSelected').html(memberSelected.length+' user(s) selected<br/><a href="javascript:;" id="addUserLink">Add users to Group</a>');
299-
}
300-
$('a#removeUserLink').click(function()
295+
296+
297+
$('a.removeUserLink').click(function()
301298
{
302299
var users='';
303300
$.each( groupUsersSelected, function(i, v){
@@ -314,16 +311,40 @@ function initCheckboxSelection()
314311
if(jsonResponse[0])
315312
{
316313
createNotive(jsonResponse[1],4000);
317-
$('div.groupMemberList input:checked').each(function()
318-
{
319-
$('div#memberList td.userid_'+$(this).attr('userid')).show();
320-
$(this).parent('td').remove();
321-
init()
322-
});
323-
$('td#userGroupSelected').html('');
324-
$('td#userMemberSelected').html('');
325-
$('td.tdUser input').attr('checked','');
326-
init();
314+
window.location.replace(json.global.webroot+'/community/manage?communityId='+json.community['community_id']+'#tabs-2');
315+
window.location.reload();
316+
}
317+
else
318+
{
319+
createNotive(jsonResponse[1],4000);
320+
}
321+
});
322+
323+
});
324+
325+
$('a.removeFromCommunity').click(function()
326+
{
327+
var users='';
328+
$.each( memberSelected, function(i, v){
329+
if($('div#memberList input[admin=false][userid='+v+']').length>0)
330+
{
331+
users+=v+'-';
332+
}
333+
334+
});
335+
$.post(json.global.webroot+'/community/manage', {communityId: json.community.community_id, removeUser: 'true', groupId:json.community.memberGroup.group_id,users:users},
336+
function(data) {
337+
jsonResponse = jQuery.parseJSON(data);
338+
if(jsonResponse==null)
339+
{
340+
createNotive('Error',4000);
341+
return;
342+
}
343+
if(jsonResponse[0])
344+
{
345+
createNotive(jsonResponse[1],4000);
346+
window.location.replace(json.global.webroot+'/community/manage?communityId='+json.community['community_id']+'#tabs-2');
347+
window.location.reload();
327348
}
328349
else
329350
{
@@ -333,13 +354,41 @@ function initCheckboxSelection()
333354

334355
});
335356

336-
$('a#addUserLink').click(function()
357+
$('a.addUserLink').click(function()
358+
{
359+
var users='';
360+
$.each( memberSelected, function(i, v){
361+
users+=v+'-';
362+
});
363+
$.post(json.global.webroot+'/community/manage', {communityId: json.community.community_id, addUser: 'true', groupId:$(this).attr('element'),users:users},
364+
function(data) {
365+
jsonResponse = jQuery.parseJSON(data);
366+
if(jsonResponse==null)
367+
{
368+
createNotive('Error',4000);
369+
return;
370+
}
371+
if(jsonResponse[0])
372+
{
373+
createNotive(jsonResponse[1],4000);
374+
window.location.replace(json.global.webroot+'/community/manage?communityId='+json.community['community_id']+'#tabs-2');
375+
window.location.reload();
376+
}
377+
else
378+
{
379+
createNotive(jsonResponse[1],4000);
380+
}
381+
});
382+
$(this).remove();
383+
});
384+
385+
$('a.addModeratorLink').click(function()
337386
{
338387
var users='';
339388
$.each( memberSelected, function(i, v){
340389
users+=v+'-';
341390
});
342-
$.post(json.global.webroot+'/community/manage', {communityId: json.community.community_id, addUser: 'true', groupId:groupSelected,users:users},
391+
$.post(json.global.webroot+'/community/manage', {communityId: json.community.community_id, addUser: 'true', groupId:json.community.moderatorGroup.group_id,users:users},
343392
function(data) {
344393
jsonResponse = jQuery.parseJSON(data);
345394
if(jsonResponse==null)
@@ -350,27 +399,15 @@ function initCheckboxSelection()
350399
if(jsonResponse[0])
351400
{
352401
createNotive(jsonResponse[1],4000);
353-
$('div.communityMemberList input:checked').each(function()
354-
{
355-
datatable[groupSelected].fnAddData( [
356-
$(this).parent('td').html()+'<span id="newRow"/>',
357-
] );
358-
$('span#newRow').parent('td').addClass('tdUser');
359-
$('span#newRow').parent('td').addClass('userid_'+$(this).attr('userid'));
360-
$('span#newRow').remove();
361-
$(this).parent('td').hide();
362-
init()
363-
});
364-
$('td.tdUser input').attr('checked','');
365-
$('td#userGroupSelected').html('');
366-
$('td#userMemberSelected').html('');
367-
init();
402+
window.location.replace(json.global.webroot+'/community/manage?communityId='+json.community['community_id']+'#tabs-2');
403+
window.location.reload();
368404
}
369405
else
370406
{
371407
createNotive(jsonResponse[1],4000);
372408
}
373409
});
410+
$(this).remove();
374411
});
375412
}
376413
function validateGroupChange(formData, jqForm, options) {

core/translation/fr-main.csv

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,8 @@ Website;Site Internet
245245
City;Ville
246246
Country;Pays
247247
Biography;Biographie
248-
In the same location;Au m�me endroit
248+
In the same location;Au m�me endroit
249+
Add in group;Ajouter au groupe
250+
Set as moderator;Promouvoir en tant que mod�rateur
251+
Remove from community;Retirer de la communaut�
252+
Remove from group;Retirer du groupe

0 commit comments

Comments
 (0)