Code Duplication    Length = 17-20 lines in 16 locations

htdocs/kernel/avatar.php 1 location

@@ 194-213 (lines=20) @@
191
     * @param  int $id
192
     * @return XoopsAvatar
193
     */
194
    public function get($id)
195
    {
196
        $avatar = false;
197
        $id     = (int)$id;
198
        if ($id > 0) {
199
            $sql = 'SELECT * FROM ' . $this->db->prefix('avatar') . ' WHERE avatar_id=' . $id;
200
            if (!$result = $this->db->query($sql)) {
201
                return false;
202
            }
203
            $numrows = $this->db->getRowsNum($result);
204
            if ($numrows == 1) {
205
                $avatar = new XoopsAvatar();
206
                $avatar->assignVars($this->db->fetchArray($result));
207
208
                return $avatar;
209
            }
210
        }
211
212
        return $avatar;
213
    }
214
215
    /**
216
     * Insert and Object into the database

htdocs/kernel/block.php 1 location

@@ 418-434 (lines=17) @@
415
     * @param  int $id bid of the block to retrieve
416
     * @return XoopsBlock reference to the block
417
     **/
418
    public function get($id)
419
    {
420
        $block = false;
421
        $id    = (int)$id;
422
        if ($id > 0) {
423
            $sql = 'SELECT * FROM ' . $this->db->prefix('newblocks') . ' WHERE bid=' . $id;
424
            if ($result = $this->db->query($sql)) {
425
                $numrows = $this->db->getRowsNum($result);
426
                if ($numrows == 1) {
427
                    $block = new XoopsBlock();
428
                    $block->assignVars($this->db->fetchArray($result));
429
                }
430
            }
431
        }
432
433
        return $block;
434
    }
435
436
    /**
437
     * write a new block into the database

htdocs/kernel/comment.php 1 location

@@ 357-374 (lines=18) @@
354
     *
355
     * @return XoopsComment {@link XoopsComment}, FALSE on fail
356
     **/
357
    public function get($id)
358
    {
359
        $comment = false;
360
        $id      = (int)$id;
361
        if ($id > 0) {
362
            $sql = 'SELECT * FROM ' . $this->db->prefix('xoopscomments') . ' WHERE com_id=' . $id;
363
            if (!$result = $this->db->query($sql)) {
364
                return $comment;
365
            }
366
            $numrows = $this->db->getRowsNum($result);
367
            if ($numrows == 1) {
368
                $comment = new XoopsComment();
369
                $comment->assignVars($this->db->fetchArray($result));
370
            }
371
        }
372
373
        return $comment;
374
    }
375
376
    /**
377
     * Write a comment to database

htdocs/kernel/configcategory.php 1 location

@@ 121-138 (lines=18) @@
118
     *
119
     * @return XoopsConfigCategory {@link XoopsConfigCategory}, FALSE on fail
120
     */
121
    public function get($id)
122
    {
123
        $confcat = false;
124
        $id      = (int)$id;
125
        if ($id > 0) {
126
            $sql = 'SELECT * FROM ' . $this->db->prefix('configcategory') . ' WHERE confcat_id=' . $id;
127
            if (!$result = $this->db->query($sql)) {
128
                return $confcat;
129
            }
130
            $numrows = $this->db->getRowsNum($result);
131
            if ($numrows == 1) {
132
                $confcat = new XoopsConfigCategory();
133
                $confcat->assignVars($this->db->fetchArray($result));
134
            }
135
        }
136
137
        return $confcat;
138
    }
139
140
    /**
141
     * Store a {@link XoopsConfigCategory}

htdocs/kernel/configitem.php 1 location

@@ 301-319 (lines=19) @@
298
     * @param  int $id ID of the config
299
     * @return XoopsConfigItem reference to the config, FALSE on fail
300
     */
301
    public function get($id)
302
    {
303
        $config = false;
304
        $id     = (int)$id;
305
        if ($id > 0) {
306
            $sql = 'SELECT * FROM ' . $this->db->prefix('config') . ' WHERE conf_id=' . $id;
307
            if (!$result = $this->db->query($sql)) {
308
                return $config;
309
            }
310
            $numrows = $this->db->getRowsNum($result);
311
            if ($numrows == 1) {
312
                $myrow  = $this->db->fetchArray($result);
313
                $config = new XoopsConfigItem();
314
                $config->assignVars($myrow);
315
            }
316
        }
317
318
        return $config;
319
    }
320
321
    /**
322
     * Write a config to the database

htdocs/kernel/configoption.php 1 location

@@ 130-147 (lines=18) @@
127
     *
128
     * @return XoopsConfigOption reference to the {@link XoopsConfigOption}, FALSE on fail
129
     */
130
    public function get($id)
131
    {
132
        $confoption = false;
133
        $id         = (int)$id;
134
        if ($id > 0) {
135
            $sql = 'SELECT * FROM ' . $this->db->prefix('configoption') . ' WHERE confop_id=' . $id;
136
            if (!$result = $this->db->query($sql)) {
137
                return $confoption;
138
            }
139
            $numrows = $this->db->getRowsNum($result);
140
            if ($numrows == 1) {
141
                $confoption = new XoopsConfigOption();
142
                $confoption->assignVars($this->db->fetchArray($result));
143
            }
144
        }
145
146
        return $confoption;
147
    }
148
149
    /**
150
     * Insert a new {@link XoopsConfigOption}

htdocs/kernel/imagecategory.php 1 location

@@ 209-226 (lines=18) @@
206
     * @internal param bool $getbinary
207
     * @return XoopsImageCategory {@link XoopsImageCategory}, FALSE on fail
208
     */
209
    public function get($id)
210
    {
211
        $id     = (int)$id;
212
        $imgcat = false;
213
        if ($id > 0) {
214
            $sql = 'SELECT * FROM ' . $this->db->prefix('imagecategory') . ' WHERE imgcat_id=' . $id;
215
            if (!$result = $this->db->query($sql)) {
216
                return $imgcat;
217
            }
218
            $numrows = $this->db->getRowsNum($result);
219
            if ($numrows == 1) {
220
                $imgcat = new XoopsImagecategory();
221
                $imgcat->assignVars($this->db->fetchArray($result));
222
            }
223
        }
224
225
        return $imgcat;
226
    }
227
228
    /**
229
     * Write a {@link XoopsImageCategory} object to the database

htdocs/kernel/imageset.php 1 location

@@ 120-137 (lines=18) @@
117
     * @internal param bool $getbinary
118
     * @return XoopsImageSet {@link XoopsImageSet}, FALSE on fail
119
     */
120
    public function get($id)
121
    {
122
        $id     = (int)$id;
123
        $imgset = false;
124
        if ($id > 0) {
125
            $sql = 'SELECT * FROM ' . $this->db->prefix('imgset') . ' WHERE imgset_id=' . $id;
126
            if (!$result = $this->db->query($sql)) {
127
                return $imgset;
128
            }
129
            $numrows = $this->db->getRowsNum($result);
130
            if ($numrows == 1) {
131
                $imgset = new XoopsImageSet();
132
                $imgset->assignVars($this->db->fetchArray($result));
133
            }
134
        }
135
136
        return $imgset;
137
    }
138
139
    /**
140
     * Write a {@link XoopsImageSet} object to the database

htdocs/kernel/imagesetimg.php 1 location

@@ 126-143 (lines=18) @@
123
     * @internal param bool $getbinary
124
     * @return XoopsImageSetImg {@link XoopsImageSetImg}, FALSE on fail
125
     */
126
    public function get($id)
127
    {
128
        $imgsetimg = false;
129
        $id        = (int)$id;
130
        if ($id > 0) {
131
            $sql = 'SELECT * FROM ' . $this->db->prefix('imgsetimg') . ' WHERE imgsetimg_id=' . $id;
132
            if (!$result = $this->db->query($sql)) {
133
                return $imgsetimg;
134
            }
135
            $numrows = $this->db->getRowsNum($result);
136
            if ($numrows == 1) {
137
                $imgsetimg = new XoopsImagesetimg();
138
                $imgsetimg->assignVars($this->db->fetchArray($result));
139
            }
140
        }
141
142
        return $imgsetimg;
143
    }
144
145
    /**
146
     * Write a {@link XoopsImageSetImg} object to the database

htdocs/kernel/notification.php 1 location

@@ 250-267 (lines=18) @@
247
     *
248
     * @return XoopsNotification {@link XoopsNotification}, FALSE on fail
249
     **/
250
    public function get($id)
251
    {
252
        $notification = false;
253
        $id           = (int)$id;
254
        if ($id > 0) {
255
            $sql = 'SELECT * FROM ' . $this->db->prefix('xoopsnotifications') . ' WHERE not_id=' . $id;
256
            if (!$result = $this->db->query($sql)) {
257
                return $notification;
258
            }
259
            $numrows = $this->db->getRowsNum($result);
260
            if ($numrows == 1) {
261
                $notification = new XoopsNotification();
262
                $notification->assignVars($this->db->fetchArray($result));
263
            }
264
        }
265
266
        return $notification;
267
    }
268
269
    /**
270
     * Write a notification(subscription) to database

htdocs/kernel/privmessage.php 1 location

@@ 173-190 (lines=18) @@
170
     * @param  int $id ID of the message
171
     * @return XoopsPrivmessage
172
     **/
173
    public function get($id)
