2011-09-28 06:46:22 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class supports Services
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package Domain
|
2011-09-28 06:46:22 +00:00
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
2011-09-28 06:46:22 +00:00
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2013-01-10 11:25:19 +00:00
|
|
|
class Model_Service_Plugin_Domain extends Model_Service_Plugin {
|
2011-09-28 06:46:22 +00:00
|
|
|
protected $_table_name = 'service__domain';
|
|
|
|
protected $_updated_column = FALSE;
|
|
|
|
|
|
|
|
// Relationships
|
|
|
|
protected $_has_one = array(
|
2012-11-09 23:13:57 +00:00
|
|
|
'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
|
2011-09-28 06:46:22 +00:00
|
|
|
'domain_registrar'=>array('foreign_key'=>'id','far_key'=>'domain_registrar_id'),
|
2013-01-10 11:25:19 +00:00
|
|
|
'service_plugin_host'=>array('through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'),
|
2011-09-28 06:46:22 +00:00
|
|
|
);
|
|
|
|
protected $_belongs_to = array(
|
|
|
|
'service'=>array(),
|
|
|
|
);
|
|
|
|
|
|
|
|
protected $_display_filters = array(
|
|
|
|
'domain_expire'=>array(
|
|
|
|
array('Config::date',array(':value')),
|
|
|
|
),
|
|
|
|
'domain_name'=>array(
|
|
|
|
array('strtoupper',array(':value')),
|
|
|
|
),
|
|
|
|
'registrar_lastsync'=>array(
|
|
|
|
array('Config::date',array(':value')),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Required abstract functions
|
2011-12-29 02:52:24 +00:00
|
|
|
public function admin_update() {
|
|
|
|
return '';
|
2011-09-28 06:46:22 +00:00
|
|
|
}
|
|
|
|
|
2012-10-08 12:52:21 +00:00
|
|
|
public function expire() {
|
|
|
|
return $this->domain_expire;
|
|
|
|
}
|
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
public function name() {
|
2012-11-09 23:13:57 +00:00
|
|
|
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name'));
|
2011-09-28 06:46:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function service_name() {
|
|
|
|
return sprintf('%s - %s',_('Domain Name License'),$this->name());
|
|
|
|
}
|
|
|
|
|
2011-12-29 02:52:24 +00:00
|
|
|
public function service_view() {
|
|
|
|
return View::factory('service/user/plugin/domain/view')
|
2013-06-04 11:50:41 +00:00
|
|
|
->set('o',$this);
|
2011-09-28 06:46:22 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 05:12:59 +00:00
|
|
|
public function username_value() {
|
|
|
|
return $this->registrar_username;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function password_value() {
|
|
|
|
return $this->registrar_password;
|
|
|
|
}
|
|
|
|
|
2011-09-28 06:46:22 +00:00
|
|
|
/**
|
|
|
|
* This provides us with a manage button to jump to the registrar
|
|
|
|
* to manage the domain.
|
|
|
|
*/
|
2012-06-22 05:12:59 +00:00
|
|
|
public function manage_button($t='') {
|
2012-10-22 12:24:28 +00:00
|
|
|
if (! parent::manage_button($t))
|
|
|
|
return NULL;
|
2012-06-22 05:12:59 +00:00
|
|
|
|
|
|
|
return ($this->username_value() AND $this->password_value()) ? $this->domain_registrar->manage_button($this,$t) : _('Please contact us');
|
2011-09-28 06:46:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function manage_dns_button() {
|
2013-01-10 11:25:19 +00:00
|
|
|
return $this->service_plugin_host->manage_button('service_plugin_host');
|
2011-09-28 06:46:22 +00:00
|
|
|
}
|
2013-05-08 09:00:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
2011-09-28 06:46:22 +00:00
|
|
|
}
|
|
|
|
?>
|