Creating a new page in ActiveCollab 3

Just created a new page in ActiveCollab 3. I wanted a new ipn (Instant Payment Notifications) handler page for paypal recurring payments. The name of my new module is PaypalRecurring.

Here are the simple steps to created a new view page in AC3.

I wanted to create URL: http://yourhost.com/index.php?path_info=ppr/capture

In the PaypalRecurringModule.class.php add a new route in defineRoutes() function like the following:

[php]function defineRoutes() {
Router::map(‘paypal_recurring_capture’, ‘ppr/capture’, array(‘controller’ => ‘paypal_recurring’, ‘action’ => ‘ipn_capture’));
}[/php]

In short it means that i will be creating a new action named ipn_capture in my paypal_recurring/controllers/PaypalRecurringController.class.php file and the name/identifier of this map is paypal_recurring_capture. In turn, it can be invoked by passing the http://yourhost.com/index.php?path_info=ppr/capture in the browser address bar. As taken from an example at AC3 documentation website i will include a function to fetch all projects by an user, just to show how functionality can be added to the controller and be displayed in the subsequent view files.

[php]// Build on top of payments module
AngieApplication::useController(‘payments’, PAYMENTS_FRAMEWORK_INJECT_INTO);

/**
* Paypal Recurring controller implementation
*/
class PaypalRecurringController extends PaymentsController{

/**
* Capture action
*/
function ipn_capture() {
//do something here.. php variables for smarty view files can be set here.
$this->response->assign(array(
‘projects’ => Projects::findActiveByUser($this->logged_user)
));
}
}[/php]

In the ipn_capture function of the PaypalRecurringController more functionality can be added. PHP variables for smarty view files can be set here as shown in the example above.

[php]{title}My Projects{/title}
{add_bread_crumb}My Projects{/add_bread_crumb}

{if $projects}
<table class="common" cellspacing="0">
<thead>
<tr>
<th>{lang}Project{/lang}</th>
<th>{lang}Leader{/lang}</th>
<th>{lang}Cost so Far{/lang}</th>
</tr>
</thead>
<tbody>
{foreach $projects as $project}
<tr>
<td>{project_link project=$project}</td>
<td>{user_link user=$project->getLeader()}</td>
<td>{$project->getCostSoFar($logged_user)|money:$project->getCurrency()}</td>
</tr>
{/foreach}
</tbody>
</table>
{else}
<p class="empty_page">{lang}No projects loaded{/lang}</p>
{/if}[/php]

Finally this page’s result can be viewed at http://yourhost.com/index.php?path_info=ppr/capture in browser

Leave a Reply