[Request] Subscribe to Group's Forums - Needs completion.

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
Locked
User avatar
XelNagah
Registered User
Posts: 14
Joined: Mon Jul 12, 2010 6:40 am

[Request] Subscribe to Group's Forums - Needs completion.

Post by XelNagah » Sat May 28, 2011 9:42 am

Hello,

I'm the administrator of the Zeitgeist Argentina's phpbb forum. Since we are using groups to organize our chapter, and we assign forums to each group, we need to:
  • Assign forums to each group. For example, the Graphic Design Group has its Graphic Design Forum along with several sub-forums such as requests, finished works, members (only viewable by the group's members), etc.
  • Subscribe the group joining user automatically to the group's assigned forums, so that when someone replies to a topic or creates a thread they become aware of this.
  • Un-subscribe the group leaving user from the group's assigned forums.
I have already developed the underlying functions, and they are implemented on our forum, but I don't have the knowledge nor the time to develop right now, a module for the ACP to control the group assignment and package this as a mod.

At present I have to manually assign the group's forums through SQL Queries into a table created for this purpose. Appart from this the MOD works great.

** So, the request is to anyone who wants to take this already working Functions and Modifications and make this an actual MOD, with integration to the Groups Administrator in the ACP, an XML install file, maybe even AUTOMOD friendly, etc.

I think many people would find this MOD very useful.

So, I leave here the work already done in standard MOD basic template's format found in http://wiki.phpbb.com/MOD_Text_Template ... c_Template:

Code: Select all

##############################################################
## MOD Title: Subscribe to Group's Forums
## MOD Author: XelNagah < e-mail > (Name) website
## MOD Description: This MOD lets you assign forums to a group in order to automatically subscribe/unsubscribe the user joining/leaving the group, to all these group's assigned forums.
## MOD Version: 0.0.1
##
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit: includes/functions_user.php,
##      includes/constants.php,
##      
##      
## Included Files: (N/A)
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
##############################################################
## MOD History:
##
##   YYYY-MM-DD - Version x.x.x
##      - version notes go here
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_user.php
#
#-----[ FIND ]------------------------------------------
#
	// Return false - no error
	return false;
}
#
#-----[ ADD AFTER ]------------------------------------------
#

//MOD : Subscribe user to Group's Forums - Start
function user_group_forums_subscribe($user_id, $group_id)
{
        global $db;

        //Get Group's Forums
        $sql = 'SELECT forum_id 
                FROM '.GROUP_FORUM_WATCH_TABLE.' 
                WHERE ' . " group_id = $group_id";
        $result=$db->sql_query($sql);

        //Build an array with each one of the Group's Forums
        while ($row = $db->sql_fetchrow($result)){
                $arrForum[]=(int)$row['forum_id'];
                }

        //If the array contains no Forums for the group, exit
        if(!sizeof($arrForum))
        {
                return 'NO_GROUP_FORUMS';
        }

        //For each one of the Group's Forums
        foreach($arrForum as $forumId){

        //Find if the user is already subscribed to the forum.  
        $sql = 'SELECT * FROM '.FORUMS_WATCH_TABLE.' WHERE ' . " forum_id = $forumId" . ' AND ' . " user_id = $user_id";
        $result=$db->sql_query($sql);

        //Get the row from the sql query as an array
        $row = $db->sql_fetchrow($result);

        //From the array, get the forum id
        $the_forum_id = (int) $row['forum_id'];
        //If the user is not already subscribed to the Group's forum
        if($the_forum_id != $forumId)
                {
                //Subscribe user to the Group's Forum
                $sql = 'INSERT INTO '.FORUMS_WATCH_TABLE.' (`forum_id`,`user_id`,`notify_status`) VALUES ('.$forumId.','.$user_id.',0)';
                $db->sql_query($sql);
                }
        }
return false;
}
//MOD : Subscribe user to Group's Forums - End

//MOD : Subscribe user to Group's Forums - Start
function user_group_forums_unsubscribe($user_id, $group_id)
{
        global $db;

        //Get Group's Forums
        $sql = 'SELECT forum_id 
                FROM '.GROUP_FORUM_WATCH_TABLE.' 
                WHERE ' . " group_id = $group_id";
        $result=$db->sql_query($sql);

        //Build an array with each one of the Group's Forums
        while ($row = $db->sql_fetchrow($result)){
                $arrForum[]=(int)$row['forum_id'];
                }

        //If the array contains no Forums for the group, exit
        if(!sizeof($arrForum))
        {
                return 'NO_GROUP_FORUMS';
        }

        //For each one of the Group's Forums
        foreach($arrForum as $forumId){
        //Unsubscribe user from the Group's Forum
        $sql = 'DELETE FROM ' .FORUMS_WATCH_TABLE . "
                WHERE forum_id = $forumId
                AND user_id = " .$user_id;
        $db->sql_query($sql);
                }
return false;
}
// MOD : Subscribe user to Group's Forums - End

#
#-----[ FIND ]------------------------------------------
#
	global $db, $auth;
#
#-----[ ADD AFTER ]------------------------------------------
#

// MOD : Subscribe user to Group's Forums - Start
// Remember if the user is pending before it is rewritten.
        $is_pending = $pending;
// MOD : Subscribe user to Group's Forums - End

#
#-----[ FIND ]------------------------------------------
#
	// Clear permissions cache of relevant users
	$auth->acl_clear_prefetch($user_id_ary);
#
#-----[ ADD AFTER ]------------------------------------------
#

