Code Duplication    Length = 10-15 lines in 6 locations

class/user.php 1 location

@@ 127-136 (lines=10) @@
124
     * @param  int    $userID
125
     * @return string
126
     */
127
    function getName($userID){
128
        global $xoopsUser, $xoopsDB;
129
        $sql = "SELECT username FROM ".$xoopsDB->prefix('smallworld_user')." WHERE userid = '".intval($userID)."'";
130
        $result = $xoopsDB->queryf($sql);
131
        while ($row = $xoopsDB->fetchArray($result)) {
132
            $name = $row['username'];
133
        }
134
135
        return $name;
136
    }
137
138
    /**
139
     * @Check if user is follower

include/functions.php 5 locations

@@ 456-466 (lines=11) @@
453
* Return owner of thread (original poster)
454
* Return Integer
455
*/
456
function Smallworld_getOwnerFromComment($msg_id_fk)
457
{
458
    global $xoopsDB;
459
    $sql = "Select uid_fk from ".$xoopsDB->prefix('smallworld_messages')." where msg_id = '".$msg_id_fk."'";
460
    $result = $xoopsDB->queryF($sql);
461
    while ($r = $xoopsDB->fetchArray($result)) {
462
        $owner = $r['uid_fk'];
463
    }
464
465
    return $owner;
466
}
467
468
// Get username from userID
469
function Smallworld_getName($userID)
@@ 469-479 (lines=11) @@
466
}
467
468
// Get username from userID
469
function Smallworld_getName($userID)
470
{
471
    global $xoopsUser, $xoopsDB;
472
    $sql = "SELECT username FROM ".$xoopsDB->prefix('smallworld_user')." WHERE userid = '".intval($userID)."'";
473
    $result = $xoopsDB->queryf($sql);
474
    while ($row = $xoopsDB->fetchArray($result)) {
475
        $name = $row['username'];
476
    }
477
478
    return $name;
479
}
480
481
// Check if user has been taken down for inspection by admin
482
// Userid = user id of user to check
@@ 773-783 (lines=11) @@
770
}
771
772
//Check privacy settings in permapage
773
function smallworldCheckPriv ($id)
774
{
775
    global $xoopsDB;
776
    $public = "SELECT priv FROM ".$xoopsDB->prefix('smallworld_messages')." WHERE msg_id = ".$id."";
777
    $result = $xoopsDB->queryF($public);
778
    while ($row = $xoopsDB->fetchArray($result)){
779
        $priv = $row['priv'];
780
    }
781
782
    return $priv;
783
}
784
785
// Function to calculate remaining seconds until user's birthday
786
// Input $d : date('Y-m-d') format
@@ 921-935 (lines=15) @@
918
  * @param int $userid
919
  * @returns string
920
  */
921
  function smallworld_getRndImg($userid)
922
  {
923
    global $xoopsDB;
924
    $sql = "SELECT imgname FROM " . $xoopsDB->prefix('smallworld_images') . " WHERE userid = " . $userid
925
        . " AND time BETWEEN UNIX_TIMESTAMP( ) - 3000 AND UNIX_TIMESTAMP() ORDER BY rand() limit 1";
926
    $result = $xoopsDB->queryF($sql);
927
    while ($r = $xoopsDB->fetchArray($result)) {
928
        $img = $r['imgname'];
929
    }
930
    if (!empty($img)) {
931
        return $img;
932
    } else {
933
        return false;
934
    }
935
  }
936
937
    /**
938
     * @Get url of smallworld
@@ 1318-1328 (lines=11) @@
1315
     * @param $txt
1316
     * @return array @users
1317
     **/
1318
    function smallworld_getUidFromName ($name)
1319
    {
1320
        global $xoopsDB;
1321
        $sql = "Select userid from ".$xoopsDB->prefix('smallworld_user')." where username = '".$name."'";
1322
        $result = $xoopsDB->queryF($sql);
1323
        while ($r = $xoopsDB->fetchArray($result)) {
1324
            $id = $r['userid'];
1325
        }
1326
1327
        return $id;
1328
    }
1329
     
1330
    /**
1331
     * Extract users from @tags