JTips logo
register
password reminder
loginheader
Quick update: We're back from holiday and are finishing off our latest joomla project, as soon as we do we will be starting work on the new v2 features.
We have some great new features planned and we cant wait to unveil them to you guys. We promise it wont be much longer!
We urge all members to submit any handy tips they might have. JoomlaTips is nothing without community involvement, so please guys - start sharing!
Many new features to be added in phase 2 of the project. Keep an eye on the notice board for our official announcements.
Our forum now has 5 new flavors. Click on the profile link on the forum to set your forum display options. More flavors will be coming soon.
Got a commercial CMT you think would benefit our members? Checkout our sponsors page on more info on how to sign up.
Friday, 21 November 2008
Start arrow discuss
JoomlaTips Discuss / Combining HotProperty and Account Expiration Control

You are not logged in.

Announcement

Quick Tip: You can change you display settings, by logging into your account and clicking on the "profile" link. We have given you 5 simple color schemes to choose from and will be adding some more soon..

#1 2006-02-27 02:38:59

trentdiggity
New member
From: ATL
Registered: 2006-01-31
Posts: 1

Combining HotProperty and Account Expiration Control

I wanted to share with you a Free Component that I have found called Account Expiration Control. AEC is used to charge agents for subscriptions via paypal. There are a few other options out there that do the same sort of thing but i found most to either lack what I was looking for or can be overlycomplex.

Here is a link to the Account Expiration Control Component.
http://forge.joomla.org/sf/projects/accountexp

Helder Garcia, the developer of this component has been a really great help to me through out the process of getting this to work. If you decide to go this route, I ask that you please donate to Helder.

I am going to cover how to use AEC to charge Agents but not the regular registered user. This way you dont have to charge members that are not listing.

Remember to back up all your files before making any changes. I am making this tutorial a few months after completing this process so i'm hoping i havent left anything out.

Install HotProperty and AEC.

After these are installed, you need to apply the Auto Assign Agent hack to the acctexp.php file. (This file is located in components>com_acctexp>) This file is very simular to the file you would normally apply the hack to.

Find

Code:

    $row->id = 0;
    $row->usertype = '';
    $row->gid = $acl->get_group_id('Registered','ARO');

Add this on the line after it.

Code:

    ### START: Add new Agent to Hot Property ###
    $row->gid = $acl->get_group_id('Agent','ARO'); // Edited. - Hot Property (Auto Assign Agent)
    ### End: Add new Agent to Hot Property ###

Find

Code:

$pwd = $row->password;
    $row->password = md5( $row->password );
    $row->registerDate = date("Y-m-d H:i:s");

    if (!$row->store()) {
        echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
        exit();
    }
    $row->checkin();

Add this on the line after it.

Code:

    ### START: Add new Agent to Hot Property ###
    
    include( 'administrator/components/com_hotproperty/config.hotproperty.php' );
    
    // Check if hp_default_company is set
    if ( !is_numeric($hp_default_company) || $hp_default_company <= 0 ) {
        
        // Use the latest company added to the database
        $database->setQuery( "SELECT id FROM #__hp_companies ORDER BY id DESC LIMIT 1" );
        $hp_default_company = $database->loadResult();

    }

    // Get Userid from #__users
    $database->setQuery("SELECT id FROM #__users WHERE username='$row->username' LIMIT 1");
    $userid = $database->loadResult();

    // Insert into #__hp_agents
    $database->setQuery("INSERT INTO #__hp_agents (user, name, email, need_approval, company) VALUES ('$userid', '$row->name', '$row->email', '".(($hp_auto_approve == '1') ? '0':'1')."', '".$hp_default_company."')");
    $database->query();

    ###   END: Add new Agent to Hot Property ###

If you do not want to have 2 seperate user registrations, follow the instructions in the hacks section of the AEC component to complete the installation of AEC.

If you want to have 2 user registrations, one paid and one free. DO NOT follow the hacks section in AEC, instead, continue on.

The Next step is to create a static page.
In the joomla admin select
Content>Static Content Manager
Create a new page, list your description of your two seperate accounts and then include a link to each of them.

Now you will need to link this page to your login module.
Open /modules/mod_login.php

Find

Code:

        if ( $registration_enabled ) {
                ?>
                <tr>
                        <td>
                        <?php echo _NO_ACCOUNT; ?>
                        <a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&task=register' ); ?>">
                        <</a>
                        </td>
                </tr>
                <?php
        }

Replace

index.php?option=com_registration&task=register

With the URL to the static page you have just created.

Edit the file joomla.php (includes/joomla.php)
Find

Code:

require_once( $mosConfig_absolute_path . "/includes/joomla.xml.php" );
    require_once( $mosConfig_absolute_path . '/includes/phpInputFilter/class.inputfilter.php' );

Add this on the line after it.

Code:

    // Hack for integration with Account Expiration Component
    if (file_exists( $mosConfig_absolute_path . "/administrator/components/com_acctexp/includes/login.validate.php" )  ) {
       include_once( $mosConfig_absolute_path . "/administrator/components/com_acctexp/includes/login.validate.php" );
    }
    // End of code for Account Expiration Control Component

Next find

Code:

    function login( $username=null,$passwd=null ) {
        global $acl;

        $usercookie     = mosGetParam( $_COOKIE, 'usercookie', '' );
        $sessioncookie     = mosGetParam( $_COOKIE, 'sessioncookie', '' );
        if (!$username || !$passwd) {
            $username     = mosGetParam( $_POST, 'username', '' );
            $passwd     = mosGetParam( $_POST, 'passwd', '' );
            $passwd     = md5( $passwd );
            $bypost     = 1;
        }
        $remember = mosGetParam( $_POST, 'remember', '' );

        if (!$username || !$passwd) {
            echo "\n";
            exit();
        } else {
            $query = "SELECT *"
            . "\n FROM #__users"
            . "\n WHERE username = '$username'"
            . "\n AND password = '$passwd'"
            ;
            $this->_db->setQuery( $query );
            $row = null;
            if ($this->_db->loadObject( $row )) {
                if ($row->block == 1) {
                    mosErrorAlert(_LOGIN_BLOCKED);

Add this on the line after it.

Code:

                    // Hack for integration with Account Expiration Component
                // check if the user account has not been expired
                // IMPORTANT: Remove this line BEFORE uninstall the component
                loginValidate($username);
                // End of code for Account Expiration Control Component

Ok that should do it. I'll be checking this thread regularly so if something doesnt work right, ask away. depending on the situation/what files you need, i might can send them.

Offline

 

#2 2006-03-06 15:26:43

Chris
Stoker
From: Buenos Aires, Argentina
Registered: 2005-12-01
Posts: 24
Website

Re: Combining HotProperty and Account Expiration Control

Hi Trent,
Thanks for that great tip! We have mostly used mambocharge in the past, but it definately looks like AEC has its place in HP (and other) implementations! I will add your tip to the site as soon as i get a chance..
Thanks again and keep the tips coming!
Regards,
Chris


"Sharing knowledge is not about giving people something, or getting something from them. That is only valid for information sharing. Sharing knowledge occurs when people are genuinely interested in helping one another develop new capacities for action. " - Peter Senge

"You can't get rid of poverty by giving people money."

Offline

 

Board footer

Powered by Punbo, © 2005 Hans Blomme
Based on PunBB, © 2002–2005 Rickard Andersson
 
Sort by Featured Tips Sort by Popular Tips Sort by Most Rated Sort by Top Rated Sort by Most Reviewed