/usr/share/otrs/Kernel/Modules/AdminProcessManagementPath.pm is in otrs2 3.3.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 | # --
# Kernel/Modules/AdminProcessManagementPath.pm - process management path
# Copyright (C) 2001-2014 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::AdminProcessManagementPath;
use strict;
use warnings;
use List::Util qw(first);
use Kernel::System::JSON;
use Kernel::System::ProcessManagement::DB::Process;
use Kernel::System::ProcessManagement::DB::Entity;
use Kernel::System::ProcessManagement::DB::Transition;
use Kernel::System::ProcessManagement::DB::TransitionAction;
use Kernel::System::VariableCheck qw(:all);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
# check all needed objects
for my $Needed (
qw(ParamObject DBObject LayoutObject ConfigObject LogObject MainObject EncodeObject)
)
{
if ( !$Self->{$Needed} ) {
$Self->{LayoutObject}->FatalError( Message => "Got no $Needed!" );
}
}
# create additional objects
$Self->{JSONObject} = Kernel::System::JSON->new( %{$Self} );
$Self->{ProcessObject} = Kernel::System::ProcessManagement::DB::Process->new( %{$Self} );
$Self->{EntityObject} = Kernel::System::ProcessManagement::DB::Entity->new( %{$Self} );
$Self->{TransitionObject} = Kernel::System::ProcessManagement::DB::Transition->new( %{$Self} );
$Self->{TransitionActionObject}
= Kernel::System::ProcessManagement::DB::TransitionAction->new( %{$Self} );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
$Self->{Subaction} = $Self->{ParamObject}->GetParam( Param => 'Subaction' ) || '';
my %SessionData = $Self->{SessionObject}->GetSessionIDData(
SessionID => $Self->{SessionID},
);
# convert JSON string to array
$Self->{ScreensPath} = $Self->{JSONObject}->Decode(
Data => $SessionData{ProcessManagementScreensPath}
);
# get available transitions
$Self->{TransitionList}
= $Self->{TransitionObject}->TransitionListGet( UserID => $Self->{UserID} );
# get available transition actions
$Self->{TransitionActionList}
= $Self->{TransitionActionObject}->TransitionActionListGet( UserID => $Self->{UserID} );
# ------------------------------------------------------------ #
# PathEdit
# ------------------------------------------------------------ #
if ( $Self->{Subaction} eq 'PathEdit' ) {
# get path data
my $PathData;
# get parameter from web browser
my $GetParam = $Self->_GetParams();
$PathData->{ProcessEntityID} = $GetParam->{ProcessEntityID} || $GetParam->{ID};
$PathData->{TransitionEntityID} = $GetParam->{TransitionEntityID} || $GetParam->{EntityID};
$PathData->{StartActivityID} = $GetParam->{StartActivityID};
# remove this screen from session screen path
$Self->_PopSessionScreen( OnlyCurrent => 1 );
return $Self->_ShowEdit(
%Param,
%{$PathData},
Action => 'Edit',
);
}
# ------------------------------------------------------------ #
# PathEditAction
# ------------------------------------------------------------ #
elsif ( $Self->{Subaction} eq 'PathEditAction' ) {
# challenge token check for write action
$Self->{LayoutObject}->ChallengeTokenCheck();
my $TransferData;
# get parameter from web browser
my $GetParam = $Self->_GetParams();
# merge changed data into process config
$TransferData->{ProcessEntityID} = $GetParam->{ProcessEntityID};
$TransferData->{TransitionEntityID} = $GetParam->{TransitionEntityID};
$TransferData->{ProcessData} = $GetParam->{ProcessData};
$TransferData->{TransitionInfo} = $GetParam->{TransitionInfo};
for my $Needed (qw(ProcessEntityID TransitionEntityID ProcessData TransitionInfo)) {
# show error if can't update
if ( !$TransferData->{$Needed} ) {
return $Self->{LayoutObject}->ErrorScreen(
Message => "Need $Needed!",
);
}
}
my $ProcessData = $Self->{JSONObject}->Decode( Data => $TransferData->{ProcessData} );
my $DataToMerge = $Self->{JSONObject}->Decode( Data => $TransferData->{TransitionInfo} );
# delete the "old" transition key from path hash
delete $ProcessData->{ $TransferData->{ProcessEntityID} }->{Path}
->{ $DataToMerge->{StartActivityEntityID} }->{ $TransferData->{TransitionEntityID} };
# insert the "new" transition entry into path hash
$ProcessData->{ $TransferData->{ProcessEntityID} }->{Path}
->{ $DataToMerge->{StartActivityEntityID} }->{ $DataToMerge->{NewTransitionEntityID} }
= {
TransitionAction => $DataToMerge->{NewTransitionActions},
ActivityEntityID => $DataToMerge->{NewTransitionActivityID},
};
my $ReturnConfig;
$ReturnConfig->{Process} = $ProcessData;
# remove this screen from session screen path
$Self->_PopSessionScreen( OnlyCurrent => 1 );
my $Redirect = $Self->{ParamObject}->GetParam( Param => 'PopupRedirect' ) || '';
my $ConfigJSON = $Self->{LayoutObject}->JSONEncode( Data => $ReturnConfig );
# check if needed to open another window or if popup should go back
if ( $Redirect && $Redirect eq '1' ) {
my $RedirectAction
= $Self->{ParamObject}->GetParam( Param => 'PopupRedirectAction' ) || '';
my $RedirectSubaction
= $Self->{ParamObject}->GetParam( Param => 'PopupRedirectSubaction' ) || '';
my $RedirectID = $Self->{ParamObject}->GetParam( Param => 'PopupRedirectID' ) || '';
my $RedirectEntityID
= $Self->{ParamObject}->GetParam( Param => 'PopupRedirectEntityID' ) || '';
# when redirecting to the transition dialog, we need the new TransitionID
# because the ID was possibly changed in this dialog
# the value is stored in data-entity
# when redirecting to the transition action dialog, data-entity contains
# the transition action ID, but still we need the transition ID for going back
my $EntityID;
if (
$RedirectSubaction eq 'TransitionActionEdit'
|| $RedirectSubaction eq 'TransitionActionNew'
)
{
$EntityID = $TransferData->{TransitionEntityID};
}
elsif ( $RedirectSubaction eq 'TransitionEdit' ) {
$EntityID = $RedirectEntityID;
}
$Self->_PushSessionScreen(
ID => $TransferData->{ProcessEntityID}, # abuse!
EntityID => $EntityID,
StartActivityID => $GetParam->{StartActivityID},
Subaction => 'PathEdit' # always use edit screen
);
# get transition id
if ( $RedirectAction eq 'AdminProcessManagementTransition' && !$RedirectID ) {
my $Transition = $Self->{TransitionObject}->TransitionGet(
EntityID => $RedirectEntityID,
UserID => $Self->{UserID},
);
$RedirectID = $Transition->{ID};
}
# redirect to another popup window
return $Self->_PopupResponse(
Redirect => 1,
Screen => {
Action => $RedirectAction,
Subaction => $RedirectSubaction,
ID => $RedirectID,
EntityID => $RedirectEntityID,
},
ConfigJSON => $ConfigJSON,
);
}
else {
# remove last screen
my $LastScreen = $Self->_PopSessionScreen();
# check if needed to return to main screen or to be redirected to last screen
if ( $LastScreen->{Action} eq 'AdminProcessManagement' ) {
# close the popup
return $Self->_PopupResponse(
ClosePopup => 1,
ConfigJSON => $ConfigJSON,
);
}
else {
# redirect to last screen
return $Self->_PopupResponse(
Redirect => 1,
Screen => $LastScreen,
ConfigJSON => $ConfigJSON,
);
}
}
}
# ------------------------------------------------------------ #
# Close popup
# ------------------------------------------------------------ #
elsif ( $Self->{Subaction} eq 'ClosePopup' ) {
# close the popup
return $Self->_PopupResponse(
ClosePopup => 1,
);
}
# ------------------------------------------------------------ #
# Error
# ------------------------------------------------------------ #
else {
return $Self->{LayoutObject}->ErrorScreen(
Message => "This subaction is not valid",
);
}
}
sub _ShowEdit {
my ( $Self, %Param ) = @_;
# check if last screen action is main screen
if ( $Self->{ScreensPath}->[-1]->{Action} eq 'AdminProcessManagement' ) {
# show close popup link
$Self->{LayoutObject}->Block(
Name => 'ClosePopup',
Data => {},
);
}
else {
# show go back link
$Self->{LayoutObject}->Block(
Name => 'GoBack',
Data => {
Action => $Self->{ScreensPath}->[-1]->{Action} || '',
Subaction => $Self->{ScreensPath}->[-1]->{Subaction} || '',
ID => $Self->{ScreensPath}->[-1]->{ID} || '',
EntityID => $Self->{ScreensPath}->[-1]->{EntityID} || '',
},
);
}
# localize available activity dialogs
my @AvailableTransitionActions = @{ $Self->{TransitionActionList} };
# create available transition actions lookup tables based on entity id
my %AvailableTransitionActionsLookup;
TRANSITIONACTION:
for my $TransitionActionConfig (@AvailableTransitionActions) {
next TRANSITIONACTION if !$TransitionActionConfig;
next TRANSITIONACTION if !$TransitionActionConfig->{EntityID};
$AvailableTransitionActionsLookup{ $TransitionActionConfig->{EntityID} }
= $TransitionActionConfig;
}
# collect possible transitions and build selection
my %TransitionList;
for my $Transition ( @{ $Self->{TransitionList} } ) {
$TransitionList{ $Transition->{EntityID} } = $Transition->{Name};
}
# fix sorting by names
my @TransitionList;
for my $TransitionID (
sort { lc $TransitionList{$a} cmp lc $TransitionList{$b} }
keys %TransitionList
)
{
push @TransitionList, {
Key => $TransitionID,
Value => $TransitionList{$TransitionID},
};
}
$Param{Transition} = $Self->{LayoutObject}->BuildSelection(
Data => \@TransitionList,
Name => "Transition",
ID => "Transition",
Title => $Self->{LayoutObject}->{LanguageObject}->Get("Transition"),
Translation => 1,
Class => 'W50pc',
);
# display available transition actions
for my $EntityID ( sort keys %AvailableTransitionActionsLookup ) {
my $TransitionActionData = $AvailableTransitionActionsLookup{$EntityID};
$Self->{LayoutObject}->Block(
Name => 'AvailableTransitionActionRow',
Data => {
ID => $TransitionActionData->{ID},
EntityID => $TransitionActionData->{EntityID},
Name => $TransitionActionData->{Name},
},
);
}
$Param{Title} = "Edit Path";
my $Output = $Self->{LayoutObject}->Header(
Value => $Param{Title},
Type => 'Small',
);
$Output .= $Self->{LayoutObject}->Output(
TemplateFile => "AdminProcessManagementPath",
Data => {
%Param,
},
);
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
sub _GetParams {
my ( $Self, %Param ) = @_;
my $GetParam;
# get parameters from web browser
for my $ParamName (
qw( ID EntityID ProcessData TransitionInfo ProcessEntityID StartActivityID TransitionEntityID )
)
{
$GetParam->{$ParamName} = $Self->{ParamObject}->GetParam( Param => $ParamName ) || '';
}
return $GetParam;
}
sub _PopSessionScreen {
my ( $Self, %Param ) = @_;
my $LastScreen;
if ( defined $Param{OnlyCurrent} && $Param{OnlyCurrent} == 1 ) {
# check if last screen action is current screen action
if ( $Self->{ScreensPath}->[-1]->{Action} eq $Self->{Action} ) {
# remove last screen
$LastScreen = pop @{ $Self->{ScreensPath} };
}
}
else {
# remove last screen
$LastScreen = pop @{ $Self->{ScreensPath} };
}
# convert screens path to string (JSON)
my $JSONScreensPath = $Self->{LayoutObject}->JSONEncode(
Data => $Self->{ScreensPath},
);
# update session
$Self->{SessionObject}->UpdateSessionID(
SessionID => $Self->{SessionID},
Key => 'ProcessManagementScreensPath',
Value => $JSONScreensPath,
);
return $LastScreen;
}
sub _PushSessionScreen {
my ( $Self, %Param ) = @_;
# add screen to the screen path
push @{ $Self->{ScreensPath} }, {
Action => $Self->{Action} || '',
Subaction => $Param{Subaction},
ID => $Param{ID},
EntityID => $Param{EntityID},
StartActivityID => $Param{StartActivityID},
};
# convert screens path to string (JSON)
my $JSONScreensPath = $Self->{LayoutObject}->JSONEncode(
Data => $Self->{ScreensPath},
);
# update session
$Self->{SessionObject}->UpdateSessionID(
SessionID => $Self->{SessionID},
Key => 'ProcessManagementScreensPath',
Value => $JSONScreensPath,
);
return 1;
}
sub _PopupResponse {
my ( $Self, %Param ) = @_;
if ( $Param{Redirect} && $Param{Redirect} eq 1 ) {
$Self->{LayoutObject}->Block(
Name => 'Redirect',
Data => {
ConfigJSON => $Param{ConfigJSON},
%{ $Param{Screen} },
},
);
}
elsif ( $Param{ClosePopup} && $Param{ClosePopup} eq 1 ) {
$Self->{LayoutObject}->Block(
Name => 'ClosePopup',
Data => {
ConfigJSON => $Param{ConfigJSON},
},
);
}
my $Output = $Self->{LayoutObject}->Header( Type => 'Small' );
$Output .= $Self->{LayoutObject}->Output(
TemplateFile => "AdminProcessManagementPopupResponse",
Data => {},
);
$Output .= $Self->{LayoutObject}->Footer( Type => 'Small' );
return $Output;
}
1;
|