X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FAdmin%2FElements%2FSelectScripCondition;h=e895c9425f4c2349855f6a6c0db69c01ef543140;hb=b8988e1d3ac75af63c85e8563e57701030315a9e;hp=b1dc5b0ddc440a23b7bbfe063ee5591371aa02df;hpb=fc6209f398899f0211cfcedeb81a3cd65e04a941;p=freeside.git

diff --git a/rt/share/html/Admin/Elements/SelectScripCondition b/rt/share/html/Admin/Elements/SelectScripCondition
index b1dc5b0dd..e895c9425 100755
--- a/rt/share/html/Admin/Elements/SelectScripCondition
+++ b/rt/share/html/Admin/Elements/SelectScripCondition
@@ -2,7 +2,7 @@
 %#
 %# COPYRIGHT:
 %#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
 %#                                          <sales@bestpractical.com>
 %#
 %# (Except where explicitly superseded by other copyright notices)
@@ -45,7 +45,10 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<select name="<%$Name%>">
+<select name="<%$Name%>"
+onchange="var idobj = document.getElementsByName('id')[0]; 
+if (idobj.value=='new') idobj.value = '';
+form.submit()">
 <option value="" 
 <% ! defined $Default && qq[ selected="selected"] %>
 >-</option>
@@ -59,9 +62,19 @@
 
 <%INIT>
 my $ScripConditions = RT::ScripConditions->new($session{'CurrentUser'});
-$ScripConditions->UnLimit;
-$ScripConditions->OrderBy(FIELD => 'Name');
 
+# hide user-defined if the user can't execute code
+if ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode')) {
+    $ScripConditions->UnLimit;
+} else {
+    $ScripConditions->Limit(
+        FIELD    => 'ExecModule',
+        OPERATOR => '!=',
+        VALUE    => 'UserDefined',
+    );
+}
+
+$ScripConditions->OrderBy(FIELD => 'Name');
 
 </%INIT>
 <%ARGS>