@@ -68,39 +68,46 @@ public function __construct($tasks) {
68
68
*
69
69
* Runs the action itself.
70
70
*
71
- * @return OperationResult the result {@link OperationResult} with information about operation status
71
+ * @return array OperationResult the array of {@link OperationResult} with information about operation status
72
72
*/
73
73
protected function doExecute () {
74
74
$ configDao = DAOFactory::getConfigDAO ();
75
75
$ taskDao = DAOFactory::getTaskDAO ();
76
76
$ projectDAO = DAOFactory::getProjectDAO ();
77
77
$ discardedTasks = array ();
78
- $ discardedReason = "" ;
78
+ $ discardedResults = array () ;
79
79
80
80
//first check permission on task write
81
81
foreach ($ this ->tasks as $ i => $ task ) {
82
82
if (!$ configDao ->isWriteAllowedForDate ($ task ->getDate ())) {
83
+ $ result = new OperationResult (false );
84
+ $ result ->setErrorNumber (20 );
85
+ $ result ->setResponseCode (500 );
86
+ $ result ->setMessage ("Error creating task: \nNot allowed to write to date. " );
87
+ $ discardedResults [] = $ result ;
83
88
$ discardedTasks [] = $ task ;
84
- $ discardedReason .= "Not allowed to write to date. \n" ;
85
89
unset($ this ->tasks [$ i ]);
86
90
continue ;
87
91
}
88
92
$ projectVO = $ projectDAO ->getById ($ task ->getProjectId ());
89
93
if (!$ projectVO || !$ projectVO ->getActivation ()) {
94
+ $ result = new OperationResult (false );
95
+ $ result ->setErrorNumber (30 );
96
+ $ result ->setResponseCode (500 );
97
+ $ result ->setMessage ("Error creating task: \nNot allowed to write to project. " );
90
98
$ discardedTasks [] = $ task ;
91
- $ discardedReason .= " Not allowed to write to project. \n" ;
99
+ $ discardedResults [] = $ result ;
92
100
unset($ this ->tasks [$ i ]);
93
101
}
94
102
}
95
103
96
- $ result = $ taskDao ->batchCreate ($ this ->tasks );
104
+ $ results = $ taskDao ->batchCreate ($ this ->tasks );
97
105
98
106
//TODO: do something meaningful with the list of discarded tasks
99
107
if (!empty ($ discardedTasks )) {
100
- $ result = new OperationResult (false );
101
- $ result ->setMessage ("Some tasks were discarded: \n" . $ discardedReason );
108
+ return array_merge ($ discardedResults , $ results );
102
109
}
103
- return $ result ;
110
+ return $ results ;
104
111
}
105
112
106
113
}
0 commit comments