Posted by davbusu on October 30, 2008 at 4:56pm
18 followers
| Project: | Drupal core |
| Version: | 6.13 |
| Component: | contact.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | davbusu |
| Status: | closed (won't fix) |
Issue Summary
The title says all.
I attached files contact.module and contact.pages.inc.
for newbies: they are in .txt format because attachment of .inc and .module files arent allowed...just rename the file
I didn't check out how to use patch because im pressed for time to finish the site, but thought it would be useful for people out there who want this feature and i think it could be included in future releases... the only 'dirty' part of the code was that when an anonymous user uses the personal contact form, in drupal_mail i used 'page_mail' as they key parameter instead of 'user_mail' .. maybe this issue can be sorted by adding 'user_mail_anon' for e.g. to make the code neither..
tellah:)
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| contact.module.txt | 10.94 KB | Ignored: Check issue status. | None | None |
| contact.pages_.inc_.txt | 9.13 KB | Ignored: Check issue status. | None | None |
Comments
#1
forgot to mention.. i used 'page_mail' so when the email is sent it, rather then receiving:
one would receive:
#2
the issue to be solved at stated is to create a function for e.g. user_mail_anon which basically is the same as page_mail but this part would also appear:
Also it would be great if the url is enclosed in brackets like in user_mail to have more consistency
#3
ok i managed to do it...find attached new contact.module and contact.pages.inc
I added key user_mail_anon which is basically the same as user_mail but doesn't displays user's page (user/0)..here is an example of the received email:
furthermore i modified a bit page_mail so it displays subject as [SITENAME/CATEGORY] SUBJECT rather then [CATEGORY] SUBJECT and the content of the mail is of the format:
#4
Please post your 6.x patches in this issue #58224: Allow anonymous users access to a members personal contact form. Also note there is the Anonymous Contact module that could use help being ported to 6.x since it is unlikely this issue will be something backported to 6.x from HEAD.
#5
Hey, I know something.... How about posting 6.x patches here and not in #58224: Allow anonymous users access to a members personal contact form?
That way the people in #58224 won't have to complain about the D6 patches obstructing D7 development. And I bet we won't confuse the testing robot either.
I did look in #58224 for patches, took the files posted in comment #193, incorporated two changes from the patch in #148
(fixed the watchdog message; made a separate form validate function) and modified things so it applies cleanly to Drupal 6.13 again. So this should work for some people who want to patch the newest D6 instead of using the contact_anon module.
#6
Great idea, I'll give it a try and report back on it here.
#7
Perfect work.
I've downloaded and applied the patch, adjusted the permissions for anonymous users and I got the personal contact links and forms straight away. Just exactly what was required.
I wonder if that could make it's way into 6.x core?
#8
This patch doesn't seem to help. I get this message:
"You need to provide a valid e-mail address to contact other users. Please update your user information and try again."
and nothing I do seems to change it. I'm actually quite flummoxed right now.
#9
@jurgenhaas: This topic has been beaten to death, and there's hardly any possibility it will get included into D6 core. (I believe most people were against it because it would open up too much possibility for people to spam your site users. But there may have been other reasons - I didn't read up on every detail.)
So it looks like the faith of this patch is to live forever in this thread marked 'duplicate', until it eventually dies out along with D6 installations, a few years from now. I know no better place for it.
@binford2k: it looks like you can only get that message when you are logged on already, i.e. not an anonymous user. (In which case the patch does not have any effect; you should also get that same message without having patched the module.)
And it looks like you need to need to check your account settings to see that you really have specified a valid e-mail address. If your e-mail address IS valid... I have no clue what's going on.
#10
No, the anonymous user gets this error message. Works fine for the authenticated user. Without this patch, the anonymous user gets the usual auth error.
#11
I don't know what to tell you without more info (and don't really know what info to ask for, to be able to trace the error). It works for me...
#12
Drupal 6 is feature frozen.
#13
I don't understand it. Here is my contact_user_page function:
function contact_user_page($account) {
global $user;
die;
if ($user->uid && !valid_email_address($user->mail)) {
$output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit")));
}
else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
$output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
}
else {
drupal_set_title(check_plain($account->name));
$output = drupal_get_form('contact_mail_user', $account);
}
return $output;
}
With that
diein there, it should crap itself on every run. Yet it has absolutely no effect. If I change thecontact_mail_userfunction just a few lines down in the file, it's reflected immediately.It's like
contact_user_pageisn't being called at all; or it's being cached in a really weird way. Anyone know what's going on?#14
Tracked down the problem. Realname conflicts. Hack patch below:
--- realname.module.orig 2009-07-17 02:13:31.000000000 -0700
+++ realname.module 2009-07-17 02:13:44.000000000 -0700
@@ -206,7 +206,7 @@
function realname_contact_user($account) {
global $user;
- if (!valid_email_address($user->mail)) {
+ if ($user->uid && !valid_email_address($user->mail)) {
$output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit")));
}
else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
#15
#5 patch works ok, thank You:)
#16
I would very much like to use the patch from #5 but I too have RealName module installed. Every time I try using the hack patch from #14 I get the error: **** malformed patch at line 5: function realname_contact_user($account) {
Could someone point me in the right direction?
Thanks!
#17
Just do it by hand. Go to line #206 and find the text
if (!valid_email_address($user->mail)) {Replace it with
if ($user->uid && !valid_email_address($user->mail)) {Btw, the first line wasn't actually part of the patch, it was the command I used to generate it. I'll go edit that post and fix it!
#18
Sorry for being a newbie, I don't understand which file I need to patch against.
#19
#5 no longer applies to the latest d6 (6.15 at this point) - looks like some changes in how they show the form to users. Anyone have an updated version? I'm working on it but if someone is done already that would be helpful....
(This might be #10's problem?)
UPDATE - the patch fails because of the commit in 6.15 from http://drupal.org/node/525504. The majority of the patch is fine except for the section that controls contact tab access:
@@ -118,9 +118,9 @@
$account->contact = FALSE;
}
return
- $account && $user->uid &&
+ $account &&
(
- ($user->uid != $account->uid && $account->contact) ||
+ (user_access('access personal contact form') && ($user->uid != $account->
uid) && $account->contact) ||
user_access('administer users')
);
}
This should now add the following section:
+ // Anonymous users can access the contact form with proper permissions
+ if (user_access('access personal contact form')) {
+ return TRUE;
+ }
as the first if statement under
function _contact_user_tab_access($account) {
global $user;
and before
// Anonymous users cannot use or have contact forms.
if (!$user->uid || !$account->uid) {
return FALSE;
}
If this seems correct and someone can roll a new patch with this it would be great. I would but I have other changes in my contact module that I don't want to accidentally incorporate into the patch....
#20
Oh. Right. Forgot about this. Well, here's a diff between d6.15 and my current working tree... Seems OK.
#21
I'll be putting this feature backport into http://drupal.org/project/contact.
#22
Thank you. I just finished hacking a backport from the D7 version of this thread, but I'm glad to see something being done for those who aren't as techno savvy. Thanks for the correction on the d7 thread, dave and roderik. I'll try to find d6 threads and reply to them hence forth so as to not hinder d7 development. Again, thanks for the prompt solutions.
#23
Hi roderik,
This patch seems to work fine against 6.16 as well, although I patched contact, duplicated it, and renamed every 'contact_' to 'contact_anonymous_' and every 'contact. to 'contact_anonymous.' so I could separate the patched module, and update to core at any time without losing the changes. Of course, I don't know what will happen if I have both enabled, as they share menu item, so I don't!
Thanks for your patch, it works great.
#24
This module does not work for me.
I get the new permission, but
1) I get database errors when switching from core "contact" to the new "contact _anonymous"
2) the Views field "Link to contact page" has gone
Side question:
What is the difference between this module and this one?
http://drupal.org/project/contact/
Thanks
#25
Damn. Hopefully I've not stepped on anyones toes with this.
I've just contributed a module to do this. It's quick and dirty and could do with a decent amount of enhancement but it scratched the itch my client had and didn't require hacking core files.
http://drupal.org/project/anonymous_contact
If people want to add to this project I'm happy to offer cvs access for a couple of co-maintainers.
#26
#23 works perfectly for drupal 6.19. Thanks.
#27
I am also using 6.19 but #23 doesn't work for me and I'm not sure why (and I'd really really really like it to work for me).
I get the following error:
Any help would be very appreciated :-)
#28
Not sure what shall I do with #23
Substitute it from the modules/contact or only add it to that folder?
or shall I add it like any other contributed module?
Thanks
#29
Forget #23
Use #25
http://drupal.org/project/anonymous_contact
#30
#23 worked for me, running 6.22
I think from an amateur developer point of view its a bit more elegant than #25 because it uses the standard contact form found in user's profile pages.
I do, however, miss the view's links - not sure why those went away, but it appears as though the "User: link to contact form" is missing from the User fields... any way to add this back in?
Thanks,