This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/host_registrar_plugin/host_registrar_plugin.inc.php
2011-05-03 09:49:01 +10:00

170 lines
4.0 KiB
PHP

<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Module:HostRegistrarPlugin
*/
/**
* The main AgileBill Host Registrar Plugin Class
*
* @package AgileBill
* @subpackage Module:HostRegistrarPlugin
*/
class host_registrar_plugin extends OSB_module {
##############################
## SEARCH ##
##############################
function search($VAR)
{
### Read the contents of the /plugins/affiliate directory:
$count = 0;
chdir(PATH_PLUGINS . 'registrar');
$dir = opendir(PATH_PLUGINS . 'registrar');
while ($file_name = readdir($dir))
{
if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name))
{
$count++;
}
}
# define the DB vars as a Smarty accessible block
global $smarty;
# create the search record:
if($count > 0)
{
# create the search record
include_once(PATH_CORE . 'search.inc.php');
$search = new CORE_search;
$arr['module'] = $this->module;
$arr['sql'] = '';
$arr['limit'] = '999';
$arr['order_by']= 'name';
$arr['results'] = $count;
$search->add($arr);
# define the search id and other parameters for Smarty
$smarty->assign('search_id', $search->id);
# page:
$smarty->assign('page', '1');
# limit:
$smarty->assign('limit', '999');
# order_by:
$smarty->assign('order_by', 'name');
# define the result count
$smarty->assign('results', $count);
}
}
##############################
## SEARCH SHOW ##
##############################
function search_show($VAR)
{
### Read the contents of the /plugins/db_mapping directory:
$count = 0;
chdir(PATH_PLUGINS . 'registrar');
$dir = opendir(PATH_PLUGINS . 'registrar');
while ($file_name = readdir($dir))
{
if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name) )
{
$result[$count]['name'] = eregi_replace('.php', '', $file_name);
$result[$count]['id'] = $count;
### Get the status of this plugin:
$db = &DB();
$q = 'SELECT status,id FROM '.AGILE_DB_PREFIX.'host_registrar_plugin WHERE
file = '. $db->qstr($result[$count]['name']) . ' AND
site_id = '. $db->qstr(DEFAULT_SITE);
$dbmap = $db->Execute($q);
### error reporting:
if ($dbmap === false)
{
global $C_debug;
$C_debug->error('affiliate_plugin.inc.php','search_show', $db->ErrorMsg()); return;
}
if($dbmap->RecordCount() > 0)
{
$result[$count]['id'] = $dbmap->fields['id'];
$result[$count]['status'] = 1;
$result[$count]['active'] = $dbmap->fields['status'];
}
else
{
$result[$count]['status'] = 0;
}
$count++;
}
}
$class_name = TRUE;
for ($i=0; $i<count($result); $i++)
{
$smart[$i] = $result[$i];
if($class_name)
{
$smart[$i]['_C'] = 'row1';
$class_name = FALSE;
} else {
$smart[$i]['_C'] = 'row2';
$class_name = TRUE;
}
}
# define the DB vars as a Smarty accessible block
global $smarty;
# define the results
$smarty->assign($this->table, $smart);
$smarty->assign('page', $VAR['page']);
$smarty->assign('order', $smarty_order);
$smarty->assign('sort', $smarty_sort);
$smarty->assign('limit', $search->limit);
$smarty->assign('search_id',$search->id);
$smarty->assign('results', $count);
# total pages
$smarty->assign('pages', 1);
# current page
$smarty->assign('page', 1);
$page_arr = '';
# page array for menu
$smarty->assign('page_arr', $page_arr);
}
}
?>