/**
  * @brief Delete this element
  *
  * @note    This function overrides the same-named function from the parent class
  *          because we have to check if this element has no parts included.
  *          (It's not allowed to delete an element which has already parts in it!)
  *
  * @param boolean $delete_recursive         @li if true, all child elements (recursive) will be deleted too (!!)
  *                                          @li if false, the parent of the child nodes (not recursive) will be
  *                                              changed to the parent element of this element
  * @param boolean $delete_files_from_hdd    if true, all attached files of this element will be deleted from harddisc drive (!!)
  *
  * @throws Exception if there are already parts included in this element
  * @throws Exception if there was an error
  */
 public function delete($delete_recursive = false, $delete_files_from_hdd = false)
 {
     try {
         $transaction_id = $this->database->begin_transaction();
         // start transaction
         $parts = $this->get_parts();
         if (count($parts) > 0) {
             throw new Exception('Das Element enthält noch ' . count($parts) . ' Bauteile!');
         }
         parent::delete($delete_recursive, $delete_files_from_hdd);
         $this->database->commit($transaction_id);
         // commit transaction
     } catch (Exception $e) {
         $this->database->rollback();
         // rollback transaction
         // restore the settings from BEFORE the transaction
         $this->reset_attributes();
         throw new Exception("Das Element \"" . $this->get_name() . "\" konnte nicht gelöscht werden!\nGrund: " . $e->getMessage());
     }
 }
 /**
  * @brief Create a new attachement type
  *
  * @param Database  &$database          reference to the database onject
  * @param User      &$current_user      reference to the current user which is logged in
  * @param Log       &$log               reference to the Log-object
  * @param string    $name               the name of the new attachement type (see AttachementType::set_name())
  * @param integer   $parent_id          the parent ID of the new attachement type (see AttachementType::set_parent_id())
  *
  * @retval AttachementType      the new attachement type
  *
  * @throws Exception    if (this combination of) values is not valid
  * @throws Exception    if there was an error
  *
  * @see DBElement::add()
  */
 public static function add(&$database, &$current_user, &$log, $name, $parent_id)
 {
     return parent::add($database, $current_user, $log, 'attachement_types', array('name' => $name, 'parent_id' => $parent_id));
 }
Esempio n. 3
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);
     // TODO
 }