Passed
Push — master ( 565d4a...492cc7 )
by Michael
07:40
created
include/search.inc.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
     $criteriaPost = new \CriteriaCompo();
56 56
     $criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts
57 57
 
58
-    $forum_list = [];// get forum lists just for forum names
58
+    $forum_list = []; // get forum lists just for forum names
59 59
     if (count($validForums) > 0) {
60 60
         $criteriaPermissions = new \CriteriaCompo();
61
-        $criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND');
62
-        $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false);
61
+        $criteriaPermissions->add(new \Criteria('p.forum_id', '('.implode(',', $validForums).')', 'IN'), 'AND');
62
+        $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '('.implode(', ', $validForums).')', 'IN'), 'forum_name', false);
63 63
     }
64 64
 
65 65
     if (is_numeric($userid) && 0 !== $userid) {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     } elseif (is_array($userid) && count($userid) > 0) {
69 69
         $userid       = array_map('intval', $userid);
70 70
         $criteriaUser = new \CriteriaCompo();
71
-        $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
71
+        $criteriaUser->add(new \Criteria('p.uid', '('.implode(',', $userid).')', 'IN'), 'OR');
72 72
     }
73 73
 
74 74
     $count = 0;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $criteriaKeywords = new \CriteriaCompo();
81 81
         foreach ($queryarray as $queryTerm) {
82 82
             $termCriteria  = new \CriteriaCompo();
83
-            $queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%';
83
+            $queryTermLike = '%'.$xoopsDB->escape($queryTerm).'%';
84 84
             if ('title' === $searchin || 'both' === $searchin) {
85 85
                 $termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR');
86 86
             }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             $criteriaKeywords->add($termCriteria, $andor);
91 91
         }
92 92
         // add highlight keywords to post links
93
-        $highlightKey = '&keywords=' . implode(' ', $queryarray);
93
+        $highlightKey = '&keywords='.implode(' ', $queryarray);
94 94
         $highlightKey = str_replace(' ', '+', $highlightKey);
95 95
     }
96 96
     $criteria = new \CriteriaCompo();
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
         $post                  = $posts[$id];
132 132
         $post_data             = $post->getPostBody();
133 133
         $ret[$i]['topic_id']   = $post->getVar('topic_id');
134
-        $ret[$i]['link']       = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key
134
+        $ret[$i]['link']       = XOOPS_URL.'/modules/newbb/viewtopic.php?post_id='.$post->getVar('post_id').$highlightKey; // add highlight key
135 135
         $ret[$i]['title']      = $post_data['subject'];
136 136
         $ret[$i]['time']       = $post_data['date'];
137 137
         $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']);
138
-        $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id');
138
+        $ret[$i]['forum_link'] = XOOPS_URL.'/modules/newbb/viewforum.php?forum='.$post->getVar('forum_id');
139 139
         $ret[$i]['post_text']  = $post_data['text'];
140 140
         $ret[$i]['uid']        = $post->getVar('uid');
141
-        $ret[$i]['poster']     = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author'];
141
+        $ret[$i]['poster']     = $post->getVar('uid') ? '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$ret[$i]['uid'].'">'.$post_data['author'].'</a>' : $post_data['author'];
142 142
         ++$i;
143 143
     }
144 144
 
Please login to merge, or discard this patch.
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -28,119 +28,119 @@
 block discarded – undo
28 28
  * @return array
29 29
  */
30 30
 function newbb_search(
31
-    $queryarray,
32
-    $andor,
33
-    $limit,
34
-    $offset,
35
-    $userid,
36
-    $forums = 0,
37
-    $sortby = 0,
38
-    $searchin = 'both',
39
-    CriteriaCompo $criteriaExtra = null
31
+	$queryarray,
32
+	$andor,
33
+	$limit,
34
+	$offset,
35
+	$userid,
36
+	$forums = 0,
37
+	$sortby = 0,
38
+	$searchin = 'both',
39
+	CriteriaCompo $criteriaExtra = null
40 40
 ) {
41
-    global $myts, $xoopsDB;
42
-    // irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set
43
-    if (!isset($GLOBALS['xoopsModuleConfig'])) {
44
-        $GLOBALS['xoopsModuleConfig'] = newbbLoadConfig();
45
-    }
46
-    // irmtfan - in XOOPSCORE/search.php $xoopsModule is not set
47
-    if (!is_object($GLOBALS['xoopsModule']) && is_object($GLOBALS['module'])
48
-        && 'newbb' === $GLOBALS['module']->getVar('dirname')) {
49
-        $GLOBALS['xoopsModule'] = $GLOBALS['module'];
50
-    }
51
-    /** @var Newbb\ForumHandler $forumHandler */
52
-    $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
53
-    $validForums  = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view")
41
+	global $myts, $xoopsDB;
42
+	// irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set
43
+	if (!isset($GLOBALS['xoopsModuleConfig'])) {
44
+		$GLOBALS['xoopsModuleConfig'] = newbbLoadConfig();
45
+	}
46
+	// irmtfan - in XOOPSCORE/search.php $xoopsModule is not set
47
+	if (!is_object($GLOBALS['xoopsModule']) && is_object($GLOBALS['module'])
48
+		&& 'newbb' === $GLOBALS['module']->getVar('dirname')) {
49
+		$GLOBALS['xoopsModule'] = $GLOBALS['module'];
50
+	}
51
+	/** @var Newbb\ForumHandler $forumHandler */
52
+	$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
53
+	$validForums  = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view")
54 54
 
55
-    $criteriaPost = new \CriteriaCompo();
56
-    $criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts
55
+	$criteriaPost = new \CriteriaCompo();
56
+	$criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts
57 57
 
58
-    $forum_list = [];// get forum lists just for forum names
59
-    if (count($validForums) > 0) {
60
-        $criteriaPermissions = new \CriteriaCompo();
61
-        $criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND');
62
-        $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false);
63
-    }
58
+	$forum_list = [];// get forum lists just for forum names
59
+	if (count($validForums) > 0) {
60
+		$criteriaPermissions = new \CriteriaCompo();
61
+		$criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND');
62
+		$forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false);
63
+	}
64 64
 
65
-    if (is_numeric($userid) && 0 !== $userid) {
66
-        $criteriaUser = new \CriteriaCompo();
67
-        $criteriaUser->add(new \Criteria('p.uid', $userid), 'OR');
68
-    } elseif (is_array($userid) && count($userid) > 0) {
69
-        $userid       = array_map('intval', $userid);
70
-        $criteriaUser = new \CriteriaCompo();
71
-        $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
72
-    }
65
+	if (is_numeric($userid) && 0 !== $userid) {
66
+		$criteriaUser = new \CriteriaCompo();
67
+		$criteriaUser->add(new \Criteria('p.uid', $userid), 'OR');
68
+	} elseif (is_array($userid) && count($userid) > 0) {
69
+		$userid       = array_map('intval', $userid);
70
+		$criteriaUser = new \CriteriaCompo();
71
+		$criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
72
+	}
73 73
 
