How to pull off user-created groups?

Discussion forum for MOD Writers regarding MOD Development.
Locked
geoffreak
Registered User
Posts: 591
Joined: Sat Feb 12, 2005 8:39 am
Contact:

How to pull off user-created groups?

Post by geoffreak »

Anyone know how I might go about allowing users to create a group? I don't suppose there is a handy group creating function out there?
Anime Revolution - Your new #1 source for All things anime and manga!
READ MY BLOG ALREADY!
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: How to pull off user-created groups?

Post by A_Jelly_Doughnut »

There is a handy group creating function. group_create is found in includes/functions_user.php :)
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
geoffreak
Registered User
Posts: 591
Joined: Sat Feb 12, 2005 8:39 am
Contact:

Re: How to pull off user-created groups?

Post by geoffreak »

Sweet. I don't suppose there would also is a forum create function with permissions set to only the group and admins would there? Likely not, but a function to create a forum and a method of setting permissions would be superb.

EDIT: I found a forum create function, but I'm still lacking proper permissions. Any suggestions?
eviL<3 wrote:Here's something i got from a topic posted here once:

Code: Select all

<?php

/**
 * Create a forum
 *
 * inspiration: http://www.phpbb.com/community/viewtopic.php?f=71&t=758985
 */
function create_forum($forum_perm_from = false)
{
	$forum_data = array(
		'parent_id'					=> 0,
		'left_id'					=> 0,
		'right_id'					=> 0,
		'forum_parents'				=> '',
		'forum_name'				=> 'test',
		'forum_desc'				=> '',
		'forum_desc_bitfield'		=> '',
		'forum_desc_options'		=> 7,
		'forum_desc_uid'			=> '',
		'forum_link'				=> '',
		'forum_password'			=> '',
		'forum_style'				=> 0,
		'forum_image'				=> '',
		'forum_rules'				=> '',
		'forum_rules_link'			=> '',
		'forum_rules_bitfield'		=> '',
		'forum_rules_options'		=> 7,
		'forum_rules_uid'			=> '',
		'forum_topics_per_page'		=> 0,
		'forum_type'				=> 1,
		'forum_status'				=> 0,
		'forum_posts'				=> 0,
		'forum_topics'				=> 0,
		'forum_topics_real'			=> 0,
		'forum_last_post_id'		=> 0,
		'forum_last_poster_id'		=> 0,
		'forum_last_post_subject'	=> '',
		'forum_last_post_time'		=> 0,
		'forum_last_poster_name'	=> '',
		'forum_last_poster_colour'	=> '',
		'forum_flags'				=> 32,
		'display_on_index'			=> false,
		'enable_indexing'			=> true,
		'enable_icons'				=> false,
		'enable_prune'				=> false,
		'prune_next'				=> 0,
		'prune_days'				=> 7,
		'prune_viewed'				=> 7,
		'prune_freq'				=> 1,
	);

	if (!class_exists('acp_forums'))
	{
		global $phpbb_root_path, $phpEx;
		include($phpbb_root_path . 'includes/acp/acp_forums.' . $phpEx);
	}

	$forums_admin = new acp_forums();
	$forums_admin->update_forum_data($forum_data);

	if ($forum_perm_from)
	{
		global $auth;

		$auth->acl_clear_prefetch();

		$users_sql_ary = $groups_sql_ary = array();

		// Copy permisisons from/to the acl users table (only forum_id gets changed)
		$sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting
			FROM ' . ACL_USERS_TABLE . '
			WHERE forum_id = ' . $forum_perm_from;
		$result = $db->sql_query($sql);
		while ($row = $db->sql_fetchrow($result))
		{
			$users_sql_ary[] = array(
				'user_id'			=> (int) $row['user_id'],
				'forum_id'			=> (int) $forum_data['forum_id'],
				'auth_option_id'	=> (int) $row['auth_option_id'],
				'auth_role_id'		=> (int) $row['auth_role_id'],
				'auth_setting'		=> (int) $row['auth_setting'],
			);
		}
		$db->sql_freeresult($result);

		// Copy permisisons from/to the acl groups table (only forum_id gets changed)
		$sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting
			FROM ' . ACL_GROUPS_TABLE . '
			WHERE forum_id = ' . $forum_perm_from;
		$result = $db->sql_query($sql);
		while ($row = $db->sql_fetchrow($result))
		{
			$groups_sql_ary[] = array(
				'group_id'			=> (int) $row['group_id'],
				'forum_id'			=> (int) $forum_data['forum_id'],
				'auth_option_id'	=> (int) $row['auth_option_id'],
				'auth_role_id'		=> (int) $row['auth_role_id'],
				'auth_setting'		=> (int) $row['auth_setting']
			);
		}
		$db->sql_freeresult($result);

		// Now insert the data
		$db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary);
		$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
		cache_moderators();
	}
}

?>
Can't help you excactly with the left/right id's though, sorry.
Anime Revolution - Your new #1 source for All things anime and manga!
READ MY BLOG ALREADY!
Locked

Return to “[3.0.x] MOD Writers Discussion”