function getImage($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentiasls) { $pACL = new paloACL($pDB); $imgDefault = $_SERVER['DOCUMENT_ROOT'] . "/admin/web/apps/{$module_name}/images/Icon-user.png"; $id_user = getParameter("ID"); $picture = false; if ($arrCredentiasls["userlevel"] == "superadmin") { $picture = $pACL->getUserPicture($id_user); } else { //verificamos que el usario pertenezca a la organizacion if ($pACL->userBellowOrganization($id_user, $arrCredentiasls["id_organization"])) { $picture = $pACL->getUserPicture($id_user); } } // Creamos la imagen a partir de un fichero existente if ($picture != false && !empty($picture["picture_type"])) { Header("Content-type: {$picture["picture_type"]}"); print $picture["picture_content"]; } else { Header("Content-type: image/png"); $im = file_get_contents($imgDefault); echo $im; } return; }
function download_faxFile($pDB, $credentials) { $pACL = new paloACL($pDB); $oFax = new paloFaxVisor($pDB); $idFax = getParameter("id"); $arrFax = $oFax->obtener_fax($idFax); if ($arrFax == false) { header('HTTP/1.1 404 Not Found'); return "File {$file_path} not found!"; } $dir_backup = "/var/www/elastixdir/faxdocs"; $file_path = $arrFax['faxpath'] . "/fax.pdf"; $file_name = $arrFax['pdf_file']; if ($credentials['userlevel'] != 'superadmin') { if (!$pACL->userBellowOrganization($arrFax["id_user"], $credentials['id_organization'])) { header('HTTP/1.1 404 Not Found'); return "File {$file_path} not found!"; } } 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}"); } }