Skip to content

Commit

Permalink
Updates for 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xtophe38 committed Jan 10, 2022
1 parent f1cba94 commit bb6af29
Show file tree
Hide file tree
Showing 12 changed files with 799 additions and 849 deletions.
45 changes: 17 additions & 28 deletions teemip-request-mgmt/src/Hook/IPRequestPlugIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,77 +15,66 @@
use utils;
use WebPage;

class IPRequestPlugIn implements iApplicationUIExtension
{
class IPRequestPlugIn implements iApplicationUIExtension {
/**
* @inheritdoc
*/
public function OnDisplayProperties($oObject, WebPage $oPage, $bEditMode = false)
{
public function OnDisplayProperties($oObject, WebPage $oPage, $bEditMode = false) {
}

/**
* @inheritdoc
*/
public function OnDisplayRelations($oObject, WebPage $oPage, $bEditMode = false)
{
public function OnDisplayRelations($oObject, WebPage $oPage, $bEditMode = false) {
}

/**
* @inheritdoc
*/
public function OnFormSubmit($oObject, $sFormPrefix = '')
{
public function OnFormSubmit($oObject, $sFormPrefix = '') {
}

public function OnFormCancel($sTempId)
{

public function OnFormCancel($sTempId) {
}

/**
* @inheritdoc
*/
public function EnumUsedAttributes($oObject)
{
public function EnumUsedAttributes($oObject) {
return array();
}

/**
* @inheritdoc
*/
public function GetIcon($oObject)
{
public function GetIcon($oObject) {
return '';
}

/**
* @inheritdoc
*/
public function GetHilightClass($oObject)
{
public function GetHilightClass($oObject) {
return HILIGHT_CLASS_NONE;
}

/**
* @inheritdoc
*/
public function EnumAllowedActions(DBObjectSet $oSet)
{
public function EnumAllowedActions(DBObjectSet $oSet) {
$oObj = $oSet->Fetch();

// Additional actions for IPRequest
if ($oObj instanceof IPRequest)
{
// Add action if in new state only
if ($oObj->Get('status') == 'assigned')
{
if ($oObj instanceof IPRequest) {
// Add action if in assigned state only
if ($oObj->Get('status') == 'assigned') {
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();

$sClass = get_class($oObj);
if (UserRights::IsStimulusAllowed($sClass, 'ev_resolve'))
{
if (UserRights::IsStimulusAllowed($sClass, 'ev_resolve')) {
$id = $oObj->GetKey();

return array(Dict::S('UI:IPManagement:Action:Implement:IPRequest') => utils::GetAbsoluteUrlModulesRoot()."teemip-request-mgmt/ui.teemip-request-mgmt.php?operation=stimulus&stimulus=ev_resolve&class=$sClass&id=$id&$sContext");
}
}
Expand Down
39 changes: 14 additions & 25 deletions teemip-request-mgmt/src/Model/AttributeClassWithIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,44 @@
* - that have an external key to an IPAddress or to an IPvnAddress (n = 4 or 6)
*/

class AttributeClassWithIP extends AttributeString
{
public function GetAllowedValues($aArgs = array(), $sContains = '')
{
class AttributeClassWithIP extends AttributeString {
public function GetAllowedValues($aArgs = array(), $sContains = '') {
$oHostObj = null;
$aValues = array();
if (isset($aArgs['this']))
{
if (isset($aArgs['this'])) {
$oHostObj = $aArgs['this'];
}
elseif (isset($aArgs['this->object()']))
{
} elseif (isset($aArgs['this->object()'])) {
$oHostObj = $aArgs['this->object()'];
}
if ($oHostObj != null)
{
if ($oHostObj != null) {
$iOrgId = $oHostObj->Get('org_id');

$aCIClassesWithIp = IPAddress::GetListOfClassesWIthIP('leaf');
foreach($aCIClassesWithIp as $sCIClass => $sKey)
{
foreach ($aCIClassesWithIp as $sCIClass => $sKey) {
$oCISet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT FunctionalCI AS ci WHERE ci.org_id = :org_id AND ci.finalclass = :ciclass"), array(), array('org_id' => $iOrgId, 'ciclass' => $sCIClass));
if ($oCISet->CountExceeds(0))
{
if ($oCISet->CountExceeds(0)) {
$aValues[$sCIClass] = MetaModel::GetName($sCIClass);
}
}
}

return $aValues;
}

public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true)
{
if (empty($sValue))
{
public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true) {
if (empty($sValue)) {
return '';
}

return MetaModel::GetName($sValue);
}

static public function GetFormFieldClass()
{
static public function GetFormFieldClass() {
return '\\Combodo\\iTop\\Form\\Field\\SelectField';
}

public function MakeFormField(DBObject $oObject, $oFormField = null)
{
if ($oFormField === null)
{
public function MakeFormField(DBObject $oObject, $oFormField = null) {
if ($oFormField === null) {
// Later : We should check $this->Get('display_style') and create a Radio / Select / ... regarding its value
$sFormFieldClass = static::GetFormFieldClass();
$oFormField = new $sFormFieldClass($this->GetCode());
Expand Down
45 changes: 16 additions & 29 deletions teemip-request-mgmt/src/Model/AttributeIPFieldInClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,18 @@
* - that point to an IPAddress or to an IPvnAddress (n = 4 or 6)
*/

class AttributeIPFieldInClass extends AttributeString
{
public function GetAllowedValues($aArgs = array(), $sContains = '')
{
class AttributeIPFieldInClass extends AttributeString {
public function GetAllowedValues($aArgs = array(), $sContains = '') {
$oHostObj = null;
$aValues = array();
if (isset($aArgs['this']))
{
if (isset($aArgs['this'])) {
$oHostObj = $aArgs['this'];
}
elseif (isset($aArgs['this->object()']))
{
} elseif (isset($aArgs['this->object()'])) {
$oHostObj = $aArgs['this->object()'];
}
if ($oHostObj != null)
{
if ($oHostObj != null) {
$sThisClass = get_class($oHostObj);
switch ($sThisClass)
{
switch ($sThisClass) {
case 'IPRequestAddressCreateV6':
$sClass = 'IPv6Address';
break;
Expand All @@ -39,44 +32,38 @@ public function GetAllowedValues($aArgs = array(), $sContains = '')
break;
}
$sCiClass = $oHostObj->Get('ciclass');
if ($sCiClass != '')
{
if ($sCiClass != '') {
$aCIClassesWithIp = IPAddress::GetListOfClassesWIthIP('leaf');
foreach($aCIClassesWithIp[$sCiClass]['IPAddress'] as $sKey => $sAttribute)
{
foreach ($aCIClassesWithIp[$sCiClass]['IPAddress'] as $sKey => $sAttribute) {
$oAttDef = MetaModel::GetAttributeDef($sCiClass, $sAttribute);
$aValues[$oAttDef->GetCode()] = $oAttDef->GetLabel();
}
foreach($aCIClassesWithIp[$sCiClass][$sClass] as $sKey => $sAttribute)
{
foreach ($aCIClassesWithIp[$sCiClass][$sClass] as $sKey => $sAttribute) {
$oAttDef = MetaModel::GetAttributeDef($sCiClass, $sAttribute);
$aValues[$oAttDef->GetCode()] = $oAttDef->GetLabel();
}
}
}

return $aValues;
}

public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true)
{
if (empty($sValue) || is_null($oHostObject))
{
public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true) {
if (empty($sValue) || is_null($oHostObject)) {
return '';
}
$sCiClass = $oHostObject->Get('ciclass');
$oAttDef = MetaModel::GetAttributeDef($sCiClass, $sValue);

return $oAttDef->GetLabel();
}

static public function GetFormFieldClass()
{
static public function GetFormFieldClass() {
return '\\Combodo\\iTop\\Form\\Field\\SelectField';
}

public function MakeFormField(DBObject $oObject, $oFormField = null)
{
if ($oFormField === null)
{
public function MakeFormField(DBObject $oObject, $oFormField = null) {
if ($oFormField === null) {
// Later : We should check $this->Get('display_style') and create a Radio / Select / ... regarding its value
$sFormFieldClass = static::GetFormFieldClass();
$oFormField = new $sFormFieldClass($this->GetCode());
Expand Down
Loading

0 comments on commit bb6af29

Please sign in to comment.