Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/07/2006, 05:03
Avatar de Azrael666
Azrael666
 
Fecha de Ingreso: noviembre-2004
Mensajes: 652
Antigüedad: 19 años, 5 meses
Puntos: 1
Restringir acceso a tema por num mensajes [phpbb]

Vamos a ver.. estoy intentando modificar un poco mis foros para tener algunos temas en los que sea necesario un numero minimo de post diarios para entrar (muy util en temas de descargas, para que no lleguen los gorrones y se registren solo para bajarse cosillas).

Por ahora lo que encontré es lo siguiente... lo que necesitaria es un poco de colaboracion para intentar a partir de estos dos MODs crear uno para lograr lo planteado, que por otra parte creo que sería bastante util para la mayoria de los que tenemos este tipo de foros:

Empezamos..

1) este MOD limita la entrada a un foro a quienes tengan menos de X mensajes totales (es decir, si el minimo es 30 mensajes y tengo 29 chao chao, no entro):

Código:
############################################################## 
## MOD Title: forum enter limit
## MOD Author: emrag < [email protected] > (Emrah Türkmen)  www.canver.net
## MOD Description: You can set a minimum message limit for forums ;)
##		    exp: you set a forum enter limit 20 for forum id = 6 so 
##		    if a normal user want to see forum id = 6 he/she must have already posted
##		    20 messages.Admins and MODs are not effected.
##
## MOD Version: 1.0.3
## 
## Installation Level: Easy
## Installation Time : 10 minutes 
## Files to Edit: viewforum.php	
##		  viewtopic.php
##		  admin/admin_forums.php
##		  language/lang_english/lang_main.php
##		  templates/subSilver/admin/forum_edit_body.tpl
##
## Included Files: db_update_limit.php
############################################################## 
##
## Author Notes: You can find this at 
##
##		 Administration Panel -> Management(FORUM ADMIN) -> Edit
##
##		 or when you are creating a new forum ;)
##
############################################################## 
##
## MOD History: ??.??.2004 - 1.0.0
##		- Initial version
##
## 		06.11.2004 - 1.0.1
##		- added a forgotten line
##		- added pre-modded files (for phpBB 2.0.10)
##
## 		25.11.2004 - 1.0.2
##		- added limit value to error message
##
## 		04.01.2005 - 1.0.3
##		- fixed a bug
##
############################################################## 
##
## Before Adding This Hack To Your Forum, You Should Back Up All Files Related To This Hack  
##
############################################################## 
# 
#-----[ SQL ]------------------------------------------ 
# 
# you can use db_update_limit.php file instead of this code ;)
#

ALTER TABLE phpbb_forums ADD forum_enter_limit MEDIUMINT(8) unsigned default '0'

# 
#-----[ OPEN ]------------------------------------------ 
# 

viewforum.php

#
#----[ FIND ]------------------------------------------ 
#

//
// Grab all the basic data (all topics except announcements)
// for this forum
//

#
#-----[ BEFORE, ADD ]------------------------------------------ 
# 

//
// forum enter limit by emrag
//
		if (!($userdata['user_level'] == ADMIN OR $userdata['user_level'] == MOD))
		{
		$sql = "SELECT f.forum_id, f.forum_enter_limit, u.user_posts
			FROM " . FORUMS_TABLE . " f, " . USERS_TABLE . " u
			WHERE user_id = " . $userdata['user_id'];

		if( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query information', '', __LINE__, __FILE__, $sql);
		}

			while ($row = $db->sql_fetchrow($result))
			{
			$forum_id_limit = $row['forum_id'];
			$forum_enter_limit = $row['forum_enter_limit'];
			$user_posts_limit = $row['user_posts'];

			$error_limit = sprintf($lang['Forum_enter_limit_error'], $forum_enter_limit);

				if ($forum_id == $forum_id_limit AND $user_posts_limit < $forum_enter_limit)
				{
					message_die(GENERAL_ERROR, $error_limit);
				}
			}
		}
//
// forum enter limit by emrag
//

# 
#-----[ OPEN ]------------------------------------------ 
# 

viewtopic.php

#
#----[ FIND ]------------------------------------------ 
#

//
// Go ahead and pull all data for this topic
//

#
#----[ BEFORE, ADD ]------------------------------------------ 
#

