ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilDclTableView Class Reference
+ Inheritance diagram for ilDclTableView:
+ Collaboration diagram for ilDclTableView:

Public Member Functions

 getId ()
 
 setId (int $id)
 
 getTableId ()
 
 setTableId (int $table_id)
 
 getTitle ()
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $description)
 
 getRoles ()
 
 setRoles (array $roles)
 
 getRoleLimitation ()
 
 setRoleLimitation (bool $role_limitation)
 
 sleep ($field_name)
 
 wakeUp ($field_name, $field_value)
 
 delete ()
 
 getTable ()
 
 getFilterableFieldSettings ()
 getFilterableFields Returns all fieldsetting-objects of this tableview which have set their filterable to true, including standard fields. More...
 
 getVisibleFields ()
 Returns all field-objects of this tableview which have set their visibility to true, including standard fields. More...
 
 getFieldSettings ()
 
 getFieldSetting ($field_id)
 
 create (bool $create_default_settings=true)
 
 createDefaultSettings ()
 create default ilDclTableViewFieldSetting entries More...
 
 createFieldSetting ($field_id)
 create ilDclTableViewFieldSetting for this tableview and the given field id More...
 
 cloneStructure (ilDclTableView $orig, array $new_fields)
 
- Public Member Functions inherited from ActiveRecord
 getArConnector ()
 
 getArFieldList ()
 
 getConnectorContainerName ()
 @description Return the Name of your Connector Table More...
 
 setConnectorContainerName (string $connector_container_name)
 
 getPrimaryFieldValue ()
 
 setPrimaryFieldValue ($value)
 
 __construct (mixed $primary_key=0)
 
 storeObjectToCache ()
 
 asStdClass ()
 
 asArray ()
 
 buildFromArray (array $array)
 
 fixDateField ($field_name, string $value)
 
 sleep ($field_name)
 
 wakeUp ($field_name, $field_value)
 
 getArrayForConnector ()
 
 installConnector ()
 
 store ()
 
 save ()
 
 create ()
 
 copy (int $new_id=0)
 
 afterObjectLoad ()
 
 read ()
 
 update ()
 
 delete ()
 
 __call ($name, $arguments)
 

Static Public Member Functions

static returnDbTableName ()
 
static findOrGetInstance ($primary_key, array $add_constructor_args=[])
 
static getAllForTableId (int $table_id)
 
static createOrGetStandardView (int $table_id)
 
- Static Public Member Functions inherited from ActiveRecord
static returnDbTableName ()
 
static installDB ()
 
static renameDBField (string $old_name, string $new_name)
 
static tableExists ()
 
static fieldExists (string $field_name)
 
static removeDBField (string $field_name)
 
static updateDB ()
 
static resetDB ()
 
static truncateDB ()
 
static flushDB ()
 @depracated never use in ILIAS Core, Plugins only More...
 
static preloadObjects ()
 
static additionalParams (array $additional_params)
 
static findOrFail ($primary_key, array $add_constructor_args=[])
 Tries to find the object and throws an Exception if object is not found, instead of returning null. More...
 
static findOrGetInstance ($primary_key, array $add_constructor_args=[])
 
static where ($where, $operator=null)
 
