/** * This method is called, when the widget should generate it's content. * Return the complete content using the methods provided by the base class. * Do NOT use the toolkit right here! * * @return string */ public function getWidgetOutput() { $strReturn = ""; if (!class_module_system_module::getModuleByName("packagemanager")->rightEdit()) { return $this->getLang("commons_error_permissions"); } $objManager = new class_module_packagemanager_manager(); $arrRemotePackages = $objManager->scanForUpdates(); $strSystemVersion = "n.a."; if (isset($arrRemotePackages["system"])) { $strSystemVersion = $arrRemotePackages["system"]; } $arrUpdates = array(); $arrLocalPackages = $objManager->getAvailablePackages(); foreach ($arrLocalPackages as $objOneMetadata) { if (isset($arrRemotePackages[$objOneMetadata->getStrTitle()])) { if ($arrRemotePackages[$objOneMetadata->getStrTitle()] != null && version_compare($arrRemotePackages[$objOneMetadata->getStrTitle()], $objOneMetadata->getStrVersion(), ">")) { $arrUpdates[$objOneMetadata->getStrTitle()] = $arrRemotePackages[$objOneMetadata->getStrTitle()]; } } } $strReturn .= $this->widgetText($this->getLang("sysinfo_kajona_version") . " " . class_module_system_module::getModuleByName("system")->getStrVersion()); $strReturn .= $this->widgetText($this->getLang("sysinfo_kajona_versionAvail") . " " . $strSystemVersion); $strReturn .= $this->widgetSeparator(); if (count($arrUpdates) > 0) { $strReturn .= $this->widgetText($this->getLang("updatecheck_versionAvail")); } foreach ($arrUpdates as $strPackage => $intVersion) { $strReturn .= $this->widgetText(class_link::getLinkAdmin("packagemanager", "list", "&packagelist_filter=" . $strPackage . "&doFilter=1", $strPackage . " (" . $intVersion . ")")); } return $strReturn; }
/** * Checks if an update is available for a list of packages. * Renders the matching icon and tooltip or the link to update a package. * * @xml * @permissions view,edit * @return string */ protected function actionGetUpdateIcons() { $strPackages = $this->getParam("packages"); $arrPackagesToCheck = explode(",", $strPackages); $objManager = new class_module_packagemanager_manager(); //close session to avoid blocking $this->objSession->sessionClose(); $arrLatestVersion = $objManager->scanForUpdates(); $arrReturn = array(); foreach ($arrPackagesToCheck as $strOnePackage) { $objMetadata = $objManager->getPackage($strOnePackage); if ($objMetadata == null || !isset($arrLatestVersion[$strOnePackage])) { $arrReturn[$strOnePackage] = class_adminskin_helper::getAdminImage("icon_updateError", $this->getLang("package_noversion")); continue; } $objHandler = $objManager->getPackageManagerForPath($objMetadata->getStrPath()); $bitUpdateAvailable = $objManager->updateAvailable($objHandler, $arrLatestVersion[$strOnePackage]); if ($bitUpdateAvailable === null) { $arrReturn[$strOnePackage] = class_adminskin_helper::getAdminImage("icon_updateError", $this->getLang("package_noversion")); } else { //compare the version to trigger additional actions $strLatestVersion = $arrLatestVersion[$strOnePackage]; if ($bitUpdateAvailable) { $arrReturn[$strOnePackage] = class_link::getLinkAdminDialog($this->getArrModule("modul"), "initPackageUpdate", "&package=" . $objHandler->getObjMetadata()->getStrPath(), $this->getLang("package_updatefound") . " " . $strLatestVersion, $this->getLang("package_updatefound") . " " . $strLatestVersion, "icon_update", $objHandler->getObjMetadata()->getStrTitle()); } else { $arrReturn[$strOnePackage] = class_adminskin_helper::getAdminImage("icon_updateDisabled", $this->getLang("package_noupdate") . " " . $strLatestVersion); } } } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return json_encode($arrReturn); }