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

Public Member Functions

 __construct (int $a_id=0)
 
 doRead ()
 Read table. More...
 
 doDelete (bool $delete_only_content=false, bool $omit_notification=false)
 Delete table Attention this does not delete the maintable of it's the maintable of the collection. More...
 
 doCreate (bool $create_tablefield_setting=true, bool $create_standardview=true)
 
 doUpdate ()
 
 setId (int $a_id)
 Set table id. More...
 
 getId ()
 Get table id. More...
 
 setObjId (int $a_id)
 
 getObjId ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 getCollectionObject ()
 
 getRecords ()
 
 loadRecords ()
 
 deleteField (int $field_id)
 
 getField (string $field_id)
 
 getFieldIds ()
 
 getCustomFields ()
 
 getNewFieldOrder ()
 getNewOrder More...
 
 getFields ()
 Returns all fields of this table including the standard fields. More...
 
 reloadFields ()
 
 getTableViews ()
 
 getVisibleTableViews (int $user_id=0, bool $with_active_detailedview=false)
 
 getFirstTableViewId (int $user_id=0, bool $with_detailed_view=false)
 
 getFieldsForFormula ()
 Returns all fields of this table including the standard fields, wich are supported for formulas. More...
 
 getRecordFields ()
 Returns all fields of this table which are NOT standard fields. More...
 
 getEditableFields (bool $creation_mode)
 
 getExportableFields ()
 Return all the fields that are marked as exportable. More...
 
 hasPermissionToEditRecord (int $ref_id, ilDclBaseRecordModel $record)
 
 hasPermissionToDeleteRecord (int $ref_id, ilDclBaseRecordModel $record)
 
 hasPermissionToDeleteRecords (int $ref_id)
 
 hasPermissionToViewRecord (int $ref_id, ilDclBaseRecordModel $record, int $user_id=0)
 
 checkLimit ()
 
 updateFields ()
 Update fields. More...
 
 sortFields (array &$fields)
 sortFields More...
 
 buildOrderFields ()
 buildOrderFields orders the fields. More...
 
 getFieldByTitle (string $title)
 Get a field by title. More...
 
 setAddPerm (bool $add_perm)
 
 getAddPerm ()
 
 setDeletePerm (bool $delete_perm)
 
 getDeletePerm ()
 
 setEditByOwner (bool $edit_by_owner)
 
 getEditByOwner ()
 
 getDeleteByOwner ()
 
 setDeleteByOwner (bool $delete_by_owner)
 
 setEditPerm (bool $edit_perm)
 
 getEditPerm ()
 
 setLimited (bool $limited)
 
 getLimited ()
 
 setLimitEnd (string $limit_end)
 
 getLimitEnd ()
 
 setLimitStart (string $limit_start)
 
 getLimitStart ()
 
 setIsVisible (bool $is_visible)
 
 getIsVisible ()
 
 setDescription (string $description)
 
 getDescription ()
 
 setDefaultSortField (string $default_sort_field)
 
 getDefaultSortField ()
 
 setDefaultSortFieldOrder (string $default_sort_field_order)
 
 getDefaultSortFieldOrder ()
 
 setPublicCommentsEnabled (bool $public_comments)
 
 getPublicCommentsEnabled ()
 
 setViewOwnRecordsPerm (bool $view_own_perm)
 
 getViewOwnRecordsPerm ()
 
 getSaveConfirmation ()
 
 setSaveConfirmation (bool $save_confirmation)
 
 hasCustomFields ()
 
 compareOrder (ilDclBaseFieldModel $a, ilDclBaseFieldModel $b)
 
 cloneStructure (ilDclTable $original)
 
 afterClone ()
 
 _hasRecords ()
 _hasRecords More...
 
 addField (ilDclBaseFieldModel $field)
 
 setExportEnabled (bool $export_enabled)
 
 getExportEnabled ()
 
 getOrder ()
 
 updateOrder ()
 
 setOrder (int $table_order)
 
 setImportEnabled (bool $import_enabled)
 
 getImportEnabled ()
 
 getPartialRecords (string $ref_id, string $sort, string $direction, ?int $limit, int $offset, array $filter=[])
 Return only the needed subset of record objects for the table, according to sorting, paging and filters. More...
 
 showInvalidFields (bool $value)
 

Static Public Member Functions

static _tableExists (int $table_id)
 
static _getTableIdByTitle (string $title, int $obj_id)
 
static _hasFieldByTitle (string $title, int $obj_id)
 Checks if a table has a field with the given title. More...
 

Protected Member Functions

 loadObj ()
 
 loadCustomFields ()
 
 doesRecordBelongToUser (ilDclBaseRecordModel $record)
 
 sortByOrder (array &$array)
 

Protected Attributes

int $id = 0
 
int $objId = null
 
ilObjDataCollection $obj = null
 
string $title = ""
 
array $fields = []
 
array $stdFields = []
 
array $records = []
 
bool $is_visible = false
 
bool $add_perm = false
 
bool $edit_perm = false
 
bool $delete_perm = false
 
bool $edit_by_owner = false
 
bool $delete_by_owner = false
 
bool $save_confirmation = false
 
bool $limited = false
 
string $limit_start = ""
 
string $limit_end = ""
 
bool $export_enabled = false
 
int $table_order = 0
 
bool $import_enabled = false
 
string $default_sort_field = "0"
 
string $default_sort_field_order = 'asc'
 Default sort-order (asc|desc) More...
 
string $description = ''
 Description for this table displayed above records. More...
 
bool $public_comments = false
 True if users can add comments on each record of this table. More...
 
int $view_own_records_perm = 0
 True if user can only view his/her own entries in the table. More...
 
array $all_fields = null
 table fields and std fields combined More...
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ilObjUser $user
 
ilDBInterface $db
 
bool $show_invalid = false
 

Detailed Description

Definition at line 24 of file class.ilDclTable.php.

Constructor & Destructor Documentation

◆ __construct()

ilDclTable::__construct ( int  $a_id = 0)

Definition at line 83 of file class.ilDclTable.php.

84 {
85 global $DIC;
86
87 $this->http = $DIC->http();
88 $this->refinery = $DIC->refinery();
89 $this->db = $DIC->database();
90 $this->user = $DIC->user();
91
92 if ($a_id != 0) {
93 $this->id = $a_id;
94 $this->doRead();
95 }
96 }
doRead()
Read table.
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, doRead(), ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getTableIdByTitle()

static ilDclTable::_getTableIdByTitle ( string  $title,
int  $obj_id 
)
static
Parameters
int$obj_idDatacollection object ID where the table belongs to

Definition at line 1090 of file class.ilDclTable.php.

1090 : int
1091 {
1092 global $DIC;
1093 $ilDB = $DIC['ilDB'];
1094
1095 $result = $ilDB->query(
1096 'SELECT id FROM il_dcl_table WHERE title = ' . $ilDB->quote($title, 'text') . ' AND obj_id = '
1097 . $ilDB->quote($obj_id, 'integer')
1098 );
1099 $id = 0;
1100 while ($rec = $ilDB->fetchAssoc($result)) {
1101 $id = $rec['id'];
1102 }
1103
1104 return $id;
1105 }

References $DIC, $id, $ilDB, and $title.

◆ _hasFieldByTitle()

static ilDclTable::_hasFieldByTitle ( string  $title,
int  $obj_id 
)
static

Checks if a table has a field with the given title.

Parameters
string$titleTitle of field
int$obj_idof the table

Definition at line 1159 of file class.ilDclTable.php.

1159 : bool
1160 {
1161 global $DIC;
1162 $ilDB = $DIC['ilDB'];
1163 $result = $ilDB->query(
1164 'SELECT * FROM il_dcl_field WHERE table_id = ' . $ilDB->quote($obj_id, 'integer') . ' AND title = '
1165 . $ilDB->quote($title, 'text')
1166 );
1167
1168 return (bool) $ilDB->numRows($result);
1169 }

References $DIC, $ilDB, and $title.

Referenced by ilDclFieldEditGUI\checkInput().

+ Here is the caller graph for this function:

◆ _hasRecords()

ilDclTable::_hasRecords ( )

_hasRecords

Definition at line 1060 of file class.ilDclTable.php.

1060 : bool
1061 {
1062 return count($this->getRecords()) > 0;
1063 }

References getRecords().

+ Here is the call graph for this function:

◆ _tableExists()

static ilDclTable::_tableExists ( int  $table_id)
static
Returns
bool returns true if there exists a table with id $table_id

Definition at line 1076 of file class.ilDclTable.php.

1076 : bool
1077 {
1078 global $DIC;
1079 $ilDB = $DIC['ilDB'];
1080
1081 $query = "SELECT * FROM il_dcl_table WHERE id = " . $table_id;
1082 $result = $ilDB->query($query);
1083
1084 return $result->numRows() != 0;
1085 }

References $DIC, and $ilDB.

Referenced by ilDclBaseFieldModel\doCreate(), and ilDclBaseRecordModel\doCreate().

+ Here is the caller graph for this function:

◆ addField()

ilDclTable::addField ( ilDclBaseFieldModel  $field)
Parameters
ilDclBaseFieldModel$fieldadd an already created field for eg. ordering.

Definition at line 1068 of file class.ilDclTable.php.

1068 : void
1069 {
1070 $this->all_fields[$field->getId()] = $field;
1071 }

References ilDclBaseFieldModel\getId().

+ Here is the call graph for this function:

◆ afterClone()

ilDclTable::afterClone ( )

Definition at line 1050 of file class.ilDclTable.php.

1050 : void
1051 {
1052 foreach ($this->getFields() as $field) {
1053 $field->afterClone($this->getRecords());
1054 }
1055 }
getFields()
Returns all fields of this table including the standard fields.

References getFields(), and getRecords().

+ Here is the call graph for this function:

◆ buildOrderFields()

ilDclTable::buildOrderFields ( )

buildOrderFields orders the fields.

Definition at line 760 of file class.ilDclTable.php.

760 : void
761 {
762 $fields = $this->getFields();
763 $this->sortByOrder($fields);
764 $count = 10;
765 $offset = 10;
766 foreach ($fields as $field) {
767 if (!is_null($field->getOrder())) {
768 $field->setOrder($count);
769 $count = $count + $offset;
770 $field->doUpdate();
771 }
772 }
773 }
sortByOrder(array &$array)

References $fields, getFields(), and sortByOrder().

Referenced by doCreate().

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

◆ checkLimit()

ilDclTable::checkLimit ( )

Definition at line 687 of file class.ilDclTable.php.

687 : bool
688 {
689 if ($this->getLimited()) {
690 $from = null;
691 $to = null;
692 $now = new ilDateTime(date("Y-m-d H:i:s"), IL_CAL_DATE);
693
694 if ($this->getLimitStart() != "") {
695 $from = new ilDateTime($this->getLimitStart(), IL_CAL_DATE);
696 }
697 if ($this->getLimitEnd() != "") {
698 $to = new ilDateTime($this->getLimitEnd(), IL_CAL_DATE);
699 }
700
701 if ($from == null && $to == null) {
702 return true;
703 }
704 if ($from <= $now && $now <= $to) {
705 return true;
706 }
707 if ($from <= $now && $to == null) {
708 return true;
709 }
710 if ($from == null && $now <= $to) {
711 return true;
712 }
713
714 return ($from <= $now && $now <= $to);
715 }
716
717 return true;
718 }
const IL_CAL_DATE
@classDescription Date and time handling

References getLimited(), getLimitEnd(), getLimitStart(), and IL_CAL_DATE.

Referenced by hasPermissionToDeleteRecord(), and hasPermissionToEditRecord().

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

◆ cloneStructure()

ilDclTable::cloneStructure ( ilDclTable  $original)

Definition at line 979 of file class.ilDclTable.php.

979 : void
980 {
981 $this->setTitle($original->getTitle());
982 $this->setDescription($original->getDescription());
983 $this->setIsVisible($original->getIsVisible());
984 $this->setEditByOwner($original->getEditByOwner());
985 $this->setAddPerm($original->getAddPerm());
986 $this->setEditPerm($original->getEditPerm());
987 $this->setDeleteByOwner($original->getDeleteByOwner());
988 $this->setSaveConfirmation($original->getSaveConfirmation());
989 $this->setDeletePerm($original->getDeletePerm());
990 $this->setLimited($original->getLimited());
991 $this->setLimitStart($original->getLimitStart());
992 $this->setLimitEnd($original->getLimitEnd());
993 $this->setViewOwnRecordsPerm($original->getViewOwnRecordsPerm());
994 $this->setExportEnabled($original->getExportEnabled());
995 $this->setImportEnabled($original->getImportEnabled());
998 $this->setOrder($original->getOrder());
999
1000 $this->doCreate(true, false);
1001 // reset stdFields to get new for the created object
1002
1004 // Clone standard-fields
1005 $org_std_fields = $original->getStandardFields();
1006 foreach ($this->getStandardFields() as $element_key => $std_field) {
1007 $std_field->clone($org_std_fields[$element_key]);
1008 if ($std_field->getId() === $original->getDefaultSortField()) {
1009 $default_sort_field = $std_field->getId();
1010 }
1011 }
1012
1013 // Clone fields
1014 $new_fields = [];
1015 foreach ($original->getFields() as $orig_field) {
1016 if (!$orig_field->isStandardField()) {
1017 $class_name = get_class($orig_field);
1018 $new_field = new $class_name();
1019 $new_field->setTableId($this->getId());
1020 $new_field->cloneStructure((int) $orig_field->getId());
1021 $new_fields[$orig_field->getId()] = $new_field;
1022
1023 if ($orig_field->getId() === $original->getDefaultSortField()) {
1024 $default_sort_field = $new_field->getId();
1025 }
1026 }
1027 }
1028
1030 $this->doUpdate();
1031
1032 // Clone Records with recordfields
1033 foreach ($original->getRecords() as $orig_record) {
1034 $new_record = new ilDclBaseRecordModel();
1035 $new_record->setTableId($this->getId());
1036 $new_record->cloneStructure($orig_record->getId(), $new_fields);
1037 }
1038
1039 //clone tableviews (includes pageobjects)
1040 foreach ($original->getTableViews() as $orig_tableview) {
1041 $new_tableview = new ilDclTableView();
1042 $new_tableview->setTableId($this->getId());
1043 $new_tableview->cloneStructure($orig_tableview, $new_fields);
1044 }
1045
1046 // mandatory for all cloning functions
1047 ilDclCache::setCloneOf($original->getId(), $this->getId(), ilDclCache::TYPE_TABLE);
1048 }
static setCloneOf(int $old, int $new, string $type)
setDefaultSortField(string $default_sort_field)
setEditByOwner(bool $edit_by_owner)
setDeletePerm(bool $delete_perm)
setSaveConfirmation(bool $save_confirmation)
setEditPerm(bool $edit_perm)
string $default_sort_field
setDeleteByOwner(bool $delete_by_owner)
setIsVisible(bool $is_visible)
setLimitStart(string $limit_start)
setOrder(int $table_order)
setImportEnabled(bool $import_enabled)
setTitle(string $a_title)
setDescription(string $description)
doCreate(bool $create_tablefield_setting=true, bool $create_standardview=true)
setDefaultSortFieldOrder(string $default_sort_field_order)
setPublicCommentsEnabled(bool $public_comments)
setAddPerm(bool $add_perm)
setLimited(bool $limited)
getId()
Get table id.
setLimitEnd(string $limit_end)
setExportEnabled(bool $export_enabled)
setViewOwnRecordsPerm(bool $view_own_perm)

References $default_sort_field, doCreate(), doUpdate(), getAddPerm(), getDefaultSortField(), getDefaultSortFieldOrder(), getDeleteByOwner(), getDeletePerm(), getDescription(), getEditByOwner(), getEditPerm(), getExportEnabled(), getFields(), getId(), getImportEnabled(), getIsVisible(), getLimited(), getLimitEnd(), getLimitStart(), getOrder(), getPublicCommentsEnabled(), getRecords(), getSaveConfirmation(), getTableViews(), getTitle(), getViewOwnRecordsPerm(), setAddPerm(), ilDclCache\setCloneOf(), setDefaultSortField(), setDefaultSortFieldOrder(), setDeleteByOwner(), setDeletePerm(), setDescription(), setEditByOwner(), setEditPerm(), setExportEnabled(), setImportEnabled(), setIsVisible(), setLimited(), setLimitEnd(), setLimitStart(), setOrder(), setPublicCommentsEnabled(), setSaveConfirmation(), setTitle(), setViewOwnRecordsPerm(), and ilDclCache\TYPE_TABLE.

+ Here is the call graph for this function:

◆ compareOrder()

ilDclTable::compareOrder ( ilDclBaseFieldModel  $a,
ilDclBaseFieldModel  $b 
)

Definition at line 964 of file class.ilDclTable.php.

964 : int
965 {
966 if (is_null($a->getOrder() == null) && is_null($b->getOrder() == null)) {
967 return 0;
968 }
969 if (is_null($a->getOrder())) {
970 return 1;
971 }
972 if (is_null($b->getOrder())) {
973 return -1;
974 }
975
976 return $a->getOrder() < $b->getOrder() ? -1 : 1;
977 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and Vendor\Package\$b.

◆ deleteField()

ilDclTable::deleteField ( int  $field_id)

Definition at line 326 of file class.ilDclTable.php.

326 : void
327 {
328 $field = ilDclCache::getFieldCache($field_id);
329 $records = $this->getRecords();
330
331 foreach ($records as $record) {
332 $record->deleteField($field_id);
333 }
334
335 $field->doDelete();
336 }
static getFieldCache(int $field_id=0)

References $records, ilDclCache\getFieldCache(), and getRecords().

+ Here is the call graph for this function:

◆ doCreate()

ilDclTable::doCreate ( bool  $create_tablefield_setting = true,
bool  $create_standardview = true 
)

Definition at line 158 of file class.ilDclTable.php.

158 : void
159 {
160 $id = $this->db->nextId("il_dcl_table");
161 $this->setId($id);
162 $query = "INSERT INTO il_dcl_table (" . "id" . ", obj_id" . ", title" . ", add_perm" . ", edit_perm" . ", delete_perm" . ", edit_by_owner"
163 . ", limited" . ", limit_start" . ", limit_end" . ", is_visible" . ", export_enabled" . ", import_enabled" . ", default_sort_field_id"
164 . ", default_sort_field_order" . ", description" . ", public_comments" . ", view_own_records_perm"
165 . ", delete_by_owner, save_confirmation , table_order ) VALUES (" . $this->db->quote(
166 $this->getId(),
167 "integer"
168 ) . ","
169 . $this->db->quote($this->getObjId(), "integer") . "," . $this->db->quote($this->getTitle(), "text") . ","
170 . $this->db->quote($this->getAddPerm() ? 1 : 0, "integer") . "," . $this->db->quote(
171 $this->getEditPerm() ? 1 : 0,
172 "integer"
173 ) . ","
174 . $this->db->quote(
175 $this->getDeletePerm() ? 1 : 0,
176 "integer"
177 ) . "," . $this->db->quote($this->getEditByOwner() ? 1 : 0, "integer") . ","
178 . $this->db->quote($this->getLimited() ? 1 : 0, "integer") . "," . $this->db->quote(
179 $this->getLimitStart(),
180 "timestamp"
181 ) . ","
182 . $this->db->quote($this->getLimitEnd(), "timestamp") . "," . $this->db->quote(
183 $this->getIsVisible() ? 1 : 0,
184 "integer"
185 ) . ","
186 . $this->db->quote(
187 $this->getExportEnabled() ? 1 : 0,
188 "integer"
189 ) . "," . $this->db->quote($this->getImportEnabled() ? 1 : 0, "integer") . ","
190 . $this->db->quote($this->getDefaultSortField(), "text") . "," . $this->db->quote(
192 "text"
193 ) . ","
194 . $this->db->quote($this->getDescription(), "text") . "," . $this->db->quote(
196 "integer"
197 ) . ","
198 . $this->db->quote(
199 $this->getViewOwnRecordsPerm(),
200 "integer"
201 ) . "," . $this->db->quote($this->getDeleteByOwner() ? 1 : 0, 'integer') . ","
202 . $this->db->quote($this->getSaveConfirmation() ? 1 : 0, 'integer') . "," . $this->db->quote(
203 $this->getOrder(),
204 'integer'
205 ) . ")";
206
207 $this->db->manipulate($query);
208
209 if ($create_standardview) {
210 //standard tableview
212 }
213
214 if ($create_tablefield_setting) {
215 $this->buildOrderFields();
216 }
217 }
static createOrGetStandardView(int $table_id)
buildOrderFields()
buildOrderFields orders the fields.
setId(int $a_id)
Set table id.

References $id, buildOrderFields(), ilDclTableView\createOrGetStandardView(), getAddPerm(), getDefaultSortField(), getDefaultSortFieldOrder(), getDeleteByOwner(), getDeletePerm(), getDescription(), getEditByOwner(), getEditPerm(), getExportEnabled(), getId(), getImportEnabled(), getIsVisible(), getLimited(), getLimitEnd(), getLimitStart(), getObjId(), getOrder(), getPublicCommentsEnabled(), getSaveConfirmation(), getTitle(), getViewOwnRecordsPerm(), and setId().

Referenced by cloneStructure().

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

◆ doDelete()

ilDclTable::doDelete ( bool  $delete_only_content = false,
bool  $omit_notification = false 
)

Delete table Attention this does not delete the maintable of it's the maintable of the collection.

unlink the the maintable in the collections object to make this work.

Definition at line 142 of file class.ilDclTable.php.

142 : void
143 {
144 foreach ($this->getRecords() as $record) {
145 $record->doDelete($omit_notification);
146 }
147
148 foreach ($this->getRecordFields() as $field) {
149 $field->doDelete();
150 }
151
152 if (!$delete_only_content) {
153 $query = "DELETE FROM il_dcl_table WHERE id = " . $this->db->quote($this->getId(), "integer");
154 $this->db->manipulate($query);
155 }
156 }
getRecordFields()
Returns all fields of this table which are NOT standard fields.

References getId(), getRecordFields(), and getRecords().

+ Here is the call graph for this function:

◆ doesRecordBelongToUser()

ilDclTable::doesRecordBelongToUser ( ilDclBaseRecordModel  $record)
protected

Definition at line 682 of file class.ilDclTable.php.

682 : bool
683 {
684 return ($this->user->getId() == $record->getOwner());
685 }

References ilDclBaseRecordModel\getOwner(), and ILIAS\Repository\user().

Referenced by hasPermissionToDeleteRecord(), and hasPermissionToEditRecord().

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

◆ doRead()

ilDclTable::doRead ( )

Read table.

Definition at line 101 of file class.ilDclTable.php.

101 : void
102 {
103 $query = "SELECT * FROM il_dcl_table WHERE id = " . $this->db->quote($this->getId(), "integer");
104 $set = $this->db->query($query);
105 $rec = $this->db->fetchAssoc($set);
106
107 $this->setObjId($rec["obj_id"]);
108 if (null !== $rec["title"]) {
109 $this->setTitle($rec["title"]);
110 }
111 $this->setAddPerm((bool) $rec["add_perm"]);
112 $this->setEditPerm((bool) $rec["edit_perm"]);
113 $this->setDeletePerm((bool) $rec["delete_perm"]);
114 $this->setEditByOwner((bool) $rec["edit_by_owner"]);
115 if (null !== $rec["export_enabled"]) {
116 $this->setExportEnabled((bool) $rec["export_enabled"]);
117 }
118 $this->setImportEnabled((bool) $rec["import_enabled"]);
119 $this->setLimited((bool) $rec["limited"]);
120 $this->setLimitStart((string) $rec["limit_start"]);
121 $this->setLimitEnd((string) $rec["limit_end"]);
122 $this->setIsVisible((bool) $rec["is_visible"]);
123 if (null !== $rec['description']) {
124 $this->setDescription($rec['description']);
125 }
126 $this->setDefaultSortField((string) $rec['default_sort_field_id']);
127 $this->setDefaultSortFieldOrder($rec['default_sort_field_order']);
128 $this->setPublicCommentsEnabled((bool) $rec['public_comments']);
129 $this->setViewOwnRecordsPerm((bool) $rec['view_own_records_perm']);
130 $this->setDeleteByOwner((bool) $rec['delete_by_owner']);
131 $this->setSaveConfirmation((bool) $rec['save_confirmation']);
132 if (null !== $rec['table_order']) {
133 $this->setOrder($rec['table_order']);
134 }
135 }
setObjId(int $a_id)

References getId(), setAddPerm(), setDefaultSortField(), setDefaultSortFieldOrder(), setDeleteByOwner(), setDeletePerm(), setDescription(), setEditByOwner(), setEditPerm(), setExportEnabled(), setImportEnabled(), setIsVisible(), setLimited(), setLimitEnd(), setLimitStart(), setObjId(), setOrder(), setPublicCommentsEnabled(), setSaveConfirmation(), setTitle(), and setViewOwnRecordsPerm().

Referenced by __construct().

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

◆ doUpdate()

ilDclTable::doUpdate ( )

Definition at line 219 of file class.ilDclTable.php.

219 : void
220 {
221 $this->db->update(
222 "il_dcl_table",
223 [
224 "obj_id" => ["integer", $this->getObjId()],
225 "title" => ["text", $this->getTitle()],
226 "add_perm" => ["integer", (int) $this->getAddPerm()],
227 "edit_perm" => ["integer", (int) $this->getEditPerm()],
228 "delete_perm" => ["integer", (int) $this->getDeletePerm()],
229 "edit_by_owner" => ["integer", (int) $this->getEditByOwner()],
230 "limited" => ["integer", $this->getLimited()],
231 "limit_start" => ["timestamp", $this->getLimitStart()],
232 "limit_end" => ["timestamp", $this->getLimitEnd()],
233 "is_visible" => ["integer", $this->getIsVisible() ? 1 : 0],
234 "export_enabled" => ["integer", $this->getExportEnabled() ? 1 : 0],
235 "import_enabled" => ["integer", $this->getImportEnabled() ? 1 : 0],
236 "description" => ["text", $this->getDescription()],
237 "default_sort_field_id" => ["text", $this->getDefaultSortField()],
238 "default_sort_field_order" => ["text", $this->getDefaultSortFieldOrder()],
239 "public_comments" => ["integer", $this->getPublicCommentsEnabled() ? 1 : 0],
240 "view_own_records_perm" => ["integer", $this->getViewOwnRecordsPerm()],
241 'delete_by_owner' => ['integer', $this->getDeleteByOwner() ? 1 : 0],
242 'save_confirmation' => ['integer', $this->getSaveConfirmation() ? 1 : 0],
243 'table_order' => ['integer', $this->getOrder()],
244 ],
245 [
246 "id" => ["integer", $this->getId()],
247 ]
248 );
249 }

References getAddPerm(), getDefaultSortField(), getDefaultSortFieldOrder(), getDeleteByOwner(), getDeletePerm(), getDescription(), getEditByOwner(), getEditPerm(), getExportEnabled(), getId(), getImportEnabled(), getIsVisible(), getLimited(), getLimitEnd(), getLimitStart(), getObjId(), getOrder(), getPublicCommentsEnabled(), getSaveConfirmation(), getTitle(), and getViewOwnRecordsPerm().

Referenced by cloneStructure(), and ilDclTableEditGUI\setAsDefault().

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

◆ getAddPerm()

ilDclTable::getAddPerm ( )

Definition at line 796 of file class.ilDclTable.php.

796 : bool
797 {
798 return $this->add_perm;
799 }

References $add_perm.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getCollectionObject()

ilDclTable::getCollectionObject ( )

Definition at line 287 of file class.ilDclTable.php.

288 {
289 $this->loadObj();
290
291 return $this->obj;
292 }
ilObjDataCollection $obj

References $obj, and loadObj().

Referenced by getVisibleTableViews().

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

◆ getCustomFields()

ilDclTable::getCustomFields ( )
Returns
ilDclBaseFieldModel[]

Definition at line 397 of file class.ilDclTable.php.

397 : array
398 {
399 if (!$this->fields) {
400 $this->loadCustomFields();
401 }
402
403 return $this->fields;
404 }

References $fields, and loadCustomFields().

+ Here is the call graph for this function:

◆ getDefaultSortField()

ilDclTable::getDefaultSortField ( )

Definition at line 909 of file class.ilDclTable.php.

909 : string
910 {
912 }

References $default_sort_field.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getDefaultSortFieldOrder()

ilDclTable::getDefaultSortFieldOrder ( )

Definition at line 922 of file class.ilDclTable.php.

922 : string
923 {
925 }
string $default_sort_field_order
Default sort-order (asc|desc)

References $default_sort_field_order.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getDeleteByOwner()

ilDclTable::getDeleteByOwner ( )

Definition at line 827 of file class.ilDclTable.php.

827 : bool
828 {
830 }

References $delete_by_owner.

Referenced by cloneStructure(), doCreate(), doUpdate(), and hasPermissionToDeleteRecord().

+ Here is the caller graph for this function:

◆ getDeletePerm()

ilDclTable::getDeletePerm ( )

Definition at line 809 of file class.ilDclTable.php.

809 : bool
810 {
811 return $this->delete_perm;
812 }

References $delete_perm.

Referenced by cloneStructure(), doCreate(), doUpdate(), hasPermissionToDeleteRecord(), and hasPermissionToDeleteRecords().

+ Here is the caller graph for this function:

◆ getDescription()

ilDclTable::getDescription ( )

Definition at line 898 of file class.ilDclTable.php.

898 : string
899 {
900 return $this->description;
901 }
string $description
Description for this table displayed above records.

References $description.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getEditableFields()

ilDclTable::getEditableFields ( bool  $creation_mode)
Parameters
bool$creation_mode
Returns
array

Definition at line 550 of file class.ilDclTable.php.

550 : array
551 {
552 $fields = $this->getRecordFields();
553 $editableFields = [];
554
555 foreach ($fields as $field) {
556 $tableview_id = $this->http->wrapper()->post()->retrieve(
557 'tableview_id',
558 $this->refinery->kindlyTo()->int()
559 );
560 if (!$field->getViewSetting($tableview_id)->isLocked($creation_mode)) {
561 $editableFields[] = $field;
562 }
563 }
564
565 return $editableFields;
566 }

References $fields, getRecordFields(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getEditByOwner()

ilDclTable::getEditByOwner ( )

Definition at line 822 of file class.ilDclTable.php.

822 : bool
823 {
825 }

References $edit_by_owner.

Referenced by cloneStructure(), doCreate(), doUpdate(), and hasPermissionToEditRecord().

+ Here is the caller graph for this function:

◆ getEditPerm()

ilDclTable::getEditPerm ( )

Definition at line 848 of file class.ilDclTable.php.

848 : bool
849 {
850 return $this->edit_perm;
851 }

References $edit_perm.

Referenced by cloneStructure(), doCreate(), doUpdate(), and hasPermissionToEditRecord().

+ Here is the caller graph for this function:

◆ getExportableFields()

ilDclTable::getExportableFields ( )

Return all the fields that are marked as exportable.

Returns
ilDclBaseFieldModel[]

Definition at line 572 of file class.ilDclTable.php.

572 : array
573 {
574 $fields = $this->getFields();
575 $exportableFields = [];
576 foreach ($fields as $field) {
577 if ($field->getExportable()) {
578 $exportableFields[] = $field;
579 }
580 }
581
582 return $exportableFields;
583 }

References $fields, and getFields().

+ Here is the call graph for this function:

◆ getExportEnabled()

ilDclTable::getExportEnabled ( )

Definition at line 1112 of file class.ilDclTable.php.

1112 : bool
1113 {
1114 return $this->export_enabled;
1115 }

References $export_enabled.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getField()

ilDclTable::getField ( string  $field_id)

Definition at line 338 of file class.ilDclTable.php.

339 {
340 $fields = $this->getFields();
341 $field = null;
342 foreach ($fields as $field_1) {
343 if ($field_1->getId() == $field_id) {
344 $field = $field_1;
345 }
346 }
347
348 return $field;
349 }

References $fields, and getFields().

+ Here is the call graph for this function:

◆ getFieldByTitle()

ilDclTable::getFieldByTitle ( string  $title)

Get a field by title.

Definition at line 778 of file class.ilDclTable.php.

779 {
780 $return = null;
781 foreach ($this->getFields() as $field) {
782 if ($field->getTitle() == $title) {
783 $return = $field;
784 break;
785 }
786 }
787
788 return $return;
789 }

References $title, and getFields().

+ Here is the call graph for this function:

◆ getFieldIds()

ilDclTable::getFieldIds ( )

Definition at line 351 of file class.ilDclTable.php.

351 : array
352 {
353 $field_ids = [];
354 foreach ($this->getFields() as $field) {
355 if ($field->getId()) {
356 $field_ids[] = $field->getId();
357 }
358 }
359
360 return $field_ids;
361 }

References getFields().

+ Here is the call graph for this function:

◆ getFields()

ilDclTable::getFields ( )

Returns all fields of this table including the standard fields.

Parameters
bool$force_include_commentsby default false, so comments will only load when enabled in tablesettings
Returns
ilDclBaseFieldModel[]

Definition at line 428 of file class.ilDclTable.php.

428 : array
429 {
430 if ($this->all_fields == null) {
431 $this->reloadFields();
432 }
433
434 return $this->all_fields;
435 }
array $all_fields
table fields and std fields combined

References $all_fields, and reloadFields().

Referenced by afterClone(), buildOrderFields(), cloneStructure(), ilDclContentExporter\fillHeaderExcel(), getExportableFields(), getField(), getFieldByTitle(), getFieldIds(), getFieldsForFormula(), getNewFieldOrder(), and updateFields().

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

◆ getFieldsForFormula()

ilDclTable::getFieldsForFormula ( )

Returns all fields of this table including the standard fields, wich are supported for formulas.

Returns
ilDclBaseFieldModel[]

Definition at line 490 of file class.ilDclTable.php.

490 : array
491 {
492 $syntax_chars = array_merge(
493 array_map(static fn(Operators $function): string => $function->value, Operators::cases()),
494 array_map(static fn(Functions $function): string => $function->value, Functions::cases()),
495 ['(', ')', ',']
496 );
497 foreach ($this->getFields() as $field) {
498 if (in_array($field->getDatatypeId(), ilDclFormulaFieldModel::SUPPORTED_FIELDS)) {
499 foreach ($syntax_chars as $element) {
500 if (str_contains($field->getTitle(), $element)) {
501 continue 2;
502 }
503 }
504 $return[] = $field;
505 }
506 }
507
508 return $return;
509 }

References getFields(), and ilDclFormulaFieldModel\SUPPORTED_FIELDS.

+ Here is the call graph for this function:

◆ getFirstTableViewId()

ilDclTable::getFirstTableViewId ( int  $user_id = 0,
bool  $with_detailed_view = false 
)

Definition at line 478 of file class.ilDclTable.php.

478 : ?int
479 {
480 $array = $this->getVisibleTableViews($user_id, $with_detailed_view);
481 $tableview = array_shift($array);
482
483 return $tableview?->getId();
484 }
getVisibleTableViews(int $user_id=0, bool $with_active_detailedview=false)

References $user_id, and getVisibleTableViews().

+ Here is the call graph for this function:

◆ getId()

ilDclTable::getId ( )

Get table id.

Definition at line 262 of file class.ilDclTable.php.

262 : int
263 {
264 return $this->id;
265 }

References $id.

Referenced by cloneStructure(), doCreate(), doDelete(), doRead(), doUpdate(), ilDclTableListGUI\getActions(), getTableViews(), loadCustomFields(), ilDclTableEditGUI\save(), and ilDclTableEditGUI\setAsDefault().

+ Here is the caller graph for this function:

◆ getImportEnabled()

ilDclTable::getImportEnabled ( )

Definition at line 1149 of file class.ilDclTable.php.

1149 : bool
1150 {
1151 return $this->import_enabled;
1152 }

References $import_enabled.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getIsVisible()

ilDclTable::getIsVisible ( )

Definition at line 888 of file class.ilDclTable.php.

888 : bool
889 {
890 return $this->is_visible;
891 }

References $is_visible.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getLimited()

ilDclTable::getLimited ( )

Definition at line 858 of file class.ilDclTable.php.

858 : bool
859 {
860 return $this->limited;
861 }

References $limited.

Referenced by checkLimit(), cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getLimitEnd()

ilDclTable::getLimitEnd ( )

Definition at line 868 of file class.ilDclTable.php.

868 : string
869 {
870 return $this->limit_end;
871 }

References $limit_end.

Referenced by checkLimit(), cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getLimitStart()

ilDclTable::getLimitStart ( )

Definition at line 878 of file class.ilDclTable.php.

878 : string
879 {
880 return $this->limit_start;
881 }
string $limit_start

References $limit_start.

Referenced by checkLimit(), cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getNewFieldOrder()

ilDclTable::getNewFieldOrder ( )

getNewOrder

Returns
int returns the place where a new field should be placed.

Definition at line 410 of file class.ilDclTable.php.

410 : int
411 {
412 $fields = $this->getFields();
413 $place = 0;
414 foreach ($fields as $field) {
415 if (!$field->isStandardField()) {
416 $place = $field->getOrder() + 1;
417 }
418 }
419
420 return $place;
421 }

References $fields, and getFields().

+ Here is the call graph for this function:

◆ getObjId()

ilDclTable::getObjId ( )

Definition at line 272 of file class.ilDclTable.php.

272 : ?int
273 {
274 return $this->objId;
275 }

References $objId.

Referenced by doCreate(), doUpdate(), hasPermissionToDeleteRecord(), hasPermissionToDeleteRecords(), hasPermissionToEditRecord(), hasPermissionToViewRecord(), and ilObjDataCollectionAccess\isTableInDataCollection().

+ Here is the caller graph for this function:

◆ getOrder()

ilDclTable::getOrder ( )

Definition at line 1117 of file class.ilDclTable.php.

1117 : int
1118 {
1119 if (!$this->table_order) {
1120 $this->updateOrder();
1121 }
1122
1123 return $this->table_order;
1124 }

References $table_order, and updateOrder().

Referenced by cloneStructure(), doCreate(), doUpdate(), and ilDclTableListGUI\getActions().

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

◆ getPartialRecords()

ilDclTable::getPartialRecords ( string  $ref_id,
string  $sort,
string  $direction,
?int  $limit,
int  $offset,
array  $filter = [] 
)

Return only the needed subset of record objects for the table, according to sorting, paging and filters.

Parameters
string$sortTitle of a field where the ilTable2GUI is sorted
string$direction'desc' or 'asc'
int$limitLimit of records
int$offsetOffset from records
array$filterContaining the filter values
Returns
array Array with two keys: 'record' => Contains the record objects, 'total' => Number of total records (without slicing)

Definition at line 1180 of file class.ilDclTable.php.

1187 : array {
1188 $sort_field = $this->getFieldByTitle($sort);
1189 $direction = strtolower($direction);
1190 $direction = (in_array($direction, ['desc', 'asc'])) ? $direction : 'asc';
1191
1192 // Sorting by a status from an ILIAS Ref field. This column is added dynamically to the table, there is no field model
1193 $sort_by_status = false;
1194 if (substr($sort, 0, 8) == '_status_') {
1195 $sort_by_status = true;
1196 $sort_field = $this->getFieldByTitle(substr($sort, 8));
1197 }
1198
1199 if (is_null($sort_field)) {
1200 $sort_field = $this->getField('id');
1201 }
1202
1203 $sort_query_object = $sort_field->getRecordQuerySortObject($direction, $sort_by_status);
1204
1205 $select_str = ($sort_query_object != null) ? $sort_query_object->getSelectStatement() : '';
1206 $join_str = ($sort_query_object != null) ? $sort_query_object->getJoinStatement() : '';
1207 $where_str = ($sort_query_object != null) ? $sort_query_object->getWhereStatement() : '';
1208 $order_str = ($sort_query_object != null) ? $sort_query_object->getOrderStatement() : '';
1209 $group_str = ($sort_query_object != null) ? $sort_query_object->getGroupStatement() : '';
1210
1211 if (count($filter)) {
1212 foreach ($filter as $key => $filter_value) {
1213 $filter_field_id = substr($key, 7);
1214 $filter_field = $this->getField($filter_field_id);
1215 $filter_record_query_object = $filter_field->getRecordQueryFilterObject($filter_value, $sort_field);
1216
1217 if ($filter_record_query_object) {
1218 $select_str .= $filter_record_query_object->getSelectStatement();
1219 $join_str .= $filter_record_query_object->getJoinStatement();
1220 $where_str .= $filter_record_query_object->getWhereStatement();
1221 $group_str .= $filter_record_query_object->getGroupStatement();
1222 }
1223 }
1224 }
1225
1226 // Build the query string
1227 $sql = "SELECT DISTINCT record.id, record.owner";
1228 if ($select_str) {
1229 $sql .= ', ';
1230 }
1231
1232 $as = ' AS ';
1233
1234 $sql .= rtrim($select_str, ',') . " FROM il_dcl_record $as record ";
1235 $sql .= $join_str;
1236 $sql .= " WHERE record.table_id = " . $this->db->quote($this->getId(), 'integer');
1237
1238 if (strlen($where_str) > 0) {
1239 $sql .= $where_str;
1240 }
1241
1242 if (strlen($group_str) > 0) {
1243 $sql .= " GROUP BY " . $group_str;
1244 }
1245
1246 if (strlen($order_str) > 0) {
1247 $sql .= " ORDER BY " . $order_str;
1248 }
1249
1250 $set = $this->db->query($sql);
1251 $total_record_ids = [];
1252
1254 while ($rec = $this->db->fetchAssoc($set)) {
1255 // Quick check if the current user is allowed to view the record
1256 if (!$is_allowed_to_view && ($this->getViewOwnRecordsPerm() && $this->user->getId() != $rec['owner'])) {
1257 continue;
1258 }
1259 $total_record_ids[] = $rec['id'];
1260 }
1261 // Save record-ids in session to enable prev/next links in detail view
1262 ilSession::set('dcl_table_id', $this->getId());
1263 ilSession::set('dcl_record_ids', $total_record_ids);
1264
1265 if ($sort_query_object != null) {
1266 $total_record_ids = $sort_query_object->applyCustomSorting($sort_field, $total_record_ids, $direction);
1267 }
1268
1269 if ($sort === 'n_comments') {
1270 global $DIC;
1271 $comments_nr = [];
1272 foreach ($total_record_ids as $id) {
1273 $comments_nr[$id] = $DIC->notes()->domain()->getNrOfCommentsForContext($DIC->notes()->data()->context($this->getObjId(), $id, 'dcl'));
1274 }
1275 uasort($comments_nr, static fn($a, $b) => ($direction === 'asc' ? 1 : -1) * ($a <=> $b));
1276 $total_record_ids = array_keys($comments_nr);
1277 }
1278
1279 // Now slice the array to load only the needed records in memory
1280 $record_ids = array_slice($total_record_ids, $offset, $limit);
1281
1282 $records = [];
1283 foreach ($record_ids as $id) {
1285 }
1286
1287 return ['records' => $records, 'total' => count($total_record_ids)];
1288 }
static getRecordCache(?int $record_id)
getField(string $field_id)
getFieldByTitle(string $title)
Get a field by title.
static hasWriteAccess(int $ref, ?int $user_id=0)
static hasEditAccess(int $ref, ?int $user_id=null)
static set(string $a_var, $a_val)
Set a value.
$ref_id
Definition: ltiauth.php:66

Referenced by ilDclRecordListGUI\getRecordListTableGUI().

+ Here is the caller graph for this function:

◆ getPublicCommentsEnabled()

ilDclTable::getPublicCommentsEnabled ( )

Definition at line 932 of file class.ilDclTable.php.

932 : bool
933 {
935 }
bool $public_comments
True if users can add comments on each record of this table.

References $public_comments.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getRecordFields()

ilDclTable::getRecordFields ( )

Returns all fields of this table which are NOT standard fields.

Returns
ilDclBaseFieldModel[]

Definition at line 539 of file class.ilDclTable.php.

539 : array
540 {
541 $this->loadCustomFields();
542
543 return $this->fields;
544 }

References $fields, and loadCustomFields().

Referenced by doDelete(), getEditableFields(), and ilDclContentImporter\getImportFieldsFromTitles().

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

◆ getRecords()

ilDclTable::getRecords ( )
Returns
ilDclBaseRecordModel[]

Definition at line 304 of file class.ilDclTable.php.

304 : array
305 {
306 if ($this->records == null) {
307 $this->loadRecords();
308 }
309
310 return $this->records;
311 }

References $records, and loadRecords().

Referenced by _hasRecords(), afterClone(), cloneStructure(), deleteField(), and doDelete().

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

◆ getSaveConfirmation()

ilDclTable::getSaveConfirmation ( )

Definition at line 947 of file class.ilDclTable.php.

947 : bool
948 {
950 }
bool $save_confirmation

References $save_confirmation.

Referenced by cloneStructure(), doCreate(), and doUpdate().

+ Here is the caller graph for this function:

◆ getTableViews()

ilDclTable::getTableViews ( )
Returns
ilDclTableView[]

Definition at line 451 of file class.ilDclTable.php.

451 : array
452 {
454 }
static getAllForTableId(int $table_id)

References ilDclTableView\getAllForTableId(), and getId().

Referenced by cloneStructure(), and getVisibleTableViews().

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

◆ getTitle()

ilDclTable::getTitle ( )

Definition at line 282 of file class.ilDclTable.php.

282 : string
283 {
284 return $this->title;
285 }

References $title.

Referenced by cloneStructure(), doCreate(), doUpdate(), and ilDclTableEditGUI\save().

+ Here is the caller graph for this function:

◆ getViewOwnRecordsPerm()

ilDclTable::getViewOwnRecordsPerm ( )

Definition at line 942 of file class.ilDclTable.php.

942 : bool
943 {
944 return (bool) $this->view_own_records_perm;
945 }
int $view_own_records_perm
True if user can only view his/her own entries in the table.

References $view_own_records_perm.

Referenced by cloneStructure(), doCreate(), doUpdate(), and hasPermissionToViewRecord().

+ Here is the caller graph for this function:

◆ getVisibleTableViews()

ilDclTable::getVisibleTableViews ( int  $user_id = 0,
bool  $with_active_detailedview = false 
)
Returns
ilDclTableView[]

Definition at line 459 of file class.ilDclTable.php.

459 : array
460 {
461 if (ilObjDataCollectionAccess::hasWriteAccess($this->getCollectionObject()->getRefId(), $user_id) && !$with_active_detailedview) {
462 return $this->getTableViews();
463 }
464
465 $visible_views = [];
466 foreach ($this->getTableViews() as $tableView) {
468 $page = new ilDclDetailedViewDefinitionGUI($tableView->getId());
469 if (!$with_active_detailedview || $page->getPageObject()->isActive()) {
470 $visible_views[] = $tableView;
471 }
472 }
473 }
474
475 return $visible_views;
476 }
@ilCtrl_Calls ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI,...
static hasAccessToTableView(ilDclTableView $tableview, ?int $user_id=0)

References $user_id, getCollectionObject(), getTableViews(), ilObjDataCollectionAccess\hasAccessToTableView(), and ilObjDataCollectionAccess\hasWriteAccess().

Referenced by getFirstTableViewId().

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

◆ hasCustomFields()

ilDclTable::hasCustomFields ( )

Definition at line 957 of file class.ilDclTable.php.

957 : bool
958 {
959 $this->loadCustomFields();
960
961 return count($this->fields) > 0;
962 }

References loadCustomFields().

+ Here is the call graph for this function:

◆ hasPermissionToDeleteRecord()

ilDclTable::hasPermissionToDeleteRecord ( int  $ref_id,
ilDclBaseRecordModel  $record 
)
Parameters
int$ref_idthe reference id of the current datacollection object
ilDclBaseRecordModel$recordthe record which will be deleted

Definition at line 621 of file class.ilDclTable.php.

621 : bool
622 {
624 return false;
625 }
627 return true;
628 }
630 return false;
631 }
632 if (!$this->checkLimit()) {
633 return false;
634 }
635 if ($this->getDeletePerm() && !$this->getDeleteByOwner()) {
636 return true;
637 }
638 if ($this->getDeleteByOwner()) {
639 return $this->doesRecordBelongToUser($record);
640 }
641
642 return false;
643 }
doesRecordBelongToUser(ilDclBaseRecordModel $record)
static hasAddRecordAccess(int $ref, ?int $user_id=0)
static _lookupObjectId(int $ref_id)

References $ref_id, ilObject\_lookupObjectId(), checkLimit(), doesRecordBelongToUser(), getDeleteByOwner(), getDeletePerm(), getObjId(), ilObjDataCollectionAccess\hasAddRecordAccess(), and ilObjDataCollectionAccess\hasWriteAccess().

+ Here is the call graph for this function:

◆ hasPermissionToDeleteRecords()

ilDclTable::hasPermissionToDeleteRecords ( int  $ref_id)
Parameters
$ref_id
Returns
bool

Definition at line 649 of file class.ilDclTable.php.

649 : bool
650 {
652 return false;
653 }
654
657 }

References $ref_id, ilObject\_lookupObjectId(), getDeletePerm(), getObjId(), ilObjDataCollectionAccess\hasAddRecordAccess(), and ilObjDataCollectionAccess\hasWriteAccess().

+ Here is the call graph for this function:

◆ hasPermissionToEditRecord()

ilDclTable::hasPermissionToEditRecord ( int  $ref_id,
ilDclBaseRecordModel  $record 
)
Parameters
$ref_idint the reference id of the current datacollection object
$recordilDclBaseRecordModel the record which will be edited
Returns
bool

Definition at line 590 of file class.ilDclTable.php.

590 : bool
591 {
593 return false;
594 }
596 return true;
597 }
599 return false;
600 }
601 if ($this->getEditByOwner()) {
602 return $this->doesRecordBelongToUser($record);
603 }
604 if (!$this->checkLimit()) {
605 return false;
606 }
608 return true;
609 }
610 if ($this->getEditPerm() && !$this->getEditByOwner()) {
611 return true;
612 }
613
614 return false;
615 }