static innerjoinAR (ActiveRecord $activeRecord, $on_this, string $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static innerjoin (string $tablename, $on_this, string $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static leftjoin (string $tablename, $on_this, string $on_external, array $fields=[' *'], string $operator='=', bool $both_external=false)
 
static orderBy (string $orderBy, string $orderDirection='ASC')
 
static dateFormat (string $date_format='d.m.Y - H:i:s')
 
static limit (int $start, int $end)
 
static affectedRows ()
 
static count ()
 
static get ()
 
static debug ()
 
static first ()
 
static getCollection ()
 
static last ()
 
static getFirstFromLastQuery ()
 
static connector (arConnector $arConnector)
 
static raw (bool $set_raw=true)
 
static getArray (?string $key=null, string|array|null $values=null)
 
static _toCamelCase (string $str, bool $capitalise_first_char=false)
 

Protected Attributes

int $id
 
int $table_id = 0
 
string $title = ""
 
array $roles = []
 
bool $role_limitation = false
 
string $description = ''
 
array $visible_fields_cache = []
 
- Protected Attributes inherited from ActiveRecord
bool $ar_safe_read = true
 
string $connector_container_name = ''
 
bool $is_new = true
 

Additional Inherited Members

- Protected Member Functions inherited from ActiveRecord
 installDatabase ()
 
- Static Protected Member Functions inherited from ActiveRecord
static getCalledClass ()
 @description Returns an instance of the instatiated calling active record (needs to be done in static methods) @TODO : This should be cached somehow More...
 
static fromCamelCase (string $str)
 

Detailed Description

Definition at line 21 of file class.ilDclTableView.php.

Member Function Documentation

◆ cloneStructure()

ilDclTableView::cloneStructure ( ilDclTableView  $orig,
array  $new_fields 
)
Parameters
ilDclTableView$orig
array$new_fieldsfields mapping

Definition at line 333 of file class.ilDclTableView.php.

333 : void
334 {
335 global $DIC;
336 //clone structure
337 $this->setTitle($orig->getTitle() . ' ' . $DIC->language()->txt('copy_of_suffix'));
338 $this->setDescription($orig->getDescription());
339 $this->setRoles($orig->getRoles());
340 $this->setRoleLimitation($orig->getRoleLimitation());
341 $this->create(false); //create default setting, adjust them later
342
343 //clone default values
345
346 //clone fieldsettings
347 foreach ($orig->getFieldSettings() as $orig_fieldsetting) {
348 $new_fieldsetting = new ilDclTableViewFieldSetting();
349 $new_fieldsetting->setTableviewId($this->getId());
350 if ($new_fields[$orig_fieldsetting->getField()] ?? null) {
351 //normal fields
352 $new_fieldsetting->setField($new_fields[$orig_fieldsetting->getField()]->getId());
353 } else {
354 //standard fields
355 $new_fieldsetting->setField($orig_fieldsetting->getField());
356 }
357 $new_field_id = $new_fieldsetting->cloneStructure($orig_fieldsetting);
358
359 //clone default value
360 $datatype = $orig_fieldsetting->getFieldObject()->getDatatypeId();
361 $match = ilDclTableViewBaseDefaultValue::findSingle($datatype, $orig_fieldsetting->getId());
362
363 if (!is_null($match)) {
364 $new_default_value = $f->create($datatype);
365 $new_default_value->setTviewSetId($new_field_id);
366 $new_default_value->setValue($match->getValue());
367 $new_default_value->create();
368 }
369 }
370 $this->createFieldSetting('comments');
371
372 //clone pageobject
374 $orig_pageobject = new ilDclDetailedViewDefinition($orig->getId());
375 $orig_pageobject->copy($this->getId());
376 }
377
378 // mandatory for all cloning functions
380 }
const TYPE_TABLEVIEW
static setCloneOf(int $old, int $new, string $type)
setTitle(string $title)
setRoleLimitation(bool $role_limitation)
setDescription(string $description)
setRoles(array $roles)
createFieldSetting($field_id)
create ilDclTableViewFieldSetting for this tableview and the given field id
global $DIC
Definition: shib_login.php:26

References $DIC, Vendor\Package\$f, ActiveRecord\create(), createFieldSetting(), ilDclDetailedViewDefinition\exists(), getDescription(), getFieldSettings(), getId(), getRoleLimitation(), getRoles(), getTitle(), ilDclCache\setCloneOf(), setDescription(), setRoleLimitation(), setRoles(), setTitle(), and ilDclCache\TYPE_TABLEVIEW.

+ Here is the call graph for this function:

◆ create()

ilDclTableView::create ( bool  $create_default_settings = true)

Definition at line 275 of file class.ilDclTableView.php.

275 : void
276 {
277 parent::create();
278 if ($create_default_settings) {
279 $this->createDefaultSettings();
280 }
281 }
createDefaultSettings()
create default ilDclTableViewFieldSetting entries

References createDefaultSettings().

+ Here is the call graph for this function:

◆ createDefaultSettings()

ilDclTableView::createDefaultSettings ( )

create default ilDclTableViewFieldSetting entries

Definition at line 286 of file class.ilDclTableView.php.

286 : void
287 {
288 $table = ilDclCache::getTableCache($this->table_id);
289
290 foreach ($table->getFieldIds() as $field_id) {
291 $this->createFieldSetting($field_id);
292 }
293
294 //ilDclTable->getFieldIds won't reuturn comments if they are disabled,
295 //still we have to create a fieldsetting for this field
296 if (!$table->getPublicCommentsEnabled()) {
297 $this->createFieldSetting('comments');
298 }
299 }
static getTableCache(?int $table_id=null)

References createFieldSetting(), and ilDclCache\getTableCache().

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFieldSetting()

ilDclTableView::createFieldSetting (   $field_id)

create ilDclTableViewFieldSetting for this tableview and the given field id

Parameters
int | string$field_id

Definition at line 305 of file class.ilDclTableView.php.

305 : void
306 {
308 [
309 'tableview_id' => $this->id,
310 'field' => $field_id,
311 ]
312 )->get()
313 ) {
314 $field_set = new ilDclTableViewFieldSetting();
315 $field_set->setTableviewId($this->id);
316 $field_set->setField($field_id);
317 $field_set->setVisible(!ilDclStandardField::_isStandardField($field_id));
318 $field_set->setFilterChangeable(true);
319 $field_set->setLockedCreate(false);
320 $field_set->setLockedEdit(false);
321 $field_set->setRequiredCreate(false);
322 $field_set->setRequiredEdit(false);
323 $field_set->setVisibleCreate(true);
324 $field_set->setVisibleEdit(true);
325 $field_set->create();
326 }
327 }
static where($where, $operator=null)
static _isStandardField($field_id)

