예제 #1
0
 function addTemplateInheritance($name)
 {
     // First get the template by name
     $template = NagiosHostTemplatePeer::getByName($name);
     if (!$template) {
         return false;
     }
     // Check to see if inheritance already exists
     $id = $this->getId();
     if (!empty($id)) {
         $c = new Criteria();
         $c->add(NagiosHostTemplateInheritancePeer::SOURCE_TEMPLATE, $this->getId());
         $c->add(NagiosHostTemplateInheritancePeer::TARGET_TEMPLATE, $template->getId());
         $relationship = NagiosHostTemplateInheritancePeer::doSelectOne($c);
         if ($relationship) {
             return false;
         }
     }
     // Okay, create new one
     $relationship = new NagiosHostTemplateInheritance();
     $relationship->setNagiosHostTemplateRelatedBySourceTemplate($this);
     $relationship->setNagiosHostTemplateRelatedByTargetTemplate($template);
     $relationship->save();
     return true;
 }