[Rt-commit] rt 04/05: Prevent class change if name is taken in destination class

Jim Brandt jbrandt at bestpractical.com
Fri Jul 9 11:54:23 EDT 2021


This is an automated email from the git hooks/post-receive script.

jbrandt pushed a commit to branch 5.0/articles-unique-only-within-own-class2
in repository rt.

commit 6a164da8b4d38261316e9937c576d88df8ebc01f
Author: Jim Brandt <jbrandt at bestpractical.com>
AuthorDate: Fri Jul 9 11:41:13 2021 -0400

    Prevent class change if name is taken in destination class
---
 lib/RT/Article.pm | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lib/RT/Article.pm b/lib/RT/Article.pm
index 4ba5bb83eb..7782d89c33 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -510,6 +510,29 @@ sub _Set {
 
 }
 
+=head2 SetClass CLASS
+
+Set the class for this article.
+
+=cut
+
+sub SetClass {
+    my $self  = shift;
+    my $value = shift;
+
+    unless ( $self->CurrentUserHasRight('ModifyArticle') ) {
+        return ( 0, $self->loc("Permission Denied") );
+    }
+
+    # Confirm the name isn't already used in the destination class
+    if ( $self->ValidateName( $self->Name, $value ) ) {
+        return ( $self->_Set( Field => 'Class', Value => $value ) );
+    }
+    else {
+        return ( 0, $self->loc('Name in use in destination class') );
+    }
+}
+
 =head2 _Value PARAM
 
 Return "PARAM" for this object. if the current user doesn't have rights, returns undef

-- 
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.


More information about the rt-commit mailing list