[Rt-commit] r4330 - in rt/branches/QUEBEC-EXPERIMENTAL: .
html/Admin/Elements
alexmv at bestpractical.com
alexmv at bestpractical.com
Mon Dec 19 14:48:22 EST 2005
Author: alexmv
Date: Mon Dec 19 14:48:21 2005
New Revision: 4330
Modified:
rt/branches/QUEBEC-EXPERIMENTAL/ (props changed)
rt/branches/QUEBEC-EXPERIMENTAL/html/Admin/Elements/EditCustomFields
Log:
r7854 at zoq-fot-pik: chmrr | 2005-12-19 14:47:41 -0500
* Squish out duplicate SortOrders in ObjectCustomFields if they
exist; this should be impossible, so the O(n) updates is mostly
justified.
Modified: rt/branches/QUEBEC-EXPERIMENTAL/html/Admin/Elements/EditCustomFields
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/html/Admin/Elements/EditCustomFields (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/html/Admin/Elements/EditCustomFields Mon Dec 19 14:48:21 2005
@@ -88,6 +88,20 @@
$ObjectCFs->LimitToObjectId($id);
$ObjectCFs->LimitToLookupType($lookup);
+# Check sanity of SortOrders
+my %SortOrders;
+$SortOrders{$_->SortOrder}++
+ while ($_ = $ObjectCFs->Next);
+
+# If there are duplicates, run though and squash them
+if (grep {$_ > 1} values %SortOrders) {
+ my $i = 1;
+ while (my $ObjectCF = $ObjectCFs->Next) {
+ $ObjectCF->SetSortOrder($i++);
+ }
+ $ObjectCFs->GotoFirstItem;
+}
+
# {{{ deal with moving sortorder of custom fields
if ($CustomField and $Move) {
my $SourceObj = RT::ObjectCustomField->new($session{'CurrentUser'});
More information about the Rt-commit
mailing list