Added Add Node capability

This commit is contained in:
Deon George
2014-10-28 16:33:15 +11:00
parent 83a2c85a25
commit 80c8971a46
11 changed files with 218 additions and 7 deletions

View File

@@ -0,0 +1,5 @@
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Node extends Controller_TemplateDefault {
protected $auth_required = TRUE;
}

View File

@@ -0,0 +1,61 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User with a TSM node functions
*
* @package TSM Access Management
* @category Controllers/User
* @author Deon George
* @copyright (c) 2009-2013 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_User_Node extends Controller_Node {
protected $secure_actions = array(
'add'=>0,
'view'=>0,
);
private function node_name($i) {
return sprintf('%s%02d',$this->ao->id(),$i);
}
public function action_add() {
if ($this->request->post()) {
$n = ORM::factory('NODE')->where('EMAIL_ADDRESS','=',$this->ao->email)->find_all();
if (FALSE AND $n->count() > $this->ao->max_nodes) {
SystemMessage::add(array(
'title'=>_('Maximum nodes created'),
'type'=>'info',
'body'=>_('Additional nodes cannot be created for your account, you have already reached your maximum. If you really need more, please contact us.'),
));
HTTP::redirect(URL::link('user','welcome'));
}
// Find a free name.
for ($i=1;$i<$n->count();$i++)
if (! Object::in_array('NODE_NAME',$this->node_name($i),$n->as_array()))
break;
$no = ORM::factory('NODE');
$no->NODE_NAME=$this->node_name($i);
$no->CONTACT=$this->ao->name();
$no->EMAILADDRESS=$this->ao->email;
$no->values($x=Arr::merge(Kohana::$config->load('tsm')->node_create,$this->request->post()));
$this->save($no);
if ($no->saved())
#HTTP::redirect(URL::link('user','node/view/'.$no->NODE_NAME));
HTTP::redirect(URL::link('user','welcome'));
}
Block::factory()
->type('form-horizontal')
->title('Register NODE')
->title_icon('fa-desktop')
->body(View::factory('node/user/add')->set('o',$this->ao));
}
}
?>

View File

@@ -0,0 +1,17 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
return array
(
'node_create' => array(
'PASSEXP'=>90,
'PASSWORD'=>'ch@ng3Me!',
'DOMAIN_NAME'=>'IDPR_DEMO',
'COMPRESSION'=>'Client',
'ARCHDELETE'=>'YES',
'BACKDELETE'=>'YES',
'OPTION_SET'=>'DEMO',
'DEDUPLICATION'=>'Client',
'USERID'=>'NONE',
'FORCEPWRESET'=>'YES',
),
);

View File

@@ -0,0 +1,13 @@
<fieldset>
<legend>Register a TSM node</legend>
<p>Please give us a description for this node.<p>
<?php echo Form::input('description','',array('divclass'=>'col-md-6','label'=>'Description','placeholder'=>'Description for Node')); ?>
</fieldset>
<div class="row">
<div class="col-md-offset-1">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-default">Cancel</button>
</div>
</div>

View File

@@ -1,5 +1,5 @@
<div class="shortcuts">
<a href="<?php echo URL::link('user','node/add',TRUE); ?>" class="shortcut"><i class="shortcut-icon fa fa-recycle"></i><span class="shortcut-label">Create Node</span></a>
<a href="<?php echo URL::link('user','node/add',TRUE); ?>" class="shortcut"><i class="shortcut-icon fa fa-desktop"></i><span class="shortcut-label">Create Node</span></a>
<a href="<?php echo URL::link('user','ssl/add',TRUE); ?>" class="shortcut"><i class="shortcut-icon fa fa-certificate"></i><span class="shortcut-label">Create SSL</span></a>
<a href="<?php echo URL::link('user','admin/add',TRUE); ?>" class="shortcut"><i class="shortcut-icon fa fa-graduation-cap"></i><span class="shortcut-label">Create Admin</span></a>
</div>