public static function GetDisplayExtendedSet(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
 {
     if (empty($aExtraParams['currentId'])) {
         $iListId = $oPage->GetUniqueId();
         // Works only if not in an Ajax page !!
     } else {
         $iListId = $aExtraParams['currentId'];
     }
     $aList = array();
     // Initialize and check the parameters
     $bViewLink = isset($aExtraParams['view_link']) ? $aExtraParams['view_link'] : true;
     $bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true;
     // Check if there is a list of aliases to limit the display to...
     $aDisplayAliases = isset($aExtraParams['display_aliases']) ? explode(',', $aExtraParams['display_aliases']) : array();
     $sZListName = isset($aExtraParams['zlist']) ? $aExtraParams['zlist'] : 'list';
     $aExtraFieldsRaw = isset($aExtraParams['extra_fields']) ? explode(',', trim($aExtraParams['extra_fields'])) : array();
     $aExtraFields = array();
     foreach ($aExtraFieldsRaw as $sFieldName) {
         // Ignore attributes not of the main queried class
         if (preg_match('/^(.*)\\.(.*)$/', $sFieldName, $aMatches)) {
             $sClassAlias = $aMatches[1];
             $sAttCode = $aMatches[2];
             if (array_key_exists($sClassAlias, $oSet->GetSelectedClasses())) {
                 $aExtraFields[$sClassAlias][] = $sAttCode;
             }
         } else {
             $aExtraFields['*'] = $sAttCode;
         }
     }
     $sHtml = '';
     $oAppContext = new ApplicationContext();
     $aClasses = $oSet->GetFilter()->GetSelectedClasses();
     $aAuthorizedClasses = array();
     foreach ($aClasses as $sAlias => $sClassName) {
         if (UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $oSet) && (UR_ALLOWED_YES || UR_ALLOWED_DEPENDS) && (count($aDisplayAliases) == 0 || in_array($sAlias, $aDisplayAliases))) {
             $aAuthorizedClasses[$sAlias] = $sClassName;
         }
     }
     $aAttribs = array();
     foreach ($aAuthorizedClasses as $sAlias => $sClassName) {
         if (array_key_exists($sAlias, $aExtraFields)) {
             $aList[$sAlias] = $aExtraFields[$sAlias];
         } else {
             $aList[$sAlias] = array();
         }
         if ($sZListName !== false) {
             $aDefaultList = self::FlattenZList(MetaModel::GetZListItems($sClassName, $sZListName));
             $aList[$sAlias] = array_merge($aDefaultList, $aList[$sAlias]);
         }
         // Filter the list to removed linked set since we are not able to display them here
         foreach ($aList[$sAlias] as $index => $sAttCode) {
             $oAttDef = MetaModel::GetAttributeDef($sClassName, $sAttCode);
             if ($oAttDef instanceof AttributeLinkedSet) {
                 // Removed from the display list
                 unset($aList[$sAlias][$index]);
             }
         }
     }
     $sSelectMode = 'none';
     $sClassAlias = $oSet->GetClassAlias();
     $oDataTable = new DataTable($iListId, $oSet, $aAuthorizedClasses);
     $oSettings = DataTableSettings::GetDataModelSettings($aAuthorizedClasses, $bViewLink, $aList);
     $bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true;
     if ($bDisplayLimit) {
         $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
         $oSettings->iDefaultPageSize = $iDefaultPageSize;
     }
     $oSettings->aSortOrder = MetaModel::GetOrderByDefault($sClassName);
     return $oDataTable->Display($oPage, $oSettings, $bDisplayMenu, $sSelectMode, $bViewLink, $aExtraParams);
 }
예제 #2
0
 public static function GetTableSettings($aClassAliases, $sTableId = null, $bOnlyOnTable = false)
 {
     $pref = null;
     $oSettings = new DataTableSettings($aClassAliases, $sTableId);
     if ($sTableId != null) {
         // An identified table, let's fetch its own settings (if any)
         $pref = appUserPreferences::GetPref($oSettings->GetPrefsKey($sTableId), null);
     }
     if ($pref == null) {
         if (!$bOnlyOnTable) {
             // Try the global preferred values for this class / set of classes
             $pref = appUserPreferences::GetPref($oSettings->GetPrefsKey(null), null);
         }
         if ($pref == null) {
             // no such settings, use the default values provided by the data model
             return null;
         }
     }
     $oSettings->unserialize($pref);
     return $oSettings;
 }
예제 #3
0
                 $oCurrSettings->ResetToDefault(false);
                 // Reset this table to the defaults
             }
         }
         $bRet = $oSettings->SaveAsDefault();
     } else {
         $bRet = $oSettings->Save();
     }
     $oPage->add($bRet ? 'Ok' : 'KO');
     break;
 case 'datatable_reset_settings':
     $oPage->SetContentType('text/plain');
     $sTableId = utils::ReadParam('table_id', null, false, 'raw_data');
     $aClassAliases = utils::ReadParam('class_aliases', array(), false, 'raw_data');
     $bResetAll = utils::ReadParam('defaults', 'true') == 'true';
     $oSettings = new DataTableSettings($aClassAliases, $sTableId);
     $bRet = $oSettings->ResetToDefault($bResetAll);
     $oPage->add($bRet ? 'Ok' : 'KO');
     break;
     // ui.linkswidget
 // ui.linkswidget
 case 'addObjects':
     $oPage->SetContentType('text/html');
     $sAttCode = utils::ReadParam('sAttCode', '');
     $iInputId = utils::ReadParam('iInputId', '');
     $sSuffix = utils::ReadParam('sSuffix', '');
     $bDuplicates = utils::ReadParam('bDuplicates', 'false') == 'false' ? false : true;
     $sJson = utils::ReadParam('json', '', false, 'raw_data');
     if (!empty($sJson)) {
         $oWizardHelper = WizardHelper::FromJSON($sJson);
         $oObj = $oWizardHelper->GetTargetObject();
예제 #4
0
 public function CloneTableSettings($sTableSettings)
 {
     $aTableSettings = json_decode($sTableSettings, true);
     $oFilter = DBObjectSearch::FromOQL($this->Get('oql'));
     $oCustomSettings = new DataTableSettings($oFilter->GetSelectedClasses());
     $oCustomSettings->iDefaultPageSize = $aTableSettings['iPageSize'];
     $oCustomSettings->aColumns = $aTableSettings['oColumns'];
     $oCustomSettings->Save('shortcut_' . $this->GetKey());
 }