74
-    $count = 0;
75
-    if (is_array($queryarray)) {
76
-        $count = count($queryarray);
77
-    }
78
-    $highlightKey = '';
79
-    if ($count > 0) {
80
-        $criteriaKeywords = new \CriteriaCompo();
81
-        foreach ($queryarray as $queryTerm) {
82
-            $termCriteria  = new \CriteriaCompo();
83
-            $queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%';
84
-            if ('title' === $searchin || 'both' === $searchin) {
85
-                $termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR');
86
-            }
87
-            if ('text' === $searchin || 'both' === $searchin) {
88
-                $termCriteria->add(new \Criteria('t.post_text', $queryTermLike, 'LIKE'), 'OR');
89
-            }
90
-            $criteriaKeywords->add($termCriteria, $andor);
91
-        }
92
-        // add highlight keywords to post links
93
-        $highlightKey = '&amp;keywords=' . implode(' ', $queryarray);
94
-        $highlightKey = str_replace(' ', '+', $highlightKey);
95
-    }
96
-    $criteria = new \CriteriaCompo();
97
-    $criteria->add($criteriaPost, 'AND');
98
-    if (null !== $criteriaPermissions) {
99
-        $criteria->add($criteriaPermissions, 'AND');
100
-    }
101
-    if (isset($criteriaUser)) {
102
-        $criteria->add($criteriaUser, 'AND');
103
-    }
104
-    if (isset($criteriaKeywords)) {
105
-        $criteria->add($criteriaKeywords, 'AND');
106
-    }
107
-    if (isset($criteriaExtra)) {
108
-        $criteria->add($criteriaExtra, 'AND');
109
-    }
110
-    //$criteria->setLimit($limit); // no need for this
111
-    //$criteria->setStart($offset); // no need for this
74
+	$count = 0;
75
+	if (is_array($queryarray)) {
76
+		$count = count($queryarray);
77
+	}
78
+	$highlightKey = '';
79
+	if ($count > 0) {
80
+		$criteriaKeywords = new \CriteriaCompo();
81
+		foreach ($queryarray as $queryTerm) {
82
+			$termCriteria  = new \CriteriaCompo();
83
+			$queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%';
84
+			if ('title' === $searchin || 'both' === $searchin) {
85
+				$termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR');
86
+			}
87
+			if ('text' === $searchin || 'both' === $searchin) {
88
+				$termCriteria->add(new \Criteria('t.post_text', $queryTermLike, 'LIKE'), 'OR');
89
+			}
90
+			$criteriaKeywords->add($termCriteria, $andor);
91
+		}
92
+		// add highlight keywords to post links
93
+		$highlightKey = '&amp;keywords=' . implode(' ', $queryarray);
94
+		$highlightKey = str_replace(' ', '+', $highlightKey);
95
+	}
96
+	$criteria = new \CriteriaCompo();
97
+	$criteria->add($criteriaPost, 'AND');
98
+	if (null !== $criteriaPermissions) {
99
+		$criteria->add($criteriaPermissions, 'AND');
100
+	}
101
+	if (isset($criteriaUser)) {
102
+		$criteria->add($criteriaUser, 'AND');
103
+	}
104
+	if (isset($criteriaKeywords)) {
105
+		$criteria->add($criteriaKeywords, 'AND');
106
+	}
107
+	if (isset($criteriaExtra)) {
108
+		$criteria->add($criteriaExtra, 'AND');
109
+	}
110
+	//$criteria->setLimit($limit); // no need for this
111
+	//$criteria->setStart($offset); // no need for this
112 112
 
113
-    if (empty($sortby)) {
114
-        $sortby = 'p.post_time';
115
-    }
116
-    $criteria->setSort($sortby);
117
-    $order = 'ASC';
118
-    if ('p.post_time' === $sortby) {
119
-        $order = 'DESC';
120
-    }
121
-    $criteria->setOrder($order);
113
+	if (empty($sortby)) {
114
+		$sortby = 'p.post_time';
115
+	}
116
+	$criteria->setSort($sortby);
117
+	$order = 'ASC';
118
+	if ('p.post_time' === $sortby) {
119
+		$order = 'DESC';
120
+	}
121
+	$criteria->setOrder($order);
122 122
 
123
-    /** @var Newbb\PostHandler $postHandler */
124
-    $postHandler = Newbb\Helper::getInstance()->getHandler('Post');
125
-    $posts       = $postHandler->getPostsByLimit($criteria, $limit, $offset);
123
+	/** @var Newbb\PostHandler $postHandler */
124
+	$postHandler = Newbb\Helper::getInstance()->getHandler('Post');
125
+	$posts       = $postHandler->getPostsByLimit($criteria, $limit, $offset);
126 126
 
127
-    $ret = [];
128
-    $i   = 0;
129
-    foreach (array_keys($posts) as $id) {
130
-        /** @var Newbb\Post $post */
131
-        $post                  = $posts[$id];
132
-        $post_data             = $post->getPostBody();
133
-        $ret[$i]['topic_id']   = $post->getVar('topic_id');
134
-        $ret[$i]['link']       = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key
135
-        $ret[$i]['title']      = $post_data['subject'];
136
-        $ret[$i]['time']       = $post_data['date'];
137
-        $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']);
138
-        $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id');
139
-        $ret[$i]['post_text']  = $post_data['text'];
140
-        $ret[$i]['uid']        = $post->getVar('uid');
141
-        $ret[$i]['poster']     = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author'];
142
-        ++$i;
143
-    }
127
+	$ret = [];
128
+	$i   = 0;
129
+	foreach (array_keys($posts) as $id) {
130
+		/** @var Newbb\Post $post */
131
+		$post                  = $posts[$id];
132
+		$post_data             = $post->getPostBody();
133
+		$ret[$i]['topic_id']   = $post->getVar('topic_id');
134
+		$ret[$i]['link']       = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key
135
+		$ret[$i]['title']      = $post_data['subject'];
136
+		$ret[$i]['time']       = $post_data['date'];
137
+		$ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']);
138
+		$ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id');
139
+		$ret[$i]['post_text']  = $post_data['text'];
140
+		$ret[$i]['uid']        = $post->getVar('uid');
141
+		$ret[$i]['poster']     = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author'];
142
+		++$i;
143
+	}
144 144
 
145
-    return $ret;
145
+	return $ret;
146 146
 }
Please login to merge, or discard this patch.
include/notification.inc.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,42 +54,42 @@
 block discarded – undo
54 54
 
55 55
         if ('forum' === $category) {
56 56
             // Assume we have a valid forum id
57
-            $sql = 'SELECT forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' WHERE forum_id = ' . $item_id;
57
+            $sql = 'SELECT forum_name FROM '.$GLOBALS['xoopsDB']->prefix('newbb_forums').' WHERE forum_id = '.$item_id;
58 58
             if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
59 59
                 // irmtfan full URL
60
-                redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERRORFORUM);
60
+                redirect_header(XOOPS_URL.'/modules/'.$module->getVar('dirname').'index.php', 2, _MD_NEWBB_ERRORFORUM);
61 61
             }
62 62
             $result_array = $GLOBALS['xoopsDB']->fetchArray($result);
63 63
             $item['name'] = $result_array['forum_name'];
64
-            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewforum.php?forum=' . $item_id;
64
+            $item['url']  = XOOPS_URL.'/modules/'.$module->getVar('dirname').'/viewforum.php?forum='.$item_id;
65 65
 
66 66
             return $item;
67 67
         }
68 68
 
69 69
         if ('thread' === $category) {
70 70
             // Assume we have a valid topid id
71
-            $sql = 'SELECT t.topic_title,f.forum_id,f.forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' t, ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' f WHERE t.forum_id = f.forum_id AND t.topic_id = ' . $item_id . ' LIMIT 1';
71
+            $sql = 'SELECT t.topic_title,f.forum_id,f.forum_name FROM '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' t, '.$GLOBALS['xoopsDB']->prefix('newbb_forums').' f WHERE t.forum_id = f.forum_id AND t.topic_id = '.$item_id.' LIMIT 1';
72 72
             if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
73 73
                 // irmtfan full URL
74
-                redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED);
74
+                redirect_header(XOOPS_URL.'/modules/'.$module->getVar('dirname').'index.php', 2, _MD_NEWBB_ERROROCCURED);
75 75
             }
76 76
             $result_array = $GLOBALS['xoopsDB']->fetchArray($result);
77 77
             $item['name'] = $result_array['topic_title'];
78
-            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum=' . $result_array['forum_id'] . '&topic_id=' . $item_id;
78
+            $item['url']  = XOOPS_URL.'/modules/'.$module->getVar('dirname').'/viewtopic.php?forum='.$result_array['forum_id'].'&topic_id='.$item_id;
79 79
 
80 80
             return $item;
81 81
         }
82 82
 
83 83
         if ('post' === $category) {
84 84
             // Assume we have a valid post id
85
-            $sql = 'SELECT subject,topic_id,forum_id FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $item_id . ' LIMIT 1';
85
+            $sql = 'SELECT subject,topic_id,forum_id FROM '.$GLOBALS['xoopsDB']->prefix('newbb_posts').' WHERE post_id = '.$item_id.' LIMIT 1';
86 86
             if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
87 87
                 // irmtfan full URL
88
-                redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED);
88
+                redirect_header(XOOPS_URL.'/modules/'.$module->getVar('dirname').'index.php', 2, _MD_NEWBB_ERROROCCURED);
89 89
             }
90 90
             $result_array = $GLOBALS['xoopsDB']->fetchArray($result);
91 91
             $item['name'] = $result_array['subject'];
92
-            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum= ' . $result_array['forum_id'] . '&amp;topic_id=' . $result_array['topic_id'] . '#forumpost' . $item_id;
92
+            $item['url']  = XOOPS_URL.'/modules/'.$module->getVar('dirname').'/viewtopic.php?forum= '.$result_array['forum_id'].'&amp;topic_id='.$result_array['topic_id'].'#forumpost'.$item_id;
93 93
 
