/** * Replaces values for given type and object. * * @param \wcf\data\acl\option\ACLOptionList $optionList * @param string $type * @param integer $objectID */ protected function replaceValues(ACLOptionList $optionList, $type, $objectID) { $options = $optionList->getObjects(); // remove previous values $conditions = new PreparedStatementConditionBuilder(); $conditions->add("optionID IN (?)", array(array_keys($options))); $conditions->add("objectID = ?", array($objectID)); $sql = "DELETE FROM\twcf" . WCF_N . "_acl_option_to_" . $type . "\n\t\t\t" . $conditions; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); // add new values if given if (!isset($_POST['aclValues']) || !isset($_POST['aclValues'][$type])) { return; } $sql = "INSERT INTO\twcf" . WCF_N . "_acl_option_to_" . $type . "\n\t\t\t\t\t(optionID, objectID, " . $type . "ID, optionValue)\n\t\t\tVALUES\t\t(?, ?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); $values =& $_POST['aclValues'][$type]; WCF::getDB()->beginTransaction(); foreach ($values as $typeID => $optionData) { foreach ($optionData as $optionID => $optionValue) { // ignore invalid option ids if (!isset($options[$optionID])) { continue; } $statement->execute(array($optionID, $objectID, $typeID, $optionValue)); } } WCF::getDB()->commitTransaction(); }