########################################################################################## JILS-12: Project Filtering (client requests) ########################################################################################## Issue Type: New Feature ----------------------------------------------------------------------------------------- Issue Information ==================== Priority: Major Status: Closed Resolution: Done (2016-04-29 15:00:58) Project: Jira Issue Listing Script (JILS) Reported By: btasker Assigned To: btasker Affected Versions: - 0.01b Targeted for fix in version: - 0.01b Time Estimate: 0 minutes Time Logged: 0 minutes ----------------------------------------------------------------------------------------- Issue Description ================== A very, very basic version of this was implemented on the homepage in commit eeb3c63 (https://github.com/bentasker/Jira-Issue-Listing/commit/eeb3c639d6350623b258cb4442fc74f725ffdbab) The aim is to use the script to populate some static HTML pages on project.bentasker.co.uk, but only certain projects should be eligible for display. The commit above introduce the concept of a comma-seperated header allowing filtering by project key, this needs to be expanded so that the filter is taken into account on every page (the script needs to return a 404 if the filter prevents an issue/version from being displayed) The header used is -- BEGIN SNIPPET -- X-PROJECT-LIMIT: JILS,GPXIN -- END SNIPPET -- ----------------------------------------------------------------------------------------- Issue Relations ================ - blocks JILS-11: Move project management to JIRA - relates to JILS-22: Ability to set filters based on IP ----------------------------------------------------------------------------------------- Activity ========== ----------------------------------------------------------------------------------------- 2014-11-03 12:20:58 btasker ----------------------------------------------------------------------------------------- Marking as blocking JILS-11 as cannot configure the export pull into projects.bentasker.co.uk until this functionality is implemented. ----------------------------------------------------------------------------------------- 2014-11-03 12:22:54 btasker ----------------------------------------------------------------------------------------- The codeblock committed in the earlier commit is -- BEGIN SNIPPET -- $sql = "SELECT ID, pname, pkey, DESCRIPTION from project "; // This will be moved somewhere more suitable (and global) in future if (isset($_SERVER['HTTP_X_PROJECT_LIMIT']) && !empty($_SERVER['HTTP_X_PROJECT_LIMIT'])){ $sql .= "WHERE pkey IN ("; $keys = explode(",",$_SERVER['HTTP_X_PROJECT_LIMIT']); foreach ($keys as $k){ $sql .= "'".$db->stringEscape($k)."',"; } $sql .= "'') "; } $sql .= 'ORDER BY pkey ASC'; $db->setQuery($sql); $projects = $db->loadResults(); -- END SNIPPET -- The best way forward is probably to add a function to _utils.class_ which checks for the header and builds the filter if needed. ----------------------------------------------------------------------------------------- 2014-11-03 12:31:02 btasker ----------------------------------------------------------------------------------------- The filter is now called within _projects.php_ by doing the following -- BEGIN SNIPPET -- $filter = buildProjectFilter(); // See JILS-12 if ($filter){ $sql .= "WHERE ".$filter; } -- END SNIPPET -- The function _buildProjectFilter()_ returns false if there is no filter to build, and it's down to the calling entity whether the generated SQL needs to be prefixed with _WHERE_ or _AND_ ----------------------------------------------------------------------------------------- 2014-11-03 12:36:33 git ----------------------------------------------------------------------------------------- -- BEGIN QUOTE -- Repo: Jira-Issue-Listing Commit: eb083892f11cef1ccd724b9f470533462f2b9a55 Author: Ben Tasker