*

Recent

Author Topic: User template setting  (Read 31055 times)

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #15 on: November 15, 2011, 03:32:34 PM »
Are you sure you're not making a rod for your own back - - Because I don't know why you don't wait for the next version to play with as I'm sure Adam would have addressed all the problems with:

The html, nested forms, form errors, nested table errors - The ability to edit file names without going to the Db to do it. And all the other script and html errors. ;)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: User template setting
« Reply #16 on: November 15, 2011, 03:37:24 PM »
meh im learning at the moment not really caring about the work itself

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #17 on: November 15, 2011, 11:49:01 PM »
Me too! ;)

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #18 on: January 08, 2013, 06:52:35 AM »
Quote
The only problem i see with this script is that if a user sets their template to "custom" then the webmaster deletes the template "custom" it will no longer allow them to log in until it is changed.

That's because you are "Guessing" what is in place and what is not, instead of checking that it exists.?

Every template would need a file named the same as the template - like default.cfg in the default, and "black.cfg" for a template named black - for example.

That file would only need to be at the minimum:

<?php
// This file needs to exist
?>

And this is where checking it with a variable takes the guesswork out of it.

If (whatever($template/$template.cfg)) {do this}else{do that};
« Last Edit: January 08, 2013, 06:55:24 AM by mort »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: User template setting
« Reply #19 on: January 08, 2013, 04:30:09 PM »
Quote
The only problem i see with this script is that if a user sets their template to "custom" then the webmaster deletes the template "custom" it will no longer allow them to log in until it is changed.

That's because you are "Guessing" what is in place and what is not, instead of checking that it exists.?

Every template would need a file named the same as the template - like default.cfg in the default, and "black.cfg" for a template named black - for example.

That file would only need to be at the minimum:

<?php
// This file needs to exist
?>

And this is where checking it with a variable takes the guesswork out of it.

If (whatever($template/$template.cfg)) {do this}else{do that};

Actually i have redone this in the newest version of the script. It works a bit differently and if i remember correctly i put in a check to make sure it exists and if not it uses default, im not entirely sure because i havnt worked on it in a while because of the holiday.

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #20 on: January 13, 2013, 03:37:13 AM »
Actually i have redone this in the newest version of the script. It works a bit differently and if i remember correctly i put in a check to make sure it exists and if not it uses default, im not entirely sure because i havnt worked on it in a while because of the holiday.

I suspect that you unbanned me because you would like some help here. So what are all the other "Developers" doing?

I took an interest in what you were trying to do with this because it's something that you have been working on for a long time.

But you don't cache "User Themes", only the Default, because if they change it - They have to wait until the cache refreshes before they can see it. It's the Default that gets the hiding - Not the user-themes. ;)

And if you want to write this in a different way?

Code: [Select]
<option value="default">default</option>';
$theme = "SELECT * FROM fas_themes WHERE `active`='1'";
$theme = sqlcache('themes', $cachelife, $theme);
foreach($theme as $row2){
if ($row2['name'] == $utemplate) { $usel = "selected"; }else{ $usel = NULL; }
echo"<option value=".$row2['name']." ".$usel." >".$row2['name']."</option>";
}
echo'
</select>

Try something like this.

Code: [Select]
$query = $db->query(sprintf("SELECT template_name FROM " . THEMES_TABLE . " WHERE visible=1 ORDER BY template_name ASC")) or die(mysql_error());

$style_list = '

<select name="user_style">';

while($row = $db->fetch_row($query)){

$template_name = $row['template_name'] ;

$selected = '';

if (!empty($user_style) && ($template_name == $user_style))
{
$selected = 'selected="selected"';
}

$style_list .= '<option style="width:100px;" value="'.$template_name.'"'.$selected.'>'.$template_name.'</option>';
};

$style_list .= '</select>';

echo '

'.$style_list.'


Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: User template setting
« Reply #21 on: January 13, 2013, 08:53:02 PM »
Actually i have redone this in the newest version of the script. It works a bit differently and if i remember correctly i put in a check to make sure it exists and if not it uses default, im not entirely sure because i havnt worked on it in a while because of the holiday.

I suspect that you unbanned me because you would like some help here. So what are all the other "Developers" doing?

I took an interest in what you were trying to do with this because it's something that you have been working on for a long time.

But you don't cache "User Themes", only the Default, because if they change it - They have to wait until the cache refreshes before they can see it. It's the Default that gets the hiding - Not the user-themes. ;)

And if you want to write this in a different way?

Code: [Select]
<option value="default">default</option>';
$theme = "SELECT * FROM fas_themes WHERE `active`='1'";
$theme = sqlcache('themes', $cachelife, $theme);
foreach($theme as $row2){
if ($row2['name'] == $utemplate) { $usel = "selected"; }else{ $usel = NULL; }
echo"<option value=".$row2['name']." ".$usel." >".$row2['name']."</option>";
}
echo'
</select>

Try something like this.

Code: [Select]
$query = $db->query(sprintf("SELECT template_name FROM " . THEMES_TABLE . " WHERE visible=1 ORDER BY template_name ASC")) or die(mysql_error());

$style_list = '

<select name="user_style">';

while($row = $db->fetch_row($query)){

$template_name = $row['template_name'] ;

$selected = '';

if (!empty($user_style) && ($template_name == $user_style))
{
$selected = 'selected="selected"';
}

$style_list .= '<option style="width:100px;" value="'.$template_name.'"'.$selected.'>'.$template_name.'</option>';
};

$style_list .= '</select>';

echo '

'.$style_list.'


I'm not really sure what you're trying to say here exactly. I understand parts of it but could you possibly elaborate?

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #22 on: January 14, 2013, 06:30:40 AM »
I'll explain it a bit later -  ;D

