[Rt-commit] rt branch, 4.4/disabled-articles, created. rt-4.2.9-115-gb89f38b

? sunnavy sunnavy at bestpractical.com
Mon Jan 12 10:23:46 EST 2015


The branch, 4.4/disabled-articles has been created
        at  b89f38bdea056114555e253007045dfec484ae76 (commit)

- Log -----------------------------------------------------------------
commit d8b38823d024f103f53dfb09706ad5938efa4efd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jan 12 14:37:13 2015 +0800

    fix description since "ModifyArticle" right can't _delete_ articles
    
    we have "DeleteArticle" for that instead

diff --git a/lib/RT/Class.pm b/lib/RT/Class.pm
index 01c0d79..ec8eb82 100644
--- a/lib/RT/Class.pm
+++ b/lib/RT/Class.pm
@@ -89,7 +89,7 @@ __PACKAGE__->AddRight( Staff   => CreateArticle       => 'Create articles in thi
 __PACKAGE__->AddRight( General => ShowArticle         => 'See articles in this class'); # loc
 __PACKAGE__->AddRight( Staff   => ShowArticleHistory  => 'See changes to articles in this class'); # loc
 __PACKAGE__->AddRight( General => SeeCustomField      => 'View custom field values' ); # loc
-__PACKAGE__->AddRight( Staff   => ModifyArticle       => 'Modify or delete articles in this class'); # loc
+__PACKAGE__->AddRight( Staff   => ModifyArticle       => 'Modify articles in this class'); # loc
 __PACKAGE__->AddRight( Staff   => ModifyArticleTopics => 'Modify topics for articles in this class'); # loc
 __PACKAGE__->AddRight( Staff   => ModifyCustomField   => 'Modify custom field values' ); # loc
 __PACKAGE__->AddRight( Admin   => AdminClass          => 'Modify metadata and custom fields for this class'); # loc

commit 527aaf055221fb6bb8f001ec078bde7d612a7867
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jan 12 14:39:31 2015 +0800

    don't delete articles, just disable them.
    
    Fixes: I#19323

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 2a0849b..cc623e8 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -444,6 +444,7 @@ SortOrder NUMBER(11,0) DEFAULT 0 NOT NULL,
 Class NUMBER(11,0) DEFAULT 0 NOT NULL,
 Parent NUMBER(11,0) DEFAULT 0 NOT NULL,
 URI varchar2(255),
+Disabled NUMBER(11,0) DEFAULT 0 NOT NULL,
 Creator NUMBER(11,0) DEFAULT 0 NOT NULL,
 Created DATE,
 LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL,
diff --git a/etc/schema.Pg b/etc/schema.Pg
index dbe23a3..cd526e2 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -676,6 +676,7 @@ SortOrder integer NOT NULL DEFAULT 0,
 Class integer NOT NULL DEFAULT 0,
 Parent integer NOT NULL DEFAULT 0,
 URI varchar(255),
+Disabled smallint NOT NULL DEFAULT 0,
 Creator integer NOT NULL DEFAULT 0,
 Created TIMESTAMP NULL,
 LastUpdatedBy integer NOT NULL DEFAULT 0,
diff --git a/etc/schema.SQLite b/etc/schema.SQLite
index 80e5749..5b2bb0f 100644
--- a/etc/schema.SQLite
+++ b/etc/schema.SQLite
@@ -481,6 +481,7 @@ SortOrder integer NOT NULL DEFAULT 0,
 Class integer NOT NULL DEFAULT 0,
 Parent integer NOT NULL DEFAULT 0,
 URI varchar(255) collate NOCASE,
+Disabled smallint NOT NULL DEFAULT 0,
 Creator integer NOT NULL DEFAULT 0,
 Created TIMESTAMP NULL,
 LastUpdatedBy integer NOT NULL DEFAULT 0,
diff --git a/etc/schema.mysql b/etc/schema.mysql
index f69ea4c..032c4d4 100644
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -469,6 +469,7 @@ CREATE TABLE Articles (
   Class int(11) NOT NULL default '0',
   Parent int(11) NOT NULL default '0',
   URI varchar(255) character set ascii default NULL,
+  Disabled int(2) NOT NULL default '0',
   Creator int(11) NOT NULL default '0',
   Created datetime default NULL,
   LastUpdatedBy int(11) NOT NULL default '0',
diff --git a/etc/upgrade/4.3.7/schema.Oracle b/etc/upgrade/4.3.7/schema.Oracle
new file mode 100644
index 0000000..1a53768
--- /dev/null
+++ b/etc/upgrade/4.3.7/schema.Oracle
@@ -0,0 +1,2 @@
+ALTER TABLE Articles ADD Disabled NUMBER(11,0) DEFAULT 0 NOT NULL;
+UPDATE ACL SET RightName='DisableArticle' WHERE RightName='DeleteArticle';
diff --git a/etc/upgrade/4.3.7/schema.Pg b/etc/upgrade/4.3.7/schema.Pg
new file mode 100644
index 0000000..61c153a
--- /dev/null
+++ b/etc/upgrade/4.3.7/schema.Pg
@@ -0,0 +1,2 @@
+ALTER TABLE Articles ADD COLUMN Disabled smallint NOT NULL DEFAULT 0;
+UPDATE ACL SET RightName='DisableArticle' WHERE RightName='DeleteArticle';
diff --git a/etc/upgrade/4.3.7/schema.SQLite b/etc/upgrade/4.3.7/schema.SQLite
new file mode 100644
index 0000000..61c153a
--- /dev/null
+++ b/etc/upgrade/4.3.7/schema.SQLite
@@ -0,0 +1,2 @@
+ALTER TABLE Articles ADD COLUMN Disabled smallint NOT NULL DEFAULT 0;
+UPDATE ACL SET RightName='DisableArticle' WHERE RightName='DeleteArticle';
diff --git a/etc/upgrade/4.3.7/schema.mysql b/etc/upgrade/4.3.7/schema.mysql
new file mode 100644
index 0000000..fb762b3
--- /dev/null
+++ b/etc/upgrade/4.3.7/schema.mysql
@@ -0,0 +1,2 @@
+ALTER TABLE Articles ADD COLUMN Disabled int(2) NOT NULL DEFAULT 0;
+UPDATE ACL SET RightName='DisableArticle' WHERE RightName='DeleteArticle';
diff --git a/lib/RT/Article.pm b/lib/RT/Article.pm
index e2833f0..8935a31 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -100,6 +100,7 @@ sub Create {
         CustomFields => {},
         Links        => {},
         Topics       => [],
+        Disabled    => 0,
         @_
     );
 
@@ -121,6 +122,7 @@ sub Create {
         Name    => $args{'Name'},
         Class   => $class->Id,
         Summary => $args{'Summary'},
+        Disabled => $args{'Disabled'},
     );
     unless ($id) {
         $RT::Handle->Rollback();
@@ -258,75 +260,13 @@ sub ValidateName {
 
 =head2 Delete
 
-Delete all its transactions
-Delete all its custom field values
-Delete all its relationships
-Delete this article.
+This does not remove from the database; it merely sets the Disabled bit.
 
 =cut
 
 sub Delete {
     my $self = shift;
-    unless ( $self->CurrentUserHasRight('DeleteArticle') ) {
-        return ( 0, $self->loc("Permission Denied") );
-    }
-
-    $RT::Handle->BeginTransaction();
-    my $linksto   = $self->_Links(  'Target' );
-    my $linksfrom = $self->_Links(  'Base' );
-    my $cfvalues = $self->CustomFieldValues;
-    my $txns     = $self->Transactions;
-    my $topics   = $self->Topics;
-
-    while ( my $item = $linksto->Next ) {
-        my ( $val, $msg ) = $item->Delete();
-        unless ($val) {
-            $RT::Logger->crit( ref($item) . ": $msg" );
-            $RT::Handle->Rollback();
-            return ( 0, $self->loc('Internal Error') );
-        }
-    }
-
-    while ( my $item = $linksfrom->Next ) {
-        my ( $val, $msg ) = $item->Delete();
-        unless ($val) {
-            $RT::Logger->crit( ref($item) . ": $msg" );
-            $RT::Handle->Rollback();
-            return ( 0, $self->loc('Internal Error') );
-        }
-    }
-
-    while ( my $item = $txns->Next ) {
-        my ( $val, $msg ) = $item->Delete();
-        unless ($val) {
-            $RT::Logger->crit( ref($item) . ": $msg" );
-            $RT::Handle->Rollback();
-            return ( 0, $self->loc('Internal Error') );
-        }
-    }
-
-    while ( my $item = $cfvalues->Next ) {
-        my ( $val, $msg ) = $item->Delete();
-        unless ($val) {
-            $RT::Logger->crit( ref($item) . ": $msg" );
-            $RT::Handle->Rollback();
-            return ( 0, $self->loc('Internal Error') );
-        }
-    }
-
-    while ( my $item = $topics->Next ) {
-        my ( $val, $msg ) = $item->Delete();
-        unless ($val) {
-            $RT::Logger->crit( ref($item) . ": $msg" );
-            $RT::Handle->Rollback();
-            return ( 0, $self->loc('Internal Error') );
-        }
-    }
-
-    $self->SUPER::Delete();
-    $RT::Handle->Commit();
-    return ( 1, $self->loc('Article Deleted') );
-
+    return $self->SetDisabled(1);
 }
 
 # }}}
@@ -532,8 +472,15 @@ sub _Set {
         @_
     );
 
-    unless ( $self->CurrentUserHasRight('ModifyArticle') ) {
-        return ( 0, $self->loc("Permission Denied") );
+    if ( $args{Field} eq 'Disabled' ) {
+        unless ( $self->CurrentUserHasRight( 'DisableArticle' ) ) {
+            return ( 0, $self->loc( "Permission Denied" ) );
+        }
+    }
+    else {
+        unless ( $self->CurrentUserHasRight( 'ModifyArticle' ) ) {
+            return ( 0, $self->loc( "Permission Denied" ) );
+        }
     }
 
     $self->_NewTransaction(
@@ -764,6 +711,21 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 
 =cut
 
+=head2 Disabled
+
+Returns the current value of Disabled.
+(In the database, Disabled is stored as int(2).)
+
+
+
+=head2 SetDisabled VALUE
+
+
+Set Disabled to VALUE.
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, Disabled will be stored as a int(2).)
+
+
 
 =head2 Creator
 
@@ -819,6 +781,8 @@ sub _CoreAccessible {
                 {read => 1, write => 1, type => 'int(11)', default => '0'},
         URI => 
                 {read => 1, write => 1, type => 'varchar(255)', default => ''},
+        Disabled => 
+                {read => 1, write => 1, type => 'int(2)', default => '0'},
         Creator => 
                 {read => 1, auto => 1, type => 'int(11)', default => '0'},
         Created => 
diff --git a/lib/RT/Articles.pm b/lib/RT/Articles.pm
index ea82827..e0b0f8c 100644
--- a/lib/RT/Articles.pm
+++ b/lib/RT/Articles.pm
@@ -57,6 +57,7 @@ sub Table {'Articles'}
 
 sub _Init {
     my $self = shift;
+    $self->{'with_disabled_column'} = 1;
     $self->OrderByCols(
         { FIELD => 'SortOrder', ORDER => 'ASC' },
         { FIELD => 'Name',      ORDER => 'ASC' },
diff --git a/lib/RT/Class.pm b/lib/RT/Class.pm
index ec8eb82..00d47ea 100644
--- a/lib/RT/Class.pm
+++ b/lib/RT/Class.pm
@@ -96,7 +96,7 @@ __PACKAGE__->AddRight( Admin   => AdminClass          => 'Modify metadata and cu
 __PACKAGE__->AddRight( Admin   => AdminTopics         => 'Modify topic hierarchy associated with this class'); # loc
 __PACKAGE__->AddRight( Admin   => ShowACL             => 'Display Access Control List'); # loc
 __PACKAGE__->AddRight( Admin   => ModifyACL           => 'Create, modify and delete Access Control List entries'); # loc
-__PACKAGE__->AddRight( Staff   => DeleteArticle       => 'Delete articles in this class'); # loc
+__PACKAGE__->AddRight( Staff   => DisableArticle      => 'Disable articles in this class'); # loc
 
 # {{{ Create
 
diff --git a/share/html/Articles/Article/Edit.html b/share/html/Articles/Article/Edit.html
index 609450b..85647cc 100644
--- a/share/html/Articles/Article/Edit.html
+++ b/share/html/Articles/Article/Edit.html
@@ -124,6 +124,11 @@ if ($Class) {
 my %create_args;
 my %CFContent;
 my $EditClass = 1;
+
+if ( $ARGS{SetEnabled} ) {
+    $ARGS{Disabled} = $ARGS{Enabled} ? 0 : 1;
+}
+
 if ( !$id ) {
     $title = loc('Create a new article');
     foreach my $arg ( sort keys %ARGS ) {
@@ -161,6 +166,7 @@ elsif ( $id eq 'new' ) {
         Name    => $ARGS{'Name'},
         Class   => $ARGS{'Class'},
         Topics  => $ARGS{'Topics'},
+        Disabled => $ARGS{'Disabled'},
         %create_args,
         %cfs
     );
@@ -198,7 +204,7 @@ else {
             Why => loc("Unable to load article") );
     }
 
-    my @attribs = qw(Name Summary Class);
+    my @attribs = qw(Name Summary Class Disabled);
 
     @results = UpdateRecordObject(
         AttributesRef => \@attribs,
diff --git a/share/html/Articles/Article/Elements/EditBasics b/share/html/Articles/Article/Elements/EditBasics
index 705cb0d..4b4db60 100644
--- a/share/html/Articles/Article/Elements/EditBasics
+++ b/share/html/Articles/Article/Elements/EditBasics
@@ -64,6 +64,16 @@
 % }
 </td>
 </tr>
+% if ($ARGS{'id'} eq 'new' || $ArticleObj->CurrentUserHasRight('DisableArticle')) {
+<tr>
+<td class="label"></td>
+<td>
+    <input type="hidden" class="hidden" name="SetEnabled" value="1" />
+    <input type="checkbox" class="checkbox" id="Enabled" name="Enabled" value="1" <% ( $ArticleObj->id && $ArticleObj->Disabled || $ARGS{'Disabled'} ) ? '' : 'checked="checked"' |n %> />
+    <label for="Enabled"><&|/l&>Enabled (Unchecking this box disables this article)</&></label>
+</td>
+</tr>
+% }
 <%INIT>
 </%INIT>
 <%ARGS>
diff --git a/share/html/Elements/BulkLinks b/share/html/Elements/BulkLinks
index d5dbeb6..dadc454 100644
--- a/share/html/Elements/BulkLinks
+++ b/share/html/Elements/BulkLinks
@@ -55,8 +55,7 @@
     <td class="value">
 % if ( $hash{DependsOn} ) {
 % for my $link ( values %{$hash{DependsOn}} ) {
-      <input type="checkbox" class="checkbox" id="DeleteLink--<%$link->Type%>-<%$link->Target%>" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
-      <label for="DeleteLink--<%$link->Type%>-<%$link->Target%>"><& /Elements/ShowLink, URI => $link->TargetURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Target' &>
 % } }
     </td>
   </tr>
@@ -65,8 +64,7 @@
     <td class="value">
 % if ( $hash{DependedOnBy} ) {
 % for my $link ( values %{$hash{DependedOnBy}} ) {
-      <input type="checkbox" class="checkbox" id="DeleteLink-<%$link->Base%>-<%$link->Type%>-" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
-      <label for="DeleteLink-<%$link->Base%>-<%$link->Type%>-"><& /Elements/ShowLink, URI => $link->BaseURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Base' &>
 % } }
     </td>
   </tr>
@@ -75,8 +73,7 @@
     <td class="value">
 % if ( $hash{MemberOf} ) {
 % for my $link ( values %{$hash{MemberOf}} ) {
-      <input type="checkbox" class="checkbox" id="DeleteLink--<%$link->Type%>-<%$link->Target%>" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
-      <label for="DeleteLink--<%$link->Type%>-<%$link->Target%>"><& /Elements/ShowLink, URI => $link->TargetURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Target' &>
 % } }
     </td>
   </tr>
@@ -85,8 +82,7 @@
     <td class="value">
 % if ( $hash{Members} ) {
 % for my $link ( values %{$hash{Members}} ) {
-      <input type="checkbox" class="checkbox" id="DeleteLink-<%$link->Base%>-<%$link->Type%>-" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
-      <label for="DeleteLink-<%$link->Base%>-<%$link->Type%>-"><& /Elements/ShowLink, URI => $link->BaseURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Base' &>
 % } }
     </td>
   </tr>
@@ -95,8 +91,7 @@
     <td class="value">
 % if ( $hash{RefersTo} ) {
 % for my $link ( values %{$hash{RefersTo}} ) {
-      <input type="checkbox" class="checkbox" id="DeleteLink--<%$link->Type%>-<%$link->Target%>" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
-      <label for="DeleteLink--<%$link->Type%>-<%$link->Target%>"><& /Elements/ShowLink, URI => $link->TargetURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Target' &>
 % } }
     </td>
   </tr>
@@ -105,10 +100,7 @@
     <td class="value">
 % if ( $hash{ReferredToBy} ) {
 % for my $link ( values %{$hash{ReferredToBy}} ) {
-% # Skip reminders
-% next if (UNIVERSAL::isa($link->BaseObj, 'RT::Ticket')  && $link->BaseObj->Type eq 'reminder');
-      <input type="checkbox" class="checkbox" id="DeleteLink-<%$link->Base%>-<%$link->Type%>-" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
-      <label for="DeleteLink-<%$link->Base%>-<%$link->Type%>-"><& /Elements/ShowLink, URI => $link->BaseURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Base' &>
 % } }
     </td>
   </tr>
diff --git a/share/html/Articles/Article/Delete.html b/share/html/Elements/EditLink
similarity index 62%
rename from share/html/Articles/Article/Delete.html
rename to share/html/Elements/EditLink
index 22dc303..39443ab 100644
--- a/share/html/Articles/Article/Delete.html
+++ b/share/html/Elements/EditLink
@@ -45,62 +45,26 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => $title &>
-<& /Elements/Tabs &>
-
-% if ($ARGS{'Delete'}) {
-<%$title%>
-<& /Elements/ListActions, actions => \@results &>
 
+% if ( $Mode eq 'Target' ) {
+    <input type="checkbox" class="checkbox" id="DeleteLink--<%$Link->Type%>-<%$Link->Target%>" name="DeleteLink--<%$Link->Type%>-<%$Link->Target%>" value="1" />
+    <label for="DeleteLink--<%$Link->Type%>-<%$Link->Target%>"><& ShowLink, URI => $Link->TargetURI &></label>
 % } else {
-<b><&|/l&>Are you sure you want to delete this article?</&></b>
-<table>
-<tr>
-<td align="left">
-<form action="Display.html" method="get">
-<input type="hidden" name="id"     value="<%$ArticleObj->Id%>" />
-<input type="submit" value="<&|/l&>No</&>" />
-</form>
-
-</td>
-<td align="right">
-<form action="Delete.html" method="post">
-<input type="hidden" name="id" value="<%$ArticleObj->Id%>" />
-<input type="hidden" name="Delete" value="yes" />
-<input type="submit" value="<&|/l&>Yes</&>" />
-</form>
-</td>
-
-</tr>
-</table>
+      <input type="checkbox" class="checkbox" id="DeleteLink-<%$Link->Base%>-<%$Link->Type%>-" name="DeleteLink-<%$Link->Base%>-<%$Link->Type%>-" value="1" />
+      <label for="DeleteLink-<%$Link->Base%>-<%$Link->Type%>-"><& ShowLink, URI => $Link->BaseURI &></label>
 % }
-<%INIT>
-
-my @results;
-
-my $title;
-my $ArticleObj = RT::Article->new( $session{'CurrentUser'} );
 
+<br />
 
-$ArticleObj->Load($id);
-unless ( $ArticleObj->id ) {
-    $m->comp("/Elements/Error", Why =>  loc("Unable to load article") );
-}
-
-
-unless ( $ArticleObj->CurrentUserHasRight('ModifyArticle') ) {
-    $m->comp("/Elements/Error", Why => loc("No permission to modify article"));
-}
-
-if ($ARGS{'Delete'} eq 'yes') {
-    $ArticleObj->Delete();
-    $title = loc('Article #[_1] deleted', $ArticleObj->Id);
-}
+<%INIT>
+my $ModeObj = $Mode . 'Obj';
+return if UNIVERSAL::isa($Link->$ModeObj, 'RT::Article') && $Link->$ModeObj->Disabled;
 
-else {
-    $title = loc('Delete article #[_1]', $ArticleObj->Id);
-}
+# Skip reminders
+return if $Mode eq 'Base' && $Link->Type eq 'RefersTo' && UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket')  && $Link->BaseObj->Type eq 'reminder';
 </%INIT>
+
 <%ARGS>
-$id => undef
+$Link
+$Mode
 </%ARGS>
diff --git a/share/html/Elements/EditLinks b/share/html/Elements/EditLinks
index 31415f0..a1eec1c 100644
--- a/share/html/Elements/EditLinks
+++ b/share/html/Elements/EditLinks
@@ -55,8 +55,7 @@
     <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Depends on').':', Relation => 'DependsOn' &></td>
     <td class="value">
 % while (my $link = $Object->DependsOn->Next) {
-      <input type="checkbox" class="checkbox" id="DeleteLink--<%$link->Type%>-<%$link->Target%>" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
-      <label for="DeleteLink--<%$link->Type%>-<%$link->Target%>"><& ShowLink, URI => $link->TargetURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Target' &>
 % }
     </td>
   </tr>
@@ -64,8 +63,7 @@
     <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Depended on by').':', Relation => 'DependedOnBy' &></td>
     <td class="value">
 % while (my $link = $Object->DependedOnBy->Next) {
-      <input type="checkbox" class="checkbox" id="DeleteLink-<%$link->Base%>-<%$link->Type%>-" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
-      <label for="DeleteLink-<%$link->Base%>-<%$link->Type%>-"><& ShowLink, URI => $link->BaseURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Base' &>
 % }
     </td>
   </tr>
@@ -73,8 +71,7 @@
     <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Parents').':', Relation => 'Parents' &></td>
     <td class="value">
 % while (my $link = $Object->MemberOf->Next) {
-      <input type="checkbox" class="checkbox" id="DeleteLink--<%$link->Type%>-<%$link->Target%>" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
-      <label for="DeleteLink--<%$link->Type%>-<%$link->Target%>"><& ShowLink, URI => $link->TargetURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Target' &>
 % }
     </td>
   </tr>
@@ -82,8 +79,7 @@
     <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Children').':', Relation => 'Children' &></td>
     <td class="value">
 % while (my $link = $Object->Members->Next) {
-      <input type="checkbox" class="checkbox" id="DeleteLink-<%$link->Base%>-<%$link->Type%>-" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
-      <label for="DeleteLink-<%$link->Base%>-<%$link->Type%>-"><& ShowLink, URI => $link->BaseURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Base' &>
 % }
     </td>
   </tr>
@@ -91,8 +87,7 @@
     <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Refers to').':', Relation => 'RefersTo' &></td>
     <td class="value">
 % while (my $link = $Object->RefersTo->Next) {
-      <input type="checkbox" class="checkbox" id="DeleteLink--<%$link->Type%>-<%$link->Target%>" name="DeleteLink--<%$link->Type%>-<%$link->Target%>" value="1" />
-      <label for="DeleteLink--<%$link->Type%>-<%$link->Target%>"><& ShowLink, URI => $link->TargetURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Target' &>
 %}
     </td>
   </tr>
@@ -100,10 +95,7 @@
     <td class="labeltop"><& ShowRelationLabel, Object => $Object, Label => loc('Referred to by').':', Relation => 'ReferredToBy' &></td>
     <td class="value">
 % while (my $link = $Object->ReferredToBy->Next) {
-% # Skip reminders
-% next if (UNIVERSAL::isa($link->BaseObj, 'RT::Ticket')  && $link->BaseObj->Type eq 'reminder');
-      <input type="checkbox" class="checkbox" id="DeleteLink-<%$link->Base%>-<%$link->Type%>-" name="DeleteLink-<%$link->Base%>-<%$link->Type%>-" value="1" />
-      <label for="DeleteLink-<%$link->Base%>-<%$link->Type%>-"><& ShowLink, URI => $link->BaseURI &></label><br />
+      <& EditLink, Link => $link, Mode => 'Base' &>
 % }
     </td>
   </tr>
diff --git a/share/html/Elements/ShowLinksOfType b/share/html/Elements/ShowLinksOfType
index 9b332da..54b8d37 100644
--- a/share/html/Elements/ShowLinksOfType
+++ b/share/html/Elements/ShowLinksOfType
@@ -89,6 +89,7 @@ my $ModeObj = "${mode}Obj";
 my (@active, @inactive, @not_tickets);
 while (my $link = $links->Next) {
     my $ToObj = $link->$ModeObj;
+    next if UNIVERSAL::isa($ToObj,'RT::Article') && $ToObj->Disabled;
     if ($ToObj and $ToObj->isa('RT::Ticket')) {
         next if $Type eq "ReferredToBy"
             and $ToObj->Type eq 'reminder';
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index b2ff96d..d8cbbf8 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -890,7 +890,6 @@ my $build_main_nav = sub {
             $tabs->child( display => title => loc('Display'), path => "/Articles/Article/Display.html?id=".$id );
             $tabs->child( history => title => loc('History'), path => "/Articles/Article/History.html?id=".$id );
             $tabs->child( modify  => title => loc('Modify'),  path => "/Articles/Article/Edit.html?id=".$id );
-            $tabs->child( delete  => title => loc('Delete'),  path => "/Articles/Article/Delete.html?id=".$id );
         }
     }
 
@@ -914,9 +913,6 @@ my $build_main_nav = sub {
                 if ( $obj->CurrentUserHasRight('ModifyArticle') ) {
                     $tabs->child(modify => title => loc('Modify'), path => '/Articles/Article/Edit.html?id=' . $id );
                 }
-                if ( $obj->CurrentUserHasRight('DeleteArticle') ) {
-                    $tabs->child(delete => title => loc('Delete'), path => '/Articles/Article/Delete.html?id=' . $id );
-                }
             }
         }
 
diff --git a/share/html/m/ticket/show b/share/html/m/ticket/show
index 8851158..f02a40e 100644
--- a/share/html/m/ticket/show
+++ b/share/html/m/ticket/show
@@ -401,7 +401,7 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
             push( @active, $link->TargetURI );
         }
     }
-    else {
+    elsif ( not (UNIVERSAL::isa($link->TargetObj, 'RT::Article') && $link->TargetObj->Disabled) ) {
         push( @not_tickets, $link->TargetURI );
     }
 }
@@ -420,6 +420,7 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
     <div class="value">
 <ul>
 % while (my $Link = $Ticket->DependedOnBy->Next) {
+% next if UNIVERSAL::isa($Link->BaseObj, 'RT::Article') && $Link->BaseObj->Disabled;
 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
 % }
 </ul>
@@ -438,6 +439,7 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
     <div class="value">
 <ul>
 % while (my $Link = $Ticket->RefersTo->Next) {
+% next if UNIVERSAL::isa($Link->TargetObj, 'RT::Article') && $Link->TargetObj->Disabled;
 <li><& /Elements/ShowLink, URI => $Link->TargetURI &></li>
 % }
 </ul>
@@ -448,6 +450,7 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
     <div class="value">
     <ul>
 % while (my $Link = $Ticket->ReferredToBy->Next) {
+% next if UNIVERSAL::isa($Link->BaseObj, 'RT::Article') && $Link->BaseObj->Disabled;
 % next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket')  && $Link->BaseObj->Type eq 'reminder');
 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
 % }
diff --git a/t/articles/article.t b/t/articles/article.t
index 7a3474f..5c7fe06 100644
--- a/t/articles/article.t
+++ b/t/articles/article.t
@@ -80,7 +80,7 @@ ok ($val, "Article Deleted: $msg");
 
  $a2 = RT::Article->new($RT::SystemUser);
 $a2->Load($id);
-ok (!$a2->Id, "Did not find the article");
+ok ($a2->Disabled, "the article is disabled");
 
 # NOT OK
 #$RT::Handle->SimpleQuery("DELETE FROM Links");
diff --git a/t/articles/uri-articles.t b/t/articles/uri-articles.t
index 9ad4b07..52544df 100644
--- a/t/articles/uri-articles.t
+++ b/t/articles/uri-articles.t
@@ -36,13 +36,7 @@ ok ($uri->ParseURI("fsck.com-article://example.com/article/$article_id"),
 
 ok ($article->Delete(), 'Deleted article');
 
-my $ret;
-warning_like {
-    $ret = $uri->ParseURI("fsck.com-article://example.com/article/$article_id");
-} qr/Unable to load article for id $article_id. It may have been deleted/,
-    "Warned about missing article";
-
-ok (!$ret, 'Returned false on missing article');
+ok($article->Disabled, 'deleted article is actually just disabled');
 
 ok (!$uri->ParseURI("fsck.com-article://foo.com/article/$article_id"),
     'ParseURI returned false with incorrect Organization');

commit 53b293b8f78f248dc4d1387a70414026e4008ac5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jan 12 21:09:44 2015 +0800

    hide reminders and disabled articles for REST

diff --git a/share/html/REST/1.0/Forms/ticket/links b/share/html/REST/1.0/Forms/ticket/links
index 45b14d0..8edc8e2 100644
--- a/share/html/REST/1.0/Forms/ticket/links
+++ b/share/html/REST/1.0/Forms/ticket/links
@@ -89,7 +89,10 @@ if ($changes) {
 
             my %old;
             my $field = $lfields{$key}->{Mode};
+            my $mode_obj = $field . 'Obj';
             while (my $link = $ticket->$key->Next) {
+                next if UNIVERSAL::isa($link->$mode_obj, 'RT::Article') && $link->$mode_obj->Disabled;
+                next if $field eq 'Base' && $link->Type eq 'RefersTo' && $link->BaseObj->Type eq 'reminder';
                 $old{$link->$field} = 1;
             }
 
@@ -157,7 +160,10 @@ else {
         my @val;
 
         my $field = $lfields{$key}->{Mode};
+        my $mode_obj = $field . 'Obj';
         while (my $link = $ticket->$key->Next) {
+            next if UNIVERSAL::isa($link->$mode_obj, 'RT::Article') && $link->$mode_obj->Disabled;
+            next if $field eq 'Base' && $link->Type eq 'RefersTo' && UNIVERSAL::isa($link->$mode_obj, 'RT::Ticket')  && $link->BaseObj->Type eq 'reminder';
             push @val, $link->$field;
         }
         push(@val, "") if (@val == 0 && defined $format && $format eq 'l');

commit 137ec6769269b94c9a211a82607589ca692c39af
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jan 12 22:31:31 2015 +0800

    hide reminders and disabled articles for ticket's relationship graph

diff --git a/lib/RT/Graph/Tickets.pm b/lib/RT/Graph/Tickets.pm
index 573d820..ac9ce4d 100644
--- a/lib/RT/Graph/Tickets.pm
+++ b/lib/RT/Graph/Tickets.pm
@@ -136,12 +136,25 @@ foreach my $field (qw(Told Starts Started Due Resolved LastUpdated Created)) {
 }
 foreach my $field (qw(Members DependedOnBy ReferredToBy)) {
     $property_cb{ $field } = sub {
-        return join ', ', map $_->BaseObj->id, @{ $_[0]->$field->ItemsArrayRef };
+        my $links = $_[0]->$field;
+        my @string;
+        while ( my $link = $links->Next ) {
+            next if UNIVERSAL::isa($link->BaseObj, 'RT::Article') && $link->BaseObj->Disabled;
+            next if $field eq 'ReferredToBy' && UNIVERSAL::isa($link->BaseObj, 'RT::Ticket') && $link->BaseObj->Type eq 'reminder';
+            push @string, $link->BaseObj->id;
+        }
+        return join ', ', @string;
     };
 }
 foreach my $field (qw(MemberOf DependsOn RefersTo)) {
     $property_cb{ $field } = sub {
-        return join ', ', map $_->TargetObj->id, @{ $_[0]->$field->ItemsArrayRef };
+        my $links = $_[0]->$field;
+        my @string;
+        while ( my $link = $links->Next ) {
+            next if UNIVERSAL::isa($link->TargetObj, 'RT::Article') && $link->TargetObj->Disabled;
+            push @string, $link->TargetObj->id;
+        }
+        return join ', ', @string;
     };
 }
 

commit b89f38bdea056114555e253007045dfec484ae76
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jan 12 22:33:48 2015 +0800

    distinguish links by prefixing scheme for non-ticket ids

diff --git a/lib/RT/Graph/Tickets.pm b/lib/RT/Graph/Tickets.pm
index ac9ce4d..8273108 100644
--- a/lib/RT/Graph/Tickets.pm
+++ b/lib/RT/Graph/Tickets.pm
@@ -141,7 +141,11 @@ foreach my $field (qw(Members DependedOnBy ReferredToBy)) {
         while ( my $link = $links->Next ) {
             next if UNIVERSAL::isa($link->BaseObj, 'RT::Article') && $link->BaseObj->Disabled;
             next if $field eq 'ReferredToBy' && UNIVERSAL::isa($link->BaseObj, 'RT::Ticket') && $link->BaseObj->Type eq 'reminder';
-            push @string, $link->BaseObj->id;
+            my $prefix =
+                UNIVERSAL::isa( $link->BaseObj, 'RT::Ticket' ) ? ''
+              : UNIVERSAL::isa( $link->BaseObj, 'RT::Article' ) ? 'a:'
+              :                                                   $link->BaseURI->Scheme . ':';
+            push @string, $prefix . $link->BaseObj->id;
         }
         return join ', ', @string;
     };
@@ -152,7 +156,11 @@ foreach my $field (qw(MemberOf DependsOn RefersTo)) {
         my @string;
         while ( my $link = $links->Next ) {
             next if UNIVERSAL::isa($link->TargetObj, 'RT::Article') && $link->TargetObj->Disabled;
-            push @string, $link->TargetObj->id;
+            my $prefix =
+                UNIVERSAL::isa( $link->TargetObj, 'RT::Ticket' ) ? ''
+              : UNIVERSAL::isa( $link->TargetObj, 'RT::Article' ) ? 'a:'
+              :                                                   $link->TargetURI->Scheme . ':';
+            push @string, $prefix . $link->TargetObj->id;
         }
         return join ', ', @string;
     };

-----------------------------------------------------------------------


More information about the rt-commit mailing list