indexStandard($request, $page); } /** * The initiative detail page (tabs: Details, Description, Objectives, Allocations, Audiences, Stakeholders, Tasks). * * Core's viewStandard() isn't used: for users who aren't administrators it checks an * ":export:enable" permission, which plans don't have. * * @param int $objectId */ public function viewAction(Request $request, $objectId): Response { $initiative = $this->getModel($this->getModelName())->getEntity((int) $objectId); if (!$initiative instanceof Initiative) { return $this->notFound('mautic.program.error.notfound'); } if (!$this->checkActionPermission('view', $initiative)) { return $this->accessDenied(); } $base = $this->getPermissionBase(); $permissions = $this->security->isGranted( [ $base.':create', $base.':editown', $base.':editother', $base.':deleteown', $base.':deleteother', ], 'RETURN_ARRAY', null, true ); $taskPermissions = $this->security->isGranted( [ 'program:tasks:create', 'program:tasks:editown', 'program:tasks:editother', ], 'RETURN_ARRAY', null, true ); return $this->delegateView([ 'viewParameters' => [ 'item' => $initiative, 'permissions' => $permissions, 'taskTree' => $this->getTaskModel()->getTaskTree($initiative), 'taskPermissions' => $taskPermissions, // Core's page_actions helper would otherwise build mautic_plan_* route names. 'indexRoute' => self::ROUTE_INDEX, 'actionRoute' => self::ROUTE_ACTION, 'tmpl' => $request->isXmlHttpRequest() ? $request->get('tmpl', 'details') : 'details', ], 'contentTemplate' => $this->getTemplateName('details.html.twig'), 'passthroughVars' => [ 'activeLink' => '#initiative_index', 'mauticContent' => $this->getJsLoadMethodPrefix(), 'route' => $this->generateUrl(self::ROUTE_ACTION, ['objectAction' => 'view', 'objectId' => $initiative->getId()]), ], ]); } /** * Adds the initiative's task tree to the form, for the read-only Tasks tab. * * @param array $args * @param string $action * * @return array */ protected function getViewArguments(array $args, $action): array { $initiative = $args['viewParameters']['entity'] ?? null; if (in_array($action, ['new', 'edit'], true) && $initiative instanceof Initiative && null !== $initiative->getId()) { $args['viewParameters']['taskTree'] = $this->getTaskModel()->getTaskTree($initiative); } return parent::getViewArguments($args, $action); } private function getTaskModel(): TaskModel { $model = $this->getModel('program.task'); \assert($model instanceof TaskModel); return $model; } public function newAction(Request $request): Response { return $this->newStandard($request); } /** * @param int $objectId * @param bool $ignorePost */ public function editAction(Request $request, $objectId, $ignorePost = false): Response { return $this->editStandard($request, $objectId, $ignorePost); } /** * @param int $objectId */ public function deleteAction(Request $request, $objectId): Response { return $this->deleteStandard($request, $objectId); } public function batchDeleteAction(Request $request): Response { return $this->batchDeleteStandard($request); } }