* create new blank report * * @return int * @throws Exception */
( $name, $subheader, $parent, $type, int $dataset, $link, $visualization, $chart, $dimension1, $dimension2, $value, $addReport = null )
| 202 | * @throws Exception |
| 203 | */ |
| 204 | public function create( |
| 205 | $name, |
| 206 | $subheader, |
| 207 | $parent, |
| 208 | $type, |
| 209 | int $dataset, |
| 210 | $link, |
| 211 | $visualization, |
| 212 | $chart, |
| 213 | $dimension1, |
| 214 | $dimension2, |
| 215 | $value, |
| 216 | $addReport = null |
| 217 | ): int { |
| 218 | $array = json_decode($link, true); |
| 219 | if (is_array($array)) { |
| 220 | foreach ($array as $key => $value) { |
| 221 | $array[$key] = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); |
| 222 | } |
| 223 | } |
| 224 | $link = json_encode($array); |
| 225 | |
| 226 | if ($type === DatasourceController::DATASET_TYPE_GROUP) { |
| 227 | $parent = 0; |
| 228 | } |
| 229 | if (!$this->isValidParent((int)$parent)) { |
| 230 | return 0; |
| 231 | } |
| 232 | if ($dataset < 0 || ($type !== DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset !== 0)) { |
| 233 | return 0; |
| 234 | } |
| 235 | if ($type === DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset === 0) { // New dataset |
| 236 | $dataset = $this->DatasetService->create($name, $dimension1, $dimension2, $value); |
| 237 | } else if ($type === DatasourceController::DATASET_TYPE_INTERNAL_DB && $dataset !== 0) { |
| 238 | $ownDataset = $this->DatasetService->readOwn($dataset); |
| 239 | if (empty($ownDataset)) { |
| 240 | return 0; |
| 241 | } |
| 242 | } |
| 243 | $reportId = $this->ReportMapper->create($name, $subheader, $parent, $type, $dataset, $link, $visualization, $chart, $dimension1, $dimension2, $value); |
| 244 | $this->ActivityManager->triggerEvent($reportId, ActivityManager::OBJECT_REPORT, ActivityManager::SUBJECT_REPORT_ADD); |
| 245 | |
| 246 | if ($addReport !== null && $addReport !== '') { |
| 247 | $this->updateGroup($addReport, $reportId); |
| 248 | } |
| 249 | return $reportId; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * copy an existing report with the current navigation status |
no test coverage detected