https://rt-wiki.bestpractical.com/index.php?title=AddSquelchedCc&feed=atom&action=history
AddSquelchedCc - Revision history
2024-03-29T08:30:40Z
Revision history for this page on the wiki
MediaWiki 1.37.2
https://rt-wiki.bestpractical.com/index.php?title=AddSquelchedCc&diff=26347&oldid=prev
Tharn at 00:49, 14 August 2016
2016-08-14T00:49:13Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 20:49, 13 August 2016</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l9">Line 9:</td>
<td colspan="2" class="diff-lineno">Line 9:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Usage: - Create a group starting with "TEAM_", add people to the group (if you need unprivileged member, select the user and click "memberships") - Run the following script</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Usage: - Create a group starting with "TEAM_", add people to the group (if you need unprivileged member, select the user and click "memberships") - Run the following script</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> <<del style="font-weight: bold; text-decoration: none;">nowiki</del>>#!/usr/bin/perl</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> <<ins style="font-weight: bold; text-decoration: none;">pre</ins>></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>#!/usr/bin/perl</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # Name: AddSquelchedCc.pl</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # Name: AddSquelchedCc.pl</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l85">Line 85:</td>
<td colspan="2" class="diff-lineno">Line 86:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> </del></<del style="font-weight: bold; text-decoration: none;">nowiki</del>></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></<ins style="font-weight: bold; text-decoration: none;">pre</ins>></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Scrip for new tickets =</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>= Scrip for new tickets =</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l106">Line 106:</td>
<td colspan="2" class="diff-lineno">Line 107:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Custom action preparation code<del style="font-weight: bold; text-decoration: none;">:</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">=== </ins>Custom action preparation code <ins style="font-weight: bold; text-decoration: none;">===</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"><pre></ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> my $ticket = $self-&gt;TicketObj;</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> my $ticket = $self-&gt;TicketObj;</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l132">Line 132:</td>
<td colspan="2" class="diff-lineno">Line 134:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></pre></ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Custom action cleanup code:</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Custom action cleanup code:</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td></tr>
<!-- diff cache key bestpractical_mediawiki1459887241:diff::1.12:old-72:rev-26347 -->
</table>
Tharn
https://rt-wiki.bestpractical.com/index.php?title=AddSquelchedCc&diff=72&oldid=prev
Admin: 2 revisions imported
2016-04-06T20:03:12Z
<p>2 revisions imported</p>
<p><b>New page</b></p><div>= Introduction =<br />
<br />
This script adds team members as watchers on a ticket, but squelch them (they'll not receive updates unless they are explicetely defined as requestors or cc or owners). When one of them creates a ticket, all the other will have access (you need to set at least [[ShowTicket]] right to "Cc". I'd recommend setting [[ShowTicket]] and [[ReplyToTicket]] to Cc and Requestors.<br />
<br />
There are a script and a scrip. The script is to apply this behavior on all the tickets already created, the scrip is for the new tickets.<br />
<br />
= Script for tickets already created =<br />
<br />
Usage: - Create a group starting with "TEAM_", add people to the group (if you need unprivileged member, select the user and click "memberships") - Run the following script<br />
<br />
<nowiki>#!/usr/bin/perl<br />
<br />
# Name: AddSquelchedCc.pl<br />
#<br />
# Description:<br />
# This script adds team members as watchers on a ticket, but squelch them<br />
# (they'll not receive updates unless they are explicetely defined as<br />
# requestors or cc or owners).<br />
# When one of them creates a ticket, all the other will have access (you<br />
# need to set at least ShowTicket right to "Cc".<br />
# I'd recommend setting ShowTicket and ReplyToTicket to Cc and Requestors.<br />
#<br />
# Usage:<br />
# - Create a group starting with "TEAM_", add people to the group<br />
# (if you need unprivileged member, select the user and click "memberships")<br />
# - Run the script<br />
<br />
# Author: &lt;Christophe.Sahut {at} sgs {dot} com&gt;<br />
# License: This module is free software; you can redistribute it<br />
# and/or modify it under the GPLv2 licence.<br />
<br />
<br />
use warnings;<br />
use strict;<br />
use lib qw(/opt/rt/lib);<br />
use RT;<br />
use RT::Users;<br />
use RT::User;<br />
use RT::Tickets;<br />
use RT::Ticket;<br />
use RT::Groups;<br />
<br />
RT::LoadConfig();<br />
RT::Init();<br />
<br />
my $return;<br />
my $message = "";<br />
my $ticket = RT::Ticket-&gt;new($RT::SystemUser);<br />
<br />
my $tickets = RT::Tickets-&gt;new($RT::SystemUser);<br />
$tickets-&gt;UnLimit();<br />
#$tickets-&gt;LimitId(OPERATOR=&gt;'&gt;',VALUE=&gt;'15000');<br />
##$tickets-&gt;LimitStatus(VALUE=&gt;'open');<br />
<br />
while (my $ticket = $tickets-&gt;Next()) {<br />
<br />
print "== Working on ticket ".$ticket-&gt;Id." ==\n";<br />
<br />
my $groups = RT::Groups-&gt;new($RT::SystemUser);<br />
$groups-&gt;LimitToUserDefinedGroups();<br />
<br />
while (my $group = $groups-&gt;Next()) {<br />
next unless $group-&gt;Name =~ /^TEAM_/;<br />
if($group-&gt;HasMemberRecursively($ticket-&gt;Creator)){<br />
print "Creator found in ".$group-&gt;Name."\n";<br />
($return,$message)=$ticket-&gt;AddWatcher(Type=&gt;"Cc",PrincipalId=&gt;$group-&gt;Id);<br />
print "Adding ".$group-&gt;Name." as a Cc Watcher (".$message.")\n";<br />
<br />
foreach my $email($group-&gt;MemberEmailAddresses){<br />
if($email) {<br />
my $user = RT::User-&gt;new(RT-&gt;SystemUser);<br />
$user-&gt;LoadByEmail($email);<br />
<br />
# Don't squelch these users<br />
next if $ticket-&gt;IsRequestor($user-&gt;Id) or<br />
$ticket-&gt;IsCc($user-&gt;Id) or<br />
$ticket-&gt;IsOwner($user);<br />
<br />
$ticket-&gt;SquelchMailTo($email);<br />
print "Squelching ".$email."\n";<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
</nowiki><br />
<br />
= Scrip for new tickets =<br />
<br />
* Create a new scrip, on your incoming queue for example :<br />
<br />
Description: [[AddSquelchedCc]]<br />
<br />
Condition: [[OnCreate]]<br />
<br />
Action: User Defined<br />
<br />
Template: Global Template: blank<br />
<br />
Stage: [[TransactionCreate]]<br />
<br />
Custom condition:<br />
<br />
return 1;<br />
<br />
<br />
Custom action preparation code:<br />
<br />
my $ticket = $self-&gt;TicketObj;<br />
<br />
my $groups = RT::Groups-&gt;new($RT::SystemUser);<br />
$groups-&gt;LimitToUserDefinedGroups();<br />
<br />
while (my $group = $groups-&gt;Next()) {<br />
next unless $group-&gt;Name =~ /^TEAM_/;<br />
if($group-&gt;HasMemberRecursively($ticket-&gt;Creator)){<br />
$ticket-&gt;AddWatcher(Type=&gt;"Cc",PrincipalId=&gt;$group-&gt;Id);<br />
foreach my $email($group-&gt;MemberEmailAddresses){<br />
if($email) {<br />
my $user = RT::User-&gt;new(RT-&gt;SystemUser);<br />
$user-&gt;LoadByEmail($email);<br />
# Don't squelch these users<br />
next if $ticket-&gt;IsRequestor($user-&gt;Id) or<br />
$ticket-&gt;IsCc($user-&gt;Id) or<br />
$ticket-&gt;IsOwner($user);<br />
$ticket-&gt;SquelchMailTo($email);<br />
}<br />
}<br />
}<br />
}<br />
return 1;<br />
<br />
<br />
Custom action cleanup code:<br />
<br />
return 1;</div>
Admin