Jump to content

alerts in serverstatus.php only displayed if client has an account on that server


Newton

Recommended Posts

Hello, 

I've modified serverstatus so that the client only see the status of the servers he has a websites hosted on (and not the full list of all of our servers). 

I've also added (thanks to brian! here too) announcements and network issues in the client area (which are only displayed for clients hosted on that specific server)

However, I'm stuck with these same critical annoucements on serverstatus page (serverstatus.tpl). Right now, any alert is displayed for all users, whether they are or not hosted on the server with issues. How can I modify that as well so that alerts are only visible for those who are affected?

Thanks. 

Link to comment
Share on other sites

13 hours ago, Newton said:

How can I modify that as well so that alerts are only visible for those who are affected?

i'm assuming you're referring to...

then to do it on the server page should only require a similar hook (at least with regards to the db query), and use ClientAreaPageServerStatus instead of ClientAreaPageHome...

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function serverstatus_network_issues_hook($vars) {

   $client = Menu::context('client');

   $networkissues = Capsule::table('tblnetworkissues')
                       ->join('tblhosting', 'tblnetworkissues.server', '=', 'tblhosting.server')
                       ->leftjoin('tblservers','tblnetworkissues.server', '=', 'tblservers.id')
                       ->select('tblnetworkissues.*','tblservers.name as server')
                       ->where('tblhosting.userid', $client->id)
                       ->where('tblnetworkissues.status','<>','Resolved')
                       ->where('tblnetworkissues.type','Server')
                       ->orderby('tblnetworkissues.lastupdate','desc')
                       ->groupby('tblnetworkissues.id')
                       ->take(2)
                       ->get();

   $encodedata = json_encode($networkissues);
   $decodedata = json_decode($encodedata, true);

   return array("issues" => $decodedata);
}
add_hook("ClientAreaPageServerStatus", 1, "serverstatus_network_issues_hook");
?>

I can see an issue with date formats, but you could fix that in the hook, or in the template using Smarty... other than that, the above hook looks fine to me. :!:

Link to comment
Share on other sites

That was easy :-P  Many thanks brian!

Works perfect, date was indeed a bit off but an easy fix.

This is my final code for those who might need something similar :

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function homepage_network_issues_hook($vars) {

   $client = Menu::context('client');
   $date = fromMySQLDate($date, $includeTime, $applyClientDateFormat);

   $networkissues = Capsule::table('tblnetworkissues')
                       ->join('tblhosting', 'tblnetworkissues.server', '=', 'tblhosting.server')
                       ->leftjoin('tblservers','tblnetworkissues.server', '=', 'tblservers.id')
                       ->select('tblnetworkissues.*','tblservers.name')
                       ->where('tblhosting.userid', $client->id)
                       ->where('tblnetworkissues.status','<>','Resolved')
                       ->where('tblnetworkissues.type','Server')
                       ->orderby('tblnetworkissues.lastupdate','desc')
                       ->groupby('tblnetworkissues.id')
                       ->take(2)
                       ->get();

   $encodedata = json_encode($networkissues);
   $decodedata = json_decode($encodedata, true);

   return array("networkissues" => $decodedata);
}
add_hook("ClientAreaPageServerStatus", 1, "serverstatus_network_issues_hook");
?>

 

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated