1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Undefined Variable: errorPhraseKey

Discussion in 'XenForo Development Discussions' started by Gossamer, Jun 7, 2014.

  1. Gossamer

    Gossamer Active Member

    I've been making good progress with my add-on, but when trying to check permissions on a delete function, I end up receiving the error below:

    And here is my code.

    ControllerPublic
    PHP:
        public function actionDelete()
        {
            
    $id $this->_input->filterSingle('id'XenForo_Input::UINT);
      
            if (!
    $this->_getReserveModel()->canDeleteReserve($errorPhraseKey))
            {
                throw 
    $this->getErrorOrNoPermissionResponseException($errorPhraseKey);
            }
          
            
    //Create a instance of our DataWriter
            
    $dwReserve XenForo_DataWriter::create('Goss_Reservations_DataWriter_Reserves');
            
    $dwReserve->setExistingData($id);
            
    $dwReserve->delete();
          
            return 
    $this->responseRedirect(
                        
    XenForo_ControllerResponse_Redirect::SUCCESS,
                        
    $this->getDynamicRedirect()
                    );
        }
    Model
    PHP:
        public function canDeleteReserve(array $ViewingUser null, &$errorPhraseKey '', array $nodePermissions null)
        {
            
    $this->standardizeViewingUserReference($viewingUser);
          
            if(!
    $viewingUser['user_id'])
            {
                return 
    false;
            }
          
            if(!
    XenForo_Permission::hasPermission($viewingUser['permissions'], 'Reserves''deleteReserve'))
            {
                return 
    false;
            }
            else
            {
                return 
    true;
            }
        }
     
    Last edited: Jun 7, 2014
  2. Syndol

    Syndol Guest

    Your function canDeleteReserve() has $ViewingUser as the first parameter but you are calling it with the $errorPhraseKey as the first parameter instead of the second.
    Also noticed that you are using $nodePermissions as a parameter but do not actually use it inside the function. Is your permission a general one or node specific?

    Edit:
    Also, $ViewingUser should be $viewingUser
     
    Last edited by a moderator: Jun 7, 2014
    Gossamer likes this.
  3. Gossamer

    Gossamer Active Member

    Thanks! Switching the order fixed it.

    And for the permission, it's a general permission. It's not node specific.
     
    Syndol likes this.

Share This Page