Code Duplication    Length = 7-8 lines in 13 locations

src/Intraface/modules/accounting/Post.php 1 location

@@ 126-133 (lines=8) @@
123
            return false;
124
        }
125
126
        if ($this->id > 0) {
127
            $sql_type = "UPDATE";
128
            $sql_end = " WHERE id = " . $this->id;
129
        } else {
130
            $sql_type = "INSERT INTO";
131
            $sql_end = "";
132
        }
133
134
        $db = new DB_Sql;
135
        $sql = $sql_type . " accounting_post
136
                 SET

src/Intraface/modules/accounting/VatPeriod.php 1 location

@@ 87-93 (lines=7) @@
84
            return 0;
85
        }
86
        $db = new DB_Sql;
87
        if ($this->id == 0 or $type=='insert') {
88
            $sql_type = "INSERT INTO ";
89
            $sql_end  = ", date_created = NOW()";
90
        } else {
91
            $sql_type = "UPDATE ";
92
            $sql_end  = " WHERE id = " . $this->id;
93
        }
94
95
        $sql = $sql_type . "accounting_vat_period SET user_id = ".$this->year->kernel->user->get('id').", label = '".$input['label']."', date_start = '".$input['date_start']."', date_end='".$input['date_end']."', date_updated=NOW(), intranet_id=".$this->year->kernel->intranet->get('id').", year_id=".$this->year->get('id')."" . $sql_end;
96

src/Intraface/modules/accounting/Voucher.php 1 location

@@ 141-147 (lines=7) @@
138
            return 0;
139
        }
140
141
        if (empty($this->id)) {
142
            $sql_type = "INSERT INTO";
143
            $sql_end = ", date_created = NOW()";
144
        } else {
145
            $sql_type = "UPDATE";
146
            $sql_end = " WHERE id = " . (int)$this->id;
147
        }
148
149
        $db = new DB_Sql;
150
        $sql = $sql_type . " accounting_voucher

src/Intraface/modules/accounting/VoucherFile.php 1 location

@@ 63-70 (lines=8) @@
60
            return $db->f('id');
61
        }
62
63
        if ($this->id > 0) {
64
            $sql_type = "UPDATE ";
65
            $sql_end = " WHERE id = " . $this->id;
66
        } else {
67
            $sql_type = "INSERT INTO ";
68
            $sql_end = " , date_created = NOW()";
69
        }
70
71
        if (empty($var['description'])) {
72
            $var['description'] = '';
73
        }

src/Intraface/modules/cms/Page.php 1 location

@@ 280-286 (lines=7) @@
277
            return 0;
278
        }
279
280
        if ($this->id == 0) {
281
            $sql_type = "INSERT INTO ";
282
            $sql_end = ", date_created = NOW()";
283
        } else {
284
            $sql_type = "UPDATE ";
285
            $sql_end = ", date_updated = NOW() WHERE id = " . $this->id;
286
        }
287
288
        $sql_extra = '';
289

src/Intraface/modules/cms/Site.php 1 location

@@ 72-78 (lines=7) @@
69
            return 0;
70
        }
71
72
        if ($this->id > 0) {
73
            $sql_type = "UPDATE ";
74
            $sql_end = " WHERE id = " . $this->id;
75
        } else {
76
            $sql_type = "INSERT INTO ";
77
            $sql_end = " , date_created = NOW()";
78
        }
79
80
        $db = new DB_Sql;
81
        $db->query($sql_type . " cms_site

src/Intraface/modules/cms/Template.php 1 location

@@ 147-153 (lines=7) @@
144
        }
145
146
        $db = new DB_Sql;
147
        if ($this->id > 0) {
148
            $sql_type = "UPDATE ";
149
            $sql_end = " WHERE id = " . $this->id;
150
        } else {
151
            $sql_type = "INSERT INTO ";
152
            $sql_end = ", date_created = NOW()";
153
        }
154
        $db->query($sql_type . " cms_template SET
155
            name = '".safeToDb($var['name'])."',
156
            date_updated = NOW(),

src/Intraface/modules/cms/TemplateSection.php 1 location

@@ 174-180 (lines=7) @@
171
        }
172
        $db = new DB_Sql;
173
174
        if ($this->id == 0) {
175
            $sql_type = "INSERT INTO ";
176
            $sql_end = ", date_created = NOW()";
177
        } else {
178
            $sql_type = "UPDATE ";
179
            $sql_end = " WHERE id = " . $this->id;
180
        }
181
        $sql = $sql_type . " cms_template_section SET
182
                name = '".safeToDb($var['name'])."',
183
                identifier = '".safeToDb($var['identifier'])."',

src/Intraface/modules/contact/ContactPerson.php 1 location

@@ 100-106 (lines=7) @@
97
            return false;
98
        }
99
100
        if ($this->id > 0) {
101
            $sql_type = "UPDATE ";
102
            $sql_end = " WHERE id = " . $this->id;
103
        } else {
104
            $sql_type = "INSERT INTO ";
105
            $sql_end = ", date_created = NOW()";
106
        }
107
108
109
        $db = MDB2::singleton(DB_DSN);

src/Intraface/modules/accounting/Account.php 1 location

@@ 257-263 (lines=7) @@
254
            return false;
255
        }
256
257
        if ($this->id > 0) {
258
            $sql_type = "UPDATE accounting_account ";
259
            $sql_end = " WHERE id = " . $this->id;
260
        } else {
261
            $sql_type = "INSERT INTO accounting_account ";
262
            $sql_end = ", date_created=NOW()";
263
        }
264
265
        $sql = $sql_type . "SET
266
            number = '".(int)$var['number']."',

src/Intraface/modules/cms/Element.php 1 location

@@ 235-241 (lines=7) @@
232
233
        $db = new DB_Sql;
234
235
        if ($this->id == 0) {
236
            $sql_type = "INSERT INTO ";
237
            $sql_end = ", date_created = NOW()";
238
        } else {
239
            $sql_type = "UPDATE ";
240
            $sql_end = " WHERE id = " . $this->id;
241
        }
242
        $sql = $sql_type . " cms_element SET
243
                intranet_id = ".$this->section->kernel->intranet->get('id').",
244
                section_id=". (int)$this->section->get('id') . ",

src/Intraface/modules/todo/TodoItem.php 1 location

@@ 111-117 (lines=7) @@
108
            $new_position = $db->f('position') + 1;
109
        }
110
111
        if ($this->id == 0) {
112
            $sql_type = "INSERT INTO ";
113
            $sql_end = ", date_created = NOW(), position = " . $new_position;
114
        } else {
115
            $sql_type = "UPDATE ";
116
            $sql_end = " WHERE id = " . $this->id;
117
        }
118
119
        $db->query($sql_type. " todo_item SET intranet_id = ".$this->todo->kernel->intranet->get('id').", item = '".$var."', todo_list_id = ".(int)$this->todo->get('id').", responsible_user_id = " .$user_id. " " . $sql_end);
120

src/Intraface/modules/newsletter/Newsletter.php 1 location

@@ 135-141 (lines=7) @@
132
            return 0;
133
        }
134
135
        if ($this->id == 0) {
136
            $sql_type = "INSERT INTO";
137
            $sql_end  = ', date_created = NOW()';
138
        } else {
139
            $sql_type = "UPDATE";
140
            $sql_end  = " WHERE id = " . $this->id;
141
        }
142
        $db  = new DB_Sql;
143
        $sql = $sql_type . " newsletter_archieve
144
            SET subject = '".$var['subject']."',