11<?php
2+
23/*
34 * This file is part of MODX Revolution.
45 *
1011
1112namespace MODX \Revolution \Processors \Resource ;
1213
13-
1414use MODX \Revolution \modContext ;
1515use MODX \Revolution \Processors \Processor ;
1616use MODX \Revolution \modResource ;
@@ -53,9 +53,13 @@ public function process()
5353
5454 // Because of BC
5555 $ data = urldecode ($ this ->getProperty ('data ' , '' ));
56- if (empty ($ data )) $ this ->failure ($ this ->modx ->lexicon ('invalid_data ' ));
56+ if (empty ($ data )) {
57+ return $ this ->failure ($ this ->modx ->lexicon ('invalid_data ' ));
58+ }
5759 $ data = $ this ->modx ->fromJSON ($ data );
58- if (empty ($ data )) $ this ->failure ($ this ->modx ->lexicon ('invalid_data ' ));
60+ if (empty ($ data )) {
61+ return $ this ->failure ($ this ->modx ->lexicon ('invalid_data ' ));
62+ }
5963
6064 // Because of BC
6165 $ this ->getNodesFormatted ($ data , $ this ->getProperty ('parent ' , 0 ));
@@ -66,7 +70,7 @@ public function process()
6670 $ source = $ this ->getProperty ('source ' , '' );
6771 $ point = $ this ->getProperty ('point ' , '' );
6872
69- if (empty ($ target )) {
73+ if (empty ($ target )) {
7074 return $ this ->failure ('Target not set ' );
7175 }
7276
@@ -83,7 +87,9 @@ public function process()
8387 $ this ->parseNodes ($ source , $ target );
8488
8589 $ sorted = $ this ->sort ();
86- if ($ sorted !== true ) return $ this ->failure ($ sorted );
90+ if ($ sorted !== true ) {
91+ return $ this ->failure ($ sorted );
92+ }
8793
8894 $ this ->fireAfterSort ();
8995
@@ -151,7 +157,6 @@ public function fireAfterSort()
151157 'contextsAffected ' => &$ this ->contextsAffected ,
152158 'modifiedNodes ' => &$ this ->nodesAffected , /* backward compat */
153159 ]);
154-
155160 }
156161
157162 public function clearCache ()
@@ -174,8 +179,12 @@ public function fixParents($node)
174179 /** @var modResource $newParent */
175180 $ newParent = $ this ->modx ->getObject (modResource::class, $ this ->target ->id );
176181
177- if (empty ($ oldParent ) && empty ($ newParent )) return ;
178- if ($ oldParent ->id == $ newParent ->id ) return ;
182+ if (empty ($ oldParent ) && empty ($ newParent )) {
183+ return ;
184+ }
185+ if ($ oldParent ->id == $ newParent ->id ) {
186+ return ;
187+ }
179188
180189 if (!empty ($ oldParent )) {
181190 $ oldParentChildrenCount = $ this ->modx ->getCount (modResource::class, ['parent ' => $ oldParent ->get ('id ' ), 'id:!= ' => $ node ->id ]);
@@ -189,7 +198,7 @@ public function fixParents($node)
189198 }
190199 }
191200
192- if (!empty ($ newParent )) {
201+ if (!empty ($ newParent ) && $ this -> point === ' append ' ) {
193202 $ newParent ->set ('isfolder ' , true );
194203 $ newParent ->save ();
195204
@@ -343,10 +352,14 @@ public function moveResource($type, $rank)
343352 public function moveResourceAbove ($ lastRank )
344353 {
345354 $ moved = $ this ->moveResource ('source ' , $ lastRank );
346- if ($ moved !== true ) return $ moved ;
355+ if ($ moved !== true ) {
356+ return $ moved ;
357+ }
347358
348359 $ moved = $ this ->moveResource ('target ' , $ lastRank + 1 );
349- if ($ moved !== true ) return $ moved ;
360+ if ($ moved !== true ) {
361+ return $ moved ;
362+ }
350363
351364 return $ this ->moveAffectedResources ($ lastRank );
352365 }
0 commit comments