function for unpublishing and publishing a job