2013-10-10 02:44:53 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class supports Services
|
|
|
|
*
|
|
|
|
* @package Host
|
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
|
|
|
* @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(
|
2013-11-28 06:41:34 +00:00
|
|
|
'host'=>array('model'=>'Host_Server','far_key'=>'host_server_id','foreign_key'=>'id'),
|
|
|
|
'tld'=>array('model'=>'Domain_TLD','foreign_key'=>'id','far_key'=>'domain_tld_id'),
|
2013-10-10 02:44:53 +00:00
|
|
|
);
|
|
|
|
protected $_belongs_to = array(
|
|
|
|
'service'=>array(),
|
|
|
|
);
|
|
|
|
|
|
|
|
protected $_display_filters = array(
|
|
|
|
'domain_name'=>array(
|
|
|
|
array('strtoupper',array(':value')),
|
|
|
|
),
|
|
|
|
'host_expire'=>array(
|
2014-08-25 04:41:07 +00:00
|
|
|
array('Site::Date',array(':value')),
|
2013-10-10 02:44:53 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2013-11-28 06:41:34 +00:00
|
|
|
protected $_save_message = TRUE;
|
|
|
|
|
2016-08-10 06:07:00 +00:00
|
|
|
/** REQUIRED ABSTRACT METHODS **/
|
|
|
|
|
|
|
|
public function attributes($variable=NULL) {}
|
2013-10-10 02:44:53 +00:00
|
|
|
|
|
|
|
public function expire() {
|
|
|
|
return $this->host_expire;
|
|
|
|
}
|
2013-11-28 06:41:34 +00:00
|
|
|
|
|
|
|
public function password() {
|
|
|
|
return $this->host_password;
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 06:41:34 +00:00
|
|
|
public function username() {
|
|
|
|
return $this->host_username;
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 06:07:00 +00:00
|
|
|
/** LOCAL METHODS **/
|
2013-11-28 06:41:34 +00:00
|
|
|
|
2013-10-10 02:44:53 +00:00
|
|
|
/**
|
|
|
|
* This provides us with a manage button to jump to the hosting server
|
|
|
|
* to manage the domain.
|
|
|
|
*/
|
|
|
|
public function manage_button($t='') {
|
|
|
|
// @todo Convert this to a Static_List display
|
|
|
|
if ($this->service->queue == 'PROVISION')
|
|
|
|
return _('To Be Provisioned');
|
|
|
|
|
2013-11-28 06:41:34 +00:00
|
|
|
if (! parent::manage($t))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ($this->username() AND $this->password() AND $a=$this->host->plugin()) ? $a->manage_button($this,$t) : '';
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
2013-05-08 09:00:47 +00:00
|
|
|
|
2016-08-10 06:07:00 +00:00
|
|
|
public function name($variable=NULL) {
|
|
|
|
return sprintf('%s.%s',$this->display('domain_name'),$this->tld->display('name'));
|
|
|
|
}
|
|
|
|
|
2013-05-08 09:00:47 +00:00
|
|
|
/**
|
|
|
|
* Search for services matching a term
|
|
|
|
*/
|
2016-08-03 04:00:51 +00:00
|
|
|
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
2013-05-08 09:00:47 +00:00
|
|
|
// 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))
|
2016-08-03 04:00:51 +00:00
|
|
|
->and_where('service.status','=',1)
|
2013-05-08 09:00:47 +00:00
|
|
|
->and_where($this->_table_name.'.domain_name','like','%'.$term.'%');
|
|
|
|
|
|
|
|
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
|
|
|
}
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
?>
|