Bug #45046 Patch: Sort by release and assigned in issue listing.
Submitted: 23 May 2009 11:33 Modified: 27 Aug 2010 19:58
Reporter: Robbert-Jan Roos Email Updates:
Status: Unsupported Impact on me:
None 
Category:Eventum Severity:S3 (Non-critical)
Version:all OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[23 May 2009 11:33] Robbert-Jan Roos
Description:
eventum -> list issues. It is not possible to sort by release or assigned users.
This would be quite convenient. Patch in suggested fix implements this feature.

How to repeat:
eventum -> list issues -> click on release or assigned column, nothing happens.

Suggested fix:
Patch against trunk 3880:

Index: include/class.issue.php
===================================================================
--- include/class.issue.php     (revision 3880)
+++ include/class.issue.php     (working copy)
@@ -2441,17 +2441,24 @@
             "last_action_date" => "desc",
             "usr_full_name" => "asc",
             "iss_expected_resolution_date" => "desc",
+            "pre_title" => "asc",
+            "assigned" => "asc"
         );
-
         foreach ($custom_fields as $fld_id => $fld_name) {
             $fields['custom_field_' . $fld_id] = "desc";
         }
+
+        $sortfields = array_combine(array_keys($fields), array_keys($fields));
+        $sortfields["pre_title"] = "pre_scheduled_date";
+        $sortfields["assigned"] = "isu_usr_id";
+
         $items = array(
             "links"  => array(),
             "images" => array()
         );
-        foreach ($fields as $field => $sort_order) {
-            if ($options["sort_by"] == $field) {
+        foreach ($sortfields as $field => $sortfield) {
+            $sort_order = $fields[$field];
+            if ($options["sort_by"] == $sortfield) {
                 $items["images"][$field] = "images/" . strtolower($options["sort_order"]) . ".gif";
                 if (strtolower($options["sort_order"]) == "asc") {
                     $sort_order = "desc";
@@ -2459,7 +2466,7 @@
                     $sort_order = "asc";
                 }
             }
-            $items["links"][$field] = $_SERVER["PHP_SELF"] . "?sort_by=" . $field . "&sort_order=" . $sort_order;
+            $items["links"][$field] = $_SERVER["PHP_SELF"] . "?sort_by=" . $sortfield . "&sort_order=" . $sort_order;
         }
         return $items;
     }
@@ -2580,7 +2587,7 @@
                 ON
                     (cf_sort.icf_iss_id = iss_id AND cf_sort.icf_fld_id = $fld_id) \n";
         }
-        if (!empty($options["users"])) {
+        if (!empty($options["users"]) || $options["sort_by"] === "isu_usr_id") {
             $stmt .= "
                  LEFT JOIN
                     " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
[25 May 2009 10:09] Robbert-Jan Roos
Hmm, just found out that this patch causes a bug in the 'next'/'previous' links in view.php.

Will need to add the joins needed for the 2 added sortfields in Issue::getSides to prevent that.
[27 May 2009 15:39] Robbert-Jan Roos
Patch which also implements the Issue::getSides function.

Attachment: sort_by_release_and_assigned.patch (application/octet-stream, text), 2.74 KiB.

[28 May 2009 10:41] Robbert-Jan Roos
Patch which implements the Issue::getSides function correctly (eventum_issue_user was joined 2 times in previous patch)

Attachment: sort_by_release_and_assigned-2.patch (application/octet-stream, text), 2.48 KiB.

[27 Aug 2010 19:58] Sveta Smirnova
Thank you for the report.

Eventum bugs are now tracked at https://bugs.launchpad.net/eventum Please re-post this bug there.