示例#1
0
 private function defualtNode()
 {
     $m = \Ipm\Model_Node::find()->where('name', 'Detected')->get_one();
     if ($m) {
         return $m->id;
     }
     $q = array('name' => 'Detected', 'parent' => 0, 'meta_update_user' => 1);
     $n = new \Ipm\Model_Node($q);
     $n->save();
     return $n->id;
 }
示例#2
0
 public function action_index()
 {
     if ($this->id) {
         $val = \Validation::forge('add');
         $val->add_field('name', 'subnet id', 'required|min_length[1]|max_length[20]');
         if ($this->type == 0) {
             $this->id = 0;
         }
         if ($val->run()) {
             //check if exist already
             $m = Model_Node::find($this->id);
             if ($m) {
                 $nodes = \Ipm\Model_Node::find()->where('parent', $this->id)->get();
                 foreach ($nodes as $n) {
                     $n->delete();
                 }
                 $m->delete();
                 echo json_encode(array('status' => 'valid'));
             } else {
                 echo json_encode(array('status' => 'none'));
             }
         }
     }
 }
示例#3
0
[
<?php 
$data = array();
foreach ($nodes as $node) {
    $subs = \Ipm\Model_Node::find()->where('parent', $node->id)->count();
    $subs += \Ipm\Model_Subnet::find()->where('parent', $node->id)->count();
    $b = array('attr' => array('id' => 'node_' . $node->id, 'rel' => 'node'), 'data' => $node->name, 'state' => $subs == 0 ? '' : 'closed');
    array_push($data, $b);
}
echo json_encode($data);
?>
]