References $ref_id, ilObject\_lookupObjectId(), checkLimit(), doesRecordBelongToUser(), getEditByOwner(), getEditPerm(), getObjId(), ilObjDataCollectionAccess\hasAddRecordAccess(), ilObjDataCollectionAccess\hasEditAccess(), and ilObjDataCollectionAccess\hasWriteAccess().

+ Here is the call graph for this function:

◆ hasPermissionToViewRecord()

ilDclTable::hasPermissionToViewRecord ( int  $ref_id,
ilDclBaseRecordModel  $record,
int  $user_id = 0 
)

Definition at line 659 of file class.ilDclTable.php.

659 : bool
660 {
662 return false;
663 }
665 $ref_id,
668 return true;
669 }
671 // Check for view only own entries setting
672 if ($this->getViewOwnRecordsPerm() && ($user_id ?: $this->user->getId()) != $record->getOwner()) {
673 return false;
674 }
675
676 return true;
677 }
678
679 return false;
680 }
static hasReadAccess(int $ref, ?int $user_id=0)

References $ref_id, $user_id, ilObject\_lookupObjectId(), getObjId(), ilDclBaseRecordModel\getOwner(), getViewOwnRecordsPerm(), ilObjDataCollectionAccess\hasEditAccess(), ilObjDataCollectionAccess\hasReadAccess(), ilObjDataCollectionAccess\hasWriteAccess(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ loadCustomFields()

ilDclTable::loadCustomFields ( )
protected

Definition at line 363 of file class.ilDclTable.php.

363 : void
364 {
365 if (!$this->fields) {
366 $query
367 = "SELECT DISTINCT il_dcl_field.*, il_dcl_tfield_set.field_order
368 FROM il_dcl_field
369 INNER JOIN il_dcl_tfield_set
370 ON ( il_dcl_tfield_set.field NOT IN ('owner',
371 'last_update',
372 'last_edit_by',
373 'id',
374 'create_date')
375 AND il_dcl_tfield_set.table_id = il_dcl_field.table_id
376 AND il_dcl_tfield_set.field = " . $this->db->cast("il_dcl_field.id", "text") . ")
377 WHERE il_dcl_field.table_id = %s
378 ORDER BY il_dcl_tfield_set.field_order ASC";
379
380 $set = $this->db->queryF($query, ['integer'], [$this->getId()]);
381 $fields = [];
382 while ($rec = $this->db->fetchAssoc($set)) {
384 if ($this->show_invalid || in_array($field->getDatatypeId(), array_keys(ilDclDatatype::getAllDatatype()))) {
385 $fields[] = $field;
386 }
387 }
388 $this->fields = $fields;
389
391 }
392 }
static buildFieldFromRecord(array $rec)
static preloadFieldProperties(array $fields)
Preloads field properties.
static getAllDatatype(bool $force=false)
Get all possible Datatypes.

References $fields, ilDclCache\buildFieldFromRecord(), ilDclDatatype\getAllDatatype(), getId(), and ilDclCache\preloadFieldProperties().

Referenced by getCustomFields(), getRecordFields(), hasCustomFields(), and reloadFields().

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

◆ loadObj()

ilDclTable::loadObj ( )
protected

Definition at line 294 of file class.ilDclTable.php.

294 : void
295 {
296 if ($this->obj == null) {
297 $this->obj = new ilObjDataCollection($this->objId, false);
298 }
299 }

Referenced by getCollectionObject().

+ Here is the caller graph for this function:

◆ loadRecords()

ilDclTable::loadRecords ( )

Definition at line 313 of file class.ilDclTable.php.

313 : void
314 {
315 $records = [];
316 $query = "SELECT id FROM il_dcl_record WHERE table_id = " . $this->db->quote($this->id, "integer");
317 $set = $this->db->query($query);
318
319 while ($rec = $this->db->fetchAssoc($set)) {
320 $records[$rec['id']] = ilDclCache::getRecordCache($rec['id']);
321 }
322
323 $this->records = $records;
324 }

References $records, and ilDclCache\getRecordCache().

Referenced by getRecords().

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

◆ reloadFields()

ilDclTable::reloadFields ( )

Definition at line 437 of file class.ilDclTable.php.

437 : void
438 {
439 $this->loadCustomFields();
440 $this->stdFields = $this->getStandardFields();
441 $fields = array_merge($this->fields, $this->stdFields);
442
443 $this->sortByOrder($fields);
444
445 $this->all_fields = $fields;
446 }

References $fields, loadCustomFields(), and sortByOrder().

Referenced by getFields().

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

◆ setAddPerm()

ilDclTable::setAddPerm ( bool  $add_perm)

Definition at line 791 of file class.ilDclTable.php.

791 : void
792 {
793 $this->add_perm = $add_perm;
794 }

References $add_perm.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setDefaultSortField()

ilDclTable::setDefaultSortField ( string  $default_sort_field)

Definition at line 903 of file class.ilDclTable.php.

903 : void
904 {
905 $default_sort_field = ($default_sort_field) ?: ""; // Change null or empty strings to zero
906 $this->default_sort_field = $default_sort_field;
907 }

References $default_sort_field.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setDefaultSortFieldOrder()

ilDclTable::setDefaultSortFieldOrder ( string  $default_sort_field_order)

Definition at line 914 of file class.ilDclTable.php.

914 : void
915 {
916 if (!in_array($default_sort_field_order, ['asc', 'desc'])) {
918 }
919 $this->default_sort_field_order = $default_sort_field_order;
920 }

References $default_sort_field_order.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setDeleteByOwner()

ilDclTable::setDeleteByOwner ( bool  $delete_by_owner)

Definition at line 832 of file class.ilDclTable.php.

832 : void
833 {
834 $this->delete_by_owner = $delete_by_owner;
835 if ($delete_by_owner) {
836 $this->setDeletePerm(true);
837 }
838 }

References $delete_by_owner, and setDeletePerm().

Referenced by cloneStructure(), doRead(), and setDeletePerm().

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

◆ setDeletePerm()

ilDclTable::setDeletePerm ( bool  $delete_perm)

Definition at line 801 of file class.ilDclTable.php.

801 : void
802 {
803 $this->delete_perm = $delete_perm;
804 if (!$delete_perm) {
805 $this->setDeleteByOwner(false);
806 }
807 }

References $delete_perm, and setDeleteByOwner().

Referenced by cloneStructure(), doRead(), and setDeleteByOwner().

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

◆ setDescription()

ilDclTable::setDescription ( string  $description)

Definition at line 893 of file class.ilDclTable.php.

893 : void
894 {
895 $this->description = $description;
896 }

References $description.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setEditByOwner()

ilDclTable::setEditByOwner ( bool  $edit_by_owner)

Definition at line 814 of file class.ilDclTable.php.

814 : void
815 {
816 $this->edit_by_owner = $edit_by_owner;
817 if ($edit_by_owner) {
818 $this->setEditPerm(true);
819 }
820 }

References $edit_by_owner, and setEditPerm().

Referenced by cloneStructure(), doRead(), and setEditPerm().

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

◆ setEditPerm()

ilDclTable::setEditPerm ( bool  $edit_perm)

Definition at line 840 of file class.ilDclTable.php.

840 : void
841 {
842 $this->edit_perm = $edit_perm;
843 if (!$edit_perm) {
844 $this->setEditByOwner(false);
845 }
846 }

References $edit_perm, and setEditByOwner().

Referenced by cloneStructure(), doRead(), and setEditByOwner().

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

◆ setExportEnabled()

ilDclTable::setExportEnabled ( bool  $export_enabled)

Definition at line 1107 of file class.ilDclTable.php.

1107 : void
1108 {
1109 $this->export_enabled = $export_enabled;
1110 }

References $export_enabled.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setId()

ilDclTable::setId ( int  $a_id)

Set table id.

Definition at line 254 of file class.ilDclTable.php.

254 : void
255 {
256 $this->id = $a_id;
257 }

Referenced by doCreate().

+ Here is the caller graph for this function:

◆ setImportEnabled()

ilDclTable::setImportEnabled ( bool  $import_enabled)

Definition at line 1144 of file class.ilDclTable.php.

1144 : void
1145 {
1146 $this->import_enabled = $import_enabled;
1147 }

References $import_enabled.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setIsVisible()

ilDclTable::setIsVisible ( bool  $is_visible)

Definition at line 883 of file class.ilDclTable.php.

883 : void
884 {
885 $this->is_visible = $is_visible;
886 }

References $is_visible.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setLimited()

ilDclTable::setLimited ( bool  $limited)

Definition at line 853 of file class.ilDclTable.php.

853 : void
854 {
855 $this->limited = $limited;
856 }

References $limited.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setLimitEnd()

ilDclTable::setLimitEnd ( string  $limit_end)

Definition at line 863 of file class.ilDclTable.php.

863 : void
864 {
865 $this->limit_end = $limit_end;
866 }

References $limit_end.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setLimitStart()

ilDclTable::setLimitStart ( string  $limit_start)

Definition at line 873 of file class.ilDclTable.php.

873 : void
874 {
875 $this->limit_start = $limit_start;
876 }

References $limit_start.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setObjId()

ilDclTable::setObjId ( int  $a_id)

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

267 : void
268 {
269 $this->objId = $a_id;
270 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setOrder()

ilDclTable::setOrder ( int  $table_order)

Definition at line 1139 of file class.ilDclTable.php.

1139 : void
1140 {
1141 $this->table_order = $table_order;
1142 }

References $table_order.

Referenced by cloneStructure(), doRead(), and ilDclTableEditGUI\setAsDefault().

+ Here is the caller graph for this function:

◆ setPublicCommentsEnabled()

ilDclTable::setPublicCommentsEnabled ( bool  $public_comments)

Definition at line 927 of file class.ilDclTable.php.

927 : void
928 {
929 $this->public_comments = $public_comments;
930 }

References $public_comments.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setSaveConfirmation()

ilDclTable::setSaveConfirmation ( bool  $save_confirmation)

Definition at line 952 of file class.ilDclTable.php.

952 : void
953 {
954 $this->save_confirmation = $save_confirmation;
955 }

References $save_confirmation.

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setTitle()

ilDclTable::setTitle ( string  $a_title)

Definition at line 277 of file class.ilDclTable.php.

277 : void
278 {
279 $this->title = $a_title;
280 }

Referenced by cloneStructure(), and doRead().

+ Here is the caller graph for this function:

◆ setViewOwnRecordsPerm()

ilDclTable::setViewOwnRecordsPerm ( bool  $view_own_perm)

Definition at line 937 of file class.ilDclTable.php.

937 : void
938 {
939 $this->view_own_records_perm = (int) $view_own_perm;
940 }

References ILIAS\Repository\int().

Referenced by cloneStructure(), and doRead().

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

◆ showInvalidFields()

ilDclTable::showInvalidFields ( bool  $value)

Definition at line 1290 of file class.ilDclTable.php.

1290 : void
1291 {
1292 $this->show_invalid = $value;
1293 }

◆ sortByOrder()

ilDclTable::sortByOrder ( array &  $array)
protected
Parameters
ilDclBaseFieldModel[]$arraythe array to sort

Definition at line 749 of file class.ilDclTable.php.

749 : void
750 {
751 // php-bug: https://bugs.php.net/bug.php?id=50688
752 // fixed in php 7 but for now we need the @ a workaround
753 usort($array, [$this, "compareOrder"]);
754 }

Referenced by buildOrderFields(), reloadFields(), and sortFields().

+ Here is the caller graph for this function:

◆ sortFields()

ilDclTable::sortFields ( array &  $fields)

sortFields

Parameters
ilDclBaseFieldModel[]$fields

Definition at line 734 of file class.ilDclTable.php.

734 : void
735 {
736 $this->sortByOrder($fields);
737 //After sorting the array loses it's keys respectivly their keys are set form $field->id to 1,2,3... so we reset the keys.
738 $named = [];
739 foreach ($fields as $field) {
740 $named[$field->getId()] = $field;
741 }
742
743 $fields = $named;
744 }

References $fields, and sortByOrder().

+ Here is the call graph for this function:

◆ updateFields()

ilDclTable::updateFields ( )

Update fields.

Definition at line 723 of file class.ilDclTable.php.

723 : void
724 {
725 foreach ($this->getFields() as $field) {
726 $field->doUpdate();
727 }
728 }

References getFields().

+ Here is the call graph for this function:

◆ updateOrder()

ilDclTable::updateOrder ( )

Definition at line 1126 of file class.ilDclTable.php.

1126 : void
1127 {
1128 $result = $this->db->query('SELECT MAX(table_order) AS table_order FROM il_dcl_table WHERE obj_id = ' . $this->db->quote(
1129 $this->getCollectionObject()->getId(),
1130 'integer'
1131 ));
1132 $this->table_order = $this->db->fetchObject($result)->table_order + 10;
1133 $this->db->query('UPDATE il_dcl_table SET table_order = ' . $this->db->quote(
1134 $this->table_order,
1135 'integer'
1136 ) . ' WHERE id = ' . $this->db->quote($this->getId(), 'integer'));
1137 }

Referenced by getOrder().

+ Here is the caller graph for this function:

Field Documentation

◆ $add_perm

bool ilDclTable::$add_perm = false
protected

Definition at line 43 of file class.ilDclTable.php.

Referenced by getAddPerm(), and setAddPerm().

◆ $all_fields

array ilDclTable::$all_fields = null
protected

table fields and std fields combined

Definition at line 76 of file class.ilDclTable.php.

Referenced by getFields().

◆ $db

ilDBInterface ilDclTable::$db
protected

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

◆ $default_sort_field

string ilDclTable::$default_sort_field = "0"
protected

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

Referenced by cloneStructure(), getDefaultSortField(), and setDefaultSortField().

◆ $default_sort_field_order

string ilDclTable::$default_sort_field_order = 'asc'
protected

Default sort-order (asc|desc)

Definition at line 60 of file class.ilDclTable.php.

Referenced by getDefaultSortFieldOrder(), and setDefaultSortFieldOrder().

◆ $delete_by_owner

bool ilDclTable::$delete_by_owner = false
protected

Definition at line 47 of file class.ilDclTable.php.

Referenced by getDeleteByOwner(), and setDeleteByOwner().

◆ $delete_perm

bool ilDclTable::$delete_perm = false
protected

Definition at line 45 of file class.ilDclTable.php.

Referenced by getDeletePerm(), and setDeletePerm().

◆ $description

string ilDclTable::$description = ''
protected

Description for this table displayed above records.

Definition at line 64 of file class.ilDclTable.php.

Referenced by getDescription(), and setDescription().

◆ $edit_by_owner

bool ilDclTable::$edit_by_owner = false
protected

Definition at line 46 of file class.ilDclTable.php.

Referenced by getEditByOwner(), and setEditByOwner().

◆ $edit_perm

bool ilDclTable::$edit_perm = false
protected

Definition at line 44 of file class.ilDclTable.php.

Referenced by getEditPerm(), and setEditPerm().

◆ $export_enabled

bool ilDclTable::$export_enabled = false
protected

Definition at line 52 of file class.ilDclTable.php.

Referenced by getExportEnabled(), and setExportEnabled().

◆ $fields

◆ $http

ILIAS HTTP Services ilDclTable::$http
protected

Definition at line 77 of file class.ilDclTable.php.

◆ $id

int ilDclTable::$id = 0
protected

Definition at line 26 of file class.ilDclTable.php.

Referenced by _getTableIdByTitle(), doCreate(), and getId().

◆ $import_enabled

bool ilDclTable::$import_enabled = false
protected

Definition at line 54 of file class.ilDclTable.php.

Referenced by getImportEnabled(), and setImportEnabled().

◆ $is_visible

bool ilDclTable::$is_visible = false
protected

Definition at line 42 of file class.ilDclTable.php.

Referenced by getIsVisible(), and setIsVisible().

◆ $limit_end

string ilDclTable::$limit_end = ""
protected

Definition at line 51 of file class.ilDclTable.php.

Referenced by getLimitEnd(), and setLimitEnd().

◆ $limit_start

string ilDclTable::$limit_start = ""
protected

Definition at line 50 of file class.ilDclTable.php.

Referenced by getLimitStart(), and setLimitStart().

◆ $limited

bool ilDclTable::$limited = false
protected

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

Referenced by getLimited(), and setLimited().

◆ $obj

ilObjDataCollection ilDclTable::$obj = null
protected

Definition at line 28 of file class.ilDclTable.php.

Referenced by getCollectionObject().

◆ $objId

int ilDclTable::$objId = null
protected

Definition at line 27 of file class.ilDclTable.php.

Referenced by getObjId().

◆ $public_comments

bool ilDclTable::$public_comments = false
protected

True if users can add comments on each record of this table.

Definition at line 68 of file class.ilDclTable.php.

Referenced by getPublicCommentsEnabled(), and setPublicCommentsEnabled().

◆ $records

array ilDclTable::$records = []
protected

Definition at line 41 of file class.ilDclTable.php.

Referenced by deleteField(), getRecords(), and loadRecords().

◆ $refinery

ILIAS Refinery Factory ilDclTable::$refinery
protected

Definition at line 78 of file class.ilDclTable.php.

◆ $save_confirmation

bool ilDclTable::$save_confirmation = false
protected

Definition at line 48 of file class.ilDclTable.php.

Referenced by getSaveConfirmation(), and setSaveConfirmation().

◆ $show_invalid

bool ilDclTable::$show_invalid = false
protected

Definition at line 81 of file class.ilDclTable.php.

◆ $stdFields

array ilDclTable::$stdFields = []
protected

Definition at line 37 of file class.ilDclTable.php.

◆ $table_order

int ilDclTable::$table_order = 0
protected

Definition at line 53 of file class.ilDclTable.php.

Referenced by getOrder(), and setOrder().

◆ $title

string ilDclTable::$title = ""
protected

◆ $user

ilObjUser ilDclTable::$user
protected

Definition at line 79 of file class.ilDclTable.php.

◆ $view_own_records_perm

int ilDclTable::$view_own_records_perm = 0
protected

True if user can only view his/her own entries in the table.

Definition at line 72 of file class.ilDclTable.php.

Referenced by getViewOwnRecordsPerm().


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