vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Is award automation SQL Cron proper for membergroupids (https://vborg.vbsupport.ru/showthread.php?t=322442)

Skyrider 04-23-2016 09:17 AM

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?

Dave 04-23-2016 09:50 AM

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


Skyrider 04-23-2016 11:40 AM

Aha, so everything after the comma was being ignored, thanks! It appears to work properly now :D. Are you by any chance able to help to 'remove' awards from the user that is no longer part of the usergroup?

Dave 04-23-2016 03:43 PM

Quote:

Originally Posted by Skyrider (Post 2569425)
Aha, so everything after the comma was being ignored, thanks! It appears to work properly now :D. 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.

MarkFL 04-23-2016 04:15 PM

Quote:

Originally Posted by Skyrider (Post 2569425)
...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? :D

squidsk 04-24-2016 12:32 AM

Quote:

Originally Posted by Dave (Post 2569424)
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.

Dave 04-24-2016 12:44 AM

Quote:

Originally Posted by squidsk (Post 2569462)
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


All times are GMT. The time now is 02:44 AM.

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.01116 seconds
  • Memory Usage 1,744KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete