mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-02 19:28:55 +00:00
Add user selectable template support.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE users ADD COLUMN style VARCHAR(255) NULL DEFAULT NULL;
|
||||
/* Add a column to pick a site theme */
|
||||
|
||||
UPDATE `tmux` SET `value` = '139' WHERE `setting` = 'sqlpatch';
|
||||
@@ -66,13 +66,16 @@ class BasePage
|
||||
$this->smarty = new Smarty();
|
||||
$this->captcha = new Captcha(['Settings' => $this->settings]);
|
||||
|
||||
if ($this->site->style != "default")
|
||||
$this->smarty->addTemplateDir(WWW_DIR.'templates/'.$this->site->style.'/views/frontend', 'style_frontend');
|
||||
$this->smarty->addTemplateDir(WWW_DIR.'templates/default/views/frontend', 'frontend');
|
||||
$this->smarty->setTemplateDir(
|
||||
array(
|
||||
'user_frontend' => NN_WWW . 'templates/' . $this->site->style . '/views/frontend',
|
||||
'frontend' => NN_WWW . 'templates/default/views/frontend'
|
||||
)
|
||||
);
|
||||
$this->smarty->setCompileDir(SMARTY_DIR.'templates_c'.DIRECTORY_SEPARATOR);
|
||||
$this->smarty->setConfigDir(SMARTY_DIR.'configs'.DIRECTORY_SEPARATOR);
|
||||
$this->smarty->setCacheDir(SMARTY_DIR.'cache'.DIRECTORY_SEPARATOR);
|
||||
$this->smarty->error_reporting = (E_ALL - E_NOTICE);
|
||||
$this->smarty->error_reporting = ((NN_DEBUG ? E_ALL : E_ALL - E_NOTICE));
|
||||
$this->secure_connection = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ;
|
||||
|
||||
if (file_exists(WWW_DIR.'templates/'.$this->site->style.'/theme.php'))
|
||||
@@ -109,6 +112,16 @@ class BasePage
|
||||
|
||||
$this->userdata["categoryexclusions"] = $this->users->getCategoryExclusion($this->users->currentUserId());
|
||||
|
||||
// Change the theme to user's selected theme if they selected one, else use the admin one.
|
||||
if (isset($this->userdata['style']) && $this->userdata['style'] !== 'None') {
|
||||
$this->smarty->setTemplateDir(
|
||||
array(
|
||||
'user_frontend' => NN_WWW . 'templates/' . $this->userdata['style'] . '/views/frontend',
|
||||
'frontend' => NN_WWW . 'templates/default/views/frontend'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//update lastlogin every 15 mins
|
||||
if (strtotime($this->userdata['now'])-900 > strtotime($this->userdata['lastlogin']))
|
||||
$this->users->updateSiteAccessed($this->userdata['id']);
|
||||
|
||||
@@ -47,7 +47,7 @@ class Users
|
||||
];
|
||||
$options += $defaults;
|
||||
|
||||
$this->pdo = ($options['Settings'] instanceof newznab\db\DB ? $options['Settings'] : new newznab\db\DB());
|
||||
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
|
||||
|
||||
$this->password_hash_cost = (defined('NN_PASSWORD_HASH_COST') ? NN_PASSWORD_HASH_COST : 11);
|
||||
}
|
||||
@@ -93,6 +93,19 @@ class Users
|
||||
return $db->query("select * from users");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the users selected theme.
|
||||
*
|
||||
* @param string|int $userID The id of the user.
|
||||
*
|
||||
* @return array|bool The users selected theme.
|
||||
*/
|
||||
public function getStyle($userID)
|
||||
{
|
||||
$row = $this->pdo->queryOneRow(sprintf("SELECT style FROM users WHERE id = %d", $userID));
|
||||
return ($row === false ? 'None' : $row['style']);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$db = new DB();
|
||||
@@ -218,7 +231,7 @@ class Users
|
||||
return $res["num"];
|
||||
}
|
||||
|
||||
public function update($id, $uname, $email, $grabs, $role, $notes, $invites, $movieview, $musicview, $gameview, $xxxview, $consoleview, $bookview, $queueType = '', $nzbgetURL = '', $nzbgetUsername = '', $nzbgetPassword = '', $saburl = '', $sabapikey = '', $sabpriority = '', $sabapikeytype = '', $nzbvortexServerUrl = false, $nzbvortexApiKey = false, $cp_url = false, $cp_api = false)
|
||||
public function update($id, $uname, $email, $grabs, $role, $notes, $invites, $movieview, $musicview, $gameview, $xxxview, $consoleview, $bookview, $queueType = '', $nzbgetURL = '', $nzbgetUsername = '', $nzbgetPassword = '', $saburl = '', $sabapikey = '', $sabpriority = '', $sabapikeytype = '', $nzbvortexServerUrl = false, $nzbvortexApiKey = false, $cp_url = false, $cp_api = false, $style = 'None')
|
||||
{
|
||||
$db = new DB();
|
||||
|
||||
@@ -255,6 +268,7 @@ class Users
|
||||
$sql[] = sprintf('xxxview = %d', $xxxview);
|
||||
$sql[] = sprintf('consoleview = %d', $consoleview);
|
||||
$sql[] = sprintf('bookview = %d', $bookview);
|
||||
$sql[] = sprintf('style = %s', $this->pdo->escapeString($style));
|
||||
|
||||
if ($queueType !== '') {
|
||||
$sql[] = sprintf('queuetype = %d', $queueType);
|
||||
|
||||
@@ -115,6 +115,8 @@ $page->smarty->assign('lookuptv_names', ['Disabled', 'Lookup All TV', 'Lookup Re
|
||||
$page->smarty->assign('lookup_reqids_ids', array(0,1,2));
|
||||
$page->smarty->assign('lookup_reqids_names', array('Disabled', 'Lookup Request IDs', 'Lookup Request IDs Threaded'));
|
||||
|
||||
$page->smarty->assign('coversPath', NN_COVERS);
|
||||
|
||||
// return a list of audiobooks, mags, ebooks, technical and foreign books
|
||||
$result = $page->settings->query("SELECT id, title FROM category WHERE id in (3030, 7010, 7020, 7040, 7060)");
|
||||
|
||||
@@ -139,11 +141,13 @@ $books_selected = explode(",", $page->site->book_reqids);
|
||||
$books_selected = array_map(create_function('$value', 'return (int)$value;'), $books_selected);
|
||||
$page->smarty->assign('book_reqids_selected', $books_selected);
|
||||
|
||||
$themelist = array();
|
||||
$themes = scandir(WWW_DIR."/templates");
|
||||
foreach ($themes as $theme)
|
||||
if (strpos($theme, ".") === false && is_dir(WWW_DIR."/templates/".$theme))
|
||||
$themelist = [];
|
||||
$themes = scandir(NN_WWW . "/templates");
|
||||
foreach ($themes as $theme) {
|
||||
if (strpos($theme, ".") === false && is_dir(NN_WWW . "/templates/" . $theme)) {
|
||||
$themelist[] = $theme;
|
||||
}
|
||||
}
|
||||
|
||||
$page->smarty->assign('themelist', $themelist);
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ switch ($action) {
|
||||
(isset($_POST['nzbvortex_server_url']) ? $_POST['nzbvortex_server_url'] : false),
|
||||
(isset($_POST['nzbvortex_api_key']) ? $_POST['nzbvortex_api_key'] : false),
|
||||
$_POST['cp_url'],
|
||||
$_POST['cp_api']
|
||||
$_POST['cp_api'],
|
||||
$_POST['style']
|
||||
);
|
||||
|
||||
$_POST['exccat'] = (!isset($_POST['exccat']) || !is_array($_POST['exccat'])) ? array() : $_POST['exccat'];
|
||||
@@ -99,6 +100,16 @@ switch ($action) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Get the list of themes.
|
||||
$themeList[] = 'None';
|
||||
$themes = scandir(NN_WWW . '/templates');
|
||||
foreach ($themes as $theme) {
|
||||
if (strpos($theme, ".") === false && $theme[0] !== '_' && is_dir(NN_WWW . '/templates/' . $theme)) {
|
||||
$themeList[] = $theme;
|
||||
}
|
||||
}
|
||||
|
||||
$page->smarty->assign('themelist', $themeList);
|
||||
|
||||
$page->smarty->assign('error', $errorStr);
|
||||
$page->smarty->assign('user', $data);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<tr><th>Registered:</th><td title="{$user.createddate}">{$user.createddate|date_format} ({$user.createddate|timeago} ago)</td></tr>
|
||||
<tr><th>Last Login:</th><td title="{$user.lastlogin}">{$user.lastlogin|date_format} ({$user.lastlogin|timeago} ago)</td></tr>
|
||||
<tr><th>Role:</th><td>{$user.rolename}</td></tr>
|
||||
<tr><th>Theme:</th><td>{$user.style}</td></tr>
|
||||
{if $userdata.role==2}<tr><th title="Admin Notes">Notes:</th><td>{$user.notes|escape:htmlall}{if $user.notes|count_characters > 0}<br/>{/if}<a href="{$smarty.const.WWW_TOP}/admin/user-edit.php?id={$user.id}#notes">Add/Edit</a></td></tr>{/if}
|
||||
{if $user.id==$userdata.id || $userdata.role==2}<tr><th title="Not public">Site Api/Rss Key:</th><td><a href="{$smarty.const.WWW_TOP}/rss?t=0&dl=1&i={$user.id}&r={$user.rsstoken}">{$user.rsstoken}</a></td></tr>{/if}
|
||||
{if $user.id==$userdata.id || $userdata.role==2}
|
||||
|
||||
@@ -42,6 +42,13 @@
|
||||
<fieldset>
|
||||
<legend>Site Preferences</legend>
|
||||
<table class="input">
|
||||
<tr>
|
||||
<th>Site theme:</th>
|
||||
<td>
|
||||
{html_options id="style" name='style' values=$themelist output=$themelist selected=$user.style}
|
||||
<span class="help-block">Change the site theme, None will use the theme the administrator set.</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>View Movie Page:</th>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user