Hi all!I have a php script that imports tickets from our old ticket system.The script includes "main.inc.php" and uses the function from Ticket class.The files I want to "connect" to the tickets and osTicket are on the same server.I have installed and activated this plugin: Storage :: Attachments on the Filesystem.I want to insert these file using the backend created by the plugin (F) but without upload files with a POST call (just giving the path).I was unable to find the right function from the classes contained in these file: class.attachments.php, class.file.php;can you suggest me the right function?osTicket version is 1.9.5.1Thanks!

Have you taken a look at /include/class.attachment.php?note: that's totally a guess.

Yes,in class.attachment.php file I found the GenericAttachments class that has a couple of useful methods: and .the function takes two parameters:(array) $files - it's an array of associative arrays with key "id" and "inline"(bool) $inline - I don't understand what "inline" means here but I have found it also in the ost_attachments table of the db.

The function it's quite the same but it takes only one file (with "id" and "inline").

I don't know how can I use these methods without an id.

Now i'm looking into include/class.file.php and maybe I've found the right function

So,in include/class.file.php I've found the method of the AttachmentFile class. This method create a record in the table with the default backend (in my case the one created from the Filesystem plugin).I've tried and it works but now, how can I attach this file to the ticket?the things I have are the file id and the ticket object.There is the method of the GenericAttachments class that could do what I want (partly) but I need to instanciate the object before I can use this method.The constructor take the "and but I don't know where I can get this informations

Ok, I resolved.After the insertion of the file in the database (ost_file table) with the method of the class I had to get a message of the ticket and then use the method of the class.here is the code:                 $file_path = "path/to/file.txt";                $finfo = new finfo(FILEINFO_MIME_TYPE);                $type = $finfo->file($file_path);                $info=array(                    'size' => filesize($file_path),                    'name' => basename($file_path),                    'data' => file_get_contents($file_path),                    'type' => $type                );                if(($file_id=AttachmentFile:($info))){                    $thread_id=$ticket->getMessages();                    ThreadEntry:($thread_id)->saveAttachment($file_id);                 }

Write a Reply...