// MOD : Subscribe user to Group's Forums - Start

                //For each one of the users in the array
                foreach ($user_id_ary as $user_id)
                {

                //Get the user id
                $the_user_id = (int) $user_id;

                //If the user is not pending
                if(!$is_pending)
                        {
                        // Susbcribe user to the Group's Forum
                        user_group_forums_subscribe($user_id,$group_id);
                        }
                }
// MOD : Subscribe user to Group's Forums - End

#
#-----[ FIND ]------------------------------------------
#
		WHERE ' . $db->sql_in_set('group_name', $group_order);
	$result = $db->sql_query($sql);
#
#-----[ ADD AFTER ]------------------------------------------
#

// MOD : Subscribe user to Group's Forums - Start

                //For each one of the users in the array
                foreach ($user_id_ary as $user_id)
                {

                //Get the user id
                $the_user_id = (int) $user_id;

                // Unsubscribe user from the Group's Forum
                user_group_forums_unsubscribe($user_id,$group_id);
                }

// MOD : Subscribe user to Group's Forums - End

#
#-----[ FIND ]------------------------------------------
#
			// Send approved email to users...
			include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
#
#-----[ ADD BEFORE ]------------------------------------------
#

                                // MOD : Subscribe user to Group's Forums - Start

                                //For each one of the users in the array
                                foreach ($user_id_ary as $user_id)
                                {

                                //Get the user id
                                $the_user_id = (int) $user_id;

                                // Susbcribe user to the Group's Forum
                                user_group_forums_subscribe($user_id,$group_id);
                                }

                                // MOD : Subscribe user to Group's Forums - End

#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
// Additional tables
#
#-----[ ADD AFTER ]------------------------------------------
#

// MOD : Subscribe to Group's Forums - Start
define('GROUP_FORUM_WATCH_TABLE',               $table_prefix . 'group_forum_watch');
// MOD : Subscribe to Group's Forums - End

#
#-----[ SQL ]------------------------------------------
#
CREATE TABLE  `{YOUR_DATABASE_NAME}`.`{YOUR_TABLE_PREFIX}_group_forum_watch` (
`group_id` INT NOT NULL ,
`forum_id` INT NOT NULL
);
#
#-----[ DIY INSTRUCTIONS ]------------------------------------------
#
Populate the group_forum_watch table with the groups and forums assignment.

For example:

The group number 30 has two forum. Members (Forum number 10) and Requests (Forum number 20)

Use the following SQL:

INSERT INTO {YOUR_TABLE_PREFIX}_group_forum_watch VALUES ('30', '10');
INSERT INTO {YOUR_TABLE_PREFIX}_group_forum_watch VALUES ('30', '20');

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
If you have any doubts, don't hesitate to PM me.

Thanks a lot to this wonderful community.

Xel.-

ttf
Registered User
Posts: 108
Joined: Sun Aug 23, 2009 1:54 pm

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by ttf » Sun Jul 10, 2011 3:01 am

Hi,

I'm really surprised that this topic missed replies. This can be a very useful feature for boards with niche forums like VIPs, Coders and so on.

Any further help will be much appreciated.

ttf
Registered User
Posts: 108
Joined: Sun Aug 23, 2009 1:54 pm

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by ttf » Mon Jul 25, 2011 10:03 pm

help please

User avatar
XelNagah
Registered User
Posts: 14
Joined: Mon Jul 12, 2010 6:40 am

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by XelNagah » Tue Jul 26, 2011 3:17 am

Hi ttf,

Unluckily I still don't have time to learn how to code and package this as an actual MOD. It is still working on our forums but I see the necessity to package this in a way that it can be useful to the rest of the community. It is actually a very simple yet useful MOD, but the interaction with the ACP is beyond my ability right now.

Maybe we can focus in sending a few PMs to a some of the MOD developers in this forum with a link to this topic. They might be interested and haven't even noticed this thread.

Cheers.-

User avatar
XelNagah
Registered User
Posts: 14
Joined: Mon Jul 12, 2010 6:40 am

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by XelNagah » Sat Dec 17, 2011 12:22 am

Still no one?

This is still working as a charm on our forums. It just needs a bit of patchwork to be deployed as a MOD and its really useful. Maybe if someone can point out where can I find someone interested in finishing this as an actual MOD we can share it to the rest of the community. I've seen several threads requesting something like this.

wlandrum
Registered User
Posts: 59
Joined: Mon Oct 02, 2006 5:19 am

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by wlandrum » Fri Jul 12, 2013 5:44 pm

Did anything ever come of this? I am looking for something like this for my forum. Thanks!

User avatar
XelNagah
Registered User
Posts: 14
Joined: Mon Jul 12, 2010 6:40 am

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by XelNagah » Fri Jul 12, 2013 7:40 pm

No one ever touched it.

It still works, but you have to add the group and forum IDs directly to the database. =(

User avatar
ccessex
Registered User
Posts: 399
Joined: Sat May 15, 2004 2:04 pm
Location: Furneux Pelham
Contact:

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by ccessex » Mon Aug 12, 2013 9:01 am

This is exactly the mod I am searching for.

I too have Private Forums for different Groups and would like them to be automatically subscribed to New Topic/Posts Notification.

Please help us if possible :D

CarolC1
Registered User
Posts: 565
Joined: Sat Dec 02, 2006 4:26 pm

Re: [Request] Subscribe to Group's Forums - Needs completion

Post by CarolC1 » Mon Nov 11, 2013 12:56 am

Exactly what we need, too. :D

Locked

Return to “[3.0.x] MOD Requests”