$type)); } } /** * Form info for admins to update */ public function admin_update() { return View::factory(sprintf('service/admin/plugin/%s/edit',$this->plugin())) ->set('o',$this); } /** * Provide the button that launches the management of this service, generally from a 3rd party */ public function manage_button() { if (! $this->service->status OR $this->service->expiring()) return FALSE; static $k = ''; // If $k is already set, we've rendered this JS if ($k) return TRUE; $k = Random::char(); Session::instance()->set('manage_button',$k); 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(); }); }); });' )); return TRUE; } /** * Return the name of the plugin */ protected function plugin() { return strtolower(preg_replace('/(.*)_([a-zA-Z]+)$/',"$2",get_class($this))); } /** * Show our service name as defined in the DB with product suffix. */ public function service_name() { return sprintf('%s - %s',$this->service->product->title(),$this->name()); } /** * View details of the service */ public function service_view() { return View::factory(sprintf('service/user/plugin/%s/view',$this->plugin())) ->set('o',$this); } } ?>