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

Event listener and class name

Discussion in 'XenForo Development Discussions' started by Vince Taglia, Jun 19, 2013.

  1. Vince Taglia

    Vince Taglia Member

    2 questions. I am currently making a plugin that will extend the user upgrades and send an RCON command to the server specified. I am currently listening to class XenForo_UserUpgradeProcessor_PayPal (or at least I am trying to) . I am using the load_class_controller listener. Am I using the right listener for what I am trying to do? Also for that listener it says:
    My class name is
    Code:
    RconUpgrade_ControllerPublic_RconUpgrade
    so for the class line I put
    Code:
    class RconUpgrade_ControllerPublic_RconUpgrade extends XFCP_RconUpgrade_ControllerPublic_RconUpgrade
    Am I doing that right? I always thought it would be
    Code:
    class My_Class_Name extends Class_Being_Extended_Name
    And finally am I calling my options correctly? Ex:
    Code:
    $rcon_ip = XenForo_Application::get('options')->rcon_ip;
    rcon_ip is the id for the option

    The code below is what I am using to test the extension and see if I am calling my options correctly.
    Code:
    <?php
        class RconUpgrade_ControllerPublic_RconUpgrade extends XFCP_RconUpgrade_ControllerPublic_RconUpgrade
        {
            $rcon_ip = XenForo_Application::get('options')->rcon_ip;
            $rcon_port = XenForo_Application::get('options')->rcon_port;
            $rcon_password = XenForo_Application::get('options')->rcon_password;
            $rcon_command1 = XenForo_Application::get('options')->rcon_command;
            $colon = ":";
            $enter = "\n";
            $File = "Test.txt"; 
            $Handle = fopen($File, 'w'); 
            fwrite($Handle, $rcon_ip);
            fwrite($Handle, $colon);
            fwrite($Handle, $rcon_port);
            fwrite($Handle, $enter);
            fwrite($Handle, $rcon_password);
            fwrite($Handle, $enter);
            fwrite($Handle, $rcon_command1);
            fclose($Handle);
        }
       
    
    ?>
    
    I go through an upgrade and if the file "Test.txt" has the info I told it to wright the extension and the option calling is correct. Thanks in advance!
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. Vince Taglia

    Vince Taglia Member

    Thank you so much. That helped a lot. I just want to be clear about the calling of options. You have your calling of the db
    Code:
    $db = XenForo_Application::get('db');
    I have mine:
    Code:
    $rcon_ip = XenForo_Application::get('options')->rcon_ip;
    Which is correct for calling options? Or is yours not calling an Add-On Option? Because I cannot find options for your plugin.
    Basically... If I want to call the option id 'rcon_ip' from my application options how do you do it?

    Edit: Oh I see now that you are calling the actual xenforo db. So am I calling my options correctly then?
     
    Last edited: Jun 20, 2013
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yep.
     

Share This Page