File tree 2 files changed +17
-12
lines changed
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -95,11 +95,10 @@ function importAttribute( $data, &$contentObjectAttribute )
95
95
function addNodeAssignment ( $ content_object , $ parent_node_id , $ set_as_main_node = false )
96
96
{
97
97
$ main_node_id = $ content_object ->attribute ( 'main_node_id ' );
98
- $ insertedNode =& $ content_object ->addLocation ( $ parent_node_id , true );
98
+ $ insertedNode = $ content_object ->addLocation ( $ parent_node_id , true );
99
99
// Now set it as published and fix main_node_id
100
100
$ insertedNode ->setAttribute ( 'contentobject_is_published ' , 1 );
101
- $ contentObject = eZContentObject::fetch ( $ objectID );
102
- $ parentContentObject = eZContentObject::fetchByNodeID ( $ parentMainNodeID );
101
+ $ parentContentObject = eZContentObject::fetchByNodeID ( $ parent_node_id );
103
102
if ( $ set_as_main_node )
104
103
{
105
104
$ main_node_id = $ insertedNode ->attribute ( 'node_id ' );
Original file line number Diff line number Diff line change @@ -7,8 +7,9 @@ function getHelpText()
7
7
{
8
8
return '
9
9
--operation="nodeassignlocations;locations=<node_id,node_id...>"
10
-
11
- locations - a colon separated list of new parent nodes to assign to this node
10
+
11
+ Add new locations under the specified parent node id \'s
12
+ locations - a colon separated list of new parent node id \'s to assign to this node
12
13
' ;
13
14
}
14
15
@@ -35,19 +36,24 @@ function setParameters( $parm_array )
35
36
36
37
// Assign locations to the given node
37
38
// locations - an array of node IDs for new parent nodes
38
- function runOperation ( &$ object )
39
+ function runOperation ( &$ node )
39
40
{
40
- $ result = true ;
41
-
42
- require_once ( 'kernel/classes/ezcontentobject.php ' );
41
+ $ db = eZDB::instance ();
42
+ $ db ->begin ();
43
43
44
44
foreach ($ this ->locations as $ location )
45
45
{
46
- $ contentobject = $ object ->object ();
47
- $ result = $ result && $ contentobject ->AddLocation ( $ location , true );
46
+ $ contentobject = $ node ->object ();
47
+ $ id = $ contentobject ->addLocation ( $ location , true );
48
+ if ( empty ( $ id ) )
49
+ {
50
+ $ db ->rollback ();
51
+ return false ;
52
+ }
48
53
}
49
54
50
- return $ result ;
55
+ $ db ->commit ();
56
+ return true ;
51
57
}
52
58
53
59
var $ locations = array ();
You can’t perform that action at this time.
0 commit comments