ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPlugin.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
5 include_once("./Services/Component/classes/class.ilComponent.php");
6 include_once("./Services/Component/exceptions/class.ilPluginException.php");
7 
16 abstract class ilPlugin
17 {
18 
22  protected $lang_initialised = false;
26  protected $id = '';
27 
28  public function __construct()
29  {
30  $this->__init();
31  }
32 
40  abstract function getComponentType();
41 
49  abstract function getComponentName();
50 
58  abstract function getSlot();
59 
67  abstract function getSlotId();
68 
77  abstract function getPluginName();
78 
84  private function setId($a_id)
85  {
86  $this->id = $a_id;
87  }
88 
94  function getId()
95  {
96  return $this->id;
97  }
98 
104  private function setLastUpdateVersion($a_lastupdateversion)
105  {
106  $this->lastupdateversion = $a_lastupdateversion;
107  }
108 
115  {
116  return $this->lastupdateversion;
117  }
118 
124  private function setVersion($a_version)
125  {
126  $this->version = $a_version;
127  }
128 
134  function getVersion()
135  {
136  return $this->version;
137  }
138 
144  private function setIliasMinVersion($a_iliasminversion)
145  {
146  $this->iliasminversion = $a_iliasminversion;
147  }
148 
155  {
156  return $this->iliasminversion;
157  }
158 
164  private function setIliasMaxVersion($a_iliasmaxversion)
165  {
166  $this->iliasmaxversion = $a_iliasmaxversion;
167  }
168 
175  {
176  return $this->iliasmaxversion;
177  }
178 
184  private function setActive($a_active)
185  {
186  $this->active = $a_active;
187  }
188 
194  function getActive()
195  {
196  return $this->active;
197  }
198 
204  protected function setSlotObject($a_slot)
205  {
206  $this->slot = $a_slot;
207  }
208 
214  protected function getSlotObject()
215  {
216  return $this->slot;
217  }
218 
224  function setDBVersion($a_dbversion)
225  {
226  $this->dbversion = $a_dbversion;
227  }
228 
234  function getDBVersion()
235  {
236  return $this->dbversion;
237  }
238 
244  function writeDBVersion($a_dbversion)
245  {
246  global $ilDB;
247 
248  $this->setDBVersion($a_dbversion);
249 
250  $q = "UPDATE il_plugin SET db_version = ".$ilDB->quote((int) $this->getDBVersion(), "integer").
251  " WHERE component_type = ".$ilDB->quote($this->getComponentType(), "text").
252  " AND component_name = ".$ilDB->quote($this->getComponentName(), "text").
253  " AND slot_id = ".$ilDB->quote($this->getSlotId(), "text").
254  " AND name = ".$ilDB->quote($this->getPluginName(), "text");
255 
256  $ilDB->manipulate($q);
257  }
258 
259 
265  public function getDirectory()
266  {
267  return $this->getSlotObject()->getPluginsDirectory()."/".$this->getPluginName();
268  }
269 
273  static public function _getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname)
274  {
275  include_once "Services/Component/classes/class.ilPluginSlot.php";
276  return ilPluginSlot::_getPluginsDirectory($a_ctype, $a_cname, $a_slot_id)."/".$a_pname;
277  }
278 
279 
285  protected function getClassesDirectory()
286  {
287  return $this->getDirectory()."/classes";
288  }
289 
293  public function includeClass($a_class_file_name)
294  {
295  include_once($this->getClassesDirectory()."/".$a_class_file_name);
296  }
297 
303  protected function getLanguageDirectory()
304  {
305  return $this->getDirectory()."/lang";
306  }
307 
311  static function getAvailableLangFiles($a_lang_directory)
312  {
313  $langs = array();
314 
315  if (!@is_dir($a_lang_directory))
316  {
317  return array();
318  }
319 
320  $dir = opendir($a_lang_directory);
321  while($file = readdir($dir))
322  {
323  if ($file != "." and
324  $file != "..")
325  {
326  // directories
327  if (@is_file($a_lang_directory."/".$file))
328  {
329  if (substr($file, 0, 6) == "ilias_" &&
330  substr($file, strlen($file) - 5) == ".lang")
331  {
332  $langs[] = array("key" => substr($file, 6, 2), "file" => $file,
333  "path" => $a_lang_directory."/".$file);
334  }
335  }
336  }
337  }
338 
339  return $langs;
340  }
341 
349  static function hasConfigureClass($a_slot_dir, $a_name)
350  {
351  if (is_file($a_slot_dir."/".
352  $a_name."/classes/class.il".$a_name."ConfigGUI.php"))
353  {
354  return true;
355  }
356  return false;
357  }
358 
365  static function getConfigureClassName($a_name)
366  {
367  return "il".$a_name."ConfigGUI";
368  }
369 
373  function getPrefix()
374  {
375  return $this->getSlotObject()->getPrefix()."_".$this->getId();
376  }
377 
383  static public function getDBUpdateScriptName($a_ctype, $a_cname, $a_slot_name, $a_pname)
384  {
385  return "Customizing/global/plugins/".$a_ctype."/".$a_cname."/".
386  $a_slot_name."/".$a_pname."/sql/dbupdate.php";
387  }
388 
392  function getTablePrefix()
393  {
394  return $this->getPrefix();
395  }
396 
401  public function updateLanguages($a_lang_keys = null)
402  {
403  ilGlobalCache::flushAll();
404  include_once("./Services/Language/classes/class.ilObjLanguage.php");
405 
406  // get the keys of all installed languages if keys are not provided
407  if(!isset($a_lang_keys))
408  {
409  $a_lang_keys = array();
410  foreach (ilObjLanguage::getInstalledLanguages() as $langObj)
411  {
412  if ($langObj->isInstalled())
413  {
414  $a_lang_keys[] = $langObj->getKey();
415  }
416  }
417  }
418 
419  $langs = $this->getAvailableLangFiles($this->getLanguageDirectory());
420 
421  $prefix = $this->getPrefix();
422 
423  foreach($langs as $lang)
424  {
425  // check if the language should be updated, otherwise skip it
426  if (!in_array($lang['key'], $a_lang_keys) )
427  {
428  continue;
429  }
430 
431  $txt = file($this->getLanguageDirectory()."/".$lang["file"]);
432  $lang_array = array();
433 
434  // get locally changed variables of the module (these should be kept)
435  $local_changes = ilObjLanguage::_getLocalChangesByModule($lang['key'], $prefix);
436 
437  // get language data
438  if (is_array($txt))
439  {
440  foreach ($txt as $row)
441  {
442  if ($row[0] != "#" && strpos($row, "#:#") > 0)
443  {
444  $a = explode("#:#",trim($row));
445  $identifier = $prefix."_".trim($a[0]);
446  $value = trim($a[1]);
447 
448  if (isset($local_changes[$identifier]))
449  {
450  $lang_array[$identifier] = $local_changes[$identifier];
451  }
452  else
453  {
454  $lang_array[$identifier] = $value;
455  ilObjLanguage::replaceLangEntry($prefix, $identifier, $lang["key"], $value);
456  }
457  //echo "<br>-$prefix-".$prefix."_".trim($a[0])."-".$lang["key"]."-";
458  }
459  }
460  }
461 
462  ilObjLanguage::replaceLangModule($lang["key"], $prefix, $lang_array);
463  }
464  }
465 
469  function updateDatabase()
470  {
471  global $ilDB, $lng;
472 
474 
475  include_once("./Services/Component/classes/class.ilPluginDBUpdate.php");
476  $dbupdate = new ilPluginDBUpdate($this->getComponentType(),
477  $this->getComponentName(), $this->getSlotId(),
478  $this->getPluginName(), $ilDB, true, $this->getTablePrefix());
479 
480  //$dbupdate->getDBVersionStatus();
481  //$dbupdate->getCurrentVersion();
482 
483  $result = $dbupdate->applyUpdate();
484  $message = '';
485  if ($dbupdate->updateMsg == "no_changes")
486  {
487  $message = $lng->txt("no_changes").". ".$lng->txt("database_is_uptodate");
488  }
489  else
490  {
491  foreach ($dbupdate->updateMsg as $row)
492  {
493  $message .= $lng->txt($row["msg"]).": ".$row["nr"]."<br/>";
494  }
495  }
496 
497  $this->message.= $message;
498 
499  return $result;
500  }
501 
505  public function loadLanguageModule()
506  {
507  global $lng;
508 
509  if (!$this->lang_initialised && is_object($lng))
510  {
511  $lng->loadLanguageModule($this->getPrefix());
512  $this->lang_initialised = true;
513  }
514  }
515 
519  public function txt($a_var)
520  {
521  global $lng;
522  $this->loadLanguageModule();
523  return $lng->txt($this->getPrefix()."_".$a_var, $this->getPrefix());
524  }
525 
529  static function lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
530  {
531  global $lng;
532 
533  // this enables default language fallback
534  $prefix = $a_mod_prefix."_".$a_pl_id;
535  return $lng->txt($prefix."_".$a_lang_var, $prefix);
536 
537  /*
538  return ilLanguage::_lookupEntry($lng->lang_key, $a_mod_prefix."_".$a_pl_id,
539  $a_mod_prefix."_".$a_pl_id."_".$a_lang_var);
540  */
541  }
542 
546  public function getTemplate($a_template, $a_par1 = true, $a_par2 = true)
547  {
548  $tpl = new ilTemplate($this->getDirectory()."/templates/".$a_template, $a_par1, $a_par2);
549 
550  return $tpl;
551  }
552 
556  public static function _getImagePath($a_ctype, $a_cname, $a_slot_id,
557  $a_pname, $a_img)
558  {
559  $d2 = ilComponent::lookupId($a_ctype, $a_cname)."_".$a_slot_id."_".
560  ilPlugin::lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_pname);
561 
562  $img = ilUtil::getImagePath($d2."/".$a_img);
563  if (is_int(strpos($img, "Customizing")))
564  {
565  return $img;
566  }
567 
568  $d = ilPlugin::_getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname);
569  return $d."/templates/images/".$a_img;
570  }
571 
575  public function getImagePath($a_img)
576  {
577  return self::_getImagePath($this->getComponentType(), $this->getComponentName(), $this->getSlotId(),
578  $this->getPluginName(), $a_img);
579  }
580 
584  public function getStyleSheetLocation($a_css_file)
585  {
586  $d2 = ilComponent::lookupId($this->getComponentType(), $this->getComponentName())."_".$this->getSlotId()."_".
588 
589  $css = ilUtil::getStyleSheetLocation("output", $a_css_file, $d2);
590  if (is_int(strpos($css, "Customizing")))
591  {
592  return $css;
593  }
594 
595  return $this->getDirectory()."/templates/".$a_css_file;
596  }
597 
601  public function addBlockFile($a_tpl, $a_var, $a_block, $a_tplname)
602  {
603  $a_tpl->addBlockFile($a_var, $a_block,
604  $this->getDirectory()."/templates/".$a_tplname);
605  }
606 
607 
616  static public function createPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
617  {
618  global $ilDB;
619 
621 
622  // check record existence record
623  $q = "SELECT * FROM il_plugin".
624  " WHERE component_type = ".$ilDB->quote($a_ctype, "text").
625  " AND component_name = ".$ilDB->quote($a_cname, "text").
626  " AND slot_id = ".$ilDB->quote($a_slot_id, "text").
627  " AND name = ".$ilDB->quote($a_pname, "text");
628  $set = $ilDB->query($q);
629  if (!$rec = $ilDB->fetchAssoc($set))
630  {
631  $q = "INSERT INTO il_plugin (component_type, component_name, slot_id, name)".
632  " VALUES (".$ilDB->quote($a_ctype, "text").",".
633  $ilDB->quote($a_cname, "text").",".
634  $ilDB->quote($a_slot_id, "text").",".
635  $ilDB->quote($a_pname, "text").")";
636  $ilDB->manipulate($q);
637  }
638  }
639 
640 
644  static public function getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
645  {
646  $cached_component = ilCachedComponentData::getInstance();
647  $rec = $cached_component->lookupPluginByName($a_pname);
648 
649  if ($rec['component_type'] == $a_ctype AND $rec['component_name'] == $a_cname AND $rec['slot_id'] == $a_slot_id) {
650  return $rec;
651  } else {
652  include_once("./Services/Component/exceptions/class.ilPluginException.php");
653  throw (new ilPluginException("No plugin record found for '" . $a_ctype . "', '" . $a_cname . "', '" . $a_slot_id . "', '" . $a_pname
654  . "'."));
655 
656  }
657  //
658  // global $ilDB;
659  //
660  // // read/set basic data
661  // $q = "SELECT * FROM il_plugin".
662  // " WHERE component_type = ".$ilDB->quote($a_ctype, "text").
663  // " AND component_name = ".$ilDB->quote($a_cname, "text").
664  // " AND slot_id = ".$ilDB->quote($a_slot_id, "text").
665  // " AND name = ".$ilDB->quote($a_pname, "text");
666  // $set = $ilDB->query($q);
667  // if ($rec = $ilDB->fetchAssoc($set))
668  // {
669  // return $rec;
670  // }
671  // else // no record? create one
672  // {
673  // // silently create these records is not a good idea, since
674  // // the function can be called with "wrong parameters"
675  // // raise exceptions instead
676  // include_once("./Services/Component/exceptions/class.ilPluginException.php");
677  // throw (new ilPluginException("No plugin record found for '".$a_ctype."', '".$a_cname."', '".$a_slot_id."', '".$a_pname."'."));
678  //
679  // $q = "INSERT INTO il_plugin (component_type, component_name, slot_id, name)".
680  // " VALUES (".$ilDB->quote($a_ctype, "text").",".
681  // $ilDB->quote($a_cname, "text").",".
682  // $ilDB->quote($a_slot_id, "text").",".
683  // $ilDB->quote($a_pname, "text").")";
684  // $ilDB->manipulate($q);
685  // $q = "SELECT * FROM il_plugin".
686  // " WHERE component_type = ".$ilDB->quote($a_ctype, "text").
687  // " AND component_name = ".$ilDB->quote($a_cname, "text").
688  // " AND slot_id = ".$ilDB->quote($a_slot_id, "text").
689  // " AND name = ".$ilDB->quote($a_pname, "text");
690  // $set = $ilDB->query($q);
691  // return $ilDB->fetchAssoc($set);
692  // }
693  }
694 
698  private function __init()
699  {
700  global $ilDB, $lng, $ilPluginAdmin;
701 
702  // read/set basic data
704  $this->getComponentName(), $this->getSlotId(), $this->getPluginName());
705  $this->setLastUpdateVersion($rec["last_update_version"]);
706  $this->setDBVersion($rec["db_version"]);
707  $this->setActive($rec["active"]);
708 
709  // get id
710  $this->setId($ilPluginAdmin->getId($this->getComponentType(),
711  $this->getComponentName(),
712  $this->getSlotId(),
713  $this->getPluginName()));
714 
715  // get version
716  $this->setVersion($ilPluginAdmin->getVersion($this->getComponentType(),
717  $this->getComponentName(),
718  $this->getSlotId(),
719  $this->getPluginName()));
720 
721  // get ilias min version
722  $this->setIliasMinVersion($ilPluginAdmin->getIliasMinVersion($this->getComponentType(),
723  $this->getComponentName(),
724  $this->getSlotId(),
725  $this->getPluginName()));
726 
727  // get ilias max version
728  $this->setIliasMaxVersion($ilPluginAdmin->getIliasMaxVersion($this->getComponentType(),
729  $this->getComponentName(),
730  $this->getSlotId(),
731  $this->getPluginName()));
732 
733  // get slot object
734  $this->setSlotObject(new ilPluginSlot($this->getComponentType(),
735  $this->getComponentName(), $this->getSlotId()));
736 
737  // load language module
738 
739  // Fix for authentication plugins
740  $this->loadLanguageModule();
741 
742  // call slot and plugin init methods
743  $this->slotInit();
744  $this->init();
745  }
746 
753  abstract protected function slotInit();
754 
759  protected function init()
760  {
761  }
762 
766  public function isActive()
767  {
768  global $ilPluginAdmin;
769 
770  return $ilPluginAdmin->isActive($this->getComponentType(),
771  $this->getComponentName(), $this->getSlotId(), $this->getPluginName());
772  }
773 
777  public function needsUpdate()
778  {
779  global $ilPluginAdmin;
780 
781  return $ilPluginAdmin->isActive($this->getComponentType(),
782  $this->getComponentName(), $this->getSlotId(), $this->getPluginName());
783  }
784 
788  function activate()
789  {
790  global $lng, $ilDB;
791 
793 
794  $result = true;
795 
796  // check whether update is necessary
797  if ($this->needsUpdate())
798  {
799  //$result = $this->isUpdatePossible();
800 
801  // do update
802  if ($result === true)
803  {
804  $result = $this->update();
805  }
806  }
807  if ($result === true)
808  {
809  $result = $this->beforeActivation();
810  // activate plugin
811  if ($result === true)
812  {
813  $q = "UPDATE il_plugin SET active = ".$ilDB->quote(1, "integer").",".
814  " plugin_id = ".$ilDB->quote($this->getId(), "text").
815  " WHERE component_type = ".$ilDB->quote($this->getComponentType(), "text").
816  " AND component_name = ".$ilDB->quote($this->getComponentName(), "text").
817  " AND slot_id = ".$ilDB->quote($this->getSlotId(), "text").
818  " AND name = ".$ilDB->quote($this->getPluginName(), "text");
819 
820  $ilDB->manipulate($q);
821  $this->afterActivation();
822  }
823  }
825  return $result;
826  }
827 
831  protected function beforeActivation()
832  {
833  return true; // false would indicate that anything went wrong
834  // activation would not proceed
835  // throw an exception in this case
836  //throw new ilPluginException($lng->txt(""));
837  }
838 
842  protected function afterActivation()
843  {
844  }
845 
849  function deactivate()
850  {
851  global $ilDB;
852 
854 
855  $result = true;
856 
857  $q = "UPDATE il_plugin SET active = ".$ilDB->quote(0, "integer").
858  " WHERE component_type = ".$ilDB->quote($this->getComponentType(), "text").
859  " AND component_name = ".$ilDB->quote($this->getComponentName(), "text").
860  " AND slot_id = ".$ilDB->quote($this->getSlotId(), "text").
861  " AND name = ".$ilDB->quote($this->getPluginName(), "text");
862 
863  $ilDB->manipulate($q);
864  $this->afterDeactivation();
865 
866  return $result;
867  }
868 
869 
873  protected function afterDeactivation()
874  {
875  }
876 
877 
878  protected function beforeUninstall()
879  {
880  // plugin-specific
881  // false would indicate that anything went wrong
882  return true;
883  }
884 
885  final function uninstall()
886  {
887  global $ilDB;
888 
889  if($this->beforeUninstall())
890  {
891  // remove all language entries (see ilObjLanguage)
892  // see updateLanguages
893  $prefix = $this->getPrefix();
894  if($prefix)
895  {
896  $ilDB->manipulate("DELETE FROM lng_data".
897  " WHERE module = ".$ilDB->quote($prefix, "text"));
898  $ilDB->manipulate("DELETE FROM lng_modules".
899  " WHERE module = ".$ilDB->quote($prefix, "text"));
900  }
901 
902  // db version is kept in il_plugin - will be deleted, too
903 
904  $q = "DELETE FROM il_plugin".
905  " WHERE component_type = ".$ilDB->quote($this->getComponentType(), "text").
906  " AND component_name = ".$ilDB->quote($this->getComponentName(), "text").
907  " AND slot_id = ".$ilDB->quote($this->getSlotId(), "text").
908  " AND name = ".$ilDB->quote($this->getPluginName(), "text");
909  $ilDB->manipulate($q);
910 
911  $this->afterUninstall();
912 
914  return true;
915  }
916 
917  return false;
918  }
919 
920  protected function afterUninstall()
921  {
922  // plugin-specific
923  }
924 
928  function update()
929  {
930  global $ilDB, $ilCtrl;
931 
933 
934  $result = $this->beforeUpdate();
935  if ($result === false) {
936  return false;
937  }
938 
939  // DB update
940  if ($result === true)
941  {
942  $result = $this->updateDatabase();
943  }
944 
945  // Load language files
946  $this->updateLanguages();
947 
948  // load control structure
949  include_once("./setup/classes/class.ilCtrlStructureReader.php");
950  $structure_reader = new ilCtrlStructureReader();
951  $structure_reader->readStructure(true, "./".$this->getDirectory(), $this->getPrefix(),
952  $this->getDirectory());
953  // $ilCtrl->storeCommonStructures();
954 
955  // add config gui to the ctrl calls
956  $ilCtrl->insertCtrlCalls("ilobjcomponentsettingsgui", ilPlugin::getConfigureClassName($this->getPluginName()),
957  $this->getPrefix());
958 
959  // set last update version to current version
960  if ($result === true)
961  {
962  $q = "UPDATE il_plugin SET last_update_version = ".$ilDB->quote($this->getVersion(), "text").
963  " WHERE component_type = ".$ilDB->quote($this->getComponentType(), "text").
964  " AND component_name = ".$ilDB->quote($this->getComponentName(), "text").
965  " AND slot_id = ".$ilDB->quote($this->getSlotId(), "text").
966  " AND name = ".$ilDB->quote($this->getPluginName(), "text");
967 
968  $ilDB->manipulate($q);
969  $this->afterUpdate();
970  }
971 
972  return $result;
973  }
974 
978  protected function beforeUpdate()
979  {
980  return true; // false would indicate that anything went wrong
981  // update would not proceed
982  // throw an exception in this case
983  //throw new ilPluginException($lng->txt(""));
984  }
985 
989  protected function afterUpdate()
990  {
991  }
992 
1001  static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
1002  {
1003  global $ilDB;
1004 
1005  include_once("./Services/Component/classes/class.ilPluginSlot.php");
1006  $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
1007 
1008  $cached_component = ilCachedComponentData::getInstance();
1009  $rec = $cached_component->lookCompId($a_ctype, $a_cname);
1010  if (! $rec) {
1011  return NULL;
1012  }
1013 
1014  // this check is done due to security reasons
1015  // $set = $ilDB->queryF("SELECT * FROM il_component WHERE type = %s ".
1016  // " AND name = %s", array("text", "text"),
1017  // array($a_ctype, $a_cname));
1018  // if (!$ilDB->fetchAssoc($set))
1019  // {
1020  // return null;
1021  // }
1022 
1023  $file = "./Customizing/global/plugins/".$a_ctype."/".
1024  $a_cname."/".$slot_name."/".
1025  $a_pname."/classes/class.il".$a_pname."Plugin.php";
1026 
1027  if (is_file($file))
1028  {
1029  include_once($file);
1030  $class = "il".$a_pname."Plugin";
1031  $plugin = new $class();
1032  return $plugin;
1033  }
1034 
1035  return null;
1036  }
1037 
1038 
1042  static function lookupStoredData($a_ctype, $a_cname, $a_slot_id, $a_pname)
1043  {
1044  global $ilDB;
1045 
1046  $q = "SELECT * FROM il_plugin WHERE ".
1047  " component_type = ".$ilDB->quote($a_ctype, "text")." AND ".
1048  " component_name = ".$ilDB->quote($a_cname, "text")." AND ".
1049  " slot_id = ".$ilDB->quote($a_slot_id, "text")." AND ".
1050  " name = ".$ilDB->quote($a_pname, "text");
1051 
1052  $set = $ilDB->query($q);
1053 
1054  $rec = $ilDB->fetchAssoc($set);
1055 
1056  return $rec;
1057  }
1058 
1062  static function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
1063  {
1064  global $ilDB, $ilPluginAdmin;
1065 
1066  $plugins = array();
1067 
1068  // $q = "SELECT * FROM il_plugin WHERE component_type = ".$ilDB->quote($a_ctype, "text").
1069  // " AND component_name = ".$ilDB->quote($a_cname, "text").
1070  // " AND slot_id = ".$ilDB->quote($a_slot_id, "text").
1071  // " AND active = ".$ilDB->quote(1, "integer");
1072  //
1073  // $set = $ilDB->query($q);
1074  $cached_component = ilCachedComponentData::getInstance();
1075  // while($rec = $ilDB->fetchAssoc($set))
1076  $lookupActivePluginsBySlotId = $cached_component->lookupActivePluginsBySlotId($a_slot_id);
1077  foreach($lookupActivePluginsBySlotId as $rec)
1078  {
1079  if ($ilPluginAdmin->isActive($a_ctype, $a_cname, $a_slot_id, $rec["name"]))
1080  {
1081  $plugins[] = $rec["name"];
1082  }
1083  }
1084 
1085  return $plugins;
1086  }
1087 
1091  function lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
1092  {
1093  global $ilDB;
1094 
1095  $q = "SELECT name FROM il_plugin ".
1096  " WHERE component_type = ".$ilDB->quote($a_ctype, "text").
1097  " AND component_name = ".$ilDB->quote($a_cname, "text").
1098  " AND slot_id = ".$ilDB->quote($a_slot_id, "text").
1099  " AND plugin_id = ".$ilDB->quote($a_plugin_id, "text");
1100 
1101  $set = $ilDB->query($q);
1102  if ($rec = $ilDB->fetchAssoc($set))
1103  {
1104  return $rec["name"];
1105  }
1106  }
1107 
1111  function lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
1112  {
1113  global $ilDB;
1114 
1115  $q = "SELECT plugin_id FROM il_plugin ".
1116  " WHERE component_type = ".$ilDB->quote($a_ctype, "text").
1117  " AND component_name = ".$ilDB->quote($a_cname, "text").
1118  " AND slot_id = ".$ilDB->quote($a_slot_id, "text").
1119  " AND name = ".$ilDB->quote($a_plugin_name, "text");
1120 
1121  $set = $ilDB->query($q);
1122  if ($rec = $ilDB->fetchAssoc($set))
1123  {
1124  return $rec["plugin_id"];
1125  }
1126  }
1127 }
1128 ?>
getTablePrefix()
Get db table plugin prefix.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
loadLanguageModule()
Load language module for plugin.
print $file
static replaceLangEntry($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
getVersion()
Get Current Version (from plugin.php file).
getIliasMinVersion()
Get Required ILIAS min.
static lookupId($a_type, $a_name)
Lookup ID of a component.
setId($a_id)
Set Id.
$result
includeClass($a_class_file_name)
Include (once) a class file.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
getImagePath($a_img)
Get image path.
update()
Update plugin.
static lookupStoredData($a_ctype, $a_cname, $a_slot_id, $a_pname)
Lookup information data in il_plugin.
_getPluginsDirectory($a_ctype, $a_cname, $a_slot_id)
Get plugins directory.
needsUpdate()
Check whether update is needed.
static getInstalledLanguages()
Get the language objects of the installed languages.
Database Update class.
static getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
Get all active plugins for a slot.
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
static _getImagePath($a_ctype, $a_cname, $a_slot_id, $a_pname, $a_img)
Get image path.
setSlotObject($a_slot)
Set Plugin Slot.
lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
Lookup name for id.
updateLanguages($a_lang_keys=null)
static getConfigureClassName($a_name)
Get plugin configure class name.
activate()
Activate.
setVersion($a_version)
Set Current Version (from plugin.php file).
getComponentName()
Get Component Name.
beforeActivation()
Before activation processing.
getTemplate($a_template, $a_par1=true, $a_par2=true)
Get template from plugin.
setIliasMaxVersion($a_iliasmaxversion)
Set Required ILIAS max.
Class ilCtrlStructureReader.
static getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get record from il_plugin table.
isActive()
Check whether plugin is active.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
getId()
Get Id.
getComponentType()
Get Component Type.
init()
Object initialization.
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
writeDBVersion($a_dbversion)
Write DB version to database.
afterActivation()
After activation processing.
lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
Lookup id for name.
setDBVersion($a_dbversion)
Set DB Version.
updateDatabase()
Update database.
getDBVersion()
Get DB Version.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Plugin Slot.
getDirectory()
Get Plugin Directory.
special template class to simplify handling of ITX/PEAR
deactivate()
Deactivate.
getActive()
Get Active.
$txt
Definition: error.php:12
txt($a_var)
Get Language Variable (prefix will be prepended automatically)
getPrefix()
Get plugin prefix, used for lang vars.
afterUpdate()
After update processing.
getLastUpdateVersion()
Get Version of last update.
setLastUpdateVersion($a_lastupdateversion)
Set Version of last update.
getClassesDirectory()
Get Plugin&#39;s classes Directory.
static getDBUpdateScriptName($a_ctype, $a_cname, $a_slot_name, $a_pname)
Get DB update script filename (full path)
static createPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
getStyleSheetLocation($a_css_file)
Get css file location.
getSlotId()
Get Slot ID.
static hasConfigureClass($a_slot_dir, $a_name)
Has the plugin a configure class?
global $lng
Definition: privfeed.php:40
slotInit()
Object initialization done by slot.
static getAvailableLangFiles($a_lang_directory)
Get array of all language files in the plugin.
global $ilDB
__init()
Default initialization.
getPluginName()
Get Plugin Name.
getSlotObject()
Get Plugin Slot.
addBlockFile($a_tpl, $a_var, $a_block, $a_tplname)
Add template content to placeholder variable.
getLanguageDirectory()
Get Plugin&#39;s language Directory.
getSlot()
Get Slot Name.
setIliasMinVersion($a_iliasminversion)
Set Required ILIAS min.
getIliasMaxVersion()
Get Required ILIAS max.
setActive($a_active)
Set Active.
beforeUpdate()
Before update processing.
afterDeactivation()
After deactivation processing.
static _getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin directory.