Closed (duplicate)
Project:
Question/Answer
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Jul 2012 at 17:06 UTC
Updated:
1 Aug 2012 at 06:34 UTC
Jump to comment: Most recent file
Comments
Comment #1
jcisio commentedAs I committed the other patch, this one needs to be rerolled. Also, I've a few comments:
- Permission name should be "deselect best answer on any question"
- I don't think we want the check $user->uid == 0
- I don't think we want the author to deselect the best answer (he should be responsible, or we need another permission "... on own question")
- You forgot to check the token (to avoid CSRF)
I hope I don't miss anything.
Comment #2
ec commentedHi,
Here is a new patch for the last dev. It takes into account all your previous remarks but the third one. Because I don't understand your point about the author of the question not able to change his/her mind and want to remove a best answer he/she has previously selected, no? May be you can elaborate a bit more on your point of view.
Best,
EricC
Comment #3
ec commentedComment #4
jcisio commentedI think to cancel an answer is a new permission, and it is for administration purposes only. So, there are cases that we don't want this ability to cancel an answer for node author, we have to separate this permission.
Comment #5
ec commentedOk. There is now a new perm
deselect best answer on own questionwhich is checked for the author of the question.Comment #6
jcisio commentedPlease test this one. I've rename the permissions to align with the other permission ("for" instead of "on" - I think). I've also changed some wording, but the patch is practically the same.
I've also noticed some problems. I wrote this module long time ago, the last stable release was on 2010, so it sure has problems. I write it here so that I won't forget to create new issues (each needs a separate issue, or merge into existing one, I don't have time now).
- Don't use node_save() for updating the choice. Use field_attach_update in D7 and ... in D6 (I'm sure that function exists, but I can't remember right now).
- Menu access control overhaul: there was no permission, so menu callback was checking only if user is logged (which is not necessary), and the whole logic is in hook_link. I'm sure we can refactor the code (now, duplicate code is starting to appear), has a better access control implementation.
- We would need to reload the page in many cases. I also think
drupal_goto($_SERVER['HTTP_REFERER']);could be changed todrupal_goto();Comment #7
ec commentedHi,
Thanks for the patch and the comments. Hopefully I have taken all your mods into account. I'm afraid I'm not a developer so I am unable to address all the issues you have mentioned, however in the following patch I have refactored the code to avoid duplicates.
- I have introduced a new function
question_answer_build_linkwhich is used to build the links array;- I have modified the function
question_answer_selectto make it work forselect,deselectand the upcomingchange. It has been renamedquestion_answer_action.It will now be very easy to introduce the
changelink I have proposed here https://drupal.org/node/1689280.Please let me know,
EricC
Comment #8
jcisio commentedI wrote them just to remind me for tasks, not to implement all of them in this issue. So don't worry (and my excuse).
Did you test it? ;-)
This involves in many changes, so I hope someone else could test it, too.
Comment #9
ec commentedI understood them this way too, so it's Ok.
yes I have it running on my sandbox, with
changeandtop level comment only. And it will soon find its way on a production site., yes. However IMHO, with the last code refactoring, your module stays small and as simple as it was before the new features.
Here is a new patch, with a small fixe and some wording. Mainly I forgot to change the
$items['question_answer/select']to make it use the new generic functionuestion_answer_action! Apart from this it should run with no problem ;-)Best,
EricC
Comment #10
ec commentedComment #11
jcisio commentedLet's say it duplicates #1689280