
#############
CustomerGroup
#############


****
NAME
****


Kernel::System::CustomerGroup - customer group lib


***********
DESCRIPTION
***********


All customer group functions. E. g. to add groups or to get a member list of a group.


****************
PUBLIC INTERFACE
****************


new()
=====


Don't use the constructor directly, use the ObjectManager instead:


.. code-block:: perl

     my $CustomerGroupObject = $Kernel::OM->Get('Kernel::System::CustomerGroup');



GroupMemberAdd()
================


to add a member to a group


.. code-block:: perl

     Permission: ro,move_into,priority,create,rw
 
     my $Success = $CustomerGroupObject->GroupMemberAdd(
         GID => 12,
         UID => 6,
         Permission => {
             ro        => 1,
             move_into => 1,
             create    => 1,
             owner     => 1,
             priority  => 0,
             rw        => 0,
         },
         UserID => 123,
     );



GroupMemberList()
=================


Get users of the given group.


.. code-block:: perl

     my %Users = $CustomerGroupObject->GroupMemberList(
         GroupID        => '123',
         Type           => 'move_into', # ro|move_into|priority|create|rw
         Result         => 'HASH',      # return hash of user id => user name entries
         RawPermissions => 0,           # 0 (return inherited permissions from CustomerCompany), default
                                        # 1 (return only direct permissions)
     );


or


.. code-block:: perl

     my @UserIDs = $CustomerGroupObject->GroupMemberList(
         GroupID        => '123',
         Type           => 'move_into', # ro|move_into|priority|create|rw
         Result         => 'ID',        # return array of user ids
         RawPermissions => 0,           # 0 (return inherited permissions from CustomerCompany), default
                                        # 1 (return only direct permissions)
     );


or


.. code-block:: perl

     my @UserNames = $CustomerGroupObject->GroupMemberList(
         GroupID        => '123',
         Type           => 'move_into', # ro|move_into|priority|create|rw
         Result         => 'Name',        # return array of user names
         RawPermissions => 0,           # 0 (return inherited permissions from CustomerCompany), default
                                        # 1 (return only direct permissions)
     );


Get groups of given user.


.. code-block:: perl

     my %Groups = $CustomerGroupObject->GroupMemberList(
         UserID         => '123',
         Type           => 'move_into', # ro|move_into|priority|create|rw
         Result         => 'HASH',      # return hash of group id => group name entries
         RawPermissions => 0,           # 0 (return inherited permissions from CustomerCompany), default
                                        # 1 (return only direct permissions)
     );


or


.. code-block:: perl

     my @GroupIDs = $CustomerGroupObject->GroupMemberList(
         UserID         => '123',
         Type           => 'move_into', # ro|move_into|priority|create|rw
         Result         => 'ID',        # return array of group ids
         RawPermissions => 0,           # 0 (return inherited permissions from CustomerCompany), default
                                        # 1 (return only direct permissions)
     );


or


.. code-block:: perl

     my @GroupNames = $CustomerGroupObject->GroupMemberList(
         UserID         => '123',
         Type           => 'move_into', # ro|move_into|priority|create|rw
         Result         => 'Name',        # return array of group names
         RawPermissions => 0,           # 0 (return inherited permissions from CustomerCompany), default
                                        # 1 (return only direct permissions)
     );



GroupCustomerAdd()
==================


to add a customer to a group


.. code-block:: perl

     Permission types: e.g. ro,move_into,priority,create,rw
     Permission context: e.g. Ticket::CustomerID::Same, Ticket::CustomerID::Other
 
     my $Success = $CustomerGroupObject->GroupCustomerAdd(
         GID        => 12,
         CustomerID => 'customer-company',
         Permission => {
             'Ticket::CustomerID::Same' => {
                 ro            => 1,
                 move_into     => 1,
                 create        => 1,
                 owner         => 1,
                 priority      => 0,
                 rw            => 0,
             },
             'Ticket::CustomerID::Other' => {
                 ro        => 1,
                 move_into => 1,
                 create    => 1,
                 owner     => 1,
                 priority  => 0,
                 rw        => 0,
             },
             # ...
         },
         UserID => 123,
     );



GroupCustomerList()
===================


Get customers of the given group.


.. code-block:: perl

     my %Customers = $CustomerGroupObject->GroupCustomerList(
         GroupID => '123',
         Type    => 'ro',    # ro|move_into|priority|create|owner|rw
         Context => 'Ticket::CustomerID::Same',
                             # permissions to same company tickets, default context
         Result  => 'HASH',  # return hash of customer id => group name entries
     );


or


.. code-block:: perl

     my @CustomerIDs = $CustomerGroupObject->GroupCustomerList(
         GroupID => '123',
         Type    => 'ro',    # ro|move_into|priority|create|owner|rw
         Context => 'Ticket::CustomerID::Same',
                             # permissions to same company tickets, default context
         Result  => 'ID',    # return array of customer ids
     );


or


.. code-block:: perl

     my @CustomerNames = $CustomerGroupObject->GroupCustomerList(
         GroupID => '123',
         Type    => 'ro',    # ro|move_into|priority|create|owner|rw
         Context => 'Ticket::CustomerID::Same',
                             # permissions to same company tickets, default context
         Result  => 'Name',  # return array of customer ids
     );


Get groups of given customer.


.. code-block:: perl

     my %Groups = $CustomerGroupObject->GroupCustomerList(
         CustomerID => '123',
         Type       => 'ro',     # ro|move_into|priority|create|owner|rw
         Context => 'Ticket::CustomerID::Same',
                             # permissions to same company tickets, default context
         Result     => 'HASH',   # return hash of group id => group name entries
     );


or


.. code-block:: perl

     my @GroupIDs = $CustomerGroupObject->GroupCustomerList(
         CustomerID => '123',
         Type       => 'ro',     # ro|move_into|priority|create|owner|rw
         Context => 'Ticket::CustomerID::Same',
                             # permissions to same company tickets, default context
         Result     => 'ID',     # return array of group ids
     );


or


.. code-block:: perl

     my @GroupNames = $CustomerGroupObject->GroupCustomerList(
         CustomerID => '123',
         Type       => 'ro',     # ro|move_into|priority|create|owner|rw
         Context => 'Ticket::CustomerID::Same',
                             # permissions to same company tickets, default context
         Result     => 'Name',   # return array of group names
     );



GroupContextNameGet()
=====================


Helper function to get currently configured name of a specific group access context


.. code-block:: perl

     my $ContextName = $CustomerGroupObject->GroupContextNameGet(
         SysConfigName => '100-CustomerID-other', # optional, defaults to '001-CustomerID-same'
     );



GroupContextNameList()
======================


Helper function to get the names of all configured group access contexts


.. code-block:: perl

     my @ContextNames = $CustomerGroupObject->GroupContextNameList();



GroupContextCustomers()
=======================


Get all customer companies of the given customer user,
including those associated via context based permissions.


.. code-block:: perl

     my %Customers = $CustomerGroupObject->GroupContextCustomers(
         CustomerUserID => '123',
     );


Returns hash with Customer IDs as key and Customer Company Name as value:


.. code-block:: perl

     %Customers = {
       '001' => 'Customer Company 1',
       '002' => 'Customer Company 2',
     };



GroupLookup()
=============


get id or name for group


.. code-block:: perl

     my $Group = $CustomerGroupObject->GroupLookup(GroupID => $GroupID);
 
     my $GroupID = $CustomerGroupObject->GroupLookup(Group => $Group);



PermissionCheck()
=================


Check if a customer user has a certain permission for a certain group.


.. code-block:: perl

     my $HasPermission = $CustomerGroupObject->PermissionCheck(
         UserID    => $UserID,
         GroupName => $GroupName,
         Type      => 'move_into',
     );





