/**
 * Icinga Editor - nový kontakt
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
require_once 'classes/IEContact.php';
$oPage->onlyForLogged();
$contact = new IEContact($oPage->getRequestValue('contact_id', 'int'));
$name = $oPage->getRequestValue('name');
if ($oPage->isPosted()) {
    $contact->setData(array('contact_name' => $name, 'use' => 'generic-contact', $contact->userColumn => $oUser->getUserID(), 'generate' => true, 'host_notifications_enabled' => true, 'service_notifications_enabled' => true, 'host_notification_period' => '24x7', 'service_notification_period' => '24x7', 'service_notification_options' => ' w,u,c,r', 'host_notification_options' => 'd,u,r', 'service_notification_commands' => 'notify-service-by-email', 'host_notification_commands' => 'notify-host-by-email', 'register' => 1));
    $contactID = $contact->saveToMySQL();
    if (is_null($contactID)) {
        $oUser->addStatusMessage(_('Kontakt nebyl založen'), 'warning');
    } else {
        $oUser->addStatusMessage(_('Kontakt byl založen'), 'success');
        $oPage->redirect('contacttweak.php?contact_id=' . $contact->getId());
        exit;
    }
}
$autoCreate = $oPage->getRequestValue('autocreate');
if ($autoCreate == 'default') {
    $contact->setData(IEContact::ownContactData());
    $contactID = $contact->saveToMySQL();
}
$oPage->addItem(new IEPageTop(_('Založení kontaktu') . ' ' . $contact->getName()));