Correct. You can't have one button do two totally different things like that.
The proper way to do this is to tell the user 'If they have called you through the intercom, dial when you're in the call 00 to unlock the door. Otherwise push the button on your phone'.