This topic is locked

Report that shows on the current users records

8/2/2008 8:28:24 PM
Shopping Cart Template tips and tricks
Z
zamzam2112 author

I made another table called _user_students and followed the pattern of the user_addresses so a user can add more than 1 student to their account.
But with this they can only see thier own students too.
Now I'm trying to make a report (users_Report.php) and it it groups by user_id from the table users.
The report and query look good, but it shows everyones _user_students in the report. I only want to show the current users id. I have the permission in the PHPrunner set for users to only see thier own data, but I guess reports and especially my custom report isn't looking at this.
I tried to add a WHERE clause in the SQL designer but it doesn't let me go any further.
last part of my Query:

[codebox]`_user_students`.sign_medical,

`_user_students`.sign_name

FROM users

RIGHT OUTER JOIN `_user_students` ON `_user_students`.user_id = users.user_id

WHERE users.user_id = ".$_SESSION["UserID"]."

[/codebox]
Now I think it has to be done in users_reports_events.php
[codebox]
// Report page: Before SQL query

function BeforeQueryReport(&$strSQL,&$strWhereClause,&$strOrderBy)

{

WHERE users.user_id ".$_SESSION["UserID"]."
//** Custom code ****

// put your custom code here
} // function BeforeQueryReport[/codebox]
Do I add something here? Or is there another setting that I can do for this?
Thanks!
Bob

Z
zamzam2112 author 8/2/2008

Modified: users_Report_variables.php (a custom view and sql query based on my users table and a right join to my students table.)
Found In the Output/Include folder:
(Used Dreamweaver8 for editing)
1st. dimmed a string for safety (around line 9)

[codebox]// adding this for SFBC

$strWhereid = $_SESSION["IDUser"];

[/codebox]
Then added the Where Clause that I wanted (around line 17 of the php file)

[codebox]$gsqlWhere="users.user_id = $strWhereid ";[/codebox]
And now the logged in user only sees their students.
I'm posting my own answer, but I still could use help if there are any security problems with doin it this way.
I will share my Project info on a test site later.Thanks