/usr/share/otrs/Kernel/Modules/AgentLinkObject.pm is in otrs2 6.0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | # --
# Copyright (C) 2001-2018 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::Modules::AgentLinkObject;
use strict;
use warnings;
use Kernel::Language qw(Translatable);
our $ObjectManagerDisabled = 1;
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
if ( $Self->{Subaction} eq 'UpdateComplextTablePreferences' ) {
# save user preferences (shown columns)
# Needed objects
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
my $JSONObject = $Kernel::OM->Get('Kernel::System::JSON');
# challenge token check for write action
$LayoutObject->ChallengeTokenCheck();
my $SourceObject = $ParamObject->GetParam( Param => 'SourceObject' ) || '';
my $SourceObjectID = $ParamObject->GetParam( Param => 'SourceObjectID' ) || '';
my $DestinationObject = $ParamObject->GetParam( Param => 'DestinationObject' ) || '';
my $AdditionalLinkListWithDataJSON = $ParamObject->GetParam( Param => 'AdditionalLinkListWithDataJSON' ) || '';
my $Success = $LayoutObject->ComplexTablePreferencesSet(
DestinationObject => $DestinationObject,
);
if ( !$Success ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "System was unable to update preferences!",
);
return;
}
# get linked objects
my $LinkListWithData = $Kernel::OM->Get('Kernel::System::LinkObject')->LinkListWithData(
Object => $SourceObject,
Object2 => $DestinationObject,
Key => $SourceObjectID,
State => 'Valid',
UserID => $Self->{UserID},
ObjectParameters => {
Ticket => {
IgnoreLinkedTicketStateTypes => 1,
},
},
);
if ($AdditionalLinkListWithDataJSON) {
# decode JSON string
my $AdditionalLinkListWithData = $Kernel::OM->Get('Kernel::System::JSON')->Decode(
Data => $AdditionalLinkListWithDataJSON,
);
$LinkListWithData = {
%{$LinkListWithData},
%{$AdditionalLinkListWithData},
};
}
# create the link table
my $LinkTableStrg = $LayoutObject->LinkObjectTableCreate(
LinkListWithData => $LinkListWithData,
ViewMode => 'Complex', # only make sense for complex
Object => $SourceObject,
Key => $SourceObjectID,
AJAX => 1,
AdditionalLinkListWithDataJSON => $AdditionalLinkListWithDataJSON,
);
return $LayoutObject->Attachment(
ContentType => 'text/html',
Content => $LinkTableStrg,
Type => 'inline',
NoCache => 1,
);
}
# ------------------------------------------------------------ #
# close
# ------------------------------------------------------------ #
if ( $Self->{Subaction} eq 'Close' ) {
return $LayoutObject->PopupClose(
Reload => 1,
);
}
# get params
my %Form;
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
$Form{SourceObject} = $ParamObject->GetParam( Param => 'SourceObject' );
$Form{SourceKey} = $ParamObject->GetParam( Param => 'SourceKey' );
$Form{Mode} = $ParamObject->GetParam( Param => 'Mode' ) || 'Normal';
# check needed stuff
if ( !$Form{SourceObject} || !$Form{SourceKey} ) {
return $LayoutObject->ErrorScreen(
Message => Translatable('Need SourceObject and SourceKey!'),
Comment => Translatable('Please contact the administrator.'),
);
}
my $LinkObject = $Kernel::OM->Get('Kernel::System::LinkObject');
# check if this is a temporary ticket link used while creating a new ticket
my $TemporarySourceTicketLink;
if (
$Form{Mode} eq 'Temporary'
&& $Form{SourceObject} eq 'Ticket'
&& $Form{SourceKey} =~ m{ \A \d+ \. \d+ }xms
)
{
$TemporarySourceTicketLink = 1;
}
# do the permission check only if it is no temporary ticket link used while creating a new ticket
if ( !$TemporarySourceTicketLink ) {
# permission check
my $Permission = $LinkObject->ObjectPermission(
Object => $Form{SourceObject},
Key => $Form{SourceKey},
UserID => $Self->{UserID},
);
if ( !$Permission ) {
return $LayoutObject->NoPermission(
Message => Translatable('You need ro permission!'),
WithHeader => 'yes',
);
}
}
# get form params
$Form{TargetIdentifier} = $ParamObject->GetParam( Param => 'TargetIdentifier' )
|| $Form{SourceObject};
# investigate the target object
if ( $Form{TargetIdentifier} =~ m{ \A ( .+? ) :: ( .+ ) \z }xms ) {
$Form{TargetObject} = $1;
$Form{TargetSubObject} = $2;
}
else {
$Form{TargetObject} = $Form{TargetIdentifier};
}
# get possible objects list
my %PossibleObjectsList = $LinkObject->PossibleObjectsList(
Object => $Form{SourceObject},
UserID => $Self->{UserID},
);
# check if target object is a possible object to link with the source object
if ( !$PossibleObjectsList{ $Form{TargetObject} } ) {
my @PossibleObjects = sort { lc $a cmp lc $b } keys %PossibleObjectsList;
$Form{TargetObject} = $PossibleObjects[0];
}
# set mode params
if ( $Form{Mode} eq 'Temporary' ) {
$Form{State} = 'Temporary';
}
else {
$Form{Mode} = 'Normal';
$Form{State} = 'Valid';
}
# get source object description
my %SourceObjectDescription = $LinkObject->ObjectDescriptionGet(
Object => $Form{SourceObject},
Key => $Form{SourceKey},
Mode => $Form{Mode},
UserID => $Self->{UserID},
);
# output header
my $Output = $LayoutObject->Header( Type => 'Small' );
my $ActiveTab;
# ------------------------------------------------------------ #
# link delete
# ------------------------------------------------------------ #
if ( $Self->{Subaction} eq 'LinkDelete' && $ParamObject->GetParam( Param => 'SubmitDelete' ) ) {
# challenge token check for write action
$LayoutObject->ChallengeTokenCheck();
# delete all temporary links older than one day
$LinkObject->LinkCleanup(
State => 'Temporary',
Age => ( 60 * 60 * 24 ),
UserID => $Self->{UserID},
);
# get the link delete keys and target object
my @LinkDeleteIdentifier = $ParamObject->GetArray(
Param => 'LinkDeleteIdentifier',
);
my $SuccessCounter = 0;
# delete links from database
IDENTIFIER:
for my $Identifier (@LinkDeleteIdentifier) {
my @Target = $Identifier =~ m{^ ( [^:]+? ) :: (.+?) :: ( [^:]+? ) $}smx;
next IDENTIFIER if !$Target[0]; # TargetObject
next IDENTIFIER if !$Target[1]; # TargetKey
next IDENTIFIER if !$Target[2]; # LinkType
my $DeletePermission = $LinkObject->ObjectPermission(
Object => $Target[0],
Key => $Target[1],
UserID => $Self->{UserID},
);
next IDENTIFIER if !$DeletePermission;
# delete link from database
my $Success = $LinkObject->LinkDelete(
Object1 => $Form{SourceObject},
Key1 => $Form{SourceKey},
Object2 => $Target[0],
Key2 => $Target[1],
Type => $Target[2],
UserID => $Self->{UserID},
);
if ($Success) {
$SuccessCounter++;
next IDENTIFIER
}
# get target object description
my %TargetObjectDescription = $LinkObject->ObjectDescriptionGet(
Object => $Target[0],
Key => $Target[1],
Mode => $Form{Mode},
UserID => $Self->{UserID},
);
# output an error notification
$Output .= $LayoutObject->Notify(
Priority => 'Error',
Data => $LayoutObject->{LanguageObject}->Translate(
"Can not delete link with %s!",
$TargetObjectDescription{Normal},
),
);
}
if ($SuccessCounter) {
$Output .= $LayoutObject->Notify(
Priority => 'Info',
Data =>
$LayoutObject->{LanguageObject}->Translate( "%s Link(s) deleted successfully.", $SuccessCounter ),
);
}
$ActiveTab = 'ManageLinks';
}
# ------------------------------------------------------------ #
# instant link delete (from the link table)
# ------------------------------------------------------------ #
elsif ( $Self->{Subaction} eq 'InstantLinkDelete' ) {
# challenge token check for write action
$LayoutObject->ChallengeTokenCheck();
# get target identifier and redirect URL
my $TargetIdentifier = $ParamObject->GetParam( Param => 'TargetIdentifier' );
my $Redirect = $ParamObject->GetParam( Param => 'Redirect' );
# get target components
my @Target = $TargetIdentifier =~ m{^ ( [^:]+? ) :: (.+?) :: ( [^:]+? ) $}smx;
if (
$Target[0] # TargetObject
&& $Target[1] # TargetKey
&& $Target[2] # LinkType
)
{
# check source permission
my $SourcePermission = $LinkObject->ObjectPermission(
Object => $Form{SourceObject},
Key => $Form{SourceKey},
UserID => $Self->{UserID},
);
# check target permission
my $TargetPermission = $LinkObject->ObjectPermission(
Object => $Target[0],
Key => $Target[1],
UserID => $Self->{UserID},
);
if ( !$SourcePermission || !$TargetPermission ) {
return $LayoutObject->NoPermission(
Message => Translatable('You need ro permission!'),
WithHeader => 'yes',
);
}
# delete link from database
my $Success = $LinkObject->LinkDelete(
Object1 => $Form{SourceObject},
Key1 => $Form{SourceKey},
Object2 => $Target[0],
Key2 => $Target[1],
Type => $Target[2],
UserID => $Self->{UserID},
);
}
# build empty JSON output
my $JSON = $LayoutObject->JSONEncode(
Data => {
Success => 1,
},
);
# send JSON response
return $LayoutObject->Attachment(
ContentType => 'application/json; charset=' . $LayoutObject->{Charset},
Content => $JSON,
Type => 'inline',
NoCache => 1,
);
}
# ------------------------------------------------------------ #
# overview
# ------------------------------------------------------------ #
# get the type
my $TypeIdentifier = $ParamObject->GetParam( Param => 'TypeIdentifier' );
# add new links
if ( $ParamObject->GetParam( Param => 'SubmitLink' ) ) {
# challenge token check for write action
$LayoutObject->ChallengeTokenCheck();
# get the link target keys
my @LinkTargetKeys = $ParamObject->GetArray( Param => 'LinkTargetKeys' );
# get all links that the source object already has
my $LinkList = $LinkObject->LinkList(
Object => $Form{SourceObject},
Key => $Form{SourceKey},
State => $Form{State},
UserID => $Self->{UserID},
);
# split the identifier
my @Type = split q{::}, $TypeIdentifier;
if ( $Type[0] && $Type[1] && ( $Type[1] eq 'Source' || $Type[1] eq 'Target' ) ) {
my $SuccessCounter = 0;
# add links
TARGETKEYORG:
for my $TargetKeyOrg (@LinkTargetKeys) {
TYPE:
for my $LType ( sort keys %{ $LinkList->{ $Form{TargetObject} } } ) {
# extract source and target
my $Source = $LinkList->{ $Form{TargetObject} }->{$LType}->{Source} ||= {};
my $Target = $LinkList->{ $Form{TargetObject} }->{$LType}->{Target} ||= {};
# check if source and target object are already linked
next TYPE
if !$Source->{$TargetKeyOrg} && !$Target->{$TargetKeyOrg};
# next type, if link already exists
if ( $LType eq $Type[0] ) {
next TYPE if $Type[1] eq 'Source' && $Source->{$TargetKeyOrg};
next TYPE if $Type[1] eq 'Target' && $Target->{$TargetKeyOrg};
}
# check the type groups
my $TypeGroupCheck = $LinkObject->PossibleType(
Type1 => $Type[0],
Type2 => $LType,
UserID => $Self->{UserID},
);
next TYPE if $TypeGroupCheck && $Type[0] ne $LType;
# get target object description
my %TargetObjectDescription = $LinkObject->ObjectDescriptionGet(
Object => $Form{TargetObject},
Key => $TargetKeyOrg,
UserID => $Self->{UserID},
);
# lookup type id
my $TypeID = $LinkObject->TypeLookup(
Name => $LType,
UserID => $Self->{UserID},
);
# get type data
my %TypeData = $LinkObject->TypeGet(
TypeID => $TypeID,
UserID => $Self->{UserID},
);
# investigate type name
my $TypeName = $TypeData{SourceName};
if ( $Target->{$TargetKeyOrg} ) {
$TypeName = $TypeData{TargetName};
}
# translate the type name
$TypeName = $LayoutObject->{LanguageObject}->Translate($TypeName);
# output an error notification
$Output .= $LayoutObject->Notify(
Priority => 'Error',
Data => $LayoutObject->{LanguageObject}->Translate(
'Can not create link with %s! Object already linked as %s.',
$TargetObjectDescription{Normal},
$TypeName,
),
);
next TARGETKEYORG;
}
my $SourceObject = $Form{TargetObject};
my $SourceKey = $TargetKeyOrg;
my $TargetObject = $Form{SourceObject};
my $TargetKey = $Form{SourceKey};
if ( $Type[1] eq 'Target' ) {
$SourceObject = $Form{SourceObject};
$SourceKey = $Form{SourceKey};
$TargetObject = $Form{TargetObject};
$TargetKey = $TargetKeyOrg;
}
# check if this is a temporary ticket link used while creating a new ticket
my $TemporaryTargetTicketLink;
if (
$Form{Mode} eq 'Temporary'
&& $TargetObject eq 'Ticket'
&& $TargetKey =~ m{ \A \d+ \. \d+ }xms
)
{
$TemporaryTargetTicketLink = 1;
}
# do the permission check only if it is no temporary ticket link
# used while creating a new ticket
if ( !$TemporaryTargetTicketLink ) {
my $AddPermission = $LinkObject->ObjectPermission(
Object => $TargetObject,
Key => $TargetKey,
UserID => $Self->{UserID},
);
next TARGETKEYORG if !$AddPermission;
}
# add links to database
my $Success = $LinkObject->LinkAdd(
SourceObject => $SourceObject,
SourceKey => $SourceKey,
TargetObject => $TargetObject,
TargetKey => $TargetKey,
Type => $Type[0],
State => $Form{State},
UserID => $Self->{UserID},
);
if ($Success) {
$SuccessCounter++;
next TARGETKEYORG;
}
# get target object description
my %TargetObjectDescription = $LinkObject->ObjectDescriptionGet(
Object => $Form{TargetObject},
Key => $TargetKeyOrg,
UserID => $Self->{UserID},
);
# output an error notification
$Output .= $LayoutObject->Notify(
Priority => 'Error',
Data => $LayoutObject->{LanguageObject}->Translate(
"Can not create link with %s!",
$TargetObjectDescription{Normal}
),
);
}
if ($SuccessCounter) {
$Output .= $LayoutObject->Notify(
Priority => 'Info',
Data => $LayoutObject->{LanguageObject}->Translate(
"%s links added successfully.",
$SuccessCounter,
),
);
}
}
}
# get the selectable object list
my $TargetObjectStrg = $LayoutObject->LinkObjectSelectableObjectList(
Object => $Form{SourceObject},
Selected => $Form{TargetIdentifier},
);
# check needed stuff
if ( !$TargetObjectStrg ) {
return $LayoutObject->ErrorScreen(
Message => $LayoutObject->{LanguageObject}
->Translate( 'The object %s cannot link with other object!', $Form{SourceObject} ),
Comment => Translatable('Please contact the administrator.'),
);
}
# output link block
$LayoutObject->Block(
Name => 'Link',
Data => {
%Form,
SourceObjectNormal => $SourceObjectDescription{Normal},
SourceObjectLong => $SourceObjectDescription{Long},
TargetObjectStrg => $TargetObjectStrg,
},
);
# output special block for temporary links
# to close the popup without reloading the parent window
if ( $Form{Mode} eq 'Temporary' ) {
$LayoutObject->AddJSData(
Key => 'TemporaryLink',
Value => 1,
);
}
# get search option list
my @SearchOptionList = $LayoutObject->LinkObjectSearchOptionList(
Object => $Form{TargetObject},
SubObject => $Form{TargetSubObject},
);
# output search option fields
for my $Option (@SearchOptionList) {
# output link search row block
$LayoutObject->Block(
Name => 'LinkSearchRow',
Data => $Option,
);
}
# create the search param hash
my %SearchParam;
OPTION:
for my $Option (@SearchOptionList) {
next OPTION if !$Option->{FormData};
next OPTION if $Option->{FormData}
&& ref $Option->{FormData} eq 'ARRAY' && !@{ $Option->{FormData} };
$SearchParam{ $Option->{Key} } = $Option->{FormData};
}
# start search
my $SearchList;
if (
%SearchParam
|| $Kernel::OM->Get('Kernel::Config')->Get('Frontend::AgentLinkObject::WildcardSearch')
)
{
$SearchList = $LinkObject->ObjectSearch(
Object => $Form{TargetObject},
SubObject => $Form{TargetSubObject},
SearchParams => \%SearchParam,
UserID => $Self->{UserID},
);
}
# remove the source object from the search list
if ( $SearchList && $SearchList->{ $Form{SourceObject} } ) {
for my $LinkType ( sort keys %{ $SearchList->{ $Form{SourceObject} } } ) {
# extract link type List
my $LinkTypeList = $SearchList->{ $Form{SourceObject} }->{$LinkType};
for my $Direction ( sort keys %{$LinkTypeList} ) {
# remove the source key
delete $LinkTypeList->{$Direction}->{ $Form{SourceKey} };
}
}
}
# get already linked objects
my $LinkListWithData = $LinkObject->LinkListWithData(
Object => $Form{SourceObject},
Key => $Form{SourceKey},
State => $Form{State},
UserID => $Self->{UserID},
);
if ( $LinkListWithData && $LinkListWithData->{ $Form{TargetObject} } ) {
# build object id lookup hash from search list
my %SearchListObjectKeys;
for my $Key (
sort keys %{ $SearchList->{ $Form{TargetObject} }->{NOTLINKED}->{Source} }
)
{
$SearchListObjectKeys{$Key} = 1;
}
# check if linked objects are part of the search list
for my $LinkType ( sort keys %{ $LinkListWithData->{ $Form{TargetObject} } } ) {
# extract link type List
my $LinkTypeList = $LinkListWithData->{ $Form{TargetObject} }->{$LinkType};
for my $Direction ( sort keys %{$LinkTypeList} ) {
# extract the keys
KEY:
for my $Key ( sort keys %{ $LinkTypeList->{$Direction} } ) {
next KEY if $SearchListObjectKeys{$Key};
# delete from linked objects list if key is not in search list
delete $LinkTypeList->{$Direction}->{$Key};
}
}
}
}
# add search result to link list
if ( $SearchList && $SearchList->{ $Form{TargetObject} } ) {
$LinkListWithData->{ $Form{TargetObject} }->{NOTLINKED} = $SearchList->{ $Form{TargetObject} }->{NOTLINKED};
}
# get possible types list
my %PossibleTypesList = $LinkObject->PossibleTypesList(
Object1 => $Form{SourceObject},
Object2 => $Form{TargetObject},
UserID => $Self->{UserID},
);
# define blank line entry
my %BlankLine = (
Key => '-',
Value => '-------------------------',
Disabled => 1,
);
# create the selectable type list
my $Counter = 0;
my @SelectableTypesList;
POSSIBLETYPE:
for my $PossibleType ( sort { lc $a cmp lc $b } keys %PossibleTypesList ) {
# lookup type id
my $TypeID = $LinkObject->TypeLookup(
Name => $PossibleType,
UserID => $Self->{UserID},
);
# get type
my %Type = $LinkObject->TypeGet(
TypeID => $TypeID,
UserID => $Self->{UserID},
);
# create the source name
my %SourceName;
$SourceName{Key} = $PossibleType . '::Source';
$SourceName{Value} = $Type{SourceName};
push @SelectableTypesList, \%SourceName;
next POSSIBLETYPE if !$Type{Pointed};
# create the target name
my %TargetName;
$TargetName{Key} = $PossibleType . '::Target';
$TargetName{Value} = $Type{TargetName};
push @SelectableTypesList, \%TargetName;
}
continue {
# add blank line
push @SelectableTypesList, \%BlankLine;
$Counter++;
}
# removed last (empty) entry
pop @SelectableTypesList;
# add blank lines on top and bottom of the list if more then two linktypes
if ( $Counter > 2 ) {
unshift @SelectableTypesList, \%BlankLine;
push @SelectableTypesList, \%BlankLine;
}
# create link type string
my $LinkTypeStrg = $LayoutObject->BuildSelection(
Data => \@SelectableTypesList,
Name => 'TypeIdentifier',
SelectedID => $TypeIdentifier || 'Normal::Source',
Class => 'Modernize',
);
# create the link table
my $LinkTableStrg = $LayoutObject->LinkObjectTableCreateComplex(
LinkListWithData => {
$Form{TargetObject} => $LinkListWithData->{ $Form{TargetObject} },
},
ViewMode => 'ComplexAdd',
LinkTypeStrg => $LinkTypeStrg,
);
# output the link table
$LayoutObject->Block(
Name => 'LinkTableComplex',
Data => {
LinkTableStrg => $LinkTableStrg,
},
);
# get already linked objects
$LinkListWithData = $LinkObject->LinkListWithData(
Object => $Form{SourceObject},
Key => $Form{SourceKey},
State => $Form{State},
UserID => $Self->{UserID},
);
# create the link table
$LinkTableStrg = $LayoutObject->LinkObjectTableCreateComplex(
LinkListWithData => $LinkListWithData,
ViewMode => 'ComplexDelete',
);
my $ManageTabDisabled = 0;
if ( !$LinkTableStrg ) {
$ManageTabDisabled = 1;
}
# output link delete block
$LayoutObject->Block(
Name => 'Delete',
Data => {
%Form,
SourceObjectNormal => $SourceObjectDescription{Normal},
},
);
# output the link table
$LayoutObject->Block(
Name => 'DeleteTableComplex',
Data => {
LinkTableStrg => $LinkTableStrg,
},
);
# start template output
$Output .= $LayoutObject->Output(
TemplateFile => 'AgentLinkObject',
Data => {
SourceObjectNormal => $SourceObjectDescription{Normal},
SourceObjectLong => $SourceObjectDescription{Long},
TargetObjectStrg => $TargetObjectStrg,
ActiveTab => $ActiveTab,
ManageTabDisabled => $ManageTabDisabled,
}
);
$Output .= $LayoutObject->Footer( Type => 'Small' );
return $Output;
}
1;
|