94 94
             return $item;
95 95
         }
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -31,67 +31,67 @@
 block discarded – undo
31 31
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
32 32
 require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.php');
33 33
 if (!defined('NEWBB_NOTIFY_ITEMINFO')) {
34
-    define('NEWBB_NOTIFY_ITEMINFO', 1);
34
+	define('NEWBB_NOTIFY_ITEMINFO', 1);
35 35
 
36
-    /**
37
-     * @param $category
38
-     * @param $item_id
39
-     * @return mixed
40
-     */
41
-    function newbb_notify_iteminfo($category, $item_id)
42
-    {
43
-        /** @var \XoopsModuleHandler $moduleHandler */
44
-        $moduleHandler = xoops_getHandler('module');
45
-        $module        = $moduleHandler->getByDirname('newbb');
36
+	/**
37
+	 * @param $category
38
+	 * @param $item_id
39
+	 * @return mixed
40
+	 */
41
+	function newbb_notify_iteminfo($category, $item_id)
42
+	{
43
+		/** @var \XoopsModuleHandler $moduleHandler */
44
+		$moduleHandler = xoops_getHandler('module');
45
+		$module        = $moduleHandler->getByDirname('newbb');
46 46
 
47
-        if ('global' === $category) {
48
-            $item['name'] = '';
49
-            $item['url']  = '';
47
+		if ('global' === $category) {
48
+			$item['name'] = '';
49
+			$item['url']  = '';
50 50
 
51
-            return $item;
52
-        }
53
-        $item_id = (int)$item_id;
51
+			return $item;
52
+		}
53
+		$item_id = (int)$item_id;
54 54
 
55
-        if ('forum' === $category) {
56
-            // Assume we have a valid forum id
57
-            $sql = 'SELECT forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' WHERE forum_id = ' . $item_id;
58
-            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
59
-                // irmtfan full URL
60
-                redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERRORFORUM);
61
-            }
62
-            $result_array = $GLOBALS['xoopsDB']->fetchArray($result);
63
-            $item['name'] = $result_array['forum_name'];
64
-            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewforum.php?forum=' . $item_id;
55
+		if ('forum' === $category) {
56
+			// Assume we have a valid forum id
57
+			$sql = 'SELECT forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' WHERE forum_id = ' . $item_id;
58
+			if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
59
+				// irmtfan full URL
60
+				redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERRORFORUM);
61
+			}
62
+			$result_array = $GLOBALS['xoopsDB']->fetchArray($result);
63
+			$item['name'] = $result_array['forum_name'];
64
+			$item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewforum.php?forum=' . $item_id;
65 65
 
66
-            return $item;
67
-        }
66
+			return $item;
67
+		}
68 68
 
69
-        if ('thread' === $category) {
70
-            // Assume we have a valid topid id
71
-            $sql = 'SELECT t.topic_title,f.forum_id,f.forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' t, ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' f WHERE t.forum_id = f.forum_id AND t.topic_id = ' . $item_id . ' LIMIT 1';
72
-            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
73
-                // irmtfan full URL
74
-                redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED);
75
-            }
76
-            $result_array = $GLOBALS['xoopsDB']->fetchArray($result);
77
-            $item['name'] = $result_array['topic_title'];
78
-            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum=' . $result_array['forum_id'] . '&topic_id=' . $item_id;
69
+		if ('thread' === $category) {
70
+			// Assume we have a valid topid id
71
+			$sql = 'SELECT t.topic_title,f.forum_id,f.forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' t, ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' f WHERE t.forum_id = f.forum_id AND t.topic_id = ' . $item_id . ' LIMIT 1';
72
+			if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
73
+				// irmtfan full URL
74
+				redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED);
75
+			}
76
+			$result_array = $GLOBALS['xoopsDB']->fetchArray($result);
77
+			$item['name'] = $result_array['topic_title'];
78
+			$item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum=' . $result_array['forum_id'] . '&topic_id=' . $item_id;
79 79
 
80
-            return $item;
81
-        }
80
+			return $item;
81
+		}
82 82
 
83
-        if ('post' === $category) {
84
-            // Assume we have a valid post id
85
-            $sql = 'SELECT subject,topic_id,forum_id FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $item_id . ' LIMIT 1';
86
-            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
87
-                // irmtfan full URL
88
-                redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED);
89
-            }
90
-            $result_array = $GLOBALS['xoopsDB']->fetchArray($result);
91
-            $item['name'] = $result_array['subject'];
92
-            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum= ' . $result_array['forum_id'] . '&amp;topic_id=' . $result_array['topic_id'] . '#forumpost' . $item_id;
83
+		if ('post' === $category) {
84
+			// Assume we have a valid post id
85
+			$sql = 'SELECT subject,topic_id,forum_id FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $item_id . ' LIMIT 1';
86
+			if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
87
+				// irmtfan full URL
88
+				redirect_header(XOOPS_URL . '/modules/' . $module->getVar('dirname') . 'index.php', 2, _MD_NEWBB_ERROROCCURED);
89
+			}
90
+			$result_array = $GLOBALS['xoopsDB']->fetchArray($result);
91
+			$item['name'] = $result_array['subject'];
92
+			$item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum= ' . $result_array['forum_id'] . '&amp;topic_id=' . $result_array['topic_id'] . '#forumpost' . $item_id;
93 93
 
94
-            return $item;
95
-        }
96
-    }
94
+			return $item;
95
+		}
96
+	}
97 97
 }
Please login to merge, or discard this patch.
include/plugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
 // MENU handler
75 75
 /* You could remove anyone by commenting out in order to disable it */
76 76
 $customConfig['valid_menumodes'] = [
77
-    0 => _MD_NEWBB_MENU_SELECT,    // for selectbox
77
+    0 => _MD_NEWBB_MENU_SELECT, // for selectbox
78 78
     //1 => _MD_NEWBB_MENU_CLICK,    // for "click to expand"
79 79
     //2 => _MD_NEWBB_MENU_HOVER        // for "mouse hover to expand"
80 80
 ];
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@
 block discarded – undo
74 74
 // MENU handler
75 75
 /* You could remove anyone by commenting out in order to disable it */
76 76
 $customConfig['valid_menumodes'] = [
77
-    0 => _MD_NEWBB_MENU_SELECT,    // for selectbox
78
-    //1 => _MD_NEWBB_MENU_CLICK,    // for "click to expand"
79
-    //2 => _MD_NEWBB_MENU_HOVER        // for "mouse hover to expand"
77
+	0 => _MD_NEWBB_MENU_SELECT,    // for selectbox
78
+	//1 => _MD_NEWBB_MENU_CLICK,    // for "click to expand"
79
+	//2 => _MD_NEWBB_MENU_HOVER        // for "mouse hover to expand"
80 80
 ];
81 81
 
82 82
 // view latest edit
Please login to merge, or discard this patch.
include/plugin.dist.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,8 +72,8 @@
 block discarded – undo
72 72
 // MENU handler
73 73
 /* You could remove anyone by commenting out in order to disable it */
74 74
 $valid_menumodes = [
75
-    0 => _MD_NEWBB_MENU_SELECT,    // for selectbox
76
-    1 => _MD_NEWBB_MENU_CLICK,    // for 'click to expand'
75
+    0 => _MD_NEWBB_MENU_SELECT, // for selectbox
76
+    1 => _MD_NEWBB_MENU_CLICK, // for 'click to expand'
77 77
     2 => _MD_NEWBB_MENU_HOVER        // for 'mouse hover to expand'
78 78
 ];
79 79
 
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,9 +72,9 @@
 block discarded – undo
72 72
 // MENU handler
73 73
 /* You could remove anyone by commenting out in order to disable it */
74 74
 $valid_menumodes = [
75
-    0 => _MD_NEWBB_MENU_SELECT,    // for selectbox
76
-    1 => _MD_NEWBB_MENU_CLICK,    // for 'click to expand'
77
-    2 => _MD_NEWBB_MENU_HOVER        // for 'mouse hover to expand'
75
+	0 => _MD_NEWBB_MENU_SELECT,    // for selectbox
76
+	1 => _MD_NEWBB_MENU_CLICK,    // for 'click to expand'
77
+	2 => _MD_NEWBB_MENU_HOVER        // for 'mouse hover to expand'
78 78
 ];
