Most Thanked

Hier kommen die Support Anfragen für phpBB 3.0.x MODs hinein.
ibraronaldo
Beiträge: 20
Registriert: 26. Apr 2011 01:28
Familienstand: Single
Wohnort: Napoli
Hat sich bedankt: 0
Danksagung erhalten: 0
Kontaktdaten:

Most Thanked

Beitrag von ibraronaldo »

Your phpBB Version: 3.0.8
Your phpBB Type: Standard phpBB (also called Vanilla (phpBB2) or Olympus (phpBB3))
MODs installed: Yes
Your knowledge: Basic Knowledge
Boardlink: http://www.graphicforum.altervista.org

PHP Version: 3.0.8

What have you done before the problem was there?
No problem

What have you already tryed to solve the problem?
Nothing

Description and Message
I wanted to know where I can make this change

Bild

Thanks
Benutzeravatar
Mahony
Site Admin
Site Admin
Beiträge: 792
Registriert: 3. Dez 2006 22:09
Hat sich bedankt: 22 Mal
Danksagung erhalten: 6 Mal

Re: Most Thanked

Beitrag von Mahony »

Hello
You need this Addon top_thanked
Diejenigen, die lautstark darüber diskutieren, warum es nicht geht, mögen bitte jene nicht stören, die es gerade tun.
Klug ist, wer nur die Hälfte von dem glaubt, was er hört. Weise ist, wer erkennt, welche Hälfte richtig ist.

Bild
ibraronaldo
Beiträge: 20
Registriert: 26. Apr 2011 01:28
Familienstand: Single
Wohnort: Napoli
Hat sich bedankt: 0
Danksagung erhalten: 0
Kontaktdaten:

Re: Most Thanked

Beitrag von ibraronaldo »

Thanks, I wanted to know if it is consistent with this http://xiradorn.it/forum/guida-phpbb-ta ... t1302.html Or do I need yours?
Benutzeravatar
Mahony
Site Admin
Site Admin
Beiträge: 792
Registriert: 3. Dez 2006 22:09
Hat sich bedankt: 22 Mal
Danksagung erhalten: 6 Mal

Re: Most Thanked

Beitrag von Mahony »

Hello
The MOD should be compatible with the Tasto Grazie (Thanks Mod).
Diejenigen, die lautstark darüber diskutieren, warum es nicht geht, mögen bitte jene nicht stören, die es gerade tun.
Klug ist, wer nur die Hälfte von dem glaubt, was er hört. Weise ist, wer erkennt, welche Hälfte richtig ist.

Bild
ibraronaldo
Beiträge: 20
Registriert: 26. Apr 2011 01:28
Familienstand: Single
Wohnort: Napoli
Hat sich bedankt: 0
Danksagung erhalten: 0
Kontaktdaten:

Re: Most Thanked

Beitrag von ibraronaldo »

Thanks I tried to install the addon called you but I get this error? Why?

Code: Alles auswählen

SQL ERROR [ mysql4 ]

Unknown column 'user_thanked' in 'field list' [1054]

SQL

SELECT username, user_id, user_type, user_colour, user_thanked AS num_thanks_from FROM phpbb_users WHERE user_id <> 1 AND user_type <> 2 AND user_thanked > 0 ORDER BY user_thanked DESC LIMIT 10

BACKTRACE

FILE: includes/db/mysql.php
LINE: 175
CALL: dbal_mysql->sql_error()

FILE: includes/db/mysql.php
LINE: 222
CALL: dbal_mysql->sql_query()

FILE: includes/db/dbal.php
LINE: 170
CALL: dbal_mysql->_sql_query_limit()

FILE: includes/functions_topthanked.php
LINE: 37
CALL: dbal_mysql->sql_query_limit()

FILE: index.php
LINE: 114
CALL: get_top_thanked()
:traurig
Benutzeravatar
Mahony
Site Admin
Site Admin
Beiträge: 792
Registriert: 3. Dez 2006 22:09
Hat sich bedankt: 22 Mal
Danksagung erhalten: 6 Mal

Re: Most Thanked

Beitrag von Mahony »

Hello
I have looked at the Tasto Grazie (Thanks Mod). It lacks the function of the number of Thanks in the thanks.php and the required Columns in the Table phpbb_users.

You should use the Thank Post MOD Version 0.4.0 or the Thank Post Mod (hide MOD compatible ) 0.2.0
Diejenigen, die lautstark darüber diskutieren, warum es nicht geht, mögen bitte jene nicht stören, die es gerade tun.
Klug ist, wer nur die Hälfte von dem glaubt, was er hört. Weise ist, wer erkennt, welche Hälfte richtig ist.

Bild
ibraronaldo
Beiträge: 20
Registriert: 26. Apr 2011 01:28
Familienstand: Single
Wohnort: Napoli
Hat sich bedankt: 0
Danksagung erhalten: 0
Kontaktdaten:

Re: Most Thanked

Beitrag von ibraronaldo »

And there's no way to make it work even with the mods I've told you?
Benutzeravatar
Mahony
Site Admin
Site Admin
Beiträge: 792
Registriert: 3. Dez 2006 22:09
Hat sich bedankt: 22 Mal
Danksagung erhalten: 6 Mal

Re: Most Thanked

Beitrag von Mahony »

ibraronaldo hat geschrieben:And there's no way to make it work even with the mods I've told you?
Sorry, no. In the Tasto Grazie (Thanks Mod) the number of thanks will not be saved.
The Tasto Grazie (Thanks Mod) based of the Thank Post MOD Version 0.4.0
Diejenigen, die lautstark darüber diskutieren, warum es nicht geht, mögen bitte jene nicht stören, die es gerade tun.
Klug ist, wer nur die Hälfte von dem glaubt, was er hört. Weise ist, wer erkennt, welche Hälfte richtig ist.

Bild
Benutzeravatar
Mahony
Site Admin
Site Admin
Beiträge: 792
Registriert: 3. Dez 2006 22:09
Hat sich bedankt: 22 Mal
Danksagung erhalten: 6 Mal

Re: Most Thanked

Beitrag von Mahony »

Hello my Friend
I have the MOD made compatible
Use this as thanks.php

Code: Alles auswählen

