19 declare(strict_types=1);
33 protected int $id = 0;
50 $this->db = $DIC->database();
51 $this->
event = $DIC->event();
52 $this->
user = $DIC->user();
53 $this->ui_factory = $DIC->ui()->factory();
54 $this->
renderer = $DIC->ui()->renderer();
56 if ($a_id && $a_id != 0) {
61 $this->notes = $DIC->notes();
62 $this->
http = $DIC->http();
66 public function doUpdate(
bool $omit_notification =
false): void
98 $recordfield->doUpdate();
102 if (!$omit_notification) {
103 $ref_id = $this->
http->wrapper()->query()->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
112 $query =
"Select * From il_dcl_record WHERE id = " . $this->db->quote($this->
getId(),
"integer") .
" ORDER BY id";
114 $set = $this->db->query($query);
115 $rec = $this->db->fetchAssoc($set);
124 if (
null !== $rec[
"create_date"]) {
127 if (
null !== $rec[
"last_update"]) {
132 $this->
setOwner((
int) $rec[
"owner"]);
133 if (
null !== $rec[
"last_edit_by"]) {
144 throw new ilException(
"The field does not have a related table!");
147 $id = $this->db->nextId(
"il_dcl_record");
150 =
"INSERT INTO il_dcl_record ( 157 ) VALUES (" . $this->db->quote($this->
getId(),
"integer") .
"," . $this->db->quote(
165 . $this->db->quote($this->
getOwner(),
"integer") .
"," . $this->db->quote($this->
getLastEditBy(),
"integer") .
" 167 $this->db->manipulate($query);
171 $recordField->doCreate();
180 $this->recordfields[$field_id]->delete();
181 if (count($this->recordfields) == 1) {
186 public function setId(
int $a_id): void
198 $this->table_id = $a_id;
208 $this->create_date = $a_datetime;
218 $this->last_update = $a_datetime;
228 $this->owner = $a_id;
258 $this->recordfields[$field_id]->setValue($value);
273 $this->recordfields[$field_id]->setValueFromForm($form);
284 return $this->recordfields[$field->
getId()]->getValueFromExcel($excel, $row, $col);
293 $value = $field->getValueFromExcel($excel, $row, $col);
295 $this->{$field->
getId()} = $value;
303 foreach ($this->recordfields as $id => $record_field) {
304 $return[
$id] = $record_field->getValue();
316 if ($field_id ===
null) {
323 return $this->recordfields[$field_id]->getValue();
334 if ($field_id ===
'owner') {
338 $worksheet->
setCell($row, $col, $name_array[
'lastname'] .
', ' . $name_array[
'firstname']);
339 } elseif ($field_id ===
'last_update') {
341 $worksheet->
setCell($row, $col, $date_time);
342 } elseif ($field_id ===
'create_date') {
344 $worksheet->
setCell($row, $col, $date_time);
350 $this->recordfields[$field_id]->fillExcelExport($worksheet, $row, $col);
363 if (is_object($this->recordfields[$field_id])) {
364 $value = $this->recordfields[$field_id]->getFormulaValue();
382 if (array_key_exists($field_id, $this->recordfields) && is_object($this->recordfields[$field_id])) {
383 $html = $this->recordfields[$field_id]->getRecordRepresentation()->getHTML(
true, $options);
395 public function getRecordFieldSingleHTML($field_id, array $options = []):
string 402 $field = $this->recordfields[$field_id];
407 $html = $field->getRecordRepresentation()->getSingleHTML($options,
false);
422 $this->recordfields[$field_id]->getRecordRepresentation()->fillFormInput($form);
442 if ($field_id ==
"last_edit_by") {
446 $this->{$field_id} = $value;
471 return $this->{$field_id};
486 return (
string) $this->
getId();
497 $ref_id = $this->
http->wrapper()->query()->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
503 $this->table->getCollectionObject()
508 $update_code =
"il.UI.counter.getCounterObject($(\".ilc_page_Page\")).incrementStatusCount(1);";
512 $comment_glyph = $this->ui_factory->symbol()->glyph()->comment()->withCounter(
513 $this->ui_factory->counter()->status($nr_comments)
515 return "document.getElementById('$id').onclick = function (event) { $ajax_link; };";
517 return $this->
renderer->render($comment_glyph);
539 if ($this->recordfields ==
null) {
542 foreach ($this->table->getRecordFields() as $field) {
543 if (($recordfields[$field->getId()] ??
null) ===
null) {
554 if ($this->table ===
null) {
563 return $this->recordfields[$field_id];
566 public function doDelete(
bool $omit_notification =
false): void
569 foreach ($this->recordfields as $recordfield) {
571 $this->
deleteMob((
int) $recordfield->getValue());
574 $recordfield->delete();
577 $query =
"DELETE FROM il_dcl_record WHERE id = " . $this->db->quote($this->
getId(),
"integer");
578 $this->db->manipulate($query);
580 $this->table->loadRecords();
582 if (!$omit_notification) {
583 $ref_id = $this->
http->wrapper()->query()->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
588 'components/ILIAS/DataCollection',
592 'table_id' => $this->table_id,
593 'record_id' => $this->
getId(),
607 $this->
setOwner($original->getOwner());
609 foreach ($new_fields as $old => $new) {
610 $old_rec_field = $original->getRecordField($old);
612 $new_rec_field->cloneStructure($old_rec_field);
613 $this->recordfields[] = $new_rec_field;
638 return $this->
getTable()->hasPermissionToEditRecord($ref_id, $this);
643 return $this->
getTable()->hasPermissionToDeleteRecord($ref_id, $this);
648 return $this->
getTable()->hasPermissionToViewRecord($ref_id, $this);
673 if ($this->nr_of_comments ===
null) {
677 $this->table->getCollectionObject()->getId(),
681 $this->nr_of_comments = $this->notes
683 ->getNrOfCommentsForContext(
$context);
getRecordFieldHTML($field_id, array $options=[])
getStandardFieldFormulaValue($field_id)
hasPermissionToView(int $ref_id)
setStandardFieldFromForm($field_id, ilPropertyFormGUI $form)
doUpdate(bool $omit_notification=false)
getRecordFieldValue(?string $field_id)
Get Field Value.
setStandardFieldValueFromExcel(ilExcel $excel, int $row, int $col, ilDclBaseFieldModel $field)
withAdditionalOnLoadCode(Closure $binder)
static _lookupName(int $a_user_id)
lookup user name
hasPermissionToEdit(int $ref_id)
getStandardFieldHTML(string $field_id, array $options=[])
setRecordFieldValue($field_id, $value)
__construct(?int $a_id=0)
setStandardField($field_id, $value)
ILIAS UI Factory $ui_factory
getRecordField(int $field_id)
static _lookupObjId(int $ref_id)
setRecordFieldValueFromForm(int $field_id, ilPropertyFormGUI $form)
Set a field value.
static buildAjaxHash(int $node_type, ?int $node_id, string $obj_type, int $obj_id, ?string $sub_type=null, ?int $sub_id=null, int $news_id=0)
Build ajax hash.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
getRecordFieldFormulaValue($field_id)
static http()
Fetches the global http state from ILIAS.
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
ILIAS Refinery Factory $refinery
getNrOfComments()
Get nr of comments of this record.
getStandardFieldPlainText(string $field_id)
ILIAS UI Renderer $renderer
static getTableCache(?int $table_id=null)
static setCloneOf(int $old, int $new, string $type)
getRecordFieldValueFromExcel(ilExcel $excel, int $row, int $col, ilDclBaseFieldModel $field)
static _isStandardField($field_id)
static getListCommentsJSCall(string $a_hash, ?string $a_update_code=null)
Get list comments js call.
fillRecordFieldExcelExport(ilExcel $worksheet, int &$row, int &$col, $field_id)
hasPermissionToDelete(int $ref_id)
setLastEditBy(?int $last_edit_by)
static getRecordCache(?int $record_id)
setCreateDate(ilDateTime $a_datetime)
getStandardField($field_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
setLastUpdate(ilDateTime $a_datetime)
ILIAS HTTP Services $http
static getRecordFieldCache(object $record, object $field)
deleteField(int $field_id)
cloneStructure(int $original_id, array $new_fields)
doDelete(bool $omit_notification=false)
fillRecordFieldFormInput($field_id, ilPropertyFormGUI $form)
static _tableExists(int $table_id)
fillStandardFieldFormInput($field_id, ilPropertyFormGUI $form)
static _lookupLogin(int $a_user_id)