├── forums-framework.php
├── images
├── mask.png
├── marker.png
└── wheel.png
├── .gitmodules
├── css
└── wp_admin.css
├── js
├── forums-admin.js
└── farbtastic.js
├── sql.txt
├── README.md
├── changelog.txt
├── languages
└── wpmudev_forums.pot
└── forums.php
/forums-framework.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/images/mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/forums/master/images/mask.png
--------------------------------------------------------------------------------
/images/marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/forums/master/images/marker.png
--------------------------------------------------------------------------------
/images/wheel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/forums/master/images/wheel.png
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "dash-notice"]
2 | path = dash-notice
3 | url = git@bitbucket.org:incsub/wpmudev-dashboard-notification.git
4 | branch = master
5 |
--------------------------------------------------------------------------------
/css/wp_admin.css:
--------------------------------------------------------------------------------
1 | input.forum_color {
2 | width: 10%
3 | }
4 |
5 | /** Color picker **/
6 | .farbtastic {
7 | position: relative;
8 | }
9 | .farbtastic * {
10 | position: absolute;
11 | cursor: crosshair;
12 | }
13 | .farbtastic, .farbtastic .wheel {
14 | width: 195px;
15 | height: 195px;
16 | }
17 | .farbtastic .color, .farbtastic .overlay {
18 | top: 47px;
19 | left: 47px;
20 | width: 101px;
21 | height: 101px;
22 | }
23 | .farbtastic .wheel {
24 | background: url(../images/wheel.png) no-repeat;
25 | width: 195px;
26 | height: 195px;
27 | }
28 | .farbtastic .overlay {
29 | background: url(../images/mask.png) no-repeat;
30 | }
31 | .farbtastic .marker {
32 | width: 17px;
33 | height: 17px;
34 | margin: -8px 0 0 -8px;
35 | overflow: hidden;
36 | background: url(../images/marker.png) no-repeat;
37 | }
38 |
39 | div.forum_color {
40 | position: absolute;
41 | background-color: #fff;
42 | border: 1px solid #DFDFDF;
43 | -moz-border-radius:4px 4px 4px 4px;
44 | }
--------------------------------------------------------------------------------
/js/forums-admin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Forums plugin admin javascript
3 | *
4 | * @author S H Mohanjith
5 | * @since 1.6.6
6 | */
7 |
8 | (function ($) {
9 | $(document).ready(function () {
10 | if ($('#forum_color_one').length > 0) {
11 | $('#forum_color_one_panel').farbtastic('#forum_color_one').hide();
12 | $('#forum_color_two_panel').farbtastic('#forum_color_two').hide();
13 | $('#forum_color_header_panel').farbtastic('#forum_color_header').hide();
14 | $('#forum_color_border_panel').farbtastic('#forum_color_border').hide();
15 |
16 | $("input.forum_color").focus(function() {
17 | if ($(this).val() == '') {
18 | $(this).val('#ffffff');
19 | }
20 | $("#"+$(this).attr('id')+"_panel").slideDown();
21 | });
22 |
23 | $("input.forum_color").blur(function() {
24 | $("#"+$(this).attr('id')+"_panel").slideUp();
25 | });
26 | }
27 | });
28 | })(jQuery);
29 |
--------------------------------------------------------------------------------
/sql.txt:
--------------------------------------------------------------------------------
1 | CREATE TABLE `wp_forums` (
2 | `forum_ID` bigint(20) unsigned NOT NULL auto_increment,
3 | `forum_blog_ID` bigint(20) NOT NULL,
4 | `forum_name` TEXT NOT NULL,
5 | `forum_nicename` TEXT,
6 | `forum_description` TEXT,
7 | `forum_topics` bigint(20) NOT NULL default '0',
8 | `forum_posts` bigint(20) NOT NULL default '0',
9 | `forum_color_one` VARCHAR(255),
10 | `forum_color_two` VARCHAR(255),
11 | `forum_color_header` VARCHAR(255),
12 | `forum_color_border` VARCHAR(255),
13 | `forum_border_size` VARCHAR(255),
14 | PRIMARY KEY (`forum_ID`)
15 | ) ENGINE=MyISAM;
16 |
17 | CREATE TABLE `wp_forums_topics` (
18 | `topic_ID` bigint(20) unsigned NOT NULL auto_increment,
19 | `topic_forum_ID` bigint(20) NOT NULL,
20 | `topic_title` TEXT NOT NULL,
21 | `topic_author` bigint(20) NOT NULL,
22 | `topic_last_author` bigint(20) NOT NULL,
23 | `topic_stamp` bigint(30) NOT NULL,
24 | `topic_last_updated_stamp` bigint(30) NOT NULL,
25 | `topic_closed` tinyint(1) NOT NULL default '0',
26 | `topic_sticky` tinyint(1) NOT NULL default '0',
27 | `topic_posts` bigint(20) NOT NULL default '0',
28 | PRIMARY KEY (`topic_ID`)
29 | ) ENGINE=MyISAM;
30 |
31 | CREATE TABLE `wp_forums_posts` (
32 | `post_ID` bigint(20) unsigned NOT NULL auto_increment,
33 | `post_forum_ID` bigint(20) NOT NULL,
34 | `post_topic_ID` bigint(20) NOT NULL,
35 | `post_author` bigint(20) NOT NULL,
36 | `post_content` TEXT,
37 | `post_stamp` bigint(30) NOT NULL,
38 | PRIMARY KEY (`post_ID`)
39 | ) ENGINE=MyISAM;
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Forums
2 |
3 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.**
4 |
5 | Give each site on your Multisite network a simple tool for creating its very own forums that can be embedded directly into any page or post. Encourage community participation and build your user base with topic-specific discussion boards.
6 |
7 | Give each site on your network its very own forum - embedded in any page or post.
8 | * Unlimited forums
9 | * Site-specific forums for Multisite
10 | * Simple embed by code
11 | * Built-in Pro Sites limiter
12 | * Simple styling options
13 | * Limit topics per page
14 |
15 | ## Forums lets you add message boards to posts or pages across an entire Multisite network.
16 |
17 | ![Open new lines of communication on your site with Forums.][36]Open new lines of communication on your site with Forums.
18 |
19 | ### Amazingly Simple
20 |
21 | Add a message board to your site in just a few clicks and encourage community participation.
22 |
23 | Include a title, brief description, set basic styling options and embed the automatically generated code into any page or post.
24 |
25 | ![Give each site owner simple styling options for matching their theme.][37]Give each site owner simple styling options for matching their theme.
26 |
27 | ### Powerful Multisite Features
28 |
29 | Give each site on your network the ability to create its own forums. Control topics per page, posts per page and maximum message boards per site.
30 |
31 | It’s like having a bbPress install for every site with powerful network admin controls.
32 |
33 | ### Expand Pro Sites
34 |
35 | Forums also includes Pro Sites integration. Restrict the number of forums a site can add depending on subscription level and add value to premium memberships.
36 |
37 | Add community message boards to Multisite with ease using the powerful Forums plugin.
38 |
39 | ### To install:
40 |
41 | 1\. Download the plugin file
42 | 2\. Unzip the file into a folder on your hard drive
43 | 3\. Upload **/forums/** folder to **/wp-content/plugins/** folder on your site
44 | 4\. Visit **Network Admin -> Plugins** and **Network Activate** it there.
45 |
46 | _Note: If you have an older version of the plugin installed in /mu-plugins/ please delete it.
47 | _
48 |
49 | **That’s it!**
50 |
51 | ### To configure
52 |
53 | 1\. Go to **Settings > Forum** in the network admin dashboard.
54 |
55 | 2\. Set the topics per page, posts per page and maximum number of forums per site and then click **Save**.
56 |
57 | ![][39]
58 |
59 | ### To Use
60 |
61 | 1\. Inside your blog dashboard go to **Forum Tab**
62 | 2\. Click on **New** to create a new forum.
63 | 3\. Add the name of your forum, description and if you desire select the main and secondary colors used, header and border color and border width then click **Save**.
64 | 4\. Copy the forum short code.
65 |
66 | ![][40]
67 |
68 | Create a new Page (or Post) and paste the forum short code.
69 |
70 | ![][41]
71 |
72 | View your Page (or Post) with the embedded forum and click on the link to create a new forum topic.
73 | Just add a title and contents to the post then click **Send Post**.
74 |
75 | ![][42]
76 |
77 | At the forums overview page, you can see the title, description and also do a search of the specific forum easy peasy.
78 |
79 | ![][43]
80 |
81 | ### Forums Features
82 |
83 | #### Big control and easier communication.
84 |
85 | * Unlimited forums
86 | * Site specific forums for Multisite
87 | * Simple embed by code
88 | * Built-in Pro Sites limiter
89 | * Forum manager
90 | * Limit topics per page
91 | * Limit posts per page
92 | * Set maximum number of forums
93 | * Forum color styling
94 | * Forum search
95 | * Set border size
96 |
97 | [36]: https://premium.wpmudev.org/wp-content/uploads/2008/08/forums-front-end-735x470.jpg
98 | [37]: https://premium.wpmudev.org/wp-content/uploads/2008/08/forum-style-735x470.jpg
99 | [39]: https://premium.wpmudev.org/wp-content/uploads/2012/03/forum65.jpg
100 | [40]: https://premium.wpmudev.org/wp-content/uploads/2012/03/forum64.jpg
101 | [41]: https://premium.wpmudev.org/wp-content/uploads/2009/11/forums12.jpg
102 | [42]: https://premium.wpmudev.org/wp-content/uploads/2012/03/forum63.jpg
103 | [43]: https://premium.wpmudev.org/wp-content/uploads/2012/03/forum61.jpg
104 |
--------------------------------------------------------------------------------
/changelog.txt:
--------------------------------------------------------------------------------
1 | Plugin Name: Forums
2 | Author: WPMUDEV
3 | Lead developer: Maniu
4 | Contributors: S H Mohanjith, Andrew Billits, Ulrich Sossou
5 |
6 | Change Log:
7 | ----------------------------------------------------------------------
8 | ----------------------------------------------------------------------
9 |
10 | 2.0.2.4 - 12/16/2016 - Maniu
11 | ----------------------------------------------------------------------
12 | - Updated WPMU DEV Dashboard Notification
13 |
14 | 2.0.2.3 - 12/15/2015 - Maniu
15 | ----------------------------------------------------------------------
16 | - Bumped plugin version
17 |
18 | 2.0.2.2 - 12/15/2015 - Maniu
19 | ----------------------------------------------------------------------
20 | - Fixed: WP 4.4 support. Manually changing shortcode from [forum:{id}] to [forum id="{id}"] is required.
21 |
22 | 2.0.2.1 - 10/19/2015 - Maniu
23 | ----------------------------------------------------------------------
24 | - Fixed: Possible notice
25 |
26 | 2.0.2.0 - 11/11/2013 - S H Mohanjith
27 | ----------------------------------------------------------------------
28 | - Fixed: Single Site Compatibility
29 |
30 | 2.0.1.9 - 10/11/2013 - S H Mohanjith
31 | ----------------------------------------------------------------------
32 | - Fixed: Allow Users To Edit Forum Posts
33 |
34 | 2.0.1.8 - 09/30/2013 - S H Mohanjith
35 | ----------------------------------------------------------------------
36 | - Fixed: Disabling upgrades
37 | - Fixed: Forums search results show post but no link to it
38 |
39 | 2.0.1.7 - 05/13/2013 - S H Mohanjith
40 | ----------------------------------------------------------------------
41 | - Remove extra slashes
42 |
43 | 2.0.1.6 - 05/13/2013 - Ignacio Cruz
44 | ----------------------------------------------------------------------
45 | - Please add ID's to the HTML elements
46 | - More improvements
47 |
48 | 2.0.1.5 - 04/26/2013 - Aaron Edwards
49 | ----------------------------------------------------------------------
50 | - IMPORTANT security update - props to JJJ @ Automattic for disclosure
51 | - SQL Injection hardening
52 | - XSS prevention
53 |
54 | 2.0.1.4 - 02/17/2013
55 | ----------------------------------------------------------------------
56 | - Login and register links added into logged out message
57 |
58 | 2.0.1.3 - 02/01/2013
59 | ----------------------------------------------------------------------
60 | - Fixed: Edit post
61 | - Charset and collation specified for DB tables
62 |
63 | 2.0.1.2 - 02/01/2013
64 | ----------------------------------------------------------------------
65 | - Fixed: Pagination issues in 3.5.1
66 |
67 | 2.0.1.1 - 12/25/2012
68 | ----------------------------------------------------------------------
69 | - Fixed: Border color
70 | - WordPress 3.5 compatibility
71 |
72 | 2.0.1 - 04/26/2012
73 | ----------------------------------------------------------------------
74 | - Pro Sites integration improvements
75 |
76 | 2.0.0 - 04/08/2012
77 | ----------------------------------------------------------------------
78 | - Fixed: Slashes in topic title
79 | - Improved DB queries
80 |
81 | 2.0.0b2 - 03/04/2012
82 | ----------------------------------------------------------------------
83 | - Bug fixes
84 |
85 | 2.0.0b1 - 02/29/2012
86 | ----------------------------------------------------------------------
87 | - ** New Feature ** Multiple forums in single post/page
88 |
89 | 1.7.3 - 01/02/2012
90 | ----------------------------------------------------------------------
91 | - Increase the maximum number of forums without editing plugin files
92 |
93 | 1.7.2 - 04/01/2012
94 | ----------------------------------------------------------------------
95 | - Allow Pro Sites restriction to be disabled
96 |
97 | 1.7.0 - 09/08/2011
98 | ----------------------------------------------------------------------
99 | - Fixed: localization fixes
100 |
101 | 1.6.9 - 07/16/2011
102 | ----------------------------------------------------------------------
103 | - Fixed: load_plugin wrong path
104 | - New pot file
105 |
106 | 1.6.8 - 04/29/2011
107 | ----------------------------------------------------------------------
108 | - Fixed: undefined function upgrades_register_feature
109 |
110 | 1.6.7 - 04/27/2011
111 | ----------------------------------------------------------------------
112 | - Fixed: Javascript error
113 |
114 | 1.6.6 - 02/05/2011
115 | ----------------------------------------------------------------------
116 | - Use WordPress date settings to format forum dates
117 | - Added "Back to index" link
118 | - Fixed: Formatting issues
119 | - Added color picker
120 |
121 | 1.6.5 - 01/08/2011
122 | ----------------------------------------------------------------------
123 | - 3.1+ compatibility update
124 |
125 | 1.6.3 - 10/18/2010
126 | ----------------------------------------------------------------------
127 | - Internationalization
128 |
129 | 1.6.2 - 01/19/2010
130 | ----------------------------------------------------------------------
131 | - Better WP compatibility
132 |
133 | 1.6.0 - 01/18/2010
134 | ----------------------------------------------------------------------
135 | - Better WP compatibility
136 |
137 | 1.5.1 - 03/25/2009
138 | ----------------------------------------------------------------------
139 | - Removed admin bar menu item
140 |
141 | 1.5.0 - 03/02/2009
142 | ----------------------------------------------------------------------
143 | - 2.7 compatibility update
144 |
145 | 1.0.2 - 09/11/2008
146 | ----------------------------------------------------------------------
147 | - Fixed minor issue in forums_upgrades_advertise()
148 |
149 | 1.0.1 - 08/25/2008
150 | ----------------------------------------------------------------------
151 | - Typo fix.
152 |
153 | 1.0.0 - 08/19/2008
154 | ----------------------------------------------------------------------
155 | - Initial Release.
156 |
--------------------------------------------------------------------------------
/languages/wpmudev_forums.pot:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2013 Forums
2 | # This file is distributed under the same license as the Forums package.
3 | msgid ""
4 | msgstr ""
5 | "Project-Id-Version: Forums 2.0.1.8\n"
6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/forums\n"
7 | "POT-Creation-Date: 2013-10-15 07:26:35+00:00\n"
8 | "MIME-Version: 1.0\n"
9 | "Content-Type: text/plain; charset=UTF-8\n"
10 | "Content-Transfer-Encoding: 8bit\n"
11 | "PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
12 | "Last-Translator: FULL NAME \n"
13 | "Language-Team: LANGUAGE \n"
14 |
15 | #: forums.php:60
16 | msgid ""
17 | "Visit the upgrades tab to get more forums. Currently you are limit to %s"
18 | msgstr ""
19 |
20 | #. #-#-#-#-# wpmudev_forums.pot (Forums 2.0.1.8) #-#-#-#-#
21 | #. Plugin Name of the plugin/theme
22 | #: forums.php:93 forums.php:293 forums.php:295 forums.php:302
23 | msgid "Forums"
24 | msgstr ""
25 |
26 | #: forums.php:93
27 | msgid "Additional Forums"
28 | msgstr ""
29 |
30 | #: forums.php:302 forums.php:1839
31 | msgid "Forum Settings"
32 | msgstr ""
33 |
34 | #: forums.php:308
35 | msgid "Pro Only..."
36 | msgstr ""
37 |
38 | #: forums.php:380
39 | msgid "Invalid user account..."
40 | msgstr ""
41 |
42 | #: forums.php:385
43 | msgid "Invalid forum..."
44 | msgstr ""
45 |
46 | #: forums.php:397
47 | msgid "Topic Added!"
48 | msgstr ""
49 |
50 | #: forums.php:433 forums.php:537 forums.php:618
51 | msgid "Topic Closed!"
52 | msgstr ""
53 |
54 | #: forums.php:435 forums.php:459 forums.php:505 forums.php:508 forums.php:539
55 | #: forums.php:563 forums.php:620 forums.php:644 forums.php:689 forums.php:709
56 | #: forums.php:712 forums.php:753 forums.php:757 forums.php:785
57 | msgid "Permission denied..."
58 | msgstr ""
59 |
60 | #: forums.php:457 forums.php:561 forums.php:642
61 | msgid "Topic Opened!"
62 | msgstr ""
63 |
64 | #: forums.php:470 forums.php:575 forums.php:655 forums.php:1692
65 | msgid "Closed"
66 | msgstr ""
67 |
68 | #: forums.php:665
69 | msgid "Error deleting topic..."
70 | msgstr ""
71 |
72 | #: forums.php:679
73 | msgid "Topic Deleted!"
74 | msgstr ""
75 |
76 | #: forums.php:693
77 | msgid "Invalid Topic!"
78 | msgstr ""
79 |
80 | #: forums.php:723
81 | msgid "Error deleting post"
82 | msgstr ""
83 |
84 | #: forums.php:727
85 | msgid "Post deleted"
86 | msgstr ""
87 |
88 | #: forums.php:773 forums.php:781
89 | msgid "Post updated..."
90 | msgstr ""
91 |
92 | #: forums.php:792 forums.php:1039 forums.php:1084
93 | msgid ""
94 | "You must be a registered and logged in user of this blog to post on this "
95 | "forum. Please Log In or %s."
96 | msgstr ""
97 |
98 | #: forums.php:803
99 | msgid "Post added..."
100 | msgstr ""
101 |
102 | #: forums.php:828
103 | msgid "Invalid Forum Code"
104 | msgstr ""
105 |
106 | #: forums.php:840
107 | msgid "Back to index"
108 | msgstr ""
109 |
110 | #: forums.php:842 forums.php:1298 forums.php:1301
111 | msgid "Delete Topic"
112 | msgstr ""
113 |
114 | #: forums.php:844
115 | msgid "Open Topic"
116 | msgstr ""
117 |
118 | #: forums.php:846
119 | msgid "Close Topic"
120 | msgstr ""
121 |
122 | #: forums.php:857
123 | msgid "Last updated: "
124 | msgstr ""
125 |
126 | #: forums.php:857 forums.php:1459
127 | msgid "D, F jS Y g:i A"
128 | msgstr ""
129 |
130 | #: forums.php:858
131 | msgid "Latest Reply From: "
132 | msgstr ""
133 |
134 | #: forums.php:898
135 | msgid "Search Results"
136 | msgstr ""
137 |
138 | #: forums.php:901
139 | msgid "Posts:"
140 | msgstr ""
141 |
142 | #: forums.php:940
143 | msgid "No matches..."
144 | msgstr ""
145 |
146 | #: forums.php:972
147 | msgid "Search"
148 | msgstr ""
149 |
150 | #: forums.php:1043 forums.php:1090
151 | msgid "New Post"
152 | msgstr ""
153 |
154 | #: forums.php:1046 forums.php:1093 forums.php:1167 forums.php:1577
155 | msgid "You must fill in all required fields..."
156 | msgstr ""
157 |
158 | #: forums.php:1058 forums.php:1105 forums.php:1185 forums.php:1594
159 | msgid "Post:"
160 | msgstr ""
161 |
162 | #: forums.php:1061 forums.php:1108 forums.php:1192 forums.php:1591
163 | #: forums.php:1597 forums.php:1970 forums.php:2039 forums.php:2144
164 | #: forums.php:2214
165 | msgid "Required"
166 | msgstr ""
167 |
168 | #: forums.php:1066
169 | msgid "Send Post »"
170 | msgstr ""
171 |
172 | #: forums.php:1113 forums.php:1602
173 | msgid "Send Post"
174 | msgstr ""
175 |
176 | #: forums.php:1164
177 | msgid "Edit Post"
178 | msgstr ""
179 |
180 | #: forums.php:1197
181 | msgid "Update »"
182 | msgstr ""
183 |
184 | #: forums.php:1198 forums.php:1255 forums.php:1310
185 | msgid "Cancel »"
186 | msgstr ""
187 |
188 | #: forums.php:1242 forums.php:1245
189 | msgid "Delete Post"
190 | msgstr ""
191 |
192 | #: forums.php:1243 forums.php:1299 forums.php:1572
193 | msgid "You must be logged in..."
194 | msgstr ""
195 |
196 | #: forums.php:1247
197 | msgid "Are you sure you want to delete this post?"
198 | msgstr ""
199 |
200 | #: forums.php:1254 forums.php:1309
201 | msgid "Delete »"
202 | msgstr ""
203 |
204 | #: forums.php:1303
205 | msgid "Are you sure you want to delete this topic?"
206 | msgstr ""
207 |
208 | #: forums.php:1346
209 | msgid " « Previous"
210 | msgstr ""
211 |
212 | #: forums.php:1348 forums.php:1391
213 | msgid "Showing %1s > %2s of %3s posts"
214 | msgstr ""
215 |
216 | #: forums.php:1354
217 | msgid "Next »"
218 | msgstr ""
219 |
220 | #: forums.php:1389
221 | msgid "Previous"
222 | msgstr ""
223 |
224 | #: forums.php:1397
225 | msgid "Next"
226 | msgstr ""
227 |
228 | #: forums.php:1459
229 | msgid "Posted: "
230 | msgstr ""
231 |
232 | #: forums.php:1467 forums.php:1469 forums.php:1473 forums.php:1946
233 | msgid "Edit"
234 | msgstr ""
235 |
236 | #: forums.php:1467
237 | msgid "Delete"
238 | msgstr ""
239 |
240 | #: forums.php:1487
241 | msgid "No posts to display..."
242 | msgstr ""
243 |
244 | #: forums.php:1571 forums.php:1574
245 | msgid "New Topic"
246 | msgstr ""
247 |
248 | #: forums.php:1588
249 | msgid "Title:"
250 | msgstr ""
251 |
252 | #: forums.php:1628 forums.php:1635
253 | msgid "TOPICS"
254 | msgstr ""
255 |
256 | #: forums.php:1629 forums.php:1636
257 | msgid "POSTS"
258 | msgstr ""
259 |
260 | #: forums.php:1630 forums.php:1637
261 | msgid "LATEST POSTER"
262 | msgstr ""
263 |
264 | #: forums.php:1635
265 | msgid "NEW"
266 | msgstr ""
267 |
268 | #: forums.php:1706 forums.php:1712
269 | msgid "No topics to display..."
270 | msgstr ""
271 |
272 | #: forums.php:1712
273 | msgid "Click here to create a new topic."
274 | msgstr ""
275 |
276 | #: forums.php:1806 forums.php:1884
277 | msgid "Nice Try..."
278 | msgstr ""
279 |
280 | #: forums.php:1843
281 | msgid "Topics per page"
282 | msgstr ""
283 |
284 | #: forums.php:1847
285 | msgid "Posts per page"
286 | msgstr ""
287 |
288 | #: forums.php:1851
289 | msgid "Maximum number of forums"
290 | msgstr ""
291 |
292 | #: forums.php:1856
293 | msgid "Maximum number of forums for upgraded blogs"
294 | msgstr ""
295 |
296 | #: forums.php:1861
297 | msgid "Allow upgrades"
298 | msgstr ""
299 |
300 | #: forums.php:1868 forums.php:2021 forums.php:2089
301 | msgid "Save"
302 | msgstr ""
303 |
304 | #: forums.php:1895 forums.php:1899
305 | msgid "Manage Forums"
306 | msgstr ""
307 |
308 | #: forums.php:1895
309 | msgid "New"
310 | msgstr ""
311 |
312 | #: forums.php:1911
313 | msgid ""
314 | "Upgrade your blog now in order to add forums, increase storage space, embed "
315 | "videos, and more."
316 | msgstr ""
317 |
318 | #: forums.php:1915
319 | msgid "Click here to add a new forum."
320 | msgstr ""
321 |
322 | #: forums.php:1947
323 | msgid "Remove"
324 | msgstr ""
325 |
326 | #: forums.php:1963 forums.php:2031
327 | msgid "New Forum"
328 | msgstr ""
329 |
330 | #: forums.php:1967 forums.php:2036 forums.php:2141 forums.php:2211
331 | msgid "Name"
332 | msgstr ""
333 |
334 | #: forums.php:1973 forums.php:2042 forums.php:2147 forums.php:2217
335 | msgid "Description"
336 | msgstr ""
337 |
338 | #: forums.php:1976 forums.php:2045 forums.php:2150 forums.php:2220
339 | msgid "Optional"
340 | msgstr ""
341 |
342 | #: forums.php:1979 forums.php:2048 forums.php:2153 forums.php:2223
343 | msgid "Color One"
344 | msgstr ""
345 |
346 | #: forums.php:1983 forums.php:1990 forums.php:1997 forums.php:2004
347 | #: forums.php:2052 forums.php:2059 forums.php:2066 forums.php:2073
348 | #: forums.php:2157 forums.php:2164 forums.php:2171 forums.php:2178
349 | #: forums.php:2227 forums.php:2234 forums.php:2241 forums.php:2248
350 | msgid "Optional - Ex: #000000 OR #FFFFFF"
351 | msgstr ""
352 |
353 | #: forums.php:1986 forums.php:2055 forums.php:2160 forums.php:2230
354 | msgid "Color Two"
355 | msgstr ""
356 |
357 | #: forums.php:1993 forums.php:2062 forums.php:2167 forums.php:2237
358 | msgid "Header Color"
359 | msgstr ""
360 |
361 | #: forums.php:2000 forums.php:2069 forums.php:2174 forums.php:2244
362 | msgid "Border Color"
363 | msgstr ""
364 |
365 | #: forums.php:2007 forums.php:2076 forums.php:2181 forums.php:2251
366 | msgid "Border Size"
367 | msgstr ""
368 |
369 | #: forums.php:2032 forums.php:2206
370 | msgid "Please fill in all required fields"
371 | msgstr ""
372 |
373 | #: forums.php:2120
374 | msgid "Forum Added."
375 | msgstr ""
376 |
377 | #: forums.php:2136 forums.php:2205
378 | msgid "Edit Forum"
379 | msgstr ""
380 |
381 | #: forums.php:2194 forums.php:2264
382 | msgid "Save Changes"
383 | msgstr ""
384 |
385 | #: forums.php:2300
386 | msgid "Settings saved."
387 | msgstr ""
388 |
389 | #: forums.php:2310
390 | msgid "Remove Forum"
391 | msgstr ""
392 |
393 | #: forums.php:2311
394 | msgid ""
395 | "Are you sure you want to remove this forum? All topics and posts will be "
396 | "deleted."
397 | msgstr ""
398 |
399 | #: forums.php:2315
400 | msgid "Continue"
401 | msgstr ""
402 |
403 | #: forums.php:2316
404 | msgid "Cancel"
405 | msgstr ""
406 |
407 | #: forums.php:2333
408 | msgid "Forum Removed."
409 | msgstr ""
410 |
411 | #: forums.php:2419
412 | msgid ""
413 | "Please install the latest version of our free "
415 | "Update Notifications plugin which helps you stay up-to-date with the "
416 | "most stable, secure versions of WPMU DEV themes and plugins. More information » "
419 | msgstr ""
420 |
421 | #. Plugin URI of the plugin/theme
422 | msgid "http://premium.wpmudev.org/project/forums/"
423 | msgstr ""
424 |
425 | #. Description of the plugin/theme
426 | msgid ""
427 | "Allows each blog to have their very own forums - embedded in any page or "
428 | "post."
429 | msgstr ""
430 |
431 | #. Author of the plugin/theme
432 | msgid "S H Mohanjith (Incsub), Ulrich Sossou (Incsub), Andrew Billits (Incsub)"
433 | msgstr ""
434 |
435 | #. Author URI of the plugin/theme
436 | msgid "http://premium.wpmudev.org"
437 | msgstr ""
438 |
--------------------------------------------------------------------------------
/js/farbtastic.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Farbtastic Color Picker 1.2
3 | * © 2008 Steven Wittens
4 | *
5 | * This program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | (function ($) {
21 | jQuery.fn.farbtastic = function (callback) {
22 | $.farbtastic(this, callback);
23 | return this;
24 | };
25 |
26 | jQuery.farbtastic = function (container, callback) {
27 | var container = $(container).get(0);
28 | return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback));
29 | }
30 |
31 | jQuery._farbtastic = function (container, callback) {
32 | // Store farbtastic object
33 | var fb = this;
34 |
35 | // Insert markup
36 | $(container).html('');
37 | var e = $('.farbtastic', container);
38 | fb.wheel = $('.wheel', container).get(0);
39 | // Dimensions
40 | fb.radius = 84;
41 | fb.square = 100;
42 | fb.width = 194;
43 |
44 | // Fix background PNGs in IE6
45 | if (navigator.appVersion.match(/MSIE [0-6]\./)) {
46 | $('*', e).each(function () {
47 | if (this.currentStyle.backgroundImage != 'none') {
48 | var image = this.currentStyle.backgroundImage;
49 | image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
50 | $(this).css({
51 | 'backgroundImage': 'none',
52 | 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
53 | });
54 | }
55 | });
56 | }
57 |
58 | /**
59 | * Link to the given element(s) or callback.
60 | */
61 | fb.linkTo = function (callback) {
62 | // Unbind previous nodes
63 | if (typeof fb.callback == 'object') {
64 | $(fb.callback).unbind('keyup', fb.updateValue);
65 | }
66 |
67 | // Reset color
68 | fb.color = null;
69 |
70 | // Bind callback or elements
71 | if (typeof callback == 'function') {
72 | fb.callback = callback;
73 | }
74 | else if (typeof callback == 'object' || typeof callback == 'string') {
75 | fb.callback = $(callback);
76 | fb.callback.bind('keyup', fb.updateValue);
77 | if (fb.callback.get(0).value) {
78 | fb.setColor(fb.callback.get(0).value);
79 | }
80 | }
81 | return this;
82 | }
83 | fb.updateValue = function (event) {
84 | if (this.value && this.value != fb.color) {
85 | fb.setColor(this.value);
86 | }
87 | }
88 |
89 | /**
90 | * Change color with HTML syntax #123456
91 | */
92 | fb.setColor = function (color) {
93 | var unpack = fb.unpack(color);
94 | if (fb.color != color && unpack) {
95 | fb.color = color;
96 | fb.rgb = unpack;
97 | fb.hsl = fb.RGBToHSL(fb.rgb);
98 | fb.updateDisplay();
99 | }
100 | return this;
101 | }
102 |
103 | /**
104 | * Change color with HSL triplet [0..1, 0..1, 0..1]
105 | */
106 | fb.setHSL = function (hsl) {
107 | fb.hsl = hsl;
108 | fb.rgb = fb.HSLToRGB(hsl);
109 | fb.color = fb.pack(fb.rgb);
110 | fb.updateDisplay();
111 | return this;
112 | }
113 |
114 | /////////////////////////////////////////////////////
115 |
116 | /**
117 | * Retrieve the coordinates of the given event relative to the center
118 | * of the widget.
119 | */
120 | fb.widgetCoords = function (event) {
121 | var x, y;
122 | var el = event.target || event.srcElement;
123 | var reference = fb.wheel;
124 |
125 | if (typeof event.offsetX != 'undefined') {
126 | // Use offset coordinates and find common offsetParent
127 | var pos = { x: event.offsetX, y: event.offsetY };
128 |
129 | // Send the coordinates upwards through the offsetParent chain.
130 | var e = el;
131 | while (e) {
132 | e.mouseX = pos.x;
133 | e.mouseY = pos.y;
134 | pos.x += e.offsetLeft;
135 | pos.y += e.offsetTop;
136 | e = e.offsetParent;
137 | }
138 |
139 | // Look for the coordinates starting from the wheel widget.
140 | var e = reference;
141 | var offset = { x: 0, y: 0 }
142 | while (e) {
143 | if (typeof e.mouseX != 'undefined') {
144 | x = e.mouseX - offset.x;
145 | y = e.mouseY - offset.y;
146 | break;
147 | }
148 | offset.x += e.offsetLeft;
149 | offset.y += e.offsetTop;
150 | e = e.offsetParent;
151 | }
152 |
153 | // Reset stored coordinates
154 | e = el;
155 | while (e) {
156 | e.mouseX = undefined;
157 | e.mouseY = undefined;
158 | e = e.offsetParent;
159 | }
160 | }
161 | else {
162 | // Use absolute coordinates
163 | var pos = fb.absolutePosition(reference);
164 | x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x;
165 | y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y;
166 | }
167 | // Subtract distance to middle
168 | return { x: x - fb.width / 2, y: y - fb.width / 2 };
169 | }
170 |
171 | /**
172 | * Mousedown handler
173 | */
174 | fb.mousedown = function (event) {
175 | // Capture mouse
176 | if (!document.dragging) {
177 | $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
178 | document.dragging = true;
179 | }
180 |
181 | // Check which area is being dragged
182 | var pos = fb.widgetCoords(event);
183 | fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
184 |
185 | // Process
186 | fb.mousemove(event);
187 | return false;
188 | }
189 |
190 | /**
191 | * Mousemove handler
192 | */
193 | fb.mousemove = function (event) {
194 | // Get coordinates relative to color picker center
195 | var pos = fb.widgetCoords(event);
196 |
197 | // Set new HSL parameters
198 | if (fb.circleDrag) {
199 | var hue = Math.atan2(pos.x, -pos.y) / 6.28;
200 | if (hue < 0) hue += 1;
201 | fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
202 | }
203 | else {
204 | var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
205 | var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
206 | fb.setHSL([fb.hsl[0], sat, lum]);
207 | }
208 | return false;
209 | }
210 |
211 | /**
212 | * Mouseup handler
213 | */
214 | fb.mouseup = function () {
215 | // Uncapture mouse
216 | $(document).unbind('mousemove', fb.mousemove);
217 | $(document).unbind('mouseup', fb.mouseup);
218 | document.dragging = false;
219 | }
220 |
221 | /**
222 | * Update the markers and styles
223 | */
224 | fb.updateDisplay = function () {
225 | // Markers
226 | var angle = fb.hsl[0] * 6.28;
227 | $('.h-marker', e).css({
228 | left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
229 | top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
230 | });
231 |
232 | $('.sl-marker', e).css({
233 | left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
234 | top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
235 | });
236 |
237 | // Saturation/Luminance gradient
238 | $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
239 |
240 | // Linked elements or callback
241 | if (typeof fb.callback == 'object') {
242 | // Set background/foreground color
243 | $(fb.callback).css({
244 | backgroundColor: fb.color,
245 | color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
246 | });
247 |
248 | // Change linked value
249 | $(fb.callback).each(function() {
250 | if (this.value && this.value != fb.color) {
251 | this.value = fb.color;
252 | }
253 | });
254 | }
255 | else if (typeof fb.callback == 'function') {
256 | fb.callback.call(fb, fb.color);
257 | }
258 | }
259 |
260 | /**
261 | * Get absolute position of element
262 | */
263 | fb.absolutePosition = function (el) {
264 | var r = { x: el.offsetLeft, y: el.offsetTop };
265 | // Resolve relative to offsetParent
266 | if (el.offsetParent) {
267 | var tmp = fb.absolutePosition(el.offsetParent);
268 | r.x += tmp.x;
269 | r.y += tmp.y;
270 | }
271 | return r;
272 | };
273 |
274 | /* Various color utility functions */
275 | fb.pack = function (rgb) {
276 | var r = Math.round(rgb[0] * 255);
277 | var g = Math.round(rgb[1] * 255);
278 | var b = Math.round(rgb[2] * 255);
279 | return '#' + (r < 16 ? '0' : '') + r.toString(16) +
280 | (g < 16 ? '0' : '') + g.toString(16) +
281 | (b < 16 ? '0' : '') + b.toString(16);
282 | }
283 |
284 | fb.unpack = function (color) {
285 | if (color.length == 7) {
286 | return [parseInt('0x' + color.substring(1, 3)) / 255,
287 | parseInt('0x' + color.substring(3, 5)) / 255,
288 | parseInt('0x' + color.substring(5, 7)) / 255];
289 | }
290 | else if (color.length == 4) {
291 | return [parseInt('0x' + color.substring(1, 2)) / 15,
292 | parseInt('0x' + color.substring(2, 3)) / 15,
293 | parseInt('0x' + color.substring(3, 4)) / 15];
294 | }
295 | }
296 |
297 | fb.HSLToRGB = function (hsl) {
298 | var m1, m2, r, g, b;
299 | var h = hsl[0], s = hsl[1], l = hsl[2];
300 | m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
301 | m1 = l * 2 - m2;
302 | return [this.hueToRGB(m1, m2, h+0.33333),
303 | this.hueToRGB(m1, m2, h),
304 | this.hueToRGB(m1, m2, h-0.33333)];
305 | }
306 |
307 | fb.hueToRGB = function (m1, m2, h) {
308 | h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
309 | if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
310 | if (h * 2 < 1) return m2;
311 | if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
312 | return m1;
313 | }
314 |
315 | fb.RGBToHSL = function (rgb) {
316 | var min, max, delta, h, s, l;
317 | var r = rgb[0], g = rgb[1], b = rgb[2];
318 | min = Math.min(r, Math.min(g, b));
319 | max = Math.max(r, Math.max(g, b));
320 | delta = max - min;
321 | l = (min + max) / 2;
322 | s = 0;
323 | if (l > 0 && l < 1) {
324 | s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
325 | }
326 | h = 0;
327 | if (delta > 0) {
328 | if (max == r && max != g) h += (g - b) / delta;
329 | if (max == g && max != b) h += (2 + (b - r) / delta);
330 | if (max == b && max != r) h += (4 + (r - g) / delta);
331 | h /= 6;
332 | }
333 | return [h, s, l];
334 | }
335 |
336 | // Install mousedown handler (the others are set on the document on-demand)
337 | $('*', e).mousedown(fb.mousedown);
338 |
339 | // Init color
340 | fb.setColor('#000000');
341 |
342 | // Set linked elements/callback
343 | if (callback) {
344 | fb.linkTo(callback);
345 | }
346 | }
347 | })(jQuery);
--------------------------------------------------------------------------------
/forums.php:
--------------------------------------------------------------------------------
1 |
62 |
63 | blogid == 2){
74 | add_action('init', 'forums_plug_init');
75 | add_action('admin_print_styles-toplevel_page_wpmudev_forums', 'forums_admin_styles');
76 | add_action('admin_print_scripts-toplevel_page_wpmudev_forums', 'forums_admin_scripts');
77 | add_action('admin_menu', 'forums_plug_pages');
78 | if (is_multisite()) {
79 | add_action('network_admin_menu', 'forums_options_plug_pages');
80 | } else {
81 | add_action('admin_menu', 'forums_options_plug_pages');
82 | }
83 | add_filter('wpabar_menuitems', 'forums_admin_bar');
84 | //}
85 | //------------------------------------------------------------------------//
86 | //---Functions------------------------------------------------------------//
87 | //------------------------------------------------------------------------//
88 | function forums_plug_init() {
89 | global $forums_current_version, $forums_enable_upgrades, $forums_max_forums, $forums_upgrades_forums;
90 |
91 | //--------------------------------Premium---------------------------------//
92 | if ($forums_enable_upgrades == 1) {
93 | if (function_exists('upgrades_register_feature')){
94 | //register premium features
95 | upgrades_register_feature( '68daf8bdc8755fe8f4859024b3054fb8', __( 'Forums', 'wpmudev_forums' ), __( 'Additional Forums', 'wpmudev_forums' ) );
96 |
97 | //load premium features
98 | if (upgrades_active_feature('68daf8bdc8755fe8f4859024b3054fb8') == 'active'){
99 | $forums_max_forums = $forums_upgrades_forums;
100 | }
101 | } else if (function_exists('is_pro_site') && is_pro_site()) {
102 | $forums_max_forums = $forums_upgrades_forums;
103 | }
104 | }
105 |
106 | if ( defined( 'WPMU_PLUGIN_DIR' ) && file_exists( WPMU_PLUGIN_DIR . '/' . basename( __FILE__ ) ) ) {
107 | load_muplugin_textdomain( 'wpmudev_forums', WPMU_PLUGIN_DIR .'forums/languages' );
108 | } else {
109 | load_plugin_textdomain( 'wpmudev_forums', false, 'forums/languages' );
110 | }
111 |
112 | if (is_admin()) {
113 | wp_register_script('farbtastic', plugins_url('forums/js/farbtastic.js'), array('jquery'));
114 | wp_register_script('forums_admin_js', plugins_url('forums/js/forums-admin.js'), array('jquery','farbtastic'), $forums_current_version, true);
115 | wp_register_style('forums_admin_css', plugins_url('forums/css/wp_admin.css'));
116 | }
117 | }
118 |
119 | function forums_admin_styles() {
120 | wp_enqueue_style('forums_admin_css');
121 | }
122 |
123 | function forums_admin_scripts() {
124 | wp_enqueue_script('farbtastic');
125 | wp_enqueue_script('forums_admin_js');
126 | }
127 |
128 | function forums_make_current() {
129 | global $wpdb, $forums_current_version;
130 | if ( !empty($wpdb->base_prefix) ) {
131 | $db_prefix = $wpdb->base_prefix;
132 | if (get_site_option( "forums_version" ) == '') {
133 | add_site_option( 'forums_version', '0.0.0' );
134 | }
135 |
136 | if (get_site_option( "forums_version" ) == $forums_current_version) {
137 | // do nothing
138 | } else {
139 | //up to current version
140 | update_site_option( "forums_installed", "no" );
141 | update_site_option( "forums_version", $forums_current_version );
142 | }
143 | forums_global_install();
144 | } else {
145 | $db_prefix = $wpdb->prefix;
146 | if (get_option( "forums_version" ) == '') {
147 | add_option( 'forums_version', '0.0.0' );
148 | }
149 |
150 | if (get_option( "forums_version" ) == $forums_current_version) {
151 | // do nothing
152 | } else {
153 | //up to current version
154 | update_option( "forums_version", $forums_current_version );
155 | forums_blog_install();
156 | }
157 | }
158 | }
159 |
160 | function forums_blog_install() {
161 | global $wpdb, $forums_current_version;
162 | if ( !empty($wpdb->base_prefix) ) {
163 | $db_prefix = $wpdb->base_prefix;
164 | } else {
165 | $db_prefix = $wpdb->prefix;
166 | }
167 | if (get_option( "forums_installed" ) == '') {
168 | add_option( 'forums_installed', 'no' );
169 | }
170 |
171 | if (get_option( "forums_installed" ) == "yes") {
172 | // do nothing
173 | } else {
174 | $charset_collate = "";
175 | if ( !empty( $wpdb->charset ) ) {
176 | $charset_collate .= "DEFAULT CHARACTER SET $wpdb->charset";
177 | }
178 | if ( !empty( $wpdb->collate ) ) {
179 | $charset_collate .= " COLLATE $wpdb->collate";
180 | }
181 |
182 | $forums_table1 = "CREATE TABLE `" . $db_prefix . "forums` (
183 | `forum_ID` bigint(20) unsigned NOT NULL auto_increment,
184 | `forum_blog_ID` bigint(20) NOT NULL,
185 | `forum_name` TEXT NOT NULL,
186 | `forum_nicename` TEXT,
187 | `forum_description` TEXT,
188 | `forum_topics` bigint(20) NOT NULL default '0',
189 | `forum_posts` bigint(20) NOT NULL default '0',
190 | `forum_color_one` VARCHAR(255),
191 | `forum_color_two` VARCHAR(255),
192 | `forum_color_header` VARCHAR(255),
193 | `forum_color_border` VARCHAR(255),
194 | `forum_border_size` VARCHAR(255),
195 | PRIMARY KEY (`forum_ID`)
196 | ) ENGINE=MyISAM {$charset_collate};";
197 | $forums_table2 = "CREATE TABLE `" . $db_prefix . "forums_topics` (
198 | `topic_ID` bigint(20) unsigned NOT NULL auto_increment,
199 | `topic_forum_ID` bigint(20) NOT NULL,
200 | `topic_title` TEXT NOT NULL,
201 | `topic_author` bigint(20) NOT NULL,
202 | `topic_last_author` bigint(20) NOT NULL,
203 | `topic_stamp` bigint(30) NOT NULL,
204 | `topic_last_updated_stamp` bigint(30) NOT NULL,
205 | `topic_closed` tinyint(1) NOT NULL default '0',
206 | `topic_sticky` tinyint(1) NOT NULL default '0',
207 | `topic_posts` bigint(20) NOT NULL default '0',
208 | PRIMARY KEY (`topic_ID`)
209 | ) ENGINE=MyISAM {$charset_collate};";
210 | $forums_table3 = "CREATE TABLE `" . $db_prefix . "forums_posts` (
211 | `post_ID` bigint(20) unsigned NOT NULL auto_increment,
212 | `post_forum_ID` bigint(20) NOT NULL,
213 | `post_topic_ID` bigint(20) NOT NULL,
214 | `post_author` bigint(20) NOT NULL,
215 | `post_content` TEXT,
216 | `post_stamp` bigint(30) NOT NULL,
217 | PRIMARY KEY (`post_ID`)
218 | ) ENGINE=MyISAM {$charset_collate};";
219 | $forums_table4 = "";
220 | $forums_table5 = "";
221 |
222 | $wpdb->query( $forums_table1 );
223 | $wpdb->query( $forums_table2 );
224 | $wpdb->query( $forums_table3 );
225 | update_option( "forums_installed", "yes" );
226 | }
227 | }
228 |
229 | function forums_global_install() {
230 | global $wpdb, $forums_current_version;
231 | if ( !empty($wpdb->base_prefix) ) {
232 | $db_prefix = $wpdb->base_prefix;
233 | } else {
234 | $db_prefix = $wpdb->prefix;
235 | }
236 | if (get_site_option( "forums_installed" ) == '') {
237 | add_site_option( 'forums_installed', 'no' );
238 | }
239 |
240 | if (get_site_option( "forums_installed" ) == "yes") {
241 | // do nothing
242 | } else {
243 |
244 | $forums_table1 = "CREATE TABLE `" . $db_prefix . "forums` (
245 | `forum_ID` bigint(20) unsigned NOT NULL auto_increment,
246 | `forum_blog_ID` bigint(20) NOT NULL,
247 | `forum_name` TEXT NOT NULL,
248 | `forum_nicename` TEXT,
249 | `forum_description` TEXT,
250 | `forum_topics` bigint(20) NOT NULL default '0',
251 | `forum_posts` bigint(20) NOT NULL default '0',
252 | `forum_color_one` VARCHAR(255),
253 | `forum_color_two` VARCHAR(255),
254 | `forum_color_header` VARCHAR(255),
255 | `forum_color_border` VARCHAR(255),
256 | `forum_border_size` VARCHAR(255),
257 | PRIMARY KEY (`forum_ID`)
258 | ) ENGINE=MyISAM;";
259 | $forums_table2 = "CREATE TABLE `" . $db_prefix . "forums_topics` (
260 | `topic_ID` bigint(20) unsigned NOT NULL auto_increment,
261 | `topic_forum_ID` bigint(20) NOT NULL,
262 | `topic_title` TEXT NOT NULL,
263 | `topic_author` bigint(20) NOT NULL,
264 | `topic_last_author` bigint(20) NOT NULL,
265 | `topic_stamp` bigint(30) NOT NULL,
266 | `topic_last_updated_stamp` bigint(30) NOT NULL,
267 | `topic_closed` tinyint(1) NOT NULL default '0',
268 | `topic_sticky` tinyint(1) NOT NULL default '0',
269 | `topic_posts` bigint(20) NOT NULL default '0',
270 | PRIMARY KEY (`topic_ID`)
271 | ) ENGINE=MyISAM;";
272 | $forums_table3 = "CREATE TABLE `" . $db_prefix . "forums_posts` (
273 | `post_ID` bigint(20) unsigned NOT NULL auto_increment,
274 | `post_forum_ID` bigint(20) NOT NULL,
275 | `post_topic_ID` bigint(20) NOT NULL,
276 | `post_author` bigint(20) NOT NULL,
277 | `post_content` TEXT,
278 | `post_stamp` bigint(30) NOT NULL,
279 | PRIMARY KEY (`post_ID`)
280 | ) ENGINE=MyISAM;";
281 | $forums_table4 = "";
282 | $forums_table5 = "";
283 |
284 | $wpdb->query( $forums_table1 );
285 | $wpdb->query( $forums_table2 );
286 | $wpdb->query( $forums_table3 );
287 | update_site_option( "forums_installed", "yes" );
288 | }
289 | }
290 |
291 | function forums_plug_pages() {
292 | global $current_user, $forums_enable_upgrades;
293 |
294 | if ( $forums_enable_upgrades && FORUM_DEMO_FOR_NON_SUPPORTER && function_exists('is_pro_site') && !is_pro_site()) {
295 | add_menu_page( __( 'Forums', 'wpmudev_forums' ), __( 'Forums', 'wpmudev_forums' ), 'manage_options', 'wpmudev_forums', 'forums_non_supporter_output');
296 | } else {
297 | add_menu_page( __( 'Forums', 'wpmudev_forums' ), __( 'Forums', 'wpmudev_forums' ), 'manage_options', 'wpmudev_forums', 'forums_manage_output');
298 | }
299 | }
300 |
301 | function forums_options_plug_pages() {
302 | $page = WP_NETWORK_ADMIN ? 'settings.php' : 'options-general.php';
303 | $perms = WP_NETWORK_ADMIN ? 'manage_network_options' : 'manage_options';
304 | add_submenu_page($page, __( 'Forum Settings', 'wpmudev_forums' ), __( 'Forums', 'wpmudev_forums' ), $perms, 'wpmudev_forum_settings', 'forums_manage_options_output');
305 | }
306 |
307 | function forums_non_supporter_output() {
308 | global $blog_id, $psts;
309 | ?>
310 |
311 |
314 | base_prefix) ) {
325 | $db_prefix = $wpdb->base_prefix;
326 | } else {
327 | $db_prefix = $wpdb->prefix;
328 | }
329 | $tmp_forum_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
330 | if ($tmp_forum_count > 0){
331 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
332 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $db_prefix . "forums_topics WHERE topic_forum_ID = %d", $tmp_fid) );
333 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $db_prefix . "forums_posts WHERE post_forum_ID = %d", $tmp_fid) );
334 | }
335 | }
336 |
337 |
338 | //------------------------------------------------------------------------//
339 | //---Output Functions-----------------------------------------------------//
340 | //------------------------------------------------------------------------//
341 |
342 | function forums_output($content) {
343 | global $wpdb, $user_ID, $forums_posts_per_page, $current_site, $post;
344 | if ( !empty($wpdb->base_prefix) ) {
345 | $db_prefix = $wpdb->base_prefix;
346 | } else {
347 | $db_prefix = $wpdb->prefix;
348 | }
349 | $original_content = $content;
350 | if(preg_match("[forum:[0-9]{1,20}]",$content) == true) {
351 | $tmp_match = $content;
352 | preg_match("|[forum:[0-9]{1,20}]|",$tmp_match,$tmp_match);
353 | $tmp_fid = $tmp_match[0];
354 | $tmp_fid = str_replace('[forum:','',$tmp_fid);
355 | $tmp_fid = str_replace(']','',$tmp_fid);
356 | $tmp_forum_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
357 | if ($tmp_forum_count > 0){
358 | $content = '';
359 | $_action = isset($_GET['action'])?$_GET['action']:'';
360 | $_topic = isset($_GET['topic'])?$_GET['topic']:'';
361 | $_search = isset($_POST['search'])?$_POST['search']:'';
362 | if ($_action == 'new_topic'){
363 | //Display New Topic Form
364 | $content = forums_output_new_topic($tmp_fid,0,'');
365 | } else if ($_action == 'new_topic_process'){
366 | //Display Topic Process, etc
367 | $tmp_errors = 0;
368 | //check for empty title
369 | if ($_POST['topic_title'] == ''){
370 | $tmp_errors = $tmp_errors + 1;
371 | }
372 | //check for empty content
373 | if ($_POST['post_content'] == ''){
374 | $tmp_errors = $tmp_errors + 1;
375 | }
376 | //check for invalid user ID
377 | $tmp_user_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "users WHERE ID = %d", $_POST['uid']) );
378 | if ($tmp_user_count > 0){
379 | //we're good
380 | } else {
381 | $tmp_errors = $tmp_errors + 1;
382 | $tmp_error_msg = __( 'Invalid user account...', 'wpmudev_forums' );
383 | }
384 | //check for invalid forum ID
385 | if ($_POST['fid'] != $tmp_fid){
386 | $tmp_errors = $tmp_errors + 1;
387 | $tmp_error_msg = __( 'Invalid forum...', 'wpmudev_forums' );
388 | }
389 | if ($tmp_errors > 0){
390 | $content = forums_output_new_topic($tmp_fid,$tmp_errors,$tmp_error_msg);
391 | } else {
392 | $tmp_tid = forums_topic_process($tmp_fid);
393 | if ($tmp_tid == ''){
394 | //nothing
395 | } else {
396 | forums_topic_count_posts($tmp_tid);
397 | forums_forum_count_posts($tmp_fid);
398 | forums_forum_count_topics($tmp_fid);
399 | $content = $content . '
' . __( 'Topic Added!', 'wpmudev_forums' ) . '
';
400 | $content = $content . forums_output_search_form($tmp_fid);
401 | $content = $content . ' ';
402 | $content = $content . forums_output_forum_nav($tmp_fid);
403 | $content = $content . ' ';
404 | $content = $content . forums_output_forum($tmp_fid);
405 | $content = $content . ' ';
406 | $content = $content . forums_output_forum_nav($tmp_fid);
407 | }
408 | }
409 | } else if ($_topic != ''){
410 | $tmp_topic_count = 0;
411 | $tmp_forum_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
412 | if ($tmp_forum_count > 0){
413 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d AND topic_forum_ID = %d", $_GET['topic'], $tmp_fid) );
414 | }
415 | if ($tmp_topic_count > 0){
416 | if ($_action == 'close_topic'){
417 | if(current_user_can('manage_options')) {
418 | $wpdb->update(
419 | "{$db_prefix}forums_topics",
420 | array(
421 | 'topic_closed' => 1,
422 | ),
423 | array(
424 | 'topic_ID' => $_GET['topic'],
425 | 'topic_forum_ID' => $tmp_fid,
426 | ),
427 | array(
428 | '%d'
429 | ),
430 | array(
431 | '%d',
432 | '%d'
433 | )
434 | );
435 | $tmp_msg = __( 'Topic Closed!', 'wpmudev_forums' );
436 | } else {
437 | $tmp_msg = __( 'Permission denied...', 'wpmudev_forums' );
438 | }
439 | }
440 | if ($_action == 'open_topic'){
441 | if(current_user_can('manage_options')) {
442 | $wpdb->update(
443 | "{$db_prefix}forums_topics",
444 | array(
445 | 'topic_closed' => 0,
446 | ),
447 | array(
448 | 'topic_ID' => $_GET['topic'],
449 | 'topic_forum_ID' => $tmp_fid,
450 | ),
451 | array(
452 | '%d'
453 | ),
454 | array(
455 | '%d',
456 | '%d'
457 | )
458 | );
459 | $tmp_msg = __( 'Topic Opened!', 'wpmudev_forums' );
460 | } else {
461 | $tmp_msg = __( 'Permission denied...', 'wpmudev_forums' );
462 | }
463 | }
464 | $tmp_forum = forum_get_details($_GET['topic']);
465 |
466 | $tmp_topic_title = $tmp_forum['topic_title'];
467 | $tmp_topic_last_updated = $tmp_forum['topic_last_updated_stamp'];
468 | $tmp_topic_last_author = $tmp_forum['topic_last_author'];
469 | $tmp_topic_closed = $tmp_forum['topic_closed'];
470 |
471 | if ($tmp_topic_closed == 1){
472 | $content = $content . '' . $tmp_topic_title . ' (' . __( 'Closed', 'wpmudev_forums' ) . ') ';
473 | } else {
474 | $content = $content . '' . $tmp_topic_title . ' ';
475 | }
476 | $tmp_msg = isset($tmp_msg)?$tmp_msg:'';
477 | if ($tmp_msg != ''){
478 | $content = $content . '
' . $tmp_msg . ' ';
479 | }
480 |
481 | if (isset($_GET['msg']) && $_GET['msg'] != ''){
482 | $content = $content . '
' . esc_html(urldecode($_GET['msg'])) . ' ';
483 | }
484 | $content = $content . ' ';
485 | $content .= forums_get_metadata( $tmp_topic_last_updated, $tmp_topic_last_author );
486 | $content .= forums_get_navigation( $post->ID, (int)$_GET['topic'], $tmp_topic_closed );
487 | $content = $content . forums_output_topic_nav((int)$_GET['topic']);
488 | $content = $content . ' ';
489 | $content = $content . forums_output_view_topic((int)$_GET['topic'],$tmp_fid);
490 | $content = $content . ' ';
491 | $content = $content . forums_output_topic_nav((int)$_GET['topic']);
492 | $content = $content . ' ';
493 | $content = $content . forums_output_new_post($tmp_fid,(int)$_GET['topic'],0,'');
494 | } else {
495 | // Invalid topic
496 | }
497 | } else if ($_action == 'delete_topic'){
498 | $tmp_topic_count = 0;
499 | $tmp_forum_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
500 | if ($tmp_forum_count > 0){
501 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d AND topic_forum_ID = %d", $_GET['tid'], $tmp_fid) );
502 | }
503 | if ($tmp_topic_count > 0){
504 | if(current_user_can('manage_options')) {
505 | $content = $content . forums_output_delete_topic($tmp_fid,(int)$_GET['tid']);
506 | } else {
507 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
508 | }
509 | } else {
510 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
511 | }
512 | } else if ($_action == 'delete_topic_process'){
513 | $tmp_topic_count = 0;
514 | $tmp_forum_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
515 | if ($tmp_forum_count > 0){
516 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d AND topic_forum_ID = %d", $_POST['tid'], $tmp_fid) );
517 | }
518 | if ($tmp_topic_count > 0){
519 | if ( isset($_POST['Cancel']) ) {
520 | if ($_GET['action'] == 'close_topic'){
521 | if(current_user_can('manage_options')) {
522 | $wpdb->update(
523 | "{$db_prefix}forums_topics",
524 | array(
525 | 'topic_closed' => 1,
526 | ),
527 | array(
528 | 'topic_ID' => $_GET['topic'],
529 | 'topic_forum_ID' => $tmp_fid,
530 | ),
531 | array(
532 | '%d'
533 | ),
534 | array(
535 | '%d',
536 | '%d'
537 | )
538 | );
539 | $tmp_msg = __( 'Topic Closed!', 'wpmudev_forums' );
540 | } else {
541 | $tmp_msg = __( 'Permission denied...', 'wpmudev_forums' );
542 | }
543 | }
544 | if ($_GET['action'] == 'open_topic'){
545 | if(current_user_can('manage_options')) {
546 | $wpdb->update(
547 | "{$db_prefix}forums_topics",
548 | array(
549 | 'topic_closed' => 0,
550 | ),
551 | array(
552 | 'topic_ID' => $_GET['topic'],
553 | 'topic_forum_ID' => $tmp_fid,
554 | ),
555 | array(
556 | '%d'
557 | ),
558 | array(
559 | '%d',
560 | '%d'
561 | )
562 | );
563 | $tmp_msg = __( 'Topic Opened!', 'wpmudev_forums' );
564 | } else {
565 | $tmp_msg = __( 'Permission denied...', 'wpmudev_forums' );
566 | }
567 | }
568 |
569 | $tmp_forum = forum_get_details($_POST['tid']);
570 |
571 | $tmp_topic_title = $tmp_forum['topic_title'];
572 | $tmp_topic_last_updated = $tmp_forum['topic_last_updated_stamp'];
573 | $tmp_topic_last_author = $tmp_forum['topic_last_author'];
574 | $tmp_topic_closed = $tmp_forum['topic_closed'];
575 |
576 | if ($tmp_topic_closed == 1){
577 | $content = $content . '' . $tmp_topic_title . ' (' . __( 'Closed', 'wpmudev_forums' ) . ') ';
578 | } else {
579 | $content = $content . '' . $tmp_topic_title . ' ';
580 | }
581 | if ($tmp_msg != ''){
582 | $content = $content . '
' . $tmp_msg . ' ';
583 | }
584 | if ($_GET['msg'] != ''){
585 | $content = $content . '
' . esc_html( urldecode( $_GET['msg'] ) ) . ' ';
586 | }
587 | $content = $content . ' ';
588 | $content .= forums_get_metadata( $tmp_topic_last_updated, $tmp_topic_last_author );
589 | $content .= forums_get_navigation( $post->ID, (int)$_POST['tid'], $tmp_topic_closed );
590 | $content = $content . forums_output_topic_nav((int)$_POST['tid']);
591 | $content = $content . ' ';
592 | $content = $content . forums_output_view_topic((int)$_POST['tid'],$tmp_fid);
593 | $content = $content . ' ';
594 | $content = $content . forums_output_topic_nav((int)$_POST['tid']);
595 | $content = $content . ' ';
596 | $content = $content . forums_output_new_post($tmp_fid,(int)$_GET['tid'],0,'');
597 | } else {
598 | if(current_user_can('manage_options')) {
599 | $tmp_errors = forums_output_delete_topic_process($tmp_fid,(int)$_POST['tid']);
600 | if ($tmp_errors > 0){
601 | if ($_GET['action'] == 'close_topic'){
602 | if(current_user_can('manage_options')) {
603 | $wpdb->update(
604 | "{$db_prefix}forums_topics",
605 | array(
606 | 'topic_closed' => 1,
607 | ),
608 | array(
609 | 'topic_ID' => $_GET['topic'],
610 | 'topic_forum_ID' => $tmp_fid
611 | ),
612 | array(
613 | '%d'
614 | ),
615 | array(
616 | '%d',
617 | '%d'
618 | )
619 | );
620 | $tmp_msg = __( 'Topic Closed!', 'wpmudev_forums' );
621 | } else {
622 | $tmp_msg = __( 'Permission denied...', 'wpmudev_forums' );
623 | }
624 | }
625 | if ($_GET['action'] == 'open_topic'){
626 | if(current_user_can('manage_options')) {
627 | $wpdb->update(
628 | "{$db_prefix}forums_topics",
629 | array(
630 | 'topic_closed' => 0,
631 | ),
632 | array(
633 | 'topic_ID' => $_GET['topic'],
634 | 'topic_forum_ID' => $tmp_fid
635 | ),
636 | array(
637 | '%d'
638 | ),
639 | array(
640 | '%d',
641 | '%d'
642 | )
643 | );
644 | $tmp_msg = __( 'Topic Opened!', 'wpmudev_forums' );
645 | } else {
646 | $tmp_msg = __( 'Permission denied...', 'wpmudev_forums' );
647 | }
648 | }
649 | $tmp_forum = forum_get_details($_POST['tid']);
650 |
651 | $tmp_topic_title = $tmp_forum['topic_title'];
652 | $tmp_topic_last_updated = $tmp_forum['topic_last_updated_stamp'];
653 | $tmp_topic_last_author = $tmp_forum['topic_last_author'];
654 | $tmp_topic_closed = $tmp_forum['topic_closed'];
655 |
656 | if ($tmp_topic_closed == 1){
657 | $content = $content . '' . $tmp_topic_title . ' (' . __( 'Closed', 'wpmudev_forums' ) . ') ';
658 | } else {
659 | $content = $content . '' . $tmp_topic_title . ' ';
660 | }
661 | if ($tmp_msg != ''){
662 | $content = $content . '
' . $tmp_msg . ' ';
663 | }
664 | if ($_GET['msg'] != ''){
665 | $content = $content . '
' . esc_html(urldecode( $_GET['msg'] )) . ' ';
666 | }
667 | $content = $content . '
' . __( 'Error deleting topic...', 'wpmudev_forums' ) . ' ';
668 | $content = $content . ' ';
669 | $content .= forums_get_metadata( $tmp_topic_last_updated, $tmp_topic_last_author );
670 | $content .= forums_get_navigation( $post->ID, (int)$_GET['topic'], $tmp_topic_closed );
671 | $content = $content . forums_output_topic_nav((int)$_POST['tid']);
672 | $content = $content . ' ';
673 | $content = $content . forums_output_view_topic((int)$_POST['tid'],$tmp_fid);
674 | $content = $content . ' ';
675 | $content = $content . forums_output_topic_nav((int)$_POST['tid']);
676 | $content = $content . ' ';
677 | $content = $content . forums_output_new_post($tmp_fid,(int)$_GET['tid'],0,'');
678 | } else {
679 | forums_forum_count_posts($tmp_fid);
680 | forums_forum_count_topics($tmp_fid);
681 | $content = $content . '
' . __( 'Topic Deleted!', 'wpmudev_forums' ) . ' ';
682 | $content = $content . forums_output_search_form($tmp_fid);
683 | $content = $content . ' ';
684 | $content = $content . forums_output_forum_nav($tmp_fid);
685 | $content = $content . ' ';
686 | $content = $content . forums_output_forum($tmp_fid);
687 | $content = $content . ' ';
688 | $content = $content . forums_output_forum_nav($tmp_fid);
689 | }
690 | } else {
691 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
692 | }
693 | }
694 | } else {
695 | $content = $content . '
' . __( 'Invalid Topic!', 'wpmudev_forums' ) . ' ';
696 | }
697 | } else if ($_action == 'delete_post'){
698 | $tmp_topic_count = 0;
699 | $tmp_post_count = 0;
700 | $tmp_forum_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
701 | if ($tmp_forum_count > 0){
702 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d AND topic_forum_ID = %d", $_GET['tid'], $tmp_fid) );
703 | }
704 | if ($tmp_topic_count > 0){
705 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_ID = %d", $_GET['tid'], $_GET['pid']) );
706 | }
707 | if ($tmp_post_count > 0){
708 | if(current_user_can('manage_options')) {
709 | $content = $content . forums_output_delete_post((int)$_GET['pid'],(int)$_GET['tid'],(int)$_GET['forum_page']);
710 | } else {
711 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
712 | }
713 | } else {
714 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
715 | }
716 | } else if ($_action == 'delete_post_process'){
717 | if ( isset($_POST['Cancel']) ) {
718 | echo '';
721 | } else {
722 | $tmp_errors = forums_output_delete_post_process($tmp_fid,(int)$_POST['pid'],(int)$_POST['tid']);
723 | if ($tmp_errors > 0){
724 | echo '';
727 | } else {
728 | echo '';
731 | }
732 | }
733 | exit();
734 | } else if ($_action == 'edit_post'){
735 | $tmp_topic_count = 0;
736 | $tmp_post_count = 0;
737 | $tmp_forum_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
738 | if ($tmp_forum_count > 0){
739 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d AND topic_forum_ID = %d", $_GET['tid'], $tmp_fid) );
740 | }
741 | if ($tmp_topic_count > 0){
742 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_ID = %d", $_GET['tid'], $_GET['pid']) );
743 | }
744 | if ($tmp_post_count > 0){
745 | if(current_user_can('manage_options')) {
746 | //yep
747 | $content = $content . forums_output_edit_post((int)$_GET['pid'],$tmp_fid,(int)$_GET['tid'],0,'',(int)$_GET['forum_page']);
748 | } else {
749 | $tmp_post_auhtor = $wpdb->get_var( $wpdb->prepare("SELECT post_author FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_ID = %d", $_GET['tid'], $_GET['pid']) );
750 | if ($tmp_post_auhtor == $user_ID){
751 | //yep
752 | $content = $content . forums_output_edit_post((int)$_GET['pid'],$tmp_fid,(int)$_GET['tid'],0,'',(int)$_GET['forum_page']);
753 | } else {
754 | //nope
755 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
756 | }
757 | }
758 | } else {
759 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
760 | }
761 | } else if ($_action == 'edit_post_process'){
762 | if ( isset($_POST['Cancel']) ) {
763 | echo '';
766 | exit();
767 | } else {
768 | if ($_POST['post_content'] == ''){
769 | $content = $content . forums_output_edit_post((int)$_POST['pid'],$tmp_fid,(int)$_POST['tid'],1,'',(int)$_POST['forum_page']);
770 | } else {
771 | //auth check
772 | if(current_user_can('manage_options')) {
773 | forums_output_edit_post_process($tmp_fid,(int)$_POST['pid'],(int)$_POST['tid']);
774 | echo '';
777 | exit();
778 | } else {
779 | $tmp_post_auhtor = $wpdb->get_var( $wpdb->prepare("SELECT post_author FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_ID = %d", $_POST['tid'], $_POST['pid']) );
780 | if ($tmp_post_auhtor == $user_ID){
781 | forums_output_edit_post_process($tmp_fid,(int)$_POST['pid'],(int)$_POST['tid']);
782 | echo '';
785 | exit();
786 | } else {
787 | $content = $content . '
' . __( 'Permission denied...', 'wpmudev_forums' ) . ' ';
788 | }
789 | }
790 | }
791 | }
792 | } else if ($_action == 'new_post_process'){
793 | if ($user_ID == '' || $user_ID == '0'){
794 | $content = $content . '
' . sprintf( __( 'You must be a registered and logged in user of this blog to post on this forum. Please Log In or %s.', 'wpmudev_forums' ), wp_login_url(), wp_register('', '', false) ) . ' ';
795 | } else {
796 | $tmp_topic_closed = $wpdb->get_var( $wpdb->prepare("SELECT topic_closed FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d", $_POST['tid']) );
797 | if ($tmp_topic_closed != '1'){
798 | if ($_POST['post_content'] == ''){
799 | $content = $content . forums_output_new_post_separate($tmp_fid,(int)$_POST['tid'],1,'');
800 | } else {
801 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_forum_ID = %d", $_POST['tid'], $tmp_fid) );
802 | $tmp_total_pages = forums_roundup($tmp_post_count / $forums_posts_per_page, 0);
803 | forums_output_new_post_process($tmp_fid,(int)$_POST['tid']);
804 | echo '';
807 | exit();
808 | }
809 | }
810 | }
811 | } else if ($_search != '' || $_search != ''){
812 | $tmp_query = '';
813 | $tmp_query = $_POST['search'];
814 | if ($tmp_query == ''){
815 | $tmp_query = $_GET['search'];
816 | }
817 | $content = $content . forums_output_search_results($tmp_fid,$tmp_query); //escaped in function
818 | } else if ($_action == '2'){
819 | } else {
820 | //Display Forum
821 | $content = $content . forums_output_search_form($tmp_fid);
822 | $content = $content . ' ';
823 | $content = $content . forums_output_forum_nav($tmp_fid);
824 | $content = $content . ' ';
825 | $content = $content . forums_output_forum($tmp_fid);
826 | $content = $content . ' ';
827 | $content = $content . forums_output_forum_nav($tmp_fid);
828 | }
829 | } else {
830 | $content = __( 'Invalid Forum Code', 'wpmudev_forums' );
831 | }
832 | //insert/post content
833 | $original_content = str_replace('[forum:' . $tmp_fid . ']','',$original_content);
834 | $content = $original_content . $content;
835 | }
836 | return $content;
837 | }
838 |
839 | function forums_get_navigation( $post_id, $topic_id, $topic_closed ) {
840 | $content = ' ';
841 | $content .= '';
842 | $content .= '' . __( 'Back to index', 'wpmudev_forums' ) . ' | ';
843 | if(current_user_can('manage_options')) {
844 | $content .= '' . __( 'Delete Topic', 'wpmudev_forums' ) . ' | ';
845 | if ($topic_closed == 1){
846 | $content .= '' . __( 'Open Topic', 'wpmudev_forums' ) . ' ';
847 | } else {
848 | $content .= '' . __( 'Close Topic', 'wpmudev_forums' ) . ' ';
849 | }
850 | }
851 | $content .= ' ';
852 | $content .= ' ';
853 | return $content;
854 | }
855 |
856 | function forums_get_metadata( $last_updated, $last_author ) {
857 | $content = ' ';
858 | $content .= '';
862 | return $content;
863 | }
864 |
865 | function forum_shortcode( $atts ) {
866 | if(isset($atts[0]))
867 | $id = $atts[0];
868 | elseif(isset($atts['id']))
869 | $id = ':'.$atts['id'];
870 | return forums_output("[forum{$id}]");
871 | }
872 | add_shortcode( 'forum', 'forum_shortcode' );
873 |
874 | function forums_output_search_results($tmp_fid,$tmp_query){
875 | global $wpdb, $user_ID, $forums_posts_per_page;
876 | if ( !empty($wpdb->base_prefix) ) {
877 | $db_prefix = $wpdb->base_prefix;
878 | } else {
879 | $db_prefix = $wpdb->prefix;
880 | }
881 |
882 | $content = '';
883 | if (isset($_REQUEST['fid']) && $_REQUEST['fid'] != $tmp_fid) {
884 |
885 | $content = $content . forums_output_search_form($tmp_fid);
886 | $content = $content . ' ';
887 | $content = $content . forums_output_forum_nav($tmp_fid);
888 | $content = $content . ' ';
889 | $content = $content . forums_output_forum($tmp_fid);
890 | $content = $content . ' ';
891 | $content = $content . forums_output_forum_nav($tmp_fid);
892 |
893 | return $content;
894 | }
895 |
896 | $tmp_forum_color_one = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_one FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
897 | $tmp_forum_color_two = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_two FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
898 | $tmp_forum_color_header = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_header FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
899 | $tmp_forum_color_border = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_border FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
900 | $tmp_forum_border_size = $wpdb->get_var( $wpdb->prepare("SELECT forum_border_size FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
901 | $style = 'style="border-collapse: collapse;border-style: solid;border-width: ' . $tmp_forum_border_size . 'px;border-color: ' . $tmp_forum_color_border . ';"';
902 |
903 |
904 | $content = $content . '' . __( 'Search Results', 'wpmudev_forums' ) . ' ';
905 | $content = $content . forums_output_search_form($tmp_fid);
906 | $content = $content . ' ';
907 | $content = $content . '' . __( 'Posts:', 'wpmudev_forums' ) . ' ';
908 |
909 | $query = "SELECT * FROM " . $db_prefix . "forums_posts WHERE post_forum_ID = %d AND post_content LIKE %s";
910 | $query = $query . " ORDER BY post_ID ASC";
911 | $query = $query . " LIMIT 25";
912 | $tmp_results = $wpdb->get_results( $wpdb->prepare($query, $tmp_fid, '%' . $tmp_query . '%' ), ARRAY_A );
913 | if (count($tmp_results) > 0){
914 | $alt_color = '';
915 | $alt_color = ('alternate' == $alt_color) ? '' : 'alternate';
916 | $tmp_counter = 0;
917 | $content = $content . '';
918 | foreach ($tmp_results as $tmp_result){
919 | $tmp_counter = $tmp_counter + 1;
920 | //=========================================================//
921 | if ($alt_color == 'alternate'){
922 | $content = $content . '';
923 | } else {
924 | $content = $content . ' ';
925 | }
926 | $tmp_forum = forum_get_details($tmp_result['post_topic_ID']);
927 |
928 | $tmp_topic_title = $tmp_forum['topic_title'];
929 | $tmp_topic_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d", $tmp_result['post_topic_ID']) );
930 |
931 | $content = $content . '' . $tmp_counter . '. ';
932 | $content = $content . '';
933 | if ($tmp_topic_post_count > $forums_posts_per_page){
934 | $content = $content . '' . $tmp_topic_title . ' ';
935 | } else {
936 | $content = $content . '' . $tmp_topic_title . ' ';
937 | }
938 | $content = $content . str_replace($tmp_query,'' . $tmp_query . ' ',forums_display_post_content($tmp_result['post_content']));
939 | $content = $content . '
';
940 | $content = $content . ' ';
941 | $alt_color = ('alternate' == $alt_color) ? '' : 'alternate';
942 | //=========================================================//
943 | }
944 | $content = $content . '
';
945 | } else {
946 | $content = $content . '
' . __( 'No matches...', 'wpmudev_forums' ) . ' ';
947 | }
948 |
949 | return $content;
950 | }
951 |
952 | function forums_output_search_form($tmp_fid){
953 | global $wpdb, $user_ID;
954 | if ( !empty($wpdb->base_prefix) ) {
955 | $db_prefix = $wpdb->base_prefix;
956 | } else {
957 | $db_prefix = $wpdb->prefix;
958 | }
959 |
960 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_forum_ID = %d", $tmp_fid) );
961 |
962 | $content = '';
963 | $tmp_query = '';
964 | if (isset($_REQUEST['fid']) && $_REQUEST['fid'] == $tmp_fid) {
965 | $tmp_query = isset($_POST['search'])?$_POST['search']:'';
966 | if ($tmp_query == ''){
967 | $tmp_query = isset($_GET['search'])?$_GET['search']:'';
968 | }
969 | }
970 |
971 | if ($tmp_topic_count > 0){
972 | $content = $content . '
';
973 | $content = $content . '';
980 | $content = $content . ' ';
981 | } else {
982 | $content = '';
983 | }
984 | return $content;
985 | }
986 |
987 | function forums_output_new_post_process($tmp_fid,$tmp_tid) {
988 | global $wpdb, $user_ID;
989 | if ( !empty($wpdb->base_prefix) ) {
990 | $db_prefix = $wpdb->base_prefix;
991 | } else {
992 | $db_prefix = $wpdb->prefix;
993 | }
994 |
995 | $wpdb->insert(
996 | "{$db_prefix}forums_posts",
997 | array(
998 | 'post_forum_ID' => $tmp_fid,
999 | 'post_topic_ID' => $tmp_tid,
1000 | 'post_author' => $user_ID,
1001 | 'post_content' => forums_save_post_content($_POST['post_content']),
1002 | 'post_stamp' => time(),
1003 | ),
1004 | array(
1005 | '%d',
1006 | '%d',
1007 | '%d',
1008 | '%s',
1009 | '%d'
1010 | )
1011 | );
1012 | $wpdb->update(
1013 | "{$db_prefix}forums_topics",
1014 | array(
1015 | 'topic_last_author' => $user_ID,
1016 | 'topic_last_updated_stamp' => time(),
1017 | ),
1018 | array(
1019 | 'topic_ID' => $tmp_tid,
1020 | ),
1021 | array(
1022 | '%d',
1023 | '%d'
1024 | ),
1025 | array(
1026 | '%d'
1027 | )
1028 | );
1029 |
1030 | forums_topic_count_posts($tmp_tid);
1031 | forums_forum_count_posts($tmp_fid);
1032 | forums_forum_count_topics($tmp_fid);
1033 |
1034 | }
1035 |
1036 | function forums_output_new_post_separate($tmp_fid,$tmp_tid,$tmp_errors,$tmp_error_msg = ''){
1037 | global $wpdb, $user_ID, $current_site;
1038 | if ( !empty($wpdb->base_prefix) ) {
1039 | $db_prefix = $wpdb->base_prefix;
1040 | } else {
1041 | $db_prefix = $wpdb->prefix;
1042 | }
1043 |
1044 | if ($user_ID == '' || $user_ID == '0'){
1045 | $content = $content . '
' . sprintf( __( 'You must be a registered and logged in user of this blog to post on this forum. Please Log In or %s.', 'wpmudev_forums' ), wp_login_url(), wp_register('', '', false) ) . ' ';
1046 | } else {
1047 | $tmp_topic_closed = $wpdb->get_var( $wpdb->prepare("SELECT topic_closed FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d", $tmp_tid) );
1048 | if ($tmp_topic_closed != '1'){
1049 | $content = $content . '' . __( 'New Post', 'wpmudev_forums' ) . ' ';
1050 | if ($tmp_errors > 0){
1051 | if ($tmp_error_msg == ''){
1052 | $tmp_error_msg = __( 'You must fill in all required fields...', 'wpmudev_forums' );
1053 | }
1054 | $content = $content . '
' . __($tmp_error_msg) . ' ';
1055 |
1056 | }
1057 | $content = $content . '';
1075 | }
1076 | }
1077 | return $content;
1078 | }
1079 |
1080 | function forums_output_new_post($tmp_fid,$tmp_tid,$tmp_errors,$tmp_error_msg = '') {
1081 | global $wpdb, $user_ID, $current_site;
1082 | if ( !empty($wpdb->base_prefix) ) {
1083 | $db_prefix = $wpdb->base_prefix;
1084 | } else {
1085 | $db_prefix = $wpdb->prefix;
1086 | }
1087 | $content = '';
1088 | if ($user_ID == '' || $user_ID == '0'){
1089 | $content = $content . ' ';
1090 | $content = $content . '
' . sprintf( __( 'You must be a registered and logged in user of this blog to post on this forum. Please Log In or %s.', 'wpmudev_forums' ), wp_login_url(), wp_register('', '', false) ) . ' ';
1091 | } else {
1092 | $tmp_topic_closed = $wpdb->get_var( $wpdb->prepare("SELECT topic_closed FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d", $tmp_tid) );
1093 | if ($tmp_topic_closed != '1'){
1094 | $content = $content . ' ';
1095 | $content = $content . ' ';
1096 | $content = $content . '' . __( 'New Post', 'wpmudev_forums' ) . ' ';
1097 | if ($tmp_errors > 0){
1098 | if ($tmp_error_msg == ''){
1099 | $tmp_error_msg = __( 'You must fill in all required fields...' );
1100 | }
1101 | $content = $content . '
' . $tmp_error_msg . ' ';
1102 |
1103 | }
1104 | $content = $content . '';
1105 | $content = $content . ' ';
1106 | $content = $content . ' ';
1107 | $content = $content . ' ';
1108 | $content = $content . '';
1109 | $content = $content . '';
1110 | $content = $content . '';
1111 | $content = $content . '' . __( 'Post:', 'wpmudev_forums' ) . ' ';
1112 | $content = $content . '' . esc_textarea(isset($_POST['post_content'])?$_POST['post_content']:'') . ' ';
1113 | $content = $content . ' ';
1114 | $content = $content . __( 'Required', 'wpmudev_forums' ) . ' ';
1115 | $content = $content . ' ';
1116 | $content = $content . '
';
1117 | $content = $content . ' ';
1118 | $content = $content . '';
1119 | $content = $content . ' ';
1120 | $content = $content . '
';
1121 | $content = $content . ' ';
1122 | }
1123 | }
1124 | return $content;
1125 | }
1126 |
1127 | function forums_output_edit_post_process($tmp_fid,$tmp_pid,$tmp_tid) {
1128 | global $wpdb, $user_ID;
1129 | if ( !empty($wpdb->base_prefix) ) {
1130 | $db_prefix = $wpdb->base_prefix;
1131 | } else {
1132 | $db_prefix = $wpdb->prefix;
1133 | }
1134 |
1135 | $wpdb->update(
1136 | "{$db_prefix}forums_posts",
1137 | array(
1138 | 'post_content' => forums_save_post_content($_POST['post_content']),
1139 | ),
1140 | array(
1141 | 'post_ID' => $tmp_pid,
1142 | ),
1143 | array(
1144 | '%s'
1145 | ),
1146 | array(
1147 | '%d'
1148 | )
1149 | );
1150 |
1151 | $content = '';
1152 | $content = $content . forums_output_topic_nav($tmp_tid);
1153 | $content = $content . ' ';
1154 | $content = $content . forums_output_view_topic($tmp_tid,$tmp_fid);
1155 | $content = $content . ' ';
1156 | $content = $content . forums_output_topic_nav($tmp_tid);
1157 | $content = $content . ' ';
1158 | $content = $content . forums_output_new_post($tmp_fid,$tmp_tid,0,'');
1159 | }
1160 |
1161 | function forums_output_edit_post($tmp_pid,$tmp_fid,$tmp_tid,$tmp_errors,$tmp_error_msg = '',$tmp_page) {
1162 | global $wpdb, $user_ID;
1163 | if ( !empty($wpdb->base_prefix) ) {
1164 | $db_prefix = $wpdb->base_prefix;
1165 | } else {
1166 | $db_prefix = $wpdb->prefix;
1167 | }
1168 |
1169 | $tmp_post_content = $wpdb->get_var( $wpdb->prepare("SELECT post_content FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_ID = %d", $_GET['tid'], $_GET['pid']) );
1170 | $content = $content . '' . __( 'Edit Post', 'wpmudev_forums' ) . ' ';
1171 | if ($tmp_errors > 0){
1172 | if ($tmp_error_msg == ''){
1173 | $tmp_error_msg = __( 'You must fill in all required fields...', 'wpmudev_forums' );
1174 | }
1175 | $content = $content . '
' . $tmp_error_msg . ' ';
1176 |
1177 | }
1178 | $content = $content . '';
1179 | $content = $content . ' ';
1180 | if ($tmp_errors > 0){
1181 | $content = $content . ' ';
1182 | } else {
1183 | $content = $content . ' ';
1184 | }
1185 | $content = $content . ' ';
1186 | $content = $content . ' ';
1187 | $content = $content . ' ';
1188 | $content = $content . '';
1189 | $content = $content . '';
1190 | $content = $content . '';
1191 | $content = $content . '' . __( 'Post:', 'wpmudev_forums' ) . ' ';
1192 | if ($tmp_errors > 0){
1193 | $content = $content . '' . esc_textarea($_POST['post_content']) . ' ';
1194 | } else {
1195 | $content = $content . '' . esc_textarea(stripslashes($tmp_post_content)) . ' ';
1196 | }
1197 | $content = $content . ' ';
1198 | $content = $content . __( 'Required', 'wpmudev_forums' ) . ' ';
1199 | $content = $content . ' ';
1200 | $content = $content . '
';
1201 | $content = $content . ' ';
1202 | $content = $content . '';
1203 | $content = $content . ' ';
1204 | $content = $content . ' ';
1205 | $content = $content . '
';
1206 | $content = $content . ' ';
1207 | return $content;
1208 | }
1209 |
1210 | function forums_output_delete_post_process($tmp_fid,$tmp_pid,$tmp_tid) {
1211 | global $wpdb, $user_ID;
1212 | if ( !empty($wpdb->base_prefix) ) {
1213 | $db_prefix = $wpdb->base_prefix;
1214 | } else {
1215 | $db_prefix = $wpdb->prefix;
1216 | }
1217 |
1218 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_ID = %d", $tmp_tid, $tmp_pid) );
1219 |
1220 | $content = $content . forums_output_topic_nav($tmp_tid);
1221 | $content = $content . ' ';
1222 | $content = $content . forums_output_view_topic($tmp_tid,$tmp_fid);
1223 | $content = $content . ' ';
1224 | $content = $content . forums_output_topic_nav($tmp_tid);
1225 | $content = $content . ' ';
1226 | $content = $content . forums_output_new_post($tmp_fid,$tmp_tid,0,'');
1227 |
1228 | $error_count = 0;
1229 |
1230 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_ID = %d", $tmp_tid, $tmp_pid) );
1231 |
1232 | if ($tmp_post_count > 0){
1233 | $error_count = $error_count + 1;
1234 | }
1235 |
1236 | return $error_count;
1237 | }
1238 |
1239 | function forums_output_delete_post($tmp_pid,$tmp_tid,$tmp_page) {
1240 | global $wpdb, $user_ID;
1241 | if ( !empty($wpdb->base_prefix) ) {
1242 | $db_prefix = $wpdb->base_prefix;
1243 | } else {
1244 | $db_prefix = $wpdb->prefix;
1245 | }
1246 |
1247 | if ($user_ID == '' || $user_ID == '0'){
1248 | $content = $content . '' . __( 'Delete Post', 'wpmudev_forums' ) . ' ';
1249 | $content = $content . '
' . __( 'You must be logged in...', 'wpmudev_forums' ) . ' ';
1250 | } else {
1251 | $content = $content . '' . __( 'Delete Post', 'wpmudev_forums' ) . ' ';
1252 | $content = $content . ' ';
1253 | $content = $content . '' . __( 'Are you sure you want to delete this post?', 'wpmudev_forums' ) . '
';
1254 | $content = $content . '';
1255 | $content = $content . ' ';
1256 | $content = $content . ' ';
1257 | $content = $content . ' ';
1258 | $content = $content . ' ';
1259 | $content = $content . '';
1260 | $content = $content . ' ';
1261 | $content = $content . ' ';
1262 | $content = $content . '
';
1263 | $content = $content . ' ';
1264 | }
1265 | return $content;
1266 | }
1267 |
1268 | function forums_output_delete_topic_process($tmp_fid,$tmp_tid) {
1269 | global $wpdb, $user_ID;
1270 | if ( !empty($wpdb->base_prefix) ) {
1271 | $db_prefix = $wpdb->base_prefix;
1272 | } else {
1273 | $db_prefix = $wpdb->prefix;
1274 | }
1275 |
1276 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d AND topic_forum_ID = %d", $tmp_tid, $tmp_fid) );
1277 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d AND post_forum_ID = %d", $tmp_tid, $tmp_fid) );
1278 |
1279 | forums_forum_count_posts($tmp_fid);
1280 | forums_forum_count_topics($tmp_fid);
1281 |
1282 | $error_count = 0;
1283 |
1284 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d AND topic_forum_ID = %d", $tmp_tid, $tmp_fid) );
1285 |
1286 | if ($tmp_topic_count > 0){
1287 | $error_count = $error_count + 1;
1288 | }
1289 |
1290 | return $error_count;
1291 | }
1292 |
1293 | function forums_output_delete_topic($tmp_fid,$tmp_tid) {
1294 | global $wpdb, $user_ID;
1295 | if ( !empty($wpdb->base_prefix) ) {
1296 | $db_prefix = $wpdb->base_prefix;
1297 | } else {
1298 | $db_prefix = $wpdb->prefix;
1299 | }
1300 |
1301 | $content = '';
1302 |
1303 | if ($user_ID == '' || $user_ID == '0'){
1304 | $content = $content . '' . __( 'Delete Topic', 'wpmudev_forums' ) . ' ';
1305 | $content = $content . '
' . __( 'You must be logged in...', 'wpmudev_forums' ) . ' ';
1306 | } else {
1307 | $content = $content . '' . __( 'Delete Topic', 'wpmudev_forums' ) . ' ';
1308 | $content = $content . ' ';
1309 | $content = $content . '' . __( 'Are you sure you want to delete this topic?', 'wpmudev_forums' ) . '
';
1310 | $content = $content . '';
1311 | $content = $content . ' ';
1312 | $content = $content . ' ';
1313 | $content = $content . ' ';
1314 | $content = $content . '';
1315 | $content = $content . ' ';
1316 | $content = $content . ' ';
1317 | $content = $content . '
';
1318 | $content = $content . ' ';
1319 | }
1320 | return $content;
1321 | }
1322 |
1323 | function forums_output_topic_nav($tmp_tid){
1324 | global $wpdb, $forums_posts_per_page;
1325 | if ( !empty($wpdb->base_prefix) ) {
1326 | $db_prefix = $wpdb->base_prefix;
1327 | } else {
1328 | $db_prefix = $wpdb->prefix;
1329 | }
1330 | $content = '';
1331 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d", $tmp_tid) );
1332 | //=========================================//
1333 | $tmp_current_page = isset($_GET['forum_page'])?(int)$_GET['forum_page']:'';
1334 | if ($tmp_current_page == ''){
1335 | $tmp_current_page = 1;
1336 | }
1337 | $tmp_total_pages = forums_roundup($tmp_post_count / $forums_posts_per_page, 0);
1338 | $tmp_showing_low = ($tmp_current_page * $forums_posts_per_page) - ($forums_posts_per_page - 1);
1339 | if ($tmp_total_pages == $tmp_current_page){
1340 | //last page...
1341 | $tmp_showing_high = $tmp_post_count;
1342 | } else {
1343 | $tmp_showing_high = $tmp_current_page * $forums_posts_per_page;
1344 | }
1345 | //=========================================//
1346 | $content = $content . '';
1347 | $content = $content . '';
1348 | if ($tmp_current_page == 1){
1349 | $content = $content . ' ';
1350 | } else {
1351 | $tmp_previus_page = $tmp_current_page - 1;
1352 | $content = $content . '' . __(' « Previous') . ' ';
1353 | }
1354 | $content = $content . '' . sprintf( __( 'Showing %1s > %2s of %3s posts', 'wpmudev_forums' ), $tmp_showing_low, $tmp_showing_high, $tmp_post_count ) . ' ';
1355 | if ($tmp_current_page == $tmp_total_pages){
1356 | //last page
1357 | $content = $content . ' ';
1358 | } else {
1359 | $tmp_next_page = $tmp_current_page + 1;
1360 | $content = $content . '' . __( 'Next »', 'wpmudev_forums' ) . ' ';
1361 | }
1362 | $content = $content . ' ';
1363 | $content = $content . '
';
1364 | return $content;
1365 | }
1366 |
1367 | function forums_output_forum_nav($tmp_fid){
1368 | global $wpdb, $forums_topics_per_page;
1369 | if ( !empty($wpdb->base_prefix) ) {
1370 | $db_prefix = $wpdb->base_prefix;
1371 | } else {
1372 | $db_prefix = $wpdb->prefix;
1373 | }
1374 |
1375 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_forum_ID = %d", $tmp_fid) );;
1376 | //=========================================//
1377 | $tmp_current_page = isset($_GET['forum_page'])?(int)$_GET['forum_page']:1;
1378 | $tmp_total_pages = forums_roundup($tmp_topic_count / $forums_topics_per_page, 0);
1379 | $tmp_showing_low = ($tmp_current_page * $forums_topics_per_page) - ($forums_topics_per_page - 1);
1380 | if ($tmp_total_pages == $tmp_current_page){
1381 | //last page...
1382 | $tmp_showing_high = $tmp_topic_count;
1383 | } else {
1384 | $tmp_showing_high = $tmp_current_page * $forums_topics_per_page;
1385 | }
1386 | //=========================================//
1387 | $content = '';
1388 | if ($tmp_topic_count > 0){
1389 | $content = $content . '';
1390 | $content = $content . '';
1391 | if ($tmp_current_page == 1){
1392 | $content = $content . ' ';
1393 | } else {
1394 | $tmp_previus_page = $tmp_current_page - 1;
1395 | $content = $content . '« ' . __( 'Previous', 'wpmudev_forums' ) . ' ';
1396 | }
1397 | $content = $content . '' . sprintf( __( 'Showing %1s > %2s of %3s posts', 'wpmudev_forums' ), $tmp_showing_low, $tmp_showing_high, $tmp_topic_count ) . ' ';
1398 | if ($tmp_current_page == $tmp_total_pages){
1399 | //last page
1400 | $content = $content . ' ';
1401 | } else {
1402 | $tmp_next_page = $tmp_current_page + 1;
1403 | $content = $content . '' . __( 'Next', 'wpmudev_forums' ) . ' » ';
1404 | }
1405 | $content = $content . ' ';
1406 | $content = $content . '
';
1407 | }
1408 | return $content;
1409 | }
1410 |
1411 | function forums_output_view_topic($tmp_tid,$tmp_fid){
1412 | global $wpdb, $user_ID, $forums_posts_per_page;
1413 | if ( !empty($wpdb->base_prefix) ) {
1414 | $db_prefix = $wpdb->base_prefix;
1415 | } else {
1416 | $db_prefix = $wpdb->prefix;
1417 | }
1418 |
1419 | $content = '';
1420 |
1421 | $tmp_forum_color_one = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_one FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1422 | $tmp_forum_color_two = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_two FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1423 | $tmp_forum_color_header = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_header FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1424 | $tmp_forum_color_border = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_border FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1425 | $tmp_forum_border_size = $wpdb->get_var( $wpdb->prepare("SELECT forum_border_size FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1426 |
1427 | $style = 'style="border-collapse: collapse;border-style: solid;border-width: ' . $tmp_forum_border_size . 'px;border-color: ' . $tmp_forum_color_border . ';padding-top:5px;padding-bottom:5px;"';
1428 |
1429 | //=========================================//
1430 | $tmp_current_page = isset($_GET['forum_page'])?(int)$_GET['forum_page']:1;
1431 | if ($tmp_current_page == 1){
1432 | $tmp_start = 0;
1433 | } else {
1434 | $tmp_math = $tmp_current_page - 1;
1435 | $tmp_math = $forums_posts_per_page * $tmp_math;
1436 | //$tmp_math = $tmp_math - 1;
1437 | $tmp_start = $tmp_math;
1438 | }
1439 | //=========================================//
1440 |
1441 | $query = "SELECT * FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d";
1442 | $query = $query . " ORDER BY post_ID ASC";
1443 | $query = $query . " LIMIT %d, %d";
1444 | $tmp_posts = $wpdb->get_results( $wpdb->prepare($query, $tmp_tid, intval( $tmp_start ), intval( $forums_posts_per_page )), ARRAY_A );
1445 | $alt_color = isset($alt_color)?$alt_color:'';
1446 |
1447 | if (count($tmp_posts) > 0){
1448 | $alt_color = ('alternate' == $alt_color) ? '' : 'alternate';
1449 | //=========================================================//
1450 | $content = '';
1451 | //=========================================================//
1452 | foreach ($tmp_posts as $tmp_post){
1453 | if ($alt_color == 'alternate'){
1454 | $content = $content . '';
1455 | } else {
1456 | $content = $content . ' ';
1457 | }
1458 | $tmp_blog_id = get_user_meta($tmp_post['post_author'], 'primary_blog', true);
1459 | if ($tmp_blog_id == ''){
1460 | $content = $content . ' ' . esc_html(forums_author_display_name($tmp_post['post_author'])) . ' ' . get_avatar( $tmp_post['post_author'], '48', get_option('avatar_default') ) . '
';
1461 | } else {
1462 | $content = $content . ' ' . esc_html(forums_author_display_name($tmp_post['post_author'])) . ' ' . get_avatar( $tmp_post['post_author'], '48', get_option('avatar_default') ) . '
';
1463 | }
1464 | $content = $content . '' . forums_display_post_content($tmp_post['post_content']) . '
';
1465 | $content = $content . __( 'Posted: ', 'wpmudev_forums' ) . date(get_option('date_format', __("D, F jS Y g:i A", 'wpmudev_forums' )),$tmp_post['post_stamp']);
1466 | $content = $content . '
# ';
1467 | $tmp_now = time();
1468 | $tmp_then = $tmp_post['post_stamp'];
1469 | $tmp_ago = $tmp_now - $tmp_then;
1470 | if(current_user_can('manage_options')){
1471 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d", $tmp_tid) );
1472 | if ($tmp_post_count > 1){
1473 | $content = $content . '
' . __( 'Edit', 'wpmudev_forums' ) . ' |
' . __( 'Delete', 'wpmudev_forums' ) . ' ';
1474 | } else {
1475 | $content = $content . '
' . __( 'Edit', 'wpmudev_forums' ) . ' ';
1476 | }
1477 | } else if ($tmp_ago < 1800){
1478 | if ($tmp_post['post_author'] == $user_ID){
1479 | $content = $content . '
' . __( 'Edit', 'wpmudev_forums' ) . ' ';
1480 | }
1481 | }
1482 | $content = $content . '
';
1483 | $content = $content . ' ';
1484 | $alt_color = ('alternate' == $alt_color) ? '' : 'alternate';
1485 | //=========================================================//
1486 | }
1487 | //=========================================================//
1488 | $content = $content . '
';
1489 | //=========================================================//
1490 | } else {
1491 | $content = $content . '';
1492 | $content = $content . '';
1493 | $content = $content . '' . __( 'No posts to display...', 'wpmudev_forums' ) . ' ';
1494 | $content = $content . ' ';
1495 | $content = $content . '
';
1496 | }
1497 |
1498 | return $content;
1499 | }
1500 |
1501 | function forums_topic_process($tmp_fid) {
1502 | global $wpdb, $user_ID;
1503 | if ( !empty($wpdb->base_prefix) ) {
1504 | $db_prefix = $wpdb->base_prefix;
1505 | } else {
1506 | $db_prefix = $wpdb->prefix;
1507 | }
1508 |
1509 | $tmp_time = time();
1510 | $wpdb->insert(
1511 | "{$db_prefix}forums_topics",
1512 | array(
1513 | 'topic_forum_ID' => $tmp_fid,
1514 | 'topic_title' => $_POST['topic_title'],
1515 | 'topic_author' => $_POST['uid'],
1516 | 'topic_last_author' => $_POST['uid'],
1517 | 'topic_stamp' => $tmp_time,
1518 | 'topic_last_updated_stamp' => $tmp_time,
1519 | ),
1520 | array(
1521 | '%d',
1522 | '%s',
1523 | '%d',
1524 | '%d',
1525 | '%d',
1526 | '%d'
1527 | )
1528 | );
1529 | $tmp_tid = $wpdb->get_var( $wpdb->prepare("SELECT topic_ID FROM " . $db_prefix . "forums_topics WHERE topic_stamp = %d AND topic_title = %s AND topic_author = %d", $tmp_time, $_POST['topic_title'], $_POST['uid'] ) );
1530 | $wpdb->insert(
1531 | "{$db_prefix}forums_posts",
1532 | array(
1533 | 'post_forum_ID' => $tmp_fid,
1534 | 'post_topic_ID' => $tmp_tid,
1535 | 'post_author' => $_POST['uid'],
1536 | 'post_content' => $_POST['post_content'],
1537 | 'post_stamp' => $tmp_time,
1538 | ),
1539 | array(
1540 | '%d',
1541 | '%d',
1542 | '%d',
1543 | '%s',
1544 | '%d'
1545 | )
1546 | );
1547 |
1548 | forums_topic_count_posts($tmp_tid);
1549 | forums_forum_count_posts($tmp_fid);
1550 | forums_forum_count_topics($tmp_fid);
1551 |
1552 | return $tmp_tid;
1553 | }
1554 |
1555 | function forums_output_new_topic($tmp_fid, $tmp_errors,$tmp_error_msg = '') {
1556 | global $wpdb, $user_ID;
1557 | if ( !empty($wpdb->base_prefix) ) {
1558 | $db_prefix = $wpdb->base_prefix;
1559 | } else {
1560 | $db_prefix = $wpdb->prefix;
1561 | }
1562 | $content = '';
1563 | if (isset($_REQUEST['fid']) && $_REQUEST['fid'] != $tmp_fid) {
1564 |
1565 | $content = $content . forums_output_search_form($tmp_fid);
1566 | $content = $content . ' ';
1567 | $content = $content . forums_output_forum_nav($tmp_fid);
1568 | $content = $content . ' ';
1569 | $content = $content . forums_output_forum($tmp_fid);
1570 | $content = $content . ' ';
1571 | $content = $content . forums_output_forum_nav($tmp_fid);
1572 |
1573 | return $content;
1574 | }
1575 |
1576 | if ($user_ID == '' || $user_ID == '0'){
1577 | $content = $content . '' . __( 'New Topic', 'wpmudev_forums' ) . ' ';
1578 | $content = $content . '
' . __( 'You must be logged in...', 'wpmudev_forums' ) . ' ';
1579 | } else {
1580 | $content = $content . '' . __( 'New Topic', 'wpmudev_forums' ) . ' ';
1581 | if ($tmp_errors > 0){
1582 | if ($tmp_error_msg == ''){
1583 | $tmp_error_msg = __( 'You must fill in all required fields...', 'wpmudev_forums' );
1584 | }
1585 | $content = $content . '
' . $tmp_error_msg . ' ';
1586 |
1587 | }
1588 | $content = $content . '';
1589 | $content = $content . ' ';
1590 | $content = $content . ' ';
1591 | $content = $content . '';
1592 | $content = $content . '';
1606 | $content = $content . ' ';
1607 | $content = $content . '';
1608 | $content = $content . ' ';
1609 | $content = $content . '
';
1610 | $content = $content . ' ';
1611 | }
1612 | return $content;
1613 | }
1614 |
1615 | function forums_output_forum($tmp_fid) {
1616 | global $wpdb, $user_ID;
1617 | if ( !empty($wpdb->base_prefix) ) {
1618 | $db_prefix = $wpdb->base_prefix;
1619 | } else {
1620 | $db_prefix = $wpdb->prefix;
1621 | }
1622 |
1623 | $tmp_forum_color_header = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_header FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1624 | $tmp_forum_color_border = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_border FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1625 | $tmp_forum_border_size = $wpdb->get_var( $wpdb->prepare("SELECT forum_border_size FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1626 | $style = 'style="border-collapse: collapse;border-style: solid;border-width: ' . $tmp_forum_border_size . 'px;border-color: ' . $tmp_forum_color_border . ';padding-top:5px;padding-bottom:5px;"';
1627 |
1628 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_forum_ID = %d", $tmp_fid) );;
1629 | $content = '';
1630 | if ($tmp_topic_count > 0){
1631 | if ($user_ID == '' || $user_ID == '0'){
1632 | $content = '
1633 |
1634 | ' . __( 'TOPICS', 'wpmudev_forums' ) . '
1635 | ' . __( 'POSTS', 'wpmudev_forums' ) . '
1636 | ' . __( 'LATEST POSTER', 'wpmudev_forums' ) . '
1637 | ';
1638 | } else {
1639 | $content = '
1640 |
1641 | ' . __( 'TOPICS', 'wpmudev_forums' ) . ' (' . __( 'NEW', 'wpmudev_forums' ) . ' )
1642 | ' . __( 'POSTS', 'wpmudev_forums' ) . '
1643 | ' . __( 'LATEST POSTER', 'wpmudev_forums' ) . '
1644 | ';
1645 |
1646 | }
1647 | }
1648 | $content = $content . forums_output_topics($tmp_fid);
1649 | if ($tmp_topic_count > 0){
1650 | $content = $content . '
';
1651 | }
1652 | return $content;
1653 | }
1654 |
1655 | function forums_output_topics($tmp_fid) {
1656 | global $wpdb, $forums_topics_per_page, $user_ID, $wp_query;
1657 | if ( !empty($wpdb->base_prefix) ) {
1658 | $db_prefix = $wpdb->base_prefix;
1659 | } else {
1660 | $db_prefix = $wpdb->prefix;
1661 | }
1662 |
1663 | $tmp_forum_color_one = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_one FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1664 | $tmp_forum_color_two = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_two FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1665 | $tmp_forum_color_header = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_header FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1666 | $tmp_forum_color_border = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_border FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1667 | $tmp_forum_border_size = $wpdb->get_var( $wpdb->prepare("SELECT forum_border_size FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $tmp_fid, $wpdb->blogid) );
1668 | $style = 'style="border-collapse: collapse;border-style: solid;border-width: ' . $tmp_forum_border_size . 'px;border-color: #' . $tmp_forum_color_border . ';padding-top:5px;padding-bottom:5px; table-layout: fixed;word-wrap: break-word;"';
1669 |
1670 | //=========================================//
1671 | $tmp_current_page = isset($_GET['forum_page'])?(int)$_GET['forum_page']:1;
1672 | if ($tmp_current_page == 1){
1673 | $tmp_start = 0;
1674 | } else {
1675 | $tmp_math = $tmp_current_page - 1;
1676 | $tmp_math = $forums_topics_per_page * $tmp_math;
1677 | //$tmp_math = $tmp_math - 1;
1678 | $tmp_start = $tmp_math;
1679 | }
1680 | //=========================================//
1681 |
1682 | $query = "SELECT * FROM " . $db_prefix . "forums_topics WHERE topic_forum_ID = %d";
1683 | $query = $query . " ORDER BY topic_last_updated_stamp DESC";
1684 | $query = $query . " LIMIT %d, %d";
1685 | $tmp_topics = $wpdb->get_results( $wpdb->prepare($query, $tmp_fid, intval( $tmp_start ), intval( $forums_topics_per_page )), ARRAY_A );
1686 | $content = '';
1687 | $alt_color = isset($alt_color)?$alt_color:'';
1688 | if (count($tmp_topics) > 0){
1689 | $alt_color = ('alternate' == $alt_color) ? '' : 'alternate';
1690 | foreach ($tmp_topics as $tmp_topic){
1691 | //=========================================================//
1692 | if ($alt_color == 'alternate'){
1693 | $content = $content . '';
1694 | } else {
1695 | $content = $content . ' ';
1696 | }
1697 | if ($tmp_topic['topic_closed'] == 1){
1698 | $content = $content . '' . esc_html(stripslashes($tmp_topic['topic_title'])) . ' (' . __( 'Closed', 'wpmudev_forums' ) . ') ';
1699 | } else {
1700 | $content = $content . '' . esc_html(stripslashes($tmp_topic['topic_title'])) . ' ';
1701 | }
1702 | $content = $content . '' . (int)$tmp_topic['topic_posts'] . ' ';
1703 | $content = $content . '' . esc_html(forums_author_display_name($tmp_topic['topic_last_author'])) . ' ';
1704 | $content = $content . ' ';
1705 | $alt_color = ('alternate' == $alt_color) ? '' : 'alternate';
1706 | //=========================================================//
1707 | }
1708 | } else {
1709 | if ($user_ID == '' || $user_ID == '0'){
1710 | $content = $content . '';
1711 | $content = $content . '';
1712 | $content = $content . '' . __( 'No topics to display...', 'wpmudev_forums' ) . ' ';
1713 | $content = $content . ' ';
1714 | $content = $content . '
';
1715 | } else {
1716 | $content = $content . '';
1721 | }
1722 | }
1723 | return $content;
1724 | }
1725 |
1726 | function forums_topic_count_posts($tmp_tid) {
1727 | global $wpdb;
1728 | if ( !empty($wpdb->base_prefix) ) {
1729 | $db_prefix = $wpdb->base_prefix;
1730 | } else {
1731 | $db_prefix = $wpdb->prefix;
1732 | }
1733 |
1734 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_topic_ID = %d", $tmp_tid) );
1735 | $wpdb->update(
1736 | "{$db_prefix}forums_topics",
1737 | array(
1738 | 'topic_posts' => $tmp_post_count,
1739 | ),
1740 | array(
1741 | 'topic_ID' => $tmp_tid,
1742 | ),
1743 | array(
1744 | '%d'
1745 | ),
1746 | array(
1747 | '%d'
1748 | )
1749 | );
1750 | }
1751 | function forums_forum_count_posts($tmp_fid) {
1752 | global $wpdb;
1753 | if ( !empty($wpdb->base_prefix) ) {
1754 | $db_prefix = $wpdb->base_prefix;
1755 | } else {
1756 | $db_prefix = $wpdb->prefix;
1757 | }
1758 |
1759 | $tmp_post_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_posts WHERE post_forum_ID = %d", $tmp_fid) );
1760 | $wpdb->update(
1761 | "{$db_prefix}forums",
1762 | array(
1763 | 'forum_posts' => $tmp_post_count,
1764 | ),
1765 | array(
1766 | 'forum_ID' => $tmp_fid,
1767 | ),
1768 | array(
1769 | '%d'
1770 | ),
1771 | array(
1772 | '%d'
1773 | )
1774 | );
1775 | }
1776 | function forums_forum_count_topics($tmp_fid) {
1777 | global $wpdb;
1778 | if ( !empty($wpdb->base_prefix) ) {
1779 | $db_prefix = $wpdb->base_prefix;
1780 | } else {
1781 | $db_prefix = $wpdb->prefix;
1782 | }
1783 |
1784 | $tmp_topic_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums_topics WHERE topic_forum_ID = %d", $tmp_fid) );
1785 | $wpdb->update(
1786 | "{$db_prefix}forums",
1787 | array(
1788 | 'forum_topics' => $tmp_topic_count,
1789 | ),
1790 | array(
1791 | 'forum_ID' => $tmp_fid,
1792 | ),
1793 | array(
1794 | '%d'
1795 | ),
1796 | array(
1797 | '%d'
1798 | )
1799 | );
1800 | }
1801 |
1802 | //------------------------------------------------------------------------//
1803 | //---Page Output Functions------------------------------------------------//
1804 | //------------------------------------------------------------------------//
1805 | function forums_manage_options_output() {
1806 | global $wpdb, $forums_max_forums, $forums_enable_upgrades, $forums_topics_per_page, $forums_posts_per_page, $forums_upgrades_forums;
1807 |
1808 | $page = WP_NETWORK_ADMIN ? 'settings.php' : 'options-general.php';
1809 | $perms = WP_NETWORK_ADMIN ? 'manage_network_options' : 'manage_options';
1810 |
1811 | if(!current_user_can($perms)) {
1812 | echo "" . __( 'Nice Try...', 'wpmudev_forums' ) . "
"; //If accessed properly, this message doesn't appear.
1813 | return;
1814 | }
1815 | echo '';
1816 | $action = isset( $_GET[ 'action' ] ) ? $_GET[ 'action' ] : '';
1817 |
1818 | if ($action == 'update_settings') {
1819 | if (is_network_admin()) {
1820 | update_site_option('forums_topics_per_page', intval($_POST['forums_topics_per_page']));
1821 | update_site_option('forums_posts_per_page', intval($_POST['forums_posts_per_page']));
1822 | update_site_option('forums_max_forums', intval($_POST['forums_max_forums']));
1823 | if (function_exists('is_pro_site')) {
1824 | update_site_option('forums_upgrades_forums', intval($_POST['forums_upgrades_forums']));
1825 | update_site_option('forums_enable_upgrades', intval($_POST['forums_enable_upgrades']));
1826 | }
1827 | } else {
1828 | update_option('forums_topics_per_page', intval($_POST['forums_topics_per_page']));
1829 | update_option('forums_posts_per_page', intval($_POST['forums_posts_per_page']));
1830 | update_option('forums_max_forums', intval($_POST['forums_max_forums']));
1831 | if (function_exists('is_pro_site')) {
1832 | update_option('forums_upgrades_forums', intval($_POST['forums_upgrades_forums']));
1833 | update_option('forums_enable_upgrades', intval($_POST['forums_enable_upgrades']));
1834 | }
1835 | }
1836 | ?>
1837 |
1840 |
1845 |
1846 |
1847 |
1873 |
1874 |
1875 |
1876 |
1877 | ';
1879 | }
1880 |
1881 | function forums_manage_output() {
1882 | global $wpdb, $forums_max_forums, $forums_enable_upgrades;
1883 | if ( !empty($wpdb->base_prefix) ) {
1884 | $db_prefix = $wpdb->base_prefix;
1885 | } else {
1886 | $db_prefix = $wpdb->prefix;
1887 | }
1888 |
1889 | if(!current_user_can('manage_options')) {
1890 | echo "
" . __( 'Nice Try...', 'wpmudev_forums' ) . "
"; //If accessed properly, this message doesn't appear.
1891 | return;
1892 | }
1893 | echo '
';
1894 | $action = isset( $_GET[ 'action' ] ) ? $_GET[ 'action' ] : '';
1895 | switch( $action ) {
1896 | //---------------------------------------------------//
1897 | default:
1898 | $tmp_forums_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_blog_ID = %d", $wpdb->blogid) );
1899 | if ($tmp_forums_count < $forums_max_forums){
1900 | ?>
1901 |
( )
1902 |
1905 |
1906 |
' . $feature_message . '
';
1919 | } else {
1920 | ?>
1921 |
1922 | get_results( $wpdb->prepare($query, $wpdb->blogid), ARRAY_A );
1927 | echo "
1928 |
1929 |
1930 | ID
1931 | Name
1932 | Topics
1933 | Posts
1934 | Page Code
1935 | Actions
1936 |
1937 |
1938 |
1939 | ";
1940 | $class = isset($class)?$class:'';
1941 | if (count($tmp_forums) > 0){
1942 | $class = ('alternate' == $class) ? '' : 'alternate';
1943 | foreach ($tmp_forums as $tmp_forum){
1944 | //=========================================================//
1945 | echo "";
1946 | echo "" . (int)$tmp_forum['forum_ID'] . " ";
1947 | echo "" . esc_html(stripslashes($tmp_forum['forum_name'])) . " ";
1948 | echo "" . (int)$tmp_forum['forum_topics'] . " ";
1949 | echo "" . (int)$tmp_forum['forum_posts'] . " ";
1950 | $tmp_page_code = '[forum id="' . (int)$tmp_forum['forum_ID'] . '"]';
1951 | echo "" . $tmp_page_code . " ";
1952 | echo "" . __( 'Edit', 'wpmudev_forums' ) . " ";
1953 | echo "" . __( 'Remove', 'wpmudev_forums' ) . " ";
1954 | echo " ";
1955 | $class = ('alternate' == $class) ? '' : 'alternate';
1956 | //=========================================================//
1957 | }
1958 | }
1959 | ?>
1960 |
1961 | get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_blog_ID = %d", $wpdb->blogid) );
1967 | if ($tmp_forums_count < $forums_max_forums){
1968 | ?>
1969 |
1970 |
1971 |
2026 |
2027 |
2028 |
2029 |
2030 |
2037 |
2038 |
2039 |
2040 |
2094 |
2095 |
2096 |
2097 |
2098 | insert(
2101 | "{$db_prefix}forums",
2102 | array(
2103 | 'forum_blog_ID' => $wpdb->blogid,
2104 | 'forum_name' => $_POST['forum_name'],
2105 | 'forum_description' => $_POST['forum_description'],
2106 | 'forum_color_one' => $_POST['forum_color_one'],
2107 | 'forum_color_two' => $_POST['forum_color_two'],
2108 | 'forum_color_header' => $_POST['forum_color_header'],
2109 | 'forum_color_border' => $_POST['forum_color_border'],
2110 | 'forum_border_size' => $_POST['forum_border_size'],
2111 | ),
2112 | array(
2113 | '%d',
2114 | '%s',
2115 | '%s',
2116 | '%s',
2117 | '%s',
2118 | '%s',
2119 | '%s',
2120 | '%d'
2121 | )
2122 |
2123 | );
2124 | echo "
2125 |
2128 | ";
2129 | exit();
2130 | }
2131 | break;
2132 | //---------------------------------------------------//
2133 | case "edit_forum":
2134 | $tmp_forum_name = $wpdb->get_var( $wpdb->prepare("SELECT forum_name FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_GET['fid'], $wpdb->blogid) );
2135 | $tmp_forum_description = $wpdb->get_var( $wpdb->prepare("SELECT forum_description FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_GET['fid'], $wpdb->blogid) );
2136 | $tmp_forum_color_one = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_one FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_GET['fid'], $wpdb->blogid) );
2137 | $tmp_forum_color_two = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_two FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_GET['fid'], $wpdb->blogid) );
2138 | $tmp_forum_color_header = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_header FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_GET['fid'], $wpdb->blogid) );
2139 | $tmp_forum_color_border = $wpdb->get_var( $wpdb->prepare("SELECT forum_color_border FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_GET['fid'], $wpdb->blogid) );
2140 | $tmp_forum_border_size = $wpdb->get_var( $wpdb->prepare("SELECT forum_border_size FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_GET['fid'], $wpdb->blogid) );
2141 | ?>
2142 |
2143 |
2144 |
2145 |
2199 |
2200 |
2201 |
2202 |
2203 | get_var( $wpdb->prepare("SELECT COUNT(*) FROM " . $db_prefix . "forums WHERE forum_ID = %d AND forum_blog_ID = %d", $_POST['fid'], $wpdb->blogid) );
2208 | if ($tmp_forum_count > 0){
2209 | if ($_POST['forum_name'] == ''){
2210 | ?>
2211 |
2212 |
2213 |
2214 |
2215 |
2269 |
2270 |
2271 |
2272 |
2273 | update(
2276 | "{$db_prefix}forums",
2277 | array(
2278 | 'forum_name' => $_POST['forum_name'],
2279 | 'forum_description' => $_POST['forum_description'],
2280 | 'forum_color_one' => $_POST['forum_color_one'],
2281 | 'forum_color_two' => $_POST['forum_color_two'],
2282 | 'forum_color_header' => $_POST['forum_color_header'],
2283 | 'forum_color_border' => $_POST['forum_color_border'],
2284 | 'forum_border_size' => $_POST['forum_border_size'],
2285 | ),
2286 | array(
2287 | 'forum_ID' => $_POST['fid'],
2288 | 'forum_blog_ID' => $wpdb->blogid
2289 | ),
2290 | array(
2291 | '%s',
2292 | '%s',
2293 | '%s',
2294 | '%s',
2295 | '%s',
2296 | '%s',
2297 | '%d'
2298 | ),
2299 | array(
2300 | '%d',
2301 | '%d'
2302 | )
2303 | );
2304 | echo "
2305 |
2308 | ";
2309 | exit();
2310 | }
2311 | }
2312 | break;
2313 | //---------------------------------------------------//
2314 | case "delete_forum":
2315 | ?>
2316 |
2317 |
2318 |
2319 |
2320 |
2321 |
2322 |
2323 |
2324 |
2325 |
2332 | window.location='edit.php?page=forums';
2333 |
2334 | ";
2335 | } else {
2336 | forums_delete_forum((int)$_POST['fid']);
2337 | echo "
2338 |
2341 | ";
2342 | }
2343 | exit();
2344 | break;
2345 | //---------------------------------------------------//
2346 | case "temp5":
2347 | break;
2348 | //---------------------------------------------------//
2349 | }
2350 | echo '
';
2351 | }
2352 |
2353 | //------------------------------------------------------------------------//
2354 | //---Support Functions----------------------------------------------------//
2355 | //------------------------------------------------------------------------//
2356 |
2357 | function forums_save_post_content($post_content){
2358 | $post_content = strip_tags($post_content, '
');
2359 | return $post_content;
2360 | }
2361 |
2362 | function forums_display_post_content($post_content){
2363 | $post_content = stripslashes($post_content);
2364 | //$post_content = str_replace(' ', "\n", $post_content);
2365 |
2366 | $reg_exUrl = "/\"{0,1}(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?\"{0,1}/";
2367 | $urls = array();
2368 |
2369 | if(($post_content) != "\n" && ($post_content) != " " && ($post_content) != "") {
2370 | if(preg_match_all($reg_exUrl, $post_content, $urls) && isset($urls[0]) && count($urls[0]) > 0) {
2371 | foreach ($urls[0] as $url) {
2372 | if (preg_match("/^\"|\"$/", $url) > 0) {
2373 | continue;
2374 | }
2375 | $post_content = str_replace($url, ''.$url.' ', $post_content);
2376 | }
2377 | }
2378 | }
2379 |
2380 | $post_content = nl2br($post_content);
2381 | return $post_content;
2382 | }
2383 |
2384 | function forums_author_display_name($author_ID){
2385 | global $wpdb;
2386 | if ( !empty($wpdb->base_prefix) ) {
2387 | $db_prefix = $wpdb->base_prefix;
2388 | } else {
2389 | $db_prefix = $wpdb->prefix;
2390 | }
2391 | $tmp_user = get_userdata( $author_ID );
2392 | return $tmp_user->display_name;
2393 | }
2394 |
2395 | function forums_roundup($value, $dp){
2396 | return ceil($value*pow(10, $dp))/pow(10, $dp);
2397 | }
2398 |
2399 | function forum_get_details($topic_id) {
2400 | global $wpdb;
2401 |
2402 | if ( !empty($wpdb->base_prefix) ) {
2403 | $db_prefix = $wpdb->base_prefix;
2404 | } else {
2405 | $db_prefix = $wpdb->prefix;
2406 | }
2407 | $forum_res = $wpdb->get_row( $wpdb->prepare("SELECT * FROM " . $db_prefix . "forums_topics WHERE topic_ID = %d", $topic_id), ARRAY_A);
2408 | $forum = array();
2409 | if ($forum_res) {
2410 | $forum['topic_title'] = stripslashes($forum_res['topic_title']);
2411 | $forum['topic_last_updated_stamp'] = stripslashes($forum_res['topic_last_updated_stamp']);
2412 | $forum['topic_last_author'] = stripslashes($forum_res['topic_last_author']);
2413 | $forum['topic_closed'] = stripslashes($forum_res['topic_closed']);
2414 | }
2415 |
2416 | return $forum;
2417 | }
2418 |
2419 | if ( !function_exists( 'wdp_un_check' ) ) {
2420 | add_action( 'admin_notices', 'wdp_un_check', 5 );
2421 | add_action( 'network_admin_notices', 'wdp_un_check', 5 );
2422 |
2423 | function wdp_un_check() {
2424 | if ( !class_exists( 'WPMUDEV_Update_Notifications' ) && current_user_can( 'edit_users' ) )
2425 | echo '';
2426 | }
2427 | }
2428 |
--------------------------------------------------------------------------------