Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00034 class ilInternalLink
00035 {
00042 function _deleteAllLinksOfSource($a_source_type, $a_source_id)
00043 {
00044 global $ilias;
00045
00046 $q = "DELETE FROM int_link WHERE source_type='$a_source_type' AND source_id='$a_source_id'";
00047 $ilias->db->query($q);
00048 }
00049
00059 function _saveLink($a_source_type, $a_source_id, $a_target_type, $a_target_id, $a_target_inst = 0)
00060 {
00061 global $ilias;
00062
00063 $q = "REPLACE INTO int_link (source_type, source_id, target_type, target_id, target_inst) VALUES".
00064 " ('$a_source_type', '$a_source_id', '$a_target_type', '$a_target_id', '$a_target_inst')";
00065 $ilias->db->query($q);
00066 }
00067
00077 function _getSourcesOfTarget($a_target_type, $a_target_id, $a_target_inst)
00078 {
00079 global $ilias;
00080
00081 $q = "SELECT * FROM int_link WHERE ".
00082 "target_type = '$a_target_type' AND ".
00083 "target_id = '$a_target_id' AND ".
00084 "target_inst = '$a_target_inst'";
00085 $source_set = $ilias->db->query($q);
00086 $sources = array();
00087 while ($source_rec = $source_set->fetchRow(DB_FETCHMODE_ASSOC))
00088 {
00089 $sources[$source_rec["source_type"].":".$source_rec["source_id"]] =
00090 array("type" => $source_rec["source_type"], "id" => $source_rec["source_id"]);
00091 }
00092
00093 return $sources;
00094 }
00095
00104 function _getTargetsOfSource($a_source_type, $a_source_id)
00105 {
00106 global $ilDB;
00107
00108 $q = "SELECT * FROM int_link WHERE ".
00109 "source_type = ".$ilDB->quote($a_source_type)." AND ".
00110 "source_id = ".$ilDB->quote($a_source_id);
00111
00112 $target_set = $ilDB->query($q);
00113 $targets = array();
00114 while ($target_rec = $target_set->fetchRow(DB_FETCHMODE_ASSOC))
00115 {
00116 $targets[$target_rec["target_type"].":".$target_rec["target_id"].":".$target_rec["target_inst"]] =
00117 array("type" => $target_rec["target_type"], "id" => $target_rec["target_id"],
00118 "inst" => $target_rec["target_inst"]);
00119 }
00120
00121 return $targets;
00122 }
00123
00133 function _getIdForImportId($a_type, $a_target)
00134 {
00135 switch($a_type)
00136 {
00137 case "PageObject":
00138 $id = ilLMObject::_getIdForImportId($a_target);
00139 if($id > 0)
00140 {
00141 return "il__pg_".$id;
00142 }
00143 break;
00144
00145 case "StructureObject":
00146 $id = ilLMObject::_getIdForImportId($a_target);
00147 if($id > 0)
00148 {
00149 return "il__st_".$id;
00150 }
00151 break;
00152
00153 case "GlossaryItem":
00154 $id = ilGlossaryTerm::_getIdForImportId($a_target);
00155 if($id > 0)
00156 {
00157 return "il__git_".$id;
00158 }
00159 break;
00160
00161 case "MediaObject":
00162 $id = ilObjMediaObject::_getIdForImportId($a_target);
00163 if($id > 0)
00164 {
00165 return "il__mob_".$id;
00166 }
00167 break;
00168 }
00169 return false;
00170 }
00171
00181 function _exists($a_type, $a_target)
00182 {
00183 switch($a_type)
00184 {
00185 case "PageObject":
00186 case "StructureObject":
00187 return ilLMObject::_exists($a_target);
00188 break;
00189
00190 case "GlossaryItem":
00191 return ilGlossaryTerm::_exists($a_target);
00192 break;
00193
00194 case "MediaObject":
00195 return ilObjMediaObject::_exists($a_target);
00196 break;
00197 }
00198 return false;
00199 }
00200
00201
00207 function _extractInstOfTarget($a_target)
00208 {
00209 if (!is_int(strpos($a_target, "__")))
00210 {
00211 $target = explode("_", $a_target);
00212 if ($target[1] > 0)
00213 {
00214 return $target[1];
00215 }
00216 }
00217 return false;
00218 }
00219
00225 function _removeInstFromTarget($a_target)
00226 {
00227 if (!is_int(strpos($a_target, "__")))
00228 {
00229 $target = explode("_", $a_target);
00230 if ($target[1] > 0)
00231 {
00232 return "il__".$target[2]."_".$target[3];
00233 }
00234 }
00235 return false;
00236 }
00237
00243 function _extractObjIdOfTarget($a_target)
00244 {
00245 $target = explode("_", $a_target);
00246 return $target[count($target) - 1];
00247 }
00248
00249 }
00250 ?>