17 $mainassert = $this->uri->segment(3, -1); |
17 $mainassert = $this->uri->segment(3, -1); |
18 $parserdata['logindata'] = $this->aulib->getLoginLink(); |
18 $parserdata['logindata'] = $this->aulib->getLoginLink(); |
19 if ($mainassert == -1) |
19 if ($mainassert == -1) |
20 { |
20 { |
21 // Managing heads |
21 // Managing heads |
22 $this->form_validation->set_rules('text', 'Aserta teksto', 'required|min_length[1]'); |
22 if ($this->input->post('add')) |
23 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
23 { |
24 $this->form_validation->set_rules('context', 'Context', 'required|min_length[0]'); |
24 $this->form_validation->set_rules('text', 'Aserta teksto', 'required|min_length[1]'); |
|
25 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
25 |
26 |
26 if ($this->form_validation->run()) |
27 // Add the new assertion if added succesfully |
|
28 if ($this->form_validation->run()) |
|
29 { |
|
30 $dbdata['assert'] = $this->input->post('text'); |
|
31 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
|
32 if ($this->input->post('context')) |
|
33 $dbdata['context'] = $this->input->post('context'); |
|
34 $this->opiniarbo_model->insert_assertion($this->aulib->getSessionId(), |
|
35 $dbdata); |
|
36 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
|
37 } |
|
38 } |
|
39 else if ($this->input->post('modify')) |
27 { |
40 { |
28 $dbdata['assert'] = $this->input->post('text'); |
41 $this->form_validation->set_rules('id', 'Valoro', 'required'); |
29 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
42 $this->form_validation->set_rules('vid', 'Valoro', 'required'); |
30 $dbdata['context'] = $this->input->post('context'); |
43 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
31 $this->opiniarbo_model->insert_assertion($this->aulib->getSessionId(), |
44 |
32 $dbdata); |
45 // Add the new assertion if added succesfully |
33 $this->opiniarbo_model->recalculate(); |
46 if ($this->form_validation->run()) |
|
47 { |
|
48 $dbdata['assertid'] = $this->input->post('id'); |
|
49 $dbdata['valueid'] = $this->input->post('vid'); |
|
50 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
|
51 $this->opiniarbo_model->modify_values($this->aulib->getSessionId(), |
|
52 $dbdata); |
|
53 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
|
54 } |
34 } |
55 } |
|
56 |
|
57 // Show the head assertions |
35 $parserdata['asserts'] = $this->opiniarbo_model->get_my_heads($this->aulib->getSessionId()); |
58 $parserdata['asserts'] = $this->opiniarbo_model->get_my_heads($this->aulib->getSessionId()); |
36 foreach($parserdata['asserts'] as &$row) |
59 foreach($parserdata['asserts'] as &$row) |
37 { |
60 { |
38 if ($row->value != NULL) |
61 if ($row['value'] != NULL) |
39 $row->value = ($row->value - 0.5) * 20; |
62 $row['value'] = ($row['value'] - 0.5) * 20; |
40 if ($row->calc_value != NULL) |
63 if ($row['calc_value'] != NULL) |
41 $row->calc_value = $row->calc_value * 10; |
64 $row['calc_value'] = ($row['calc_value'] - 0.5)*20; |
42 } |
65 } |
|
66 $parserdata['asserts_other'] = $this->opiniarbo_model->get_other_heads($this->aulib->getSessionId()); |
43 $this->parser->parse('arbo_heads', $parserdata); |
67 $this->parser->parse('arbo_heads', $parserdata); |
44 } |
68 } |
45 else |
69 else |
46 { |
70 { |
47 // Assert chosen |
71 // Assert chosen |
48 $parserdata['mainassert'] = $mainassert; |
72 $parserdata['mainassert'] = $mainassert; |
49 |
73 |
50 $this->form_validation->set_rules('text', 'Aserta teksto', 'required|min_length[1]'); |
74 if ($this->input->post('add')) |
51 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
75 { |
52 $this->form_validation->set_rules('influence', 'Influo', 'callback__influence_check'); |
76 $this->form_validation->set_rules('text', 'Aserta teksto', 'required|min_length[1]'); |
53 $this->form_validation->set_rules('context', 'Context', 'required|min_length[0]'); |
77 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
|
78 $this->form_validation->set_rules('influence', 'Influo', 'required'); |
54 |
79 |
55 if ($this->form_validation->run()) |
80 // Add the subassertion if possible |
|
81 if ($this->form_validation->run()) |
|
82 { |
|
83 $dbdata['assert'] = $this->input->post('text'); |
|
84 $dbdata['value'] = $this->input->post('value')/20. + 0.5; |
|
85 $dbdata['influence'] = $this->input->post('influence')/10.; |
|
86 if ($this->input->post('context')) |
|
87 $dbdata['context'] = $this->input->post('context'); |
|
88 $dbdata['parent'] = $mainassert; |
|
89 $this->opiniarbo_model->insert_assertion($this->aulib->getSessionId(), |
|
90 $dbdata); |
|
91 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
|
92 } |
|
93 } |
|
94 else if ($this->input->post('modify')) |
56 { |
95 { |
57 $dbdata['assert'] = $this->input->post('text'); |
96 $this->form_validation->set_rules('id', 'Valoro', 'required'); |
58 $dbdata['value'] = $this->input->post('value')/20. + 0.5; |
97 $this->form_validation->set_rules('vid', 'Valoro', 'required'); |
59 $dbdata['influence'] = $this->input->post('influence')/10.; |
98 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
60 $dbdata['context'] = $this->input->post('context'); |
99 $this->form_validation->set_rules('influence', 'Influo', 'required'); |
61 $dbdata['parent'] = $mainassert; |
100 |
62 $this->opiniarbo_model->insert_assertion($this->aulib->getSessionId(), |
101 // Modify the values if possible |
63 $dbdata); |
102 if ($this->form_validation->run()) |
64 $this->opiniarbo_model->recalculate(); |
103 { |
|
104 $dbdata['assertid'] = $this->input->post('id'); |
|
105 $dbdata['valueid'] = $this->input->post('vid'); |
|
106 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
|
107 $dbdata['influence'] = $this->input->post('influence')/10; |
|
108 $this->opiniarbo_model->modify_values($this->aulib->getSessionId(), |
|
109 $dbdata); |
|
110 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
|
111 } |
65 } |
112 } |
66 $assertdata = $this->opiniarbo_model->get_assert($mainassert, $this->aulib->getSessionId()); |
113 $assertdata = $this->opiniarbo_model->get_assert($mainassert, $this->aulib->getSessionId()); |
67 $parserdata['maintext'] = $assertdata['assert']; |
114 $parserdata['maintext'] = $assertdata['assert']; |
68 $parserdata['mainvalue'] = $assertdata['value']; |
115 $parserdata['mainvalue'] = $assertdata['value']; |
69 if ($parserdata['mainvalue'] != NULL) |
116 if ($parserdata['mainvalue'] != NULL) |