Internal overhaul

This commit is contained in:
Deon George
2013-11-28 17:41:34 +11:00
parent 0ed5e5163d
commit f8a5b153cf
91 changed files with 1570 additions and 1619 deletions

View File

@@ -13,6 +13,10 @@ abstract class Model_Service_Plugin extends ORM_OSB {
// Reset any sorting that may be defined in our parent
protected $_sorting = array();
protected $_belongs_to = array(
'service'=>array(),
);
/**
* When does our service expire
*/
@@ -26,56 +30,43 @@ abstract class Model_Service_Plugin extends ORM_OSB {
/**
* The table attributes that provide username/password values
*/
abstract public function password_value();
abstract public function username_value();
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/
public function _details($type) {
switch ($type) {
// Nothing to add for invoices
case 'invoice_detail_items':
return array();
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
abstract public function password();
abstract public function username();
/**
* Provide the button that launches the management of this service, generally from a 3rd party
*/
public function manage_button() {
protected function manage() {
// Dont show the manage button for expired or inactive services
if (! $this->service->status OR $this->service->expiring())
return FALSE;
static $k = '';
static $x = '';
// If $k is already set, we've rendered this JS
if ($k)
return TRUE;
// If $x is already set, we've rendered this JS
if (! $x) {
$x = Random::char();
$k = Random::char();
Session::instance()->set('manage_button',$k);
Session::instance()->set('manage_button',$x);
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
var x=0;
$("button[name=submit]").click(function() {
var t=$(this).val().split(":");
if (x++) { alert("Session expired, please refresh the page!"); return false; }
$.getJSON("'.URL::link('user','service/ajaxmanage/'.$this->service_id,TRUE).'", { k: "'.$k.'",t: t[1] }, function(data) {
$.each(data, function(key, val) { $("#"+key+"_"+t[0]+"_"+t[1]).val(val); });
}).error(function() { alert("There was a problem with the request"); return false; }).success(
function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
});
});'
));
Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
var x=0;
$("button[name=submit]").click(function() {
var t=$(this).val().split(":");
if (x++) { alert("Session expired, please refresh the page!"); return false; }
$.getJSON("'.URL::link('user','service/ajaxmanage/'.$this->service_id,TRUE).'", { k: "'.$x.'",t: t[1] },
function(data) {$.each(data, function(key, val) { $("#"+key+"_"+t[0]+"_"+t[1]).val(val); }); })
.error(function() { alert("There was a problem with the request"); return false; })
.success(function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
});
});'
);
}
return TRUE;
}
@@ -109,5 +100,23 @@ function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
public function service_name() {
return sprintf('%s - %s',$this->service->product->title(),$this->name());
}
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/
public function _details($type) {
switch ($type) {
// Nothing to add for invoices
case 'invoice_detail_items':
return array();
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
}
?>