The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (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
#1
There should be a 1 to 1 mirror between users and usersc so that if we wanted to make changes to the code, or say an image, it wouldn't disrupt future upgrades because new code goes in users.

The first thing that I'd try to change is the logo.png file in https://witches.community/users/images/logo.png
If I create https://witches.community/usersc/images/logo.png the refresh does not pull from the usersc/images directory, it pulls from users/images

Is that expected behavior?

Besides editing the main UserSpice code (which will later break the edits and may impact future upgrades), what is the best way to cause UserSpice to pull from every directory in usersc instead of users?
  Reply
#2
I'm on my phone, so I have to be a little short. That is not how it works. If you copy one of the "core" users folders to users , yours will load instead of ours and you can change whatever you want. There are also a ton of things in users/includes and scripts...most of which are documented in the files themselves that allow you to be able to to sort of inject you changes into our code without having to maintain a separate full php file. You can also copy one of our templates and change it to charge the look and feel, however I recommend that you keep an eye when we update the template that you copied to see if we added new features. Also logo.png is a file we expect you to replace and it predates the usersc folder. One other option is that if you make you own template, you can have a logo of any size or in any location you want. Let me know if you have more questions.
  Reply
#3
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?
  Reply
#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
#5
I've got some working code, except for the $users structure.. it's not being respected on new page loads. I'm stumped.

<?php
require_once '../users/init.php';

require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';

if(isset($user) && $user->isLoggedIn()){
echo "hokay";
die;
}

This is the top of the page inside users/wall.php

This is what is at the top of most user-facing pages in users folder

I noticed when saving a wall post and inserting a row into the wall table, this doesn't exist: $user->data()->id

Any suggestions helpful.
  Reply
#6
Ok. That seems really weird. Does your template seem to be working? Does it seem like you're logged in?

Try just doing dump($user); somewhere on the page and seeing if all the $user info is there.
  Reply
#7
(04-26-2019, 06:16 PM)mudmin Wrote: Ok. That seems really weird.  Does your template seem to be working? Does it seem like you're logged in?  

Try just doing dump($user); somewhere on the page and seeing if all the $user info is there.

Yeah, it's odd. I'm back to trying to figure it out. I added start_session() at the top of the page, just below the 2 "require_once" lines, and it still isn't keeping a session.

When I go to index.php or messages.php or any other page, it shows in the banner that I'm logged in and the session is valid, but on in the users folder, wall.php does not keep the session. If I reload any other the other pages, the session is still active. wall.php doesn't load it, for some reason, and shows this:

User Object
(
   [_db:User:private] => DB Object
       (
           [_pdoBig GrinB:private] => PDO Object
               (
               )

           [_queryBig GrinB:private] => PDOStatement Object
               (
                   [queryString] => SELECT id, group_id FROM groups_menus WHERE menu_id = ?
               )

           [_errorBig GrinB:private] =>
           [_errorInfoBig GrinB:private] => Array
               (
                   [0] => 0
                   [1] =>
                   [2] =>
               )

           [_resultsBig GrinB:private] => Array
               (
                   [0] => stdClass Object
                       (
                           [id] => 7
                           [group_id] => 0
                       )

               )

           [_resultsArrayBig GrinB:private] => Array
               (
                   [0] => Array
                       (
                           [id] => 7
                           [group_id] => 0
                       )

               )

           [_countBig GrinB:private] => 1
           [_lastIdBig GrinB:private] => 0
           [_queryCountBig GrinB:private] => 17
       )

   [_data:User:private] =>
   [_sessionName:User:private] => user
   [_isLoggedIn:User:private] =>
   [_cookieName:User:private] => pmresofiw318373csb
   [_isNewAccount:User:private] =>
   [tableName] => users
)


I have also logged in to the site with an iOS device and sessions are find for all pages except wall.php

At the top of wall.php I have:

<?php
require_once '../users/init.php';
require_once $abs_us_root.$us_url_root.'users/includes/template/prep.php';
?>


Also, $abs_us_root.$us_url_root.'users/includes/template/prep.php'; = /home/admin/public_html/users/includes/template/prep.php (which is valid)

In users/init.php after session_start();  I added a print_r($_SESSION) and found that in all pages there is a valid session, except users/wall.php $_SESSION is not even set. But the thing is, if I go to any other existing page (messages.php mail index etc) the session is valid again and init.php's print_r ($_SESSION) shows valid for all pages except wall.php, even if I go back and forth to different pages.

I put wall.php in usersc and get the same results.

I think at this point, I have to go into init.php to see where things are getting lost. The session isn't valid anymore after the 2 require_once lines. Working on it more tonight.

* solved *

It was the footer. This was missing:

<?php require_once $abs_us_root . $us_url_root . 'usersc/templates/' . $settings->template . '/footer.php'; //custom template footer ?>

This footer must be there, like you said, this has something to do with the templates, and that needs the footer.
I am assuming that in this footer, it uses "usersc" instead of "users" because it wants to give first dibbs to the usersc folder for templates or changes to templates, over the "users" folder.
  Reply
#8
Ok. So this line
[queryString] => SELECT id, group_id FROM groups_menus WHERE menu_id = ?

Makes me think there is a one of 2 things going on. Either you've reused the $user variable in some way, your you have another db query on your page that is breaking something.

Try doing
dump($db->errorInfo());
after any queries you make on the page and even below each of the requires to see if anything is coming up.
  Reply
#9
(04-27-2019, 10:55 AM)mudmin Wrote: Ok. So this line
 [queryString] => SELECT id, group_id FROM groups_menus WHERE menu_id = ?

Makes me think there is a one of 2 things going on. Either you've reused the $user variable in some way, your you have another db query on your page that is breaking something.

Try doing
dump($db->errorInfo());  
after any queries you make on the page and even below  each of the requires to see if anything is coming up.

I forgot the footer, and that caused all sorts of issues. It's looking good, now. I have the SQL sorted out. For styling, it doesn't look like usersc/css/custom.css is auto-loaded, either. Is that correct?
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)