Ejemplo n.º 1
0
/**
 * 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()));
$oPage->addPageColumns();
Ejemplo n.º 2
0
 /**
  * Smazaže kontakt i jeho subkontakty
  *
  * @return boolean
  */
 public function rename($newname)
 {
     $oldname = $this->getName();
     $this->setDataValue($this->nameColumn, $newname);
     if ($this->saveToMySQL()) {
         $childs = $this->getChilds();
         $subcontact = new IEContact();
         $service = new IEService();
         foreach ($childs as $childID => $childInfo) {
             $subcontact->loadFromMySQL($childID);
             $type = $subcontact->getDataValue('alias');
             $subcontact->setDataValue($subcontact->nameColumn, $newname . ' ' . $type);
             $services = $this->myDbLink->queryTo2DArray('SELECT ' . $service->getmyKeyColumn() . ' FROM ' . $service->myTable . ' WHERE contacts LIKE \'%' . $oldname . ' ' . $type . '%\'');
             if (count($services)) {
                 foreach ($services as $serviceID) {
                     $service->loadFromMySQL((int) $serviceID);
                     if ($service->delMember('contacts', $id)) {
                         $service->addMember('contacts', $id, $newname . ' ' . $type);
                         $service->saveToMySQL();
                     }
                 }
             }
             $subcontact->saveToMySQL();
         }
     } else {
         $this->addStatusMessage(_('Kontakt nelze přejmenovat'), 'warning');
     }
 }