ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $ilDB
$DIC
Definition: xapitoken.php:46

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 262 of file class.ilInternalLink.php.

263 {
264 global $DIC;
265
266 $tree = $DIC->repositoryTree();
267
268 switch ($a_type) {
269 case "PageObject":
270 case "StructureObject":
271 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
272 return ilLMObject::_exists($a_target);
273 break;
274
275 case "GlossaryItem":
276 return ilGlossaryTerm::_exists($a_target);
277 break;
278
279 case "MediaObject":
280 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
281 return ilObjMediaObject::_exists($a_target);
282 break;
283
284 case "WikiPage":
285 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
286 return ilWikiPage::_exists("wiki", (int) $a_target);
287 break;
288
289 case "RepositoryItem":
290 if (is_int(strpos($a_target, "_"))) {
291 $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target);
292 return $tree->isInTree($ref_id);
293 }
294 break;
295 }
296 return false;
297 }
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 305 of file class.ilInternalLink.php.

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

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 348 of file class.ilInternalLink.php.

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

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":
176 $id = ilLMObject::_getIdForImportId($a_target);
177 if ($id > 0) {
178 return "il__pg_" . $id;
179 }
180 break;
181
182 case "StructureObject":
183 $id = ilLMObject::_getIdForImportId($a_target);
184 if ($id > 0) {
185 return "il__st_" . $id;
186 }
187 break;
188
189 case "GlossaryItem":
190 $id = ilGlossaryTerm::_getIdForImportId($a_target);
191 //echo "+".$id."+".$a_target."+";
192 if ($id > 0) {
193 return "il__git_" . $id;
194 }
195 break;
196
197 case "WikiPage":
198 // no import IDs for wiki pages (yet)
199 //$id = ilGlossaryTerm::_getIdForImportId($a_target);
200 $id = 0;
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) {
230 $refs = ilObject::_getAllReferences($id);
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 (ilInternalLink::_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 }
250 return false;
251 }
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)

References $a_type, _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 ilCOPageHTMLExport\collectPageElements(), 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 321 of file class.ilInternalLink.php.

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

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 360 of file class.ilInternalLink.php.

361 {
362 $result = new ilSearchResult();
363
364 $query_parser = new ilQueryParser($a_search_str, '%_');
365 $query_parser->setCombination(QP_COMBINATION_AND);
366 $query_parser->setMinWordLength(3);
367 $query_parser->parse();
368
369 $user_search = ilObjectSearchFactory::_getUserSearchInstance($query_parser);
370 $user_search->enableActiveCheck(true);
371 $user_search->setFields(array('login'));
372 $result_obj = $user_search->performSearch();
373 $result->mergeEntries($result_obj);
374
375 $user_search->setFields(array('firstname'));
376 $result_obj = $user_search->performSearch();
377 $result->mergeEntries($result_obj);
378
379 $user_search->setFields(array('lastname'));
380 $result_obj = $user_search->performSearch();
381 $result->mergeEntries($result_obj);
382
383 $result->setMaxHits(100000);
384 $result->preventOverwritingMaxhits(true);
385 $result->filter(ROOT_FOLDER_ID, true);
386
387 // Filter users (depends on setting in user accounts)
388 include_once 'Services/User/classes/class.ilUserFilter.php';
389 $users = ilUserFilter::getInstance()->filter($result->getResultIds());
390
391 include_once("./Services/User/classes/class.ilObjUser.php");
393
394 $users = array_intersect($users, $p["public"]);
395
396 return $users;
397 }
$result
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, 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: