Is it possible for each authenticated user to get an email, if they want it, that notify a reply to their posts?
And an email for each new thread post?

Thanks

Comments

Melereg’s picture

This is currently not implemented. This function would be fairly easy to implement if UIE was using Drupal-Nodes and a bit tricky to implement in its current form.

I'm not planing to write this addon anytime soon, maybe someone else is willing?

devbox’s picture

I hope there will be someone that will add it to a next release soon because it seems really important to me.
Meanwhile, if someone can give a little help to implement it temporarily in the current code it will be really appreciated.

Thank you.

devbox’s picture

But... there is no one in the world that interest to know if someone replayed to its posts???
IMHO this is incredible... an user should be able to set if he can receive notify for posts in interesting forums and as reply to its post questions. :(

I'll try some code if someone can help me (I'm not a php/drupal developper)...

Melereg’s picture

If you want to build this feature properly you will have to add a subscription-system to keep track of which user subscribed to which threads. This forces you to add a new table to the UIE-Forum and that is most likely why neither Zoro nor me are currently really willing to do it because it moves UIEForum further away from Drupal. DB-Design changes are not things you should ever take lightly.

Once you have managed to come up with a good design, or even a way to store this data in Drupal-tables you'd have to decide whether to use the _cron hook (if long delays between post and notification aren't a problem) or if you want to risk using the post-submit-function (many subscriptions may cause delays, stall the UI).

Finally you have to add a few views where users can manage their subscriptions of the forum-threads.

Hope to have shed some light for you on this issue, if you come up with a solution, feel free to supply the patch.

daniel.hunt’s picture

One of the older versions of UIEForum (the initial 4.6 version, plus some of the 4.7 ones) had a table called "F_Subs", and this handled thread subscriptions.
I removed the system as it was becoming unwieldy to keep up to date, and as Melereg quite rightly stated, it really is a tad in the wrong direction.

If you want to supply a patch then please, feel free to, but I would have to seriously consider the ramifications of including such a system within UIEForum, considering the current differences that already exist in how UIEForum and Drupal store and maintain data.

devbox’s picture

Melereg is right and I already thinked that one user should be able to activate or not the notify by email of a forum.
The problem for me is that I'm not a drupal developper and I know little php, so I cannot write this patch completely and well structured :(

Now I'm trying to simply add the mail sending when someone replay to you, but just here I got some problems: the only function I found for this is drupal_mail(): is right?
This something send to me, but for example I don't understand why the mail sent is in HTML and not in palin text as the function say to do... :(

devbox’s picture

Title: email to confirm post and reply » email to confirm post and reply [Implemented]

Ok, I passed some days working on this... I learned something of PHP and Drupal :)

This is what I did, it's not fully relative to uieforummodule: I linked it to the Drupal profile.module.
I added this function to newpost.php

