ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilInternalLink Class Reference

Class ilInternalLink. More...

+ Collaboration diagram for ilInternalLink:

Static Public Member Functions

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

Detailed Description

Class ilInternalLink.

Some methods to handle internal links

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ _deleteAllLinksOfSource()

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

Delete all links of a given source.

Parameters
string$a_source_typesource type
int$a_source_ifsource id
int$a_langsource language

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

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

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ _deleteAllLinksToTarget()

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

Delete all links to a given target.

Parameters
string$a_target_typetarget type
int$a_target_idtarget id
int$a_target_insttarget installation id

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

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

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ _exists()

static ilInternalLink::_exists (   $a_type,
  $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
boolean true/false

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

264 {
265 global $DIC;
266
267 $tree = $DIC->repositoryTree();
268
269 switch ($a_type) {
270 case "PageObject":
271 case "StructureObject":
272 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
273 return ilLMObject::_exists($a_target);
274 break;
275
276 case "GlossaryItem":
277 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
278 return ilGlossaryTerm::_exists($a_target);
279 break;
280
281 case "MediaObject":
282 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
283 return ilObjMediaObject::_exists($a_target);
284 break;
285
286 case "WikiPage":
287 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
288 return ilWikiPage::_exists("wiki", (int) $a_target);
289 break;
290
291 case "RepositoryItem":
292 if (is_int(strpos($a_target, "_"))) {
293 $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target);
294 return $tree->isInTree($ref_id);
295 }
296 break;
297 }
298 return false;
299 }
static _exists($a_id)
checks wether a glossary term with specified id exists or not
static _exists($a_id)
checks wether a lm content object with specified id exists or not
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
$a_type
Definition: workflow.php:92

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

Referenced by ilPageObject\resolveIntLinks().

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

◆ _extractInstOfTarget()

static ilInternalLink::_extractInstOfTarget (   $a_target)
static

Extract installation id out of target.

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

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

308 {
309 if (!is_int(strpos($a_target, "__"))) {
310 $target = explode("_", $a_target);
311 if ($target[1] > 0) {
312 return $target[1];
313 }
314 }
315 return false;
316 }

References $target.

Referenced by _getIdForImportId(), ilPageObject\_handleImportRepositoryLinks(), ilPCQuestion\afterPageUpdate(), ilPCQuestionGUI\edit(), ilQuestionExporter\exportQuestion(), ilPCQuestionGUI\feedback(), ilPageObject\getQuestionIds(), ilPageObject\newIIMCopies(), ilPageObject\newMobCopies(), ilPageObject\newQuestionCopies(), ilPageObject\resolveIntLinks(), ilPCQuestionGUI\setTabs(), ilLMObject\updateInternalLinks(), and ilPortfolioPage\updateInternalLinks().

+ Here is the caller graph for this function:

◆ _extractObjIdOfTarget()

◆ _extractTypeOfTarget()

static ilInternalLink::_extractTypeOfTarget (   $a_target)
static

Extract type out of target.

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

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

351 {
352 $target = explode("_", $a_target);
353 return $target[count($target) - 2];
354 }

References $target.

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

+ Here is the caller graph for this function:

◆ _getIdForImportId()

static ilInternalLink::_getIdForImportId (   $a_type,
  $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 171 of file class.ilInternalLink.php.

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

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

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

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

◆ _getSourcesOfTarget()

static ilInternalLink::_getSourcesOfTarget (   $a_target_type,
  $a_target_id,
  $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.

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

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ _getTargetsOfSource()

static ilInternalLink::_getTargetsOfSource (   $a_source_type,
  $a_source_id,
  $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
Returns
array targets (array of array("type", "id", "inst"))

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

136 {
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((int) $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 $DIC, and $ilDB.

Referenced by ilObjContentObject\exportHTMLPages(), ilSCORM2004Asset\getGlossaryTermIds(), ilPageObjectGUI\showPage(), and ilLMPresentationGUI\showPrintView().

+ Here is the caller graph for this function:

◆ _removeInstFromTarget()

static ilInternalLink::_removeInstFromTarget (   $a_target)
static

Removes installation id from target string.

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

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

324 {
325 if (!is_int(strpos($a_target, "__"))) {
326 $target = explode("_", $a_target);
327 if ($target[1] > 0) {
328 return "il__" . $target[2] . "_" . $target[3];
329 }
330 }
331 return false;
332 }

References $target.

Referenced by ilPageObject\resolveIntLinks().

+ Here is the caller graph for this function:

◆ _saveLink()

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

save internal link information

Parameters
string$a_source_typesource type
int$a_source_ifsource id
string$a_target_typetarget type
int$a_target_idtarget id
int$a_target_insttarget installation id

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

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

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ searchUsers()

static ilInternalLink::searchUsers (   $a_search_str)
static

Search users.

Parameters

return

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

363 {
364 $result = new ilSearchResult();
365
366 $query_parser = new ilQueryParser($a_search_str, '%_');
367 $query_parser->setCombination(QP_COMBINATION_AND);
368 $query_parser->setMinWordLength(3);
369 $query_parser->parse();
370
371 $user_search = ilObjectSearchFactory::_getUserSearchInstance($query_parser);
372 $user_search->enableActiveCheck(true);
373 $user_search->setFields(array('login'));
374 $result_obj = $user_search->performSearch();
375 $result->mergeEntries($result_obj);
376
377 $user_search->setFields(array('firstname'));
378 $result_obj = $user_search->performSearch();
379 $result->mergeEntries($result_obj);
380
381 $user_search->setFields(array('lastname'));
382 $result_obj = $user_search->performSearch();
383 $result->mergeEntries($result_obj);
384
385 $result->setMaxHits(100000);
386 $result->preventOverwritingMaxhits(true);
387 $result->filter(ROOT_FOLDER_ID, true);
388
389 // Filter users (depends on setting in user accounts)
390 include_once 'Services/User/classes/class.ilUserFilter.php';
391 $users = ilUserFilter::getInstance()->filter($result->getResultIds());
392
393 include_once("./Services/User/classes/class.ilObjUser.php");
395
396 $users = array_intersect($users, $p["public"]);
397
398 return $users;
399 }
$result
$users
Definition: authpage.php:44
const QP_COMBINATION_AND
static getProfileStatusOfUsers($a_user_ids)
Get profile status.
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
static getInstance()
Singelton get instance.

References $result, $users, ilObjectSearchFactory\_getUserSearchInstance(), ilUserFilter\getInstance(), ilObjUser\getProfileStatusOfUsers(), and QP_COMBINATION_AND.

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: