Beispiel #1
0
function savemembers()
{
    checkPerm('subscribe');
    require_once _base_ . '/lib/lib.userselector.php';
    $id_group = importVar('id_group', true, 0);
    $acl_man = new DoceboACLManager();
    $user_select = new UserSelector();
    $user_selected = $user_select->getSelection($_POST);
    $old_users = $acl_man->getGroupUMembers($id_group);
    $add_members = array_diff($user_selected, $old_users);
    $del_members = array_diff($old_users, $user_selected);
    $re = true;
    if ($user_selected === $old_users) {
        Util::jump_to('index.php?modname=groups&op=groups&result=ok');
        return;
    }
    if (count($add_members)) {
        while (list(, $idst_user) = each($add_members)) {
            $re &= $acl_man->addToGroup($id_group, $idst_user);
        }
    }
    if (count($del_members)) {
        while (list(, $idst_user) = each($del_members)) {
            $re &= $acl_man->removeFromGroup($id_group, $idst_user);
        }
    }
    if (!$re) {
        Util::jump_to('index.php?modname=groups&op=groups&result=err');
    }
    Util::jump_to('index.php?modname=groups&op=groups&result=ok');
}