Approve Mod in admin_forum_extend verschieben

Allgemeiner Support zum phpBB 2 Board und phpBB 2 Modifikationen
Forumsregeln
Auch wenn hier der Support für phpBB 2 weiterhin aufrecht erhalten bleibt, weisen wir darauf hin, dass das phpBB 2 nicht mehr offiziell unterstützt und weiterentwickelt wird!
Antworten
Benutzeravatar
karstenkurt
Beiträge: 597
Registriert: Do 31.Mär, 2005 20:20
Kontaktdaten:

Approve Mod in admin_forum_extend verschieben

Beitrag von karstenkurt »

Hallo,

hab mal versucht den ApproveMod (http://www.phpbb.com/phpBB/viewtopic.ph ... sc&start=0) von der admin_forums in die admin_forum_extend zu verschieben. Die tpl ist entsprechend angepasst. Allerdings hab ich einige Probleme beim Code. Es sind 3 Codeblöcke einzufügen:

Code: Alles auswählen

# 
#-----[ FIND ]------------------------------------------
#
//
// start forum prune stuff.
//
if( $row['prune_enable'] )
{

# 
#-----[ BEFORE, ADD ]------------------------------------------
# 
// 
// Begin Approve_Mod Block : 14
// 
$approve_mod = array();
$sql = "SELECT * FROM " . APPROVE_FORUMS_TABLE . " 
          WHERE forum_id = " . intval($forum_id); 
     if ( !($result = $db->sql_query($sql)) ) 
     { 
     message_die(GENERAL_ERROR, $lang['approve_posts_error_obtain'], '', __LINE__, __FILE__, $sql); 
     } 
				if ( $row_approve = $db->sql_fetchrow($result) ) 
				{         
					$approve_mod['moderators'] = array();
					$approve_mod['moderators'] = explode('|', $row_approve['approve_moderators']);

					$row_approve['approve_notify_user_options'] = '';					
					$row_approve['approve_notify_user_list'] = '';

					for($i = 0; !empty($approve_mod['moderators'][$i]); $i++)
					{
						$sql = "SELECT username
							FROM " . USERS_TABLE . "
							WHERE user_id = " . intval($approve_mod['moderators'][$i]);
						if ( !$result = $db->sql_query($sql) )
						{
							message_die(GENERAL_ERROR, "Couldn't get forum Prune Information","",__LINE__, __FILE__, $sql);
						}
						if ( $row_user = $db->sql_fetchrow($result) )
						{
							if ( $row_user['user_id'] != ANONYMOUS )
							{
								$row_approve['approve_notify_user_options'] = $row_approve['approve_notify_user_options'] . "\n<option>" . $row_user['username'] . "</option>";
								if ( $row_approve['approve_notify_user_list'] == '' )
								{
									$row_approve['approve_notify_user_list'] = $row_user['username'];
								}
								else
								{
									$row_approve['approve_notify_user_list'] = $row_approve['approve_notify_user_list'] . "  |  " . $row_user['username'];
									//used two spaces on either side, because phpBB truncates spaces in usernames.
								}
							}
						}
					}

					$approve_mod['notify_user_options'] = $row_approve['approve_notify_user_options'];
					$approve_mod['notify_user_list'] = $row_approve['approve_notify_user_list'];
					$approve_mod['enabled'] = ( intval($row_approve['enabled']) == 1 ) ? "checked" : ""; 
					$approve_mod['posts_enabled'] = ( intval($row_approve['approve_posts']) == 1 ) ? "checked" : ""; 
					$approve_mod['poste_enabled'] = ( intval($row_approve['approve_poste']) == 1 ) ? "checked" : ""; 
					$approve_mod['topics_enabled'] = ( intval($row_approve['approve_topics']) == 1 ) ? "checked" : ""; 
					$approve_mod['topice_enabled'] = ( intval($row_approve['approve_topice']) == 1 ) ? "checked" : ""; 
					$approve_mod['users_enabled'] = ( intval($row_approve['approve_users']) == 1 ) ? "checked" : "";
					$approve_mod['users_disabled'] = ( intval($row_approve['approve_users']) == 1 ) ? "" : "checked";
					$approve_mod['notify_user_enabled'] = ( intval($row_approve['approve_notify_approval']) == 1 ) ? "checked" : "";
					$approve_mod['notify_user_disabled'] = ( intval($row_approve['approve_notify_approval']) == 1 ) ? "" : "checked";
					$approve_mod['notify_enabled'] = ( intval($row_approve['approve_notify']) == 1 ) ? "checked" : "";
					$approve_mod['notify_disabled'] = ( intval($row_approve['approve_notify']) == 1 ) ? "" : "checked";
					$approve_mod['notify_pm_enabled'] = ( intval($row_approve['approve_notify_type']) == 1 ) ? "checked" : "";
					$approve_mod['notify_email_enabled'] = ( intval($row_approve['approve_notify_type']) == 1 ) ? "" : "checked";
					$approve_mod['notify_message_enabled'] = ( intval($row_approve['approve_notify_message']) == 1 ) ? "checked" : "";
					$approve_mod['notify_message_len'] = intval($row_approve['approve_notify_message_len']);
					$approve_mod['notify_posts_enabled'] = ( intval($row_approve['approve_notify_posts']) == 1 ) ? "checked" : "";
					$approve_mod['notify_poste_enabled'] = ( intval($row_approve['approve_notify_poste']) == 1 ) ? "checked" : "";
					$approve_mod['notify_topics_enabled'] = ( intval($row_approve['approve_notify_topics']) == 1 ) ? "checked" : "";
					$approve_mod['notify_topice_enabled'] = ( intval($row_approve['approve_notify_topice']) == 1 ) ? "checked" : "";
					$approve_mod['hide_topics_enabled'] = ( intval($row_approve['forum_hide_unapproved_topics']) == 1 ) ? "checked" : "";
					$approve_mod['hide_posts_enabled'] = ( intval($row_approve['forum_hide_unapproved_posts']) == 1 ) ? "checked" : "";
					$approve_mod['hide_topics_disabled'] = ( intval($row_approve['forum_hide_unapproved_topics']) == 1 ) ? "" : "checked";
					$approve_mod['hide_posts_disabled'] = ( intval($row_approve['forum_hide_unapproved_posts']) == 1 ) ? "" : "checked";
				}
// 
// End Approve_Mod Block : 14
//

Code: Alles auswählen

# 
#-----[ FIND ]------------------------------------------
#
			$template->assign_vars(array(
				'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"),
# 
#-----[ BEFORE, ADD ]------------------------------------------
# 
//	
// Begin Approve_Mod Block : 15
//
			if ( $mode == 'editforum' )
			{
				$template->assign_block_vars("approve_mod_switch", array() );
				$template->assign_vars(array(
					'L_APPROVE_POSTS' => $lang['approve_admin_posts'],
					'L_APPROVE_ENABLE' => $lang['approve_admin_enable'],
					'L_APPROVE_POSTS_TOPICS' => $lang['approve_admin_posts_topics'],
					'L_APPROVE_NOTIFY_POSTS_TOPICS' => $lang['approve_admin_notify_posts_topics'],
					'L_APPROVE_POSTS_ENABLE' => $lang['approve_admin_posts_enable'],
					'L_APPROVE_TOPICS_ENABLE' => $lang['approve_admin_topics_enable'], 
					'L_APPROVE_USERS_ENABLE' => $lang['approve_admin_users_enable'], 
					'L_APPROVE_USERS_ALL' => $lang['approve_admin_users_all'], 
					'L_APPROVE_USERS_MOD' => $lang['approve_admin_users_mod'], 
					'L_APPROVE_POSTE_ENABLE' => $lang['approve_admin_poste_enable'], 
					'L_APPROVE_TOPICE_ENABLE' => $lang['approve_admin_topice_enable'], 
					'L_APPROVE_NOTIFY_ENABLE' => $lang['approve_admin_notify_admin_enable'],
					'L_APPROVE_NOTIFY_USER_ENABLE' => $lang['approve_admin_notify_user_enable'],
					'L_APPROVE_NOTIFY_TYPE' => $lang['approve_admin_notify_type'],
					'L_APPROVE_NOTIFY_PM_ENABLE' => $lang['approve_admin_notify_pm_enable'],
					'L_APPROVE_NOTIFY_EMAIL_ENABLE' => $lang['approve_admin_notify_email_enable'],
					'L_APPROVE_NOTIFY_MESSAGE_ENABLE' => $lang['approve_admin_notify_message_enable'],
					'L_APPROVE_NOTIFY_MESSAGE_LEN' => $lang['approve_admin_notify_message_length'],
					'L_APPROVE_NOTIFY_ENABLED' => $lang['Enabled'],
					'L_APPROVE_NOTIFY_DISABLED' => $lang['Disabled'], 
					'L_APPROVE_NOTIFY_USER' => $lang['approve_admin_moderators'],
					'L_APPROVE_NOTIFY_POSTS_ENABLE' => $lang['approve_admin_notify_posts_enable'],
					'L_APPROVE_NOTIFY_POSTE_ENABLE' => $lang['approve_admin_notify_poste_enable'],
					'L_APPROVE_NOTIFY_TOPICS_ENABLE' => $lang['approve_admin_notify_topics_enable'],
					'L_APPROVE_NOTIFY_TOPICE_ENABLE' => $lang['approve_admin_notify_topice_enable'],
					'L_APPROVE_BUTTON_FIND' => $lang['approve_admin_button_find'],
					'L_APPROVE_BUTTON_ADD' => $lang['approve_admin_button_add'],
					'L_APPROVE_BUTTON_REM' => $lang['approve_admin_button_rem'],
					'L_APPROVE_HIDE_TOPICS_ENABLE' => $lang['approve_admin_hide_topics_enable'],
					'L_APPROVE_HIDE_POSTS_ENABLE' => $lang['approve_admin_hide_posts_enable'],
					'S_APPROVE_ENABLED' => $approve_mod['enabled'],
					'S_APPROVE_POSTS_ENABLED' => $approve_mod['posts_enabled'],
					'S_APPROVE_POSTE_ENABLED' => $approve_mod['poste_enabled'],
					'S_APPROVE_TOPICS_ENABLED' => $approve_mod['topics_enabled'],
					'S_APPROVE_TOPICE_ENABLED' => $approve_mod['topice_enabled'],
					'S_APPROVE_USERS_ENABLED' => $approve_mod['users_enabled'],
					'S_APPROVE_USERS_DISABLED' => $approve_mod['users_disabled'],
					'S_APPROVE_NOTIFY_ENABLED' => $approve_mod['notify_enabled'],
					'S_APPROVE_NOTIFY_USER_ENABLED' => $approve_mod['notify_user_enabled'],
					'S_APPROVE_NOTIFY_USER_DISABLED' => $approve_mod['notify_user_disabled'],
					'S_APPROVE_NOTIFY_PM_ENABLED' => $approve_mod['notify_pm_enabled'],
					'S_APPROVE_NOTIFY_EMAIL_ENABLED' => $approve_mod['notify_email_enabled'],
					'S_APPROVE_NOTIFY_MESSAGE_ENABLED' => $approve_mod['notify_message_enabled'],
					'S_APPROVE_NOTIFY_MESSAGE_LEN' => $approve_mod['notify_message_len'],
					'S_APPROVE_NOTIFY_DISABLED' => $approve_mod['notify_disabled'],
					'S_APPROVE_NOTIFY_USER_OPTIONS' => $approve_mod['notify_user_options'],
					'S_APPROVE_NOTIFY_USER_LIST' => $approve_mod['notify_user_list'],
					'S_APPROVE_NOTIFY_POSTS_ENABLED' => $approve_mod['notify_posts_enabled'],
					'S_APPROVE_NOTIFY_POSTE_ENABLED' => $approve_mod['notify_poste_enabled'],
					'S_APPROVE_NOTIFY_TOPICS_ENABLED' => $approve_mod['notify_topics_enabled'],
					'S_APPROVE_NOTIFY_TOPICE_ENABLED' => $approve_mod['notify_topice_enabled'],
					'S_APPROVE_HIDE_TOPICS_ENABLED' => $approve_mod['hide_topics_enabled'],
					'S_APPROVE_HIDE_POSTS_ENABLED' => $approve_mod['hide_posts_enabled'],
					'S_APPROVE_HIDE_TOPICS_DISABLED' => $approve_mod['hide_topics_disabled'],
					'S_APPROVE_HIDE_POSTS_DISABLED' => $approve_mod['hide_posts_disabled'] )
				);
			}
// 
// End Approve_Mod Block : 15
//

Code: Alles auswählen

# 
#-----[ FIND ]------------------------------------------
#
		case 'modforum':

# 
#-----[ AFTER, ADD ]------------------------------------------
# 
// 
// Begin Approve_Mod Block : 16
// 
			$approve_notify_user_list = '';
			$approve_enable = (intval($HTTP_POST_VARS['approve_enable']) == 1) ? 1 : 0;

			if ( trim($HTTP_POST_VARS['usernames_list']) != '' ) 
			{ 
				$approve_mod['moderators'] = array();
				$approve_mod['moderators'] = explode('  |  ', trim($HTTP_POST_VARS['usernames_list']));

				for($i = 0; !empty($approve_mod['moderators'][$i]); $i++)
				{
					$sql = "SELECT user_id, user_level
						FROM " . USERS_TABLE . "
						WHERE username = '" . $approve_mod['moderators'][$i] . "'";
					if ( !$result = $db->sql_query($sql) )
					{
						message_die(GENERAL_ERROR, $lang['approve_posts_error_obtain'],"",__LINE__, __FILE__, $sql);
					}
					if ( $row_user = $db->sql_fetchrow($result) )
					{
						if ( intval($row_user['user_id']) != intval(ANONYMOUS) && intval($row_user['user_level']) != intval(DELETED) )
						{
							if ( $approve_notify_user_list == '' ) 
							{
								$approve_notify_user_list = $row_user['user_id'];
							}
							else
							{
								$approve_notify_user_list = $approve_notify_user_list . '|' . $row_user['user_id'];
							}
						}
						else
						{
							message_die(GENERAL_ERROR, $lang['approve_admin_notify_user_invalid'] . $approve_mod['moderators'][$i]);
						}
					}
					else
					{
						message_die(GENERAL_ERROR, $lang['approve_admin_notify_user_invalid'] . $approve_mod['moderators'][$i]);
					}
				}
			}
			else
			{
				if ( $HTTP_POST_VARS['approve_notify_enable'] )
				{
					message_die(GENERAL_ERROR, $lang['approve_admin_notify_user_empty']);
				}
			}
			$sql = "DELETE FROM " . APPROVE_FORUMS_TABLE . " 
				WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
			if ( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, $lang['approve_posts_error_delete'], '', __LINE__, __FILE__, $sql);
			}
			$sql = "INSERT INTO " . APPROVE_FORUMS_TABLE . " (forum_id, enabled, approve_posts, approve_topics, approve_users, approve_poste, approve_topice, approve_notify, approve_notify_type, approve_notify_message, approve_notify_message_len, approve_moderators, approve_notify_posts, approve_notify_poste, approve_notify_topics, approve_notify_topice, approve_notify_approval, forum_hide_unapproved_topics, forum_hide_unapproved_posts) 
				VALUES (" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($approve_enable) . ", " . intval($HTTP_POST_VARS['approve_posts_enable']) . ", " . intval($HTTP_POST_VARS['approve_topics_enable']) . ", " . intval($HTTP_POST_VARS['approve_users_enable']) . ", " . intval($HTTP_POST_VARS['approve_poste_enable']) . ", " . intval($HTTP_POST_VARS['approve_topice_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_type_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_message_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_message_len']) . ", '" . $approve_notify_user_list . "', " . intval($HTTP_POST_VARS['approve_notify_posts_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_poste_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_topics_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_topice_enable']) . ", " . intval($HTTP_POST_VARS['approve_notify_user_enable']) . ", " . intval($HTTP_POST_VARS['approve_hide_topics_enable']) . ", " . intval($HTTP_POST_VARS['approve_hide_posts_enable']) . ")";
			if ( !$result = $db->sql_query($sql) ) 
			{ 
				message_die(GENERAL_ERROR, $lang['approve_posts_error_insert'], '', __LINE__, __FILE__, $sql); 
			} 
// 
// End Approve_Mod Block : 16
//
Ausserdem müssen die Einstellungen in die DB geschrieben werden. Die Einstellungen werden nicht in der Tabelle phpbb_forums gespeichert, sondern in der Tabelle phpbb_approve_forums. Wenn ich das mit der admin_forums_extend.php richtig verstanden habe,werden dort aber nur Felder in der phpbb_forums verarbeitet. Wie kann ich vorgehen, um den Mod efolgreich in der admin_forums_extend zu nutzen?
Zuletzt geändert von karstenkurt am So 05.Feb, 2006 13:59, insgesamt 1-mal geändert.
Benutzeravatar
oxpus
Administrator
Beiträge: 28735
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Beitrag von oxpus »

Das ist mit dem CH MOD nicht so einfach. Rat von mir: Bau das NICHT in die admin_forums_extend.php ein!
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Benutzeravatar
karstenkurt
Beiträge: 597
Registriert: Do 31.Mär, 2005 20:20
Kontaktdaten:

Beitrag von karstenkurt »

Schade, aber ok. Du hast die Erfahrung.
Bild
Antworten