예제 #1
0
 /**
  * @copydoc DBElement::check_values_validity()
  */
 public static function check_values_validity(&$database, &$current_user, &$log, &$values, $is_new, &$element = NULL)
 {
     // first, we let all parent classes to check the values
     parent::check_values_validity($database, $current_user, $log, $values, $is_new, $element);
     // set the datetype of the boolean attributes
     settype($values['obsolete'], 'boolean');
     // check "part_id"
     try {
         $part = new Part($database, $current_user, $log, $values['part_id']);
         $part->set_attributes(array());
         // save part attributes to update its "last_modified"
     } catch (Exception $e) {
         debug('error', 'Ungültige "part_id": "' . $values['part_id'] . '"' . "\n\nUrsprüngliche Fehlermeldung: " . $e->getMessage(), __FILE__, __LINE__, __METHOD__);
         throw new Exception('Das gewählte Bauteil existiert nicht!');
     }
     // check "id_supplier"
     try {
         if ($values['id_supplier'] < 1) {
             throw new Exception('id_supplier < 1');
         }
         $supplier = new Supplier($database, $current_user, $log, $values['id_supplier']);
     } catch (Exception $e) {
         debug('error', 'Ungültige "id_supplier": "' . $values['id_supplier'] . '"' . "\n\nUrsprüngliche Fehlermeldung: " . $e->getMessage(), __FILE__, __LINE__, __METHOD__);
         throw new Exception('Der gewählte Lieferant existiert nicht!');
     }
 }