ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 Class ilInternalLink Some methods to handle internal links

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Deprecated:
10 This component will be removed with ILIAS 10

Definition at line 25 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 30 of file class.ilInternalLink.php.

References $DIC, $ilDB, and $q.

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

34  : void {
35  global $DIC;
36 
37  $ilDB = $DIC->database();
38 
39  $lang_where = "";
40  if ($a_lang !== "") {
41  $lang_where = " AND source_lang = " . $ilDB->quote($a_lang, "text");
42  }
43 
44  $q = "DELETE FROM int_link WHERE source_type = " .
45  $ilDB->quote($a_source_type, "text") . " AND source_id=" .
46  $ilDB->quote($a_source_id, "integer") .
47  $lang_where;
48  $ilDB->manipulate($q);
49  }
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23
+ 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 54 of file class.ilInternalLink.php.

References $DIC, and $ilDB.

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

58  : void {
59  global $DIC;
60 
61  $ilDB = $DIC->database();
62 
63  $ilDB->manipulateF(
64  "DELETE FROM int_link WHERE target_type = %s " .
65  " AND target_id = %s AND target_inst = %s ",
66  array("text", "integer", "integer"),
67  array($a_target_type, $a_target_id, $a_target_inst)
68  );
69  }
global $DIC
Definition: shib_login.php:26
+ 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 265 of file class.ilInternalLink.php.

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

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

268  : bool {
269  global $DIC;
270 
271  $tree = $DIC->repositoryTree();
272 
273  switch ($a_type) {
274  case "PageObject":
275  case "StructureObject":
276  return ilLMObject::_exists($a_target);
277 
278  case "GlossaryItem":
279  return ilGlossaryTerm::_exists($a_target);
280 
281  case "MediaObject":
282  return ilObjMediaObject::_exists($a_target);
283 
284  case "WikiPage":
285  return ilWikiPage::_exists("wiki", (int) $a_target);
286 
287  case "RepositoryItem":
288  if (is_int(strpos($a_target, "_"))) {
289  $ref_id = self::_extractObjIdOfTarget($a_target);
290  return $tree->isInTree($ref_id);
291  }
292  break;
293  }
294  return false;
295  }
static _exists(int $a_id)
checks whether a glossary term with specified id exists or not
$ref_id
Definition: ltiauth.php:65
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
global $DIC
Definition: shib_login.php:26
static _exists(int $id, bool $reference=false, ?string $type=null)
static _exists(int $a_id)
checks wether a lm content object with specified id exists or not
+ 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 302 of file class.ilInternalLink.php.

References null.

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

302  : ?int
303  {
304  if (!is_int(strpos($a_target, "__"))) {
305  $target = explode("_", $a_target);
306  if (isset($target[1]) && $target[1] > 0) {
307  return (int) $target[1];
308  }
309  }
310  return null;
311  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ _extractObjIdOfTarget()

◆ _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 342 of file class.ilInternalLink.php.

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

342  : string
343  {
344  $target = explode("_", $a_target);
345  return (string) ($target[count($target) - 2] ?? "");
346  }
+ 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 175 of file class.ilInternalLink.php.

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

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

178  : ?string {
179  switch ($a_type) {
180  case "PageObject":
181  $id = ilLMObject::_getIdForImportId($a_target);
182  if ($id > 0) {
183  return "il__pg_" . $id;
184  }
185  break;
186 
187  case "StructureObject":
188  $id = ilLMObject::_getIdForImportId($a_target);
189  if ($id > 0) {
190  return "il__st_" . $id;
191  }
192  break;
193 
194  case "GlossaryItem":
196  //echo "+".$id."+".$a_target."+";
197  if ($id > 0) {
198  return "il__git_" . $id;
199  }
200  break;
201 
202  case "WikiPage":
203  // no import IDs for wiki pages (yet)
204  //$id = ilGlossaryTerm::_getIdForImportId($a_target);
205  $id = 0;
206  /*
207  if ($id > 0) {
208  return "il__wpage_" . $id;
209  }*/
210  break;
211 
212  case "MediaObject":
214  if ($id > 0) {
215  return "il__mob_" . $id;
216  }
217  break;
218 
219  case "RepositoryItem":
220 
221  $tarr = explode("_", $a_target);
222  $import_id = $a_target;
223 
224  // if a ref id part is given, strip this
225  // since this will not be part of an import id
226  // see also bug #6685
227  if (($tarr[4] ?? "") != "") {
228  $import_id = $tarr[0] . "_" . $tarr[1] . "_" . $tarr[2] . "_" . $tarr[3];
229  }
230 
231  $id = ilObject::_getIdForImportId($import_id);
232 
233  // get ref id for object id
234  // (see ilPageObject::insertInstIntoIDs for the export procedure)
235  if ($id > 0) {
237  foreach ($refs as $ref) {
238  return "il__obj_" . $ref;
239  }
240  }
241 
242  // 26 Sep 2018: moved this under the import id handling above
243  // If an imported object is found, this is always preferred.
244  // see also bug #23324
245  if (self::_extractInstOfTarget($a_target) == IL_INST_ID
246  && IL_INST_ID > 0) {
247  // does it have a ref id part?
248  if (($tarr[4] ?? "") != "") {
249  return "il__obj_" . $tarr[4];
250  }
251  }
252 
253  break;
254  }
255  return null;
256  }
const IL_INST_ID
Definition: constants.php:40
static _getIdForImportId(string $a_import_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _getIdForImportId(string $import_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getIdForImportId(string $a_import_id)
get current object id for import id (static)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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 107 of file class.ilInternalLink.php.

References $DIC, $ilDB, and $q.

Referenced by ilMobStakeholder\checkAccessGlossaryTerm(), ilObjMediaObjectAccess\checkAccessGlossaryTerm(), ILIAS\Wiki\Links\LinkManager\getLinksToPage(), ilWikiPage\getLinksToPage(), ILIAS\Wiki\Page\PageManager\getOrphanedPages(), ilGlossaryTerm\getUsages(), ilGlossaryPresentationGUI\listDefinitions(), ilQuestionPageParser\processPagesToParse(), ilWikiPage\rename(), and ilLMObject\updateInternalLinks().

111  : array {
112  global $DIC;
113 
114  $ilDB = $DIC->database();
115 
116  $q = "SELECT * FROM int_link WHERE " .
117  "target_type = " . $ilDB->quote($a_target_type, "text") . " AND " .
118  "target_id = " . $ilDB->quote($a_target_id, "integer") . " AND " .
119  "target_inst = " . $ilDB->quote($a_target_inst, "integer");
120  $source_set = $ilDB->query($q);
121  $sources = array();
122  while ($source_rec = $ilDB->fetchAssoc($source_set)) {
123  $sources[$source_rec["source_type"] . ":" . $source_rec["source_id"] . ":" . $source_rec["source_lang"]] =
124  array("type" => $source_rec["source_type"], "id" => $source_rec["source_id"],
125  "lang" => $source_rec["source_lang"]);
126  }
127 
128  return $sources;
129  }
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23
+ 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 138 of file class.ilInternalLink.php.

References $DIC, $ilDB, and $q.

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

142  : array {
143  global $DIC;
144 
145  $ilDB = $DIC->database();
146 
147  $lang_where = "";
148  if ($a_source_lang !== "") {
149  $lang_where = " AND source_lang = " . $ilDB->quote($a_source_lang, "text");
150  }
151 
152  $q = "SELECT * FROM int_link WHERE " .
153  "source_type = " . $ilDB->quote($a_source_type, "text") . " AND " .
154  "source_id = " . $ilDB->quote($a_source_id, "integer") .
155  $lang_where;
156 
157  $target_set = $ilDB->query($q);
158  $targets = array();
159  while ($target_rec = $ilDB->fetchAssoc($target_set)) {
160  $targets[$target_rec["target_type"] . ":" . $target_rec["target_id"] . ":" . $target_rec["target_inst"]] =
161  array("type" => $target_rec["target_type"], "id" => $target_rec["target_id"],
162  "inst" => $target_rec["target_inst"]);
163  }
164 
165  return $targets;
166  }
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23
+ 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 317 of file class.ilInternalLink.php.

References null.

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

317  : ?string
318  {
319  if (!is_int(strpos($a_target, "__"))) {
320  $target = explode("_", $a_target);
321  if ($target[1] > 0) {
322  return "il__" . $target[2] . "_" . $target[3];
323  }
324  }
325  return null;
326  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 74 of file class.ilInternalLink.php.

References $DIC, and $ilDB.

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

81  : void {
82  global $DIC;
83 
84  $ilDB = $DIC->database();
85 
86  $ilDB->replace(
87  "int_link",
88  array(
89  "source_type" => array("text", $a_source_type),
90  "source_id" => array("integer", $a_source_id),
91  "source_lang" => array("text", $a_source_lang),
92  "target_type" => array("text", $a_target_type),
93  "target_id" => array("integer", $a_target_id),
94  "target_inst" => array("integer", $a_target_inst)
95  ),
96  array()
97  );
98  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ searchUsers()

static ilInternalLink::searchUsers ( string  $a_search_str)
static

Search users.

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

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

Referenced by ilInternalLinkGUI\getUserSearchResult().

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