79 79
 
80 80
 return $customConfig;
Please login to merge, or discard this patch.
include/functions.image.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -39,24 +39,24 @@  discard block
 block discarded – undo
39 39
     function newbbAttachmentImage($source)
40 40
     {
41 41
         $img_path   = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']);
42
-        $img_url    = XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'];
43
-        $thumb_path = $img_path . '/thumbs';
44
-        $thumb_url  = $img_url . '/thumbs';
42
+        $img_url    = XOOPS_URL.'/'.$GLOBALS['xoopsModuleConfig']['dir_attachments'];
43
+        $thumb_path = $img_path.'/thumbs';
44
+        $thumb_url  = $img_url.'/thumbs';
45 45
 
46
-        $thumb     = $thumb_path . '/' . $source;
47
-        $image     = $img_path . '/' . $source;
48
-        $thumb_url = $thumb_url . '/' . $source;
49
-        $image_url = $img_url . '/' . $source;
46
+        $thumb     = $thumb_path.'/'.$source;
47
+        $image     = $img_path.'/'.$source;
48
+        $thumb_url = $thumb_url.'/'.$source;
49
+        $image_url = $img_url.'/'.$source;
50 50
 
51 51
         $imginfo  = @getimagesize($image);
52
-        $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : '';
52
+        $img_info = (count($imginfo) > 0) ? $imginfo[0].'X'.$imginfo[1].' px' : '';
53 53
 
54 54
         if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0
55 55
             && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) {
56 56
             if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width']
57 57
                 || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
58 58
                 //if (!file_exists($thumb_path.'/'.$source) && $imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_img_width']) {
59
-                if (!file_exists($thumb_path . '/' . $source)) {
59
+                if (!file_exists($thumb_path.'/'.$source)) {
60 60
                     newbbCreateThumbnail($source, $GLOBALS['xoopsModuleConfig']['max_image_width']);
61 61
                 }
62 62
             }
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
                 || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
66 66
                 $pseudo_width  = $GLOBALS['xoopsModuleConfig']['max_image_width'];
67 67
                 $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_width'] * ($imginfo[1] / $imginfo[0]);
68
-                $pseudo_size   = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'";
68
+                $pseudo_size   = "width='".$pseudo_width."px' height='".$pseudo_height."px'";
69 69
             }
70 70
             // irmtfan to fix Undefined variable: pseudo_height
71 71
             if (!empty($pseudo_height) && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0
72 72
                 && $pseudo_height > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
73 73
                 $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_height'];
74 74
                 $pseudo_width  = $GLOBALS['xoopsModuleConfig']['max_image_height'] * ($imginfo[0] / $imginfo[1]);
75
-                $pseudo_size   = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'";
75
+                $pseudo_size   = "width='".$pseudo_width."px' height='".$pseudo_height."px'";
76 76
             }
77 77
         }
78 78
 
79 79
         if (file_exists($thumb)) {
80
-            $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">';
80
+            $attachmentImage = '<a href="'.$image_url.'" title="'.$source.' '.$img_info.'" target="_blank">';
81 81
             // $attachmentImage .= '<img src="' . $thumb_url . '" alt="' . $source . ' ' . $img_info . '" />';
82
-            $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />';
82
+            $attachmentImage .= '<img src="'.$image_url.'" '.$pseudo_size.' alt="'.$source.' '.$img_info.'" />';
83 83
             $attachmentImage .= '</a>';
84 84
         } elseif (!empty($pseudo_size)) {
85
-            $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">';
86
-            $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />';
85
+            $attachmentImage = '<a href="'.$image_url.'" title="'.$source.' '.$img_info.'" target="_blank">';
86
+            $attachmentImage .= '<img src="'.$image_url.'" '.$pseudo_size.' alt="'.$source.' '.$img_info.'" />';
87 87
             $attachmentImage .= '</a>';
88 88
         } elseif (file_exists($image)) {
89
-            $attachmentImage = '<img src="' . $image_url . '" alt="' . $source . ' ' . $img_info . '" />';
89
+            $attachmentImage = '<img src="'.$image_url.'" alt="'.$source.' '.$img_info.'" />';
90 90
         } else {
91 91
             $attachmentImage = '';
92 92
         }
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $cmd        = '';
105 105
         $img_path   = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']);
106
-        $thumb_path = $img_path . '/thumbs';
107
-        $src_file   = $img_path . '/' . $source;
108
-        $new_file   = $thumb_path . '/' . $source;
106
+        $thumb_path = $img_path.'/thumbs';
107
+        $src_file   = $img_path.'/'.$source;
108
+        $new_file   = $thumb_path.'/'.$source;
109 109
         //$imageLibs = newbb_getImageLibs();
110 110
 
111 111
         if (!filesize($src_file) || !is_readable($src_file)) {
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
         if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
132 132
             if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
133 133
                 $cur_dir     = __DIR__;
134
-                $src_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $src_file) . '"';
135
-                $new_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $new_file) . '"';
134
+                $src_file_im = '"'.$cur_dir.'\\'.str_replace('/', '\\', $src_file).'"';
135
+                $new_file_im = '"'.$cur_dir.'\\'.str_replace('/', '\\', $new_file).'"';
136 136
             } else {
137 137
                 $src_file_im = @escapeshellarg($src_file);
138 138
                 $new_file_im = @escapeshellarg($new_file);
139 139
             }
140
-            $path           = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
141
-            $magick_command = $path . 'convert -quality 85 -antialias -sample ' . $newWidth . 'x' . $newHeight . ' ' . $src_file_im . ' +profile "*" ' . str_replace('\\', '/', $new_file_im) . '';
140
+            $path           = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'].'/';
141
+            $magick_command = $path.'convert -quality 85 -antialias -sample '.$newWidth.'x'.$newHeight.' '.$src_file_im.' +profile "*" '.str_replace('\\', '/', $new_file_im).'';
142 142
 
143 143
             @passthru($magick_command);
144 144
             if (file_exists($new_file)) {
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
         }
148 148
 
149 149
         if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
150
-            $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
150
+            $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'].'/';
151 151
             if (preg_match("/\.png/", $source)) {
152
-                $cmd = $path . "pngtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "pnmtopng > $new_file";
152
+                $cmd = $path."pngtopnm $src_file | ".$path."pnmscale -xysize $newWidth $newHeight | ".$path."pnmtopng > $new_file";
153 153
             } elseif (preg_match("/\.(jpg|jpeg)/", $source)) {
154
-                $cmd = $path . "jpegtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "ppmtojpeg -quality=90 > $new_file";
154
+                $cmd = $path."jpegtopnm $src_file | ".$path."pnmscale -xysize $newWidth $newHeight | ".$path."ppmtojpeg -quality=90 > $new_file";
155 155
             } elseif (preg_match("/\.gif/", $source)) {
156
-                $cmd = $path . "giftopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | ppmquant 256 | " . $path . "ppmtogif > $new_file";
156
+                $cmd = $path."giftopnm $src_file | ".$path."pnmscale -xysize $newWidth $newHeight | ppmquant 256 | ".$path."ppmtogif > $new_file";
157 157
             }
158 158
 
159 159
             @exec($cmd, $output, $retval);
Please login to merge, or discard this patch.
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -30,192 +30,192 @@
 block discarded – undo
30 30
 //  ------------------------------------------------------------------------ //
31 31
 
