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/classes/Model/Service/Plugin/Host.php

101 lines
2.6 KiB
PHP
Raw Permalink Normal View History

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Services
*
2013-03-19 22:35:19 +00:00
* @package Host
* @category Models
* @author Deon George
2013-03-19 22:35:19 +00:00
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Service_Plugin_Host extends Model_Service_Plugin {
protected $_table_name = 'service__hosting';
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
protected $_serialize_column = array(
'server_data_date',
);
// Relationships
protected $_has_one = array(
2012-11-09 23:13:57 +00:00
'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'host_server'=>array('far_key'=>'host_server_id','foreign_key'=>'id'),
);
protected $_belongs_to = array(
'service'=>array(),
);
protected $_display_filters = array(
'domain_name'=>array(
array('strtoupper',array(':value')),
),
'host_expire'=>array(
array('Config::date',array(':value')),
),
);
// Required abstract functions
public function admin_update() {
return '';
}
public function expire() {
return $this->host_expire;
}
public function name() {
2012-11-09 23:13:57 +00:00
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name'));
}
public function service_view() {
return View::factory('service/user/plugin/host/view')
->set('o',$this);
}
public function username_value() {
return $this->host_username;
}
public function password_value() {
return $this->host_password;
}
/**
* This provides us with a manage button to jump to the hosting server
* to manage the domain.
*/
public function manage_button($t='') {
if (! parent::manage_button($t))
return NULL;
2011-12-16 23:31:35 +00:00
// @todo Convert this to a Static_List display
if ($this->service->queue == 'PROVISION')
return _('To Be Provisioned');
2012-07-01 00:18:21 +00:00
return ($this->username_value() AND $this->password_value() AND $a=$this->host_server->plugin()) ? $a->manage_button($this,$t) : '';
}
/**
* Search for services matching a term
*/
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
// We only show domain names.
if (is_numeric($term))
return array();
$ao = Auth::instance()->get_user();
$options['key'] = 'id';
$options['object'] = DB::select($this->_table_name.'.id',$this->_table_name.'.domain_name')
->from($this->_table_name)
->join('service')
->on('service.id','=',$this->_table_name.'.service_id')
->where('service.account_id','IN',$ao->RTM->customers($ao->RTM))
->and_where($this->_table_name.'.domain_name','like','%'.$term.'%');
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
}
}
?>