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/Controller/Admin/Host.php

78 lines
2.0 KiB
PHP
Raw Normal View History

2013-10-10 02:44:53 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Host Server functions
*
* @package Host
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Host extends Controller_TemplateDefault_Admin {
protected $secure_actions = array(
'ajaxmanage'=>TRUE,
'list'=>TRUE,
'update'=>TRUE,
);
public function action_ajaxmanage() {
$hso = ORM::factory('Host_Server',$this->request->param('id'));
$k = Session::instance()->get_once('manage_button');
$o = array(
'u'=>$hso->manage_username ? $hso->manage_username : strtolower($hso->name),
'p'=>(! $k OR ! $this->request->is_ajax() OR ! $hso->loaded() OR $k != $this->request->query('k')) ? Random::char() : $hso->manage_password,
2013-10-10 02:44:53 +00:00
);
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode($o));
}
/**
* Show a list of hosting servers
*/
public function action_list() {
Block::add(array(
'title'=>_('Customer Services'),
'body'=>Table::display(
ORM::factory('Host_Server')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>URL::link('admin','host/update/')),
'name'=>array('label'=>'Details'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>URL::link('admin','host/update'),
)),
));
}
public function action_update() {
$hso = ORM::factory('Host_Server',$this->request->param('id'));
$output = '';
if (! $hso->loaded())
HTTP::redirect('welcome/index');
if ($this->request->post()) {
$hso->values($this->request->post());
2013-10-10 02:44:53 +00:00
if ($hso->changed() AND ! $hso->save())
throw new Kohana_Exception('Unable to save record?');
}
$output .= View::factory($this->viewpath())
->set('hso',$hso)
->set('plugin_form',$hso->admin_update());
Block::add(array(
'title'=>sprintf('%s %s:%s',_('Update Host Server'),$hso->id,$hso->name),
'body'=>$output,
));
}
}
?>