Exemplo n.º 1
0
 private static function copyContacts($deployment, $revision, array $cInfo)
 {
     if (self::$init === false) {
         self::init();
     }
     foreach ($cInfo as $contact => $cArray) {
         if ($cArray['deployment'] == self::$m_commonrepo && $cArray['deployment'] == 'common') {
             continue;
         }
         if ($cArray['deployment'] == self::$m_commonrepo) {
             continue;
         }
         foreach ($cArray as $key => $value) {
             if (is_array($cArray[$key])) {
                 $cArray[$key] = implode(',', $cArray[$key]);
             }
         }
         RevDeploy::createDeploymentContact($deployment, $contact, $cArray, $revision);
     }
 }
Exemplo n.º 2
0
                    $apiResponse->setExtraResponseData('parameter-pager-regex', "/^(?[2-9][0-8][0-9])?-[2-9][0-0]{2}-[0-9]{4}\$/");
                    $app->halt(404, $apiResponse->returnJson());
                }
            }
        } else {
            $apiResponse = new APIViewData(1, $deployment, "Unable to detect an appropriate contact parameter, email or pager");
            $app->halt(404, $apiResponse->returnJson());
        }
    }
    $contactInfo = contact_validate($app, $deployment, $contactInfo);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (RevDeploy::existsDeploymentContact($deployment, $contactInfo['contact_name'], $deployRev) === true) {
        RevDeploy::modifyDeploymentContact($deployment, $contactInfo['contact_name'], $contactInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Modified Contact  " . $contactInfo['contact_name']);
    } else {
        RevDeploy::createDeploymentContact($deployment, $contactInfo['contact_name'], $contactInfo, $deployRev);
        $apiResponse = new APIViewData(0, $deployment, "Successfully Created Contact  " . $contactInfo['contact_name']);
    }
    $apiResponse->printJson();
})->name('saigon-api-create-contact');
$app->delete('/sapi/contact/:deployment/:contact', function ($deployment, $contact) use($app) {
    check_deployment_exists($app, $deployment);
    check_auth($app, $deployment);
    check_revision_status($deployment);
    $deployRev = RevDeploy::getDeploymentNextRev($deployment);
    if (preg_match('/,/', $contact)) {
        $contacts = preg_split('/\\s?,\\s?/', $contact);
        foreach ($contacts as $ctemp) {
            RevDeploy::deleteDeploymentContact($deployment, $ctemp, $deployRev);
        }
    } else {
 public function copy_to_write()
 {
     $viewData = new ViewData();
     $deployment = $this->getDeployment('contact_error');
     $contactName = $this->getParam('contactName');
     $modrevision = RevDeploy::getDeploymentNextRev($deployment);
     $contactInfo = $this->fetchContactInfo($deployment, 'copy_to_write', $modrevision);
     $todeployment = $this->getParam('todeployment');
     if ($todeployment === false) {
         $viewData->error = 'Unable to detect contact to copy contact to';
         $viewData->availdeployments = $this->getDeploymentsAvailToUser();
         $viewData->contactInfo = $contactInfo;
         $viewData->contacttemplates = RevDeploy::getCommonMergedDeploymentContactTemplates($deployment, $modrevision);
         $viewData->notifycmds = RevDeploy::getCommonMergedDeploymentNotifyCommands($deployment, $modrevision);
         $viewData->timeperiods = RevDeploy::getCommonMergedDeploymentTimeperiods($deployment, $modrevision);
         $viewData->deployment = $deployment;
         $viewData->action = 'copy_to_write';
         $this->sendResponse('contact_action_stage', $viewData);
     }
     $this->checkGroupAuth($todeployment);
     $this->checkDeploymentRevStatus($todeployment);
     $tdRev = RevDeploy::getDeploymentNextRev($todeployment);
     if (RevDeploy::existsDeploymentContact($todeployment, $contactName, $tdRev) === true) {
         RevDeploy::modifyDeploymentContact($todeployment, $contactName, $contactInfo, $tdRev);
     } else {
         RevDeploy::createDeploymentContact($todeployment, $contactName, $contactInfo, $tdRev);
     }
     $viewData->deployment = $deployment;
     $viewData->todeployment = $todeployment;
     $viewData->contact = $contactName;
     $this->sendResponse('contact_write', $viewData);
 }