Allow reordering of featured articles without "Edit State" permission for all articles#19886
Closed
jo-sf wants to merge 3 commits intojoomla:3.10-devfrom
Closed
Allow reordering of featured articles without "Edit State" permission for all articles#19886jo-sf wants to merge 3 commits intojoomla:3.10-devfrom
jo-sf wants to merge 3 commits intojoomla:3.10-devfrom
Conversation
Method canEditState() copied from article.php into feature.php and modified such that it checks the "content_id" field of the "#__content_frontpage" table (the code in article.php doesn't fit to that table).
Quy
reviewed
May 18, 2018
Contributor
|
I have tested this item ✅ successfully on dfc9270 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19886. |
8 tasks
Member
|
Sorry that it took so long to respond. This is a nice addition to Joomla, as Joomla 3 is not accepting new features, would you mind to rebase it to the 4.2 branch? In the meantime I'm closing it, when ready please reopen, so we can get it properly tested. Thank you very much for your contribution, making Joomla better. |
1 similar comment
Member
|
Sorry that it took so long to respond. This is a nice addition to Joomla, as Joomla 3 is not accepting new features, would you mind to rebase it to the 4.2 branch? In the meantime I'm closing it, when ready please reopen, so we can get it properly tested. Thank you very much for your contribution, making Joomla better. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
An editor allowed to manage some categories and all articles belonging to these categories is also allowed to set the "featured" flag for some of these articles, but he is not able to change the ordering of these featured articles (assume that there is a menu item showing the featured articles within those categories the editor is allowed to manage).
Currently you need the "Edit State" permission for all articles in order to rearrange featured articles, even if you have the "Edit State" permission for all these featured articles.
Use Case
Within a sports club with many divisions we have one editor for each division. There is one top-level category for each division and the editor responsible for a division can administrate this top-level category such that he can add sub-categories when needed, create articles, make these articles featured or unfeatured. There is a separate menu for each sports division with a menu item displaying all featured articles of that division. Each editor is allowed to log in to the backend.
The editors are currently not able to change the ordering of these featured articles. They open the page with the featured articles in the backend, select their categories, set the sort ordering to "Ordering ascending" and rearrange the featured articles by moving them with the mouse to the desired place. At first sight everything looks fine in the backend and there is no error message that changing the order was not possible, but if they reload the respective page in the frontend (or reload the backend page with the featured article list) they get the previous order.
Testing instructions
For testing my PR you need a current Joomla installation with the sample data installed.
Preparation
Create a new user group with the name "Park Site Authors", the parent user group is "Registered".
Set the following permissions for this new user group:
Add this new user group to the access level "Special".
Finally create a new user with the name "Park Site Author", login "psauthor", password ..., mail ... and assign the user group "Park Site Authors" to this user (in doing so you might remove the default user group "Registered").
Note: the editors in the sports club have additional permissions beside those given above (like access to the media section), but these permissions do not interfere with the issue in this PR.
If you think you've seen this setup before - this is true, see PR #19822.
Status Quo
Log in as user "psauthor" and go to Articles. Open the search tools and select the "Animals" category (this is a sub-sub-category of the "Park Site" category). You should now see 4 articles and you should have the right to change them. Make three of them to featured articles.
Next go to Articles: Featured. You should now see the three articles in the "Animals" category and another four articles. Open the search tools and select the "Animals" category. Now you should see only the three featured articles from the "Animals" category. Change the sort ordering to "Ordering ascending".
Rearrange the featured articles, e.g. by moving the first featured article in the list to the end of this list. Note that the list now shows the new ordering and that no error message is displayed.
Reload the page and you'll see that the order of the featured articles is the same as before you rearranged the featured articles.
Changes
First apply this PR.
Then log in as user "psauthor" and repeat all steps described above including reloading the featured articles page. Now the new order of the featured articles is permanent.
A Final Note Regarding Implementation
In investigating this issue I saw that the method
canEditState()inadministrator/components/com_content/models/article.phpis finally executed on behalf of the methodsaveorder()inlibraries/src/MVC/Model/AdminModel.phpin order to check whether the user may edit the state of the given object (featured article), but this method works only for rows from the#__contenttable.But here it gets rows from the
#__content_frontpagetable where neither a columnidnor a columncatidexists. So this method finally calls the parent method which checks whether the user has the "Edit State" permission for all articles.I copied the method
canEditState()from.../article.phpto.../feature.php, changedidintocontent_idand removed the category check (catidfield) since this field doesn't exist in the#__content_frontpagetable.