original_string: public function cancel($userId, $code)
      {
          $this->loadModel('User.Users');
          $user = $this->Users
              ->find()
              ->where(['id' => $userId])
              ->contain(['Roles'])
              ->limit(1)
              ->first();
  
          if (in_array(ROLE_ID_ADMINISTRATOR, $user->role_ids) &&
              $this->Users->countAdministrators() === 1
          ) {
              $this->Flash->warning(__d('user', 'You are the last administrator in the system, your account cannot be canceled.'));
              $this->redirect($this->referer());
          }
  
          if ($user && $code == $user->cancel_code) {
              if ($this->Users->delete($user)) {
                  NotificationManager::canceled($user)->send();
                  $this->Flash->success(__d('user', 'Account successfully canceled'));
              } else {
                  $this->Flash->danger(__d('user', 'Account could not be canceled due to an internal error, please try again later.'));
              }
          } else {
              $this->Flash->warning(__d('user', 'Not user was found, invalid cancellation URL.'));
          }
  
          $this->title(__d('user', 'Account Cancellation'));
          $this->redirect($this->referer());
      }
code: public function cancel($userId, $code)
      {
          $this->loadModel('User.Users');
          $user = $this->Users
              ->find()
              ->where(['id' => $userId])
              ->contain(['Roles'])
              ->limit(1)
              ->first();
  
          if (in_array(ROLE_ID_ADMINISTRATOR, $user->role_ids) &&
              $this->Users->countAdministrators() === 1
          ) {
              $this->Flash->warning(__d('user', 'You are the last administrator in the system, your account cannot be canceled.'));
              $this->redirect($this->referer());
          }
  
          if ($user && $code == $user->cancel_code) {
              if ($this->Users->delete($user)) {
                  NotificationManager::canceled($user)->send();
                  $this->Flash->success(__d('user', 'Account successfully canceled'));
              } else {
                  $this->Flash->danger(__d('user', 'Account could not be canceled due to an internal error, please try again later.'));
              }
          } else {
              $this->Flash->warning(__d('user', 'Not user was found, invalid cancellation URL.'));
          }
  
          $this->title(__d('user', 'Account Cancellation'));
          $this->redirect($this->referer());
      }
code_tokens: public function cancel ( $ userId , $ code ) { $ this -> loadModel ( 'User.Users' ) ; $ user = $ this -> Users -> find ( ) -> where ( [ 'id' => $ userId ] ) -> contain ( [ 'Roles' ] ) -> limit ( 1 ) -> first ( ) ; if ( in_array ( ROLE_ID_ADMINISTRATOR , $ user -> role_ids ) && $ this -> Users -> countAdministrators ( ) === 1 ) { $ this -> Flash -> warning ( __d ( 'user' , 'You are the last administrator in the system, your account cannot be canceled.' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; } if ( $ user && $ code == $ user -> cancel_code ) { if ( $ this -> Users -> delete ( $ user ) ) { NotificationManager :: canceled ( $ user ) -> send ( ) ; $ this -> Flash -> success ( __d ( 'user' , 'Account successfully canceled' ) ) ; } else { $ this -> Flash -> danger ( __d ( 'user' , 'Account could not be canceled due to an internal error, please try again later.' ) ) ; } } else { $ this -> Flash -> warning ( __d ( 'user' , 'Not user was found, invalid cancellation URL.' ) ) ; } $ this -> title ( __d ( 'user' , 'Account Cancellation' ) ) ; $ this -> redirect ( $ this -> referer ( ) ) ; }
docstring: Here is where user's account is actually removed.
  
  @param int $userId The ID of the user whose account is being canceled
  @param string $code Cancellation code, code is a MD5 hash of user's encrypted
  password + site's salt
  @return void Redirects to previous page
docstring_tokens: Here is where user s account is actually removed .