Ejemplo n.º 1
0
 static function attachDownload($ticketid, $fileid, $for_user = false)
 {
     $ticket = new SupportTicket();
     if ($ticket->load($ticketid, $for_user)) {
         $attach = $ticket->getAttach($fileid);
         if (substr($attach->diskfile, 0, 7) == "http://" || substr($attach->diskfile, 0, 8) == "https://") {
             header('Location: ' . $attach->diskfile);
             exit;
         }
         $file = JPATH_SITE . DS . FSS_Settings::get('attach_location') . DS . "support" . DS . $attach->diskfile;
         $display_filename = FSS_Helper::basename($attach->filename);
         if (!$for_user) {
             $user = JFactory::GetUser($attach->user_id);
             $type = FSS_Settings::get('support_filename');
             switch ($type) {
                 case 1:
                     $display_filename = $user->username . "_" . $display_filename;
                     break;
                 case 2:
                     $display_filename = $user->username . "_" . date("Y-m-d") . "_" . $display_filename;
                     break;
                 case 3:
                     $display_filename = date("Y-m-d") . "_" . $user->username . "_" . $display_filename;
                     break;
                 case 4:
                     $display_filename = date("Y-m-d") . "_" . $display_filename;
                     break;
             }
         }
         require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'files.php';
         FSS_File_Helper::DownloadFile($file, $display_filename);
     }
     exit;
 }