mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Merge remote-tracking branch 'origin/develop' into feature/backoffice-full-moon-design
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
define('ITOP_APPLICATION', 'iTop');
|
||||
define('ITOP_APPLICATION_SHORT', 'iTop');
|
||||
define('ITOP_VERSION', '2.7.0-dev');
|
||||
define('ITOP_VERSION', '2.8.0-dev');
|
||||
define('ITOP_REVISION', 'svn');
|
||||
define('ITOP_BUILD_DATE', '$WCNOW$');
|
||||
define('ITOP_VERSION_FULL', ITOP_VERSION.'-'.ITOP_REVISION);
|
||||
|
||||
@@ -859,10 +859,14 @@ class DBObjectSearch extends DBSearch
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DBObjectSearch $oFilter
|
||||
* @param $sExtKeyAttCode
|
||||
* Add a link to another filter, using an extkey already present in current filter
|
||||
*
|
||||
* @param DBObjectSearch $oFilter filter to join to
|
||||
* @param string $sExtKeyAttCode extkey present in current filter, that allows to points to $oFilter
|
||||
* @param int $iOperatorCode
|
||||
* @param null $aRealiasingMap array of <old-alias> => <new-alias>, for each alias that has changed
|
||||
* @param array $aRealiasingMap array of <old-alias> => <new-alias>, for each alias that has changed.
|
||||
* Doesn't change existing alias, use {@link \DBObjectSearch::RenameAlias()} for that.
|
||||
*
|
||||
* @throws CoreException
|
||||
* @throws CoreWarning
|
||||
*/
|
||||
|
||||
@@ -1848,7 +1848,7 @@ abstract class MetaModel
|
||||
* @param string $sClass
|
||||
* @param string $sListCode
|
||||
*
|
||||
* @return array
|
||||
* @return array list of attribute codes
|
||||
*/
|
||||
public static function GetZListItems($sClass, $sListCode)
|
||||
{
|
||||
@@ -1868,6 +1868,82 @@ abstract class MetaModel
|
||||
return self::GetZListItems($sParentClass, $sListCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRemoteClass
|
||||
*
|
||||
* @return \AttributeDefinition[] list of attdefs to display by default for the remote class
|
||||
*
|
||||
* @since 2.8.0 N°2334
|
||||
*/
|
||||
public static function GetZListAttDefsFilteredForIndirectRemoteClass($sRemoteClass)
|
||||
{
|
||||
$aAttCodesToPrint = [];
|
||||
|
||||
foreach (MetaModel::GetZListItems($sRemoteClass, 'list') as $sFieldCode)
|
||||
{
|
||||
//TODO: check the state of the attribute: hidden or visible ?
|
||||
if ($sFieldCode == 'finalclass')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$oRemoteAttDef = MetaModel::GetAttributeDef($sRemoteClass, $sFieldCode);
|
||||
$aAttCodesToPrint[] = $oRemoteAttDef;
|
||||
}
|
||||
|
||||
return $aAttCodesToPrint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sClass left class
|
||||
* @param string $sAttCode AttributeLinkedSetIndirect attcode
|
||||
*
|
||||
* @return \AttributeDefinition[] list of attdefs to display by default for lnk class
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @since 2.8.0 N°2334
|
||||
*/
|
||||
public static function GetZListAttDefsFilteredForIndirectLinkClass($sClass, $sAttCode)
|
||||
{
|
||||
$aAttCodesToPrint = [];
|
||||
|
||||
$oLinkedSetAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
$sLinkedClass = $oLinkedSetAttDef->GetLinkedClass();
|
||||
$sExtKeyToRemote = $oLinkedSetAttDef->GetExtKeyToRemote();
|
||||
$sExtKeyToMe = $oLinkedSetAttDef->GetExtKeyToMe();
|
||||
|
||||
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
|
||||
$sDefaultState = MetaModel::GetDefaultState($sClass);
|
||||
|
||||
foreach (MetaModel::FlattenZList(MetaModel::GetZListItems($sLinkedClass, 'list')) as $sLnkAttCode)
|
||||
{
|
||||
$oLnkAttDef = MetaModel::GetAttributeDef($sLinkedClass, $sLnkAttCode);
|
||||
if ($sStateAttCode == $sLnkAttCode)
|
||||
{
|
||||
// State attribute is always hidden from the UI
|
||||
continue;
|
||||
}
|
||||
if (($sLnkAttCode == $sExtKeyToMe)
|
||||
|| ($sLnkAttCode == $sExtKeyToRemote)
|
||||
|| ($sLnkAttCode == 'finalclass'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!($oLnkAttDef->IsWritable()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$iFlags = MetaModel::GetAttributeFlags($sLinkedClass, $sDefaultState, $sLnkAttCode);
|
||||
if (!($iFlags & OPT_ATT_HIDDEN) && !($iFlags & OPT_ATT_READONLY))
|
||||
{
|
||||
$aAttCodesToPrint[] = $oLnkAttDef;
|
||||
}
|
||||
}
|
||||
|
||||
return $aAttCodesToPrint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sClass
|
||||
* @param string $sListCode
|
||||
|
||||
@@ -30,6 +30,9 @@ require_once('dbobjectiterator.php');
|
||||
|
||||
class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
{
|
||||
public const LINK_ALIAS = 'Link';
|
||||
public const REMOTE_ALIAS = 'Remote';
|
||||
|
||||
protected $sHostClass; // subclass of DBObject
|
||||
protected $sAttCode; // xxxxxx_list
|
||||
protected $sClass; // class of the links
|
||||
@@ -786,11 +789,13 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
/**
|
||||
* @param bool $bShowObsolete
|
||||
*
|
||||
* @return \DBObjectSet
|
||||
* @return \DBObjectSet indirect relations will get `SELECT L,R ...` (l = lnk class, R = remote)
|
||||
* @throws \CoreException
|
||||
* @throws \CoreWarning
|
||||
* @throws \MySQLException
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 2.8.0 N°2334 returns both lnk and remote classes for indirect relations
|
||||
*/
|
||||
public function ToDBObjectSet($bShowObsolete = true)
|
||||
{
|
||||
@@ -802,7 +807,11 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
|
||||
/** @var \AttributeExternalKey $oLinkingAttDef */
|
||||
$oLinkingAttDef = MetaModel::GetAttributeDef($this->sClass, $sExtKeyToRemote);
|
||||
|
||||
// N°2334 add pointed class (SELECT L,R) to have all fields (lnk + remote) in display
|
||||
// the pointed class is always present in the search, as generated by \AttributeLinkedSet::GetDefaultValue
|
||||
$sTargetClass = $oLinkingAttDef->GetTargetClass();
|
||||
$oRemoteClassSearch = new DBObjectSearch($sTargetClass);
|
||||
if (!$bShowObsolete && MetaModel::IsObsoletable($sTargetClass))
|
||||
{
|
||||
$oNotObsolete = new BinaryExpression(
|
||||
@@ -810,10 +819,12 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
'=',
|
||||
new ScalarExpression(0)
|
||||
);
|
||||
$oNotObsoleteRemote = new DBObjectSearch($sTargetClass);
|
||||
$oNotObsoleteRemote->AddConditionExpression($oNotObsolete);
|
||||
$oLinkSearch->AddCondition_PointingTo($oNotObsoleteRemote, $sExtKeyToRemote);
|
||||
$oRemoteClassSearch->AddConditionExpression($oNotObsolete);
|
||||
}
|
||||
$oLinkSearch->AddCondition_PointingTo($oRemoteClassSearch, $sExtKeyToRemote);
|
||||
$oLinkSearch->RenameAlias($oLinkSearch->GetClassAlias(), self::LINK_ALIAS);
|
||||
$oLinkSearch->RenameAlias($sTargetClass, self::REMOTE_ALIAS);
|
||||
$oLinkSearch->SetSelectedClasses([self::LINK_ALIAS, self::REMOTE_ALIAS]);
|
||||
}
|
||||
$oLinkSet = new DBObjectSet($oLinkSearch);
|
||||
$oLinkSet->SetShowObsoleteData($bShowObsolete);
|
||||
|
||||
Reference in New Issue
Block a user