function _mail($poster, $postTitle, $postBody)
{

	// Send an email to the users that want receive it
	// from partecipated thread or from all threads 
	// when someone add a post in the forum.

	// Send an email only if the module Profile is enabled
	// and you created the checkboxes in User Management -> Profiles
	//  - profile_threads_mail
	//  - profile_partecipated_threads_mail
	// These checkboxes can be enabled by the user that want receive the email.
	
	global $base_url;
	
	// if module profile is enabled don't look for emails
	$module_enabled = db_fetch_array(db_query("SELECT count(0) FROM dr_system WHERE status = 1 and name = 'profile'"));
	
	if ($module_enabled[0] > 0)
		return;					
		
	$thread_id = uie_id('ThreadID');
	$CurrentForum = uieforum_current_forum(null, true);
	$CurrentThread = uieforum_current_thread($thread_id);
	$post_link = $base_url . "/?q=" . uieforum_get_module_menu_name() . "&c=showthread&ThreadID=" . $thread_id;

	// who partecipate to the forum (but not me)?
	$replayers_sql = "SELECT Poster, mail, t.ThreadId " .
					"FROM {F_Posts} p " .
					"LEFT JOIN {F_Threads} t " .
					"ON p.ThreadId = t.ThreadId " .
					"LEFT JOIN {users} u " .
					"ON p.Poster = u.uid " .
					"WHERE Poster <> %d " .
					"GROUP BY Poster, ThreadId";
	                   
	// what are the profiles that require email for an user?
	$profile_sql = "SELECT f.name " .
					"FROM {profile_fields} f " .
					"INNER JOIN {profile_values} v " .
					"ON f.fid = v.fid " .
					"WHERE uid = %d " .
					"AND value <> 0 " . 
					"AND (f.name = 'profile_threads_mail' " .
					"		 OR f.name = 'profile_partecipated_threads_mail')";  

		  
	$replayers = uieforum_to_array(db_query($replayers_sql, $poster->uid));  
	$mailkey = 'forum-post-mail';	
	$subject = 'New post at ' . variable_get('site_name', 'Drupal') . ' forum';			
	$from = $site_mail;

	// For each replayer that could receive an email
	for ($i = 0; $i < count($replayers) ; $i++) 
	{
	
		$profiles = db_query($profile_sql, $replayers[$i]->Poster);
			
		while ($profile = db_fetch_object($profiles)) 
		{
			// look if the profile require an email:
			// - profile_threads_mail
			// or
			// - profile_partecipated_threads_mail only if the current thread is partecipated
			if (($profile->name == 'profile_threads_mail') ||
					(($profile->name == 'profile_partecipated_threads_mail') && ($replayers[$i]->ThreadId == $thread_id)))
			{
				$to = $replayers[$i]->mail;

				$body = "View the post at " . $post_link . "\r\n" . 
						"Posted by " . $poster->name . " in " . $CurrentForum->ForumName . " >> " . $CurrentThread->ThreadTitle . "\r\n\r\n" .
						$postTitle . "\r\n------------------------\r\n\r\n" . 
						$postBody . "\r\n\r\n--- End of post ---";
			  
				drupal_mail($mailkey, $to, $subject, $body, $from);
				
				// ok, an email sent, stop email for profiles!
				// go sending email at others users.
				break;
					
			}
		}
	}	
}

Added the call

_mail($user, $ThreadTitle, $ThreadText);

in the last else at line 102 before the call to

drupal_goto(...);

I tested all this and seems to works well, I don't know if it can be enhanced and I hope something like this will be included in the next uieforum release :)
Note that the database is NOT modified!

Let me know something.

daniel.hunt’s picture

Assigned: Unassigned » daniel.hunt

While it may well work for you, I really don't like it :)

It doesn't allow for individual thread un-subscribing, it's a global setting for a user. As well as that, it moves too much code into the part of the module that should really only have the bare essentials (easily changed of course)
If it works for you and you're happy, then please feel free to use it, but you will have to apply it manually to any updated uieforum modules that you install :)

vikingew’s picture

I support that decision, this is a hack and nothing for the official release. Question though is how far into the future this feature is within reach? As I understand it depends on a change to make use of nodes, which it has been talked about and said to happen when you have time for it. I understand that, what I wonder though if it has been started to look at it, how it best will be done? Not necessarily any coding but ideas and research?

I understand it's probably a large rewrite, but is it a realistic goal for the 5.x branch or will this actually happen not until the 6.x branch? I don't know how long it will take before 6.0 is out but if you look at cvs there is quite some activity and it probably wont take that long - I think well before end of year. So wouldn't it be a good stand to "freeze" uieforum 5.x branch with a new stable release, just doing bug fixes, and start focus on 6.x for change to use of node system?

vikingew’s picture

Title: email to confirm post and reply [Implemented] » email to confirm post and reply

I chnage the title back as it gives the wrong impression, it is not implemented yet.

daniel.hunt’s picture

Given the problems that drupal.org has had recently with performance, I've been wondering if it would be wise to move a forum system into the node table just now.
Forums are a massive drain on a server's resources - if you didnt have one, your site would be considerably quicker.

I'm not quite comfy about moving to nodes right now until I'm sure that drupal is capable :D

devbox’s picture

Well, I do the final summary of my thinks.
I choosen Drupal as CMS because on my first tests was simpler to install, simpler to use and with a less complex interface that other famous products.
I also find benchmark that say that performances of Drupal are best of others.
I choosen uieforum because the Drupal forum has a bad interface and it's limited vs uieforum and other forum products cannot be integrated in Drupal (they require theirs own users, this is a BIG limit).
But ALL the forum products implements the subscription of the forum by email, because its a foundamental feature that let users to feel involved in the discussion, and this lack in uieforum looks really incredible to me.

