/** * Updates the simple role data * @param NsmRole $role * @param AgaviRequestDataHolder $rd * @return boolean * @author Marius Hein */ public function updateRoleData(NsmRole &$role, AgaviRequestDataHolder &$rd) { AppKitDoctrineUtil::updateRecordsetFromArray($role, $rd->getParameters(), self::$editableAttributes); // Checking the principal if (!$role->NsmPrincipal->principal_id) { $role->NsmPrincipal->principal_type = NsmPrincipal::TYPE_ROLE; } if ($role->role_id === null) { // insert a new role $role->save(); } else { // update role $parts = array(); $params = array(); foreach ($role as $property => $value) { if ($property == "role_id" || !in_array($property, self::$editableAttributes)) { continue; } if ($value === null) { $parts[] = "{$property} = NULL"; } else { $parts[] = "{$property} = ? "; $params[] = $value; } } $params[] = $role->role_id; $dql = "UPDATE NsmRole SET " . implode(",", $parts) . " WHERE role_id = ?"; AppKitLogger::warn("Test: %s - %s", $dql, var_export($params, true)); $query = new Doctrine_Query(); $query->setConnection(AppKitDoctrineUtil::getConnection()); $query->parseDqlQuery($dql); $query->execute($params); } return true; }