Giter VIP home page Giter VIP logo

Comments (7)

clonemeagain avatar clonemeagain commented on September 26, 2024

Turns out the PDF was missing a constant.. fixed.

Still trying to decipher the attachments.. yay Does work now though.

from osticket-plugin-archiver.

cornernote avatar cornernote commented on September 26, 2024

This code seems to work for me, hope it helps.

class ArchiverPlugin extends Plugin {
    ...
    private function archive(Ticket $ticket) {
        ...
            // start dumping attachments:
            foreach ( $ticket->getThread ()->getEntries('') as $_entry ) {
                $entry = $ticket->getThread ()->getEntry($_entry['id']);
                foreach( $entry->getAttachments () as $a ){
                    $file = new AttachmentFile($a['attach_id']);
                    $this->copyFile ( $file, "$folder/attachment_{$a['name']}" );
                }
            }
        ...
    }
    ...
}

from osticket-plugin-archiver.

cornernote avatar cornernote commented on September 26, 2024

Also this line won't work like you expect, because slugify replaces / with -:

$folder = $path . @Format::slugify ( "/$dept/$user/{$ticket->getSubject ()}_{$ticket->getNumber ()}" );

Should be like this:

$folder = $path 
    . '/' . @Format::slugify ($dept);
    . '/' . @Format::slugify ($user);
    . '/' . @Format::slugify ("{$ticket->getSubject ()}_{$ticket->getNumber ()}");

from osticket-plugin-archiver.

cornernote avatar cornernote commented on September 26, 2024

While I'm here...

ArchiverPlugin::copyFile should wrap $file->open() in a try/catch to prevent an exception if the file can't be loaded (say you manually deleted some files before finding this plugin).

    private function copyFile(AttachmentFile $file, $dest) {
        try {
            $bk = $file->open ();
        } catch ( Exception $e ) {
            $this->log ( "Errors were encountered loading attachment" );
            return;
        }
        //  $bk = $file->open ();
        ...
    }

from osticket-plugin-archiver.

clonemeagain avatar clonemeagain commented on September 26, 2024

You up for a PR mate? Seem to know what you're doing.

from osticket-plugin-archiver.

cornernote avatar cornernote commented on September 26, 2024

In retrospect, probably would have been easier than dumping code into comments :)

from osticket-plugin-archiver.

cornernote avatar cornernote commented on September 26, 2024

p.s. I enjoyed your colourful comments throughout the code :)

from osticket-plugin-archiver.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.