The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
users and userc not mirrors
#4
(04-24-2019, 06:11 AM)Malkatesa Wrote: Okay, I see.

So if I wanted to create a Wall plugin, such that folks could post pictures and text into a public Wall, kind of like a Facebook Activity Wall, I'd want to store those images in a folder. The filenames of those images would need to be stored in the database along with the timestamp, the user that posted it, and perhaps if it was to also be used as the user's avatar/profile pic. I wouldn't want to touch existing tables that UserSpice maintains, so I'd want to create a table just for the Wall plugin. In DB.php, there isn't currently a CREATE TABLE function, that I can see. Is that correct?

So if I wanted to CREATE TABLE IF NOT EXISTS wall ()... would I need to extend the DB class, or is there already an easy way to CREATE a new table that I'm not seeing?

What sort of general guidelines are there for Plugins. I mean, what if I wanted to count the number of Wall posts a user created in a period of time to make sure they don't spam the Wall? Would that go in the regular UserSpice maintained table, or would that go in the Wall table that I created? What's the best practice for this situation?
Normally plugins get their own tables unless there is a reason for them to add a column to an existing table. Your profile pic thing is a good example where you might want to add a (really distinct) column like wall_profile_pic or something like that to the users table. That won't break anything.

And for things that are more complicated you can just do $db->query(CREATE TABLE IF NOT EXISTS wall...   just like you would have any other table

So best practices for plugins are don't include anything on the header/footer of every page if you don't need to (unless it's something for a notification or something where that makes sense).  It's good to start your plugin tables with plg_wall_whatever just to avoid any conflicts.  In your particular situation I might do something like wall_access being a 1 or 0 on the users table and in the event they're spamming, you could flip wall_access to a 0 and that wouldn't allow them access to post anymore, but we're pretty flexible on how you do that sort of thing.

One thing to note, that in the upcoming .10 release, I'm updating what we call plugin hooks that allow you to make your plugin work inside of existing pages and forms without breaking them.  So you can add a button on account.php to go to the wall.  The demo plugin in .10 will show how to do this and this table https://userspice.com/plugin-hooks/ shows you where we have hooks now.  Basically on install, you say, hey...I want to add something to the top of the login.php page or at the bottom of the account.php page and that thing is inside this php file.  UserSpice takes care of the rest.
  Reply


Messages In This Thread
users and userc not mirrors - by Malatesa - 04-23-2019, 04:42 PM
RE: users and userc not mirrors - by mudmin - 04-23-2019, 04:51 PM
RE: users and userc not mirrors - by Malatesa - 04-24-2019, 06:11 AM
RE: users and userc not mirrors - by mudmin - 04-24-2019, 11:59 AM
RE: users and userc not mirrors - by Malatesa - 04-26-2019, 01:57 PM
RE: users and userc not mirrors - by mudmin - 04-26-2019, 06:16 PM
RE: users and userc not mirrors - by mudmin - 04-27-2019, 10:55 AM
RE: users and userc not mirrors - by Malatesa - 04-28-2019, 03:47 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)