References ilDclStandardField\_isStandardField(), and ActiveRecord\where().

Referenced by cloneStructure(), and createDefaultSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createOrGetStandardView()

static ilDclTableView::createOrGetStandardView ( int  $table_id)
static
Parameters
$table_id
Returns
ilDclTableView|ActiveRecord

Definition at line 394 of file class.ilDclTableView.php.

395 {
396 if ($standardview = self::where(['table_id' => $table_id])->first()) {
397 return $standardview;
398 }
399
400 global $DIC;
401 $rbacreview = $DIC['rbacreview'];
402 $http = $DIC->http();
403 $refinery = $DIC->refinery();
404
405 $roles = [];
406
407 $ref_id = $http->wrapper()->query()->retrieve('ref_id', $refinery->kindlyTo()->int());
408 foreach ($rbacreview->getParentRoleIds($ref_id) as $role_array) {
409 $roles[] = $role_array['obj_id'];
410 }
411
412 $view = new self();
413
414 $hasRefId = $http->wrapper()->query()->has('ref_id');
415
416 if ($hasRefId) {
417 global $DIC;
418 $rbacreview = $DIC['rbacreview'];
419
420 $ref_id = $http->wrapper()->query()->retrieve('ref_id', $refinery->kindlyTo()->int());
421
422 $roles = [];
423 foreach ($rbacreview->getParentRoleIds($ref_id) as $role_array) {
424 $roles[] = $role_array['obj_id'];
425 }
426 $view->setRoles(array_merge($roles, $rbacreview->getLocalRoles($ref_id)));
427 }
428 $view->setTableId($table_id);
429 // bugfix mantis 0023307
430 $lng = $DIC['lng'];
431 $view->setTitle($lng->txt('dcl_title_standardview'));
432 $view->create();
433
434 return $view;
435 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$http
Definition: deliver.php:30
$ref_id
Definition: ltiauth.php:66
global $lng
Definition: privfeed.php:31

References $DIC, $http, $lng, $ref_id, ILIAS\UI\examples\Layout\Page\Mail\$refinery, $roles, $table_id, and ActiveRecord\first().

Referenced by ilDclTable\doCreate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilDclTableView::delete ( )

Reimplemented from ActiveRecord.

Definition at line 170 of file class.ilDclTableView.php.

170 : void
171 {
172 //Delete settings
173 foreach ($this->getFieldSettings() as $setting) {
174 $setting->delete();
175 }
176 parent::delete();
177 }

References getFieldSettings().

+ Here is the call graph for this function:

◆ findOrGetInstance()

static ilDclTableView::findOrGetInstance (   $primary_key,
array  $add_constructor_args = [] 
)
static
Returns
ActiveRecord|ilDclTableView

Reimplemented from ActiveRecord.

Definition at line 187 of file class.ilDclTableView.php.

188 {
189 return parent::findOrGetInstance($primary_key, $add_constructor_args);
190 }

Referenced by ilDclRecordEditGUI\__construct(), ilDclCreateViewDefinitionGUI\__construct(), ilDclEditViewDefinitionGUI\__construct(), and ilDclTableViewGUI\executeCommand().

+ Here is the caller graph for this function:

◆ getAllForTableId()

static ilDclTableView::getAllForTableId ( int  $table_id)
static
Returns
ilDclTableView[]|ActiveRecord[]

Definition at line 385 of file class.ilDclTableView.php.

385 : array
386 {
387 return self::where(['table_id' => $table_id])->orderBy('title')->get();
388 }

References $table_id, and ActiveRecord\where().

Referenced by ilDclBaseFieldModel\addToTableViews(), and ilDclTable\getTableViews().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilDclTableView::getDescription ( )

Definition at line 115 of file class.ilDclTableView.php.

115 : string
116 {
117 return $this->description;
118 }

References $description.

Referenced by cloneStructure().

+ Here is the caller graph for this function:

◆ getFieldSetting()

ilDclTableView::getFieldSetting (   $field_id)
Parameters
$field_id
Returns
ilDclTableViewFieldSetting|ActiveRecord

Definition at line 267 of file class.ilDclTableView.php.

268 {
270 'tableview_id' => $this->getId(),
271 'field' => $field_id
272 ])->first();
273 }

References getId(), and ActiveRecord\where().

+ Here is the call graph for this function:

◆ getFieldSettings()

ilDclTableView::getFieldSettings ( )
Returns
ilDclTableViewFieldSetting[]
Exceptions
arException

Definition at line 243 of file class.ilDclTableView.php.

243 : array
244 {
246 [
247 'tableview_id' => $this->getId(),
248 'il_dcl_tfield_set.table_id' => $this->getTableId(),
249 ]
250 )->innerjoin('il_dcl_tfield_set', 'field', 'field', [])->orderBy('il_dcl_tfield_set.field_order')->get();
251
252 $result = [];
253 foreach ($settings as $setting) {
254 $datatype = $setting->getFieldObject()->getDatatypeId();
255 if ($datatype === null || in_array($datatype, array_keys(ilDclDatatype::getAllDatatype()))) {
256 $result[] = $setting;
257 }
258 }
259
260 return $result;
261 }
static getAllDatatype(bool $force=false)
Get all possible Datatypes.

References ilDclDatatype\getAllDatatype(), getId(), getTableId(), and ActiveRecord\where().

Referenced by cloneStructure(), and delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilterableFieldSettings()

ilDclTableView::getFilterableFieldSettings ( )

getFilterableFields Returns all fieldsetting-objects of this tableview which have set their filterable to true, including standard fields.

Returns
ilDclBaseFieldModel[]|ilDclTableViewFieldSetting[]

Definition at line 197 of file class.ilDclTableView.php.

197 : array
198 {
200 [
201 "tableview_id" => $this->id,
202 'in_filter' => 1,
203 'il_dcl_tfield_set.table_id' => $this->getTableId(),
204 ]
205 )->innerjoin('il_dcl_tfield_set', 'field', 'field', [])
206 ->orderBy('il_dcl_tfield_set.field_order')
207 ->get();
208 }

References getTableId(), and ActiveRecord\where().

+ Here is the call graph for this function:

◆ getId()

ilDclTableView::getId ( )

Definition at line 85 of file class.ilDclTableView.php.

85 : ?int
86 {
87 return $this->id;
88 }

References $id.

Referenced by cloneStructure(), ilDclTableViewGUI\getActions(), getFieldSetting(), and getFieldSettings().

+ Here is the caller graph for this function:

◆ getRoleLimitation()

ilDclTableView::getRoleLimitation ( )

Definition at line 135 of file class.ilDclTableView.php.

135 : bool
136 {
138 }

References $role_limitation.

Referenced by cloneStructure(), and ilObjDataCollectionAccess\hasAccessToTableView().

+ Here is the caller graph for this function:

◆ getRoles()

ilDclTableView::getRoles ( )

Definition at line 125 of file class.ilDclTableView.php.

125 : array
126 {
127 return $this->roles;
128 }

References $roles.

Referenced by cloneStructure(), and ilObjDataCollectionAccess\hasAccessToTableView().

+ Here is the caller graph for this function:

◆ getTable()

ilDclTableView::getTable ( )

Definition at line 179 of file class.ilDclTableView.php.

179 : ilDclTable
180 {
181 return ilDclCache::getTableCache($this->table_id);
182 }

References ilDclCache\getTableCache().

+ Here is the call graph for this function:

◆ getTableId()

ilDclTableView::getTableId ( )

Definition at line 95 of file class.ilDclTableView.php.

95 : int
96 {
97 return $this->table_id;
98 }

References $table_id.

Referenced by getFieldSettings(), getFilterableFieldSettings(), and getVisibleFields().

+ Here is the caller graph for this function:

◆ getTitle()

ilDclTableView::getTitle ( )

Definition at line 105 of file class.ilDclTableView.php.

105 : string
106 {
107 return $this->title;
108 }

References $title.

Referenced by cloneStructure().

+ Here is the caller graph for this function:

◆ getVisibleFields()

ilDclTableView::getVisibleFields ( )

Returns all field-objects of this tableview which have set their visibility to true, including standard fields.

Returns
ilDclBaseFieldModel[]|ilDclTableViewFieldSetting[]

Definition at line 214 of file class.ilDclTableView.php.

214 : array
215 {
216 if (!$this->visible_fields_cache) {
218 [
219 "tableview_id" => $this->id,
220 'visible' => true,
221 'il_dcl_tfield_set.table_id' => $this->getTableId(),
222 ]
223 )->innerjoin(
224 'il_dcl_tfield_set',
225 'field',
226 'field',
227 []
228 )->orderBy('il_dcl_tfield_set.field_order')->get();
229 $fields = [];
230 foreach ($visible as $field_rec) {
231 $fields[] = $field_rec->getFieldObject();
232 }
233 $this->visible_fields_cache = $fields;
234 }
235
237 }

References $visible_fields_cache, getTableId(), and ActiveRecord\where().

+ Here is the call graph for this function:

◆ returnDbTableName()

static ilDclTableView::returnDbTableName ( )
static
Returns
string @description Return the Name of your Database Table

Reimplemented from ActiveRecord.

Definition at line 80 of file class.ilDclTableView.php.

80 : string
81 {
82 return "il_dcl_tableview";
83 }

◆ setDescription()

ilDclTableView::setDescription ( string  $description)

Definition at line 120 of file class.ilDclTableView.php.

120 : void
121 {
122 $this->description = $description;
123 }

References $description.

Referenced by cloneStructure().

+ Here is the caller graph for this function:

◆ setId()

ilDclTableView::setId ( int  $id)

Definition at line 90 of file class.ilDclTableView.php.

90 : void
91 {
92 $this->id = $id;
93 }

References $id.

◆ setRoleLimitation()

ilDclTableView::setRoleLimitation ( bool  $role_limitation)

Definition at line 140 of file class.ilDclTableView.php.

140 : void
141 {
142 $this->role_limitation = $role_limitation;
143 }

References $role_limitation.

Referenced by cloneStructure().

+ Here is the caller graph for this function:

◆ setRoles()

ilDclTableView::setRoles ( array  $roles)

Definition at line 130 of file class.ilDclTableView.php.

130 : void
131 {
132 $this->roles = $roles;
133 }

References $roles.

Referenced by cloneStructure().

+ Here is the caller graph for this function:

◆ setTableId()

ilDclTableView::setTableId ( int  $table_id)

Definition at line 100 of file class.ilDclTableView.php.

100 : void
101 {
102 $this->table_id = $table_id;
103 }

References $table_id.

◆ setTitle()

ilDclTableView::setTitle ( string  $title)

Definition at line 110 of file class.ilDclTableView.php.

110 : void
111 {
112 $this->title = $title;
113 }

References $title.

Referenced by cloneStructure().

+ Here is the caller graph for this function:

◆ sleep()

ilDclTableView::sleep (   $field_name)
Parameters
string$field_name

Reimplemented from ActiveRecord.

Definition at line 148 of file class.ilDclTableView.php.

148 : ?string
149 {
150 if ($field_name == 'roles') {
151 return json_encode($this->roles);
152 }
153
154 return null;
155 }

◆ wakeUp()

ilDclTableView::wakeUp (   $field_name,
  $field_value 
)
Parameters
string$field_name
int | string$field_value

Reimplemented from ActiveRecord.

Definition at line 161 of file class.ilDclTableView.php.

161 : ?array
162 {
163 if ($field_name == 'roles') {
164 return json_decode($field_value);
165 }
166
167 return null;
168 }

Field Documentation

◆ $description

string ilDclTableView::$description = ''
protected

Definition at line 70 of file class.ilDclTableView.php.

Referenced by getDescription(), and setDescription().

◆ $id

int ilDclTableView::$id
protected

Definition at line 33 of file class.ilDclTableView.php.

Referenced by getId(), and setId().

◆ $role_limitation

bool ilDclTableView::$role_limitation = false
protected

Definition at line 63 of file class.ilDclTableView.php.

Referenced by getRoleLimitation(), and setRoleLimitation().

◆ $roles

array ilDclTableView::$roles = []
protected

Definition at line 56 of file class.ilDclTableView.php.

Referenced by createOrGetStandardView(), getRoles(), and setRoles().

◆ $table_id

int ilDclTableView::$table_id = 0
protected

◆ $title

string ilDclTableView::$title = ""
protected

Definition at line 49 of file class.ilDclTableView.php.

Referenced by getTitle(), and setTitle().

◆ $visible_fields_cache

array ilDclTableView::$visible_fields_cache = []
protected

Definition at line 74 of file class.ilDclTableView.php.

Referenced by getVisibleFields().


The documentation for this class was generated from the following file: