Re: [rt-users] Scrip question

2007-04-10 Thread Karen Nyenhuis
Have you tried setting the scrip stage to TransactionBatch?   The scrip 
will then get triggered only once after all transactions have been 
generated.  You then have to iterate over all the transactions to look 
for your condition.  There is an example in the RT Essentials book.

Stephen Turner wrote:
  

> Also, there's a potential trap you can get caught in when updating
> ticket fields in scrips - if the update that fires the scrip is
> triggered from a ticket update screen, the value that is shown on the
> screen when the submit button is pressed can override your scrip update.
> For example, if your ticket is open, you make an update to a custom
> field, and this triggers a scrip that, in custom code, changes the
> status to 'stalled', the sequence of events that take place may set the
> ticket back to what it was on the screen (ie open). I haven't found a
> way round this one -



This just bit me today. I have a scrip that changes a custom field on
owner change. When user gives away a ticket from /Ticket/Modify.html,
there's also the current value of said custom field selected.

What happens is that the scrip changes the value of the custom field
just to have it set back in the next transaction.

This of course doesn't happen if I change the owner in the
ModifyPeople.html, but I don't think I am able to educate my users...

I really hope there is a solution to this that does not involve
modifying RT. If not, I'll just disable the owner update from
Modify.html. But that is, to put it mildly, crude.

Any ideas?

regards,
Borut Mrak.

  

___
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com


Re: [rt-users] Large attachments - how to warn user before dropped

2007-01-25 Thread Karen Nyenhuis




Thanks Eric for all your help.  Worked great.

Karen

Schultz, Eric wrote:

  

  I would like to warn the user before dropping a large 
  

attachment and 


  give them the opportunity to make a different selection.
I saw this in an earlier email (dated 2006-02-24 from Eric Shultz 
"TruncateLongAttachments .."), where he had modified the RT 
code to do 
just that.  I've been attempting to do the same thing in 
  

Update.html, 


  but failing.  I can't seem to determine the filesize with the 
information at hand.  Can anyone point me in the right 
direction?  Or is 
Update.html not the place to be making these changes?
  

Hi Karen.  Unfortunately, I've made a bunch of other changes to the
3.4.x code, so I can't easily provide you with just a simple patch.
What I can provide is the code I added for this 
functionality, however,
and at about what point in the file share/html/Ticket/Update.html.
Note, however, that I did not set TruncateLongAttachments in
RT_SiteConfig.pm, I set DropLongAttachments to 1.  Here are 
my changes:

#1:
---
  <& /Ticket/Elements/Tabs,
  Ticket => $TicketObj,
  Title=> $title &>

+ <& /Elements/ListActions, actions => [EMAIL PROTECTED] &>
+
  
  
---

#2:
---
  <%INIT>
  my $CanRespond = 0;
  my $CanComment = 0;
  my $title;
+ my @Actions;

  my $TicketObj = LoadTicket($id);

---

#3:
---
  $session{'Attachments'} = { %{$session{'Attachments'} || {}},
$ARGS{'Attach'} => $attachment };
+
+ my $latest_attach = $ARGS{'Attach'};
+
+ # Check the length of all attachments put together, compensating
+ # for encoding overhead (* .75) like is done elsewhere in the
code.
+ my $total_length = 0;
+ foreach my $key (keys %{$session{'Attachments'}}) {
+   my $length = length(
${$session{'Attachments'}}{$key}->stringify_body );
+ $total_length += int($length * .75 / 1024);
+ }
+
+ # If the total of all attachments exceeds the RT config 
parameter,
+ # and we're told to drop long attachments, drop all of them.
+ # But still allow a message update.
+ my $maxsize = int($RT::MaxAttachmentSize * .75 / 1024);
+ if ($total_length > $maxsize and $RT::DropLongAttachments) {
+   $RT::Logger->warning( "Exceeded maximum attachment size. Total
length: ${total_length}k (max: ${maxsize}k)" );
+   push( @Actions, "Attachment '$latest_attach' not 
uploaded: total
size of all attachments (${total_length}k) would exceed limit
(${maxsize}k)" );
+   delete ${$session{'Attachments'}}{$latest_attach};  # remove
only the latest one that tipped the scales
+ delete $ARGS{SubmitTicket};  # don't go to the Display.html
page
+ }
  }
  # }}}

  # delete temporary storage entry to make WebUI clean
  unless (keys %{$session{'Attachments'}} and $ARGS{'UpdateAttach'}) {
  delete $session{'Attachments'};
---


Let me know how that works for you.

Eric Schultz
United Online, Inc.

  
  

I neglected to mention that I also do pretty much the same thing in
Create.html, so people can't make a ticket with too large of an
attachment.  The only difference is I have a commitme flag:

my $commitme = 1;

If the $total_length exceeds $maxsize, I set $commitme = 0, then later I
have this:

if ( $commitme and (!exists $ARGS{'AddMoreAttach'}) && ($ARGS{'id'} eq
'new')) {

So I don't go to Display.html yet (giving them another opportunity to
attach something smaller).


Eric Schultz
United Online, Inc.

  



___
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

[rt-users] Large attachments - how to warn user before dropped

2007-01-24 Thread Karen Nyenhuis
I would like to warn the user before dropping a large attachment and 
give them the opportunity to make a different selection.
I saw this in an earlier email (dated 2006-02-24 from Eric Shultz 
"TruncateLongAttachments .."), where he had modified the RT code to do 
just that.  I've been attempting to do the same thing in Update.html, 
but failing.  I can't seem to determine the filesize with the 
information at hand.  Can anyone point me in the right direction?  Or is 
Update.html not the place to be making these changes?


We're using RT3.4.4

Karen Nyenhuis

___
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com