Help Desk Software & Beyond
May 17, 2012, 05:41:11 AM *
Welcome, Guest. Please login or register.
To post messages you need to register. We apologize for inconvenience, but this is to prevent spam.
Registration is instant (no email verification) and we do not ask for any personal information.

Login with username, password and session length
News: Welcome to Help Desk Software forum!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [REQ] File Attachment Deletion (delete file attachments on tickets)  (Read 544 times)
bjray
Newbie
*

Karma: 3
Posts: 25


View Profile
« on: August 03, 2011, 10:40:19 AM »

Need some help on modifying the trouble ticket system.

I am in need of adding the ability for operators with ME privileges to delete file attachments on tickets.

I have been able to generate a link (a href) when there is an attachment on a ticket.

I have added a new sub routine to TTXFile.pm for deletion of one file.

Here is what I have code wise, and I'll show the error/issue I am getting/having. Any help is appreciated!

In ticket.html -->
Quote
function delfile(FID){
 if (confirm("[%Please confirm file attachment deletion%]")) {
   msg = document.newticket.problem.value;
   window.location.href = "(%ENV_SCRIPT_NAME%)?cmd=delfile&fid="+FID;
 }
}

In TTXTicket.pm -->
Quote
    for (my $i=1; $i < 10; ++$i) {
      if ($header{"FILE$i"} ne undef) {
        if ($firstfile) {
          $body .= '<br class=sm><br class=sm>[%Files%]:<br>'."\n";
          $firstfile = 0;
        }
        $header{"FILE$i"} =~ s/CGIURL/$ENV{SCRIPT_NAME}/;
        $body .= $header{"FILE$i"} . "<br>\n";
        if($header{"FILE$i"} =~ /(fid=\d*-\d*-\d*-\d*)/i){
            $fid = substr($1, 4);
      }
      $body .= "<a href='".$cfg->get('scriptname')."?cmd=delfile&fid=".$fid."' onclick='return delfile(".$fid.")'>delete attachment</a><br>\n"; #added by BJR --> this will be file attachment link for deletion!
      }
    }

In ttx.cgi -->
Quote
#File Attachment Deletion
 delfile => { action => 'TTXFile::delfile', access => 1, noheader => 1 },

In TTXFile.pm -->
Quote
sub delfile {
  my $fid = shift.'.dat';
  my $dir = TTXData::get('CONFIG')->get('basedir').'/files';
  if(($fid !~ /(\d*-\d*-\d*-\d*).dat/) || (!open(F, "$dir/$fid"))) {
    fatalerror("File not found: ".$fid);
  }else{
   unlink "$dir/$fid";
  }
}

The error appears to come when passing the file id from the javascript function (found in ticket.html --see above) into the sub routine delfile (found in TTXFile --see above).

When I run it directly (ie: http://ticketsystem/ttx.cgi?cmd=delfile&fid=1881-1312380452-1-380644 ) I receive:
Fatal Error: File not found: TTXConfig=HASH(0x1c23290).dat

Now, if I manually define the $fid (in TTXFile.pm) as: my $fid = 1881-1312380452-1-380644 (instead of: my $fid = shift.'.dat'; -->as found above);
The file will delete with no problem.

I have one more issue that pertains to this, but one at a time I suppose.

Any insight would be greatly appreciated!!

Thanks,
Brandon
« Last Edit: August 03, 2011, 10:44:18 AM by Sparky » Logged
Sparky
Moderator
Hero Member
*****

Karma: 83
Posts: 2,228


stop pushing all those buttons


View Profile
« Reply #1 on: August 03, 2011, 10:47:59 AM »

I can't help much as I have no time right now to collaborate.  I planned on doing something similar myself but my hosting account now has "unlimited" hard drive space.

Keep going, walk away, come back, you'll get it working eventually.   It took me many weeks to get my Ticket Merge module working reliably.
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
bjray
Newbie
*

Karma: 3
Posts: 25


View Profile
« Reply #2 on: August 05, 2011, 10:21:29 AM »

Thanks for the encouragement  Smiley I took a day away and bam I got it all working.
It Might not be the most prudent or ingenious install, but it works how I thought it should.
Till next time.
Logged
Sparky
Moderator
Hero Member
*****

Karma: 83
Posts: 2,228


stop pushing all those buttons


View Profile
« Reply #3 on: August 05, 2011, 10:30:16 AM »

When you get a chance, please share it here by starting a new [MOD] thread.  Thank-you!
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
bjray
Newbie
*

Karma: 3
Posts: 25


View Profile
« Reply #4 on: August 09, 2011, 03:33:27 PM »

Please see thread:
http://forum.unitedwebcoders.com/index.php/topic,1260.0.html
Logged
Sparky
Moderator
Hero Member
*****

Karma: 83
Posts: 2,228


stop pushing all those buttons


View Profile
« Reply #5 on: August 09, 2011, 03:38:08 PM »

This is now indexed as TTX Modification #46...

http://forum.unitedwebcoders.com/index.php/topic,737.0.html
Logged

Did you update the paths in ttxcfg.cgi after moving TTX to your new location?   Undecided
To those seeking help.... please report back when you figure it out.  Cheesy
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC3 | SMF © 2001-2006, Lewis Media Valid XHTML 1.0! Valid CSS!
Page created in 0.025 seconds with 18 queries.