Skip to content

Commit

Permalink
Version 1.7
Browse files Browse the repository at this point in the history
    * Fix installation issues on MySQL 5.7+
  • Loading branch information
lukasamd committed Feb 20, 2017
1 parent 64c7957 commit 333a99b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 39 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.7
* Fix installation issues on MySQL 5.7+



Version 1.6
* Cache template
* Updated functions_indicators.php
Expand Down
38 changes: 28 additions & 10 deletions root/inc/plugins/unreadPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function unreadPosts_info() {
'website' => 'https://tkacz.pro',
'author' => 'Lukasz Tkacz',
'authorsite' => 'https://tkacz.pro',
'version' => '1.6',
'version' => '1.7',
'guid' => '',
'compatibility' => '18*',
'codename' => 'view_unread_posts',
Expand Down Expand Up @@ -103,7 +103,8 @@ function unreadPosts_deactivate() {
* Plugin Class
*
*/
class unreadPosts {
class unreadPosts
{
// SQL Where Statement
private static $where = '';

Expand All @@ -121,7 +122,8 @@ class unreadPosts {

// SQL Query Limit
private static $limit = 0;



/**
* Add all needed hooks
*
Expand Down Expand Up @@ -162,6 +164,7 @@ public static function addHooks()
}
}


/**
* Redirect to first unread post in topic
*
Expand Down Expand Up @@ -221,7 +224,8 @@ public static function actionNewpost()
exit;
}
}



/**
* Action to mark thread read by xmlhttp
*
Expand All @@ -241,6 +245,7 @@ public static function xmlhttpMarkThread()
}
}


/**
* Action for ajax request for upadate counter
*
Expand Down Expand Up @@ -314,6 +319,7 @@ static function xmlhttpGetUnreads()
echo $content;
}


/**
* Get post dateline and show indicator if enabled
*
Expand Down Expand Up @@ -361,6 +367,7 @@ public static function analyzePostbit(&$post)
}
}


/**
* Compare last post time with thread read time and update its.
*
Expand All @@ -375,6 +382,7 @@ public static function markShowthreadLinear()
}
}


/**
* Insert plugin read data for new reply / new thread action.
*
Expand All @@ -390,6 +398,7 @@ public static function newThreadOrReplyMark() {
}
}


/**
* Update user lastmark field after mark all forums read and registration.
*
Expand All @@ -412,6 +421,7 @@ public static function updateLastmark()
}
}


/**
* Search for threads ids with unreads posts
*
Expand Down Expand Up @@ -471,7 +481,8 @@ public static function doSearch()
$db->insert_query("searchlog", $searcharray);
redirect("search.php?action=results&sid={$sid}", $lang->redirect_searchresults);
}



/**
* Add thread start date to search results
*
Expand All @@ -494,6 +505,7 @@ public static function modifySearchResultThread() {
}
}


/**
* Change links action from lastpost to unread and display link to search unreads
*
Expand Down Expand Up @@ -591,7 +603,8 @@ public static function modifyOutput(&$content)
$content = str_replace('?action=unreads', "?action=unreads&fid=" . self::$fid, $content);
}
}



/**
* Get actual thread read plugin data
*
Expand All @@ -611,7 +624,8 @@ public static function getReadTime()

self::$readTime = max($time_thread, $time_forum, $mybb->user['lastmark']);
}



/**
* Helper function to decide if unread counter is allowed on current page
*
Expand All @@ -637,7 +651,8 @@ private static function isPageCounterAllowed()
}
return false;
}



/**
* Prepare WHERE statement for unread posts search query
*
Expand Down Expand Up @@ -707,7 +722,8 @@ private static function buildSQLWhere()
self::$where .= " AND t.fid NOT IN ($inactiveforums)";
}
}



/**
* Prepare LIMIT for search query
*
Expand All @@ -727,6 +743,7 @@ private static function buildSQLLimit() {
return $limit + 1;
}


/**
* Helper function to get variable from config
*
Expand All @@ -738,7 +755,8 @@ public static function getConfig($name) {

return $mybb->settings["unreadPosts{$name}"];
}



/**
* Say thanks to plugin author - paste link to author website.
* Please don't remove this code if you didn't make donate
Expand Down
24 changes: 7 additions & 17 deletions root/inc/plugins/unreadPosts.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
* Plugin Installator Class
*
*/
class unreadPostsInstaller {
class unreadPostsInstaller
{

public static function install() {
public static function install()
{
global $db, $lang, $mybb;
self::uninstall();

Expand All @@ -39,7 +41,6 @@ public static function install() {
$disporder = 1;

$settings_group = array(
'gid' => 'NULL',
'name' => 'unreadPosts',
'title' => $db->escape_string($lang->unreadPostsName),
'description' => $db->escape_string($lang->unreadPostsGroupDesc),
Expand All @@ -50,7 +51,6 @@ public static function install() {
$gid = (int) $db->insert_id();

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsExceptions',
'title' => $db->escape_string($lang->unreadPostsExceptions),
'description' => $db->escape_string($lang->unreadPostsExceptionsDesc),
Expand All @@ -62,7 +62,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsStatusActionUnread',
'title' => $db->escape_string($lang->unreadPostsStatusActionUnread),
'description' => $db->escape_string($lang->unreadPostsStatusActionUnreadDesc),
Expand All @@ -74,7 +73,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsStatusPostbitMark',
'title' => $db->escape_string($lang->unreadPostsStatusPostbitMark),
'description' => $db->escape_string($lang->unreadPostsStatusPostbitMarkDesc),
Expand All @@ -86,7 +84,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsStatusCounter',
'title' => $db->escape_string($lang->unreadPostsStatusCounter),
'description' => $db->escape_string($lang->unreadPostsStatusCounterDesc),
Expand All @@ -98,7 +95,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsCounterRefresh',
'title' => $db->escape_string($lang->unreadPostsCounterRefresh),
'description' => $db->escape_string($lang->unreadPostsCounterRefreshDesc),
Expand All @@ -110,7 +106,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsCounterRefreshInterval',
'title' => $db->escape_string($lang->unreadPostsCounterRefreshInterval),
'description' => $db->escape_string($lang->unreadPostsCounterRefreshIntervalDesc),
Expand All @@ -122,7 +117,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsLimit',
'title' => $db->escape_string($lang->unreadPostsLimit),
'description' => $db->escape_string($lang->unreadPostsLimitDesc),
Expand All @@ -134,7 +128,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsStatusMoved',
'title' => $db->escape_string($lang->unreadPostsStatusMoved),
'description' => $db->escape_string($lang->unreadPostsStatusMovedDesc),
Expand All @@ -147,7 +140,6 @@ public static function install() {


$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsStatusCounterHide',
'title' => $db->escape_string($lang->unreadPostsStatusCounterHide),
'description' => $db->escape_string($lang->unreadPostsStatusCounterHideDesc),
Expand All @@ -159,7 +151,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsCounterPages',
'title' => $db->escape_string($lang->unreadPostsCounterPages),
'description' => $db->escape_string($lang->unreadPostsCounterPagesDesc),
Expand All @@ -171,7 +162,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsMarkAllReadLink',
'title' => $db->escape_string($lang->unreadPostsMarkAllReadLink),
'description' => $db->escape_string($lang->unreadPostsMarkAllReadLinkDesc),
Expand All @@ -183,7 +173,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsThreadStartDate',
'title' => $db->escape_string($lang->unreadPostsThreadStartDate),
'description' => $db->escape_string($lang->unreadPostsThreadStartDateDesc),
Expand All @@ -195,7 +184,6 @@ public static function install() {
$db->insert_query('settings', $setting);

$setting = array(
'sid' => 'NULL',
'name' => 'unreadPostsFidMode',
'title' => $db->escape_string($lang->unreadPostsFidMode),
'description' => $db->escape_string($lang->unreadPostsFidModeDesc),
Expand All @@ -217,7 +205,9 @@ public static function install() {
rebuild_settings();
}

public static function uninstall() {

public static function uninstall()
{
global $db;

$result = $db->simple_select('settinggroups', 'gid', "name = 'unreadPosts'");
Expand Down
Loading

0 comments on commit 333a99b

Please sign in to comment.