Exemplo n.º 1
0
     $err = false;
     if ($value != '') {
         foreach ($values as $val) {
             if (!preg_match("/\\d\\d:\\d\\d-\\d\\d:\\d\\d/", trim($val))) {
                 $err = true;
             }
         }
     }
     if ($err) {
         $error = "Entry value must be comma-delimited list of proper values.";
     } else {
         // Check for existing entry with that name!
         $c = new Criteria();
         $c->add(NagiosTimeperiodEntryPeer::TIMEPERIOD_ID, $timeperiod->getId());
         $c->add(NagiosTimeperiodEntryPeer::ENTRY, $entry);
         $foundEntry = NagiosTimeperiodEntryPeer::doSelectOne($c);
         if ($foundEntry) {
             $error = "That entry already exists.  Remove it then add it with the new value.";
         } else {
             // Okay, let's add.
             $newEntry = new NagiosTimeperiodEntry();
             $newEntry->setTimeperiodId($timeperiod->getId());
             $newEntry->setEntry($entry);
             $newEntry->setValue($value);
             $newEntry->save();
             $success = "Entry added.";
             $entry = '';
             $value = '';
         }
     }
 }