Pagina 1 van 1

forumwatch niet blijven mailen als je nog niet gekeken hebt.

Geplaatst: 26 sep 2007, 10:55
door volgensbartjes.nl
  • Adres van je forum: http://leden.musicalwognum.nl
    Event. modificaties op je forum:forum watch van cosmic_invaders. (http://www.phpbb.com/community/viewtopi ... &sk=t&sd=a)
    Wanneer ontstond het probleem?altijd al aanwezig
    phpBB versie: 2.0.22

    Heb je onlangs iets verandert aan je forum?nee
    Wat is het probleem?
    Ik heb al aan het begin dat ik het forum in gebruik nam, forum watch geinstalleerd. Nu kregen veel mensen geen mailtjes, daar ben ik mee bezig om het op te lossen. Maar ik heb nu ook nog een ander probleem, déze forum watch mailt iedere keer als er gereageerd word, en niet zoals de ingebouwde topic watch, pas als je een keer hebt gekeken. Is er iemadn die dat zo kan maken (misschien makkelijk kopieren vanuit de topic watch funtie?). Als er nu dus een onderwerp wordt aangemaakt krijgt iemand een mailtje, als ik dan ga kijken, ik sluit weer af, en er reageerd iemand, moet k ook een mailtje krijgen, maar als er daarna nóg 3 mensen reageren, en ik kijk pas een paar uur daarna weer op mijn mail moeten er niet 3 nieuwe mails staan.
    Ik hoop dat iemand mij hier zsm mee kan helpen, want ik dacht dat ik alles nu op orde had, maar nu krijgt iedereen een beetje veel mails, ook een beetje lullig.
    Mvg,
    Bart Huisman

..

Re: forumwatch niet blijven mailen als je nog niet gekeken hebt.

Geplaatst: 29 sep 2007, 10:47
door volgensbartjes.nl
onderstaand de codes, misschien dat iemand het dan beter begrijpt. ik heb functions_post.php, daarin staat een stuk voor forum watch:

Code: Selecteer alles

//
// Forum watch
//

function forum_watch($mode, &$post_data, &$s_title, &$forum_id, &$topic_id, &$post_id, &$notify_user)
{
        global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
        global $userdata, $user_ip;


        $current_time = time();

        if ($mode == 'delete')
        {

/*    I should not be deleting this !!! 
*     Thanks to malbano at phpBB forums - he brought my attention to this...
*     http://www.phpbb.com/phpBB/viewtopic.php?p=1277605
*     :-)
*/

/*

                $delete_sql = " AND user_id = " . $userdata['user_id'];
                $sql = "DELETE FROM " . FORUM_WATCH_TABLE . " WHERE forum_id = $forum_id" . $delete_sql;
                if (!$db->sql_query($sql))
                {
                        message_die(GENERAL_ERROR, 'Could not change forum notify data', '', __LINE__, __FILE__, $sql);
                }
*/

        }
        else
        {
                if ($mode == 'reply' || $mode == 'newtopic')
                {
                        $sql = "SELECT ban_userid
                                FROM " . BANLIST_TABLE;
                        if (!($result = $db->sql_query($sql)))
                        {
                                message_die(GENERAL_ERROR, 'Could not obtain banlist', '', __LINE__, __FILE__, $sql);
                        }

                        $user_id_sql = '';
                        while ($row = $db->sql_fetchrow($result))
                        {
                                if (isset($row['ban_userid']) && !empty($row['ban_userid']))
                                {
                                        $user_id_sql .= ', ' . $row['ban_userid'];
                                }
                        }

			
			// Removed the earlier "individual queries" in favor of the following query to reduce SQL processing time.
			$sql = "SELECT f.forum_name as forum_name, t.topic_title as topic_title, 
					pt.post_subject as post_subject, pt.post_text as post_text 
				FROM " . POSTS_TABLE  . " p 
					LEFT JOIN " . POSTS_TEXT_TABLE . " pt ON pt.post_id = p.post_id 
					LEFT JOIN " . FORUMS_TABLE . " f ON p.forum_id = f.forum_id 
					LEFT JOIN " . TOPICS_TABLE . " t ON p.topic_id = t.topic_id 
				WHERE p.post_id = $post_id ";


                        if (!($result = $db->sql_query($sql)))
                        {
                                message_die(GENERAL_ERROR, 'Could not obtain information about the new post.', '', __LINE__, __FILE__, $sql);
                        }

                        $forum_title = '';
                        $topic_title = '';
                        $post_subject = '';
                        $post_text = '';
                        $row = $db->sql_fetchrow($result);

                        if($row != false)
                        {
				$forum_title = $row['forum_name'];
				$topic_title = $row['topic_title'];
                                $post_subject = strip_tags($row['post_subject']);


                                $post_text = strip_tags($row['post_text']);

				// lets strip the bbcodes here..

        			// Remove URL's
			        $post_text = preg_replace('/\b[a-z0-9]+:\/\/[a-z0-9\.\-]+(\/[a-z0-9\?\.%_\-\+=&\/]+)?/', ' ', $post_text);
			        // Quickly remove BBcode.
			        $post_text = preg_replace('/\[img:[a-z0-9]{10,}\].*?\[\/img:[a-z0-9]{10,}\]/', ' ', $post_text);
			        $post_text = preg_replace('/\[\/?url(=.*?)?\]/', ' ', $post_text);
			        $post_text = preg_replace('/\[\/?[a-z\*=\+\-]+(\:?[0-9a-z]+)?:[a-z0-9]{10,}(\:[a-z0-9]+)?=?.*?\]/', ' ', $post_text);


                        }

                        $sql = "SELECT u.user_id, u.user_email, u.user_lang
                                FROM " . FORUM_WATCH_TABLE . " fw, " . USERS_TABLE . " u
                                WHERE fw.forum_id = $forum_id
                                        AND fw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")
                                        AND fw.notify_status = 1
                                        AND u.user_id = fw.user_id";
                        if (!($result = $db->sql_query($sql)))
                        {
                                message_die(GENERAL_ERROR, 'Could not obtain list of forum watchers', '', __LINE__, __FILE__, $sql);
                        }

                        $update_watched_sql = '';
                        $bcc_list_ary = array();

                        if ($row = $db->sql_fetchrow($result))
                        {
                                // Sixty second limit
                                @set_time_limit(60);

                                do
                                {
                                        if ($row['user_email'] != '')
                                        {
                                                $bcc_list_ary[$row['user_lang']][] = $row['user_email'];
                                        }
                                        $update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['user_id'] : $row['user_id'];
                                }
                                while ($row = $db->sql_fetchrow($result));

                                //
                                // Let's do some checking to make sure that mass mail functions
                                // are working in win32 versions of php.
                                //
                                if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery'])
                                {
                                        $ini_val = (@phpversion() >= '4.0.0') ? 'ini_get' : 'get_cfg_var';

                                        // We are running on windows, force delivery to use our smtp functions
                                        // since php's are broken by default
                                        $board_config['smtp_delivery'] = 1;
                                        $board_config['smtp_host'] = @$ini_val('SMTP');
                                }

                                if (sizeof($bcc_list_ary))
                                {
                                        include_once($phpbb_root_path . 'includes/emailer.'.$phpEx);
                                        $emailer = new emailer($board_config['smtp_delivery']);

                                        $script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
                                        $script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
                                        $server_name = trim($board_config['server_name']);
                                        $server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
                                        $server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';

                                        $orig_word = array();
                                        $replacement_word = array();
                                        obtain_word_list($orig_word, $replacement_word);

                                        $emailer->from($board_config['board_email']);
                                        $emailer->replyto($board_config['board_email']);

                                        $s_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($s_title)) : unprepare_message($s_title);

                                        @reset($bcc_list_ary);

                                        while (list($user_lang, $bcc_list) = each($bcc_list_ary))
                                        {
                                                $emailer->use_template('forum_notify', $user_lang);


                                                for ($i = 0; $i < count($bcc_list); $i++)
                                                {
                                                        $emailer->bcc($bcc_list[$i]);
                                                }

                                                // The Topic_reply_notification lang string below will be used
                                                // if for some reason the mail template subject cannot be read
                                                // ... note it will not necessarily be in the posters own language!
                                                $emailer->set_subject($lang['Topic_reply_notification']);

                                                // This is a nasty kludge to remove the username var ... till (if?)
                                                // translators update their templates
                                                $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);


						// Include only the first 50 words...
						$post_text_words=split(" ",$post_text); 
						$trunc_post_text_words = join(" ",array_slice($post_text_words,0,50)) . "..."; 

                                                $emailer->assign_vars(array(
                                                        'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
                                                        'SITENAME' => $board_config['sitename'],
                                                        'USERNAME' => $userdata['sitename'],
                                                        'TOPIC_TITLE' => $topic_title,
                                                        'FORUM_TITLE' => $forum_title,

                                                        'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id",
                                                        'POST_SUBJECT' => $post_subject,
                                                        'POST_TEXT' => $trunc_post_text_words)
                                                );

                                                $emailer->send();
                                                $emailer->reset();
                                        }
                                }
                        }
                        $db->sql_freeresult($result);
                }
        }
}

//
// End Forum watch
//
en een stuk voor topic watch (standaard al ingebouwd) :

Code: Selecteer alles

//
// Handle user notification on new post
//
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user)
{
	global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
	global $userdata, $user_ip;

	$current_time = time();

	if ($mode != 'delete')
	{
		if ($mode == 'reply')
		{
			$sql = "SELECT ban_userid 
				FROM " . BANLIST_TABLE;
			if (!($result = $db->sql_query($sql)))
			{
				message_die(GENERAL_ERROR, 'Could not obtain banlist', '', __LINE__, __FILE__, $sql);
			}

			$user_id_sql = '';
			while ($row = $db->sql_fetchrow($result))
			{
				if (isset($row['ban_userid']) && !empty($row['ban_userid']))
				{
					$user_id_sql .= ', ' . $row['ban_userid'];
				}
			}

			$sql = "SELECT u.user_id, u.user_email, u.user_lang 
				FROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u 
				WHERE tw.topic_id = $topic_id 
					AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ") 
					AND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . " 
					AND u.user_id = tw.user_id";
			if (!($result = $db->sql_query($sql)))
			{
				message_die(GENERAL_ERROR, 'Could not obtain list of topic watchers', '', __LINE__, __FILE__, $sql);
			}

			$update_watched_sql = '';
			$bcc_list_ary = array();
			
			if ($row = $db->sql_fetchrow($result))
			{
				// Sixty second limit
				@set_time_limit(60);

				do
				{
					if ($row['user_email'] != '')
					{
						$bcc_list_ary[$row['user_lang']][] = $row['user_email'];
					}
					$update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['user_id'] : $row['user_id'];
				}
				while ($row = $db->sql_fetchrow($result));

				//
				// Let's do some checking to make sure that mass mail functions
				// are working in win32 versions of php.
				//
				if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery'])
				{
					$ini_val = (@phpversion() >= '4.0.0') ? 'ini_get' : 'get_cfg_var';

					// We are running on windows, force delivery to use our smtp functions
					// since php's are broken by default
					$board_config['smtp_delivery'] = 1;
					$board_config['smtp_host'] = @$ini_val('SMTP');
				}

				if (sizeof($bcc_list_ary))
				{
					include_once($phpbb_root_path . 'includes/emailer.'.$phpEx);
					$emailer = new emailer($board_config['smtp_delivery']);

					$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
					$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
					$server_name = trim($board_config['server_name']);
					$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
					$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';

					$orig_word = array();
					$replacement_word = array();
					obtain_word_list($orig_word, $replacement_word);

					$emailer->from($board_config['board_email']);
					$emailer->replyto($board_config['board_email']);

					$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title);

					@reset($bcc_list_ary);
					while (list($user_lang, $bcc_list) = each($bcc_list_ary))
					{
						$emailer->use_template('topic_notify', $user_lang);
		
						for ($i = 0; $i < count($bcc_list); $i++)
						{
							$emailer->bcc($bcc_list[$i]);
						}

						// The Topic_reply_notification lang string below will be used
						// if for some reason the mail template subject cannot be read 
						// ... note it will not necessarily be in the posters own language!
						$emailer->set_subject($lang['Topic_reply_notification']); 
						
						// This is a nasty kludge to remove the username var ... till (if?)
						// translators update their templates
						$emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);

						$emailer->assign_vars(array(
							'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
							'SITENAME' => $board_config['sitename'],
							'TOPIC_TITLE' => $topic_title, 

							'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id",
							'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_TOPIC_URL . "=$topic_id&unwatch=topic")
						);

						$emailer->send();
						$emailer->reset();
					}
				}
			}
			$db->sql_freeresult($result);

			if ($update_watched_sql != '')
			{
				$sql = "UPDATE " . TOPICS_WATCH_TABLE . "
					SET notify_status = " . TOPIC_WATCH_NOTIFIED . "
					WHERE topic_id = $topic_id
						AND user_id IN ($update_watched_sql)";
				$db->sql_query($sql);
			}
		}

		$sql = "SELECT topic_id 
			FROM " . TOPICS_WATCH_TABLE . "
			WHERE topic_id = $topic_id
				AND user_id = " . $userdata['user_id'];
		if (!($result = $db->sql_query($sql)))
		{
			message_die(GENERAL_ERROR, 'Could not obtain topic watch information', '', __LINE__, __FILE__, $sql);
		}

		$row = $db->sql_fetchrow($result);

		if (!$notify_user && !empty($row['topic_id']))
		{
			$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
				WHERE topic_id = $topic_id
					AND user_id = " . $userdata['user_id'];
			if (!$db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Could not delete topic watch information', '', __LINE__, __FILE__, $sql);
			}
		}
		else if ($notify_user && empty($row['topic_id']))
		{
			$sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
				VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
			if (!$db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Could not insert topic watch information', '', __LINE__, __FILE__, $sql);
			}
		}
	}
}
bij het kijken naar wie het gestuurd moet worden kijkt de 2e blijkbaar of sinds de laatste post de gebruiker het topic al heeft bezocht. Alleen als hij hem al heeft bezocht wordt het bericht verstuurd.
Ik heb alleen geen idee welk stukje van de code dat is. Als iemand het weet, kan die dat misschien in de eerste code ook toevoegen? als er een nieuw topic wordt gestart, en de vorige is nog niet bekeken moet de mail wel gewoon verstuurd worden, gaat puur om het zelfde als bij de topic watch, als iemand een reactie plaatst, dat hij dán wel of niet een mail stuurt...
Alvast bedankt,
Bart

Re: forumwatch niet blijven mailen als je nog niet gekeken hebt.

Geplaatst: 06 okt 2007, 21:45
door Ramon Fincken
Bart,

ik heb die mod ook op 1 van mijn forums lopen en werkt perfect.
Ik raad je dus even aan alles na te lopen ..


Ramonn