With this script, from what I can see - If you change the default style in the ACP to say "Blue" the user will be still be redirected to a theme called default? And if the "default" theme doesn't exist - as it doesn't in beta2 What happens if one is not logged in, or hasn't selected a theme,  and the theme "default" doesn't exist?

Code: [Select]
if(isset($_SESSION['userid'])){
$suserid = $_SESSION['userid'];
$usrdata = $db->fetch_row($db->query(sprintf('SELECT * FROM dd_users WHERE userid=\'%u\'', $suserid)));
}else{
$suserid = NULL;
$usrdata = NULL;
}

if(isset($suserid)){
$query = mysql_query("SELECT `template` FROM `dd_users` WHERE `userid`='$suserid'");
$row = mysql_fetch_array($query);
$user_template = $row['template'];
}else{
$user_template = '';
}

if(!empty($user_template) && $user_template != "default"){
$template = $user_template;
}else{
$query = mysql_query("SELECT `template` FROM `fas_themes` WHERE `default`='1'");
$row = mysql_fetch_array($query);
$template = $row['template'];
}

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: User template setting
« Reply #23 on: January 14, 2013, 08:01:55 AM »
I'll explain it a bit later -  ;D

With this script, from what I can see - If you change the default style in the ACP to say "Blue" the user will be still be redirected to a theme called default? And if the "default" theme doesn't exist - as it doesn't in beta2 What happens if one is not logged in, or hasn't selected a theme,  and the theme "default" doesn't exist?

Code: [Select]
if(isset($_SESSION['userid'])){
$suserid = $_SESSION['userid'];
$usrdata = $db->fetch_row($db->query(sprintf('SELECT * FROM dd_users WHERE userid=\'%u\'', $suserid)));
}else{
$suserid = NULL;
$usrdata = NULL;
}

if(isset($suserid)){
$query = mysql_query("SELECT `template` FROM `dd_users` WHERE `userid`='$suserid'");
$row = mysql_fetch_array($query);
$user_template = $row['template'];
}else{
$user_template = '';
}

if(!empty($user_template) && $user_template != "default"){
$template = $user_template;
}else{
$query = mysql_query("SELECT `template` FROM `fas_themes` WHERE `default`='1'");
$row = mysql_fetch_array($query);
$template = $row['template'];
}

By default it means the theme that is set as default in the admin panel. There isnt actually supposed to be a theme called "default" it just means to instead of selecting a user set theme it will select the theme that the admins have set to be the default theme.

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #24 on: January 14, 2013, 03:27:50 PM »
Bit confusing if not anything else?

If you changed the user "template" to "user_template"

You could use something like this.

Code: [Select]
if(isset($_SESSION['userid'])){
$suserid = $_SESSION['userid'];
$usrdata = $db->fetch_row($db->query(sprintf("SELECT * FROM dd_users WHERE userid='%u'", $suserid)));

$query = mysql_query("SELECT template FROM fas_themes WHERE visible=1 ORDER BY template ASC") or die(mysql_error()); 

while($row = mysql_fetch_array($query)) {

$available = $row['template'];
$style = $usrdata['user_template'];

if((!$usrdata) || ($available != $style)){$template = $template; // Whatever is set in the ACP Settings
}else{
if(!empty($style)) {$template = $style;}
}
}
mysql_free_result($query);
}

Too easy.  :P
« Last Edit: January 14, 2013, 03:54:36 PM by mort »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: User template setting
« Reply #25 on: January 14, 2013, 09:08:48 PM »
Bit confusing if not anything else?

If you changed the user "template" to "user_template"

You could use something like this.

Code: [Select]
if(isset($_SESSION['userid'])){
$suserid = $_SESSION['userid'];
$usrdata = $db->fetch_row($db->query(sprintf("SELECT * FROM dd_users WHERE userid='%u'", $suserid)));

$query = mysql_query("SELECT template FROM fas_themes WHERE visible=1 ORDER BY template ASC") or die(mysql_error()); 

while($row = mysql_fetch_array($query)) {

$available = $row['template'];
$style = $usrdata['user_template'];

if((!$usrdata) || ($available != $style)){$template = $template; // Whatever is set in the ACP Settings
}else{
if(!empty($style)) {$template = $style;}
}
}
mysql_free_result($query);
}

Too easy.  :P

The reason i did it the way i did was so that so if the user never changed their theme and they just left it the one set as default. Then the admin decides that he wants to add a new theme and change that to the default. If i dont have the default option, unless i can think of another way, the users will still stay at the old default theme(unless deleted of course) even though i changed the default theme in the admin panel. Get what im saying?

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #26 on: January 15, 2013, 01:41:48 AM »
Get what im saying?

No I don't - The "default" theme in the ACP is the one Admin wants the Guests to see - Or "New" users to have when they register - Not force users to have it, just because he thinks they should. Doesn't make sense? :(

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: User template setting
« Reply #27 on: January 15, 2013, 09:57:10 AM »
Get what im saying?

No I don't - The "default" theme in the ACP is the one Admin wants the Guests to see - Or "New" users to have when they register - Not force users to have it, just because he thinks they should. Doesn't make sense? :(

I see what your saying.

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: User template setting
« Reply #28 on: February 18, 2013, 05:00:53 AM »
There's something else that is missing,

Without logged Sessions or Cookie Sessions, I can't see how anything the user selects is going to be "Remembered" from page to page, or how things are going to be "Remembered" between login and logout.

FAS has neither?

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: User template setting
« Reply #29 on: February 18, 2013, 01:25:24 PM »
There's something else that is missing,

Without logged Sessions or Cookie Sessions, I can't see how anything the user selects is going to be "Remembered" from page to page, or how things are going to be "Remembered" between login and logout.

FAS has neither?

The theme they select is saved in the database, im not sure what you mean.