32 32
 if (!defined('NEWBB_FUNCTIONS_IMAGE')) {
33
-    define('NEWBB_FUNCTIONS_IMAGE', true);
34
-
35
-    /**
36
-     * @param $source
37
-     * @return string
38
-     */
39
-    function newbbAttachmentImage($source)
40
-    {
41
-        $img_path   = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']);
42
-        $img_url    = XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'];
43
-        $thumb_path = $img_path . '/thumbs';
44
-        $thumb_url  = $img_url . '/thumbs';
45
-
46
-        $thumb     = $thumb_path . '/' . $source;
47
-        $image     = $img_path . '/' . $source;
48
-        $thumb_url = $thumb_url . '/' . $source;
49
-        $image_url = $img_url . '/' . $source;
50
-
51
-        $imginfo  = @getimagesize($image);
52
-        $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : '';
53
-
54
-        if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0
55
-            && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) {
56
-            if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width']
57
-                || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
58
-                //if (!file_exists($thumb_path.'/'.$source) && $imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_img_width']) {
59
-                if (!file_exists($thumb_path . '/' . $source)) {
60
-                    newbbCreateThumbnail($source, $GLOBALS['xoopsModuleConfig']['max_image_width']);
61
-                }
62
-            }
63
-
64
-            if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width']
65
-                || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
66
-                $pseudo_width  = $GLOBALS['xoopsModuleConfig']['max_image_width'];
67
-                $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_width'] * ($imginfo[1] / $imginfo[0]);
68
-                $pseudo_size   = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'";
69
-            }
70
-            // irmtfan to fix Undefined variable: pseudo_height
71
-            if (!empty($pseudo_height) && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0
72
-                && $pseudo_height > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
73
-                $pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_height'];
74
-                $pseudo_width  = $GLOBALS['xoopsModuleConfig']['max_image_height'] * ($imginfo[0] / $imginfo[1]);
75
-                $pseudo_size   = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'";
76
-            }
77
-        }
78
-
79
-        if (file_exists($thumb)) {
80
-            $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">';
81
-            // $attachmentImage .= '<img src="' . $thumb_url . '" alt="' . $source . ' ' . $img_info . '" />';
82
-            $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />';
83
-            $attachmentImage .= '</a>';
84
-        } elseif (!empty($pseudo_size)) {
85
-            $attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">';
86
-            $attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />';
87
-            $attachmentImage .= '</a>';
88
-        } elseif (file_exists($image)) {
89
-            $attachmentImage = '<img src="' . $image_url . '" alt="' . $source . ' ' . $img_info . '" />';
90
-        } else {
91
-            $attachmentImage = '';
92
-        }
93
-
94
-        return $attachmentImage;
95
-    }
96
-
97
-    /**
98
-     * @param $source
99
-     * @param $thumb_width
100
-     * @return bool
101
-     */
102
-    function newbbCreateThumbnail($source, $thumb_width)
103
-    {
104
-        $cmd        = '';
105
-        $img_path   = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']);
106
-        $thumb_path = $img_path . '/thumbs';
107
-        $src_file   = $img_path . '/' . $source;
108
-        $new_file   = $thumb_path . '/' . $source;
109
-        //$imageLibs = newbb_getImageLibs();
110
-
111
-        if (!filesize($src_file) || !is_readable($src_file)) {
112
-            return false;
113
-        }
114
-
115
-        if (!is_dir($thumb_path) || !is_writable($thumb_path)) {
116
-            return false;
117
-        }
118
-
119
-        $imginfo = @getimagesize($src_file);
120
-
121
-        if (null === $imginfo) {
122
-            return false;
123
-        }
124
-        if ($imginfo[0] < $thumb_width) {
125
-            return false;
126
-        }
127
-
128
-        $newWidth  = (int)min($imginfo[0], $thumb_width);
129
-        $newHeight = (int)($imginfo[1] * $newWidth / $imginfo[0]);
130
-
131
-        if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
132
-            if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
133
-                $cur_dir     = __DIR__;
134
-                $src_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $src_file) . '"';
135
-                $new_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $new_file) . '"';
136
-            } else {
137
-                $src_file_im = @escapeshellarg($src_file);
138
-                $new_file_im = @escapeshellarg($new_file);
139
-            }
140
-            $path           = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
141
-            $magick_command = $path . 'convert -quality 85 -antialias -sample ' . $newWidth . 'x' . $newHeight . ' ' . $src_file_im . ' +profile "*" ' . str_replace('\\', '/', $new_file_im) . '';
142
-
143
-            @passthru($magick_command);
144
-            if (file_exists($new_file)) {
145
-                return true;
146
-            }
147
-        }
148
-
149
-        if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
150
-            $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
151
-            if (preg_match("/\.png/", $source)) {
152
-                $cmd = $path . "pngtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "pnmtopng > $new_file";
153
-            } elseif (preg_match("/\.(jpg|jpeg)/", $source)) {
154
-                $cmd = $path . "jpegtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "ppmtojpeg -quality=90 > $new_file";
155
-            } elseif (preg_match("/\.gif/", $source)) {
156
-                $cmd = $path . "giftopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | ppmquant 256 | " . $path . "ppmtogif > $new_file";
157
-            }
158
-
159
-            @exec($cmd, $output, $retval);
160
-            if (file_exists($new_file)) {
161
-                return true;
162
-            }
163
-        }
164
-
165
-        $type            = $imginfo[2];
166
-        $supported_types = [];
167
-
168
-        if (!extension_loaded('gd')) {
169
-            return false;
170
-        }
171
-        if (function_exists('imagegif')) {
172
-            $supported_types[] = 1;
173
-        }
174
-        if (function_exists('imagejpeg')) {
175
-            $supported_types[] = 2;
176
-        }
177
-        if (function_exists('imagepng')) {
178
-            $supported_types[] = 3;
179
-        }
180
-
181
-        $imageCreateFunction = function_exists('imagecreatetruecolor') ? 'imagecreatetruecolor' : 'imagecreate';
182
-
183
-        if (in_array($type, $supported_types)) {
184
-            switch ($type) {
185
-                case 1:
186
-                    if (!function_exists('imagecreatefromgif')) {
187
-                        return false;
188
-                    }
189
-                    $im     = imagecreatefromgif($src_file);
190
-                    $new_im = imagecreate($newWidth, $newHeight);
191
-                    imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]);
192
-                    imagegif($new_im, $new_file);
193
-                    imagedestroy($im);
194
-                    imagedestroy($new_im);
195
-                    break;
196
-                case 2:
197
-                    $im     = imagecreatefromjpeg($src_file);
198
-                    $new_im = $imageCreateFunction($newWidth, $newHeight);
199
-                    imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]);
200
-                    imagejpeg($new_im, $new_file, 90);
201
-                    imagedestroy($im);
202
-                    imagedestroy($new_im);
203
-                    break;
204
-                case 3:
205
-                    $im     = imagecreatefrompng($src_file);
206
-                    $new_im = $imageCreateFunction($newWidth, $newHeight);
207
-                    imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]);
208
-                    imagepng($new_im, $new_file);
209
-                    imagedestroy($im);
210
-                    imagedestroy($new_im);
211
-                    break;
212
-            }
213
-        }
214
-
215
-        if (file_exists($new_file)) {
216
-            return true;
217
-        } else {
218
-            return false;
219
-        }
220
-    }
33
+	define('NEWBB_FUNCTIONS_IMAGE', true);
34
+
35
+	/**
36
+	 * @param $source
37
+	 * @return string
38
+	 */
39
+	function newbbAttachmentImage($source)
40
+	{
41
+		$img_path   = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']);
42
+		$img_url    = XOOPS_URL . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'];
43
+		$thumb_path = $img_path . '/thumbs';
44
+		$thumb_url  = $img_url . '/thumbs';
45
+
46
+		$thumb     = $thumb_path . '/' . $source;
47
+		$image     = $img_path . '/' . $source;
48
+		$thumb_url = $thumb_url . '/' . $source;
49
+		$image_url = $img_url . '/' . $source;
50
+
51
+		$imginfo  = @getimagesize($image);
52
+		$img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : '';
53
+
54
+		if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0
55
+			&& $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) {
56
+			if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width']
57
+				|| $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
58
+				//if (!file_exists($thumb_path.'/'.$source) && $imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_img_width']) {
59
+				if (!file_exists($thumb_path . '/' . $source)) {
60
+					newbbCreateThumbnail($source, $GLOBALS['xoopsModuleConfig']['max_image_width']);
61
+				}
62
+			}
63
+
64
+			if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width']
65
+				|| $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
66
+				$pseudo_width  = $GLOBALS['xoopsModuleConfig']['max_image_width'];
67
+				$pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_width'] * ($imginfo[1] / $imginfo[0]);
68
+				$pseudo_size   = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'";
69
+			}
70
+			// irmtfan to fix Undefined variable: pseudo_height
71
+			if (!empty($pseudo_height) && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0
72
+				&& $pseudo_height > $GLOBALS['xoopsModuleConfig']['max_image_height']) {
73
+				$pseudo_height = $GLOBALS['xoopsModuleConfig']['max_image_height'];
74
+				$pseudo_width  = $GLOBALS['xoopsModuleConfig']['max_image_height'] * ($imginfo[0] / $imginfo[1]);
75
+				$pseudo_size   = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'";
76
+			}
77
+		}
78
+
79
+		if (file_exists($thumb)) {
80
+			$attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">';
81
+			// $attachmentImage .= '<img src="' . $thumb_url . '" alt="' . $source . ' ' . $img_info . '" />';
82
+			$attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />';
83
+			$attachmentImage .= '</a>';
84
+		} elseif (!empty($pseudo_size)) {
85
+			$attachmentImage = '<a href="' . $image_url . '" title="' . $source . ' ' . $img_info . '" target="_blank">';
86
+			$attachmentImage .= '<img src="' . $image_url . '" ' . $pseudo_size . ' alt="' . $source . ' ' . $img_info . '" />';
87
+			$attachmentImage .= '</a>';
88
+		} elseif (file_exists($image)) {
89
+			$attachmentImage = '<img src="' . $image_url . '" alt="' . $source . ' ' . $img_info . '" />';
90
+		} else {
91
+			$attachmentImage = '';
92
+		}
93
+
94
+		return $attachmentImage;
95
+	}
96
+
97
+	/**
98
+	 * @param $source
99
+	 * @param $thumb_width
100
+	 * @return bool
101
+	 */
102
+	function newbbCreateThumbnail($source, $thumb_width)
103
+	{
104
+		$cmd        = '';
105
+		$img_path   = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments']);
106
+		$thumb_path = $img_path . '/thumbs';
107
+		$src_file   = $img_path . '/' . $source;
108
+		$new_file   = $thumb_path . '/' . $source;
109
+		//$imageLibs = newbb_getImageLibs();
110
+
111
+		if (!filesize($src_file) || !is_readable($src_file)) {
112
+			return false;
113
+		}
114
+
115
+		if (!is_dir($thumb_path) || !is_writable($thumb_path)) {
116
+			return false;
117
+		}
118
+
119
+		$imginfo = @getimagesize($src_file);
120
+
121
+		if (null === $imginfo) {
122
+			return false;
123
+		}
124
+		if ($imginfo[0] < $thumb_width) {
125
+			return false;
126
+		}
127
+
128
+		$newWidth  = (int)min($imginfo[0], $thumb_width);
129
+		$newHeight = (int)($imginfo[1] * $newWidth / $imginfo[0]);
130
+
131
+		if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
132
+			if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
133
+				$cur_dir     = __DIR__;
134
+				$src_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $src_file) . '"';
135
+				$new_file_im = '"' . $cur_dir . '\\' . str_replace('/', '\\', $new_file) . '"';
136
+			} else {
137
+				$src_file_im = @escapeshellarg($src_file);
138
+				$new_file_im = @escapeshellarg($new_file);
139
+			}
140
+			$path           = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
141
+			$magick_command = $path . 'convert -quality 85 -antialias -sample ' . $newWidth . 'x' . $newHeight . ' ' . $src_file_im . ' +profile "*" ' . str_replace('\\', '/', $new_file_im) . '';
142
+
143
+			@passthru($magick_command);
144
+			if (file_exists($new_file)) {
145
+				return true;
146
+			}
147
+		}
148
+
149
+		if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
150
+			$path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
151
+			if (preg_match("/\.png/", $source)) {
152
+				$cmd = $path . "pngtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "pnmtopng > $new_file";
153
+			} elseif (preg_match("/\.(jpg|jpeg)/", $source)) {
154
+				$cmd = $path . "jpegtopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | " . $path . "ppmtojpeg -quality=90 > $new_file";
155
+			} elseif (preg_match("/\.gif/", $source)) {
156
+				$cmd = $path . "giftopnm $src_file | " . $path . "pnmscale -xysize $newWidth $newHeight | ppmquant 256 | " . $path . "ppmtogif > $new_file";
157
+			}
158
+
159
+			@exec($cmd, $output, $retval);
160
+			if (file_exists($new_file)) {
161
+				return true;
162
+			}
163
+		}
164
+
165
+		$type            = $imginfo[2];
166
+		$supported_types = [];
167
+
168
+		if (!extension_loaded('gd')) {
169
+			return false;
170
+		}
171
+		if (function_exists('imagegif')) {
172
+			$supported_types[] = 1;
173
+		}
174
+		if (function_exists('imagejpeg')) {
175
+			$supported_types[] = 2;
176
+		}
177
+		if (function_exists('imagepng')) {
178
+			$supported_types[] = 3;
179
+		}
180
+
181
+		$imageCreateFunction = function_exists('imagecreatetruecolor') ? 'imagecreatetruecolor' : 'imagecreate';
182
+
183
+		if (in_array($type, $supported_types)) {
184
+			switch ($type) {
185
+				case 1:
186
+					if (!function_exists('imagecreatefromgif')) {
187
+						return false;
188
+					}
189
+					$im     = imagecreatefromgif($src_file);
190
+					$new_im = imagecreate($newWidth, $newHeight);
191
+					imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]);
192
+					imagegif($new_im, $new_file);
193
+					imagedestroy($im);
194
+					imagedestroy($new_im);
195
+					break;
196
+				case 2:
197
+					$im     = imagecreatefromjpeg($src_file);
198
+					$new_im = $imageCreateFunction($newWidth, $newHeight);
199
+					imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]);
200
+					imagejpeg($new_im, $new_file, 90);
201
+					imagedestroy($im);
202
+					imagedestroy($new_im);
203
+					break;
204
+				case 3:
205
+					$im     = imagecreatefrompng($src_file);
206
+					$new_im = $imageCreateFunction($newWidth, $newHeight);
207
+					imagecopyresized($new_im, $im, 0, 0, 0, 0, $newWidth, $newHeight, $imginfo[0], $imginfo[1]);
208
+					imagepng($new_im, $new_file);
209
+					imagedestroy($im);
210
+					imagedestroy($new_im);
211
+					break;
212
+			}
213
+		}
214
+
215
+		if (file_exists($new_file)) {
216
+			return true;
217
+		} else {
218
+			return false;
219
+		}
220
+	}
221 221
 }
