ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilInternalLink Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilInternalLink:

Static Public Member Functions

static _deleteAllLinksOfSource (string $a_source_type, int $a_source_id, string $a_lang="-")
 Delete all links of a given source. More...
 
static _deleteAllLinksToTarget (string $a_target_type, int $a_target_id, int $a_target_inst=0)
 Delete all links to a given target. More...
 
static _saveLink (string $a_source_type, int $a_source_id, string $a_target_type, int $a_target_id, int $a_target_inst=0, string $a_source_lang="-")
 save internal link information More...
 
static _getSourcesOfTarget (string $a_target_type, int $a_target_id, int $a_target_inst)
 get all sources of a link target More...
 
static _getTargetsOfSource (string $a_source_type, int $a_source_id, string $a_source_lang="-")
 Get all targets of a source object (e.g., a page) More...
 
static _getIdForImportId (string $a_type, string $a_target)
 Get current id for an import id. More...
 
static _exists (string $a_type, string $a_target)
 Check if internal link refers to a valid target. More...
 
static _extractInstOfTarget (string $a_target)
 Extract installation id out of target. More...
 
static _removeInstFromTarget (string $a_target)
 Removes installation id from target string. More...
 
static _extractObjIdOfTarget (string $a_target)
 Extract object id out of target. More...
 
static _extractTypeOfTarget (string $a_target)
 Extract type out of target. More...
 
static searchUsers (string $a_search_str)
 Search users. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 of file class.ilInternalLink.php.

Member Function Documentation

◆ _deleteAllLinksOfSource()

static ilInternalLink::_deleteAllLinksOfSource ( string  $a_source_type,
int  $a_source_id,
string  $a_lang = "-" 
)
static

Delete all links of a given source.

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

28 : void {
29 global $DIC;
30
31 $ilDB = $DIC->database();
32
33 $lang_where = "";
34 if ($a_lang !== "") {
35 $lang_where = " AND source_lang = " . $ilDB->quote($a_lang, "text");
36 }
37
38 $q = "DELETE FROM int_link WHERE source_type = " .
39 $ilDB->quote($a_source_type, "text") . " AND source_id=" .
40 $ilDB->quote($a_source_id, "integer") .
41 $lang_where;
42 $ilDB->manipulate($q);
43 }
global $DIC
Definition: shib_login.php:26

References $ilDB.

Referenced by ILIAS\TestQuestionPool\Questions\SuggestedSolution\SuggestedSolutionsDatabaseRepository\additionalOnDelete(), SurveyQuestion\delete(), assQuestion\deleteSuggestedSolutions(), assQuestion\resolveSuggestedSolutionLinks(), and SurveyQuestion\syncWithOriginal().

+ Here is the caller graph for this function:

◆ _deleteAllLinksToTarget()

static ilInternalLink::_deleteAllLinksToTarget ( string  $a_target_type,
int  $a_target_id,
int  $a_target_inst = 0 
)
static

Delete all links to a given target.

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

52 : void {
53 global $DIC;
54
55 $ilDB = $DIC->database();
56
57 $ilDB->manipulateF(
58 "DELETE FROM int_link WHERE target_type = %s " .
59 " AND target_id = %s AND target_inst = %s ",
60 array("text", "integer", "integer"),
61 array($a_target_type, $a_target_id, $a_target_inst)
62 );
63 }

Referenced by ilPortfolioPage\delete(), and ilWikiPage\delete().

+ Here is the caller graph for this function:

◆ _exists()

static ilInternalLink::_exists ( string  $a_type,
string  $a_target 
)
static

Check if internal link refers to a valid target.

Parameters
string$a_typetarget type ("PageObject" | "StructureObject" | "GlossaryItem" | "MediaObject")
string$a_targettarget id, e.g. "il__pg_244")
Returns
bool true/false

Definition at line 259 of file class.ilInternalLink.php.