//
// forum enter limit by emrag
//
		if (!($userdata['user_level'] == ADMIN OR $userdata['user_level'] == MOD))
		{
		$sql = "SELECT f.forum_id, f.forum_enter_limit, u.user_posts
			FROM " . FORUMS_TABLE . " f, " . USERS_TABLE . " u
			WHERE user_id = " . $userdata['user_id'];

		if( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query information', '', __LINE__, __FILE__, $sql);
		}

			while ($row = $db->sql_fetchrow($result))
			{
			$forum_id_limit = $row['forum_id'];
			$forum_enter_limit = $row['forum_enter_limit'];
			$user_posts_limit = $row['user_posts'];

			$error_limit = sprintf($lang['Forum_enter_limit_error'], $forum_enter_limit);

				if ($forum_id == $forum_id_limit AND $user_posts_limit < $forum_enter_limit)
				{
					message_die(GENERAL_ERROR, $error_limit);
				}
			}
		}
//
// forum enter limit by emrag
//


# 
#-----[ OPEN ]------------------------------------------ 
# 

admin/admin_forums.php

#
#----[ FIND ]------------------------------------------ 
#

				$forumstatus = $row['forum_status'];

#
#----[ AFTER, ADD ]------------------------------------------ 
#

				$forum_enter_limit = $row['forum_enter_limit'];

#
#----[ FIND ]------------------------------------------ 
#

				$forumstatus = FORUM_UNLOCKED;

#
#----[ AFTER, ADD ]------------------------------------------ 
#

				$forum_enter_limit = '';

#
#----[ FIND ]------------------------------------------ 
#

				'FORUM_NAME' => $forumname,

#
#----[ AFTER, ADD ]------------------------------------------ 
#

				'FORUM_ENTER_LIMIT' => $forum_enter_limit,
				'L_FORUM_ENTER_LIMIT' => $lang['Forum_enter_limit'],

#
#-----[ FIND ]--------------------------------------------
#
			$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
				VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";

#
#-----[ IN LINE, FIND ]------------------------------------
#
, forum_status

#
#-----[ AFTER, ADD ]--------------------------------------
#

, forum_enter_limit

#
#-----[ IN LINE, FIND ]------------------------------------
#
, " . intval($HTTP_POST_VARS['forumstatus']) . "

#
#-----[ AFTER, ADD ]--------------------------------------
#

, " . intval($HTTP_POST_VARS['forum_enter_limit']) . "

#
#-----[ FIND ]--------------------------------------------
#
			$sql = "UPDATE " . FORUMS_TABLE . "
				SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "

#
#-----[ IN LINE, FIND ]------------------------------------
#
, forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . "

#
#-----[ AFTER, ADD ]--------------------------------------
#

, forum_enter_limit = " . intval($HTTP_POST_VARS['forum_enter_limit']) . "

# 
#-----[ OPEN ]------------------------------------------ 
# 

language/lang_english/lang_main.php

#
#----[ FIND ]------------------------------------------ 
#

?>

#
#----[ BEFORE, ADD ]------------------------------------------ 
#

$lang['Forum_enter_limit'] = 'Forum enter limit';
//Necesitas escribir un minimo de <b>%d</b> mensajes al dia para entrar a este tema.
$lang['Forum_enter_limit_error'] = 'You have to post <b>%d</b> message to display this forum/topic.';

# 
#-----[ OPEN ]------------------------------------------ 
# 

templates/subSilver/admin/forum_edit_body.tpl

#
#----[ FIND ]------------------------------------------ 
#

	<tr> 
	  <td class="row1">{L_FORUM_STATUS}</td>
	  <td class="row2"><select name="forumstatus">{S_STATUS_LIST}</select></td>
	</tr>

#
#----[ AFTER, ADD ]------------------------------------------ 
#

	<tr> 
	  <td class="row1">{L_FORUM_ENTER_LIMIT}</td>
	  <td class="row2"><input type="text" name="forum_enter_limit" value="{FORUM_ENTER_LIMIT}" size="10" maxlength="8" /></td>
	</tr>

#
#-----[ SAVE ALL FILES/CLOSE ]------------------------------------------ 
#
# EoM
supongo que en este caso no sería muy dificil el hacer que en lugar de limitar por foro limitase por un tema en concreto (no lo he mirado aun)


Nota: divido en dos temas que no me deja meterlo solo en uno jaja
__________________
ALOZORRO v5.0 (ahora en .es)