19 declare(strict_types=1);
36 $result = $this->db->query(
"SELECT * FROM il_dcl_data WHERE id = " . $this->db->quote($this->getId(),
"integer"));
38 $data = $this->db->fetchObject($result);
48 protected function doCreate(
bool $clone_mode =
false): void
50 $this->log->write(
'doCreate');
55 $main_table->setObjId($this->
getId());
56 $main_table->setTitle($this->
getTitle());
57 $main_table->setAddPerm(
true);
58 $main_table->setEditPerm(
true);
59 $main_table->setDeletePerm(
false);
60 $main_table->setDeleteByOwner(
true);
61 $main_table->setEditByOwner(
true);
62 $main_table->setLimited(
false);
63 $main_table->setIsVisible(
true);
64 $main_table->doCreate();
72 "id" => [
"integer", $this->
getId()],
73 "is_online" => [
"integer", (
int) $this->
getOnline()],
74 "rating" => [
"integer", (
int) $this->
getRating()],
76 "approval" => [
"integer", (
int) $this->
getApproval()],
85 $table->doDelete(
false,
true);
90 $query =
"DELETE FROM il_dcl_data WHERE id = " . $this->db->quote($this->
getId(),
"integer");
91 $this->db->manipulate($query);
101 "id" => [
"integer", $this->
getId()],
102 "is_online" => [
"integer", (
int) $this->
getOnline()],
103 "rating" => [
"integer", (
int) $this->
getRating()],
105 "approval" => [
"integer", (
int) $this->
getApproval()],
109 "id" => [
"integer", $this->
getId()],
114 public function sendNotification($a_action, $a_table_id, $a_record_id =
null):
void 117 $user = $DIC->user();
135 if (!count($users)) {
141 $link = ilLink::_getLink($this->
getRefId());
147 foreach (array_unique($users) as $idx =>
$user_id) {
150 $ilDclTable =
new ilDclTable($record->getTableId());
155 $ulng->loadLanguageModule(
'dcl');
157 $subject = sprintf($ulng->txt(
'dcl_change_notification_subject'), $this->
getTitle());
160 $message .= $ulng->txt(
'dcl_change_notification_dcl_' . $a_action) .
":\n\n";
161 $message .= $ulng->txt(
'obj_dcl') .
": " . $this->
getTitle() .
"\n\n";
162 $message .= $ulng->txt(
'dcl_table') .
": " . $obj_table->getTitle() .
"\n\n";
163 $message .= $ulng->txt(
'dcl_record') .
":\n";
164 $message .=
"------------------------------------\n";
166 if (!$record->getTableId()) {
167 $record->setTableId($a_table_id);
172 if ($tableview_id = $record->getTable()->getFirstTableViewId($this->
getRefId(),
$user_id)) {
173 $visible_fields = ilDclTableView::find($tableview_id)->getVisibleFields();
174 if (empty($visible_fields)) {
178 foreach ($visible_fields as $field) {
180 if ($field->isStandardField()) {
181 $value = $record->getStandardFieldPlainText($field->getId());
182 } elseif ($record_field = $record->getRecordField((
int) $field->getId())) {
183 $value = $record_field->getPlainText();
187 $t .= $field->getTitle() .
": " . $value .
"\n";
193 $message .=
"------------------------------------\n";
196 $message .= $ulng->txt(
'dcl_change_notification_link') .
": " . $link .
"\n\n";
198 $message .= $ulng->txt(
'dcl_change_why_you_receive_this_email');
201 $mail_obj->appendInstallationSignature(
true);
215 $this->db->setLimit(1);
217 $result = $this->db->query(
218 'SELECT id FROM il_dcl_table 219 WHERE obj_id = ' . $this->db->quote($this->getId(),
'integer') .
220 $only_visible .
' ORDER BY -table_order DESC' 225 if (!$result->numRows() && $only_visible) {
226 $this->db->setLimit(1);
227 $result = $this->db->query(
228 'SELECT id FROM il_dcl_table 229 WHERE obj_id = ' . $this->db->quote($this->getId(),
'integer') .
' ORDER BY -table_order DESC ' 233 return $this->db->fetchObject($result)->id;
240 foreach ($table_order as
$title) {
243 $table->setOrder($order);
263 if (!$cp_options->isRootNode($this->getRefId())) {
264 $new_obj->setOnline(
true);
267 $new_obj->cloneStructure($this->
getRefId());
283 $this->
setRating($original->getRating());
291 foreach ($original->getTables() as $table) {
293 $new_table->setObjId($this->
getId());
294 $new_table->cloneStructure($table);
301 $table->afterClone();
310 $this->is_online = $a_val;
323 $this->rating = $a_val;
333 $this->public_notes = $a_val;
343 $this->approval = $a_val;
386 $query =
"SELECT id FROM il_dcl_table WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") .
387 " ORDER BY title ASC";
388 $set = $this->db->query($query);
391 while ($rec = $this->db->fetchAssoc($set)) {
407 if ($table->getIsVisible() && $table->getVisibleTableViews($this->ref_id)) {
408 $tables[$table->getId()] = $table;
421 $ilDB = $DIC[
'ilDB'];
422 $result =
$ilDB->query(
423 'SELECT * FROM il_dcl_table WHERE obj_id = ' .
$ilDB->quote($obj_id,
'integer') .
' AND title = ' 424 .
$ilDB->quote($title,
'text')
427 return (
bool)
$ilDB->numRows($result);
438 if (preg_match_all(
'/<.*?br.*?>/', $body, $matches)) {
439 $matches = array_unique($matches[0]);
440 $brNewLineMatches =
array_map(
static function ($match):
string {
441 return $match .
"\n";
445 $body = str_replace(
"\r",
'', $body);
447 $body = str_replace($brNewLineMatches,
"\n", $body);
449 $body = str_replace($matches,
"\n", $body);
451 return str_replace(
"\n",
"\r\n", $body);
const TYPE_DATACOLLECTION
setNotification(bool $a_val)
cloneMetaData(ilObject $target_obj)
static _lookupFullname(int $a_user_id)
getFirstVisibleTableId()
for users with write access, return id of table with the lowest sorting for users with no write acces...
static _getTableIdByTitle(string $title, int $obj_id)
static _hasTableByTitle(string $title, int $obj_id)
Checks if a DataCollection has a table with a given title.
doCloneObject(ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
Clone DCL.
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object.
prepareMessageText(string $body)
notification()
description: > Example for rendring a notification glyph.
const TYPE_DATA_COLLECTION
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _hasWriteAccess(int $ref)
static _hasReadAccess(int $ref)
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:
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
setOnline(bool $a_val)
setOnline
static getTableCache(?int $table_id=null)
static hasWriteAccess(int $ref, ?int $user_id=0)
static setCloneOf(int $old, int $new, string $type)
static updateNotificationTime(int $type, int $id, array $user_ids, ?int $page_id=null, bool $activate_new_entries=true)
Update the last mail timestamp for given object and users.
static getRecordCache(?int $record_id)
setPublicNotes(bool $a_val)
doCreate(bool $clone_mode=false)
static hasReadAccess(int $ref, ?int $user_id=0)
static _getInstance(int $a_copy_id)
getTableById(int $table_id)
cloneStructure(int $original_id)
Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollec...
reorderTables(array $table_order)
static _lookupLogin(int $a_user_id)