262 : bool {
263 global $DIC;
264
265 $tree = $DIC->repositoryTree();
266
267 switch ($a_type) {
268 case "PageObject":
269 case "StructureObject":
270 return ilLMObject::_exists((int) $a_target);
271
272 case "GlossaryItem":
273 return ilGlossaryTerm::_exists((int) $a_target);
274
275 case "MediaObject":
276 return ilObjMediaObject::_exists((int) $a_target);
277
278 case "WikiPage":
279 return ilWikiPage::_exists("wiki", (int) $a_target);
280
281 case "RepositoryItem":
282 if (is_int(strpos($a_target, "_"))) {
283 $ref_id = self::_extractObjIdOfTarget($a_target);
284 return $tree->isInTree($ref_id);
285 }
286 break;
287 }
288 return false;
289 }
static _exists(int $a_id)
checks whether a glossary term with specified id exists or not
static _exists(int $a_id)
checks wether a lm content object with specified id exists or not
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.

References ilGlossaryTerm\_exists(), ilLMObject\_exists(), ilObjMediaObject\_exists(), and ilPageObject\_exists().

Referenced by ILIAS\COPage\Link\LinkManager\resolveIntLinks().

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

◆ _extractInstOfTarget()

static ilInternalLink::_extractInstOfTarget ( string  $a_target)
static

Extract installation id out of target.

Parameters
string$a_targetimport target id (e.g. "il_2_pg_22")

Definition at line 296 of file class.ilInternalLink.php.

296 : ?int
297 {
298 if (!is_int(strpos($a_target, "__"))) {
299 $target = explode("_", $a_target);
300 if (isset($target[1]) && $target[1] > 0) {
301 return (int) $target[1];
302 }
303 }
304 return null;
305 }

References ILIAS\Scripts\PHPStan\$target.

Referenced by ilPCQuestionGUI\edit(), ilQuestionExporter\exportQuestion(), ilPCQuestionGUI\feedback(), ilPCQuestion\getQuestionIds(), ilPCInteractiveImage\handleCopiedContent(), ilPCQuestion\handleCopiedContent(), ILIAS\COPage\Link\LinkManager\resolveIntLinks(), ilPCQuestionGUI\setTabs(), ilPortfolioPage\updateInternalLinks(), and ilLMObject\updateInternalLinks().

+ Here is the caller graph for this function:

◆ _extractObjIdOfTarget()

static ilInternalLink::_extractObjIdOfTarget ( string  $a_target)
static

◆ _extractTypeOfTarget()

static ilInternalLink::_extractTypeOfTarget ( string  $a_target)
static

Extract type out of target.

Parameters
string$a_targetimport target id (e.g. "il_2_pg_22")

Definition at line 336 of file class.ilInternalLink.php.

336 : string
337 {
338 $target = explode("_", $a_target);
339 return (string) ($target[count($target) - 2] ?? "");
340 }

References ILIAS\Scripts\PHPStan\$target.

Referenced by ilPortfolioPage\updateInternalLinks(), and ilLMObject\updateInternalLinks().

+ Here is the caller graph for this function:

◆ _getIdForImportId()

static ilInternalLink::_getIdForImportId ( string  $a_type,
string  $a_target 
)
static

Get current id for an import id.

Parameters
string$a_typetarget type ("PageObject" | "StructureObject" | "GlossaryItem" | "MediaObject")
string$a_targetimport target id (e.g. "il_2_pg_22")
Returns
string current target id (e.g. "il__pg_244")

Definition at line 169 of file class.ilInternalLink.php.

