• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilGlossaryTerm.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00033 class ilGlossaryTerm
00034 {
00035         var $ilias;
00036         var $lng;
00037         var $tpl;
00038 
00039         var $id;
00040         var $glossary;
00041         var $term;
00042         var $language;
00043         var $glo_id;
00044         var $import_id;
00045 
00050         function ilGlossaryTerm($a_id = 0)
00051         {
00052                 global $lng, $ilias, $tpl;
00053 
00054                 $this->lng =& $lng;
00055                 $this->ilias =& $ilias;
00056                 $this->tpl =& $tpl;
00057 
00058                 $this->id = $a_id;
00059                 $this->type = "term";
00060                 if ($a_id != 0)
00061                 {
00062                         $this->read();
00063                 }
00064         }
00065 
00069         function read()
00070         {
00071                 $q = "SELECT * FROM glossary_term WHERE id = '".$this->id."'";
00072                 $term_set = $this->ilias->db->query($q);
00073                 $term_rec = $term_set->fetchRow(DB_FETCHMODE_ASSOC);
00074 
00075                 $this->setTerm($term_rec["term"]);
00076                 $this->setImportId($term_rec["import_id"]);
00077                 $this->setLanguage($term_rec["language"]);
00078                 $this->setGlossaryId($term_rec["glo_id"]);
00079 
00080         }
00081 
00089         function _getIdForImportId($a_import_id)
00090         {
00091                 global $ilDB;
00092                 
00093                 $q = "SELECT * FROM glossary_term WHERE import_id = '".$a_import_id."'".
00094                         " ORDER BY create_date DESC LIMIT 1";
00095                 $term_set = $ilDB->query($q);
00096                 while ($term_rec = $term_set->fetchRow(DB_FETCHMODE_ASSOC))
00097                 {
00098                         $glo_id = ilGlossaryTerm::_lookGlossaryID($term_rec["id"]);
00099 
00100                         if (ilObject::_hasUntrashedReference($glo_id))
00101                         {
00102                                 return $term_rec["id"];
00103                         }
00104                 }
00105 
00106                 return 0;
00107         }
00108         
00109         
00117         function _exists($a_id)
00118         {
00119                 global $ilDB;
00120                 
00121                 include_once("content/classes/Pages/class.ilInternalLink.php");
00122                 if (is_int(strpos($a_id, "_")))
00123                 {
00124                         $a_id = ilInternalLink::_extractObjIdOfTarget($a_id);
00125                 }
00126 
00127                 $q = "SELECT * FROM glossary_term WHERE id = '".$a_id."'";
00128                 $obj_set = $ilDB->query($q);
00129                 if ($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
00130                 {
00131                         return true;
00132                 }
00133                 else
00134                 {
00135                         return false;
00136                 }
00137 
00138         }
00139 
00140 
00146         function setId($a_id)
00147         {
00148                 $this->id = $a_id;
00149         }
00150 
00151 
00157         function getId()
00158         {
00159                 return $this->id;
00160         }
00161 
00167         function setGlossary(&$a_glossary)
00168         {
00169                 $this->glossary =& $a_glossary;
00170                 $this->setGlossaryId($a_glossary->getId());
00171         }
00172 
00173 
00179         function setGlossaryId($a_glo_id)
00180         {
00181                 $this->glo_id = $a_glo_id;
00182         }
00183 
00184 
00190         function getGlossaryId()
00191         {
00192                 return $this->glo_id;
00193         }
00194 
00195 
00201         function setTerm($a_term)
00202         {
00203                 $this->term = $a_term;
00204         }
00205 
00206 
00212         function getTerm()
00213         {
00214                 return $this->term;
00215         }
00216 
00217 
00223         function setLanguage($a_language)
00224         {
00225                 $this->language = $a_language;
00226         }
00227 
00232         function getLanguage()
00233         {
00234                 return $this->language;
00235         }
00236 
00237 
00241         function setImportId($a_import_id)
00242         {
00243                 $this->import_id = $a_import_id;
00244         }
00245 
00246 
00250         function getImportId()
00251         {
00252                 return $this->import_id;
00253         }
00254 
00255 
00259         function create()
00260         {
00261                 $q = "INSERT INTO glossary_term (glo_id, term, language, import_id, create_date, last_update)".
00262                         " VALUES ('".$this->getGlossaryId()."', '".ilUtil::prepareDBString($this->term).
00263                         "', '".$this->language."','".$this->getImportId()."',now(), now())";
00264                 $this->ilias->db->query($q);
00265                 $this->setId($this->ilias->db->getLastInsertId());
00266         }
00267 
00268 
00272         function delete()
00273         {
00274                 require_once("content/classes/class.ilGlossaryDefinition.php");
00275                 $defs = ilGlossaryDefinition::getDefinitionList($this->getId());
00276                 foreach($defs as $def)
00277                 {
00278                         $def_obj =& new ilGlossaryDefinition($def["id"]);
00279                         $def_obj->delete();
00280                 }
00281                 $q = "DELETE FROM glossary_term ".
00282                         " WHERE id = '".$this->getId()."'";
00283                 $this->ilias->db->query($q);
00284         }
00285 
00286 
00290         function update()
00291         {
00292                 $q = "UPDATE glossary_term SET ".
00293                         " glo_id = '".$this->getGlossaryId()."', ".
00294                         " term = '".ilUtil::prepareDBString($this->getTerm())."', ".
00295                         " import_id = '".$this->getImportId()."', ".
00296                         " language = '".$this->getLanguage()."', ".
00297                         " last_update = now() ".
00298                         " WHERE id = '".$this->getId()."'";
00299                 $this->ilias->db->query($q);
00300         }
00301 
00305         function _lookGlossaryID($term_id)
00306         {
00307                 global $ilDB;
00308 
00309                 $query = "SELECT * FROM glossary_term WHERE id = '".$term_id."'";
00310                 $obj_set = $ilDB->query($query);
00311                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00312 
00313                 return $obj_rec["glo_id"];
00314         }
00315 
00319         function _lookGlossaryTerm($term_id)
00320         {
00321                 global $ilDB;
00322 
00323                 $query = "SELECT * FROM glossary_term WHERE id = '".$term_id."'";
00324                 $obj_set = $ilDB->query($query);
00325                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00326 
00327                 return $obj_rec["term"];
00328         }
00329 
00333         function getTermList($a_glo_id, $searchterm="")
00334         {
00335                 $terms = array();
00336                 $searchterm = (!empty ($searchterm))?" AND term like '$searchterm%'":"";
00337                 $q = "SELECT * FROM glossary_term WHERE glo_id ='".$a_glo_id."' $searchterm ORDER BY language, term";
00338                 $term_set = $this->ilias->db->query($q);
00339                 while ($term_rec = $term_set->fetchRow(DB_FETCHMODE_ASSOC))
00340                 {
00341                         $terms[] = array("term" => $term_rec["term"],
00342                                 "language" => $term_rec["language"], "id" => $term_rec["id"]);
00343                 }
00344                 return $terms;
00345         }
00346 
00350         function exportXML(&$a_xml_writer, $a_inst)
00351         {
00352                 //include_once("content/classes/class..php");
00353 
00354                 $attrs = array();
00355                 $attrs["Language"] = $this->getLanguage();
00356                 $attrs["Id"] = "il_".IL_INST_ID."_git_".$this->getId();
00357                 $a_xml_writer->xmlStartTag("GlossaryItem", $attrs);
00358 
00359                 $attrs = array();
00360                 $a_xml_writer->xmlElement("GlossaryTerm", $attrs, $this->getTerm());
00361 
00362                 $defs = ilGlossaryDefinition::getDefinitionList($this->getId());
00363 
00364                 foreach($defs as $def)
00365                 {
00366                         $definition = new ilGlossaryDefinition($def["id"]);
00367                         $definition->exportXML($a_xml_writer, $a_inst);
00368                 }
00369 
00370                 $a_xml_writer->xmlEndTag("GlossaryItem");
00371         }
00372 
00378         function _goto($a_target,$a_type)
00379         {
00380                 global $rbacsystem, $ilErr, $lng;
00381 
00382 
00383                 if ($a_type == "glo")
00384                 {
00385                         include_once 'classes/class.ilSearch.php';
00386                         
00387                         // Added this additional check (ParentConditions) to avoid calls of objects inside e.g courses.
00388                         // Will be replaced in future releases by ilAccess::checkAccess()
00389                         if ($rbacsystem->checkAccess("read", $a_target) and ilSearch::_checkParentConditions($a_target))
00390                         {
00391                                 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00392                         }
00393                         
00394                         ilUtil::redirect(
00395                                         "./content/glossary_presentation.php?ref_id=".$a_target);                               
00396                 
00397                 }
00398 
00399                 // determine learning object
00400                 $glo_id = ilGlossaryTerm::_lookGlossaryID ($a_target);//::_lookupContObjID($a_target);
00401 
00402                 // get all references
00403                 $ref_ids = ilObject::_getAllReferences($glo_id);
00404 
00405                 // check read permissions
00406                 foreach ($ref_ids as $ref_id)
00407                 {
00408                         include_once 'classes/class.ilSearch.php';
00409                         
00410                         // Added this additional check (ParentConditions) to avoid calls of objects inside e.g courses.
00411                         // Will be replaced in future releases by ilAccess::checkAccess()
00412                         if ($rbacsystem->checkAccess("read", $ref_id) and ilSearch::_checkParentConditions($ref_id))
00413                         {
00414                                 ilUtil::redirect(
00415                                         "./content/glossary_presentation.php?cmd=listDefinitions&term_id=".$a_target."&ref_id=".$ref_id);                               
00416                         }
00417                 }
00418 
00419                 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00420         }
00421 
00422 
00423 } // END class ilGlossaryTerm
00424 
00425 ?>

Generated on Fri Dec 13 2013 09:06:35 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1