Comments (7)
Turns out the PDF was missing a constant.. fixed.
Still trying to decipher the attachments.. yay Does work now though.
from osticket-plugin-archiver.
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.
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.
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.
You up for a PR mate? Seem to know what you're doing.
from osticket-plugin-archiver.
In retrospect, probably would have been easier than dumping code into comments :)
from osticket-plugin-archiver.
p.s. I enjoyed your colourful comments throughout the code :)
from osticket-plugin-archiver.
Related Issues (19)
- Polish Readme HOT 1
- Importer
- Logo missing from PDF HOT 3
- Option to just purge old tickets
- In 1.9.12 Internal Server Error HOT 2
- time of purge HOT 6
- Error after installing plugin HOT 9
- Please use tags for releases to identify compatible osTicket version.
- Plugin not working
- Call to undefined method QuerySet::getAttachments
- is still working? HOT 1
- PHP Parse error for folder path in Advanced mode
- Version 1.14.1 HOT 2
- osTicket 1.15 HOT 1
- All data is not cleaned up
- Change status to Archived without changing the Closure Date value HOT 1
- Is there a way to Manually run this plug-in?
- Compatible with 1.17.2?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osticket-plugin-archiver.