N°2907 - Keep (standard) read-only tabs visible in edit mode

Specifics:
    - User / Grant matrix
    - Subnet / IP Usage
    - Incident / Known errors
    - UserRequest (Simple/ITIL) / Known errors
Generics:
    - History (moved to activity panel)
    - Notifications
This commit is contained in:
Molkobain
2020-10-19 22:21:33 +02:00
parent deda05351b
commit 71bb071f38
9 changed files with 99 additions and 124 deletions

View File

@@ -169,11 +169,9 @@ class URP_Profiles extends UserRightsBaseClassGUI
function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
{
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage);
}
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage);
}
public static function GetReadOnlyAttributes()

View File

@@ -311,11 +311,9 @@ class URP_Profiles extends UserRightsBaseClassGUI
function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
{
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage);
}
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage);
}
}

View File

@@ -143,11 +143,9 @@ class URP_Profiles extends UserRightsBaseClass
function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
{
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage);
}
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage);
}
}

View File

@@ -738,45 +738,41 @@ EOF
$oExtensionInstance->OnDisplayRelations($this, $oPage, $bEditMode);
}
// Display Notifications after the other tabs since this tab disappears in edition
if (!$bEditMode)
// Look for any trigger that considers this object as "In Scope"
// If any trigger has been found then display a tab with notifications
//
$oTriggerSet = new CMDBObjectSet(new DBObjectSearch('Trigger'));
$aTriggers = array();
while ($oTrigger = $oTriggerSet->Fetch())
{
// Look for any trigger that considers this object as "In Scope"
// If any trigger has been found then display a tab with notifications
//
$oTriggerSet = new CMDBObjectSet(new DBObjectSearch('Trigger'));
$aTriggers = array();
while ($oTrigger = $oTriggerSet->Fetch())
if ($oTrigger->IsInScope($this))
{
if ($oTrigger->IsInScope($this))
{
$aTriggers[] = $oTrigger->GetKey();
}
$aTriggers[] = $oTrigger->GetKey();
}
if (count($aTriggers) > 0)
}
if (count($aTriggers) > 0)
{
$iId = $this->GetKey();
$aParams = array('triggers' => $aTriggers, 'id' => $iId);
$aNotifSearches = array();
$iNotifsCount = 0;
$aNotificationClasses = MetaModel::EnumChildClasses('EventNotification', ENUM_CHILD_CLASSES_EXCLUDETOP);
foreach($aNotificationClasses as $sNotifClass)
{
$iId = $this->GetKey();
$aParams = array('triggers' => $aTriggers, 'id' => $iId);
$aNotifSearches = array();
$iNotifsCount = 0;
$aNotificationClasses = MetaModel::EnumChildClasses('EventNotification', ENUM_CHILD_CLASSES_EXCLUDETOP);
foreach($aNotificationClasses as $sNotifClass)
{
$aNotifSearches[$sNotifClass] = DBObjectSearch::FromOQL("SELECT $sNotifClass AS Ev JOIN Trigger AS T ON Ev.trigger_id = T.id WHERE T.id IN (:triggers) AND Ev.object_id = :id");
$aNotifSearches[$sNotifClass]->SetInternalParams($aParams);
$oNotifSet = new DBObjectSet($aNotifSearches[$sNotifClass], array());
$iNotifsCount += $oNotifSet->Count();
}
// Display notifications regarding the object: on block per subclass to have the interesting columns
$sCount = ($iNotifsCount > 0) ? ' ('.$iNotifsCount.')' : '';
$oPage->SetCurrentTab('UI:NotificationsTab', Dict::S('UI:NotificationsTab').$sCount);
$aNotifSearches[$sNotifClass] = DBObjectSearch::FromOQL("SELECT $sNotifClass AS Ev JOIN Trigger AS T ON Ev.trigger_id = T.id WHERE T.id IN (:triggers) AND Ev.object_id = :id");
$aNotifSearches[$sNotifClass]->SetInternalParams($aParams);
$oNotifSet = new DBObjectSet($aNotifSearches[$sNotifClass], array());
$iNotifsCount += $oNotifSet->Count();
}
// Display notifications regarding the object: on block per subclass to have the interesting columns
$sCount = ($iNotifsCount > 0) ? ' ('.$iNotifsCount.')' : '';
$oPage->SetCurrentTab('UI:NotificationsTab', Dict::S('UI:NotificationsTab').$sCount);
foreach($aNotificationClasses as $sNotifClass)
{
$oPage->p(MetaModel::GetClassIcon($sNotifClass, true).' '.MetaModel::GetName($sNotifClass));
$oBlock = new DisplayBlock($aNotifSearches[$sNotifClass], 'list', false);
$oBlock->Display($oPage, 'notifications_'.$sNotifClass, array('menu' => false));
}
foreach($aNotificationClasses as $sNotifClass)
{
$oPage->p(MetaModel::GetClassIcon($sNotifClass, true).' '.MetaModel::GetName($sNotifClass));
$oBlock = new DisplayBlock($aNotifSearches[$sNotifClass], 'list', false);
$oBlock->Display($oPage, 'notifications_'.$sNotifClass, array('menu' => false));
}
}
}

