ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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

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

References $DIC, and $ilDB.

Referenced by SurveyQuestion\_resolveIntLinks(), assQuestion\_resolveIntLinks(), SurveyQuestion\delete(), ilPageObject\deleteInternalLinks(), assQuestion\deleteSuggestedSolutions(), SurveyQuestion\saveMaterial(), SurveyQuestion\syncWithOriginal(), and assQuestion\updateSuggestedSolutions().

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

References $DIC, and $ilDB.

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

57  : void {
58  global $DIC;
59 
60  $ilDB = $DIC->database();
61 
62  $ilDB->manipulateF(
63  "DELETE FROM int_link WHERE target_type = %s " .
64  " AND target_id = %s AND target_inst = %s ",
65  array("text", "integer", "integer"),
66  array($a_target_type, $a_target_id, $a_target_inst)
67  );
68  }
global $DIC
Definition: feed.php:28
+ 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 ilPageObject\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((int) $a_target);
277 
278  case "GlossaryItem":
279  return ilGlossaryTerm::_exists((int) $a_target);
280 
281  case "MediaObject":
282  return ilObjMediaObject::_exists((int) $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
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
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.

Referenced by ilPageObject\_handleImportRepositoryLinks(), ilPCQuestion\afterPageUpdate(), ilPCQuestionGUI\edit(), ilQuestionExporter\exportQuestion(), ilPCQuestionGUI\feedback(), ilPageObject\getQuestionIds(), ilPageObject\newIIMCopies(), ilPageObject\newMobCopies(), ilPageObject\newQuestionCopies(), ilPageObject\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  }
+ 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 174 of file class.ilInternalLink.php.

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

Referenced by SurveyQuestion\_resolveInternalLink(), assQuestion\_resolveInternalLink(), ilMapArea\_resolveIntLinks(), and ilPageObject\resolveIntLinks().

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

References $DIC, and $ilDB.

Referenced by ilPageObject\_handleImportRepositoryLinks(), ilObjMediaObjectAccess\checkAccessGlossaryTerm(), ilWikiPage\getLinksToPage(), ilWikiPage\getOrphanedPages(), ilGlossaryTerm\getUsages(), ilGlossaryPresentationGUI\listDefinitions(), ilQuestionPageParser\processPagesToParse(), ilWikiPage\rename(), and ilLMObject\updateInternalLinks().

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

References $DIC, and $ilDB.

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

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

Referenced by ilPageObject\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  }
+ 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 73 of file class.ilInternalLink.php.

References $DIC, and $ilDB.

Referenced by SurveyQuestion\_resolveIntLinks(), assQuestion\_resolveIntLinks(), ilWikiPage\saveInternalLinks(), ilPageObject\saveInternalLinks(), SurveyQuestion\saveMaterial(), SurveyQuestion\syncWithOriginal(), and assQuestion\updateSuggestedSolutions().

80  : void {
81  global $DIC;
82 
83  $ilDB = $DIC->database();
84 
85  $ilDB->replace(
86  "int_link",
87  array(
88  "source_type" => array("text", $a_source_type),
89  "source_id" => array("integer", $a_source_id),
90  "source_lang" => array("text", $a_source_lang),
91  "target_type" => array("text", $a_target_type),
92  "target_id" => array("integer", $a_target_id),
93  "target_inst" => array("integer", $a_target_inst)
94  ),
95  array()
96  );
97  }
global $DIC
Definition: feed.php:28
+ 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)
+ 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: