aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2005-01-20 20:57:45 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2005-01-20 20:57:45 +0000
commit9c1a4bdac16945c7d616b3449cc7d97a2548fc22 (patch)
tree27e35d979f7b8fd6b7844a6cba941b5b04a438bd /phpBB/includes
parenta7ef13c639e048e9ee9edc25e7f7d9a5bf155812 (diff)
downloadforums-9c1a4bdac16945c7d616b3449cc7d97a2548fc22.tar
forums-9c1a4bdac16945c7d616b3449cc7d97a2548fc22.tar.gz
forums-9c1a4bdac16945c7d616b3449cc7d97a2548fc22.tar.bz2
forums-9c1a4bdac16945c7d616b3449cc7d97a2548fc22.tar.xz
forums-9c1a4bdac16945c7d616b3449cc7d97a2548fc22.zip
- bugfixes
- default sort options for posts too - adjusted format_date to remove the (time intensive) preg_ calls - temporary style.php code. git-svn-id: file:///svn/phpbb/trunk@5068 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/db/mysql.php2
-rw-r--r--phpBB/includes/functions.php11
-rw-r--r--phpBB/includes/functions_privmsgs.php7
-rw-r--r--phpBB/includes/session.php33
-rw-r--r--phpBB/includes/ucp/ucp_pm.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php6
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php93
7 files changed, 108 insertions, 46 deletions
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index ec9f17bf27..aa9e6c1a39 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -263,8 +263,6 @@ class sql_db
$query_id = $this->query_result;
}
- // This method is called too often... do not waste memory by calling/checking unneeded things
-// if (method_exists($cache, 'sql_fetchrow') && $cache->sql_exists($query_id))
if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_fetchrow($query_id);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index e75b01714c..f3cb791438 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -562,12 +562,9 @@ function watch_topic_forum($mode, &$s_watching, &$s_watching_img, $user_id, $mat
}
else
{
- if (isset($_GET['unwatch']))
+ if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode)
{
- if ($_GET['unwatch'] == $mode)
- {
- login_box();
- }
+ login_box();
}
else
{
@@ -1016,8 +1013,8 @@ function redirect($url)
// Make sure no &amp;'s are in, this will break the redirect
$url = str_replace('&amp;', '&', $url);
- // Local redirect? If not, prepend the boards url
- if (strpos($url, '://') === false && strpos($url, '/') !== 0)
+ // If relative path, prepend board url
+ if (strpos($url, '://') === false && $url{0} != '/')
{
$url = generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url));
}
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 1682df0d1e..73171f318f 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -101,7 +101,7 @@ $global_rule_conditions = array(
);
// Get all folder
-function get_folder($user_id, &$folder, $folder_id = false, $mode = '')
+function get_folder($user_id, &$folder, $folder_id = false)
{
global $db, $user, $template;
@@ -110,11 +110,6 @@ function get_folder($user_id, &$folder, $folder_id = false, $mode = '')
$folder = array();
}
- if ($mode == 'unread')
- {
- $folder['unread'] = array('folder_name' => $user->lang['UNREAD_MESSAGES']);
- }
-
// Get folder informations
$sql = 'SELECT folder_id, COUNT(msg_id) as num_messages, SUM(unread) as num_unread
FROM ' . PRIVMSGS_TO_TABLE . "
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 46a99c2d38..f71d133378 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -590,6 +590,24 @@ class user extends session
$this->theme[$style_priority]['pagination_sep'] = ', ';
}
+ // TEMP
+ $this->theme['primary']['parse_css_file'] = false;
+ if (!$this->theme['primary']['theme_storedb'] && $this->theme['primary']['parse_css_file'])
+ {
+ $this->theme['primary']['theme_storedb'] = 1;
+
+ $sql_ary = array(
+ 'theme_data' => implode('', file("{$phpbb_root_path}styles/" . $this->theme['primary']['theme_path'] . '/theme/stylesheet.css')),
+ 'theme_mtime' => time(),
+ 'theme_storedb' => 1
+ );
+
+ $db->sql_query('UPDATE ' . STYLES_CSS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE theme_id = ' . $style);
+
+ unset($sql_ary);
+ }
+
$template->set_template();
$this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['primary']['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang'];
@@ -703,17 +721,20 @@ class user extends session
$midnight = gmmktime(0, 0, 0, $m, $d, $y) - $this->timezone - $this->dst;
}
- if ($gmepoch > $midnight && !$forcedate)
+ if (strpos($format, '|') === false || (!($gmepoch > $midnight && !$forcedate) && !($gmepoch > $midnight - 86400 && !$forcedate)))
{
- return preg_replace('#\|.*?\|#', $this->lang['datetime']['TODAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
+ return strtr(@gmdate(str_replace('|', '', $format), $gmepoch + $this->timezone + $this->dst), $lang_dates);
}
- else if ($gmepoch > $midnight - 86400 && !$forcedate)
+
+ if ($gmepoch > $midnight && !$forcedate)
{
- return preg_replace('#\|.*?\|#', $this->lang['datetime']['YESTERDAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
+ $format = substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1);
+ return str_replace('||', $this->lang['datetime']['TODAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
}
- else
+ else if ($gmepoch > $midnight - 86400 && !$forcedate)
{
- return strtr(@gmdate(str_replace('|', '', $format), $gmepoch + $this->timezone + $this->dst), $lang_dates);
+ $format = substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1);
+ return str_replace('||', $this->lang['datetime']['YESTERDAY'], strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates));
}
}
diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php
index fdb6396133..21962ea215 100644
--- a/phpBB/includes/ucp/ucp_pm.php
+++ b/phpBB/includes/ucp/ucp_pm.php
@@ -288,7 +288,7 @@ class ucp_pm extends module
update_unread_status($message_row['unread'], $message_row['msg_id'], $user->data['user_id'], $folder_id);
}
- get_folder($user->data['user_id'], $folder, $folder_id, $mode);
+ get_folder($user->data['user_id'], $folder, $folder_id);
$s_folder_options = $s_to_folder_options = '';
foreach ($folder as $f_id => $folder_ary)
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 059760c500..8edac192ad 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -187,9 +187,9 @@ function get_pm_from($folder_id, $folder, $user_id, $url, $type = 'folder')
$start = request_var('start', 0);
- $sort_days = (isset($_REQUEST['st'])) ? max(intval($_REQUEST['st']), 0) : ((!empty($user->data['user_show_days'])) ? $user->data['user_show_days'] : 0);
- $sort_key = (!empty($_REQUEST['sk'])) ? htmlspecialchars($_REQUEST['sk']) : ((!empty($user->data['user_sortby_type'])) ? $user->data['user_sortby_type'] : 't');
- $sort_dir = (!empty($_REQUEST['sd'])) ? htmlspecialchars($_REQUEST['sd']) : ((!empty($user->data['user_sortby_dir'])) ? $user->data['user_sortby_dir'] : 'd');
+ $sort_days = request_var('st', ((!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0));
+ $sort_key = request_var('sk', ((!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'));
+ $sort_dir = request_var('sd', ((!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'));
// PM ordering options
$limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index dde3442002..2464df2164 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -162,9 +162,13 @@ class ucp_prefs extends module
if ($submit)
{
$var_ary = array(
- 'sk' => (string) 't',
- 'sd' => (string) 'd',
- 'st' => 0,
+ 'topic_sk' => (string) 't',
+ 'topic_sd' => (string) 'd',
+ 'topic_st' => 0,
+
+ 'post_sk' => (string) 't',
+ 'post_sd' => (string) 'a',
+ 'post_st' => 0,
'images' => true,
'flash' => false,
@@ -180,8 +184,10 @@ class ucp_prefs extends module
}
$var_ary = array(
- 'sk' => array('string', false, 1, 1),
- 'sd' => array('string', false, 1, 1),
+ 'topic_sk' => array('string', false, 1, 1),
+ 'topic_sd' => array('string', false, 1, 1),
+ 'post_sk' => array('string', false, 1, 1),
+ 'post_sd' => array('string', false, 1, 1),
);
$error = validate_data($data, $var_ary);
@@ -201,10 +207,14 @@ class ucp_prefs extends module
}
$sql_ary = array(
- 'user_options' => $user->data['user_options'],
- 'user_sortby_type' => $sk,
- 'user_sortby_dir' => $sd,
- 'user_show_days' => $st,
+ 'user_options' => $user->data['user_options'],
+ 'user_topic_sortby_type'=> $topic_sk,
+ 'user_post_sortby_type' => $post_sk,
+ 'user_topic_sortby_dir' => $topic_sd,
+ 'user_post_sortby_dir' => $post_sd,
+
+ 'user_topic_show_days' => $topic_st,
+ 'user_post_show_days' => $post_st,
);
$sql = 'UPDATE ' . USERS_TABLE . '
@@ -221,18 +231,55 @@ class ucp_prefs extends module
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
- $sk = (isset($sk)) ? $sk : ((!empty($user->data['user_sortby_type'])) ? $user->data['user_sortby_type'] : 't');
- $sd = (isset($sd)) ? $sd : ((!empty($user->data['user_sortby_dir'])) ? $user->data['user_sortby_dir'] : 'd');
- $st = (isset($st)) ? $st : ((!empty($user->data['user_show_days'])) ? $user->data['user_show_days'] : 0);
+ $topic_sk = (isset($topic_sk)) ? $topic_sk : ((!empty($user->data['user_tpic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't');
+ $post_sk = (isset($post_sk)) ? $post_sk : ((!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't');
+
+ $topic_sd = (isset($topic_sd)) ? $topic_sd : ((!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd');
+ $post_sd = (isset($post_sd)) ? $post_sd : ((!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'd');
+
+ $topic_st = (isset($topic_st)) ? $topic_st : ((!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0);
+ $post_st = (isset($post_st)) ? $post_st : ((!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0);
+
+ $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
+
+ // Topic ordering options
+ $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
+
+ $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
+ $sort_by_topic_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
+
+ // Post ordering options
+ $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
+
+ $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
+ $sort_by_post_sql = array('a' => 'u.username', 't' => 'p.post_id', 's' => 'p.post_subject');
- // Topic ordering display
- $limit_days = array(0 => $user->lang['ALL_TOPICS'], 0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
+ foreach (array('topic', 'post') as $sort_option)
+ {
+ ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">';
+ foreach (${'limit_' . $sort_option . '_days'} as $day => $text)
+ {
+ $selected = (${$sort_option . '_st'} == $day) ? ' selected="selected"' : '';
+ ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
+ }
+ ${'s_limit_' . $sort_option . '_days'} .= '</select>';
- $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
- $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
+ ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">';
+ foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text)
+ {
+ $selected = (${$sort_option . '_sk'} == $key) ? ' selected="selected"' : '';
+ ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
+ }
+ ${'s_sort_' . $sort_option . '_key'} .= '</select>';
- $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
- gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
+ ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">';
+ foreach ($sort_dir_text as $key => $value)
+ {
+ $selected = (${$sort_option . '_sd'} == $key) ? ' selected="selected"' : '';
+ ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
+ }
+ ${'s_sort_' . $sort_option . '_dir'} .= '</select>';
+ }
$images = (isset($images)) ? $images : $user->optionget('viewimg');
$images_yes = ($images) ? ' checked="checked"' : '';
@@ -270,9 +317,13 @@ class ucp_prefs extends module
'DISABLE_CENSORS_NO' => $wordcensor_no,
'S_CHANGE_CENSORS' => ($auth->acl_get('u_chgcensors')) ? true : false,
- 'S_SELECT_SORT_DAYS' => $s_limit_days,
- 'S_SELECT_SORT_KEY' => $s_sort_key,
- 'S_SELECT_SORT_DIR' => $s_sort_dir)
+
+ 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days,
+ 'S_TOPIC_SORT_KEY' => $s_sort_topic_key,
+ 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir,
+ 'S_POST_SORT_DAYS' => $s_limit_post_days,
+ 'S_POST_SORT_KEY' => $s_sort_post_key,
+ 'S_POST_SORT_DIR' => $s_sort_post_dir)
);
break;