Code Duplication    Length = 6-9 lines in 2 locations

class/SwDatabase.php 2 locations

@@ 490-498 (lines=9) @@
487
        if (0 == $status) {
488
            $sql    = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " (me,you,status,date) VALUES ('" . $userid . "', '" . $friendid . "', '1', UNIX_TIMESTAMP())";
489
            $result = $GLOBALS['xoopsDB']->queryF($sql);
490
        } elseif ($status > 0) {
491
            $sql     = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . (int)$friendid . "' AND you = '" . (int)$userid . "'";
492
            $sql2    = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . (int)$userid . "' AND you = '" . (int)$friendid . "'";
493
            $result  = $GLOBALS['xoopsDB']->queryF($sql);
494
            $result = $result && $GLOBALS['xoopsDB']->queryF($sql2);
495
496
            // Since friendship is canceled also following is deleted
497
            $this->toogleFollow(1, $userid, $friendid);
498
        }
499
500
        return $result ? true : false;
501
    }
@@ 545-550 (lines=6) @@
542
            $query2 = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " (me,you,status,date) VALUES ('" . $myUid . "', '" . $friend . "', '2', UNIX_TIMESTAMP())";
543
            $result = $GLOBALS['xoopsDB']->queryF($query);
544
            $result = $result && $GLOBALS['xoopsDB']->queryF($query2);
545
        } elseif (0 > $stat) {
546
            $query  = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . (int)$friend . "' AND you = '" . (int)$myUid . "'";
547
            $query2 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE you = '" . (int)$friend . "' AND me = '" . (int)$myUid . "'";
548
            $result = $GLOBALS['xoopsDB']->queryF($query);
549
            $result = $result && $GLOBALS['xoopsDB']->queryF($query2);
550
        }
551
        return $result ? true : false;
552
    }
553