system/modules/DocumentManagementSystem/modules/ModuleDmsManagement.php
private function manageDeleteDocument(&$params, &$dmsLoader, &$manageCategory, &$arrMessages, &$blnShowStart, $documentId)
  {
    $params->loadRootCategory = true; // get complete path to root, for checking inherited access rights
    $params->loadAccessRights = true;
    $params->loadDocuments = false;
    $category = $dmsLoader->loadCategory($manageCategory, $params);
    
    if (!$category->isDeletableForCurrentMember())
    {
      $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_allowed'];
      $blnShowStart = true;
    }
    else
    {
      $document = $dmsLoader->loadDocument($documentId, $params);
      
      if ($document != null)
      {
        // delete the document in the database
        $dmsWriter = \DmsWriter::getInstance();
        
        if ($dmsWriter->deleteDocument($document))
        {
          $arrMessages['successes'][] = $GLOBALS['TL_LANG']['DMS']['SUCCESS']['document_successfully_deleted'];
          
          // delete the file
          $filePath = \DmsConfig::getDocumentFilePath($document->getFileNameVersioned());
          if (file_exists(TL_ROOT . '/' . $filePath))
          {
            unlink($filePath);
            \Dbafs::deleteResource($filePath);
            
            $arrMessages['successes'][] = $GLOBALS['TL_LANG']['DMS']['SUCCESS']['document_file_successfully_deleted'];
          }
          else
          {
            $arrMessages['infos'][] = $GLOBALS['TL_LANG']['DMS']['INFO']['document_delete_file_not_exists'];
          }
        }
        else
        {
          $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['delete_document_failed'];
        }
      }
      else
      {
        $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_found'];
      }
      $this->manageSelectDocument($params, $dmsLoader, $manageCategory, $arrMessages, $blnShowStart);
    }
  }
private function manageDeleteDocument(&$params, &$dmsLoader, &$manageCategory, &$arrMessages, &$blnShowStart, $documentId)
  {
    $params->loadRootCategory = true; // get complete path to root, for checking inherited access rights
    $params->loadAccessRights = true;
    $params->loadDocuments = false;
    $category = $dmsLoader->loadCategory($manageCategory, $params);
    
    if (!$category->isDeletableForCurrentMember())
    {
      $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_allowed'];
      $blnShowStart = true;
    }
    else
    {
      $document = $dmsLoader->loadDocument($documentId, $params);
      
      if ($document != null)
      {
        // delete the document in the database
        $dmsWriter = \DmsWriter::getInstance();
        
        if ($dmsWriter->deleteDocument($document))
        {
          $arrMessages['successes'][] = $GLOBALS['TL_LANG']['DMS']['SUCCESS']['document_successfully_deleted'];
          
          // delete the file
          $filePath = \DmsConfig::getDocumentFilePath($document->getFileNameVersioned());
          if (file_exists(TL_ROOT . '/' . $filePath))
          {
            unlink($filePath);
            \Dbafs::deleteResource($filePath);
            
            $arrMessages['successes'][] = $GLOBALS['TL_LANG']['DMS']['SUCCESS']['document_file_successfully_deleted'];
          }
          else
          {
            $arrMessages['infos'][] = $GLOBALS['TL_LANG']['DMS']['INFO']['document_delete_file_not_exists'];
          }
        }
        else
        {
          $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['delete_document_failed'];
        }
      }
      else
      {
        $arrMessages['errors'][] = $GLOBALS['TL_LANG']['DMS']['ERR']['manage_document_not_found'];
      }
      $this->manageSelectDocument($params, $dmsLoader, $manageCategory, $arrMessages, $blnShowStart);
    }
  }
private function manageDeleteDocument ( & $ params , & $ dmsLoader , & $ manageCategory , & $ arrMessages , & $ blnShowStart , $ documentId ) { $ params -> loadRootCategory = true ; // get complete path to root, for checking inherited access rights $ params -> loadAccessRights = true ; $ params -> loadDocuments = false ; $ category = $ dmsLoader -> loadCategory ( $ manageCategory , $ params ) ; if ( ! $ category -> isDeletableForCurrentMember ( ) ) { $ arrMessages [ 'errors' ] [ ] = $ GLOBALS [ 'TL_LANG' ] [ 'DMS' ] [ 'ERR' ] [ 'manage_document_not_allowed' ] ; $ blnShowStart = true ; } else { $ document = $ dmsLoader -> loadDocument ( $ documentId , $ params ) ; if ( $ document != null ) { // delete the document in the database $ dmsWriter = \ DmsWriter :: getInstance ( ) ; if ( $ dmsWriter -> deleteDocument ( $ document ) ) { $ arrMessages [ 'successes' ] [ ] = $ GLOBALS [ 'TL_LANG' ] [ 'DMS' ] [ 'SUCCESS' ] [ 'document_successfully_deleted' ] ; // delete the file $ filePath = \ DmsConfig :: getDocumentFilePath ( $ document -> getFileNameVersioned ( ) ) ; if ( file_exists ( TL_ROOT . '/' . $ filePath ) ) { unlink ( $ filePath ) ; \ Dbafs :: deleteResource ( $ filePath ) ; $ arrMessages [ 'successes' ] [ ] = $ GLOBALS [ 'TL_LANG' ] [ 'DMS' ] [ 'SUCCESS' ] [ 'document_file_successfully_deleted' ] ; } else { $ arrMessages [ 'infos' ] [ ] = $ GLOBALS [ 'TL_LANG' ] [ 'DMS' ] [ 'INFO' ] [ 'document_delete_file_not_exists' ] ; } } else { $ arrMessages [ 'errors' ] [ ] = $ GLOBALS [ 'TL_LANG' ] [ 'DMS' ] [ 'ERR' ] [ 'delete_document_failed' ] ; } } else { $ arrMessages [ 'errors' ] [ ] = $ GLOBALS [ 'TL_LANG' ] [ 'DMS' ] [ 'ERR' ] [ 'manage_document_not_found' ] ; } $ this -> manageSelectDocument ( $ params , $ dmsLoader , $ manageCategory , $ arrMessages , $ blnShowStart ) ; } }
Execute unpublishing documents
Execute unpublishing documents