diff --git a/newznab/build/newznab.xml b/newznab/build/newznab.xml index 5fd4ce115..e89a4250f 100644 --- a/newznab/build/newznab.xml +++ b/newznab/build/newznab.xml @@ -2,8 +2,8 @@ - 122 - 122 + 125 + 125 0.4.1 diff --git a/newznab/controllers/Backfill.php b/newznab/controllers/Backfill.php index d188ddd1b..1e7065ee7 100644 --- a/newznab/controllers/Backfill.php +++ b/newznab/controllers/Backfill.php @@ -77,6 +77,12 @@ class Backfill */ protected $_safePartRepair; + /** + * Should we disable the group if we have backfilled far enough? + * @var bool + */ + protected $_disableBackfillGroup; + /** * Constructor. * @@ -114,6 +120,7 @@ class Backfill $this->_safeBackFillDate = ($this->pdo->getSetting('safebackfilldate') != '') ? (string)$this->pdo->getSetting('safebackfilldate') : '2008-08-14'; $this->_safePartRepair = ($this->pdo->getSetting('safepartrepair') == 1 ? 'update' : 'backfill'); $this->_tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 1 ? true : false); + $this->_disableBackfillGroup = ($this->pdo->getSetting('disablebackfillgroup') == 1 ? true : false); } /** @@ -268,11 +275,23 @@ class Backfill $dMessage = "We have hit the maximum we can backfill for " . $groupName . - ", skipping it, consider disabling backfill on it."; + ($this->_disableBackfillGroup ? ", disabling backfill on it." : + ", skipping it, consider disabling backfill on it."); if ($this->_debug) { $this->_debugging->log('Backfill', "backfillGroup", $dMessage, \Logger::LOG_NOTICE); } + if ($this->_disableBackfillGroup) { + $this->pdo->queryExec( + sprintf(' + UPDATE groups + SET backfill = 0 + WHERE id = %d', + $groupArr['id'] + ) + ); + } + if ($this->_echoCLI) { $this->pdo->log->doEcho($this->pdo->log->notice($dMessage), true); } diff --git a/newznab/controllers/Users.php b/newznab/controllers/Users.php index da5f9feb2..870ac9edb 100644 --- a/newznab/controllers/Users.php +++ b/newznab/controllers/Users.php @@ -18,6 +18,7 @@ class Users const ROLE_USER = 1; const ROLE_ADMIN = 2; const ROLE_DISABLED = 3; + const ROLE_MODERATOR = 4; const DEFAULT_INVITES = 1; const DEFAULT_INVITE_EXPIRY_DAYS = 7; @@ -434,9 +435,7 @@ class Users public function isDisabled($username) { - $role = $this->pdo->queryOneRow(sprintf("select role as role from users where username = %s ", $this->pdo->escapeString($username))); - - return ($role["role"] == Users::ROLE_DISABLED); + return $this->roleCheck(self::ROLE_DISABLED, $username); } public function isValidUrl($url) @@ -986,4 +985,53 @@ class Users { return $this->pdo->queryInsert(sprintf("delete from userdownloads where releaseid = %d", $releaseID)); } + + /** + * Checks if a user is a specific role. + * + * @notes Uses type of $user to denote identifier. if string: username, if int: userid + * @param int $roleID + * @param string|int $user + * @return bool + */ + public function roleCheck($roleID, $user) { + + if (is_string($user) && strlen($user) > 0) { + $user = $this->pdo->escapeString($user); + $querySuffix = "username = '$user'"; + } elseif (is_int($user) && $user >= 0) { + $querySuffix = "id = $user"; + } else { + return false; + } + + $result = $this->pdo->queryOneRow( + sprintf( + "SELECT role FROM users WHERE %s", + $querySuffix + ) + ); + + return ((integer)$result['role'] == (integer) $roleID) ? true : false; + } + + /** + * Wrapper for roleCheck specifically for Admins. + * + * @param int $userID + * @return bool + */ + public function isAdmin($userID) { + return $this->roleCheck(self::ROLE_ADMIN, (integer) $userID); + } + + /** + * Wrapper for roleCheck specifically for Moderators. + * + * @param int $userId + * @return bool + */ + public function isModerator($userId) { + return $this->roleCheck(self::ROLE_MODERATOR, (integer) $userId); + } } \ No newline at end of file diff --git a/resources/db/patches/0121~site.sql b/resources/db/patches/0121~site.sql index b2a404fdd..88caf7d12 100644 --- a/resources/db/patches/0121~site.sql +++ b/resources/db/patches/0121~site.sql @@ -1,2 +1,9 @@ -INSERT INTO `site` (`setting`, `value`) VALUES ('processthumbnails', '0'); -UPDATE `site` SET `value` = '121' WHERE `setting` = 'sqlpatch'; \ No newline at end of file +INSERT IGNORE INTO settings (name, value, hint, setting) +VALUES ( + 'processthumbnails', 0, + 'Whether to attempt to process a video thumbnail image. You must have ffmpeg for this.', + 'processthumbnails' +); + +UPDATE site SET value = 1 +WHERE setting = 'processthumbnails' AND (SELECT * FROM (SELECT value FROM site WHERE setting = 'ffmpegpath') s) != ''; \ No newline at end of file diff --git a/resources/db/patches/0123~settings.sql b/resources/db/patches/0123~settings.sql new file mode 100644 index 000000000..86fe9c1df --- /dev/null +++ b/resources/db/patches/0123~settings.sql @@ -0,0 +1,6 @@ +INSERT IGNORE INTO settings (name, value, hint, setting) +VALUES ( + 'disablebackfillgroup', 0, + 'Whether to disable backfill on a group if the target date has been reached.', + 'disablebackfillgroup' +); \ No newline at end of file diff --git a/resources/db/patches/0124~settings.sql b/resources/db/patches/0124~settings.sql new file mode 100644 index 000000000..a05edfd59 --- /dev/null +++ b/resources/db/patches/0124~settings.sql @@ -0,0 +1 @@ +INSERT INTO settings (section, subsection, name, value, hint, setting) VALUES ('', '', 'privateprofiles', 1, 'Hide profiles from other users (admin/mod can still access).', 'privateprofiles'); \ No newline at end of file diff --git a/resources/db/patches/0125~settings.sql b/resources/db/patches/0125~settings.sql new file mode 100644 index 000000000..4bd4f1750 --- /dev/null +++ b/resources/db/patches/0125~settings.sql @@ -0,0 +1,9 @@ +INSERT IGNORE INTO settings (name, value, hint, setting) +VALUES ( + 'processthumbnails', 0, + 'Whether to attempt to process a video thumbnail image. You must have ffmpeg for this.', + 'processthumbnails' +); + +UPDATE settings SET value = 1 +WHERE setting = 'processthumbnails' AND (SELECT * FROM (SELECT value FROM settings WHERE setting = 'ffmpegpath') s) != ''; \ No newline at end of file diff --git a/www/pages/profile.php b/www/pages/profile.php index 3f1cb512a..a14804e2a 100644 --- a/www/pages/profile.php +++ b/www/pages/profile.php @@ -19,6 +19,29 @@ elseif (isset($_GET["name"])) else $userid = $users->currentUserId(); +$privileged = ($users->isAdmin($userid) || $users->isModerator($userid)) ? true : false; +$privateProfiles = ($page->settings->getSetting('privateprofiles') == 1) ? true : false; +$publicView = false; + +if (!$privateProfiles || $privileged) { + + $altID = (isset($_GET['id']) && $_GET['id'] >= 0) ? (int) $_GET['id'] : false; + $altUsername = (isset($_GET['name']) && strlen($_GET['name']) > 0) ? $_GET['name'] : false; + + // If both 'id' and 'name' are specified, 'id' should take precedence. + if ($altID === false && $altUsername !== false) { + $user = $users->getByUsername($altUsername); + if ($user) { + $altID = $user['id']; + } + } else if ($altID !== false) { + $userid = $altID; + $publicView = true; + } +} + + + $data = $users->getById($userid); if (!$data) $page->show404(); @@ -31,6 +54,9 @@ $page->smarty->assign('apihits', $users->getApiRequests($userid)); $page->smarty->assign('grabstoday', $users->getDownloadRequests($userid)); $page->smarty->assign('userinvitedby',$invitedby); $page->smarty->assign('user',$data); +$page->smarty->assign('privateprofiles', $privateProfiles); +$page->smarty->assign('publicview', $publicView); +$page->smarty->assign('privileged', $privileged); $commentcount = $rc->getCommentCountForUser($userid); $offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; diff --git a/www/templates/nntmux/views/admin/site-edit.tpl b/www/templates/nntmux/views/admin/site-edit.tpl index 2a9dfe256..1ec47f9d9 100644 --- a/www/templates/nntmux/views/admin/site-edit.tpl +++ b/www/templates/nntmux/views/admin/site-edit.tpl @@ -619,6 +619,15 @@ + + + + {html_radios id="disablebackfillgroup" name='disablebackfillgroup' values=$yesno_ids output=$yesno_names selected=$fsite->disablebackfillgroup separator='
'} +
Whether to disable a group automatically during backfill if the target date has been reached.
+ + + + @@ -1532,6 +1541,15 @@ + + + + + {html_radios id="privateprofiles" name='privateprofiles' values=$yesno_ids output=$yesno_names selected=$fsite->privateprofiles separator='
'} +
Should we disallow users from accessing profiles other than their own? (regardless of this setting admin/mod can access).
+ + + : diff --git a/www/templates/nntmux/views/frontend/forum.tpl b/www/templates/nntmux/views/frontend/forum.tpl index 57fbad568..81e8372db 100644 --- a/www/templates/nntmux/views/frontend/forum.tpl +++ b/www/templates/nntmux/views/frontend/forum.tpl @@ -25,10 +25,12 @@ {$result.message|escape:"htmlall"|truncate:200:'...':false:false} - - {$result.username} -
- on {$result.createddate|date_format}
({$result.createddate|timeago})
+ {if !$privateprofiles || $isadmin || $ismod} + {$result.username}
+ {else} + {$result.username} + {/if} + {$result.createddate|date_format}
({$result.createddate|timeago})
{$result.updateddate|date_format}
({$result.updateddate|timeago})
diff --git a/www/templates/nntmux/views/frontend/forumpost.tpl b/www/templates/nntmux/views/frontend/forumpost.tpl index 97012692c..8382fc526 100644 --- a/www/templates/nntmux/views/frontend/forumpost.tpl +++ b/www/templates/nntmux/views/frontend/forumpost.tpl @@ -17,10 +17,11 @@ {foreach from=$results item=result name=result} - {if $result.isadmin == 1}{/if} - {$result.username} - {if $result.isadmin == 1}{/if} -
+ {if !$privateprofiles || $isadmin || $ismod} + {$result.username} + {else} + {$result.username} + {/if} on {$result.createddate|date_format}
({$result.createddate|timeago})
{if $userdata.role==2}
diff --git a/www/templates/nntmux/views/frontend/profile.tpl b/www/templates/nntmux/views/frontend/profile.tpl index 8afd37fb1..c83c16aa3 100644 --- a/www/templates/nntmux/views/frontend/profile.tpl +++ b/www/templates/nntmux/views/frontend/profile.tpl @@ -3,14 +3,14 @@ - {if $user.id==$userdata.id || $userdata.role==2}{/if} + {if $isadmin || !$publicview}{/if} {if $userdata.role==2}{/if} - {if $user.id==$userdata.id || $userdata.role==2}{/if} - {if $user.id==$userdata.id || $userdata.role==2} + {if $isadmin || !$publicview}{/if} + {if $isadmin || !$publicview} {/if} @@ -37,8 +37,17 @@ {/if} {if $userinvitedby && $userinvitedby.username != ""} - - {/if} + + + + {/if} - {if $user.id==$userdata.id || $userdata.role==2}{/if} + {if $isadmin || !$publicview}{/if} {if $page->site->sabintegrationtype == 2 && $user.id==$userdata.id}
Username:{$user.username|escape:"htmlall"}
Email:{$user.email}
Email:{$user.email}
Registered:{$user.createddate|date_format} ({$user.createddate|timeago} ago)
Last Login:{$user.lastlogin|date_format} ({$user.lastlogin|timeago} ago)
Role:{$user.rolename}
Theme:{$user.style}
Notes:{$user.notes|escape:htmlall}{if $user.notes|count_characters > 0}
{/if}Add/Edit
Site Api/Rss Key:{$user.rsstoken}
Site Api/Rss Key:{$user.rsstoken}
API Hits Today:{$apihits.num} {if $userdata.role==2 && $apihits.num > 0}Reset{/if}
Grabs Today:{$grabstoday.num} {if $grabstoday.num >= $user.downloadrequests}  (Next DL in {($grabstoday.nextdl/3600)|intval}h {($grabstoday.nextdl/60) % 60}m){/if}{if $userdata.role==2 && $grabstoday.num > 0}Reset{/if}
Invited By:{$userinvitedby.username}
Invited By: + {if $privileged || !$privateprofiles} + {$userinvitedby.username} + {else} + {$userinvitedby.username} + {/if} + +
UI Preferences: @@ -50,7 +59,7 @@ {if $user.bookview == "1"}View book covers{else}View standard book category{/if}
Excluded Categories:{$exccats|replace:",":"
"}
Excluded Categories:{$exccats|replace:",":"
"}
SABnzbd Integration: diff --git a/www/templates/nntmux/views/frontend/viewnzb.tpl b/www/templates/nntmux/views/frontend/viewnzb.tpl index 4eb247456..732f0c69a 100644 --- a/www/templates/nntmux/views/frontend/viewnzb.tpl +++ b/www/templates/nntmux/views/frontend/viewnzb.tpl @@ -573,14 +573,10 @@ {foreach from=$comments|@array_reverse:true item=comment}
- {if $comment.role == -1} - {$comment.username}{if $isadmin} @{$comment.rolename}{/if} - {elseif $comment.role == 2} - {$comment.username} - {elseif $comment.role == 4} - {$comment.username} - {else} + {if !$privateprofiles || $isadmin || $ismod} {$comment.username} + {else} + {$comment.username} {/if}
{$comment.createddate|daysago}