/**
  * Functional point that deletes a document fax of the database, and deletes also the PDF document associated to the fax if exist
  *
  * @param   integer      $id        ID of the fax to be deleted
  * @return  boolean      true if the document fax was deleted, false if an error exists
  */
 function delFaxDoc($id)
 {
     if (!$this->_checkUserAuthorized('faxviewer')) {
         return false;
     }
     // Verificar presencia de ID del fax
     if (!isset($id) || !preg_match('/^\\d+$/', $id)) {
         $this->errMsg["fc"] = 'PARAMERROR';
         $this->errMsg["fm"] = 'Invalid ID';
         $this->errMsg["fd"] = 'Fax ID must be nonnegative integer';
         $this->errMsg["cn"] = get_class($this);
         return false;
     }
     $id = (int) $id;
     //obtenemos las credenciales del usuario
     $arrCredentials = getUserCredentials();
     // Borrar el registro y el documento de fax, dado su ID
     $oFax = new paloFaxVisor();
     $bExito = $oFax->deleteInfoFax($id, $arrCredentials["id_organization"]);
     if (!$bExito) {
         $this->errMsg["fm"] = 'Database operation failed';
         $this->errMsg["cn"] = get_class($oFax);
         if ($oFax->errMsg != '') {
             $this->errMsg["fc"] = 'DBERROR';
             $this->errMsg["fd"] = 'Unable to delete fax information - ' . $oFax->errMsg;
         } else {
             $this->errMsg["fc"] = 'INTERNALERROR';
             $this->errMsg["fd"] = 'Unable to delete fax document';
         }
     }
     return $bExito;
 }
Esempio n. 2
0
function download_faxFile()
{
    $oFax = new paloFaxVisor();
    $idFax = getParameter("id");
    $arrFax = $oFax->obtener_fax($idFax);
    $dir_backup = "/var/www/faxes";
    $file_path = $arrFax['faxpath'] . "/fax.pdf";
    $file_name = $arrFax['pdf_file'];
    if (!file_exists("{$dir_backup}/{$file_path}")) {
        header('HTTP/1.1 404 Not Found');
        return "File {$file_path} not found!";
    } else {
        header("Cache-Control: private");
        header("Pragma: cache");
        header('Content-Type: application/pdf');
        header("Content-Length: " . filesize("{$dir_backup}/{$file_path}"));
        header("Content-disposition: attachment; filename={$file_name}");
        readfile("{$dir_backup}/{$file_path}");
    }
}
Esempio n. 3
0
function delete_faxFile($smarty, $module_name, $local_templates_dir, $pDB, $credentials)
{
    $oFax = new paloFaxVisor($pDB);
    $id_organization = null;
    if ($credentials['userlevel'] != 'superadmin') {
        $id_organization = $credentials['id_organization'];
    }
    // Ejecutar el borrado, si se ha validado.
    if (is_array($_POST['faxes']) && count($_POST['faxes']) > 0) {
        $msgError = NULL;
        foreach ($_POST['faxes'] as $idFax) {
            if (!$oFax->deleteInfoFax($idFax, $id_organization)) {
                if ($oFax->errMsg = '') {
                    $msgError = _tr('Unable to eliminate pdf file from the path.');
                } else {
                    $msgError = _tr('Unable to eliminate pdf file from the database.') . ' - ' . $oFax->errMsg;
                }
            }
        }
        if (!is_null($msgError)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oFax->errMsg));
        }
    } else {
        $smarty->assign("mb_title", _tr('ERROR'));
        $smarty->assign("mb_message", _tr('You must select at least one fax'));
    }
    return listarFaxes($smarty, $module_name, $local_templates_dir, $pDB, $credentials);
}