Пример #1
0
                $results[$cttemp] = RevDeploy::getDeploymentContactTemplate($deployment, $cttemp, $deployRev);
            }
        }
        if (empty($results)) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect contact templates specified: {$contacttemplate}");
            $app->halt(404, $apiResponse->returnJson());
        } else {
            $apiResponse = new APIViewData(0, $deployment, false);
            $apiResponse->setExtraResponseData('contact_templates', $results);
        }
    } else {
        if (RevDeploy::existsDeploymentContactTemplate($deployment, $contacttemplate, $deployRev) === false) {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect contact template specified: {$contacttemplate}");
            $app->halt(404, $apiResponse->returnJson());
        } else {
            $contactTemplateInfo = RevDeploy::getDeploymentContactTemplate($deployment, $contacttemplate, $deployRev);
            $apiResponse = new APIViewData(0, $deployment, false);
            $apiResponse->setExtraResponseData('contact_template', $contactTemplateInfo);
        }
    }
    $apiResponse->printJson();
})->name('saigon-api-get-contact-template');
$app->post('/sapi/contacttemplate/:deployment', function ($deployment) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    check_revision_status($deployment);
    $request = $app->request();
    $contentType = $request->headers('Content-Type');
    if ($contentType == 'application/json') {
        $contactTemplateInfo = $request->getBody();
        $contactTemplateInfo = json_decode($contactTemplateInfo, true);
 public function copy_common_stage()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('contact_template_error');
     $contactTemplate = $this->getParam('contacttemp');
     if ($contactTemplate === false) {
         $viewData->header = $this->getErrorHeader('contact_template_error');
         $viewData->error = 'Unable to detect contact template specified in post params';
         $this->sendError('generic_error', $viewData);
     }
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $commonRepo = RevDeploy::getDeploymentCommonRepo($deployment);
     $commonrevision = RevDeploy::getDeploymentRev($commonRepo);
     $viewData->contacttemplates = RevDeploy::getCommonMergedDeploymentContactTemplates($deployment, $modrevision);
     $viewData->notifycmds = RevDeploy::getCommonMergedDeploymentNotifyCommands($deployment, $modrevision);
     $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
     $viewData->contactInfo = RevDeploy::getDeploymentContactTemplate($commonRepo, $contactTemplate, $commonrevision);
     $viewData->deployment = $deployment;
     $viewData->contacttemplate = $contactTemplate;
     $viewData->action = 'copy_write';
     $this->sendResponse('contact_template_action_stage', $viewData);
 }