Please login to merge, or discard this patch.
include/functions.user.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -222,7 +222,7 @@
 block discarded – undo
222 222
         return $forum_moderators;
223 223
     }
224 224
 
225
-    $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums');
225
+    $sql = 'SELECT forum_moderator FROM '.$GLOBALS['xoopsDB']->prefix('newbb_forums');
226 226
     if ($result = $GLOBALS['xoopsDB']->query($sql)) {
227 227
         while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
228 228
             if (empty($myrow['forum_moderator'])) {
Please login to merge, or discard this patch.
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function newbbGetUnameFromIds($uid, $usereal = 0, $linked = false)
31 31
 {
32
-    xoops_load('xoopsuserutility');
33
-    $ids = \XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked);
32
+	xoops_load('xoopsuserutility');
33
+	$ids = \XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked);
34 34
 
35
-    return $ids;
35
+	return $ids;
36 36
 }
37 37
 
38 38
 /**
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
  */
44 44
 function newbbGetUnameFromId($uid, $usereal = 0, $linked = false)
45 45
 {
46
-    xoops_load('xoopsuserutility');
46
+	xoops_load('xoopsuserutility');
47 47
 
48
-    return \XoopsUserUtility::getUnameFromId($uid, $usereal, $linked);
48
+	return \XoopsUserUtility::getUnameFromId($uid, $usereal, $linked);
49 49
 }
50 50
 
51 51
 /**
@@ -57,41 +57,41 @@  discard block
 block discarded – undo
57 57
  */
58 58
 function newbbIsAdministrator($user = -1, $mid = 0)
