Code Duplication    Length = 71-71 lines in 2 locations

class/images.php 1 location

@@ 22-92 (lines=71) @@
19
 * @since        1.0
20
 * @author       Michael Albertsen (http://culex.dk) <[email protected]>
21
 */
22
class SmallWorldImages
23
{
24
    /**
25
     * @Create folders
26
     * @param  int $userID
27
     * @return void
28
     */
29
    public function createAlbum($userID)
30
    {
31
        $dir = XOOPS_ROOT_PATH . '/uploads/albums_smallworld';
32
        if (!file_exists($dir . '/' . $userID . '/thumbnails') || !file_exists($dir . '/' . $userID . '/')) {
33
            if (!is_dir($dir . '/')) {
34
                mkdir($dir, 0777);
35
            } else {
36
                mkdir($dir . '/' . $userID, 0777);
37
                mkdir($dir . '/' . $userID . '/thumbnails', 0777);
38
                Smallworld_CreateIndexFiles($dir . '/');
39
                Smallworld_CreateIndexFiles($dir . '/' . $userID . '/');
40
                Smallworld_CreateIndexFiles($dir . '/' . $userID . '/thumbnails/');
41
            }
42
        }
43
    }
44
45
    /**
46
     * @View user album. Userid = owner, user = visitor
47
     * @param  int $userID
48
     * @param  int $user
49
     * @return array|bool
50
     */
51
    public function viewalbum($userID, $user)
52
    {
53
        global $xoopsUser, $xoopsDB, $xoopsTpl;
54
        $post        = [];
55
        $checkFriend = new SmallWorldUser;
56
        if (0 != $checkFriend->friendcheck($userID, $user)) {
57
            // check friend is good to go
58
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_images') . " WHERE userid = '" . $user . "'";
59
            $result = $xoopsDB->query($sql);
60
            $i      = 0;
61
            while ($sqlfetch = $xoopsDB->fetchArray($result)) {
62
                $post[$i]['id']      = stripslashes($sqlfetch['id']);
63
                $post[$i]['userid']  = stripslashes($sqlfetch['userid']);
64
                $post[$i]['imgurl']  = stripslashes($sqlfetch['imgurl']);
65
                $post[$i]['desc']    = Smallworld_cleanup_string($sqlfetch['desc']);
66
                $post[$i]['alt']     = Smallworld_cleanup_string($sqlfetch['desc']);
67
                $post[$i]['time']    = stripslashes($sqlfetch['time']);
68
                $post[$i]['editimg'] = "<span class='smallworld_edit_imgdesc_holder'><img src='assets/images/edit_icon.png'></span> <a class='smallworld_edit_imgdesc' href='editimages.php'>" . _SMALLWORLD_EDITDESCRIPTION . '</a>';
69
                ++$i;
70
            }
71
72
            return $post;
73
        } else {
74
            //Not a friends album
75
            return false;
76
        }
77
    }
78
79
    /**
80
     * @Get image count for user
81
     * @param  int $userid
82
     * @return int
83
     */
84
    public function count($userid)
85
    {
86
        global $xoopsDB;
87
        $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_images') . " WHERE userid = '" . $userid . "'";
88
        $result = $xoopsDB->queryF($sql);
89
90
        return $xoopsDB->getRowsNum($result);
91
    }
92
}
93

class/SmallWorldImages.php 1 location

@@ 22-92 (lines=71) @@
19
 * @since        1.0
20
 * @author       Michael Albertsen (http://culex.dk) <[email protected]>
21
 */
22
class SmallWorldImages
23
{
24
    /**
25
     * @Create folders
26
     * @param  int $userID
27
     * @return void
28
     */
29
    public function createAlbum($userID)
30
    {
31
        $dir = XOOPS_ROOT_PATH . '/uploads/albums_smallworld';
32
        if (!file_exists($dir . '/' . $userID . '/thumbnails') || !file_exists($dir . '/' . $userID . '/')) {
33
            if (!is_dir($dir . '/')) {
34
                mkdir($dir, 0777);
35
            } else {
36
                mkdir($dir . '/' . $userID, 0777);
37
                mkdir($dir . '/' . $userID . '/thumbnails', 0777);
38
                Smallworld_CreateIndexFiles($dir . '/');
39
                Smallworld_CreateIndexFiles($dir . '/' . $userID . '/');
40
                Smallworld_CreateIndexFiles($dir . '/' . $userID . '/thumbnails/');
41
            }
42
        }
43
    }
44
45
    /**
46
     * @View user album. Userid = owner, user = visitor
47
     * @param  int $userID
48
     * @param  int $user
49
     * @return array|bool
50
     */
51
    public function viewalbum($userID, $user)
52
    {
53
        global $xoopsUser, $xoopsDB, $xoopsTpl;
54
        $post        = [];
55
        $checkFriend = new SmallWorldUser;
56
        if (0 != $checkFriend->friendcheck($userID, $user)) {
57
            // check friend is good to go
58
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_images') . " WHERE userid = '" . $user . "'";
59
            $result = $xoopsDB->query($sql);
60
            $i      = 0;
61
            while ($sqlfetch = $xoopsDB->fetchArray($result)) {
62
                $post[$i]['id']      = stripslashes($sqlfetch['id']);
63
                $post[$i]['userid']  = stripslashes($sqlfetch['userid']);
64
                $post[$i]['imgurl']  = stripslashes($sqlfetch['imgurl']);
65
                $post[$i]['desc']    = Smallworld_cleanup_string($sqlfetch['desc']);
66
                $post[$i]['alt']     = Smallworld_cleanup_string($sqlfetch['desc']);
67
                $post[$i]['time']    = stripslashes($sqlfetch['time']);
68
                $post[$i]['editimg'] = "<span class='smallworld_edit_imgdesc_holder'><img src='assets/images/edit_icon.png'></span> <a class='smallworld_edit_imgdesc' href='editimages.php'>" . _SMALLWORLD_EDITDESCRIPTION . '</a>';
69
                ++$i;
70
            }
71
72
            return $post;
73
        } else {
74
            //Not a friends album
75
            return false;
76
        }
77
    }
78
79
    /**
80
     * @Get image count for user
81
     * @param  int $userid
82
     * @return int
83
     */
84
    public function count($userid)
85
    {
86
        global $xoopsDB;
87
        $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_images') . " WHERE userid = '" . $userid . "'";
88
        $result = $xoopsDB->queryF($sql);
89
90
        return $xoopsDB->getRowsNum($result);
91
    }
92
}
93