public function testChangelog() { $this->flushDBCache(); $objChanges = new class_module_system_changelog(); $strSystemid = generateSystemid(); $arrOldValues = $objChanges->readOldValues(new dummyObject($strSystemid)); $this->assertEquals($arrOldValues["strTest"], "old"); $this->assertEquals($arrOldValues["strSecondTest"], "second old"); $arrOldValues = $objChanges->getOldValuesForSystemid($strSystemid); $this->assertEquals($arrOldValues["strTest"], "old"); $this->assertEquals($arrOldValues["strSecondTest"], "second old"); $objChanges->createLogEntry(new dummyObject($strSystemid), "1"); $objChanges->processCachedInserts(); $this->assertEquals(0, class_module_system_changelog::getLogEntriesCount($strSystemid)); class_carrier::getInstance()->getObjDB()->flushQueryCache(); $objDummy = new dummyObject($strSystemid); $objDummy->setStrTest("new test 1"); $objDummy->setStrSecondTest("new val 2"); $objChanges->createLogEntry($objDummy, "2"); $objChanges->processCachedInserts(); $this->assertEquals(2, class_module_system_changelog::getLogEntriesCount($strSystemid)); $this->assertEquals(2, count(class_module_system_changelog::getLogEntries($strSystemid))); $arrLogs = class_module_system_changelog::getLogEntries($strSystemid); foreach ($arrLogs as $objOneChangelog) { if ($objOneChangelog->getStrProperty() == "strTest") { $this->assertEquals($objOneChangelog->getStrOldValue(), "old"); $this->assertEquals($objOneChangelog->getStrNewValue(), "new test 1"); } if ($objOneChangelog->getStrProperty() == "strSecondTest") { $this->assertEquals($objOneChangelog->getStrOldValue(), "second old"); $this->assertEquals($objOneChangelog->getStrNewValue(), "new val 2"); } } class_carrier::getInstance()->getObjDB()->flushQueryCache(); $objChanges->createLogEntry(new dummyObject($strSystemid), "2", true); $objChanges->processCachedInserts(); $this->assertEquals(4, class_module_system_changelog::getLogEntriesCount($strSystemid)); $this->assertEquals(4, count(class_module_system_changelog::getLogEntries($strSystemid))); }
/** * Renders the list of changes for the passed systemrecord. * May be called from other modules in order to get the rendered list for a single record. * In most cases rendered as a overlay, so in folderview mode * * @param string $strSystemid sytemid to filter * @param string $strSourceModule source-module, required for a working pageview * @param string $strSourceAction source-action, required for a working pageview * @param bool $bitBlockFolderview * * @return string * @since 3.4.0 * @autoTestable * @permissions changelog */ public function actionGenericChangelog($strSystemid = "", $strSourceModule = "system", $strSourceAction = "genericChangelog", $bitBlockFolderview = false) { if (!$bitBlockFolderview && $this->getParam("bitBlockFolderview") == "") { $this->setArrModuleEntry("template", "/folderview.tpl"); } if ($strSystemid == "") { $strSystemid = $this->getSystemid(); } if (!validateSystemid($strSystemid) && $this->getObjModule()->rightChangelog()) { $strReturn = $this->objToolkit->warningBox($this->getLang("generic_changelog_no_systemid")); $strReturn .= $this->objToolkit->formHeader(getLinkAdminHref("system", "genericChangeLog", "bitBlockFolderview=1")); $strReturn .= $this->objToolkit->formInputText("systemid", "systemid"); $strReturn .= $this->objToolkit->formInputSubmit(); $strReturn .= $this->objToolkit->formClose(); return $strReturn; // return "asd"; } $strReturn = ""; // check needed rights - done twice since public and callable by not only the controller // if(!class_carrier::getInstance()->getObjRights()->validatePermissionString(class_rights::$STR_RIGHT_CHANGELOG, $this->getObjModule())) // return $this->getLang("commons_error_permissions"); //showing a list using the pageview $objArraySectionIterator = new class_array_section_iterator(class_module_system_changelog::getLogEntriesCount($strSystemid)); $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1)); $objArraySectionIterator->setArraySection(class_module_system_changelog::getLogEntries($strSystemid, $objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos())); $arrData = array(); $arrHeader = array(); $arrHeader[] = $this->getLang("commons_date"); $arrHeader[] = $this->getLang("change_user"); if ($strSystemid == "") { $arrHeader[] = $this->getLang("change_module"); } if ($strSystemid == "") { $arrHeader[] = $this->getLang("change_record"); } $arrHeader[] = $this->getLang("change_action"); $arrHeader[] = $this->getLang("change_property"); $arrHeader[] = $this->getLang("change_oldvalue"); $arrHeader[] = $this->getLang("change_newvalue"); /** @var $objOneEntry class_changelog_container */ foreach ($objArraySectionIterator as $objOneEntry) { $arrRowData = array(); /** @var interface_versionable|class_model $objTarget */ $objTarget = $objOneEntry->getObjTarget(); $strOldValue = $objOneEntry->getStrOldValue(); $strNewValue = $objOneEntry->getStrNewValue(); if ($objTarget != null) { $strOldValue = $objTarget->renderVersionValue($objOneEntry->getStrProperty(), $strOldValue); $strNewValue = $objTarget->renderVersionValue($objOneEntry->getStrProperty(), $strNewValue); } $strOldValue = htmlStripTags($strOldValue); $strNewValue = htmlStripTags($strNewValue); $arrRowData[] = dateToString($objOneEntry->getObjDate()); $arrRowData[] = $this->objToolkit->getTooltipText(uniStrTrim($objOneEntry->getStrUsername(), 15), $objOneEntry->getStrUsername()); if ($strSystemid == "") { $arrRowData[] = $objTarget != null ? $objTarget->getArrModule("modul") : ""; } if ($strSystemid == "") { $arrRowData[] = $objTarget != null ? $this->objToolkit->getTooltipText(uniStrTrim($objTarget->getVersionRecordName(), 20), $objTarget->getVersionRecordName() . " " . $objOneEntry->getStrSystemid()) : ""; } $arrRowData[] = $objTarget != null ? $this->objToolkit->getTooltipText(uniStrTrim($objTarget->getVersionActionName($objOneEntry->getStrAction()), 15), $objTarget->getVersionActionName($objOneEntry->getStrAction())) : ""; $arrRowData[] = $objTarget != null ? $this->objToolkit->getTooltipText(uniStrTrim($objTarget->getVersionPropertyName($objOneEntry->getStrProperty()), 20), $objTarget->getVersionPropertyName($objOneEntry->getStrProperty())) : ""; $arrRowData[] = $this->objToolkit->getTooltipText(uniStrTrim($strOldValue, 20), $strOldValue); $arrRowData[] = $this->objToolkit->getTooltipText(uniStrTrim($strNewValue, 20), $strNewValue); $arrData[] = $arrRowData; } $objManager = new class_module_packagemanager_manager(); if ($objManager->getPackage("phpexcel") != null) { $strReturn .= $this->objToolkit->getContentToolbar(array(class_link::getLinkAdmin($this->getArrModule("modul"), "genericChangelogExportExcel", "&systemid=" . $strSystemid, class_adminskin_helper::getAdminImage("icon_excel") . " " . $this->getLang("change_export_excel"), "", "", false))); } $strReturn .= $this->objToolkit->dataTable($arrHeader, $arrData); $strReturn .= $this->objToolkit->getPageview($objArraySectionIterator, $strSourceModule, $strSourceAction, "&systemid=" . $strSystemid . "&bitBlockFolderview=" . $this->getParam("bitBlockFolderview")); return $strReturn; }