public function testChangelogArrayHandling() { $arrOld = array(1, 2, 3, 4, 5); $arrNew = array(3, 4, 5, 6, 7); $arrChanges = array(array("property" => "testArray", "oldvalue" => $arrOld, "newvalue" => $arrNew)); $strSystemid = generateSystemid(); $objDummy = new dummyObject($strSystemid); $objChanges = new class_module_system_changelog(); $this->assertEquals(0, class_module_system_changelog::getLogEntriesCount($strSystemid)); $objChanges->processChanges($objDummy, "arrayTest", $arrChanges); $objChanges->processCachedInserts(); $this->flushDBCache(); $this->assertEquals(class_module_system_changelog::getLogEntriesCount($strSystemid), 4); $arrChanges = class_module_system_changelog::getSpecificEntries($strSystemid, "arrayTest", "testArray"); $this->assertEquals(4, count($arrChanges)); foreach ($arrChanges as $objOneChangeSet) { if ($objOneChangeSet->getStrOldValue() != "") { $this->assertTrue(in_array($objOneChangeSet->getStrOldValue(), array(1, 2))); } if ($objOneChangeSet->getStrNewValue() != "") { $this->assertTrue(in_array($objOneChangeSet->getStrNewValue(), array(6, 7))); } } }
/** * Writes rights to the database. * Wrapper to the recursive function class_rights::setRightsRecursive($arrRights, $strSystemid) * * @param mixed $arrRights * @param string $strSystemid * * @see setRightsRecursive($arrRights, $strSystemid) * @throws class_exception * @return bool */ public function setRights($arrRights, $strSystemid) { //start a new tx $this->flushRightsCache(); $this->objDb->transactionBegin(); $objInstance = class_objectfactory::getInstance()->getObject($strSystemid); if ($objInstance !== null && $objInstance instanceof interface_versionable) { $arrCurrPermissions = $this->getPlainRightRow($strSystemid); //create a changehistory entry $objLog = new class_module_system_changelog(); $arrChanges = array(array("property" => "rightInherit", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_INHERIT], "newvalue" => $arrRights[self::$STR_RIGHT_INHERIT]), array("property" => "rightView", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_VIEW], "newvalue" => $arrRights[self::$STR_RIGHT_VIEW]), array("property" => "rightEdit", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_EDIT], "newvalue" => $arrRights[self::$STR_RIGHT_EDIT]), array("property" => "rightDelete", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_DELETE], "newvalue" => $arrRights[self::$STR_RIGHT_DELETE]), array("property" => "rightRight", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT]), array("property" => "rightRight1", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT1], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT1]), array("property" => "rightRight2", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT2], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT2]), array("property" => "rightRight3", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT3], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT3]), array("property" => "rightRight4", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT4], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT4]), array("property" => "rightRight5", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_RIGHT5], "newvalue" => $arrRights[self::$STR_RIGHT_RIGHT5]), array("property" => "rightChangelog", "oldvalue" => $arrCurrPermissions[self::$STR_RIGHT_CHANGELOG], "newvalue" => $arrRights[self::$STR_RIGHT_CHANGELOG])); $objLog->processChanges($objInstance, "editPermissions", $arrChanges); } $bitSave = $this->setRightsRecursive($arrRights, $strSystemid); if ($bitSave) { $this->objDb->transactionCommit(); class_logger::getInstance()->addLogRow("saving rights of record " . $strSystemid . " succeeded", class_logger::$levelInfo); } else { $this->objDb->transactionRollback(); class_logger::getInstance()->addLogRow("saving rights of record " . $strSystemid . " failed", class_logger::$levelError); throw new class_exception("saving rights of record " . $strSystemid . " failed", class_exception::$level_ERROR); } return $bitSave; }