Code Duplication    Length = 31-32 lines in 3 locations

htdocs/kernel/configcategory.php 1 location

@@ 147-177 (lines=31) @@
144
     *
145
     * @return bool true on success, otherwise false
146
     */
147
    public function insert(XoopsObject $confcat)
148
    {
149
        $className = 'XoopsConfigCategory';
150
        if (!($confcat instanceof $className)) {
151
            return false;
152
        }
153
        if (!$confcat->isDirty()) {
154
            return true;
155
        }
156
        if (!$confcat->cleanVars()) {
157
            return false;
158
        }
159
        foreach ($confcat->cleanVars as $k => $v) {
160
            ${$k} = $v;
161
        }
162
        if ($confcat->isNew()) {
163
            $confcat_id = $this->db->genId('configcategory_confcat_id_seq');
164
            $sql        = sprintf('INSERT INTO %s (confcat_id, confcat_name, confcat_order) VALUES (%u, %s, %u)', $this->db->prefix('configcategory'), $confcat_id, $this->db->quoteString($confcat_name), $confcat_order);
165
        } else {
166
            $sql = sprintf('UPDATE %s SET confcat_name = %s, confcat_order = %u WHERE confcat_id = %u', $this->db->prefix('configcategory'), $this->db->quoteString($confcat_name), $confcat_order, $confcat_id);
167
        }
168
        if (!$result = $this->db->query($sql)) {
169
            return false;
170
        }
171
        if (empty($confcat_id)) {
172
            $confcat_id = $this->db->getInsertId();
173
        }
174
        $confcat->assignVar('confcat_id', $confcat_id);
175
176
        return $confcat_id;
177
    }
178
179
    /**
180
     * Delete a {@link XoopsConfigCategory}

htdocs/kernel/imageset.php 1 location

@@ 146-177 (lines=32) @@
143
     *
144
     * @return bool true on success, otherwise false
145
     */
146
    public function insert(XoopsObject $imgset)
147
    {
148
        $className = 'XoopsComment';
149
        if (!($imgset instanceof $className)) {
150
            return false;
151
        }
152
153
        if (!$imgset->isDirty()) {
154
            return true;
155
        }
156
        if (!$imgset->cleanVars()) {
157
            return false;
158
        }
159
        foreach ($imgset->cleanVars as $k => $v) {
160
            ${$k} = $v;
161
        }
162
        if ($imgset->isNew()) {
163
            $imgset_id = $this->db->genId('imgset_imgset_id_seq');
164
            $sql       = sprintf('INSERT INTO %s (imgset_id, imgset_name, imgset_refid) VALUES (%u, %s, %u)', $this->db->prefix('imgset'), $imgset_id, $this->db->quoteString($imgset_name), $imgset_refid);
165
        } else {
166
            $sql = sprintf('UPDATE %s SET imgset_name = %s, imgset_refid = %u WHERE imgset_id = %u', $this->db->prefix('imgset'), $this->db->quoteString($imgset_name), $imgset_refid, $imgset_id);
167
        }
168
        if (!$result = $this->db->query($sql)) {
169
            return false;
170
        }
171
        if (empty($imgset_id)) {
172
            $imgset_id = $this->db->getInsertId();
173
        }
174
        $imgset->assignVar('imgset_id', $imgset_id);
175
176
        return true;
177
    }
178
179
    /**
180
     * Delete an XoopsImageSet from the database

htdocs/kernel/groupperm.php 1 location

@@ 184-214 (lines=31) @@
181
     *
182
     * @return bool true on success, otherwise false
183
     */
184
    public function insert(XoopsObject $perm)
185
    {
186
        $className = 'XoopsGroupPerm';
187
        if (!($perm instanceof $className)) {
188
            return false;
189
        }
190
        if (!$perm->isDirty()) {
191
            return true;
192
        }
193
        if (!$perm->cleanVars()) {
194
            return false;
195
        }
196
        foreach ($perm->cleanVars as $k => $v) {
197
            ${$k} = $v;
198
        }
199
        if ($perm->isNew()) {
200
            $gperm_id = $this->db->genId('group_permission_gperm_id_seq');
201
            $sql      = sprintf('INSERT INTO %s (gperm_id, gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, %u, %u, %s)', $this->db->prefix('group_permission'), $gperm_id, $gperm_groupid, $gperm_itemid, $gperm_modid, $this->db->quoteString($gperm_name));
202
        } else {
203
            $sql = sprintf('UPDATE %s SET gperm_groupid = %u, gperm_itemid = %u, gperm_modid = %u WHERE gperm_id = %u', $this->db->prefix('group_permission'), $gperm_groupid, $gperm_itemid, $gperm_modid, $gperm_id);
204
        }
205
        if (!$result = $this->db->query($sql)) {
206
            return false;
207
        }
208
        if (empty($gperm_id)) {
209
            $gperm_id = $this->db->getInsertId();
210
        }
211
        $perm->assignVar('gperm_id', $gperm_id);
212
213
        return true;
214
    }
215
216
    /**
217
     * Delete a {@link XoopsGroupPerm}