View File

@@ -512,25 +512,23 @@ abstract class User extends cmdbAbstractObject
function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
{
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage, 'bizmodel,grant_by_profile');
// debug
if (false)
{
$oPage->SetCurrentTab('More on user rigths (dev only)');
$oPage->add("<h3>User rights</h3>\n");
$this->DoShowGrantSumary($oPage, 'addon/userrights');
$oPage->add("<h3>Change log</h3>\n");
$this->DoShowGrantSumary($oPage, 'core/cmdb');
$oPage->add("<h3>Application</h3>\n");
$this->DoShowGrantSumary($oPage, 'application');
$oPage->add("<h3>GUI</h3>\n");
$this->DoShowGrantSumary($oPage, 'gui');
}
$oPage->SetCurrentTab('UI:UserManagement:GrantMatrix');
$this->DoShowGrantSumary($oPage, 'bizmodel,grant_by_profile');
// debug
if (false)
{
$oPage->SetCurrentTab('More on user rigths (dev only)');
$oPage->add("<h3>User rights</h3>\n");
$this->DoShowGrantSumary($oPage, 'addon/userrights');
$oPage->add("<h3>Change log</h3>\n");
$this->DoShowGrantSumary($oPage, 'core/cmdb');
$oPage->add("<h3>Application</h3>\n");
$this->DoShowGrantSumary($oPage, 'application');
$oPage->add("<h3>GUI</h3>\n");
$this->DoShowGrantSumary($oPage, 'gui');
}
}

View File

@@ -4808,8 +4808,6 @@
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
{
$oPage->SetCurrentTab('Class:Subnet/Tab:IPUsage');
$bit_ip = ip2long($this->Get('ip'));
@@ -4852,7 +4850,6 @@
}
$iAnIP++;
}
}
}]]></code>
</method>
</methods>

View File

@@ -1078,25 +1078,22 @@
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
if (MetaModel::IsValidClass('KnownError'))
{
if (MetaModel::IsValidClass('KnownError'))
//Search for known errors
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
$iTicketID = $this->GetKey();;
$oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
$iNumberKE=$oKnownErrorSet->count();
if ($iNumberKE > 0)
{
//Search for known errors
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
$iTicketID = $this->GetKey();;
$oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
$iNumberKE=$oKnownErrorSet->count();
if ($iNumberKE > 0)
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList', Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
}
else
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
}
self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList', Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
}
else
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
}
self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
}
}]]></code>
</method>

View File

@@ -1219,26 +1219,22 @@
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
if (MetaModel::IsValidClass('KnownError'))
{
if (MetaModel::IsValidClass('KnownError'))
{
//Search for known errors
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
$iTicketID = $this->GetKey();;
$oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
$iNumberKE=$oKnownErrorSet->count();
if ($iNumberKE > 0)
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList', Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
}
else
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
}
self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
//Search for known errors
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
$iTicketID = $this->GetKey();;
$oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
$iNumberKE=$oKnownErrorSet->count();
if ($iNumberKE > 0)
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList', Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
}
else
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
}
self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
}
}]]></code>
</method>

View File

@@ -1237,26 +1237,23 @@
{
parent::DisplayBareRelations($oPage, $bEditMode);
if (!$bEditMode)
{
if (MetaModel::IsValidClass('KnownError'))
{
//Search for known errors
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
$iTicketID = $this->GetKey();;
$oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
$iNumberKE=$oKnownErrorSet->count();
if ($iNumberKE > 0)
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList', Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
}
else
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
}
self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
}
}
if (MetaModel::IsValidClass('KnownError'))
{
//Search for known errors
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
$iTicketID = $this->GetKey();;
$oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
$iNumberKE=$oKnownErrorSet->count();
if ($iNumberKE > 0)
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList', Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
}
else
{
$oPage->SetCurrentTab('Class:UserRequest:KnownErrorList');
}
self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
}
}]]></code>
</method>
<method id="resolveChilds">