Forum Watch - Notify All Forum Message to Moderators
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexCPG-BB (forum)
Author Message
Aforo
I18N / L10N Lead Dev


Joined: Dec 27, 2007
Posts: 146

PostPost subject: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 2:56 am
Reply with quote

Yesterday, thinking about the problem of my moderators in same forums (they wan't to know when a user post in their forum, specially new topics) I was reading some post here and I thought that this can not be so difficult...

Many people asking:
dragonflycms.org/Forum...c/t=23384/
dragonflycms.org/Forum...c/t=14134/
dragonflycms.org/Forum...ic/t=2314/

But solutions are not nice...

Wel I was working and I think that I solved most of the problem. In 10 minutes you can have a option for watching a forum (take care with opening this option to all user if you have a big site because your mail server can be "ill" at the end of the afternoon). Also is the forum is very alive... it's not so usseful.

www.webnaranja.com/upl..._forum.jpg

Follow this short proccess and youll get this link (working) for watching all the messages in your forums.

Let's go step by step. (If you need Support in Spanish Language follow this other link: www.webnaranja.com/foros.php?t=372

_________________
Aforo - Google Earth - WebNaranja - DFcms.es

Aforo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Centos 5/Apache 2.2.3/MySQL:5.0.45/PHP:5.2.10 /9.2


Last edited by Aforo on Sat Jan 10, 2009 3:24 am; edited 1 time in total
Back to top
View user's profile Visit poster's website
Aforo
I18N / L10N Lead Dev


Joined: Dec 27, 2007
Posts: 146

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:00 am
Reply with quote

1 step create table forums watch

Go to your database and Mysql :

Quote:
--- Create Forum Notify table -------

CREATE TABLE nuke_bbforums_watch (
forum_id smallint(5) unsigned NOT NULL default '0',
user_id mediumint(8) NOT NULL default '0',
notify_status tinyint(1) NOT NULL default '0',
KEY forum_id (forum_id),
KEY user_id (user_id),
KEY notify_status (notify_status)
);

notify_status will not be used, but I mantain it because can be usseful in future and because in PHPbb they use it.

_________________
Aforo - Google Earth - WebNaranja - DFcms.es

Aforo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Centos 5/Apache 2.2.3/MySQL:5.0.45/PHP:5.2.10 /9.2
Back to top
View user's profile Visit poster's website
Aforo
I18N / L10N Lead Dev


Joined: Dec 27, 2007
Posts: 146

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:04 am
Reply with quote

Second Step Vars and Contants....

Now we are going to work over importants files


######### --- ADD to includes/constants.php -- #######

Quote:
// Forum Watch:
define('FORUMS_WATCH_TABLE', $prefix.'_bbforums_watch');

######--- ADD three variables in languages/[lang]/forums.php -- #######

(Add them by each Language)

Quote:
'Forum_watch_subject' => 'Forum Watch',
'Forum_watch' => 'Forum Watch',
'Forum_unwatch' => 'Forum Unwatch',

_________________
Aforo - Google Earth - WebNaranja - DFcms.es

Aforo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Centos 5/Apache 2.2.3/MySQL:5.0.45/PHP:5.2.10 /9.2
Back to top
View user's profile Visit poster's website
Aforo
I18N / L10N Lead Dev


Joined: Dec 27, 2007
Posts: 146

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:08 am
Reply with quote

3 step "Sending emails" includes/functions_post.php

We are going to work in the file that send eamil notification to the users when they are watching a topic:

######### --- includes/functions_post.php ---- #########

---------- Add this line at the end of function "function user_notification" --- line 432

Quote:
user_forum_notification($mode, $post_data, $topic_title, $forum_id, $topic_id, $post_id, $notify_user);


----------- Create new function in the same file --------

Quote:

function user_forum_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user)
{
global $board_config, $lang, $db, $phpbb_root_path, $MAIN_CFG;
global $userdata;

$current_time = gmtime();
//////////////// mio - Observar Foro - Forum Watch ////////////////
if(!$topic_title || $topic_title == "" ){
$row = $db->sql_fetchrow( $db->sql_query('SELECT topic_title FROM '.TOPICS_TABLE.' WHERE topic_id ='.$topic_id ));
$topic_title = $row['topic_title'];
}

if ($mode == 'reply' || $mode == 'newtopic' ) {
$result = $db->sql_query('SELECT user_id FROM '.USERS_TABLE.' WHERE user_level<1');
$user_id_sql = '';
while ($row = $db->sql_fetchrow($result)) { $user_id_sql .= ', '.$row['user_id']; }

$sql = "SELECT u.user_id, u.user_email, u.user_lang
FROM ".FORUMS_WATCH_TABLE." tw, ".USERS_TABLE." u
WHERE tw.forum_id = $forum_id
AND tw.user_id NOT IN (".$userdata['user_id'].", ".ANONYMOUS.$user_id_sql.")
AND u.user_id = tw.user_id";
$result = $db->sql_query($sql);

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

if ($row = $db->sql_fetchrow($result)) {
// Sixty second limit
set_time_limit(0);
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));

if (sizeof($bcc_list_ary)) {
include("includes/phpBB/emailer.php");
$emailer = new emailer();

$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, htmlunprepare($topic_title)) : htmlunprepare($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!
// modificacion importante
$emailer->set_subject($lang['Forum_watch_subject'].": $forum_id: - ".$topic_title);
// 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'],
// Important Modify
'TOPIC_TITLE' => $lang['Forum_watch_subject'].": $forum_id: - ".$topic_title,

'U_TOPIC' => getlink('&file=viewtopic&' . POST_POST_URL . "=$post_id", true, true)."#$post_id",
'U_STOP_WATCHING_TOPIC' => getlink("&file=viewforum&f=$forum_id&unwatch=forum", true, true))
);
$emailer->send();
$emailer->reset();
}
}
}
$db->sql_freeresult($result);
}

