Admin Plugin Maker

Discussion in 'Integration' started by scheibanet, Jun 5, 2012.

  1. scheibanet

    scheibanet New Member

    Joined:
    Apr 13, 2011
    Messages:
    7
    Hi,
    i tried the Plugin Maker and have a problem.
    I just want to put the username und password from a member into a second mysql database.
    I thought i can use the admin-plugin-maker script to do that quit easily but its not working.
    I dont have much knowledge about php and amember v4 so i hope somebody can help me.
    So here is the code i get from the plugin maker script:

    PHP:
    <?php
    /**
    * Freeradius Integration Plugin
    * Checklist (mark tested items with x):
    * [x] - template generated
    * [ ] - go to aMember Cp -> Setup -> Plugins and enable this plugin
    * [ ] - test user creation
    * try to create user in aMember and add access manually.
    * Login to Freeradius and check that
    * that corresponding user appeared in users list and all necessary
    * fields transferred
    * [ ] - test password generation: login to freeradius as the new user
    * [ ] - update user record in amember and try to login and view profile in the script
    * [ ] - implement single-login
    *
    **/
    class Am_Protect_Freeradius extends Am_Protect_Databased
    {
    const 
    PLUGIN_DATE '$Date$';
    const 
    PLUGIN_REVISION '@@VERSION@@';
     
    protected 
    $guessTablePattern "radcheck";
    protected 
    $guessFieldsPattern = array(
    'username','value',
    );
    protected 
    $groupMode Am_Protect_Databased::GROUP_NONE;
     
    public function 
    afterAddConfigItems(Am_Form_Setup_ProtectDatabased $form)
    {
    parent::afterAddConfigItems($form);
    // additional configuration items for the plugin may be inserted here
    }
     
    public function 
    getPasswordFormat()
    {
    return 
    SavedPassTable::PASSWORD_PLAIN;
    }
     
    /**
    * Return record of customer currently logged-in to the
    * third-party script, or null if not found or not logged-in
    * @return Am_Record|null
    */
    public function getLoggedInRecord()
    {
    // for single-login must return
    }
     
    public function 
    loginUser(Am_Record $record$password)
    {
    // login user to third-party script
    }
    public function 
    logoutUser(User $user)
    {
    // logout user from third-party script
    }
     
    public function 
    createTable()
    {
    $table = new Am_Protect_Table($this$this->getDb(), '?_radcheck''id');
    $table->setFieldsMapping(array(
    array(
    Am_Protect_Table::FIELD_LOGIN'username'),
    array(
    Am_Protect_Table::FIELD_PASS'value'),
     
    ));
     
    return 
    $table;
    }
     
    function 
    getReadme()
    {
    return <<<CUT
    freeradius README
     
    CUT;
    }
    }
     
     
    I can enable the script and the database connection test is ok but when i try to add a user in amember nothing happened in the second database. Hope somebody can help.
    thx Sven
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Sven,
    Have you enabled integration for your plugin? aMember CP -> Protect Content -> Integrations?
  3. scheibanet

    scheibanet New Member

    Joined:
    Apr 13, 2011
    Messages:
    7
    Ah ok, i missed that.
    Now when a user sign up and pay i have the information in my second database. but when the subscription runs out the record stays in the second database. only when i delete the user in amember i get rid of the user in the second database. isnt it working out of the box? Can you help me with the code please?

Share This Page