Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2016, 09:17 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Is award automation SQL Cron proper for membergroupids

In regards of:
https://vborg.vbsupport.ru/showthread.php?p=2568256 ( YaAS-Automation-R4.zip )

There's this specific code in the file that handles the membergroupid's for giving automated awards.

Code:
// USERGROUP AWARDS
$usergroupAwards = $vbulletin->db->query_read("
	SELECT *
	FROM " . TABLE_PREFIX . "award_automation
	WHERE (auto_active=1) AND (auto_type='usergroup')
	");
	
while ($usergroupAwardsArray = $vbulletin->db->fetch_array($usergroupAwards))
{
	$getUsersWithGroup = $vbulletin->db->query_read("
		SELECT userid
		FROM " . TABLE_PREFIX . "user
		WHERE (usergroupid=$usergroupAwardsArray[auto_criteria])
		OR " . $usergroupAwardsArray[auto_criteria] . " IN (membergroupids)
		");
		
	while ($array3 = $vbulletin->db->fetch_array($getUsersWithGroup))
	{
		$checkUsergroupAward = $vbulletin->db->query_read("
			SELECT userid, award_id
			FROM " . TABLE_PREFIX . "award_user
			WHERE (userid=$array3[userid]) AND (award_id=$usergroupAwardsArray[auto_awardid])
			");
		
		$alreadyissued = $vbulletin->db->num_rows($checkUsergroupAward);		
		
		if (empty($alreadyissued)) {
			// Issue New Usergroup Award
			$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "award_user (award_id, userid, issue_reason, issue_time, award_cgroup) VALUES ('$usergroupAwardsArray[auto_awardid]', '$array3[userid]', '" . addslashes($usergroupAwardsArray['auto_issuereason']) . "', " . time() . ", 'usergroup')");
		}
	}
}
However, for some reason when the user is in multiple secondary usergroups, its refusing to give out the awards. Sometimes there are problems as well where it doesn't give awards when the member is part of the secondary usergroup either, but works when the user is in primary. As such my question, is there any 'problem' within the code?
Reply With Quote
  #2  
Old 04-23-2016, 09:50 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is this part in the second query:
PHP Code:
OR " . $usergroupAwardsArray[auto_criteria] . " IN (membergroupids
membergroupids is a string that may consist of commas. It should be changed to
PHP Code:
OR FIND_IN_SET(" . $usergroupAwardsArray[auto_criteria] . "membergroupids
Reply With Quote
3 благодарности(ей) от:
Lynne, MarkFL, Skyrider
  #3  
Old 04-23-2016, 11:40 AM
Skyrider Skyrider is offline
 
Join Date: Feb 2006
Location: Netherlands
Posts: 1,392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Aha, so everything after the comma was being ignored, thanks! It appears to work properly now . Are you by any chance able to help to 'remove' awards from the user that is no longer part of the usergroup?
Reply With Quote
  #4  
Old 04-23-2016, 03:43 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Skyrider View Post
Aha, so everything after the comma was being ignored, thanks! It appears to work properly now . Are you by any chance able to help to 'remove' awards from the user that is no longer part of the usergroup?
I wouldn't know about that, I have never used that mod before.
Reply With Quote
  #5  
Old 04-23-2016, 04:15 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Skyrider View Post
...Are you by any chance able to help to 'remove' awards from the user that is no longer part of the usergroup?
The best place to ask questions regarding features and usage of a product is in the thread for that product. Developers are much more likely to read posts in their product threads than threads posted in the general discussion forums...and who better to address a question about a product than the one who created it?
Reply With Quote
Благодарность от:
Lynne
  #6  
Old 04-24-2016, 12:32 AM
squidsk's Avatar
squidsk squidsk is offline
 
Join Date: Nov 2010
Posts: 969
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
The problem is this part in the second query:
PHP Code:
OR " . $usergroupAwardsArray[auto_criteria] . " IN (membergroupids
membergroupids is a string that may consist of commas. It should be changed to
PHP Code:
OR FIND_IN_SET(" . $usergroupAwardsArray[auto_criteria] . "membergroupids
Shouldn't matter as 'IN' expects a comma separated list, see http://dev.mysql.com/doc/refman/5.7/en/expressions.html, specifically the second example using IN.
Reply With Quote
  #7  
Old 04-24-2016, 12:44 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by squidsk View Post
Shouldn't matter as 'IN' expects a comma separated list, see http://dev.mysql.com/doc/refman/5.7/en/expressions.html, specifically the second example using IN.
As far as I know it will not work like that since vBulletin stores it as a whole string.
Refer to http://stackoverflow.com/a/4156063
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04212 seconds
  • Memory Usage 2,239KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (4)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete