Code Duplication    Length = 8-20 lines in 8 locations

main/webservices/registration.soap.php 8 locations

@@ 6454-6465 (lines=12) @@
6451
);
6452
6453
// Define the method WSCreateGroup
6454
function WSCreateGroup($params)
6455
{
6456
    if (!WSHelperVerifyKey($params['secret_key'])) {
6457
        return returnError(WS_ERROR_SECRET_KEY);
6458
    }
6459
    $userGroup = new UserGroup();
6460
    $params = [
6461
        'name' => $params['name']
6462
    ];
6463
    return $userGroup->save($params);
6464
    //return GroupPortalManager::add($params['name'], null, null, 1);
6465
}
6466
6467
/* Create group Web Service end */
6468
@@ 6503-6522 (lines=20) @@
6500
);
6501
6502
// Define the method WSUpdateGroup
6503
function WSUpdateGroup($params)
6504
{
6505
    if (!WSHelperVerifyKey($params['secret_key'])) {
6506
        return returnError(WS_ERROR_SECRET_KEY);
6507
    }
6508
    $params['allow_member_group_to_leave'] = null;
6509
6510
    $userGroup = new UserGroup();
6511
    return $userGroup->update($params);
6512
6513
    /*return GroupPortalManager::update(
6514
        $params['id'],
6515
        $params['name'],
6516
        $params['description'],
6517
        $params['url'],
6518
        $params['visibility'],
6519
        $params['picture_uri'],
6520
        $params['allow_member_group_to_leave']
6521
    );*/
6522
}
6523
6524
/* Update group Web Service end */
6525
@@ 6554-6564 (lines=11) @@
6551
);
6552
6553
// Define the method WSDeleteGroup
6554
function WSDeleteGroup($params)
6555
{
6556
    if (!WSHelperVerifyKey($params['secret_key'])) {
6557
        return returnError(WS_ERROR_SECRET_KEY);
6558
    }
6559
    $userGroup = new UserGroup();
6560
6561
    return $userGroup->delete($params['id']);
6562
6563
    //return GroupPortalManager::delete($params['id']);
6564
}
6565
6566
/* Delete group Web Service end */
6567
@@ 6597-6607 (lines=11) @@
6594
);
6595
6596
// Define the method GroupBindToParent
6597
function GroupBindToParent($params)
6598
{
6599
    if (!WSHelperVerifyKey($params['secret_key'])) {
6600
        return returnError(WS_ERROR_SECRET_KEY);
6601
    }
6602
    $userGroup = new UserGroup();
6603
6604
    return $userGroup->set_parent_group($params['id'], $params['parent_id']);
6605
6606
    //return GroupPortalManager::set_parent_group($params['id'], $params['parent_id']);
6607
}
6608
6609
/* Bind group Web Service end */
6610
@@ 6639-6646 (lines=8) @@
6636
);
6637
6638
// Define the method GroupUnbindFromParent
6639
function GroupUnbindFromParent($params)
6640
{
6641
    if (!WSHelperVerifyKey($params['secret_key'])) {
6642
        return returnError(WS_ERROR_SECRET_KEY);
6643
    }
6644
    $userGroup = new UserGroup();
6645
    return $userGroup->set_parent_group($params['id'], 0);
6646
}
6647
6648
/* Unbind group Web Service end */
6649
@@ 6679-6688 (lines=10) @@
6676
);
6677
6678
// Define the method WSAddUserToGroup
6679
function WSAddUserToGroup($params)
6680
{
6681
    if (!WSHelperVerifyKey($params['secret_key'])) {
6682
        return returnError(WS_ERROR_SECRET_KEY);
6683
    }
6684
6685
    $userGroup = new UserGroup();
6686
6687
    return $userGroup->add_user_to_group($params['user_id'], $params['group_id']);
6688
}
6689
6690
/* Add user to group Web Service end */
6691
@@ 6722-6734 (lines=13) @@
6719
);
6720
6721
// Define the method WSUpdateUserRoleInGroup
6722
function WSUpdateUserRoleInGroup($params)
6723
{
6724
    if (!WSHelperVerifyKey($params['secret_key'])) {
6725
        return returnError(WS_ERROR_SECRET_KEY);
6726
    }
6727
    $userGroup = new UserGroup();
6728
6729
    return $userGroup->update_user_role(
6730
        $params['user_id'],
6731
        $params['group_id'],
6732
        $params['relation_type']
6733
    );
6734
}
6735
6736
/* Update user role Web Service end */
6737
@@ 6767-6778 (lines=12) @@
6764
);
6765
6766
// Define the method WSDeleteUserFromGroup
6767
function WSDeleteUserFromGroup($params)
6768
{
6769
    if (!WSHelperVerifyKey($params['secret_key'])) {
6770
        return returnError(WS_ERROR_SECRET_KEY);
6771
    }
6772
    $userGroup = new UserGroup();
6773
6774
    return $userGroup->delete_user_rel_group(
6775
        $params['user_id'],
6776
        $params['group_id']
6777
    );
6778
}
6779
6780
6781
/* Delete user from group Web Service end */