Support ⇒ Modules & Blocks ⇒ Kudos - AddOn ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexModules & Blocks

Kudos - AddOn Reply to topic

Go to page Previous 1, 2, 3

In between your issue, please apply this fix because your ternary operators are wrong. Third time I ask this, have you done the following:
NanoCaiordo wrote
Try with:
'C_ALTER1' => can_admin('Kudos') ? 1 : ($MAIN_CFG['kudos']['kudos_max'] > 0 ? 1 : ''), 'C_ALTER2' => can_admin('Kudos') ? 1 : ($MAIN_CFG['kudos']['kudos_max'] > 1 ? 1 : ''),


Regarding if it fixes your current issue or not, it needs to be done.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


Installed the Module on a vanilla df 9.4 test site and works just fine. Users can donate each other's Kudos, even having negative Kudos :/

www.greenday2k.net

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


greenday2k wrote
Installed the Module on a vanilla df 9.4 test site and works just fine. Users can donate each other's Kudos, even having negative Kudos :/


Applying my proposed code would fix that issue on the user side.
As far I can understand, if the user is still able to donate kudos even when in negative balance the check needs to be, also, properly done while posting.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


Sorry Nano, I had no real idea what you meant as there has never been any problem with users giving Kudos to others.

Anyhow I have made your changes to both viewtopic.php and the kudos-status.php and there are still no problems with giving Kudos so all good.

Nothing has changed regarding Donating Kudos, still get the credit check error you cannot donate Kudos you do not have.

Donating Kudos can only be done from the users profile page using the kudos-status block and has nothing to do with the forums.

Heres that block.

<?php /********************************************** Kudos YA Block for CPG-NUKE 9.2.x ********************************************** Copyright (c) 2007-08 $Revision: 2.0 $ $Author: BrokenCrust $ $Date: 2008/09/14 $ ***********************************************/ if (!defined('CPG_NUKE')) { exit; } $user_id = $userinfo['user_id']; global $userinfo, $CPG_SESS, $MAIN_CFG; if (is_active('Kudos')) { get_lang('kudos'); require_once('modules/Kudos/lists.inc'); $status = $db->sql_fetchrow($db->sql_query("SELECT kudos_pos, kudos_neg, kudos_pos-kudos_neg AS kudos FROM ".$user_prefix."_users WHERE user_id=".$user_id)); $history = $db->sql_query("SELECT w.username AS who, w.user_id AS who_id, k.kudos_time, k.kudos_reason, k.kudos FROM ".$prefix."_kudos_history AS k LEFT JOIN ".$user_prefix."_users AS w ON k.kudos_from=w.user_id WHERE k.kudos_to=".$user_id." ORDER BY k.kudos_time DESC LIMIT 5"); $donation = $db->sql_fetchrow($db->sql_query("SELECT kudos_pos-kudos_neg AS kudos FROM ".$user_prefix."_users WHERE user_id=".$userinfo['user_id'])); $cpgtpl->assign_vars(array( 'C_HIST' => (($db->sql_numrows($history) > 0) || ($MAIN_CFG['kudos']['kudos_history'] == 0)) ? 1 : '', 'C_ADMIN' => can_admin('Kudos') ? 1 : '', 'C_USER' => is_user() ? 1 : '', 'C_POS_NEG' => $MAIN_CFG['kudos']['kudos_pos_neg'] == 0 ? '' : 1, 'C_WHO' => $MAIN_CFG['kudos']['kudos_show_who'] == 0 ? '' : 1, 'C_DONATE' => ($userinfo['kudos_pos'] - $userinfo['kudos_neg']) > 10 ? 1 : '', 'C_ALTER1' => can_admin('Kudos') ? 1 : ($MAIN_CFG['kudos']['kudos_max'] > 0 ? 1 : ''), 'C_ALTER2' => can_admin('Kudos') ? 1 : ($MAIN_CFG['kudos']['kudos_max'] > 1 ? 1 : ''), 'I_UP_1' => 'themes/'.$CPG_SESS['theme'].'/images/kudos/up1.png', 'I_UP_2' => 'themes/'.$CPG_SESS['theme'].'/images/kudos/up2.png', 'I_KUDOS' => 'themes/'.$CPG_SESS['theme'].'/images/kudos/kudos.png', 'I_DOWN_2' => 'themes/'.$CPG_SESS['theme'].'/images/kudos/down2.png', 'I_DOWN_1' => 'themes/'.$CPG_SESS['theme'].'/images/kudos/down1.png', 'L_DONATE' => donate_list($user_id, $donation['kudos']), 'K_TITLE' => $username.'\'s '._KUDOS, 'N_DONATE' => 'kudos', 'S_OVERALL' => $status['kudos'], 'S_POS' => $status['kudos_pos'], 'S_NEG' => $status['kudos_neg'], 'U_UP_1' => getlink('Kudos&amp;op=credit&amp;user_id='.$user_id.'&amp;amount=1'), 'U_UP_2' => getlink('Kudos&amp;op=credit&amp;user_id='.$user_id.'&amp;amount=2'), 'U_KUDOS' => getlink('Kudos'), 'U_DOWN_2' => getlink('Kudos&amp;op=credit&amp;user_id='.$user_id.'&amp;amount=-2'), 'U_DOWN_1' => getlink('Kudos&amp;op=credit&amp;user_id='.$user_id.'&amp;amount=-1'), 'U_MANAGE' => adminlink('Kudos&amp;mode=manage&amp;user_id='.$user_id) )); if ($db->sql_numrows($history) > 0) { $class = 1; while ($hist = $db->sql_fetchrow($history)) { $cpgtpl->assign_block_vars('hist', array( 'F_CLASS' => ($class == 1 ? 'row1' : 'row2'), 'H_WHO' => $hist['who'], 'H_TIME' => L10NTime::date($userinfo['user_dateformat'], $hist['kudos_time'], $userinfo['user_dst'], $userinfo['user_timezone']), 'H_REASON' => decode_reason($hist['kudos_reason']), 'H_KUDOS' => sprintf('%+d', $hist['kudos']), 'U_WHO' => getlink("Your_Account&amp;profile=".$hist['who_id']) )); if ($class == 1) { $class = 2; } else { $class = 1; } } } OpenTable(); $cpgtpl->set_filenames(array('kudos-status' => 'Your_Account/blocks/kudos-status.html')); $cpgtpl->display('kudos-status'); CloseTable(); }

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


1. The following code wont fix the real issue, but just try it.
2. It's not intended to modify current behaviors, it is only meant to be a speed up.
3. It's highly modified and untested, I only checked for parse errors.
4. Go into maintenance mode and enable CPG_DEBUG in config.php.
5. Surf to Your_Account and get note for any current PHP notices and or warnings.
6. Backup modules/Your_Account/blocks/kudos-staus.php and replace with the one in the attached zip.
7. Repeat step 5 and test a little.
8. Post here findings.

Edit: removed attachment.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS

Last edited by NanoCaiordo on Wed Mar 05, 2014 5:34 pm; edited 1 time in total


Gave it a whirl, didn't see any obvious errors/warnings, but a user who had Kudos 8 gets reported as having Kudos 33.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


Check in database if that is true.
No PHP notices/warnings with both versions? Better then i thought

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


Yes sorry, 8 is true, yet the new kudos-status is displaying 33.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


I'll have a look in 12 hours.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


Go to class.kudos.inc around line 51 and have something like (add the var_dump line and the exit line after $this->reason):
	public function donation($from_id, $reason_id = 13) {

		$this->from_id   = intval($from_id);
		$this->reason_id = intval($reason_id);

		var_dump("From {$this->from_id}; To {$this->to_id}; {$this->amount}");
		exit;


Try to donate and post here results.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


string(16) "From 4; To 24; 5"

I am userid 4 trying to donate 5 kudos to userid 24.

BTW we do not fail that check anyhow, as then we would get a _K_NOT_POS error. I also see there that as an admin I'm exempt from both self and credit checks, explains why it works as admin.

the check I fail everytime is this error.

_K_NO_CREDIT

private function credit_check() { global $db, $user_prefix; $check = $db->sql_fetchrow($db->sql_query("SELECT kudos_pos-kudos_neg AS kudos FROM ".$user_prefix."_users WHERE user_id=".$this->from_id)); if ($kudos < $check['kudos']) { cpg_error(_K_NO_CREDIT); } }

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


you have to edit that function $kudos isnt defined

use this version to debug the process
private function credit_check() { global $db, $user_prefix; $check = $db->sql_fetchrow($db->sql_query("SELECT kudos_pos-kudos_neg AS kudos FROM ".$user_prefix."_users WHERE user_id=".$this->from_id)); if ($this->amount < $check['kudos']) { cpg_error(_K_NO_CREDIT.' Positive Kudos: '.$check['kudos_pos'].' Negative Kudos'.$check['kudos_neg']. ' Amount: '.$this->amount.' Kudos:'.$check['kudos'] ); } }

www.greenday2k.net

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


That's more detailed. I was trying to Donate 5 Kudos, and yes my Kudos is 37.

You cannot donate kudos that you do not have. Positive Kudos: Negative Kudos Amount: 5 Kudos:37

Mmm, I wonder, could it be a simple typo? as in should not 5 being GREATER than my Kudos result in a lack of credit?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


Thanks a bunch guys, donations working fine now, heres the code that works for the credit check.

private function credit_check() { global $db, $user_prefix; $check = $db->sql_fetchrow($db->sql_query("SELECT kudos_pos-kudos_neg AS kudos FROM ".$user_prefix."_users WHERE user_id=".$this->from_id)); if ($this->amount > $check['kudos']) { cpg_error(_K_NO_CREDIT); } }

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0

All times are UTC
Go to page Previous 1, 2, 3


Jump to: