Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions cake4/rd_cake/src/Controller/Component/CountsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,26 @@ public function countPermanentUsers(int $cloudId): array {
)
->count();

// Suspended users
$suspended = (clone $base)
->where(['PermanentUsers.admin_state' => 'suspended'])
->count();
// Check if admin_state column exists
$PermanentUsers = TableRegistry::getTableLocator()->get('PermanentUsers');
$schema = $PermanentUsers->getSchema();
$hasAdminState = $schema->hasColumn('admin_state');

// Suspended users (only if column exists)
$suspended = 0;
if ($hasAdminState) {
$suspended = (clone $base)
->where(['PermanentUsers.admin_state' => 'suspended'])
->count();
}

// Terminated users
$terminated = (clone $base)
->where(['PermanentUsers.admin_state' => 'terminated'])
->count();
// Terminated users (only if column exists)
$terminated = 0;
if ($hasAdminState) {
$terminated = (clone $base)
->where(['PermanentUsers.admin_state' => 'terminated'])
->count();
}

return [
'total' => (int)$total,
Expand Down
58 changes: 35 additions & 23 deletions cake4/rd_cake/src/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,15 @@ public function itemsFor(){
$tabItem = $this->request->getQuery('item_id');
$cloudId = $this->request->getQuery('cloud_id');
$req_q = $this->request->getQuery();

$comps = [];
$right = false;

if($cloudId){
$r_and_c = $this->Aa->rights_and_components_on_cloud();
$right = $r_and_c['rights'];
$comps = $r_and_c['components'];
if($r_and_c && isset($r_and_c['rights'])){
$right = $r_and_c['rights'];
$comps = $r_and_c['components'] ?? [];
}
}
//$right = $this->Aa->rights_on_cloud();

Expand Down Expand Up @@ -629,7 +633,7 @@ public function itemsFor(){
}

if($tabItem == 'tabMainUsers'){
if($comps['cmp_permanent_users']){
if(isset($comps['cmp_permanent_users']) && $comps['cmp_permanent_users']){
$items[] = [
"title" => "Permanent Users",
"glyph" => "xf2c0@FontAwesome",
Expand All @@ -640,7 +644,7 @@ public function itemsFor(){
]
];
}
if($comps['cmp_vouchers']){
if(isset($comps['cmp_vouchers']) && $comps['cmp_vouchers']){
$items[] = [
"title" => "Vouchers",
"glyph" => "xf145@FontAwesome",
Expand All @@ -663,7 +667,7 @@ public function itemsFor(){
}

if($tabItem == 'tabMainRadius'){
if($comps['cmp_dynamic_clients']){
if(isset($comps['cmp_dynamic_clients']) && $comps['cmp_dynamic_clients']){
$items[] = [
"title" => "RADIUS Clients",
"glyph" => "xf1ce@FontAwesome",
Expand All @@ -674,7 +678,7 @@ public function itemsFor(){
]
];
}
if($comps['cmp_nas']){
if(isset($comps['cmp_nas']) && $comps['cmp_nas']){
$items[] = [
"title" => "NAS",
"glyph" => "xf1cb@FontAwesome",
Expand All @@ -685,7 +689,7 @@ public function itemsFor(){
]
];
}
if($comps['cmp_profiles']){
if(isset($comps['cmp_profiles']) && $comps['cmp_profiles']){
$items[] = [
"title" => "Profiles",
"glyph" => "xf1b3@FontAwesome",
Expand All @@ -697,7 +701,7 @@ public function itemsFor(){
];
}

if($comps['cmp_realms']){
if(isset($comps['cmp_realms']) && $comps['cmp_realms']){
$items[] = [
"title" => "Realms (Groups)",
"glyph" => "xf06c@FontAwesome",
Expand Down Expand Up @@ -725,10 +729,10 @@ public function itemsFor(){
}

if($tabItem == 'tabMainNetworks'){
if($comps['cmp_meshes']){
if(isset($comps['cmp_meshes']) && $comps['cmp_meshes']){
$items['meshes'] = true;
}
if($comps['cmp_ap_profiles']){
if(isset($comps['cmp_ap_profiles']) && $comps['cmp_ap_profiles']){
$items['ap_profiles'] = true;
}
$items['unknown_nodes'] = true;
Expand Down Expand Up @@ -824,15 +828,20 @@ public function usersItems(){
//FIXME This needs some more work in terms of components which should be listed per Access Provider

$cloudId = (int)$this->request->getQuery('cloud_id');
$comps = [];
$right = false;

if($cloudId){
$r_and_c = $this->Aa->rights_and_components_on_cloud();
$right = $r_and_c['rights'];
$comps = $r_and_c['components'];
if($r_and_c && isset($r_and_c['rights'])){
$right = $r_and_c['rights'];
$comps = isset($r_and_c['components']) ? $r_and_c['components'] : [];
}
}

$firstRow = [];

if($comps['cmp_permanent_users']){
if(isset($comps['cmp_permanent_users']) && $comps['cmp_permanent_users']){
$tUsers = $this->Counts->countPermanentUsers($cloudId);
$firstRow['column1'] =
[
Expand All @@ -848,7 +857,7 @@ public function usersItems(){
'accent' => 'blue'
];
}
if($comps['cmp_vouchers']){
if(isset($comps['cmp_vouchers']) && $comps['cmp_vouchers']){
$tVouchers = $this->Counts->countVouchers($cloudId);
$firstRow['column2'] =
[
Expand Down Expand Up @@ -1438,8 +1447,8 @@ private function _get_user_detail($user,$auto_compact=false){

private function _nav_tree($rc){

$rights = $rc['rights'];
$components = $rc['components'];
$rights = isset($rc['rights']) ? $rc['rights'] : false;
$components = isset($rc['components']) ? $rc['components'] : [];
$items = [
[
'text' => 'OVERVIEW',
Expand All @@ -1451,7 +1460,7 @@ private function _nav_tree($rc){
]
];

if($components['cmp_permanent_users'] || $components['cmp_vouchers']){
if(isset($components['cmp_permanent_users']) && isset($components['cmp_vouchers']) && ($components['cmp_permanent_users'] || $components['cmp_vouchers'])){
$items[] = [
'text' => 'USERS',
'leaf' => true,
Expand All @@ -1462,7 +1471,10 @@ private function _nav_tree($rc){
];
}

if($components['cmp_dynamic_clients'] || $components['cmp_nas'] || $components['cmp_profiles'] || $components['cmp_realms'] ){
if((isset($components['cmp_dynamic_clients']) && $components['cmp_dynamic_clients']) ||
(isset($components['cmp_nas']) && $components['cmp_nas']) ||
(isset($components['cmp_profiles']) && $components['cmp_profiles']) ||
(isset($components['cmp_realms']) && $components['cmp_realms'])){
$items[] = [
'text' => 'RADIUS',
'leaf' => true,
Expand All @@ -1473,7 +1485,8 @@ private function _nav_tree($rc){
];
}

if($components['cmp_meshes'] || $components['cmp_ap_profiles']){
if((isset($components['cmp_meshes']) && $components['cmp_meshes']) ||
(isset($components['cmp_ap_profiles']) && $components['cmp_ap_profiles'])){
$items[] = [
'text' => 'NETWORK',
'leaf' => true,
Expand All @@ -1484,7 +1497,7 @@ private function _nav_tree($rc){
];
}

if($components['cmp_other']){
if(isset($components['cmp_other']) && $components['cmp_other']){
$items[] = [
'text' => 'OTHER',
'leaf' => true,
Expand Down Expand Up @@ -1521,5 +1534,4 @@ private function _nav_tree_blank(){

return $items;
}
}

}