Completed
Push — master ( 53f46e...48acc0 )
by
unknown
01:29
created

SmallWorldImages::viewalbum()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 3
nop 2
dl 0
loc 30
rs 9.44
c 0
b 0
f 0
1
<?php 
2
namespace XoopsModules\Smallworld;
3
/**
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * SmallWorld
15
 *
16
 * @copyright    The XOOPS Project (https://xoops.org)
17
 * @copyright    2011 Culex
18
 * @license      GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/)
19
 * @package      SmallWorld
20
 * @since        1.0
21
 * @author       Michael Albertsen (http://culex.dk) <[email protected]>
22
 */
23
class SmallWorldImages
24
{
25
    /**
26
     * @Create folders
27
     * @param  int $userID
28
     * @return void
29
     */
30
    public function createAlbum($userID)
31
    {
32
        $dir = XOOPS_ROOT_PATH . '/uploads/albums_smallworld';
33
        if (!file_exists($dir . '/' . $userID . '/thumbnails') || !file_exists($dir . '/' . $userID . '/')) {
34
            if (!is_dir($dir . '/')) {
35
                mkdir($dir, 0777);
36
            } else {
37
                mkdir($dir . '/' . $userID, 0777);
38
                mkdir($dir . '/' . $userID . '/thumbnails', 0777);
39
                Smallworld_CreateIndexFiles($dir . '/');
0 ignored issues
show
Deprecated Code introduced by
The function smallworld_CreateIndexFiles() has been deprecated with message: - no longer used

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
40
                Smallworld_CreateIndexFiles($dir . '/' . $userID . '/');
0 ignored issues
show
Deprecated Code introduced by
The function smallworld_CreateIndexFiles() has been deprecated with message: - no longer used

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
41
                Smallworld_CreateIndexFiles($dir . '/' . $userID . '/thumbnails/');
0 ignored issues
show
Deprecated Code introduced by
The function smallworld_CreateIndexFiles() has been deprecated with message: - no longer used

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
42
            }
43
        }
44
    }
45
46
    /**
47
     * @View user album. Userid = owner, user = visitor
48
     * @param  int $userID
49
     * @param  int $user
50
     * @return array|bool
51
     */
52
    public function viewalbum($userID, $user)
53
    {
54
        global $xoopsUser, $xoopsDB, $xoopsTpl;
55
        $post        = [];
56
        $checkFriend = new SmallWorldUser;
57
		        //$checkFriend = new SmallWorldUser;
58
        $usr     = new \XoopsUser($userID);
59
        $isadmin = $usr->isAdmin();
60
        if (0 != $checkFriend->friendcheck($userID, $user) || $isadmin == true) {
61
            // check friend is good to go
62
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_images') . " WHERE userid = '" . $user . "'";
63
            $result = $xoopsDB->query($sql);
64
            $i      = 0;
65
            while ($sqlfetch = $xoopsDB->fetchArray($result)) {
66
                $post[$i]['id']      = stripslashes($sqlfetch['id']);
67
                $post[$i]['userid']  = stripslashes($sqlfetch['userid']);
68
                $post[$i]['imgurl']  = stripslashes($sqlfetch['imgurl']);
69
                $post[$i]['desc']    = Smallworld_cleanup_string($sqlfetch['desc']);
70
                $post[$i]['alt']     = Smallworld_cleanup_string($sqlfetch['desc']);
71
                $post[$i]['time']    = stripslashes($sqlfetch['time']);
72
                $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>';
73
                ++$i;
74
            }
75
76
            return $post;
77
        } else {
78
            //Not a friends album
79
            return false;
80
        }
81
    }
82
83
    /**
84
     * @Get image count for user
85
     * @param  int $userid
86
     * @return int
87
     */
88
    public function count($userid)
89
    {
90
        global $xoopsDB;
91
        $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_images') . " WHERE userid = '" . $userid . "'";
92
        $result = $xoopsDB->queryF($sql);
93
94
        return $xoopsDB->getRowsNum($result);
95
    }
96
}
97