//////////////// Fin Observar Foro - End of Forum Watch ////////////////

}

//
// Fill smiley templates (or just the variables) with smileys
// Either in a window or inline
//

_________________
Aforo - Google Earth - WebNaranja - DFcms.es

Aforo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Centos 5/Apache 2.2.3/MySQL:5.0.45/PHP:5.2.10 /9.2


Last edited by Aforo on Sat Jan 10, 2009 3:13 am; edited 1 time in total
Back to top
View user's profile Visit poster's website
Aforo
I18N / L10N Lead Dev


Joined: Dec 27, 2007
Posts: 146

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:11 am
Reply with quote

4 step - Modify viewforum.php

We are going to the file: modules/Forums/viewforum.php

I have marked in red "(is_user() && $is_auth['auth_mod'])" because if we want to open this feature to all users we only need chage it by (is_user())

----- go to "End of forum prune" and add the next lines ---

Add here:

Quote:

//
// End of forum prune
//

if (is_user() && $is_auth['auth_mod']) {

$can_watch_forum = TRUE;
$sql = "SELECT notify_status
FROM ".FORUMS_WATCH_TABLE."
WHERE forum_id = $forum_id
AND user_id = ".$userdata['user_id'];
$result = $db->sql_query($sql);

if ( $row = $db->sql_fetchrow($result) ) {
// user watching
if ( isset($_GET['unwatch']) ) {
if ( $_GET['unwatch'] == 'forum' ) {
// user tring to "unwatch"
$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
$db->sql_query("DELETE $sql_priority FROM ".FORUMS_WATCH_TABLE."
WHERE forum_id = $forum_id
AND user_id = ".$userdata['user_id']);
}
url_refresh(getlink("&amp;file=viewforum&amp;f=$forum_id"));
$message = $lang['No_longer_watching'].'<br /><br />'.sprintf($lang['Click_return_topic'], '<a href="'.getlink("&amp;file=viewforum&amp;f=$forum_id").'">', '</a>');
message_die(GENERAL_MESSAGE, $message);
} else {
// user not ask for "unwatch"
$is_watching_forum = TRUE;
}
} else {
if ( isset($_GET['watch']) ) {
if ( $_GET['watch'] == 'forum' ) {
$is_watching_forum = TRUE;
$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
$sql = "INSERT $sql_priority INTO ".FORUMS_WATCH_TABLE." (user_id, forum_id, notify_status)
VALUES (".$userdata['user_id'].", $forum_id, 0)";
$result = $db->sql_query($sql);
}
url_refresh(getlink("&amp;file=viewforum&amp;f=$forum_id"));
$message = $lang['You_are_watching'].'<br /><br />'.sprintf($lang['Click_return_topic'], '<a href="'.getlink("&amp;file=viewforum&amp;f=$forum_id").'">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
}
} else {

// no user but try to unwatch

if ( isset($_GET['unwatch']) ) {
if ( $_GET['unwatch'] == 'forum' ) {
url_redirect(getlink('Your_Account'), true);
}
}
}


//
// End of forum watching
//


//
// Forum watch link
//
$s_watching_forum ='';
if ( $can_watch_forum ) {
if ( $is_watching_forum ) {
$s_watching_forum = ' <a href="'.getlink("&amp;file=viewforum&amp;f=$forum_id&amp;unwatch=forum").'">'.$lang['Forum_unwatch'].'</a> ';
} else {
$s_watching_forum = ' <a href="'.getlink("&amp;file=viewforum&amp;f=$forum_id&amp;watch=forum").'">'.$lang['Forum_watch'].'</a> ';
}
}

//
// End Forum watch link
//

--------- go to U_POST_NEW_TOPIC and add SERV_LINE

We search the line U_POST_NEW_TOPIC and we add after "SERV_LINE"

In my case, I se this line for sending services related to a forum (rss, gadget egoogle...) and of this way I dont need to toutch tenplates for every change.

Quote:
'U_POST_NEW_TOPIC' => getlink("&amp;file=posting&amp;mode=newtopic&amp;".POST_FORUM_URL."=$forum_id"),
// (rss, igoogle, watch forums...)
'SERV_LINE' => '<a href="rss/forums.php?f='.$forum_id.'"><img src="images/rss2.gif" alt="RSS: '.$forum_row['forum_name'].'" style="vertical-align:middle;" /></a> RSS'.$s_watching_forum,

_________________
Aforo - Google Earth - WebNaranja - DFcms.es

Aforo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Centos 5/Apache 2.2.3/MySQL:5.0.45/PHP:5.2.10 /9.2
Back to top
View user's profile Visit poster's website
Aforo
I18N / L10N Lead Dev


Joined: Dec 27, 2007
Posts: 146

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:21 am
Reply with quote

5 Step - Templates

You must go to your template for forum:

themes/[Theme_name]/template/forums/viewforum_body.html

An you must insert the variable 'SERV_LINE'

In my template is in the line 165 but in your case I don't know:

Quote:

<tr>
<td colspan="8" class="gensmall">{SERV_LINE}</td>
</tr>

I'm goin to add some interesting files (specially functions_post.php ) for help you a bit more...

Have a bast using it... Very Happy

_________________
Aforo - Google Earth - WebNaranja - DFcms.es

Aforo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Centos 5/Apache 2.2.3/MySQL:5.0.45/PHP:5.2.10 /9.2
Back to top
View user's profile Visit poster's website
Phoenix
Site Admin


Joined: Apr 19, 2004
Posts: 8729
Location: Netizen

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:24 am
Reply with quote

Might save you some trouble soon - good work Smile

I will be adding forum watch as an option in ForumsPlus - I figure I will option it on a groups basis so webmasters can choose the level it affects their server.


Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
Aforo
I18N / L10N Lead Dev


Joined: Dec 27, 2007
Posts: 146

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:26 am
Reply with quote

Laughing Well.. perhaps my work can be usseful for somebody. Very Happy

But thank you, Phoenix.

_________________
Aforo - Google Earth - WebNaranja - DFcms.es

Aforo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Centos 5/Apache 2.2.3/MySQL:5.0.45/PHP:5.2.10 /9.2
Back to top
View user's profile Visit poster's website
Phoenix
Site Admin


Joined: Apr 19, 2004
Posts: 8729
Location: Netizen

PostPost subject: Re: Forum Watch - Notify All Forum Message to Moderators
Posted: Sat Jan 10, 2009 3:33 am
Reply with quote

No, thank you - will be viewing your changes when I do it Very Happy

Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexCPG-BB (forum) All times are GMT
Page 1 of 1


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

stopsoftwarepatents.eu petition banner
User Info [x]

Welcome Anonymous

Nickname
Password
(Register)

Last CVS commits [x]

Languages [x]

Community [x]

Support for DragonflyCMS in a other languages:

Deutsch
Español

X-links [x]
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

Preview theme [x]
Each user can view the site with a different theme.
Themes marked with a * also change the forum look.


You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
This page generated in 1.821 seconds with 16 DB Queries in 0.0903 seconds
Memory Usage: 2.98 MB
Interactive software released under GNU GPL, Code Credits, Privacy Policy