Code Duplication    Length = 11-11 lines in 4 locations

class/PublicWallUpdates.php 2 locations

@@ 228-238 (lines=11) @@
225
     * @param int $msgid
226
     * @return int
227
     */
228
    public function countVotes($type, $val, $msgid)
229
    {
230
        $sum    = 0;
231
        $query  = 'SELECT SUM(' . $val . ') AS sum FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " WHERE msg_id = '" . (int)$msgid . "' AND com_id = '0'";
232
        $result = $GLOBALS['xoopsDB']->queryF($query);
233
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
234
            $sum = $row['sum'];
235
        }
236
237
        return (int)$sum; // make sure it's an integer - not sure this is really necessary
238
    }
239
240
    /**
241
     * Count comments votes
@@ 249-259 (lines=11) @@
246
     * @param int $msgid
247
     * @returns int
248
     */
249
    public function countVotesCom($type, $val, $comid, $msgid)
250
    {
251
        $sum    = 0;
252
        $query  = 'SELECT SUM(' . $val . ') AS sum FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " WHERE com_id = '" . (int)$comid . "' AND msg_id = '" . (int)$msgid . "'";
253
        $result = $GLOBALS['xoopsDB']->queryF($query);
254
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
255
            $sum = $row['sum'];
256
        }
257
258
        return (int)$sum;
259
    }
260
261
    /**
262
     * @Check is user is friend

class/WallUpdates.php 2 locations

@@ 115-125 (lines=11) @@
112
     * @param int $msg_id
113
     * @return array
114
     */
115
    public function Comments($msg_id)
116
    {
117
        $data = []; //init data array
118
        $query  = 'SELECT C.msg_id_fk, C.com_id, C.uid_fk, C.comment, C.created, U.username FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_comments') . ' C, ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . " U WHERE C.uid_fk=U.userid AND C.msg_id_fk='" . $msg_id . "' ORDER BY C.com_id ASC ";
119
        $result = $GLOBALS['xoopsDB']->queryF($query);
120
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
121
            $data[] = $row;
122
        }
123
124
        return $data;
125
    }
126
127
    /**
128
     * Get user image based on uid
@@ 310-320 (lines=11) @@
307
     * @param int $msgid
308
     * @returns int
309
     */
310
    public function countVotesCom($type, $val, $comid, $msgid)
311
    {
312
        $sum = 0;
313
        $query  = 'SELECT SUM(' . $val . ') AS sum FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " WHERE com_id = '" . $comid . "' AND msg_id = '" . $msgid . "'";
314
        $result = $GLOBALS['xoopsDB']->queryF($query);
315
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
316
            $sum = $row['sum'];
317
        }
318
319
        return (int)$sum;
320
    }
321
322
    /**
323
     * Check if user has voted