174
    {
175
        $pm = false;
176
        $id = (int)$id;
177
        if ($id > 0) {
178
            $sql = 'SELECT * FROM ' . $this->db->prefix('priv_msgs') . ' WHERE msg_id=' . $id;
179
            if (!$result = $this->db->query($sql)) {
180
                return $pm;
181
            }
182
            $numrows = $this->db->getRowsNum($result);
183
            if ($numrows == 1) {
184
                $pm = new XoopsPrivmessage();
185
                $pm->assignVars($this->db->fetchArray($result));
186
            }
187
        }
188
189
        return $pm;
190
    }
191
192
    /**
193
     * Insert a message in the database

htdocs/kernel/tplset.php 2 locations

@@ 140-157 (lines=18) @@
137
     * @param  int $id tplset_id of the tplsets to retrieve
138
     * @return object XoopsTplset reference to the tplsets
139
     **/
140
    public function get($id)
141
    {
142
        $tplset = false;
143
        $id     = (int)$id;
144
        if ($id > 0) {
145
            $sql = 'SELECT * FROM ' . $this->db->prefix('tplset') . ' WHERE tplset_id=' . $id;
146
            if (!$result = $this->db->query($sql)) {
147
                return $tplset;
148
            }
149
            $numrows = $this->db->getRowsNum($result);
150
            if ($numrows == 1) {
151
                $tplset = new XoopsTplset();
152
                $tplset->assignVars($this->db->fetchArray($result));
153
            }
154
        }
155
156
        return $tplset;
157
    }
158
159
    /**
160
     * retrieve a specific {@link XoopsBlock}
@@ 169-186 (lines=18) @@
166
     * @internal param int $id tplset_id of the block to retrieve
167
     * @return object XoopsTplset reference to the tplsets
168
     */
169
    public function getByName($tplset_name)
170
    {
171
        $tplset      = false;
172
        $tplset_name = trim($tplset_name);
173
        if ($tplset_name != '') {
174
            $sql = 'SELECT * FROM ' . $this->db->prefix('tplset') . ' WHERE tplset_name=' . $this->db->quoteString($tplset_name);
175
            if (!$result = $this->db->query($sql)) {
176
                return $tplset;
177
            }
178
            $numrows = $this->db->getRowsNum($result);
179
            if ($numrows == 1) {
180
                $tplset = new XoopsTplset();
181
                $tplset->assignVars($this->db->fetchArray($result));
182
            }
183
        }
184
185
        return $tplset;
186
    }
187
188
    /**
189
     * write a new block into the database

htdocs/modules/system/class/avatar.php 1 location

@@ 135-154 (lines=20) @@
132
     * @param  int $id
133
     * @return object
134
     */
135
    public function get($id)
136
    {
137
        $avatar = false;
138
        $id     = (int)$id;
139
        if ($id > 0) {
140
            $sql = 'SELECT * FROM ' . $this->db->prefix('avatar') . ' WHERE avatar_id=' . $id;
141
            if (!$result = $this->db->query($sql)) {
142
                return false;
143
            }
144
            $numrows = $this->db->getRowsNum($result);
145
            if ($numrows == 1) {
146
                $avatar = new SystemAvatar();
147
                $avatar->assignVars($this->db->fetchArray($result));
148
149
                return $avatar;
150
            }
151
        }
152
153
        return $avatar;
154
    }
155
}
156

htdocs/kernel/group.php 2 locations

@@ 141-158 (lines=18) @@
138
     * @param  int $id ID of the group to get
139
     * @return XoopsGroup XoopsGroup reference to the group object, FALSE if failed
140
     */
141
    public function get($id)
142
    {
143
        $id    = (int)$id;
144
        $group = false;
145
        if ($id > 0) {
146
            $sql = 'SELECT * FROM ' . $this->db->prefix('groups') . ' WHERE groupid=' . $id;
147
            if (!$result = $this->db->query($sql)) {
148
                return $group;
149
            }
150
            $numrows = $this->db->getRowsNum($result);
151
            if ($numrows == 1) {
152
                $group = new XoopsGroup();
153
                $group->assignVars($this->db->fetchArray($result));
154
            }
155
        }
156
157
        return $group;
158
    }
159
160
    /**
161
     * insert a group into the database
@@ 325-342 (lines=18) @@
322
     * @param  int $id ID of the membership to get
323
     * @return mixed reference to the object if successful, else FALSE
324
     */
325
    public function get($id)
326
    {
327
        $id    = (int)$id;
328
        $mship = false;
329
        if ($id > 0) {
330
            $sql = 'SELECT * FROM ' . $this->db->prefix('groups_users_link') . ' WHERE linkid=' . $id;
331
            if (!$result = $this->db->query($sql)) {
332
                return $mship;
333
            }
334
            $numrows = $this->db->getRowsNum($result);
335
            if ($numrows == 1) {
336
                $mship = new XoopsMembership();
337
                $mship->assignVars($this->db->fetchArray($result));
338
            }
339
        }
340
341
        return $mship;
342
    }
343
344
    /**
345
     * inserts a membership in the database