<?php
/** 
*
* @package phpBB3
* @version $Id: thanks.php,v 0.2.0 2007/04/21 23:56:31 geoffreak Exp $
* @copyright (c) 2007 Geoffreak
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit; 
}
define('THANKS_TABLE', $table_prefix . 'thanks');

// create an array of all users
$sql = 'SELECT *
	FROM ' . USERS_TABLE;
$result = $db->sql_query($sql);
$users = array();
while ($row = $db->sql_fetchrow($result))
{
	if ((!isset($row['user_thanked']) || !isset($row['user_thanked_others'])) && $user->data['user_type'] == USER_FOUNDER)
	{
		install_040();
	}
	$users[$row['user_id']] = array( 
		'username' 			=> $row['username'], 
		'user_id'	 		=> $row['user_id'], 
		'user_colour' 		=> $row['user_colour'], 
		'user_gender' 		=> (isset($row['user_gender'])) ?  $row['user_gender'] : false,
		'thanks_give'		=> (isset($row['user_thanked_others'])) ? $row['user_thanked_others'] : 0,
		'thanks_receive'	=> (isset($row['user_thanked'])) ? $row['user_thanked'] : 0,
	);
}
$db->sql_freeresult($result);

// Do stuff based on header variables
// Two variables are needed to avoid accidental refresh errors
if (isset($_REQUEST['thanks']) && !isset($_REQUEST['rthanks'])) 
{
	insert_thanks(request_var('thanks', 0), $user->data['user_id']);
}
if (isset($_REQUEST['rthanks']) && !isset($_REQUEST['thanks']))
{
	delete_thanks(request_var('rthanks', 0), $user->data['user_id']);
}


// create an array of all thanks info
$sql = 'SELECT *
	FROM ' . THANKS_TABLE;
$result = $db->sql_query($sql);
$thankers = array();
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
	$thankers[$i] = array(  
		'user_id' => $row['user_id'], 
		'post_id' => $row['post_id'], 
	);
	$i++;
}
$db->sql_freeresult($result);

function install_040()
{
	global $db, $user; 
	$sql = 'SELECT *
		FROM ' . POSTS_TABLE;
	$result = $db->sql_query($sql);
	$posts_arr = array();
	while ($row = $db->sql_fetchrow($result))
	{
		$posts_arr[$row['poster_id']][] = $row['post_id'];
	}
	$db->sql_freeresult($result);
	
	$sql = 'SELECT *
		FROM ' . USERS_TABLE;
	$result = $db->sql_query($sql);
	$users_thanked = array();
	$users_thanked_others = array();
	while ($row = $db->sql_fetchrow($result))
	{
		$users_thanked[$row['user_id']] = 0;
		$users_thanked_others[$row['user_id']] = 0;
	}
	$db->sql_freeresult($result);
	
	$sql = 'ALTER TABLE `' . USERS_TABLE . '` ADD `user_thanked` INT NOT NULL DEFAULT 0 ;';
	$db->sql_query($sql);
	$sql = 'ALTER TABLE `' . USERS_TABLE . '` ADD `user_thanked_others` INT NOT NULL DEFAULT 0 ;';
	$db->sql_query($sql);

	foreach ($users_thanked as $this_user_id => $thanks_count)
	{
		if (isset($posts_arr[$this_user_id]) && is_array($posts_arr[$this_user_id]))
		{
			foreach ($posts_arr[$this_user_id] as $key2 => $this_post_id)
			{
				if($thankers != 0)              
{
				foreach ($thankers as $key => $values)
				{
					if ($values['post_id'] == $this_post_id)
					{
						$users_thanked[$this_user_id]++;
					}
				}
			}
		}
		}
		if($thankers != 0)              
{
		foreach ($thankers as $key => $values)
		{
			if ($values['user_id'] == $this_user_id)
			{
				$users_thanked_others[$this_user_id]++;
			}
		}
		}
		$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
			'user_thanked'			=> $users_thanked[$this_user_id],
			'user_thanked_others'	=> $users_thanked_others[$this_user_id],
		)) . " WHERE user_id = $this_user_id";
		$db->sql_query($sql);
	}
	$sql2 = 'INSERT INTO ' . CONFIG_TABLE . ' ' . $db->sql_build_array('INSERT', array(
		'config_name'	=> 'thanks_version',
		'config_value'	=> '0.4.0',
	));
	$db->sql_query($sql2);
	trigger_error($user->lang['TP_040_UPGRADED']);
}


// Output thanks list
function get_thanks($post_id)
{
	global $db, $users, $poster_id, $thankers;
	$return = '';
    $user_list = array();
	foreach($thankers as $key => $value)
	{
		if ($thankers[$key]['post_id'] == $post_id && $thankers[$key]['user_id'] != $poster_id && ($thankers[$key]['user_id'] == 2 || $thankers[$key]['user_id'] > 52))
		{
			$user_list[ strtolower( $users[$thankers[$key]['user_id']]['username'] ) ] = array( 
				'username' => $users[$thankers[$key]['user_id']]['username'], 
				'user_id' => $users[$thankers[$key]['user_id']]['user_id'], 
				'user_colour' => $users[$thankers[$key]['user_id']]['user_colour'], 
			);
		}
	}
	ksort($user_list);
	$i = 0;
	foreach($user_list as $key => $value)
	{
		if ($i > 0)
		{
			$return .= ', ';
		}
		$i++;
		$return .= get_username_string('full', $value['user_id'], $value['username'], $value['user_colour'], $value['username']);
	}
	$return = ($return == '') ? false : $return;
	return $return;
}
function get_thanks_number($post_id)
{
	global $db, $thankers;
	$i = 0;
	foreach($thankers as $key => $value)
	{
		if ($thankers[$key]['post_id'] == $post_id)
		{
			$i++;
		}
	}
	return $i;
}
// add a user to the thanks list
function insert_thanks($post_id, $user_id)
{
   global $db, $users;
   if ($user_id != ANONYMOUS && ($user_id == 2 || $user_id > 52))
	{	
		$sql = 'SELECT *
			FROM ' . THANKS_TABLE . "
			WHERE post_id = $post_id 
				AND user_id = $user_id
			LIMIT 1";
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);
		
		$to_id = request_var('to_id', 0);
		if (empty($row) && !empty($to_id))
		{
			$sql2 = 'INSERT INTO ' . THANKS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
				'user_id'	=> $user_id,
				'post_id'	=> $post_id
			));
			$db->sql_query($sql2);
			$users[$user_id]['thanks_give'] += 1;
			$users[$to_id]['thanks_receive'] += 1;
			$sql1 = 'UPDATE ' . USERS_TABLE . ' 
				SET user_thanked_others = ' . $users[$user_id]['thanks_give'] . "
				WHERE user_id = $user_id";
			$sql3 = 'UPDATE ' . USERS_TABLE . ' 
				SET user_thanked = ' . $users[$to_id]['thanks_receive'] . "
				WHERE user_id = $to_id";
			$db->sql_query($sql1);
			$db->sql_query($sql3);
		}
	}
}
// remove a user's thanks
function delete_thanks($post_id, $user_id)
{
	global $db, $user, $users, $auth;
	if ($auth->acl_get('a_') || $auth->acl_get('m_'))
	{
		$sql = 'SELECT *
			FROM ' . THANKS_TABLE . "
			WHERE post_id = $post_id AND user_id = $user_id
			LIMIT 1";
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);

		$to_id = request_var('to_id', 0);
		if (!empty($row) && !empty($to_id))
		{
			$sql = "DELETE FROM " . THANKS_TABLE . "
				WHERE post_id = $post_id AND user_id = " . $user->data['user_id'];
			$db->sql_query($sql);
			$users[$user_id]['thanks_give'] -= 1;
			$users[$to_id]['thanks_receive'] -= 1;
			$sql1 = 'UPDATE ' . USERS_TABLE . ' 
				SET user_thanked_others = ' . $users[$user_id]['thanks_give'] . "
				WHERE user_id = $user_id";
			$sql3 = 'UPDATE ' . USERS_TABLE . ' 
				SET user_thanked = ' . $users[$to_id]['thanks_receive'] . "
				WHERE user_id = $to_id";
			$db->sql_query($sql1);
			$db->sql_query($sql3);
		}
	}
	else
    {
	trigger_error('NOT_AUTHORISEDTHANKS');
    }
}
// display the text/image saying either to add or remove thanks
function get_thanks_text($post_id)
{
	global $db, $user, $postrow;
	if (already_thanked($post_id, $user->data['user_id']))
	{
		$postrow = array_merge($postrow, array(
			'THANK_ALT'		=> $user->lang['REMOVE_THANKS'],
			'THANK_ALT2'	=> $user->lang['THANK_POST2'],
			'THANKS_IMG'	=> '/removethanks.gif',
		));
		return;
	}
	$postrow = array_merge($postrow, array(
		'THANK_ALT'		=> $user->lang['THANK_POST1'],
		'THANK_ALT2'	=> $user->lang['THANK_POST2'],
		'THANKS_IMG'	=> '/thankposts.gif',
	));
	return;
}
// change the variable sent via the link to avoid odd errors
function get_thanks_link($post_id)
{
	global $db, $user;
	if (already_thanked($post_id, $user->data['user_id']))
	{
		return 'rthanks';
	}
	return 'thanks';
}
// check if the user has already thanked that post
function already_thanked($post_id, $user_id)
{
	global $db, $thankers;
	$thanked = false;
	foreach($thankers as $key => $value)
	{
		if ($thankers[$key]['post_id'] == $post_id && $thankers[$key]['user_id'] == $user_id)
		{
			$thanked = true;
		}
	}
	return $thanked;
}
// check gender in applicable
function get_gender($user_id)
{
	global $users, $user;
	if ($user_id == ANONYMOUS || $users[$user_id]['user_gender'] == false)
	{
		return $user->lang['THANK_GENDER_U'];
	}
	else if ($users[$user_id]['user_gender'] == 1)
	{
		return $user->lang['THANK_GENDER_M'];
	}
	else if ($users[$user_id]['user_gender'] == 2)
	{
		return $user->lang['THANK_GENDER_F'];
	}
	return $user->lang['THANK_GENDER_U'];
}
// gets the number of users that have thanked the poster
function get_user_count($user_id, $receive)
{
	global $users;
	if ($receive)
	{
		return $users[$user_id]['thanks_receive'];
	}
	else
	{
		return $users[$user_id]['thanks_give'];
	}
}
// stuff goes here to avoid over-editing viewtopic.php
function output_thanks($user_id)
{
	global $db, $user, $poster_id, $postrow, $row, $phpEx, $topic_data, $phpbb_root_path;
	if (!empty($postrow))
	{
		$forum_id = (isset($forum_id)) ? $forum_id : 0;
		$number = get_thanks_number($row['post_id']) . ' ';
		$pl_text = $user->lang['THANK_TEXT_2pl'];
		if ($number == 1)
		{
			$pl_text = $user->lang['THANK_TEXT_2'];
			$number = '';
		}
		get_thanks_text($row['post_id']);
		$postrow = array_merge($postrow, array(
			'THANKS_GENDER' 		=> ' ' . get_gender($user_id),
			'THANKS'				=> get_thanks($row['post_id']),
			'THANKS_LINK'			=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&f=' . $forum_id : '') . '&' . get_thanks_link($row['post_id']) . '=' . $row['post_id'] . '&to_id=' . $poster_id . '#p' . $row['post_id'],
			'THANK_TEXT'			=> $user->lang['THANK_TEXT_1'] . ' ' . $number . $pl_text . ' ',
			'POSTER_RECEIVE_COUNT'	=> get_user_count($poster_id, true),
			'POSTER_GIVE_COUNT'		=> get_user_count($poster_id, false),
			'S_IS_OWN_POST'			=> ($user->data['user_id'] == $poster_id) ? true : false,
		));
	}
}

?>
Diejenigen, die lautstark darüber diskutieren, warum es nicht geht, mögen bitte jene nicht stören, die es gerade tun.
Klug ist, wer nur die Hälfte von dem glaubt, was er hört. Weise ist, wer erkennt, welche Hälfte richtig ist.

Bild
ibraronaldo
Beiträge: 20
Registriert: 26. Apr 2011 01:28
Familienstand: Single
Wohnort: Napoli
Hat sich bedankt: 0
Danksagung erhalten: 0
Kontaktdaten:

Re: Most Thanked

Beitrag von ibraronaldo »

Now I feel great friend now hope it works :D
Antworten