/**
  * Sets the user up as a new staff user
  *
  * @param \Gems_User_User $user
  * @param string $password
  */
 protected function makeNewStaffUser(\Gems_User_User $user, $password)
 {
     $staff_id = $user->getUserId();
     $sql = 'SELECT gul_id_user FROM gems__user_logins WHERE gul_can_login = 1 AND gul_login = ? AND gul_id_organization = ?';
     try {
         $user_id = $this->db->fetchOne($sql, array($user->getLoginName(), $user->getBaseOrganizationId()));
         $currentTimestamp = new \MUtil_Db_Expr_CurrentTimestamp();
         // Move to USER_STAFF
         $values['gup_id_user'] = $user_id;
         $values['gup_password'] = $this->hashNewPassword($password);
         $values['gup_reset_key'] = null;
         $values['gup_reset_requested'] = null;
         $values['gup_reset_required'] = 0;
         $values['gup_changed'] = $currentTimestamp;
         $values['gup_changed_by'] = $staff_id;
         $values['gup_created'] = $currentTimestamp;
         $values['gup_created_by'] = $staff_id;
         $this->db->insert('gems__user_passwords', $values);
         // Update user class
         $values = array();
         $values['gul_user_class'] = \Gems_User_UserLoader::USER_STAFF;
         $values['gul_changed'] = $currentTimestamp;
         $values['gul_changed_by'] = $staff_id;
         $this->db->update('gems__user_logins', $values, $this->db->quoteInto('gul_id_user = ?', $user_id));
         // Remove old password
         $values = array();
         $values['gsf_password'] = null;
         $values['gsf_changed'] = $currentTimestamp;
         $values['gsf_changed_by'] = $user_id;
         $this->db->update('gems__staff', $values, $this->db->quoteInto('gsf_id_user = ?', $staff_id));
         $user->refresh(\Gems_User_UserLoader::USER_STAFF);
     } catch (\Zend_Db_Exception $e) {
         \GemsEscort::getInstance()->logger->log($e->getMessage(), \Zend_Log::ERR);
         // Fall through as this does not work if the database upgrade did not run
         // \MUtil_Echo::r($e);
     }
 }