59 59
 {
60
-    global $xoopsModule;
61
-
62
-    if (is_numeric($user) && -1 == $user) {
63
-        $user = $GLOBALS['xoopsUser'];
64
-    }
65
-    if (!is_object($user) && (int)$user < 1) {
66
-        return false;
67
-    }
68
-    $uid = is_object($user) ? $user->getVar('uid') : (int)$user;
69
-
70
-    if (!$mid) {
71
-        if (is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname', 'n')) {
72
-            $mid = $xoopsModule->getVar('mid', 'n');
73
-        } else {
74
-            /** @var \XoopsModuleHandler $moduleHandler */
75
-            $moduleHandler = xoops_getHandler('module');
76
-            $newbb_module  = $moduleHandler->getByDirname('newbb');
77
-            $mid           = $newbb_module->getVar('mid', 'n');
78
-            unset($newbb_module);
79
-        }
80
-    }
81
-
82
-    if (is_object($xoopsModule) && is_object($GLOBALS['xoopsUser']) && $mid == $xoopsModule->getVar('mid', 'n')
83
-        && $uid == $GLOBALS['xoopsUser']->getVar('uid', 'n')) {
84
-        return $GLOBALS['xoopsUserIsAdmin'];
85
-    }
86
-
87
-    /** @var \XoopsMemberHandler $memberHandler */
88
-    $memberHandler = xoops_getHandler('member');
89
-    $groups        = $memberHandler->getGroupsByUser($uid);
90
-
91
-    /** @var \XoopsGroupPermHandler $grouppermHandler */
92
-    $grouppermHandler = xoops_getHandler('groupperm');
93
-
94
-    return $grouppermHandler->checkRight('module_admin', $mid, $groups);
60
+	global $xoopsModule;
61
+
62
+	if (is_numeric($user) && -1 == $user) {
63
+		$user = $GLOBALS['xoopsUser'];
64
+	}
65
+	if (!is_object($user) && (int)$user < 1) {
66
+		return false;
67
+	}
68
+	$uid = is_object($user) ? $user->getVar('uid') : (int)$user;
69
+
70
+	if (!$mid) {
71
+		if (is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname', 'n')) {
72
+			$mid = $xoopsModule->getVar('mid', 'n');
73
+		} else {
74
+			/** @var \XoopsModuleHandler $moduleHandler */
75
+			$moduleHandler = xoops_getHandler('module');
76
+			$newbb_module  = $moduleHandler->getByDirname('newbb');
77
+			$mid           = $newbb_module->getVar('mid', 'n');
78
+			unset($newbb_module);
79
+		}
80
+	}
81
+
82
+	if (is_object($xoopsModule) && is_object($GLOBALS['xoopsUser']) && $mid == $xoopsModule->getVar('mid', 'n')
83
+		&& $uid == $GLOBALS['xoopsUser']->getVar('uid', 'n')) {
84
+		return $GLOBALS['xoopsUserIsAdmin'];
85
+	}
86
+
87
+	/** @var \XoopsMemberHandler $memberHandler */
88
+	$memberHandler = xoops_getHandler('member');
89
+	$groups        = $memberHandler->getGroupsByUser($uid);
90
+
91
+	/** @var \XoopsGroupPermHandler $grouppermHandler */
92
+	$grouppermHandler = xoops_getHandler('groupperm');
93
+
94
+	return $grouppermHandler->checkRight('module_admin', $mid, $groups);
95 95
 }
96 96
 
97 97
 /**
@@ -103,24 +103,24 @@  discard block
 block discarded – undo
103 103
  */
104 104
 function newbbIsModerator(&$forum, $user = -1)
105 105
 {
106
-    if (!is_object($forum)) {
107
-        $forum_id = (int)$forum;
108
-        if (0 == $forum_id) {
109
-            return false;
110
-        }
111
-        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
112
-        $forum        = $forumHandler->get($forum_id);
113
-    }
114
-
115
-    if (is_numeric($user) && -1 == $user) {
116
-        $user = $GLOBALS['xoopsUser'];
117
-    }
118
-    if (!is_object($user) && (int)$user < 1) {
119
-        return false;
120
-    }
121
-    $uid = is_object($user) ? $user->getVar('uid', 'n') : (int)$user;
122
-
123
-    return in_array($uid, $forum->getVar('forum_moderator'), true);
106
+	if (!is_object($forum)) {
107
+		$forum_id = (int)$forum;
108
+		if (0 == $forum_id) {
109
+			return false;
110
+		}
111
+		$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
112
+		$forum        = $forumHandler->get($forum_id);
113
+	}
114
+
115
+	if (is_numeric($user) && -1 == $user) {
116
+		$user = $GLOBALS['xoopsUser'];
117
+	}
118
+	if (!is_object($user) && (int)$user < 1) {
119
+		return false;
120
+	}
121
+	$uid = is_object($user) ? $user->getVar('uid', 'n') : (int)$user;
122
+
123
+	return in_array($uid, $forum->getVar('forum_moderator'), true);
124 124
 }
125 125
 
126 126
 /**
@@ -131,31 +131,31 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function newbbIsAdmin($forum = 0)
133 133
 {
134
-    global $xoopsModule;
135
-    static $_cachedModerators;
136
-
137
-    if (empty($forum)) {
138
-        return $GLOBALS['xoopsUserIsAdmin'];
139
-    }
140
-
141
-    if (!is_object($GLOBALS['xoopsUser'])) {
142
-        return false;
143
-    }
144
-
145
-    if ($GLOBALS['xoopsUserIsAdmin'] && 'newbb' === $xoopsModule->getVar('dirname')) {
146
-        return true;
147
-    }
148
-
149
-    $cache_id = is_object($forum) ? $forum->getVar('forum_id', 'n') : (int)$forum;
150
-    if (!isset($_cachedModerators[$cache_id])) {
151
-        if (!is_object($forum)) {
152
-            $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
153
-            $forum        = $forumHandler->get((int)$forum);
154
-        }
155
-        $_cachedModerators[$cache_id] = $forum->getVar('forum_moderator');
156
-    }
157
-
158
-    return in_array($GLOBALS['xoopsUser']->getVar('uid'), $_cachedModerators[$cache_id]);
134
+	global $xoopsModule;
135
+	static $_cachedModerators;
136
+
137
+	if (empty($forum)) {
138
+		return $GLOBALS['xoopsUserIsAdmin'];
139
+	}
140
+
141
+	if (!is_object($GLOBALS['xoopsUser'])) {
142
+		return false;
143
+	}
144
+
145
+	if ($GLOBALS['xoopsUserIsAdmin'] && 'newbb' === $xoopsModule->getVar('dirname')) {
146
+		return true;
147
+	}
148
+
149
+	$cache_id = is_object($forum) ? $forum->getVar('forum_id', 'n') : (int)$forum;
150
+	if (!isset($_cachedModerators[$cache_id])) {
151
+		if (!is_object($forum)) {
152
+			$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
153
+			$forum        = $forumHandler->get((int)$forum);
154
+		}
155
+		$_cachedModerators[$cache_id] = $forum->getVar('forum_moderator');
156
+	}
157
+
158
+	return in_array($GLOBALS['xoopsUser']->getVar('uid'), $_cachedModerators[$cache_id]);
159 159
 }
160 160
 
161 161
 /* use hardcoded DB query to save queries */
@@ -165,47 +165,47 @@  discard block
 block discarded – undo
165 165
  */
166 166
 function newbbIsModuleAdministrators(array $uid = [])
167 167
 {
168
-    global $xoopsModule;
169
-    $module_administrators = [];
170
-
171
-    //    $xoopsMembershipHandler = xoops_getHandler('membership');
172
-    //    $xoopsMembershipTable   = $xoopsMembershipHandler->table;
173
-
174
-    /** @var \XoopsMembershipHandler $xoopsMembershipHandler */
175
-    $xoopsMembershipHandler = xoops_getHandler('membership');
176
-    $xoopsMembershipTable   = $xoopsMembershipHandler->table;
177
-    /** @var \XoopsGroupPermHandler $xoopsGroupPermHandler */
178
-    $xoopsGroupPermHandler = xoops_getHandler('groupperm');
179
-    $xoopsGroupPermTable   = $xoopsGroupPermHandler->table;
180
-
181
-    if (!(bool)$uid) {
182
-        return $module_administrators;
183
-    }
184
-    $mid = $xoopsModule->getVar('mid');
185
-
186
-    $sql = 'SELECT COUNT(l.groupid) AS count, l.uid FROM '
187
-           . $xoopsMembershipTable
188
-           . ' AS l'
189
-           . ' LEFT JOIN '
190
-           . $xoopsGroupPermTable
191
-           . ' AS p ON p.gperm_groupid=l.groupid'
192
-           . ' WHERE l.uid IN ('
193
-           . implode(', ', array_map('intval', $uid))
194
-           . ')'
195
-           . "    AND p.gperm_modid = '1' AND p.gperm_name = 'module_admin' AND p.gperm_itemid = '"
196
-           . (int)$mid
197
-           . "'"
198
-           . ' GROUP BY l.uid';
199
-
200
-    if ($result = $GLOBALS['xoopsDB']->query($sql)) {
201
-        while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
202
-            if (!empty($myrow['count'])) {
203
-                $module_administrators[] = $myrow['uid'];
204
-            }
205
-        }
206
-    }
207
-
208
-    return $module_administrators;
168
+	global $xoopsModule;
169
+	$module_administrators = [];
170
+
171
+	//    $xoopsMembershipHandler = xoops_getHandler('membership');
172
+	//    $xoopsMembershipTable   = $xoopsMembershipHandler->table;
173
+
174
+	/** @var \XoopsMembershipHandler $xoopsMembershipHandler */
175
+	$xoopsMembershipHandler = xoops_getHandler('membership');
176
+	$xoopsMembershipTable   = $xoopsMembershipHandler->table;
177
+	/** @var \XoopsGroupPermHandler $xoopsGroupPermHandler */
178
+	$xoopsGroupPermHandler = xoops_getHandler('groupperm');
179
+	$xoopsGroupPermTable   = $xoopsGroupPermHandler->table;
180
+
181
+	if (!(bool)$uid) {
182
+		return $module_administrators;
183
+	}
184
+	$mid = $xoopsModule->getVar('mid');
185
+
186
+	$sql = 'SELECT COUNT(l.groupid) AS count, l.uid FROM '
187
+		   . $xoopsMembershipTable
188
+		   . ' AS l'
189
+		   . ' LEFT JOIN '
190
+		   . $xoopsGroupPermTable
191
+		   . ' AS p ON p.gperm_groupid=l.groupid'
192
+		   . ' WHERE l.uid IN ('
193
+		   . implode(', ', array_map('intval', $uid))
194
+		   . ')'
195
+		   . "    AND p.gperm_modid = '1' AND p.gperm_name = 'module_admin' AND p.gperm_itemid = '"
196
+		   . (int)$mid
197
+		   . "'"
198
+		   . ' GROUP BY l.uid';
199
+
200
+	if ($result = $GLOBALS['xoopsDB']->query($sql)) {
201
+		while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
202
+			if (!empty($myrow['count'])) {
203
+				$module_administrators[] = $myrow['uid'];
204
+			}
205
+		}
206
+	}
207
+
208
+	return $module_administrators;
209 209
 }
210 210
 
211 211
 /* use hardcoded DB query to save queries */
@@ -216,22 +216,22 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function newbbIsForumModerators(array $uid = [], $mid = 0)
218 218
 {
219
-    $forum_moderators = [];
220
-
221
-    if (!(bool)$uid) {
222
-        return $forum_moderators;
223
-    }
224
-
225
-    $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums');
226
-    if ($result = $GLOBALS['xoopsDB']->query($sql)) {
227
-        while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
228
-            if (empty($myrow['forum_moderator'])) {
229
-                continue;
230
-            }
231
-            $forum_moderators = array_merge($forum_moderators, unserialize($myrow['forum_moderator']));
232
-        }
233
-    }
234
-
235
-    return array_unique($forum_moderators);
219
+	$forum_moderators = [];
220
+
221
+	if (!(bool)$uid) {
222
+		return $forum_moderators;
223
+	}
224
+
225
+	$sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums');
226
+	if ($result = $GLOBALS['xoopsDB']->query($sql)) {
227
+		while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
228
+			if (empty($myrow['forum_moderator'])) {
229
+				continue;
230
+			}
231
+			$forum_moderators = array_merge($forum_moderators, unserialize($myrow['forum_moderator']));
232
+		}
233
+	}
234
+
235
+	return array_unique($forum_moderators);
236 236
 }
237 237
 //ENDIF;
Please login to merge, or discard this patch.
include/images.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 $forumImage['facebook'] = $forumImage['twitter'] = $forumImage['linkedin'] = $forumImage['googleplus'] = $forumImage['stumbleupon'] = $forumImage['friendfeed'] = $forumImage['digg'] = $forumImage['reddit'] = $forumImage['delicious'] = $forumImage['technorati'] = $forumImage['wong'] = $forumImage['anonym'] = $forumImage['more'] = $forumImage['less'] = 'icon';
49 49
 
50 50
 for ($i = 1; $i <= 5; ++$i) {
51
-    $forumImage['rate' . $i] = 'icon';
51
+    $forumImage['rate'.$i] = 'icon';
52 52
 }
53 53
 
54 54
 $forumImage['p_delete'] = $forumImage['p_reply'] = $forumImage['p_quote'] = $forumImage['p_edit'] = $forumImage['p_report'] =
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 $forumImage['facebook'] = $forumImage['twitter'] = $forumImage['linkedin'] = $forumImage['googleplus'] = $forumImage['stumbleupon'] = $forumImage['friendfeed'] = $forumImage['digg'] = $forumImage['reddit'] = $forumImage['delicious'] = $forumImage['technorati'] = $forumImage['wong'] = $forumImage['anonym'] = $forumImage['more'] = $forumImage['less'] = 'icon';
49 49
 
50 50
 for ($i = 1; $i <= 5; ++$i) {
51
-    $forumImage['rate' . $i] = 'icon';
51
+	$forumImage['rate' . $i] = 'icon';
52 52
 }
53 53
 
54 54
 $forumImage['p_delete'] = $forumImage['p_reply'] = $forumImage['p_quote'] = $forumImage['p_edit'] = $forumImage['p_report'] =
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 $forumImage['p_bann'] =
63 63
 
64
-    'language';
64
+	'language';
65 65
 
66 66
 /*
67 67
 $forumImage[''] = $forumImage['blank'] = $forumImage['icon']."blank";
Please login to merge, or discard this patch.
admin/admin_footer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
 global $pathIcon32;
21 21
 if (!class_exists('\Xoops', false)) {
22
-    echo "<div class='adminfooter'>\n" . "  <div style='text-align: center;'>\n" . "    <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . "  </div>\n" . '  ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . "</div>\n";
22
+    echo "<div class='adminfooter'>\n"."  <div style='text-align: center;'>\n"."    <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n"."  </div>\n".'  '._AM_MODULEADMIN_ADMIN_FOOTER."\n"."</div>\n";
23 23
 }
24 24
 
25 25
 xoops_cp_footer();
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 global $pathIcon32;
21 21
 
22 22
 if (!class_exists('\Xoops', false)) {
23
-    echo "<div class='adminfooter'>\n" . "  <div style='text-align: center;'>\n" . "    <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . "  </div>\n" . '  ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . "</div>\n";
23
+	echo "<div class='adminfooter'>\n" . "  <div style='text-align: center;'>\n" . "    <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . "  </div>\n" . '  ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . "</div>\n";
24 24
 }
25 25
 
26 26
 xoops_cp_footer();
Please login to merge, or discard this patch.
include/form.forum.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
29 29
 
30 30
 // The forum instanciation
31
-$form_forum = new \XoopsThemeForm(_AM_NEWBB_EDITTHISFORUM . ' ' . $forumObject->getVar('forum_name'), 'form_forum', xoops_getenv('PHP_SELF'));
31
+$form_forum = new \XoopsThemeForm(_AM_NEWBB_EDITTHISFORUM.' '.$forumObject->getVar('forum_name'), 'form_forum', xoops_getenv('PHP_SELF'));
32 32
 
33 33
 // Forum name
34 34
 $form_forum->addElement(new \XoopsFormText(_AM_NEWBB_FORUMNAME, 'forum_name', 50, 80, $forumObject->getVar('forum_name', 'E')), true);
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 $perm_checkbox = new \XoopsFormCheckBox('', 'perm_template', $forumObject->isNew());
66 66
 $perm_checkbox->addOption(1, _AM_NEWBB_PERM_TEMPLATEAPP);
67 67
 $perm_tray->addElement($perm_checkbox);
68
-$perm_tray->addElement(new \XoopsFormLabel('', '<a href="admin_permissions.php?action=template" rel="external" title="">' . _AM_NEWBB_PERM_TEMPLATE . '</a>'));
68
+$perm_tray->addElement(new \XoopsFormLabel('', '<a href="admin_permissions.php?action=template" rel="external" title="">'._AM_NEWBB_PERM_TEMPLATE.'</a>'));
69 69
 $form_forum->addElement($perm_tray);
70 70
 
71 71
 $form_forum->addElement(new \XoopsFormHidden('forum', $forumObject->getVar('forum_id')));
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@
 block discarded – undo
19 19
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
20 20
 
21 21
 if (!is_object($forumObject)) {
22
-    xoops_error('forum object IS null');
22
+	xoops_error('forum object IS null');
23 23
 
24
-    return;
24
+	return;
25 25
 }
26 26
 
27 27
 require_once $GLOBALS['xoops']->path('class/xoopstree.php');
Please login to merge, or discard this patch.