ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5include_once("./Services/Component/classes/class.ilComponent.php");
6include_once("./Services/Component/exceptions/class.ilPluginException.php");
7
16abstract 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 public function getComponentType();
41
49 abstract public function getComponentName();
57 abstract public function getSlot();
58
66 abstract public function getSlotId();
67
76 abstract public function getPluginName();
77
83 private function setId($a_id)
84 {
85 $this->id = $a_id;
86 }
87
93 public function getId()
94 {
95 return $this->id;
96 }
97
103 private function setLastUpdateVersion($a_lastupdateversion)
104 {
105 $this->lastupdateversion = $a_lastupdateversion;
106 }
107
113 public function getLastUpdateVersion()
114 {
115 return $this->lastupdateversion;
116 }
117
123 private function setVersion($a_version)
124 {
125 $this->version = $a_version;
126 }
127
133 public function getVersion()
134 {
135 return $this->version;
136 }
137
143 private function setIliasMinVersion($a_iliasminversion)
144 {
145 $this->iliasminversion = $a_iliasminversion;
146 }
147
153 public function getIliasMinVersion()
154 {
155 return $this->iliasminversion;
156 }
157
163 private function setIliasMaxVersion($a_iliasmaxversion)
164 {
165 $this->iliasmaxversion = $a_iliasmaxversion;
166 }
167
173 public function getIliasMaxVersion()
174 {
175 return $this->iliasmaxversion;
176 }
177
183 private function setActive($a_active)
184 {
185 $this->active = $a_active;
186 }
187
193 public function getActive()
194 {
195 return $this->active;
196 }
197
203 protected function setSlotObject($a_slot)
204 {
205 $this->slot = $a_slot;
206 }
207
213 protected function getSlotObject()
214 {
215 return $this->slot;
216 }
217
223 public function setDBVersion($a_dbversion)
224 {
225 $this->dbversion = $a_dbversion;
226 }
227
233 public function getDBVersion()
234 {
235 return $this->dbversion;
236 }
237
243 public function writeDBVersion($a_dbversion)
244 {
245 global $ilDB;
246
247 $this->setDBVersion($a_dbversion);
248
249 $q = "UPDATE il_plugin SET db_version = " . $ilDB->quote((int) $this->getDBVersion(), "integer") .
250 " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
251 " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
252 " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
253 " AND name = " . $ilDB->quote($this->getPluginName(), "text");
254
255 $ilDB->manipulate($q);
256 }
257
258
264 public function getDirectory()
265 {
266 return $this->getSlotObject()->getPluginsDirectory() . "/" . $this->getPluginName();
267 }
268
272 public static function _getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname)
273 {
274 include_once "Services/Component/classes/class.ilPluginSlot.php";
275 return ilPluginSlot::_getPluginsDirectory($a_ctype, $a_cname, $a_slot_id) . "/" . $a_pname;
276 }
277
278
284 protected function getClassesDirectory()
285 {
286 return $this->getDirectory() . "/classes";
287 }
288
292 public function includeClass($a_class_file_name)
293 {
294 include_once($this->getClassesDirectory() . "/" . $a_class_file_name);
295 }
296
302 protected function getLanguageDirectory()
303 {
304 return $this->getDirectory() . "/lang";
305 }
306
310 public static function getAvailableLangFiles($a_lang_directory)
311 {
312 $langs = array();
313
314 if (!@is_dir($a_lang_directory)) {
315 return array();
316 }
317
318 $dir = opendir($a_lang_directory);
319 while ($file = readdir($dir)) {
320 if ($file != "." and
321 $file != "..") {
322 // directories
323 if (@is_file($a_lang_directory . "/" . $file)) {
324 if (substr($file, 0, 6) == "ilias_" &&
325 substr($file, strlen($file) - 5) == ".lang") {
326 $langs[] = array("key" => substr($file, 6, 2), "file" => $file,
327 "path" => $a_lang_directory . "/" . $file);
328 }
329 }
330 }
331 }
332
333 return $langs;
334 }
335
343 public static function hasConfigureClass($a_slot_dir, $a_name)
344 {
345 if (is_file($a_slot_dir . "/" .
346 $a_name . "/classes/class.il" . $a_name . "ConfigGUI.php")) {
347 return true;
348 }
349 return false;
350 }
351
358 public static function getConfigureClassName($a_name)
359 {
360 return "il" . $a_name . "ConfigGUI";
361 }
362
366 public function getPrefix()
367 {
368 return $this->getSlotObject()->getPrefix() . "_" . $this->getId();
369 }
370
376 public static function getDBUpdateScriptName($a_ctype, $a_cname, $a_slot_name, $a_pname)
377 {
378 return "Customizing/global/plugins/" . $a_ctype . "/" . $a_cname . "/" .
379 $a_slot_name . "/" . $a_pname . "/sql/dbupdate.php";
380 }
381
385 public function getTablePrefix()
386 {
387 return $this->getPrefix();
388 }
389
394 public function updateLanguages($a_lang_keys = null)
395 {
396 ilGlobalCache::flushAll();
397 include_once("./Services/Language/classes/class.ilObjLanguage.php");
398
399 // get the keys of all installed languages if keys are not provided
400 if (!isset($a_lang_keys)) {
401 $a_lang_keys = array();
402 foreach (ilObjLanguage::getInstalledLanguages() as $langObj) {
403 if ($langObj->isInstalled()) {
404 $a_lang_keys[] = $langObj->getKey();
405 }
406 }
407 }
408
409 $langs = $this->getAvailableLangFiles($this->getLanguageDirectory());
410
411 $prefix = $this->getPrefix();
412
413 foreach ($langs as $lang) {
414 // check if the language should be updated, otherwise skip it
415 if (!in_array($lang['key'], $a_lang_keys)) {
416 continue;
417 }
418
419 $txt = file($this->getLanguageDirectory() . "/" . $lang["file"]);
420 $lang_array = array();
421
422 // get locally changed variables of the module (these should be kept)
423 $local_changes = ilObjLanguage::_getLocalChangesByModule($lang['key'], $prefix);
424
425 // get language data
426 if (is_array($txt)) {
427 foreach ($txt as $row) {
428 if ($row[0] != "#" && strpos($row, "#:#") > 0) {
429 $a = explode("#:#", trim($row));
430 $identifier = $prefix . "_" . trim($a[0]);
431 $value = trim($a[1]);
432
433 if (isset($local_changes[$identifier])) {
434 $lang_array[$identifier] = $local_changes[$identifier];
435 } else {
436 $lang_array[$identifier] = $value;
437 ilObjLanguage::replaceLangEntry($prefix, $identifier, $lang["key"], $value);
438 }
439 //echo "<br>-$prefix-".$prefix."_".trim($a[0])."-".$lang["key"]."-";
440 }
441 }
442 }
443
444 ilObjLanguage::replaceLangModule($lang["key"], $prefix, $lang_array);
445 }
446 }
447
451 public function updateDatabase()
452 {
453 global $ilDB, $lng;
454
456
457 include_once("./Services/Component/classes/class.ilPluginDBUpdate.php");
458 $dbupdate = new ilPluginDBUpdate(
459 $this->getComponentType(),
460 $this->getComponentName(),
461 $this->getSlotId(),
462 $this->getPluginName(),
463 $ilDB,
464 true,
465 $this->getTablePrefix()
466 );
467
468 //$dbupdate->getDBVersionStatus();
469 //$dbupdate->getCurrentVersion();
470
471 $result = $dbupdate->applyUpdate();
472 $message = '';
473 if ($dbupdate->updateMsg == "no_changes") {
474 $message = $lng->txt("no_changes") . ". " . $lng->txt("database_is_uptodate");
475 } else {
476 foreach ($dbupdate->updateMsg as $row) {
477 $message .= $lng->txt($row["msg"]) . ": " . $row["nr"] . "<br/>";
478 }
479 }
480
481 $this->message.= $message;
482
483 return $result;
484 }
485
489 public function loadLanguageModule()
490 {
491 global $lng;
492
493 if (!$this->lang_initialised && is_object($lng)) {
494 $lng->loadLanguageModule($this->getPrefix());
495 $this->lang_initialised = true;
496 }
497 }
498
502 public function txt($a_var)
503 {
504 global $lng;
505 $this->loadLanguageModule();
506 return $lng->txt($this->getPrefix() . "_" . $a_var, $this->getPrefix());
507 }
508
512 public static function lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
513 {
514 global $lng;
515
516 // this enables default language fallback
517 $prefix = $a_mod_prefix . "_" . $a_pl_id;
518 return $lng->txt($prefix . "_" . $a_lang_var, $prefix);
519 }
520
529 public static function langExitsById($pluginId, $langVar)
530 {
531 global $lng;
532
534 $pl->loadLanguageModule();
535
536 return $lng->exists($pl->getPrefix() . "_" . $langVar);
537 }
538
539
543 public function getTemplate($a_template, $a_par1 = true, $a_par2 = true)
544 {
545 $tpl = new ilTemplate($this->getDirectory() . "/templates/" . $a_template, $a_par1, $a_par2);
546
547 return $tpl;
548 }
549
553 public static function _getImagePath(
554 $a_ctype,
555 $a_cname,
556 $a_slot_id,
557 $a_pname,
558 $a_img
559 ) {
560 $d2 = ilComponent::lookupId($a_ctype, $a_cname) . "_" . $a_slot_id . "_" .
561 ilPlugin::lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_pname);
562
563 $img = ilUtil::getImagePath($d2 . "/" . $a_img);
564 if (is_int(strpos($img, "Customizing"))) {
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(
578 $this->getComponentType(),
579 $this->getComponentName(),
580 $this->getSlotId(),
581 $this->getPluginName(),
582 $a_img
583 );
584 }
585
589 public function getStyleSheetLocation($a_css_file)
590 {
591 $d2 = ilComponent::lookupId($this->getComponentType(), $this->getComponentName()) . "_" . $this->getSlotId() . "_" .
593
594 $css = ilUtil::getStyleSheetLocation("output", $a_css_file, $d2);
595 if (is_int(strpos($css, "Customizing"))) {
596 return $css;
597 }
598
599 return $this->getDirectory() . "/templates/" . $a_css_file;
600 }
601
605 public function addBlockFile($a_tpl, $a_var, $a_block, $a_tplname)
606 {
607 $a_tpl->addBlockFile(
608 $a_var,
609 $a_block,
610 $this->getDirectory() . "/templates/" . $a_tplname
611 );
612 }
613
614
623 public static function createPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
624 {
625 global $ilDB;
626
628
629 $q = "INSERT INTO il_plugin (component_type, component_name, slot_id, name)" .
630 " VALUES (" . $ilDB->quote($a_ctype, "text") . "," .
631 $ilDB->quote($a_cname, "text") . "," .
632 $ilDB->quote($a_slot_id, "text") . "," .
633 $ilDB->quote($a_pname, "text") . ")";
634
635 $ilDB->manipulate($q);
636 }
637
638
642 public static function getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
643 {
644 $cached_component = ilCachedComponentData::getInstance();
645 $rec = $cached_component->lookupPluginByName($a_pname);
646
647 if ($rec['component_type'] == $a_ctype and $rec['component_name'] == $a_cname and $rec['slot_id'] == $a_slot_id) {
648 return $rec;
649 } else {
650 include_once("./Services/Component/exceptions/class.ilPluginException.php");
651 throw (new ilPluginException("No plugin record found for '" . $a_ctype . "', '" . $a_cname . "', '" . $a_slot_id . "', '" . $a_pname
652 . "'."));
653 }
654 }
655
659 private function __init()
660 {
661 global $ilDB, $lng, $ilPluginAdmin;
662
663 // read/set basic data
665 $this->getComponentType(),
666 $this->getComponentName(),
667 $this->getSlotId(),
668 $this->getPluginName()
669 );
670 $this->setLastUpdateVersion($rec["last_update_version"]);
671 $this->setDBVersion($rec["db_version"]);
672 $this->setActive($rec["active"]);
673
674 // get id
675 $this->setId($ilPluginAdmin->getId(
676 $this->getComponentType(),
677 $this->getComponentName(),
678 $this->getSlotId(),
679 $this->getPluginName()
680 ));
681
682 // get version
683 $this->setVersion($ilPluginAdmin->getVersion(
684 $this->getComponentType(),
685 $this->getComponentName(),
686 $this->getSlotId(),
687 $this->getPluginName()
688 ));
689
690 // get ilias min version
691 $this->setIliasMinVersion($ilPluginAdmin->getIliasMinVersion(
692 $this->getComponentType(),
693 $this->getComponentName(),
694 $this->getSlotId(),
695 $this->getPluginName()
696 ));
697
698 // get ilias max version
699 $this->setIliasMaxVersion($ilPluginAdmin->getIliasMaxVersion(
700 $this->getComponentType(),
701 $this->getComponentName(),
702 $this->getSlotId(),
703 $this->getPluginName()
704 ));
705
706 // get slot object
707 $this->setSlotObject(new ilPluginSlot(
708 $this->getComponentType(),
709 $this->getComponentName(),
710 $this->getSlotId()
711 ));
712
713 // load language module
714
715 // Fix for authentication plugins
716 $this->loadLanguageModule();
717
718 // call slot and plugin init methods
719 $this->slotInit();
720 $this->init();
721 }
722
729 abstract protected function slotInit();
730
735 protected function init()
736 {
737 }
738
742 public function isActive()
743 {
744 global $ilPluginAdmin;
745
746 return $ilPluginAdmin->isActive(
747 $this->getComponentType(),
748 $this->getComponentName(),
749 $this->getSlotId(),
750 $this->getPluginName()
751 );
752 }
753
757 public function needsUpdate()
758 {
759 global $ilPluginAdmin;
760
761 return $ilPluginAdmin->needsUpdate(
762 $this->getComponentType(),
763 $this->getComponentName(),
764 $this->getSlotId(),
765 $this->getPluginName()
766 );
767 }
768
774 public function install()
775 {
776 global $ilDB;
777
779 $q = "UPDATE il_plugin SET plugin_id = " . $ilDB->quote($this->getId(), "text") .
780 " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
781 " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
782 " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
783 " AND name = " . $ilDB->quote($this->getPluginName(), "text");
784
785 $ilDB->manipulate($q);
786 $this->afterInstall();
787 }
788
792 public function activate()
793 {
794 global $lng, $ilDB;
795
797
798 $result = true;
799
800 // check whether update is necessary
801 if ($this->needsUpdate()) {
802 //$result = $this->isUpdatePossible();
803
804 // do update
805 if ($result === true) {
806 $result = $this->update();
807 }
808 }
809 if ($result === true) {
810 $result = $this->beforeActivation();
811 // activate plugin
812 if ($result === true) {
813 $q = "UPDATE il_plugin SET active = " . $ilDB->quote(1, "integer") .
814 " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
815 " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
816 " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
817 " AND name = " . $ilDB->quote($this->getPluginName(), "text");
818
819 $ilDB->manipulate($q);
820 $this->afterActivation();
821 }
822 }
824 return $result;
825 }
826
832 protected function afterInstall()
833 {
834 }
835
839 protected function beforeActivation()
840 {
841 return true; // false would indicate that anything went wrong
842 // activation would not proceed
843 // throw an exception in this case
844 //throw new ilPluginException($lng->txt(""));
845 }
846
850 protected function afterActivation()
851 {
852 }
853
857 public function deactivate()
858 {
859 global $ilDB;
860
862
863 $result = true;
864
865 $q = "UPDATE il_plugin SET active = " . $ilDB->quote(0, "integer") .
866 " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
867 " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
868 " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
869 " AND name = " . $ilDB->quote($this->getPluginName(), "text");
870
871 $ilDB->manipulate($q);
872 $this->afterDeactivation();
873
874 return $result;
875 }
876
877
881 protected function afterDeactivation()
882 {
883 }
884
885
886 protected function beforeUninstall()
887 {
888 // plugin-specific
889 // false would indicate that anything went wrong
890 return true;
891 }
892
893 final public function uninstall()
894 {
895 global $ilDB;
896
897 if ($this->beforeUninstall()) {
898 // remove all language entries (see ilObjLanguage)
899 // see updateLanguages
900 $prefix = $this->getPrefix();
901 if ($prefix) {
902 $ilDB->manipulate("DELETE FROM lng_data" .
903 " WHERE module = " . $ilDB->quote($prefix, "text"));
904 $ilDB->manipulate("DELETE FROM lng_modules" .
905 " WHERE module = " . $ilDB->quote($prefix, "text"));
906 }
907
908 $this->clearEventListening();
909
910 // db version is kept in il_plugin - will be deleted, too
911
912 $q = "DELETE FROM il_plugin" .
913 " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
914 " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
915 " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
916 " AND name = " . $ilDB->quote($this->getPluginName(), "text");
917 $ilDB->manipulate($q);
918
919 $this->afterUninstall();
920
922 return true;
923 }
924
925 return false;
926 }
927
928 protected function afterUninstall()
929 {
930 // plugin-specific
931 }
932
936 public function update()
937 {
938 global $ilDB, $ilCtrl;
939
941
942 $result = $this->beforeUpdate();
943 if ($result === false) {
944 return false;
945 }
946
947 // DB update
948 if ($result === true) {
949 $result = $this->updateDatabase();
950 }
951
952 // Load language files
953 $this->updateLanguages();
954
955 // load control structure
956 include_once("./setup/classes/class.ilCtrlStructureReader.php");
957 $structure_reader = new ilCtrlStructureReader();
958 $structure_reader->readStructure(
959 true,
960 "./" . $this->getDirectory(),
961 $this->getPrefix(),
962 $this->getDirectory()
963 );
964 // $ilCtrl->storeCommonStructures();
965
966 // add config gui to the ctrl calls
967 $ilCtrl->insertCtrlCalls(
968 "ilobjcomponentsettingsgui",
970 $this->getPrefix()
971 );
972
973 $this->readEventListening();
974
975 // set last update version to current version
976 if ($result === true) {
977 $q = "UPDATE il_plugin SET last_update_version = " . $ilDB->quote($this->getVersion(), "text") .
978 " WHERE component_type = " . $ilDB->quote($this->getComponentType(), "text") .
979 " AND component_name = " . $ilDB->quote($this->getComponentName(), "text") .
980 " AND slot_id = " . $ilDB->quote($this->getSlotId(), "text") .
981 " AND name = " . $ilDB->quote($this->getPluginName(), "text");
982
983 $ilDB->manipulate($q);
984 $this->afterUpdate();
985 }
986
987 return $result;
988 }
989
993 protected function readEventListening()
994 {
996 $this->getDirectory() . '/plugin.xml',
997 $this->getComponentType(),
998 $this->getComponentName(),
999 $this->getSlotId(),
1000 $this->getPluginName()
1001 );
1002 $reader->clearEvents();
1003 $reader->startParsing();
1004 }
1005
1006
1010 protected function clearEventListening()
1011 {
1012 $reader = new ilPluginReader(
1013 $this->getDirectory() . '/plugin.xml',
1014 $this->getComponentType(),
1015 $this->getComponentName(),
1016 $this->getSlotId(),
1017 $this->getPluginName()
1018 );
1019 $reader->clearEvents();
1020 }
1021
1025 protected function beforeUpdate()
1026 {
1027 return true; // false would indicate that anything went wrong
1028 // update would not proceed
1029 // throw an exception in this case
1030 //throw new ilPluginException($lng->txt(""));
1031 }
1032
1036 protected function afterUpdate()
1037 {
1038 }
1039
1048 public static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
1049 {
1050 include_once("./Services/Component/classes/class.ilPluginSlot.php");
1051 $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
1052
1053 $cached_component = ilCachedComponentData::getInstance();
1054 $rec = $cached_component->lookCompId($a_ctype, $a_cname);
1055 if (!$rec) {
1056 return null;
1057 }
1058
1059 $file = "./Customizing/global/plugins/" . $a_ctype . "/" .
1060 $a_cname . "/" . $slot_name . "/" .
1061 $a_pname . "/classes/class.il" . $a_pname . "Plugin.php";
1062
1063 if (is_file($file)) {
1064 include_once($file);
1065 $class = "il" . $a_pname . "Plugin";
1066 $plugin = new $class();
1067 return $plugin;
1068 }
1069
1070 return null;
1071 }
1072
1073
1084 public static function lookupStoredData($a_ctype, $a_cname, $a_slot_id, $a_pname)
1085 {
1086 global $ilDB;
1087
1088 $q = "SELECT * FROM il_plugin WHERE" .
1089 " component_type = " . $ilDB->quote($a_ctype, "text") . " AND" .
1090 " component_name = " . $ilDB->quote($a_cname, "text") . " AND" .
1091 " slot_id = " . $ilDB->quote($a_slot_id, "text") . " AND" .
1092 " name = " . $ilDB->quote($a_pname, "text");
1093
1094 $set = $ilDB->query($q);
1095
1096 if ($ilDB->numRows($set) == 0) {
1097 return array();
1098 }
1099
1100 return $ilDB->fetchAssoc($set);
1101 }
1102
1106 public static function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
1107 {
1108 global $ilPluginAdmin;
1109
1110 $plugins = array();
1111
1112 $cached_component = ilCachedComponentData::getInstance();
1113
1114 $lookupActivePluginsBySlotId = $cached_component->lookupActivePluginsBySlotId($a_slot_id);
1115 foreach ($lookupActivePluginsBySlotId as $rec) {
1116 if ($ilPluginAdmin->isActive($a_ctype, $a_cname, $a_slot_id, $rec["name"])) {
1117 $plugins[] = $rec["name"];
1118 }
1119 }
1120
1121 return $plugins;
1122 }
1123
1131 public static function getActivePluginIdsForSlot($a_ctype, $a_cname, $a_slot_id)
1132 {
1133 global $ilPluginAdmin;
1134
1135 $plugins = array();
1136 $cached_component = ilCachedComponentData::getInstance();
1137 $lookupActivePluginsBySlotId = $cached_component->lookupActivePluginsBySlotId($a_slot_id);
1138 foreach ($lookupActivePluginsBySlotId as $rec) {
1139 if ($ilPluginAdmin->isActive($a_ctype, $a_cname, $a_slot_id, $rec["name"])) {
1140 $plugins[] = $rec["plugin_id"];
1141 }
1142 }
1143
1144 return $plugins;
1145 }
1146
1150 public static function lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
1151 {
1152 global $ilDB;
1153
1154 $q = "SELECT name FROM il_plugin " .
1155 " WHERE component_type = " . $ilDB->quote($a_ctype, "text") .
1156 " AND component_name = " . $ilDB->quote($a_cname, "text") .
1157 " AND slot_id = " . $ilDB->quote($a_slot_id, "text") .
1158 " AND plugin_id = " . $ilDB->quote($a_plugin_id, "text");
1159
1160 $set = $ilDB->query($q);
1161 if ($rec = $ilDB->fetchAssoc($set)) {
1162 return $rec["name"];
1163 }
1164 }
1165
1169 public static function lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
1170 {
1171 global $ilDB;
1172
1173 $q = "SELECT plugin_id FROM il_plugin " .
1174 " WHERE component_type = " . $ilDB->quote($a_ctype, "text") .
1175 " AND component_name = " . $ilDB->quote($a_cname, "text") .
1176 " AND slot_id = " . $ilDB->quote($a_slot_id, "text") .
1177 " AND name = " . $ilDB->quote($a_plugin_name, "text");
1178
1179 $set = $ilDB->query($q);
1180 if ($rec = $ilDB->fetchAssoc($set)) {
1181 return $rec["plugin_id"];
1182 }
1183 }
1184}
$result
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
static lookupId($a_type, $a_name)
Lookup ID of a component.
Class ilCtrlStructureReader.
static getInstalledLanguages()
Get the language objects of the installed languages.
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
static getRepoPluginObjectByType($type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin.
Database Update class.
Class ilPluginReader.
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
static _getPluginsDirectory($a_ctype, $a_cname, $a_slot_id)
Get plugins directory.
static createPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
setIliasMinVersion($a_iliasminversion)
Set Required ILIAS min.
getDBVersion()
Get DB Version.
static getAvailableLangFiles($a_lang_directory)
Get array of all language files in the plugin.
setSlotObject($a_slot)
Set Plugin Slot.
writeDBVersion($a_dbversion)
Write DB version to database.
needsUpdate()
Check whether update is needed.
getTablePrefix()
Get db table plugin prefix.
afterActivation()
After activation processing.
readEventListening()
Read the event listening definitions from the plugin.xml (if file exists)
updateLanguages($a_lang_keys=null)
static getDBUpdateScriptName($a_ctype, $a_cname, $a_slot_name, $a_pname)
Get DB update script filename (full path)
includeClass($a_class_file_name)
Include (once) a class file.
activate()
Activate.
isActive()
Check whether plugin is active.
getSlotId()
Get Slot ID.
setId($a_id)
Set Id.
getSlotObject()
Get Plugin Slot.
getLastUpdateVersion()
Get Version of last update.
static lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
Lookup id for name.
clearEventListening()
Clear the entries of this plugin in the event handling table.
setLastUpdateVersion($a_lastupdateversion)
Set Version of last update.
addBlockFile($a_tpl, $a_var, $a_block, $a_tplname)
Add template content to placeholder variable.
getLanguageDirectory()
Get Plugin's language Directory.
afterUpdate()
After update processing.
getPrefix()
Get plugin prefix, used for lang vars.
update()
Update plugin.
setActive($a_active)
Set Active.
getVersion()
Get Current Version (from plugin.php file).
afterInstall()
After install processing.
getTemplate($a_template, $a_par1=true, $a_par2=true)
Get template from plugin.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
init()
Object initialization.
getPluginName()
Get Plugin Name.
setDBVersion($a_dbversion)
Set DB Version.
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
static getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get record from il_plugin table.
deactivate()
Deactivate.
getSlot()
Get Slot Name.
getComponentName()
Get Component Name.
static _getImagePath( $a_ctype, $a_cname, $a_slot_id, $a_pname, $a_img)
Get image path.
__init()
Default initialization.
static lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
Lookup name for id.
beforeUpdate()
Before update processing.
static _getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin directory.
getDirectory()
Get Plugin Directory.
getIliasMaxVersion()
Get Required ILIAS max.
getImagePath($a_img)
Get image path.
getIliasMinVersion()
Get Required ILIAS min.
getStyleSheetLocation($a_css_file)
Get css file location.
install()
Install.
getClassesDirectory()
Get Plugin's classes Directory.
static getConfigureClassName($a_name)
Get plugin configure class name.
beforeActivation()
Before activation processing.
loadLanguageModule()
Load language module for plugin.
slotInit()
Object initialization done by slot.
static hasConfigureClass($a_slot_dir, $a_name)
Has the plugin a configure class?
static lookupStoredData($a_ctype, $a_cname, $a_slot_id, $a_pname)
Lookup information data in il_plugin.
setIliasMaxVersion($a_iliasmaxversion)
Set Required ILIAS max.
getId()
Get Id.
txt($a_var)
Get Language Variable (prefix will be prepended automatically)
afterDeactivation()
After deactivation processing.
getComponentType()
Get Component Type.
static langExitsById($pluginId, $langVar)
Is searched lang var available in plugin lang files.
getActive()
Get Active.
setVersion($a_version)
Set Current Version (from plugin.php file).
static getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
Get all active plugin names for a slot.
static getActivePluginIdsForSlot($a_ctype, $a_cname, $a_slot_id)
Get All active plugin ids for a slot.
updateDatabase()
Update database.
special template class to simplify handling of ITX/PEAR
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$lang
Definition: consent.php:3
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$txt
Definition: error.php:11
global $ilCtrl
Definition: ilias.php:18
catch(Exception $e) $message
global $lng
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $ilDB