diff --git a/CHANGELOG.md b/CHANGELOG.md index cca11a27d6a..a80f9d3bbc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ requesting a new account and will be displayed in the User Accounts module (PR # #### Bug Fixes - *Add item here* ### Modules +#### Help Editor +- Cleaned up the deprecated column `Parent Topic` (PR #7025) #### Issue Tracker - Readability of comments and history was improved. (PR #6138) #### Candidate Parameters @@ -120,4 +122,4 @@ be used by projects having custom modules not in LORIS. (PR #5913) - The tool `phpstan` has been added to our automated test suite. (PR #4928) - Config files for static analysis have been moved to the `test/` directory. (PR #5871) - Dashboard was refactored to turn panels into module widgets. (PR #5896) -- Add CSSGrid component type (PR #6090) \ No newline at end of file +- Add CSSGrid component type (PR #6090) diff --git a/SQL/0000-00-04-Help.sql b/SQL/0000-00-04-Help.sql index c59aa6266f1..81555f3ac77 100644 --- a/SQL/0000-00-04-Help.sql +++ b/SQL/0000-00-04-Help.sql @@ -4,7 +4,6 @@ CREATE TABLE `help` ( `helpID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `parentID` int(11) NOT NULL DEFAULT '-1', `hash` varchar(32) DEFAULT NULL, `topic` varchar(100) NOT NULL DEFAULT '', `content` text NOT NULL, diff --git a/SQL/Cleanup_patches/2020-09-09-RemoveHelpParentID.sql b/SQL/Cleanup_patches/2020-09-09-RemoveHelpParentID.sql new file mode 100644 index 00000000000..2a35871c018 --- /dev/null +++ b/SQL/Cleanup_patches/2020-09-09-RemoveHelpParentID.sql @@ -0,0 +1 @@ +ALTER TABLE help DROP COLUMN parentID; diff --git a/modules/help_editor/ajax/process.php b/modules/help_editor/ajax/process.php index 004cd3f0a29..e075352b260 100644 --- a/modules/help_editor/ajax/process.php +++ b/modules/help_editor/ajax/process.php @@ -42,60 +42,34 @@ ), ] ); -} else { - //content does not exist insert the help file - if (!empty($_POST['section']) - && $_POST['subsection'] != 'undefined' - && empty($_POST['parentID']) - ) { - //create parent help section first - $parentID = HelpFile::insert( - [ - 'hash' => md5($_POST['section']), - 'topic' => "", - 'content' => "Under construction", - 'created' => date( - 'Y-m-d h:i:s', - time() - ), - ] - ); - // check errors - } - if (!empty($_POST['section']) - && $_POST['subsection'] != 'undefined' - && !empty($_POST['parentID']) - ) { - - // insert the help file - $helpID = HelpFile::insert( - [ - 'parentID' => $_POST['parentID'], - 'hash' => md5($_POST['subsection']), - 'topic' => $_POST['title'], - 'content' => $_POST['content'], - 'created' => date( - 'Y-m-d h:i:s', - time() - ), - ] - ); - - } else if (!empty($_POST['section']) - && $_POST['subsection'] == 'undefined' - ) { - //default case - $helpID = HelpFile::insert( - [ - 'hash' => md5($_POST['section']), - 'topic' => $_POST['title'], - 'content' => $_POST['content'], - 'created' => date( - 'Y-m-d h:i:s', - time() - ), - ] - ); - } +} else if (!empty($_POST['section']) + && $_POST['subsection'] != 'undefined' +) { + // insert the help file + $helpID = HelpFile::insert( + [ + 'hash' => md5($_POST['subsection']), + 'topic' => $_POST['title'], + 'content' => $_POST['content'], + 'created' => date( + 'Y-m-d h:i:s', + time() + ), + ] + ); +} else if (!empty($_POST['section']) + && $_POST['subsection'] == 'undefined' +) { + //default case + $helpID = HelpFile::insert( + [ + 'hash' => md5($_POST['section']), + 'topic' => $_POST['title'], + 'content' => $_POST['content'], + 'created' => date( + 'Y-m-d h:i:s', + time() + ), + ] + ); } - diff --git a/modules/help_editor/help/help_editor.md b/modules/help_editor/help/help_editor.md index 242f87e183d..b1504686693 100644 --- a/modules/help_editor/help/help_editor.md +++ b/modules/help_editor/help/help_editor.md @@ -4,4 +4,4 @@ This module displays existing help content for LORIS modules and pages. Use the *Selection Filter* section to search by Topic or Content keywords. -Click on the blue link in any *Topic* or *Parent Topic* column to edit the content within. Make your edits within the Edit Help Content page, and click **Save**. +Click on the blue link in any *Topic* column to edit the content within. Make your edits within the Edit Help Content page, and click **Save**. diff --git a/modules/help_editor/js/help_editor_helper.js b/modules/help_editor/js/help_editor_helper.js index 2be016cd06a..bed2851c3ee 100644 --- a/modules/help_editor/js/help_editor_helper.js +++ b/modules/help_editor/js/help_editor_helper.js @@ -51,7 +51,6 @@ $("#save-help").click(function(e) { content = $('textarea[name="content"]').val(), section = $("#section").val(), subsection = $("#subsection").val(), - parentID = $("#parentID").val(), helpID = $("#helpID").val(), returnString = $("#return").val(); @@ -63,7 +62,6 @@ $("#save-help").click(function(e) { content: content ? content : '', section: section ? section : '', subsection: subsection ? subsection : '', - parentID: parentID ? parentID : '', helpID: helpID ? helpID : '', }, success: function() { diff --git a/modules/help_editor/jsx/help_editor.js b/modules/help_editor/jsx/help_editor.js index e0c757ac562..c858d0202c8 100644 --- a/modules/help_editor/jsx/help_editor.js +++ b/modules/help_editor/jsx/help_editor.js @@ -71,14 +71,10 @@ class HelpEditor extends React.Component { let result = {cell}; switch (column) { case 'Topic': - url = loris.BaseURL + '/help_editor/edit_help_content/?helpID=' + - row['Help ID'] + '&parentID=' + row['Parent ID']; + url = loris.BaseURL + '/help_editor/edit_help_content/?helpID=' + + row['Help ID']; result = {cell}; break; - case 'Parent Topic': - url = loris.BaseURL + '/help_editor/edit_help_content/?helpID=' + - row['Parent ID'] + '&parentID=' + row['Parent Topic ID']; - result = {cell}; } return result; @@ -112,9 +108,6 @@ class HelpEditor extends React.Component { name: 'topic', type: 'text', }}, - {label: 'Parent ID', show: false}, - {label: 'Parent Topic ID', show: false}, - {label: 'Parent Topic', show: true}, {label: 'Content', show: true, filter: { name: 'content', type: 'text', diff --git a/modules/help_editor/php/edit_help_content.class.inc b/modules/help_editor/php/edit_help_content.class.inc index 9fbaaff6872..4f87bfd97f1 100644 --- a/modules/help_editor/php/edit_help_content.class.inc +++ b/modules/help_editor/php/edit_help_content.class.inc @@ -49,34 +49,29 @@ class Edit_Help_Content extends \NDB_Form $defaults = []; // Sanitize user input - $safeSection = $_REQUEST['section'] ? + $safeSection = isset($_REQUEST['section']) ? htmlspecialchars($_REQUEST['section']) : ''; - $safeSubsection = $_REQUEST['subsection'] ? + $safeSubsection = isset($_REQUEST['subsection']) ? htmlspecialchars($_REQUEST['subsection']) : ''; $defaults = []; - $helpID = ''; - $parentID = ''; + $helpID = ''; if (isset($_REQUEST['helpID'])) { $helpID = htmlspecialchars($_REQUEST['helpID']); } - if (isset($_GET['parentID'])) { - $parentID = htmlspecialchars($_GET['parentID']); - } - if (!empty($_REQUEST['section'])) { + if (isset($_REQUEST['section']) && !empty($_REQUEST['section'])) { $helpID = HelpFile::hashToID(md5($_REQUEST['section'])); } - if (!empty($_REQUEST['section']) + if (isset($_REQUEST['section']) && !empty($_REQUEST['section']) + && isset($_REQUEST['subsection']) && $_REQUEST['subsection'] != 'undefined' ) { - $helpID = HelpFile::hashToID(md5($_REQUEST['subsection'])); - $parentID = HelpFile::hashToID(md5($_GET['section'])); + $helpID = HelpFile::hashToID(md5($_REQUEST['subsection'])); } $this->tpl_data['section'] = $safeSection; $this->tpl_data['subsection'] = $safeSubsection; $this->tpl_data['helpID'] = $helpID ? $helpID : ''; - $this->tpl_data['parentID'] = $parentID ? $parentID : ''; if (!empty($helpID)) { $help_file = HelpFile::factory($helpID); diff --git a/modules/help_editor/php/helpfile.class.inc b/modules/help_editor/php/helpfile.class.inc index f09c7f9a04a..f417baade4a 100644 --- a/modules/help_editor/php/helpfile.class.inc +++ b/modules/help_editor/php/helpfile.class.inc @@ -62,8 +62,7 @@ class HelpFile // set the help ID $obj->helpID = $helpID; $result = $DB->pselectRow( - "SELECT helpID, parentID, hash, topic, - content, + "SELECT helpID, hash, topic, content, created, updated FROM help WHERE helpID = :HID", ['HID' => $helpID] ); @@ -109,188 +108,6 @@ class HelpFile return true; } - /** - * Returns whether or not the topic has subtopics - * - * @return bool - */ - function hasChild() - { - // create DB object - $DB =& \Database::singleton(); - - $result = $DB->pselectOne( - "SELECT COUNT(*) FROM help WHERE parentID = :HID", - ['HID' => $this->helpID] - ); - return ($result > 0); - } - - - /** - * Returns an array of its subtopics' IDs - * - * @param int $stopat Stop at this depth - * @param int $level Depth - * - * @return array - */ - function childIDs($stopat = 1, $level = 1) - { - // create DB object - $DB =& \Database::singleton(); - - // see if it has a child - $hasChild = $this->hasChild(); - - $childIDs = []; - - // get its children - if ($hasChild) { - $result = $DB->pselect( - "SELECT helpID FROM help WHERE parentID = :HID", - ['HID' => $this->helpID] - ); - // add the children to the array - $childIDs = $result; - - // check if we're done recursing - if ($level != $stopat) { - // check all the children for more children - foreach ($childIDs as $childID) { - // make the child - $child =& HelpFile::factory($childID); - // get the child's children - $grandChildIDs = $child->childIDs($stopat, $level + 1); - - // add the children to the array - $childIDs = array_merge($childIDs, $grandChildIDs); - } - } - } - - return $childIDs; - } - - - /** - * Returns an array of its subtopics's IDs and topics - * - * @param int $stopat Stop at this depth - * @param int $level Depth - * - * @return array - */ - function childData($stopat = 1, $level = 1) - { - // create DB object - $DB =& \Database::singleton(); - - // see if it has a child - $hasChild = $this->hasChild(); - - $childData = []; - - // get its children - if ($hasChild) { - $result = $DB->pselect( - "SELECT helpID, topic, $level as level - FROM help - WHERE parentID = :HID", - ['HID' => $this->helpID] - ); - - // add the children to the array - $childData = $result; - - // check if we're done recursing - if ($level !== $stopat) { - // check all the children for more children - foreach ($childData as $row) { - // make the child - $child =& HelpFile::factory($row['helpID']); - // get the child's children - $grandChildData = $child->childData($stopat, $level + 1); - - // add the children to the array - $childData = array_merge($childData, $grandChildData); - } - } - } - - return $childData; - } - - - /** - * Returns an array of its parent's IDs - * - * @param int $stopat Stop at this depth - * @param int $level Depth - * - * @return array - */ - function parentIDs($stopat = 1, $level = 1) - { - $parentIDs = []; - - if ($this->data['parentID'] > 0) { - // add the parent to the array - $parentIDs[] = $this->data['parentID']; - - // check if we're done recursing - if ($level != $stopat) { - // make the parent - $parent =& HelpFile::factory($this->data['parentID']); - // get the parent's parent - $grandParentIDs = $parent->parentIDs($stopat, $level + 1); - - // add the parents to the array - $parentIDs = array_merge($parentIDs, $grandParentIDs); - } - } - - return $parentIDs; - } - - - /** - * Returns an array of its parent's IDs and topics - * - * @param int $stopat Stop at this depth - * @param int $level Depth - * - * @return array - */ - function parentData($stopat = 1, $level = 1) - { - // create DB object - $DB = \Database::singleton(); - - $parentData = []; - - if ($this->data['parentID'] > 0) { - $parentData = $DB->pselectRow( - "SELECT helpID, topic, $level as level - FROM help - WHERE helpID = :HID", - ['HID' => $this->data['parentID']] - ); - - // check if we're done recursing - if (is_array($parentData) && $level != $stopat) { - // make the parent - $parent =& HelpFile::factory($this->data['parentID']); - - // get the parent's parent - $grandParentData = $parent->parentData($stopat, $level + 1); - - $parentData = array_merge($parentData, $grandParentData); - } - } - - return $parentData ?? []; - } /** * Dumps the HelpFile as an array diff --git a/modules/help_editor/php/helprowprovisioner.class.inc b/modules/help_editor/php/helprowprovisioner.class.inc index 588903d6fe8..4c79491788a 100644 --- a/modules/help_editor/php/helprowprovisioner.class.inc +++ b/modules/help_editor/php/helprowprovisioner.class.inc @@ -37,18 +37,13 @@ class HelpRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisioner function __construct() { parent::__construct( - "SELECT helpChild.helpID as helpID, - helpChild.topic as Topic, - helpChild.parentID as Parent_ID, - helpParent.parentID as ParentTopic_ID, - helpParent.topic as Parent_Topic, - helpChild.content as Content - FROM help helpChild - LEFT JOIN help helpParent - ON (helpChild.parentID = helpParent.helpID) - WHERE helpChild.hash IS NOT NULL - AND helpChild.topic IS NOT NULL - ORDER BY helpChild.helpID", + "SELECT help.helpID as helpID, + help.topic as Topic, + help.content as Content + FROM help + WHERE help.hash IS NOT NULL + AND help.topic IS NOT NULL + ORDER BY help.helpID", [] ); } diff --git a/modules/help_editor/templates/form_edit_help_content.tpl b/modules/help_editor/templates/form_edit_help_content.tpl index 4cff3904189..3e1dc96478e 100644 --- a/modules/help_editor/templates/form_edit_help_content.tpl +++ b/modules/help_editor/templates/form_edit_help_content.tpl @@ -31,7 +31,6 @@ - diff --git a/modules/help_editor/test/TestPlan.md b/modules/help_editor/test/TestPlan.md index 71fa87ed675..ca3e7ac8c15 100644 --- a/modules/help_editor/test/TestPlan.md +++ b/modules/help_editor/test/TestPlan.md @@ -22,7 +22,7 @@ [Automation Testing] 12. Test clear filter button. [Automation Testing] -13. Test links to topics, both parent and subtopic. +13. Test the topic link. [Manual Testing] 14. Ensure permission for Edit Help is working properly. [Manual Testing] diff --git a/modules/help_editor/test/help_editorTest.php b/modules/help_editor/test/help_editorTest.php index 7c410ffb4a3..85eae36d67e 100644 --- a/modules/help_editor/test/help_editorTest.php +++ b/modules/help_editor/test/help_editorTest.php @@ -38,12 +38,11 @@ function setUp() $this->DB->insert( "help", [ - 'helpID' => '999999', - 'parentID' => '-1', - 'hash' => $md5String, - 'topic' => 'Test Topic', - 'content' => 'This is a test content.', - 'created' => '2013-04-05 00:00:00', + 'helpID' => '999999', + 'hash' => $md5String, + 'topic' => 'Test Topic', + 'content' => 'This is a test content.', + 'created' => '2013-04-05 00:00:00', ] ); }