don't save codeblock if user does not have the rights

Prevents undefined variable $codeblock
#762