Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43295
Total Topics: 7523
Most Online Today: 159
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 149
Total: 149

Author Topic: Populating badges via SQL  (Read 4528 times)

0 Members and 1 Guest are viewing this topic.

Offline ransim

  • Member
  • *
  • Posts: 4
    • View Profile
Populating badges via SQL
« on: April 16, 2013, 12:42:20 am »
I'm very interested in purchasing this to replace an old achievement system a site I now run had in Buddypress.

The organization does a lot of activity tracking in a separate database that is going to be tied to SMF. I'd like to be able to bulk assign badges with a SQL update rather then attempt to do it through the user interface.

Before I dive into this I'm mostly curious about the database set up. If I try to run an insert into statement or an update statement am I going to run into a nightmare.

IE could I do:

Insert into smf_memberbadges
('member_id','badge_id')
select u.member_id, 12 as badge_id
from trackingUsers as u
join activity as a on a.member_id = u.member_id
where a.widgets > 10

Or something similar to update the badges associated with users based on data in another table.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Populating badges via SQL
« Reply #1 on: April 16, 2013, 08:27:11 am »
Yes it can be done I use two tables. One for the badges themselves and the other table to log which users have what badges.
The non sql part would be copying over the badge images to badgeawards folders for the thumbnail and fullsize badge image.

You would need to set the custom column in badges to 1 and come up with a unqiue action keyword/name for each badge that you import.

The two main database tables below for reference.

Code: [Select]
CREATE TABLE IF NOT EXISTS {$db_prefix}badgeawards_badges (
  id_badge int(10) NOT NULL auto_increment,
  action varchar(100),
  title varchar(255),
  description text,
  enabled tinyint default 1,
  custom tinyint default 0,
  id_order int(5),
  image varchar(255),
  large_image varchar(255),
  credits int(10) default 0,
  sendpm tinyint(1) default 1,
  hidden tinyint(1) default 0,
  karma_good smallint(5) unsigned NOT NULL default '0',
  UNIQUE KEY (action),
  PRIMARY KEY  (id_badge)
) Engine=MyISAM

Code: [Select]
CREATE TABLE IF NOT EXISTS {$db_prefix}badgeawards_badge_log(
id_log int(11) NOT NULL auto_increment,
id_badge int(10) unsigned NOT NULL default '0',
date int(10) unsigned NOT NULL default '0',
id_member int(10) unsigned NOT NULL default '0',
PRIMARY KEY  (id_log),
KEY  (id_badge),
KEY  (id_member),
KEY  (date)
) Engine=MyISAM

Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline ransim

  • Member
  • *
  • Posts: 4
    • View Profile
Re: Populating badges via SQL
« Reply #2 on: April 17, 2013, 03:48:21 pm »
Thank you kindly! Question answered.

Offline ransim

  • Member
  • *
  • Posts: 4
    • View Profile
Re: Populating badges via SQL
« Reply #3 on: April 17, 2013, 04:13:12 pm »
Actually, I just realized as I was going to purchase but this is only for 1.1.x?

I'm on 2.0.4, will this work with 2.0.x sites?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Populating badges via SQL
« Reply #4 on: April 17, 2013, 04:14:27 pm »
It works for SMF 2.0.x and SMF 1.1.x
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline ransim

  • Member
  • *
  • Posts: 4
    • View Profile
Re: Populating badges via SQL
« Reply #5 on: April 17, 2013, 04:45:18 pm »
It works for SMF 2.0.x and SMF 1.1.x

Ah, whew! I had a moment of sad.

 

Related Topics

  Subject / Started by Replies Last post
Custom Badges

Started by SMFHacks « 1 2 » Support

18 Replies
17950 Views
Last post May 14, 2018, 02:47:36 pm
by SMFHacks
1 Replies
3655 Views
Last post June 10, 2012, 09:44:06 am
by SMFHacks
3 Replies
3737 Views
Last post June 18, 2012, 10:49:06 am
by FrizzleFried
8 Replies
6634 Views
Last post February 10, 2013, 12:12:09 pm
by SMFHacks
16 Replies
20115 Views
Last post October 03, 2017, 08:49:37 pm
by drewactual

+- Recent Topics

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

Powered by EzPortal