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
Getting Started (totally inexperienced coder here!)
#2
So there are a few ways you can tackle this. It basically depends on what sort of logic you want to use.

If you want each individual user to have their own xml file then I would do something along the lines of creating the filename with the userid as the filename.

So you would load that file as
Code:
$filename = $user->data()->id.".xml";

If you want an xml file based on a permission level (and you're not going to have crossovers where people have multiple permission levels, then what I would do is go into the admin permissions table and add your levels, let's just say level1,level2 to keep things simple. If you click on those levels, you'll see that there is an "id" there. That's the id of the permission level. Right now user is 1 and admin is 2, so that would make level1 3, and level2 4.

You could do
Code:
if(hasPerm([3],$user->data()->id)){
Code:
//open this file
Code:
}

Basically, that is checking the logged in user's id and seeing if they have that permission level.

I guess the third thing you could want to do is be able to set the xml file more specifically per user. In that case, you could add a column, maybe called xml varchar(255) into the users table and then put the xml filename that person has access to in the database. You could access that on any page by doing

Code:
$user->data()->xml;

Finally if you are really going to be more random than that, you could make a database table for each xml file and insert the id of the user into that table.

If any of these ideas sound "right" to you, let me know and I can help you follow them through.
  Reply


Messages In This Thread
Getting Started (totally inexperienced coder here!) - by mudmin - 03-12-2017, 04:35 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)