3declare(strict_types=1);
88 $this->
ilias = $DIC[
"ilias"];
89 $this->obj_definition =
$DIC[
"objDefinition"];
90 $this->db =
$DIC[
"ilDB"];
91 $this->log =
$DIC[
"ilLog"];
93 $this->
error = $DIC[
"ilErr"];
94 $this->tree =
$DIC[
"tree"];
95 $this->app_event_handler =
$DIC[
"ilAppEventHandler"];
97 $this->referenced = $reference;
98 $this->call_by_reference = $reference;
100 if (isset(
$DIC[
"lng"])) {
101 $this->
lng = $DIC[
"lng"];
104 if (isset(
$DIC[
"ilUser"])) {
105 $this->
user = $DIC[
"ilUser"];
108 if (isset(
$DIC[
"rbacadmin"])) {
109 $this->rbac_admin =
$DIC[
"rbacadmin"];
112 if (isset(
$DIC[
"rbacreview"])) {
113 $this->rbac_review =
$DIC[
"rbacreview"];
117 $this->referenced =
false;
120 if ($this->referenced) {
146 $this->process_auto_reating =
true;
154 }
catch (InvalidArgumentException
$e) {
157 if ($this->referenced) {
158 if (!isset($this->ref_id)) {
159 $message =
"ilObject::read(): No ref_id given! (" . $this->type .
")";
165 "SELECT od.obj_id, od.type, od.title, od.description, od.owner, od.create_date," . PHP_EOL
166 .
"od.last_update, od.import_id, od.offline, ore.ref_id, ore.obj_id, ore.deleted, ore.deleted_by" . PHP_EOL
167 .
"FROM " . self::TABLE_OBJECT_DATA .
" od" . PHP_EOL
168 .
"JOIN object_reference ore ON od.obj_id = ore.obj_id" . PHP_EOL
169 .
"WHERE ore.ref_id = " . $this->db->quote($this->ref_id,
"integer") . PHP_EOL
172 $result = $this->db->query($sql);
175 if ($this->db->numRows($result) == 0) {
177 "ilObject::read(): Object with ref_id %s not found! (%s)",
184 if (!isset($this->
id)) {
185 $message = sprintf(
"ilObject::read(): No obj_id given! (%s)", $this->type);
190 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
191 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
192 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
194 $result = $this->db->query($sql);
196 if ($this->db->numRows($result) == 0) {
197 $message = sprintf(
"ilObject::read(): Object with obj_id: %s (%s) not found!", $this->
id, $this->type);
201 $obj = $this->db->fetchAssoc($result);
203 $this->
id = (
int) $obj[
"obj_id"];
206 if ($this->type != $obj[
"type"] && $obj[
"type"] !=
"xxx") {
208 "ilObject::read(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
218 $this->type = (string) $obj[
"type"];
219 $this->title = (string) $obj[
"title"];
221 $this->untranslatedTitle = (string) $obj[
"title"];
224 $this->desc = (string) $obj[
"description"];
225 $this->owner = (
int) $obj[
"owner"];
226 $this->create_date = (string) $obj[
"create_date"];
227 $this->last_update = (string) $obj[
"last_update"];
228 $this->import_id = (string) $obj[
"import_id"];
232 if ($this->obj_definition->isRBACObject($this->getType())) {
234 "SELECT obj_id, description" . PHP_EOL
235 .
"FROM object_description" . PHP_EOL
236 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
239 $res = $this->db->query($sql);
242 if (($row->description ??
'') !==
'') {
249 $translation_type = $this->obj_definition->getTranslationType($this->type);
251 if ($translation_type ==
"sys") {
252 $this->title = $this->
lng->txt(
"obj_" . $this->type);
254 } elseif ($translation_type ==
"db") {
256 "SELECT title, description" . PHP_EOL
257 .
"FROM object_translation" . PHP_EOL
258 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
259 .
"AND lang_code = " . $this->db->quote(
$ilUser->getCurrentLanguage(),
'text') . PHP_EOL
261 $r = $this->db->query($sql);
264 $this->title = (string) $row->title;
265 $this->setDescription((
string) $row->description);
283 $this->referenced =
true;
288 return $this->ref_id ?? 0;
350 if (strlen($this->long_desc)) {
352 } elseif (strlen($this->desc)) {
377 "SELECT obj_id" . PHP_EOL
378 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
380 .
"ORDER BY create_date DESC" . PHP_EOL
390 return (
int) $row->obj_id;
395 $this->offline = $status;
405 return $this->obj_definition->supportsOfflineHandling($this->
getType());
415 "SELECT import_id" . PHP_EOL
416 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
417 .
"WHERE obj_id = " .
$db->
quote($obj_id,
"integer") . PHP_EOL
422 return (
string) $row->import_id;
449 if ($owner_id != -1) {
455 $own_name =
$lng->
txt(
"unknown");
457 $own_name =
$owner->getFullname();
465 $this->owner = $usr_id;
493 if (!isset($this->type)) {
494 $message = sprintf(
"%s::create(): No object type given!", get_class($this));
498 $this->log->write(
"ilObject::create(), start");
504 } elseif (is_object(
$user)) {
508 $this->
id = $this->db->nextId(self::TABLE_OBJECT_DATA);
510 "obj_id" => [
"integer", $this->
getId()],
511 "type" => [
"text", $this->
getType()],
512 "title" => [
"text", $this->
getTitle()],
514 "owner" => [
"integer",
$owner],
515 "create_date" => [
"date", $this->db->now()],
516 "last_update" => [
"date", $this->db->now()],
521 $this->db->insert(self::TABLE_OBJECT_DATA, $values);
525 if ($this->obj_definition->isRBACObject($this->getType())) {
530 $this->db->insert(
'object_description', $values);
533 if ($this->obj_definition->isOrgUnitPermissionType($this->type)) {
541 "SELECT last_update, create_date" . PHP_EOL
542 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
543 .
"WHERE obj_id = " . $this->db->quote($this->
id,
"integer") . PHP_EOL
545 $obj_set = $this->db->query($sql);
546 $obj_rec = $this->db->fetchAssoc($obj_set);
547 $this->last_update = $obj_rec[
"last_update"];
548 $this->create_date = $obj_rec[
"create_date"];
554 $this->log->write(sprintf(
555 "ilObject::create(), finished, obj_id: %s, type: %s, title: %s",
561 $this->app_event_handler->raise(
565 'obj_id' => $this->
id,
566 'obj_type' => $this->type
576 "title" => [
"text", $this->
getTitle()],
578 "last_update" => [
"date", $this->db->now()],
584 "obj_id" => [
"integer", $this->
getId()]
587 $this->db->update(self::TABLE_OBJECT_DATA, $values, $where);
593 "SELECT last_update" . PHP_EOL
594 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
595 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
597 $obj_set = $this->db->query($sql);
598 $obj_rec = $this->db->fetchAssoc($obj_set);
599 $this->last_update = $obj_rec[
"last_update"];
601 if ($this->obj_definition->isRBACObject($this->getType())) {
604 "SELECT obj_id, description" . PHP_EOL
605 .
"FROM object_description" . PHP_EOL
606 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') . PHP_EOL
608 $res = $this->db->query($sql);
610 if (
$res->numRows()) {
615 'obj_id' => [
'integer',$this->
getId()]
617 $this->db->update(
'object_description', $values, $where);
621 'obj_id' => [
'integer',$this->
getId()]
623 $this->db->insert(
'object_description', $values);
627 $this->app_event_handler->raise(
631 'obj_id' => $this->
getId(),
632 'obj_type' => $this->
getType(),
652 $this->app_event_handler->raise(
655 array(
'obj_id' => $this->
getId(),
656 'obj_type' => $this->
getType(),
662 if ($element ==
'General') {
664 if (!is_object($md_gen = $md->getGeneral())) {
667 $this->
setTitle($md_gen->getTitle());
669 foreach ($md_gen->getDescriptionIds() as
$id) {
670 $md_des = $md_gen->getDescription(
$id);
696 $md_creator->setTitle($this->
getTitle());
697 $md_creator->setTitleLanguage(
$ilUser->getPref(
'language'));
699 $md_creator->setDescriptionLanguage(
$ilUser->getPref(
'language'));
700 $md_creator->setKeywordLanguage(
$ilUser->getPref(
'language'));
703 $md_creator->create();
721 $md_gen = $md->getGeneral();
726 $md_gen = $md->getGeneral();
729 $md_gen->setTitle($this->
getTitle());
732 $md_des_ids = $md_gen->getDescriptionIds();
733 if (count($md_des_ids) > 0) {
734 $md_des = $md_gen->getDescription($md_des_ids[0]);
776 "owner" => [
"integer", $this->
getOwner()],
777 "last_update" => [
"date", $this->db->now()]
781 "obj_id" => [
"integer", $this->
getId()]
784 $this->db->update(self::TABLE_OBJECT_DATA, $values, $where);
797 "SELECT obj_id" . PHP_EOL
798 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
800 .
"ORDER BY create_date DESC" . PHP_EOL
806 return (
int) $row[
"obj_id"];
822 "SELECT ref_id" . PHP_EOL
823 .
"FROM object_reference" . PHP_EOL
824 .
"WHERE obj_id = " .
$db->
quote(
$id,
'integer') . PHP_EOL
831 $ref[(
int) $row[
"ref_id"]] = (
int) $row[
"ref_id"];
840 return (
string)
$DIC[
"ilObjDataCache"]->lookupTitle($obj_id);
849 return $DIC[
'ilObjDataCache']->lookupOfflineStatus($obj_id);
858 return (
int)
$DIC[
"ilObjDataCache"]->lookupOwner($obj_id);
870 if ($partial_match) {
875 "SELECT obj_id" . PHP_EOL
876 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
877 .
"WHERE " . $where . PHP_EOL
888 $object_ids[] = (
int) $row[
'obj_id'];
897 return (
string)
$DIC[
"ilObjDataCache"]->lookupDescription($obj_id);
919 "SELECT MAX(last_update) as last_update" . PHP_EOL
920 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
921 .
"WHERE " .
$db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
927 return (
string) $row[
"last_update"];
933 return $DIC[
"ilObjDataCache"]->lookupObjId(
$ref_id);
942 "deleted" => [
"date",
$db->
now()],
943 "deleted_by" => [
"integer", $deleted_by]
947 "ref_id" => [
"integer",
$ref_id]
950 $db->
update(
"object_reference", $values, $where);
962 "UPDATE object_reference" . PHP_EOL
963 .
"SET deleted = " .
$db->
now() .
", " . PHP_EOL
964 .
"deleted_by = " .
$db->
quote($user_id,
"integer") . PHP_EOL
965 .
"WHERE " .
$db->
in(
"ref_id", $ref_ids,
false,
"integer") . PHP_EOL;
976 "deleted" => [
"timestamp",
null],
977 "deleted_by" => [
"integer", 0]
981 "ref_id" => [
"integer",
$ref_id]
984 $db->
update(
"object_reference", $values, $where);
993 "SELECT deleted" . PHP_EOL
994 .
"FROM object_reference" . PHP_EOL
1000 return $row[
"deleted"];
1012 "title" => [
"text",
$title],
1013 "last_update" => [
"date",
$db->
now()]
1017 "obj_id" => [
"integer", $obj_id]
1020 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1036 "description" => [
"text",
$desc],
1037 "last_update" => [
"date",
$db->
now()]
1041 "obj_id" => [
"integer", $obj_id]
1044 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1050 "SELECT obj_id, description" . PHP_EOL
1051 .
"FROM object_description" . PHP_EOL
1052 .
"WHERE obj_id = " .
$db->
quote($obj_id,
'integer') . PHP_EOL
1056 if ($result->numRows()) {
1058 "description" => [
"clob",
$desc]
1060 $db->
update(
"object_description", $values, $where);
1063 "description" => [
"clob",
$desc],
1064 "obj_id" => [
"integer",$obj_id]
1066 $db->
insert(
"object_description", $values);
1081 "last_update" => [
"date",
$db->
now()]
1085 "obj_id" => [
"integer", $obj_id]
1088 $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
1096 return $DIC[
"ilObjDataCache"]->lookupType(
$DIC[
"ilObjDataCache"]->lookupObjId(
$id));
1099 return $DIC[
"ilObjDataCache"]->lookupType(
$id);
1114 foreach ($ref_ids as
$ref_id) {
1126 return $DIC[
"ilObjDataCache"]->lookupObjId(
$ref_id);
1142 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1143 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1151 $objects[$row[
"title"] .
"." . $row[
"obj_id"]] = [
1152 "id" => $row[
"obj_id"],
1153 "type" => $row[
"type"],
1154 "title" => $row[
"title"],
1155 "description" => $row[
"description"]
1171 $this->tree->insertNode($this->
getRefId(), $parent_ref_id);
1174 $log_entry = sprintf(
1175 "ilObject::putInTree(), parent_ref: %s, ref_id: %s, obj_id: %s, type: %s, title: %s",
1183 $this->log->write($log_entry);
1185 $this->app_event_handler->raise(
1190 'obj_type' => $this->
getType(),
1191 'obj_id' => $this->
getId(),
1192 'parent_ref_id' => $parent_ref_id
1210 $parent_roles = $this->rbac_review->getParentRoleIds($parent_ref_id);
1211 foreach ($parent_roles as $parent_role) {
1215 $operations = $this->rbac_review->getOperationsOfRole(
1216 (
int) $parent_role[
'obj_id'],
1218 (
int) $parent_role[
'parent']
1220 $this->rbac_admin->grantPermission(
1221 (
int) $parent_role[
'obj_id'],
1234 if (!isset($this->
id)) {
1235 $message =
"ilObject::createNewReference(): No obj_id given!";
1239 $next_id = $this->db->nextId(
'object_reference');
1242 "ref_id" => [
"integer", $next_id],
1243 "obj_id" => [
"integer", $this->
getId()]
1246 $this->db->insert(
"object_reference", $values);
1248 $this->ref_id = $next_id;
1249 $this->referenced =
true;
1256 if (!isset($this->
id)) {
1257 $message =
"ilObject::countReferences(): No obj_id given!";
1262 "SELECT COUNT(ref_id) num" . PHP_EOL
1263 .
"FROM object_reference" . PHP_EOL
1264 .
"WHERE obj_id = " . $this->db->quote($this->
id,
'integer') . PHP_EOL
1267 $res = $this->db->query($sql);
1268 $row = $this->db->fetchObject(
$res);
1270 return (
int) $row->num;
1281 public function delete():
bool
1291 if ($this->type !=
$type) {
1292 $log_entry = sprintf(
1293 "ilObject::delete(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
1299 $this->log->write($log_entry);
1300 $this->
error->raiseError(
1301 sprintf(
"ilObject::delete(): Type mismatch. (%s/%s)", $this->type, $this->
id),
1302 $this->
error->WARNING
1306 $this->app_event_handler->raise(
'Services/Object',
'beforeDeletion', [
'object' => $this]);
1309 "DELETE FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1310 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1312 $this->db->manipulate($sql);
1315 "DELETE FROM object_description" . PHP_EOL
1316 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
"integer") . PHP_EOL
1318 $this->db->manipulate($sql);
1322 "ilObject::delete(), deleted object, obj_id: %s, type: %s, title: %s",
1334 $news_item->deleteNewsOfContext($this->
getId(), $this->
getType());
1341 "DELETE FROM dav_property" . PHP_EOL
1342 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') . PHP_EOL
1344 $this->db->manipulate($sql);
1355 "ilObject::delete(), object not deleted, number of references: %s, obj_id: %s, type: %s, title: %s",
1365 if ($this->referenced) {
1368 $this->app_event_handler->raise(
'Services/Object',
'deleteReference', [
'ref_id' => $this->
getRefId()]);
1371 "DELETE FROM object_reference" . PHP_EOL
1372 .
"WHERE ref_id = " . $this->db->quote($this->
getRefId(),
'integer') . PHP_EOL
1374 $this->db->manipulate($sql);
1378 "ilObject::delete(), reference deleted, ref_id: %s, obj_id: %s, type: %s, title: %s",
1399 if ($this->referenced) {
1424 $action->setRefId($this->
getRefId());
1440 public static function _exists(
int $id,
bool $reference =
false, ?
string $type =
null): bool
1447 "SELECT object_data.obj_id" . PHP_EOL
1448 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1449 .
"LEFT JOIN object_reference ON object_reference.obj_id = object_data.obj_id " . PHP_EOL
1450 .
"WHERE object_reference.ref_id= " .
$db->
quote(
$id,
"integer") . PHP_EOL
1454 "SELECT object_data.obj_id" . PHP_EOL
1455 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1456 .
"WHERE obj_id = " .
$db->
quote(
$id,
"integer") . PHP_EOL
1461 $sql .=
" AND object_data.type = " .
$db->
quote(
$type,
"text") . PHP_EOL;
1483 $order =
" ORDER BY title";
1487 $where =
"WHERE type = " .
$db->
quote($obj_type,
"text");
1495 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
1496 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
1505 $row[
"desc"] = $row[
"description"];
1506 $arr[$row[
"obj_id"]] = $row;
1522 bool $show_path =
true
1531 "SELECT obj_data.title obj_title, path_data.title path_title, child" . PHP_EOL
1532 .
"FROM tree " . PHP_EOL
1533 .
"JOIN object_reference obj_ref ON child = obj_ref.ref_id " . PHP_EOL
1534 .
"JOIN object_data obj_data ON obj_ref.obj_id = obj_data.obj_id " . PHP_EOL
1535 .
"JOIN object_reference path_ref ON parent = path_ref.ref_id " . PHP_EOL
1536 .
"JOIN object_data path_data ON path_ref.obj_id = path_data.obj_id " . PHP_EOL
1537 .
"WHERE " .
$db->
in(
"child", $ref_ids,
false,
"integer") . PHP_EOL
1538 .
"ORDER BY obj_data.title" . PHP_EOL
1543 $options[0] =
$lng->
txt(
'obj_' . $new_type .
'_select');
1549 if (strlen(
$title = $row->obj_title) > 40) {
1554 if (strlen(
$path = $row->path_title) > 40) {
1561 $options[$row->child] =
$title;
1563 return $options ?: array();
1569 public function cloneObject(
int $target_id,
int $copy_id = 0,
bool $omit_tree =
false): ?
ilObject
1574 $rbac_admin =
$DIC[
"rbacadmin"];
1576 $class_name = (
'ilObj' . $this->obj_definition->getClassName($this->getType()));
1580 $title = $this->getTitle();
1581 $this->obj_log->debug($title);
1582 $this->obj_log->debug(
"isTreeCopyDisabled: " . $options->isTreeCopyDisabled());
1583 $this->obj_log->debug(
"omit_tree: " . $omit_tree);
1584 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1585 $title_with_suffix = $this->appendCopyInfo(
$target_id, $copy_id);
1586 $title = mb_strlen($title_with_suffix) < self::TITLE_LENGTH ? $title_with_suffix : $title;
1587 $this->obj_log->debug(
"title incl. copy info: " . $title);
1592 $new_obj =
new $class_name(0,
false);
1593 $new_obj->setOwner(
$ilUser->getId());
1594 $new_obj->setTitle($title);
1595 $new_obj->setDescription($this->getLongDescription());
1596 $new_obj->setType($this->getType());
1599 $new_obj->create(
true);
1601 if ($this->supportsOfflineHandling()) {
1602 $new_obj->setOffLineStatus($this->getOfflineStatus());
1606 if (!$options->isTreeCopyDisabled() && !$omit_tree) {
1608 $new_obj->createReference();
1613 if ($this->getRefId()) {
1615 $rbac_admin->
copyLocalRoles($this->getRefId(), $new_obj->getRefId());
1625 "INSERT INTO dav_property" . PHP_EOL
1626 .
"(obj_id, node_id, ns, name, value)" . PHP_EOL
1627 .
"SELECT " . $this->db->quote($new_obj->getId(),
'integer') .
", node_id, ns, name, value " . PHP_EOL
1628 .
"FROM dav_property" . PHP_EOL
1629 .
"WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') . PHP_EOL
1631 $this->db->manipulate($sql);
1635 $customIconFactory =
$DIC[
'object.customicons.factory'];
1636 $customIcon = $customIconFactory->getByObjId($this->
getId(), $this->getType());
1637 $customIcon->copy($new_obj->getId());
1639 $tile_image =
$DIC->object()->commonSettings()->tileImage()->getByObjId($this->
getId());
1640 $tile_image->copy($new_obj->getId());
1642 $this->app_event_handler->raise(
1646 'object' => $new_obj,
1647 'cloned_from_object' => $this,
1660 if (!$cp_options->isRootNode($this->getRefId())) {
1661 return $this->getTitle();
1666 $other_children_of_same_type = $this->tree->getChildsByType(
$target_id, $this->type);
1668 if ($obj_translations->getLanguages() === []) {
1669 $existing_titles = array_map(
1670 fn (array $child):
string => $child[
'title'],
1671 $other_children_of_same_type
1674 return $this->appendNumberOfCopiesToTitle(
1675 $this->
lng->txt(
'copy_of_suffix'),
1676 $this->lng->txt(
'copy_n_of_suffix'),
1682 return $this->appendCopyInfoToTranslations($obj_translations, $other_children_of_same_type);
1687 array $other_children_of_same_type
1689 $nodes_translations = array_map(
1692 $other_children_of_same_type
1695 $title_translations_per_lang = array_reduce(
1696 $nodes_translations,
1697 $this->getCallbackForTitlesPerLanguageTransformation(),
1701 $new_languages = [];
1702 $installed_langs = $this->
lng->getInstalledLanguages();
1703 foreach ($obj_translations->
getLanguages() as $language) {
1704 $lang_code = $language->getLanguageCode();
1705 $suffix_lang = $lang_code;
1706 if (!in_array($suffix_lang, $installed_langs)) {
1707 $suffix_lang = $this->
lng->getDefaultLanguage();
1709 $language->setTitle(
1710 $this->appendNumberOfCopiesToTitle(
1711 $this->
lng->txtlng(
'common',
'copy_of_suffix', $suffix_lang),
1712 $this->lng->txtlng(
'common',
'copy_n_of_suffix', $suffix_lang),
1713 $language->getTitle(),
1714 $title_translations_per_lang[$lang_code] ?? []
1717 $new_languages[$lang_code] = $language;
1727 $langs = $nt->getLanguages();
1728 foreach ($langs as
$lang) {
1729 if (!array_key_exists(
$lang->getLanguageCode(), $npl)) {
1730 $npl[
$lang->getLanguageCode()] = [];
1732 $npl[
$lang->getLanguageCode()][] =
$lang->getTitle();
1739 string $copy_suffix,
1740 string $copy_n_suffix,
1742 array $other_titles_for_lang
1744 $title_without_suffix = $this->buildTitleWithoutCopySuffix($copy_suffix, $copy_n_suffix, $title);
1745 $title_with_suffix =
"{$title_without_suffix} {$copy_suffix}";
1746 if ($other_titles_for_lang === []
1747 || $this->isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
1748 return $title_with_suffix;
1751 for (
$i = 2;
true;
$i++) {
1752 $title_with_suffix = $title_without_suffix .
' ' . sprintf($copy_n_suffix,
$i);
1753 if ($this->isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
1754 return $title_with_suffix;
1761 foreach ($nodes as $node) {
1762 if (($title === $node)) {
1777 $regexp_for_suffix = preg_replace(
1778 '/([\^$.\[\]|()?*+{}])/',
1783 $regexp_for_file_name =
'/' . preg_replace(
'/%1\\\\\$s/',
'([0-9]+)', $regexp_for_suffix) .
'$/';
1785 if (preg_match($regexp_for_file_name, $title, $matches)) {
1786 return substr($title, 0, -strlen($matches[0]));
1789 if (str_ends_with($title,
" {$copy_suffix}")) {
1818 $obj->applyDidacticTemplate($tpl_id);
1829 $md =
new ilMD($this->
getId(), 0, $this->getType());
1830 $md->cloneMD($target_obj->
getId(), 0, $target_obj->
getType());
1834 public static function getIconForReference(
1839 bool $offline =
false
1844 $objDefinition =
$DIC[
"objDefinition"];
1846 if ($obj_id ==
"" &&
$type ==
"") {
1858 if ($obj_id &&
$ilSetting->get(
'custom_icons')) {
1860 $customIconFactory =
$DIC[
'object.customicons.factory'];
1861 $customIcon = $customIconFactory->getPresenterByObjId($obj_id,
$type);
1862 if ($customIcon->exists()) {
1871 $path = $dtpl_icon_factory->getIconPathForReference(
$ref_id);
1873 $path = $dtpl_icon_factory->getIconPathForObject($obj_id);
1881 if ($objDefinition->isPluginTypeName(
$type)) {
1882 if ($objDefinition->getClassName(
$type) !=
"") {
1883 $class_name =
"il" . $objDefinition->getClassName(
$type) .
'Plugin';
1885 if (is_file(
$location .
"/class." . $class_name .
".php")) {
1886 return call_user_func(array($class_name,
"_getIcon"),
$type, $size, $obj_id);
1894 return "./images/icon_" .
$type .
".svg";
1908 string $size =
"big",
1910 bool $offline =
false
1912 return self::getIconForReference(0, $obj_id, $size,
$type, $offline);
1917 if ($this->process_auto_reating
1918 && $this->hasAutoRating()
1919 && method_exists($this,
"setRating")
1921 $this->setRating(
true);
1931 if (!
$ref_id || !in_array(
$type, array(
"file",
"lm",
"wiki"))) {
1935 return $this->selfOrParentWithRatingEnabled();
1940 $tree = $this->tree;
1943 if (!$parent_ref_id) {
1946 if ($parent_ref_id) {
1969 $objDefinition =
$DIC[
"objDefinition"];
1970 $tree =
$DIC->repositoryTree();
1973 $deps[
"dep"] = array();
1976 $deps[
"del_ids"][$obj_id] = $obj_id;
1978 if (!$objDefinition->isPluginTypeName(
$type)) {
1979 $class_name =
"ilObj" . $objDefinition->getClassName(
$type);
1980 $odeps = call_user_func(array($class_name,
"getDeletionDependencies"), $obj_id);
1981 if (is_array($odeps)) {
1995 foreach ($deps[
"del_ids"] as $obj_id) {
1996 unset($deps[
"dep"][$obj_id]);
1998 $deps = $deps[
"dep"];
2013 $db =
$DIC->database();
2016 "SELECT obj_id, description" . PHP_EOL
2017 .
"FROM object_description" . PHP_EOL
2018 .
"WHERE " . $db->
in(
"obj_id", $obj_ids,
false,
"integer") . PHP_EOL
2020 $result = $db->
query($sql);
2024 $all[$row[
"obj_id"]] = $row[
"description"];
2033 $db =
$DIC->database();
2034 $obj_definition =
$DIC[
"objDefinition"];
2040 "SELECT od.obj_id, od.type, od.title" . PHP_EOL
2041 .
"FROM object_data od" . PHP_EOL
2042 .
"JOIN object_reference oref ON(oref.obj_id = od.obj_id)" . PHP_EOL
2043 .
"JOIN tree ON (tree.child = oref.ref_id)" . PHP_EOL
2047 $sql .=
"WHERE od.owner = " . $db->
quote($user_id,
"integer") . PHP_EOL;
2050 "LEFT JOIN usr_data ud ON (ud.usr_id = od.owner)" . PHP_EOL
2051 .
"WHERE (od.owner < " . $db->
quote(1,
"integer") . PHP_EOL
2052 .
"OR od.owner IS NULL OR ud.login IS NULL)" . PHP_EOL
2053 .
"AND od.owner <> " . $db->
quote(-1,
"integer") . PHP_EOL
2058 "AND " . $db->
in(
"od.type", $types,
false,
"text") . PHP_EOL
2059 .
"AND tree.tree > " . $db->
quote(0,
"integer") . PHP_EOL
2066 $all[$row[
"type"]][$row[
"obj_id"]] = $row[
"title"];
2078 $db =
$DIC->database();
2080 if (!in_array(
$type, array(
"catr",
"crsr",
"sess",
"grpr",
"prgr"))) {
2085 $missing_obj_ids = array();
2086 foreach ($obj_title_map as $obj_id => $title) {
2087 if (!trim($title)) {
2088 $missing_obj_ids[] = $obj_id;
2092 if (!
sizeof($missing_obj_ids)) {
2102 "SELECT oref.obj_id, od.type, od.title" . PHP_EOL
2103 .
"FROM object_data od" . PHP_EOL
2104 .
"JOIN container_reference oref ON (od.obj_id = oref.target_obj_id)" . PHP_EOL
2105 .
"AND " . $db->
in(
"oref.obj_id", $missing_obj_ids,
false,
"integer") . PHP_EOL
2107 $result = $db->
query($sql);
2110 $obj_title_map[$row[
"obj_id"]] = $row[
"title"];
2114 foreach ($missing_obj_ids as $obj_id) {
2116 $obj_title_map[$obj_id] = $sess->getFirstAppointment()->appointmentToString();
2125 $db =
$DIC->database();
2128 "SELECT create_date" . PHP_EOL
2129 .
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
2130 .
"WHERE obj_id = " . $db->
quote($obj_id,
"integer") . PHP_EOL
2132 $result = $db->
query($sql);
2134 return $rec[
"create_date"];
2147 return $this->obj_definition->getSubObjects($this->type, $filter);
2158 "SELECT obj_id FROM object_data" . PHP_EOL
2159 .
"WHERE type = 'typ'" . PHP_EOL
2160 .
"AND title = " .
$ilDB->quote(
$type,
'text') . PHP_EOL
2169 return (
int) $row[
'obj_id'] ??
null;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _deleteByObjId(int $a_obj_id)
Delete by objekt id.
static _cloneValues(int $copy_id, int $a_source_id, int $a_target_id, ?string $a_sub_type=null, ?int $a_source_sub_id=null, ?int $a_target_sub_id=null)
Clone Advanced Meta Data.
static _deleteSettingsOfBlock(int $a_block_id, string $a_block_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static cloneDependencies(int $a_src_ref_id, int $a_target_ref_id, int $a_copy_id)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static _getInstance(int $a_copy_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static getActionsByTemplateId(int $a_tpl_id)
Get actions of one template.
static deleteByRefId(int $a_ref_id)
static deleteByObjId(int $a_obj_id)
static lookupTemplateId(int $a_ref_id)
static assignTemplate(int $a_ref_id, int $a_obj_id, int $a_tpl_id)
static getInstance()
Get the singleton instance of this ilECSImportManager.
Error Handling & global info handling uses PEAR error class.
static _deleteByObjId(int $a_obj_id)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
A news item can be created by different sources.
static deleteAllEntries(int $ref_id)
Delete all db entries for ref id.
static add(ilObject $object)
parses the objects.xml it handles the xml-description of all ilias objects
isPlugin(string $obj_name)
get RBAC status by type returns true if object type is an (activated) plugin type
isRBACObject(string $obj_name)
get RBAC status by type returns true if object type is a RBAC object type
getSubObjectsRecursively(string $obj_type, bool $include_source_obj=true, bool $add_admin_objects=false)
Get all sub objects by type.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupTxtById(string $plugin_id, string $lang_var)
const AUTO_RATING_NEW_OBJECTS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
setPermissions(int $parent_ref_id)
createReference()
creates reference for object
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
appendCopyInfo(int $target_id, int $copy_id)
Prepend Copy info if object with same name exists in that container.
static _lookupOwnerName(int $owner_id)
Lookup owner name for owner id.
ilRbacReview $rbac_review
cloneMetaData(ilObject $target_obj)
Copy meta data.
static _writeDescription(int $obj_id, string $desc)
write description to db (static)
static _getObjectsByType(string $obj_type="", int $owner=null)
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?
static _getObjectTypeIdByTitle(string $type, \ilDBInterface $ilDB=null)
static _setDeletedDate(int $ref_id, int $deleted_by)
initDefaultRoles()
init default roles settings Purpose of this function is to create a local role folder and local roles...
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
static _getAllReferences(int $id)
get all reference ids for object ID
updateOwner()
update owner of object in db
supportsOfflineHandling()
cloneDependencies(int $target_id, int $copy_id)
Clone object dependencies.
doMDUpdateListener(string $a_element)
static _lookupDeletedDate(int $ref_id)
selfOrParentWithRatingEnabled()
static collectDeletionDependencies(array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
Collect deletion dependencies.
ilAppEventHandler $app_event_handler
static _isInTrash(int $ref_id)
getPossibleSubObjects(bool $filter=true)
get all possible sub objects of this type the object can decide which types of sub objects are possib...
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.
static _writeTitle(int $obj_id, string $title)
write title to db (static)
static _getIdForImportId(string $import_id)
applyDidacticTemplate(int $tpl_id)
static _lookupImportId(int $obj_id)
ilObjectDefinition $obj_definition
static _getIdsForTitle(string $title, string $type='', bool $partial_match=false)
isTitleUnique(string $title, array $nodes)
getLastUpdateDate()
Get last update date in YYYY-MM-DD HH-MM-SS format.
bool $process_auto_reating
static _prepareCloneSelection(array $ref_ids, string $new_type, bool $show_path=true)
Prepare copy wizard object selection.
static getDeletionDependencies(int $obj_id)
Get deletion dependencies.
static setDeletedDates(array $ref_ids, int $user_id)
setImportId(string $import_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getLastUpdateOfObjects(array $obj_ids)
static _lookupLastUpdate(int $obj_id, bool $formatted=false)
getOwnerName()
get full name of object owner
__construct(int $id=0, bool $reference=true)
withReferences()
determines whether objects are referenced or not (got ref ids or not)
getLongDescription()
get object long description (stored in object_description)
string $untranslatedTitle
static _writeImportId(int $obj_id, string $import_id)
write import id to db (static)
static getAllOwnedRepositoryObjects(int $user_id)
setOfflineStatus(bool $status)
create()
note: title, description and type should be set when this function is called
static _lookupCreationDate(int $obj_id)
getUntranslatedTitle()
Get untranslated object title WebDAV needs to access the untranslated title of an object.
getCallbackForTitlesPerLanguageTransformation()
appendCopyInfoToTranslations(ilObjectTranslation $obj_translations, array $other_children_of_same_type)
static _getObjectsDataForType(string $type, bool $omit_trash=false)
get all objects of a certain type
appendNumberOfCopiesToTitle(string $copy_suffix, string $copy_n_suffix, string $title, array $other_titles_for_lang)
beforeMDUpdateListener(string $a_element)
static _resetDeletedDate(int $ref_id)
static getLongDescriptions(array $obj_ids)
static _lookupObjId(int $ref_id)
MDUpdateListener(string $element)
Metadata update listener.
setParentRolePermissions(int $parent_ref_id)
Initialize the permissions of parent roles (local roles of categories, global roles....
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
buildTitleWithoutCopySuffix(string $copy_suffix, string $copy_n_suffix, string $title)
getCreateDate()
Get create date in YYYY-MM-DD HH-MM-SS format.
static fixMissingTitles($type, array &$obj_title_map)
Try to fix missing object titles.
setDescription(string $desc)
getPresentationTitle()
get presentation title Normally same as title Overwritten for sessions
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
Class ilRbacAdmin Core functions for role based access control.
copyLocalRoles(int $a_source_id, int $a_target_id)
Copy local roles This method creates a copy of all local role.
revokePermission(int $a_ref_id, int $a_rol_id=0, bool $a_keep_protected=true)
Revokes permissions of an object of one role.
static delete(int $a_ref_id)
class ilRbacReview Contains Review functions of core Rbac.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
static subStr(string $a_str, int $a_start, ?int $a_length=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
update(string $table_name, array $values, array $where)
@description $where MUST contain existing columns only.
insert(string $table_name, array $values)
fetchObject(ilDBStatement $query_result)
setLimit(int $limit, int $offset=0)
like(string $column, string $type, string $value="?", bool $case_insensitive=true)
Generate a like subquery.
numRows(ilDBStatement $statement)
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
in(string $field, array $values, bool $negate=false, string $type="")
Class ChatMainBarProvider \MainMenu\Provider.
header include for all ilias files.