- if ( $new_obj_type ne $obj_type ) {
- ($val, $msg ) = $obj->SetObjectType($new_obj_type);
- push @results, loc ('Unable to set privacy object: [_1]', $msg) unless ( $val );
+
+ # we need to check right before we change any of ObjectType and ObjectId,
+ # or it will fail the 2nd change if we use SetObjectType and
+ # SetObjectId sequentially
+
+ if ( $obj->CurrentUserHasRight('update') ) {
+ if ( $new_obj_type ne $obj_type ) {
+ ( $val, $msg ) = $obj->__Set(
+ Field => 'ObjectType',
+ Value => $new_obj_type,
+ );
+ push @results, loc( 'Unable to set privacy object: [_1]', $msg )
+ unless ($val);
+ }
+ if ( $new_obj_id != $obj_id ) {
+ ( $val, $msg ) = $obj->__Set(
+ Field => 'ObjectId',
+ Value => $new_obj_id,
+ );
+ push @results, loc( 'Unable to set privacy id: [_1]', $msg )
+ unless ($val);
+ }