Esempio n. 1
0
 /**
  * @see ProjectItemInterface::unlink_item_full()
  * @return bool
  * @throws ProjectItemUnlinkException
  */
 public function unlink_item_full()
 {
     global $transaction;
     if ($this->item_id) {
         $transaction_id = $transaction->begin();
         if (Project_Wrapper::delete_data_entity_sub_item_links($this->item_id) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new ProjectItemUnlinkException(true, "Data-Entity Sub-Item delete failed");
         }
         if (ProjectHasItem_Access::delete_sub_items($this->item_id) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new ProjectItemUnlinkException(true, "Sub-Item delete failed");
         }
         $project_has_item_pk_array = ProjectHasItem_Access::list_entries_by_item_id($this->item_id);
         if (is_array($project_has_item_pk_array)) {
             if (count($project_has_item_pk_array) >= 1) {
                 foreach ($project_has_item_pk_array as $key => $value) {
                     $project_has_item = new ProjectHasItem_Access($value);
                     if ($project_has_item->delete() == false) {
                         if ($transaction_id != null) {
                             $transaction->rollback($transaction_id);
                         }
                         throw new ProjectItemUnlinkExecption(true, "Database delete failed");
                     }
                 }
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             } else {
                 return true;
             }
         } else {
             throw new ProjectItemUnlinkExecption(false, "Item not linked");
         }
     } else {
         throw new ProjectItemUnlinkExecption();
     }
 }