|
65 | 65 |
|
66 | 66 | if ($this->tab == 'logic') { |
67 | 67 |
|
68 | | - $method_name = gr('method'); |
69 | | - if (!$method_name) { |
70 | | - $method_name = 'logicAction'; |
71 | | - } |
72 | 68 |
|
73 | | - $out['METHOD'] = $method_name; |
| 69 | + $method_name = gr('method'); |
74 | 70 |
|
75 | 71 | $object = getObject($rec['LINKED_OBJECT']); |
76 | 72 |
|
77 | | - |
78 | 73 | $methods = $object->getParentMethods($object->class_id, '', 1); |
79 | 74 | $total = count($methods); |
80 | 75 | for ($i = 0; $i < $total; $i++) { |
81 | | - if ($methods[$i]['TITLE'] == $out['METHOD']) { |
82 | | - $methods[$i]['SELECTED'] = 1; |
83 | | - } |
84 | 76 | if ($methods[$i]['DESCRIPTION'] != '') { |
85 | 77 | $methods[$i]['DESCRIPTION'] = $methods[$i]['TITLE'] . ' - ' . $methods[$i]['DESCRIPTION']; |
86 | 78 | } else { |
87 | 79 | $methods[$i]['DESCRIPTION'] = $methods[$i]['TITLE']; |
88 | 80 | } |
| 81 | + if (isset($object_rec['ID'])) { |
| 82 | + $object_method = SQLSelectOne("SELECT * FROM methods WHERE TITLE='".$methods[$i]['TITLE']."' AND OBJECT_ID=".$object_rec['ID']." ORDER BY TITLE"); |
| 83 | + if (isset($object_method['ID'])) { |
| 84 | + $methods[$i]['DESCRIPTION'].=' (*)'; |
| 85 | + if (!$method_name) { |
| 86 | + $method_name = $object_method['TITLE']; |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + |
89 | 91 | } |
| 92 | + |
| 93 | + if (!$method_name) { |
| 94 | + $method_name = 'logicAction'; |
| 95 | + } |
| 96 | + |
| 97 | + $out['METHOD'] = $method_name; |
90 | 98 | $out['METHODS'] = $methods; |
91 | 99 |
|
92 | 100 | $method_id = $object->getMethodByName($method_name, $object->class_id, $object->id); |
93 | 101 |
|
94 | 102 | $method_rec = SQLSelectOne("SELECT * FROM methods WHERE ID=" . (int)$method_id); |
95 | 103 |
|
96 | 104 | if ($method_rec['OBJECT_ID'] != $object->id) { |
97 | | - $method_rec = array(); |
98 | | - $method_rec['OBJECT_ID'] = $object->id; |
99 | | - $method_rec['TITLE'] = $method_name; |
100 | | - $method_rec['CALL_PARENT'] = 1; |
101 | | - $method_rec['ID'] = SQLInsert('methods', $method_rec); |
| 105 | + $method_rec['CODE'] = ''; |
102 | 106 | } |
103 | 107 |
|
104 | 108 | if (defined('SETTINGS_CODEEDITOR_TURNONSETTINGS')) { |
|
108 | 112 | } |
109 | 113 |
|
110 | 114 | if ($this->mode == 'update') { |
111 | | - global $code; |
| 115 | + |
| 116 | + if ($method_rec['OBJECT_ID'] != $object->id) { |
| 117 | + $method_rec = array(); |
| 118 | + $method_rec['OBJECT_ID'] = $object->id; |
| 119 | + $method_rec['TITLE'] = $method_name; |
| 120 | + $method_rec['CALL_PARENT'] = 1; |
| 121 | + $method_rec['ID'] = SQLInsert('methods', $method_rec); |
| 122 | + } |
| 123 | + |
| 124 | + $code = gr('code'); |
112 | 125 |
|
113 | 126 | $old_code = $method_rec['CODE']; |
114 | 127 | $method_rec['CODE'] = $code; |
|
129 | 142 | $out['ERR_OLD_CODE'] = $old_code; |
130 | 143 | $ok = 0; |
131 | 144 | } |
| 145 | + } else { |
| 146 | + if ($method_rec['ID']) { |
| 147 | + SQLExec("DELETE FROM methods WHERE ID=".$method_rec['ID']); |
| 148 | + } |
| 149 | + $this->redirect("?id=".$rec['ID']."&view_mode=".$this->view_mode."&tab=".$this->tab."&method=".urlencode($method_rec['TITLE'])); |
132 | 150 | } |
133 | 151 | if ($ok) { |
134 | 152 | SQLUpdate('methods', $method_rec); |
|
0 commit comments