Closed (fixed)
Project:
Privatemsg
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Feb 2009 at 23:50 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
litwol commentedthis one is definitely not critical for 1.0, this is API improvement so it should go in no sooner than 2.0.
Comment #2
berdirThis makes sense to include now imho. Always returning an array makes things really nicer. And as part of this, I also fixed the user blocking bug, see below.
Changes in that patch:
- Return array with success message, errors and warnings
- Slightly changed privatemsg_new_thread and privatemg_reply to work with updated validate function
- Some changes to pm_send_validate to output errors and warnings
- Pass $message by reference to _privatemsg_validate_message and remove $author and $show_warnings parameter. $author is already included in $message, $show_warnings is not needed anymore and the by reference change fixes the broken user blocking.
- change pm_send to display only usernames to which the message was sent, excluding blocked users..
Note:
- _privatemsg_send currently simply overwrites the 'success' key in privatemsg_new_thread and reply... if something would fail inside that function and we add checks to actually return false, this would mean that success would be FALSE but there aren't any errors...
Comment #3
berdirPatch got lost...
Comment #4
berdirWhat about the following:
returned array is built up like the following:
The array is returned by _privatemsg_message_validate, which has a boolean flag if the current page is a form. The $messages array and the $flag are forwarded to the validate hook, too. If the flag is set, the validate function and hooks will/should set errors with form_set_error instead of adding them to $messages.
As $messages is passed around as a whole, validate hooks can add errors, warnings, notices, ... . It could for example be printed with the following code:
Or a module invoking privatemsg_new_thread could decide to only display errors.
Related to that is the question if validate should be by reference or not, see #376023-1: #288183 followup: change hook_privatemsg_block_message to work on multiple recipients.
Comment #5
berdirHere is a updated patch
- added a $form flag, if set to true, sub modules should use form_set_error to report errors
- $messages array, where all modules can store information according to the dsm types.
Comment #6
berdirComment #7
berdirUpdated patch
- updated and added privatemgapi.test
- Changed parameters for new_thread and reply because body is now optional. It also allows to add options directly to the $message array.
Comment #8
berdirMinor changes in the validate function (user permission check) and some coding style fixes.
Would be great if someone with simpletest 2.x-dev could run the tests..
- First as is
- If that works, change $recipient2 to $recipient1 on line 88 and/or 91 and check if still works.
I'm having permission issues and I can't figure out why. Also, it seems that others can't reproduce it: #385152: Clear user_access() cache
Comment #9
berdirFound the reason for the failing tests, it was the static cache of user_access. See the link above.
Added same fixes for permission checking and a workaround for the mentioned bug. Should be ready now..
Comment #10
berdirRe-roll with a fixed bug in privatemsg_reply() (thread_id was not used).
Comment #11
berdirRe-roll.
Comment #12
naheemsays commentedwith this patch applied, when there are invalid users, there is a duplicated message as the invalid check and the error message is given twice:
So from the patch just remove
and it is ready to go.
Comment #13
naheemsays commentedFixed bit in comment 12 and I am pretentious enough to set this to rtbc.
Comment #14
naheemsays commentedComment #15
litwol commentedIts in. thanks.
It needs API doc. for example its not very clear at first what $form = false/true does. also that function serves 2 purpses deppending on the context in which its called (also based on $form argument).
Comment #16
berdirSomehow the api tests got lost when nbz rerolled the patch :)
Re-uploading them.
Comment #17
litwol commentedConsidering that tests are only developer facing, this doesn't require must review. and in it goes ...