172 : ?string {
173 global $DIC;
174 $wiki_import_resolver = $DIC->wiki()->internal()->domain()->page()->importResolver();
175
176 switch ($a_type) {
177 case "PageObject":
179 if ($id > 0) {
180 return "il__pg_" . $id;
181 }
182 break;
183
184 case "StructureObject":
186 if ($id > 0) {
187 return "il__st_" . $id;
188 }
189 break;
190
191 case "GlossaryItem":
193 //echo "+".$id."+".$a_target."+";
194 if ($id > 0) {
195 return "il__git_" . $id;
196 }
197 break;
198
199 case "WikiPage":
200 $id = $wiki_import_resolver->getIdForImportId($a_target);
201 if ($id > 0) {
202 return "il__wpage_" . $id;
203 }
204 break;
205
206 case "MediaObject":
208 if ($id > 0) {
209 return "il__mob_" . $id;
210 }
211 break;
212
213 case "RepositoryItem":
214
215 $tarr = explode("_", $a_target);
216 $import_id = $a_target;
217
218 // if a ref id part is given, strip this
219 // since this will not be part of an import id
220 // see also bug #6685
221 if (($tarr[4] ?? "") != "") {
222 $import_id = $tarr[0] . "_" . $tarr[1] . "_" . $tarr[2] . "_" . $tarr[3];
223 }
224
225 $id = ilObject::_getIdForImportId($import_id);
226
227 // get ref id for object id
228 // (see ilPageObject::insertInstIntoIDs for the export procedure)
229 if ($id > 0) {
231 foreach ($refs as $ref) {
232 return "il__obj_" . $ref;
233 }
234 }
235
236 // 26 Sep 2018: moved this under the import id handling above
237 // If an imported object is found, this is always preferred.
238 // see also bug #23324
239 if (self::_extractInstOfTarget($a_target) == IL_INST_ID
240 && IL_INST_ID > 0) {
241 // does it have a ref id part?
242 if (($tarr[4] ?? "") != "") {
243 return "il__obj_" . $tarr[4];
244 }
245 }
246
247 break;
248 }
249 return null;
250 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getIdForImportId(string $a_import_id)
static _getIdForImportId(string $a_import_id)
get current object id for import id (static)
static _getAllReferences(int $id)
get all reference ids for object ID
static _getIdForImportId(string $import_id)
const IL_INST_ID
Definition: constants.php:40

References $id, ilObject\_getAllReferences(), ilGlossaryTerm\_getIdForImportId(), ilLMObject\_getIdForImportId(), ilObject\_getIdForImportId(), and IL_INST_ID.

Referenced by SurveyQuestion\_resolveInternalLink(), ilMapArea\_resolveIntLinks(), assQuestion\resolveInternalLink(), and ILIAS\COPage\Link\LinkManager\resolveIntLinks().

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

◆ _getSourcesOfTarget()

static ilInternalLink::_getSourcesOfTarget ( string  $a_target_type,
int  $a_target_id,
int  $a_target_inst 
)
static

get all sources of a link target

Parameters
string$a_target_typetarget type
int$a_target_idtarget id
int$a_target_insttarget installation id
Returns
array sources (array of array("type", "id"))

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

105 : array {
106 global $DIC;
107
108 $ilDB = $DIC->database();
109
110 $q = "SELECT * FROM int_link WHERE " .
111 "target_type = " . $ilDB->quote($a_target_type, "text") . " AND " .
112 "target_id = " . $ilDB->quote($a_target_id, "integer") . " AND " .
113 "target_inst = " . $ilDB->quote($a_target_inst, "integer");
114 $source_set = $ilDB->query($q);
115 $sources = array();
116 while ($source_rec = $ilDB->fetchAssoc($source_set)) {
117 $sources[$source_rec["source_type"] . ":" . $source_rec["source_id"] . ":" . $source_rec["source_lang"]] =
118 array("type" => $source_rec["source_type"], "id" => $source_rec["source_id"],
119 "lang" => $source_rec["source_lang"]);
120 }
121
122 return $sources;
123 }

Referenced by ILIAS\Wiki\Page\PageManager\getOrphanedPages(), ilGlossaryTerm\getUsages(), ilQuestionPageParser\processPagesToParse(), and ilLMObject\updateInternalLinks().

+ Here is the caller graph for this function:

◆ _getTargetsOfSource()

static ilInternalLink::_getTargetsOfSource ( string  $a_source_type,
int  $a_source_id,
string  $a_source_lang = "-" 
)
static

Get all targets of a source object (e.g., a page)

Parameters
string$a_source_typesource type (e.g. "lm:pg" | "dbk:pg")
int$a_source_idsource id
string$a_source_langsource language
Returns
array targets (array of array("type", "id", "inst"))

Definition at line 132 of file class.ilInternalLink.php.

136 : array {
137 global $DIC;
138
139 $ilDB = $DIC->database();
140
141 $lang_where = "";
142 if ($a_source_lang !== "") {
143 $lang_where = " AND source_lang = " . $ilDB->quote($a_source_lang, "text");
144 }
145
146 $q = "SELECT * FROM int_link WHERE " .
147 "source_type = " . $ilDB->quote($a_source_type, "text") . " AND " .
148 "source_id = " . $ilDB->quote($a_source_id, "integer") .
149 $lang_where;
150
151 $target_set = $ilDB->query($q);
152 $targets = array();
153 while ($target_rec = $ilDB->fetchAssoc($target_set)) {
154 $targets[$target_rec["target_type"] . ":" . $target_rec["target_id"] . ":" . $target_rec["target_inst"]] =
155 array("type" => $target_rec["target_type"], "id" => $target_rec["target_id"],
156 "inst" => $target_rec["target_inst"]);
157 }
158
159 return $targets;
160 }

References $ilDB.

Referenced by ilPageObjectGUI\showPage(), ilLMPresentationGUI\showPrintView(), and ilObjWiki\updateInternalLinksOnCopy().

+ Here is the caller graph for this function:

◆ _removeInstFromTarget()

static ilInternalLink::_removeInstFromTarget ( string  $a_target)
static

Removes installation id from target string.

Parameters
string$a_targetimport target id (e.g. "il_2_pg_22")

Definition at line 311 of file class.ilInternalLink.php.

311 : ?string
312 {
313 if (!is_int(strpos($a_target, "__"))) {
314 $target = explode("_", $a_target);
315 if ($target[1] > 0) {
316 return "il__" . $target[2] . "_" . $target[3];
317 }
318 }
319 return null;
320 }

References ILIAS\Scripts\PHPStan\$target.

Referenced by ILIAS\COPage\Link\LinkManager\resolveIntLinks().

+ Here is the caller graph for this function:

◆ _saveLink()

static ilInternalLink::_saveLink ( string  $a_source_type,
int  $a_source_id,
string  $a_target_type,
int  $a_target_id,
int  $a_target_inst = 0,
string  $a_source_lang = "-" 
)
static

save internal link information

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

75 : void {
76 global $DIC;
77
78 $ilDB = $DIC->database();
79
80 $ilDB->replace(
81 "int_link",
82 array(
83 "source_type" => array("text", $a_source_type),
84 "source_id" => array("integer", $a_source_id),
85 "source_lang" => array("text", $a_source_lang),
86 "target_type" => array("text", $a_target_type),
87 "target_id" => array("integer", $a_target_id),
88 "target_inst" => array("integer", $a_target_inst)
89 ),
90 array()
91 );
92 }

Referenced by ILIAS\TestQuestionPool\Questions\SuggestedSolution\SuggestedSolutionsDatabaseRepository\additionalOnStore(), assQuestion\resolveSuggestedSolutionLinks(), ILIAS\Wiki\Links\LinkManager\saveInternalLinksForPage(), and SurveyQuestion\syncWithOriginal().

+ Here is the caller graph for this function:

◆ searchUsers()

static ilInternalLink::searchUsers ( string  $a_search_str)
static

Search users.

Definition at line 345 of file class.ilInternalLink.php.

345 : array
346 {
347 $result = new ilSearchResult();
348
349 $query_parser = new ilQueryParser($a_search_str);
350 $query_parser->setCombination(ilQueryParser::QP_COMBINATION_AND);
351 $query_parser->setMinWordLength(3);
352 $query_parser->parse();
353
354 $user_search = ilObjectSearchFactory::_getUserSearchInstance($query_parser);
355 $user_search->enableActiveCheck(true);
356 $user_search->setFields(array('login'));
357 $result_obj = $user_search->performSearch();
358 $result->mergeEntries($result_obj);
359
360 $user_search->setFields(array('firstname'));
361 $result_obj = $user_search->performSearch();
362 $result->mergeEntries($result_obj);
363
364 $user_search->setFields(array('lastname'));
365 $result_obj = $user_search->performSearch();
366 $result->mergeEntries($result_obj);
367
368 $result->setMaxHits(100000);
369 $result->preventOverwritingMaxhits(true);
370 $result->filter(ROOT_FOLDER_ID, true);
371
372 // Filter users (depends on setting in user accounts)
373 $users = ilUserFilter::getInstance()->filter($result->getResultIds());
374
376
377 $users = array_intersect($users, $p["public"]);
378
379 return $users;
380 }
static getProfileStatusOfUsers(array $a_user_ids)
static _getUserSearchInstance(ilQueryParser $query_parser)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ROOT_FOLDER_ID
Definition: constants.php:32

References ilObjectSearchFactory\_getUserSearchInstance(), ilUserFilter\getInstance(), ilObjUser\getProfileStatusOfUsers(), ilQueryParser\QP_COMBINATION_AND, and ROOT_FOLDER_ID.

Referenced by ilInternalLinkGUI\getUserSearchResult().

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

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