0, 'view'=>0, ); private function node_name($i) { return sprintf('%s%02d',$this->ao->id(),$i); } public function action_add() { $n = ORM::factory('NODE')->where('EMAIL_ADDRESS','=',$this->ao->email)->find_all(); if ($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')); } if ($this->request->post()) { // 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)); } } ?>