I tried commenting out the lines 54 and 55 and everything seems to be ok. I even tried to move photos to different albums owned by the same user and I could, what were you trying to do ("Just can't move photos to different albums until the rest of the code is fixed")?
the write_p and album_write_p are set in the xql page so I don't see where the problem is, or am I missing someting?