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
/printthread.php 16 require_once



UserSpice
Bug in admin.php in 4.4 - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.4 (https://userspice.com/forums/forumdisplay.php?fid=27)
+--- Thread: Bug in admin.php in 4.4 (/showthread.php?tid=1325)



Bug in admin.php in 4.4 - haydentech - 02-02-2019

In admin.php, you have this function:

 function usView($file){
   global $abs_us_root;
   global $us_url_root;
   if(file_exists($abs_us_root.$us_url_root.'usersc/includes/admin/'.$file)){
     $path = $abs_us_root.$us_url_root.'usersc/admin/'.$file;
   }else{
     $path = $abs_us_root.$us_url_root.'users/views/'.$file;
   }
   return $path;
 }


It's looking for the override file in the wrong place.  The line where $path is set seems like it should be:

$path = $abs_us_root.$us_url_root.'usersc/includes/admin/'.$file;

Also, if you fix the aforementioned bug and manage to load a custom view, the admin dashboard also displays on the same screen due to this default code at the end of the switch in admin.php:

   default:
   if($view != ''){
   logger($user->data()->id,"Errors","Tried to visit unsupported view ($view) in admin.php");
   }
   include($abs_us_root.$us_url_root.'users/views/_admin_dashboard.php');



There needs to be some way to not show the dashboard if a custom view has been instantiated earlier. Also, there's no need to log an error in this situation.


RE: Bug in admin.php in 4.4 - Brandin - 02-03-2019

Thanks for the report, Hayden. We'll look into this.


RE: Bug in admin.php in 4.4 - mudmin - 02-06-2019

(02-02-2019, 12:36 AM)haydentech Wrote: In admin.php, you have this function:

 function usView($file){
   global $abs_us_root;
   global $us_url_root;
   if(file_exists($abs_us_root.$us_url_root.'usersc/includes/admin/'.$file)){
     $path = $abs_us_root.$us_url_root.'usersc/admin/'.$file;
   }else{
     $path = $abs_us_root.$us_url_root.'users/views/'.$file;
   }
   return $path;
 }


It's looking for the override file in the wrong place.  The line where $path is set seems like it should be:

$path = $abs_us_root.$us_url_root.'usersc/includes/admin/'.$file;

Also, if you fix the aforementioned bug and manage to load a custom view, the admin dashboard also displays on the same screen due to this default code at the end of the switch in admin.php:

   default:
   if($view != ''){
   logger($user->data()->id,"Errors","Tried to visit unsupported view ($view) in admin.php");
   }
   include($abs_us_root.$us_url_root.'users/views/_admin_dashboard.php');



There needs to be some way to not show the dashboard if a custom view has been instantiated earlier.  Also, there's no need to log an error in this situation.

Hi Hayden. Thanks so much for the report. I think I got it.  This replaces users/admin.php
https://pastebin.com/iqP2b1Uu

The way this works is if you take that view called users/views/_aaaa_master_view_template.php and copy it to usersc/includes/admin/whatever.php you can call
admin.php?view=whatever and your view will load.  If you call admin.php?view=whatever2 and that file doesn't exist, you'll just get the dashboard.

Let me know if that works for you. It's slated to go out in 4.4.02
Thanks for your help.