/** * constructor */ function ilPluginDBUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname, $a_db_handler, $tmp_flag, $a_db_prefix) { $this->db_prefix = $a_db_prefix; // workaround to allow setup migration if ($a_db_handler) { $this->db =& $a_db_handler; if ($tmp_flag) { $this->PATH = "./"; } else { $this->PATH = "../"; } } else { global $mySetup; $this->db = $mySetup->db; $this->PATH = "./"; } $this->ctype = $a_ctype; $this->cname = $a_cname; $this->slot_id = $a_slot_id; $this->pname = $a_pname; include_once "./Services/Component/classes/class.ilPluginSlot.php"; $this->slot_name = ilPluginSlot::lookupSlotName($this->ctype, $this->cname, $this->slot_id); $this->getCurrentVersion(); // get update file for current version $updatefile = $this->getFileForStep($this->currentVersion + 1); $this->current_file = $updatefile; $this->DB_UPDATE_FILE = $this->PATH . ilPlugin::getDBUpdateScriptName($this->ctype, $this->cname, $this->slot_name, $this->pname); // // NOTE: multiple update files for plugins are not supported yet // $this->LAST_UPDATE_FILE = $this->PATH . ilPlugin::getDBUpdateScriptName($this->ctype, $this->cname, $this->slot_name, $this->pname); $this->readDBUpdateFile(); $this->readLastUpdateFile(); $this->readFileVersion(); }
/** * Get plugins directory */ function _getPluginsDirectory($a_ctype, $a_cname, $a_slot_id) { return "./Customizing/global/plugins/" . $a_ctype . "/" . $a_cname . "/" . ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id); }
function showPlugin() { global $ilCtrl, $ilTabs, $lng, $tpl, $ilDB, $ilToolbar; if (!$_GET["ctype"] || !$_GET["cname"] || !$_GET["slot_id"] || !$_GET["plugin_id"]) { $ilCtrl->redirect($this, "listPlugins"); } include_once "./Services/Component/classes/class.ilPluginSlot.php"; $slot = new ilPluginSlot($_GET["ctype"], $_GET["cname"], $_GET["slot_id"]); $plugin = null; foreach ($slot->getPluginsInformation() as $item) { if ($item["id"] == $_GET["plugin_id"]) { $plugin = $item; break; } } if (!$plugin) { $ilCtrl->redirect($this, "listPlugins"); } $ilTabs->clearTargets(); $ilTabs->setBackTarget($lng->txt("cmps_plugins"), $ilCtrl->getLinkTarget($this, "listPlugins")); $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]); $ilCtrl->setParameter($this, "cname", $_GET["cname"]); $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]); $ilCtrl->setParameter($this, "plugin_id", $_GET["plugin_id"]); $ilCtrl->setParameter($this, "pname", $plugin["name"]); $langs = ilPlugin::getAvailableLangFiles($slot->getPluginsDirectory() . "/" . $plugin["name"] . "/lang"); // dbupdate $file = ilPlugin::getDBUpdateScriptName($_GET["ctype"], $_GET["cname"], ilPluginSlot::lookupSlotName($_GET["ctype"], $_GET["cname"], $_GET["slot_id"]), $plugin["name"]); $db_curr = $db_file = null; if (@is_file($file)) { include_once "./Services/Component/classes/class.ilPluginDBUpdate.php"; $dbupdate = new ilPluginDBUpdate($_GET["ctype"], $_GET["cname"], $_GET["slot_id"], $plugin["name"], $ilDB, true, ""); $db_curr = $dbupdate->getCurrentVersion(); $db_file = $dbupdate->getFileVersion(); /* update command if ($db_file > $db_curr) { $ilToolbar->addButton($lng->txt("cmps_update_db"), $ilCtrl->getLinkTarget($this, "updatePluginDB")); } */ } // toolbar actions if ($plugin["activation_possible"]) { $ilToolbar->addButton($lng->txt("cmps_activate"), $ilCtrl->getLinkTarget($this, "activatePlugin")); } // deactivation/refresh languages button if ($plugin["is_active"]) { // refresh languages button if (count($langs) > 0) { $ilToolbar->addButton($lng->txt("cmps_refresh"), $ilCtrl->getLinkTarget($this, "refreshLanguages")); } // configure button if (ilPlugin::hasConfigureClass($slot->getPluginsDirectory(), $plugin["name"]) && $ilCtrl->checkTargetClass(ilPlugin::getConfigureClassName($plugin["name"]))) { $ilToolbar->addButton($lng->txt("cmps_configure"), $ilCtrl->getLinkTargetByClass(strtolower(ilPlugin::getConfigureClassName($plugin["name"])), "configure")); } // deactivate button $ilToolbar->addButton($lng->txt("cmps_deactivate"), $ilCtrl->getLinkTarget($this, "deactivatePlugin")); } // update button if ($plugin["needs_update"]) { $ilToolbar->addButton($lng->txt("cmps_update"), $ilCtrl->getLinkTarget($this, "updatePlugin")); } // info $resp = array(); if (strlen($plugin["responsible"])) { $responsibles = explode('/', $plugin["responsible_mail"]); foreach ($responsibles as $responsible) { if (!strlen($responsible = trim($responsible))) { continue; } $resp[] = $responsible; } $resp = $plugin["responsible"] . " (" . implode(" / ", $resp) . ")"; } if ($plugin["is_active"]) { $status = $lng->txt("cmps_active"); } else { $r = $status["inactive_reason"] != "" ? " (" . $status["inactive_reason"] . ")" : ""; $status = $lng->txt("cmps_inactive") . $r; } $info[""][$lng->txt("cmps_name")] = $plugin["name"]; $info[""][$lng->txt("cmps_id")] = $plugin["id"]; $info[""][$lng->txt("cmps_version")] = $plugin["version"]; if ($resp) { $info[""][$lng->txt("cmps_responsible")] = $resp; } $info[""][$lng->txt("cmps_ilias_min_version")] = $plugin["ilias_min_version"]; $info[""][$lng->txt("cmps_ilias_max_version")] = $plugin["ilias_max_version"]; $info[""][$lng->txt("cmps_status")] = $status; if (sizeof($langs)) { $lang_files = array(); foreach ($langs as $lang) { $lang_files[] = $lang["file"]; } $info[""][$lng->txt("cmps_languages")] = implode(", ", $lang_files); } else { $info[""][$lng->txt("cmps_languages")] = $lng->txt("cmps_no_language_file_available"); } $info[$lng->txt("cmps_basic_files")]["plugin.php"] = $plugin["plugin_php_file_status"] ? $lng->txt("cmps_available") : $lng->txt("cmps_missing"); $info[$lng->txt("cmps_basic_files")][$lng->txt("cmps_class_file")] = ($plugin["class_file_status"] ? $lng->txt("cmps_available") : $lng->txt("cmps_missing")) . " (" . $plugin["class_file"] . ")"; if (!$db_file) { $info[$lng->txt("cmps_database")][$lng->txt("file")] = $lng->txt("cmps_no_db_update_file_available"); } else { $info[$lng->txt("cmps_database")][$lng->txt("file")] = "dbupdate.php"; $info[$lng->txt("cmps_database")][$lng->txt("cmps_current_version")] = $db_curr; $info[$lng->txt("cmps_database")][$lng->txt("cmps_file_version")] = $db_file; } include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setTitle($lng->txt("cmps_plugin")); foreach ($info as $section => $items) { if (trim($section)) { $sec = new ilFormSectionHeaderGUI(); $sec->setTitle($section); $form->addItem($sec); } foreach ($items as $key => $value) { $non = new ilNonEditableValueGUI($key); $non->setValue($value); $form->addItem($non); } } $tpl->setContent($form->getHTML()); }
/** * Get plugin object. * * @param string $a_ctype IL_COMP_MODULE | IL_COMP_SERVICE * @param string $a_cname component name * @param string $a_sname plugin slot name * @param string $a_pname plugin name */ static final function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname) { global $ilDB; include_once "./Services/Component/classes/class.ilPluginSlot.php"; $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id); $cached_component = ilCachedComponentData::getInstance(); $rec = $cached_component->lookCompId($a_ctype, $a_cname); if (!$rec) { return NULL; } // this check is done due to security reasons // $set = $ilDB->queryF("SELECT * FROM il_component WHERE type = %s ". // " AND name = %s", array("text", "text"), // array($a_ctype, $a_cname)); // if (!$ilDB->fetchAssoc($set)) // { // return null; // } $file = "./Customizing/global/plugins/" . $a_ctype . "/" . $a_cname . "/" . $slot_name . "/" . $a_pname . "/classes/class.il" . $a_pname . "Plugin.php"; if (is_file($file)) { include_once $file; $class = "il" . $a_pname . "Plugin"; $plugin = new $class(); return $plugin; } return null; }
/** * Standard Version of Fill Row. Most likely to * be overwritten by derived class. */ protected function fillRow($a_set) { global $lng, $ilCtrl, $ilDB; $ilCtrl->setParameter($this->parent_obj, "ctype", $_GET["ctype"]); $ilCtrl->setParameter($this->parent_obj, "cname", $_GET["cname"]); $ilCtrl->setParameter($this->parent_obj, "slot_id", $_GET["slot_id"]); $ilCtrl->setParameter($this->parent_obj, "pname", $a_set["name"]); // dbupdate $file = ilPlugin::getDBUpdateScriptName($_GET["ctype"], $_GET["cname"], ilPluginSlot::lookupSlotName($_GET["ctype"], $_GET["cname"], $_GET["slot_id"]), $a_set["name"]); if (@is_file($file)) { include_once "./Services/Component/classes/class.ilPluginDBUpdate.php"; $dbupdate = new ilPluginDBUpdate($_GET["ctype"], $_GET["cname"], $_GET["slot_id"], $a_set["name"], $ilDB, true, ""); // update command /* if ($dbupdate->getFileVersion() > $dbupdate->getCurrentVersion()) { $this->tpl->setCurrentBlock("db_update_cmd"); $this->tpl->setVariable("TXT_UPDATE_DB", $lng->txt("cmps_update_db")); $this->tpl->setVariable("HREF_UPDATE_DB", $ilCtrl->getLinkTarget($this->parent_obj, "updatePluginDB")); $this->tpl->parseCurrentBlock(); } */ // db version $this->tpl->setCurrentBlock("db_versions"); $this->tpl->setVariable("TXT_CURRENT_VERSION", $lng->txt("cmps_current_version")); $this->tpl->setVariable("VAL_CURRENT_VERSION", $dbupdate->getCurrentVersion()); $this->tpl->setVariable("TXT_FILE_VERSION", $lng->txt("cmps_file_version")); $this->tpl->setVariable("VAL_FILE_VERSION", $dbupdate->getFileVersion()); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("db_update"); $this->tpl->setVariable("DB_UPDATE_FILE", "dbupdate.php"); } else { $this->tpl->setCurrentBlock("db_update"); $this->tpl->setVariable("DB_UPDATE_FILE", $lng->txt("cmps_no_db_update_file_available")); } $this->tpl->parseCurrentBlock(); // language files $langs = ilPlugin::getAvailableLangFiles($this->slot->getPluginsDirectory() . "/" . $a_set["name"] . "/lang"); if (count($langs) == 0) { $this->tpl->setCurrentBlock("lang"); $this->tpl->setVariable("VAL_LANG_FILE", $lng->txt("cmps_no_language_file_available")); $this->tpl->parseCurrentBlock(); } foreach ($langs as $lang) { $this->tpl->setCurrentBlock("lang"); $this->tpl->setVariable("VAL_LANG_FILE", $lang["file"]); $this->tpl->parseCurrentBlock(); } // activation button if ($a_set["activation_possible"]) { $this->tpl->setCurrentBlock("activate"); $this->tpl->setVariable("HREF_ACTIVATE", $ilCtrl->getLinkTarget($this->parent_obj, "activatePlugin")); $this->tpl->setVariable("TXT_ACTIVATE", $lng->txt("cmps_activate")); $this->tpl->parseCurrentBlock(); } // deactivation/refresh languages button if ($a_set["is_active"]) { // deactivate button $this->tpl->setCurrentBlock("deactivate"); $this->tpl->setVariable("HREF_DEACTIVATE", $ilCtrl->getLinkTarget($this->parent_obj, "deactivatePlugin")); $this->tpl->setVariable("TXT_DEACTIVATE", $lng->txt("cmps_deactivate")); $this->tpl->parseCurrentBlock(); // refresh languages button if (count($langs) > 0) { $this->tpl->setCurrentBlock("refresh_langs"); $this->tpl->setVariable("HREF_REFRESH_LANGS", $ilCtrl->getLinkTarget($this->parent_obj, "refreshLanguages")); $this->tpl->setVariable("TXT_REFRESH_LANGS", $lng->txt("cmps_refresh")); $this->tpl->parseCurrentBlock(); } // configure button if (ilPlugin::hasConfigureClass($this->slot->getPluginsDirectory(), $a_set["name"]) && $ilCtrl->checkTargetClass(ilPlugin::getConfigureClassName($a_set["name"]))) { $this->tpl->setCurrentBlock("configure"); $this->tpl->setVariable("HREF_CONFIGURE", $ilCtrl->getLinkTargetByClass(strtolower(ilPlugin::getConfigureClassName($a_set["name"])), "configure")); $this->tpl->setVariable("TXT_CONFIGURE", $lng->txt("cmps_configure")); $this->tpl->parseCurrentBlock(); } } // update button if ($a_set["needs_update"]) { $this->tpl->setCurrentBlock("update"); $this->tpl->setVariable("HREF_UPDATE", $ilCtrl->getLinkTarget($this->parent_obj, "updatePlugin")); $this->tpl->setVariable("TXT_UPDATE", $lng->txt("cmps_update")); $this->tpl->parseCurrentBlock(); } if (strlen($a_set["responsible"])) { $responsibles = explode('/', $a_set["responsible_mail"]); $first_handled = false; foreach ($responsibles as $responsible) { if (!strlen($responsible = trim($responsible))) { continue; } if ($first_handled) { $this->tpl->touchBlock('plugin_responsible_sep'); } $this->tpl->setCurrentBlock("plugin_responsible"); $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE_MAIL", $responsible); $this->tpl->parseCurrentBlock(); $first_handled = true; } $this->tpl->setCurrentBlock("responsible_mail"); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("responsible"); $this->tpl->setVariable("TXT_RESPONSIBLE", $lng->txt("cmps_responsible")); $this->tpl->setVariable("VAL_PLUGIN_RESPONSIBLE", $a_set["responsible"]); $this->tpl->parseCurrentBlock(); } $this->tpl->setVariable("VAL_PLUGIN_NAME", $a_set["name"]); $this->tpl->setVariable("VAL_PLUGIN_ID", $a_set["id"]); $this->tpl->setVariable("TXT_PLUGIN_NAME", $lng->txt("cmps_name")); $this->tpl->setVariable("TXT_PLUGIN_ID", $lng->txt("cmps_id")); $this->tpl->setVariable("TXT_PLUGIN_VERSION", $lng->txt("cmps_version")); $this->tpl->setVariable("TXT_PHP_FILE", "plugin.php"); $this->tpl->setVariable("TXT_CLASS_FILE", $lng->txt("cmps_class_file")); $this->tpl->setVariable("VAL_CLASS_FILE", $a_set["class_file"]); $this->tpl->setVariable("TXT_VERSION", $lng->txt("cmps_version")); $this->tpl->setVariable("VAL_PLUGIN_VERSION", $a_set["version"]); $this->tpl->setVariable("TXT_ILIAS_MIN", $lng->txt("cmps_ilias_min_version")); $this->tpl->setVariable("VAL_ILIAS_MIN", $a_set["ilias_min_version"]); $this->tpl->setVariable("TXT_ILIAS_MAX", $lng->txt("cmps_ilias_max_version")); $this->tpl->setVariable("VAL_ILIAS_MAX", $a_set["ilias_max_version"]); $this->tpl->setVariable("TXT_STATUS", $lng->txt("cmps_status")); if ($a_set["is_active"]) { $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_active")); } else { $r = $a_set["inactive_reason"] != "" ? " (" . $a_set["inactive_reason"] . ")" : ""; $this->tpl->setVariable("VAL_STATUS", $lng->txt("cmps_inactive") . $r); } if ($a_set["plugin_php_file_status"]) { $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_available")); } else { $this->tpl->setVariable("VAL_PLUGIN_PHP_FILE_STATUS", $lng->txt("cmps_missing")); } if ($a_set["class_file_status"]) { $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_available")); } else { $this->tpl->setVariable("VAL_CLASS_FILE_STATUS", $lng->txt("cmps_missing")); } }
/** * Get basic data of plugin from plugin.php * * @param string $a_ctype Component Type * @param string $a_cname Component Name * @param string $a_slot_id Slot ID * @param string $a_pname Plugin Name */ private final function getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname) { global $ilDB, $lng; if (!isset($this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname])) { include_once "./Services/Component/classes/class.ilPluginSlot.php"; $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id); $plugin_php_file = "./Customizing/global/plugins/" . $a_ctype . "/" . $a_cname . "/" . $slot_name . "/" . $a_pname . "/plugin.php"; $rec = ilPlugin::getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname); if (is_file($plugin_php_file)) { include_once $plugin_php_file; $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = array("version" => $version, "id" => $id, "ilias_min_version" => $ilias_min_version, "ilias_max_version" => $ilias_max_version, "responsible" => $responsible, "responsible_mail" => $responsible_mail, "learning_progress" => (bool) $learning_progress); } $active = $rec["active"]; $needs_update = false; $activation_possible = !$active; $inactive_reason = ""; // version checks if (ilComponent::isVersionGreaterString($ilias_min_version, ILIAS_VERSION_NUMERIC)) { $active = false; if (is_object($lng)) { $inactive_reason = $lng->txt("cmps_needs_newer_ilias_version"); } else { $inactive_reason = "Plugin needs a newer version of ILIAS."; } $activation_possible = false; } else { if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, $ilias_max_version)) { $active = false; if (is_object($lng)) { $inactive_reason = $lng->txt("cmps_needs_newer_plugin_version"); } else { $inactive_reason = "Plugin does not support current version of ILIAS. Newer version of plugin needed."; } $activation_possible = false; } else { if ($rec["last_update_version"] == "") { $active = false; if (is_object($lng)) { $inactive_reason = $lng->txt("cmps_needs_update"); } else { $inactive_reason = "Update needed."; } $needs_update = true; $activation_possible = false; } else { if (ilComponent::isVersionGreaterString($rec["last_update_version"], $version)) { $active = false; if (is_object($lng)) { $inactive_reason = $lng->txt("cmps_needs_upgrade"); } else { $inactive_reason = "Upgrade needed."; } $activation_possible = false; } else { if ($rec["last_update_version"] != $version) { $active = false; if (is_object($lng)) { $inactive_reason = $lng->txt("cmps_needs_update"); } else { $inactive_reason = "Update needed."; } $needs_update = true; $activation_possible = false; } } } } } $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"] = $active; $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["inactive_reason"] = $inactive_reason; $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"] = $needs_update; $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["activation_possible"] = $activation_possible; $this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = true; } }