NAME
Kernel::WebApp::Util::Organizer
DESCRIPTION
Handles all the organizer operations for a specific user.
PUBLIC INTERFACE
has UserID
Attribute that holds the record user id.
has User
Attribute that holds all user information.
has Readonly
Attribute that holds if user can execute methods that modify the organizer.
has ItemsTypes
Attribute that holds all the item types available in the system.
ItemGet()
Gets the item object for the given name.
my $Value = $Organizer->ItemGet(
Name => '...', # item name
JSONReady => 1, # (optional)
);
Returns
C<undef> - if no item was found.
instance of 'Kernel::WebApp::Util::Organizer::ItemType::*.pm'
hashref in case 'JSONReady' param was given
{
Name => '...',
Label => '...',
Description => '...',
Icon => '...',
Order => '...',
SystemItem => '...', # 1|0
SystemItemName => '...',
SystemItemDeleted => '...', # 1|0
Changeable => '...', # 1|0
Config => {...},
ItemType => '...',
ItemTypeCustomizable => '...', # 1|0
}
ItemAdd()
Adds a new item for the organizer.
my $Value = $Organizer->ItemAdd(
Item => {
Name => '...' # required
Label => '...' # required
Icon => '...' # required
Order => '...' # required
ItemType => '...' # required
},
);
Returns
C<undef> - in case an error occurred.
instance of 'Kernel::WebApp::Util::Organizer::ItemType::*.pm'
ItemDelete()
Deletes an item form the organizer.
my $Value = $Organizer->ItemDelete(
Name => '...',
);
Returns
C<undef> - in case an error occurred.
1 - in case of success.
ItemUpdate()
Updates the item data. If no data is passed to update the current item is returned, if exists.
my $Item = $Organizer->ItemUpdate(
Name => '...' # required
Data => {
Label => '...', # optional
Order => '...', # optional
Icon => '...', # optional
},
);
Returns
C<undef> - in case any error occurs.
instance of 'Kernel::WebApp::Util::Organizer::ItemType::*.pm'
Save()
Saves the organizer changes.
my $Saved = $Organizer->Save(
PushEvent => '1|0', # optional, if it should emit the push event or not (default 1)
SyncItemID => '7e97ba0d-e80b-11ec-83af-a00f568b8e85', # optional, if provided check for changes just for this organizer item
);
Returns
C<undef> - in case an error occurred.
1 - in case of success.
Items()
Returns the current items in the organizer.
ItemsActiveList()
Returns a list of the current active items in the organizer.
# Without any parameter.
my $List = $Organizer->ItemsActiveList();
# Return the items sorted.
my $List = $Organizer->ItemsActiveList( Sorted => 1, );
# Return as JSON ready list (each item will be an plain HashRef
instead an instance of Kernel::WebApp::Util::Organizer::ItemType::*).
my $List = $Organizer->ItemsActiveList( JSONReady => 1, );
AvailableSystemItems()
Current available system items, that can be added to the organizer.
my $AvailableSystemItems = $Organizer->AvailableSystemItems(
JSONReady => 1, # optional, returns all items as hash-ref (works in conjunction with other params)
ForLabel => '...' # optional, returns the items for the given label (ItemType label)
ByLabel => 1|0 # optional, returns all items separated by label (ItemType label)
);
Returns
# With no params
{
Name => Kernel::WebApp::Util::Organizer::ItemType::*->new(
Name => '...',
Label => '...',
Icon => '...',
Order => '...',
Config => { ... },
Changeable => '...',
),
}
# With param 'ByLabel'
{
Label1 => {
ItemType => '...',
Items => {
Name => Kernel::WebApp::Util::Organizer::ItemType::*->new(
Name => '...',
Label => '...',
Icon => '...',
Order => '...',
Config => { ... },
Changeable => '...',
),
},
}
}
# With param 'ForLabel'
{
ItemType => '...',
Items => {
Name => Kernel::WebApp::Util::Organizer::ItemType::*->new(
Name => '...',
Label => '...',
Icon => '...',
Order => '...',
Config => { ... },
Changeable => '...',
),
},
}
# With param 'JSOMReady'
{
Name => {
Name => '...',
Label => '...',
Icon => '...',
Order => '...',
Config => { ... },
Changeable => '...',
},
}
Sync()
Synchronizes the organizer items with the system items. Could happen that new items are added and other removed. In the end it saves the organizer state.
my $Synced = $Organizer->Sync(
PushEvent => '1|0', # optional, if it should emit the push event or
# not after sync and saved (default 1)
SyncItemID" => "7e97ba0d-e80b-11ec-83af-a00f568b8e85", # optional, sync only the single organizer item
# idetnified by the provided UUID
);
RefreshSystemItems()
Clears the organizer cache for the known system items registered.
Reset()
Resets the user's organizer by deleting the current configuration and re-initializing all system items.
PRIVATE INTERFACE
_BuildItemTypes()
Returns the available item types in the system.
{
Name => {
Module => '...',
GroupLabel => '...',
}
}
has _RecordID
Attribute that holds the ID
of the record in the database.
has _Config
Attribute that holds the current configuration of the organizer.
has _OldConfig
Attribute that holds the old configuration of the organizer.
has _SystemItems
Attribute that holds the items configured in the system configuration.
has _AvailableSystemItems
Attribute that holds the available items configured in the system configuration.
_Initialize()
This method is called in the constructor and initializes the user organizer. If it's the first time, it'll sync the with the system items.
my $Organizer = Kernel::WebApp::Util::Organizer->new(
UserID => '...', # required,
NoSync => '...' # optional, don't synchronize with the system items
# if it's the first time for the given user, the sync
# will always run
SyncItemID" => "7e97ba0d-e80b-11ec-83af-a00f568b8e85", # optional, sync only the single organizer item
# idetnified by the provided UUID
);
_BuildSystemItems()
Initializes the internal attribute _SystemItems
. It will discover all the system items configured in the system configuration and also the ones allowed for the user in context.
_BuildUser()
Initializes the attribute User
.
_BuildReadonly()
Initializes the attribute Readonly
.
_GenerateConfigHash()
Generates an md5
hash of the passed Config
.
my $MD5Hash = $Organizer->_GenerateConfigHash(
Config => {...},
);
_InsertUpdateDBRecord()
Insert or update the database record.
_ParseItems()
Loop over all the given items and try to instantiate an ItemType
object for each one.
my $ItemTypesParsed = $Organizer->_ParseItems(
Items => {
Dummy => {...}
},
);
Returns the HashRef
of items
{
Dummy => Kernel::WebApp::Util::Organizer::ItemType::*->new(...),
}