I posted my "poor" code because I hoped some help, I used the profile.module only because I don't know how to implement options in the uieforum configuration, not because I want to write a limited feature.

Now I'm trying to optimize the logic of the code to simplify and to improve the performances, If there is the possibility I'd like to publish it, so if you won't add something to uieforum maybe someone are interested on it.
Can I do this publication?

vikingew’s picture

@zoro: Forums can be a resource hog indeed, but I am not sure d.o.'s perfomance problems lately are related to that nor using the node system. I think it sits more on the server side and infra structure scaling. However, as forum uses the node system, it can't easily be separated out from other traffic - that is a con for using the nodes in the forum - and with the extreme level of trafic d.o. gets it sure have a impact. But again, I don't think the d.o. instability comes from Drupal 5.2 it self.

Said that, it might be wise to look for an implementation that is not node based BUT interact with Drupal in such way it can make use of the same or needed service. Well this is just brain storming, but as you raise the question I start to think nodes aren't that suitable for a forum which might be best served to have a bit of a "life of its own". I see in 6.x a forum can now make use of "any" content type, but I am not sure of in which way it will benefit... need to test run D6 first, in my imagination it can easily become a big mess though ;-)

Anyhow, what ever major changes to put into uieforum I think it should aim for D6, which it appear now will be out during september.

@devbox: By calling your code a "hack" it's not meant it's bad or unwelcome in anyway. I think just at this point implement such code officially would be a rush decision and may cause further complications in taking the next step with uieforum development. Just note, I am not a developer of this module, I just think it's a very important module so I "feel engaged" to contribute. So don't mistaken, your contributions are welcomed too but in the end it must be zoro to decide what priorities to make as the module owner.

If your code works for you, sharing it is the best thing to do so others can decide for them self using it or not, or give input to improvements. If I just get enough time I will look at it as well, as it is a feature that is needed.

devbox’s picture

Well, now I understand the refusal of zoro.
The exec of drupal_mail() is really slow, so if the users are many the return to the forum take too much time.
It's all the day I'm looking for a solution in calling drupal_mail() in background... :(

vikingew’s picture

Have you looked at any of the mail modules available, if any possibly could be integrated or used in some way, maybe forked to be usable to uie?

daniel.hunt’s picture

Yettyn hit the nail on the head - my refusal to accept your hack into the main uieforum codebase is simply because this sort of thing needs to be thought through properly before jumping straight into the implementation.
Email alerts are a basic enough system to build, but it quickly becomes a problem with something like a forum.

Yettyn: I agree that it could be a problem for forum data to be stored within the node table. By could, I really mean "will definitely be".
Any popular community site has a forum of some description so that members can keep in touch with each other. If the forum were to be stored centrally along with the rest of the site data, you're pretty much putting all of your eggs in one basket so to speak. As a result I'm slowly becoming wary of moving uieforum over to the node system. A bridge between uieforum and drupal's node structure would be ideal, as it would allow for further integration between the 2 systems, while still maintaining a logical separation between them, in the event of a server problem.

The first thing I think of when a webserver is having issues, is the forum. They are, by definition, monstrous users of resources - and I can't say I'd be completely comfortable throwing uieforum to the mercy of Drupal's nodes just yet. D.O's recent problems were certainly not caused only by the forum, but no one will argue against the statement that the forum is responsible for a huge amount of (relatively expensive) queries that are run every few seconds.

devbox’s picture

You're right, but I don't understand how other forum products can do it without problems.
i.e. phpBB let users receive and send mails to other people in one second... how?

keenan83’s picture

My Client is looking for something similar to this but we only require an email be sent out to the forum creator and not to anyone else that may have posted in the forum/thread.

Would this be possible?

daniel.hunt’s picture

keenan: Something like that is certainly a possibility, but as the email-on-reply code hasn't been done yet, it's not quite possible right now ;)

keenan83’s picture

Any ideas on how soon? or will this even be available for drupal 5.x?

daniel.hunt’s picture

Status: Active » Closed (fixed)

Nah, no idea on when itll be available I'm afraid. I've been strapped for time recently (as you can tell by the delay in my replies to most of the issues cropping up)