Skip to content
Permalink
Browse files

added sort option by own log date; fixed sorting by last log

  • Loading branch information...
following
following committed Apr 28, 2013
1 parent d12f8cf commit d27d9c3fa5048bd0a7f491d18ff07a0b0a11b0c5
@@ -2437,6 +2437,8 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('1995', 'Opencac
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('1996', 'The visited website <b>%1</b> does not exists, we found the following suitable pages:', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('1998', 'OK', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('1999', 'Show active', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2000', 'My last log', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2001', 'Own logs', '2013-04-25 23:00:00');

-- Table sys_trans_ref
SET NAMES 'utf8';
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1996', 'DE', 'Die gesuchte Webseite <b>%1</b> existiert nicht, aber wir haben folgende Seiten gefunden:', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1998', 'DE', 'OK', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1999', 'DE', 'aktive anzeigen', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2000', 'DE', 'mein letztes Log', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2001', 'DE', 'Eigene Logs', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs \r', '2010-09-02 00:15:30');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07');
@@ -85,7 +85,7 @@
<td width="46" height="13" bgcolor="#E6E6E6"><b>{t}D/T{/t}</b></td>
<td width="448" height="13" bgcolor="#E6E6E6"><b>{t}Name{/t}</b></td>
<td width="48" height="13" bgcolor="#E6E6E6"><b>&nbsp;</b></td>
<td width="126" height="13" bgcolor="#E6E6E6"><b>{t}Last logs{/t}</b></td>
<td width="126" height="13" bgcolor="#E6E6E6"><b style="display:{displaylastlogs}">{t}Last logs{/t}</b><b style="display:{displayownlogs}">{t}Own logs{/t}</b></td>
</tr>
<!--a-->{results}<!--z-->
</table>
@@ -148,6 +148,8 @@ function sync_options(element)
sortby = "bycreated";
else if (document.optionsform.sort[3].checked == true)
sortby = "bylastlog";
else if (document.optionsform.sort[4].checked == true)
sortby = "bymylastlog";
var tmpattrib = "";
for (i = 0; i < maAttributes.length; i++)
@@ -277,10 +279,11 @@ function switchAttributeCat2()
<td style="vertical-align:top">{t}Sorting of result:{/t}</td>
<td colspan="2">
<div style="padding:0 0 5px 0">
<input type="radio" name="sort" value="byname" index="0" id="l_sortbyname" class="radio" onclick="sync_options(this)" {byname_checked}> <label for="l_sortbyname">{t}Cachename{/t}</label>&nbsp;
<input type="radio" name="sort" value="bydistance" index="1" id="l_sortbydistance" class="radio" onclick="sync_options(this)" {bydistance_checked} {bydistance_enabled} accept=""> <label for="l_sortbydistance">{t}Distance from <a href="myprofile.php">user-profile home coordinates</a>{/t}</label></div>
<input type="radio" name="sort" value="byname" index="0" id="l_sortbyname" class="radio" onclick="sync_options(this)" {byname_checked} > <label for="l_sortbyname">{t}Cachename{/t}</label>&nbsp;
<input type="radio" name="sort" value="bydistance" index="1" id="l_sortbydistance" class="radio" onclick="sync_options(this)" {bydistance_checked} {bydistance_enabled} accept=""{disable_nologin}"> <label for="l_sortbydistance" {grey_nologin}">{t}Distance from <a href="myprofile.php">user-profile home coordinates</a>{/t}</label></div>
<input type="radio" name="sort" value="bycreated" index="2" id="l_sortbycreated" class="radio" onclick="sync_options(this)" {bycreated_checked}> <label for="l_sortbycreated">{t}Listed since{/t}</label>&nbsp;
<input type="radio" name="sort" value="bylastlog" index="3" id="l_sortbylastlog" class="radio" onclick="sync_options(this)" {bylastlog_checked}> <label for="l_sortbylastlog">{t}Last log{/t}</label>
<input type="radio" name="sort" value="bylastlog" index="3" id="l_sortbylastlog" class="radio" onclick="sync_options(this)" {bylastlog_checked}> <label for="l_sortbylastlog" >{t}Last log{/t}</label>&nbsp;
<input type="radio" name="sort" value="bymylastlog" index="4" id="l_sortbymylastlog" class="radio" onclick="sync_options(this)" {bymylastlog_checked} {disable_nologin}> <label for="l_sortbymylastlog" {grey_nologin}>{t}My last log{/t}</label>
</td>
</tr>
<tr>
@@ -297,9 +300,9 @@ function switchAttributeCat2()
<tr>
<td>{t}Hide following caches:{/t}</td>
<td colspan="2">
<input type="checkbox" name="f_userowner" value="1" id="l_userowner" class="checkbox" onclick="sync_options(this)" {f_userowner_disabled} /> <label for="l_userowner">{t}My owned{/t}</label>&nbsp;&nbsp;
<input type="checkbox" name="f_userfound" value="1" id="l_userfound" class="checkbox" onclick="sync_options(this)" {f_userfound_disabled} /> <label for="l_userfound">{t}My finds{/t}</label>&nbsp;&nbsp;
<input type="checkbox" name="f_ignored" value="1" id="l_ignored" class="checkbox" onclick="sync_options(this)" {f_ignored_disabled} > <label for="l_ignored">{t}My ignored{/t}</label>&nbsp;&nbsp;
<input type="checkbox" name="f_userowner" value="1" id="l_userowner" class="checkbox" onclick="sync_options(this)" {f_userowner_disabled} /> <label for="l_userowner" {grey_nologin}>{t}My owned{/t}</label>&nbsp;&nbsp;
<input type="checkbox" name="f_userfound" value="1" id="l_userfound" class="checkbox" onclick="sync_options(this)" {f_userfound_disabled} /> <label for="l_userfound" {grey_nologin}>{t}My finds{/t}</label>&nbsp;&nbsp;
<input type="checkbox" name="f_ignored" value="1" id="l_ignored" class="checkbox" onclick="sync_options(this)" {f_ignored_disabled} > <label for="l_ignored" {grey_nologin}>{t}My ignored{/t}</label>&nbsp;&nbsp;
<img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" alt="{t}Notice{/t}" title="{t}Notice{/t}" align="middle">{t}Only usable if signed in.{/t}
</td>
</tr>
@@ -188,11 +188,13 @@
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
if ($options['sort'] == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
if ($options['sort'] == 'bymylastlog')
$sAddJoin .= ' AND `cache_logs`.`user_id`=' . sql_escape($usr === false? 0 : $usr['userid']);
$sGroupBy = ' GROUP BY `caches`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`,
@@ -210,7 +212,7 @@
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -78,11 +78,14 @@
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
if ($options['sort'] == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
if ($options['sort'] == 'bymylastlog')
$sAddJoin .= ' AND `cache_logs`.`user_id`=' . sql_escape($usr === false? 0 : $usr['userid']);
$sGroupBy = ' GROUP BY `caches`.`cache_id`';
}
$sql .= ' `caches`.`name` `name`, `caches`.`status` `status`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`,
`caches`.`difficulty` `difficulty`, `caches`.`terrain` `terrain`, `caches`.`desc_languages` `desc_languages`,
@@ -102,15 +105,15 @@
LEFT JOIN `caches_attributes` AS `tbloconly` ON `caches`.`cache_id`=`tbloconly`.`cache_id` AND
`tbloconly`.`attrib_id`=6' .
$sAddJoin
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
. ' WHERE `caches`.`cache_id` IN (' . $sqlFilter . ')' .
$sGroupBy;
$sortby = $options['sort'];
$sql .= ' ORDER BY ';
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -175,18 +178,22 @@
else
$tmpline = mb_ereg_replace('{oconly}', '', $tmpline);
// das letzte found suchen
// get last logs
if ($options['sort'] != 'bymylastlog' || $usr === false)
$ownlogs = "";
else
$ownlogs = " AND `cache_logs`.`user_id`='" . sql_escape($usr['userid']) . "'";
$sql = 'SELECT `cache_logs`.`id` `id`, `cache_logs`.`type` `type`, `cache_logs`.`date` `date`, `log_types`.`icon_small` `icon_small`
FROM `cache_logs`, `log_types`
WHERE `cache_logs`.`cache_id`=\'' . sql_escape($caches_record['cache_id']) . '\'
AND `log_types`.`id`=`cache_logs`.`type`
AND `log_types`.`id`=`cache_logs`.`type`' . $ownlogs . '
ORDER BY `cache_logs`.`date` DESC LIMIT 6';
$result = sql_slave($sql);
if ($row = sql_fetch_array($result))
{
$tmpline = mb_ereg_replace('{logimage1}',
icon_log_type($row['icon_small'], ""). '<a href=\'viewlogs.php?cacheid='.htmlspecialchars($caches_record['cache_id'], ENT_COMPAT, 'UTF-8').'#'.htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8').'\'>{gray_s}' .date($logdateformat, strtotime($row['date'])) . '{gray_e}</a>', $tmpline);
icon_log_type($row['icon_small'], ""). '<a href=\'viewlogs.php?cacheid='.htmlspecialchars($caches_record['cache_id'], ENT_COMPAT, 'UTF-8').'#log'.htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8').'\'>{gray_s}' .date($logdateformat, strtotime($row['date'])) . '{gray_e}</a>', $tmpline);
$tmpline = mb_ereg_replace('{logdate1}', "", $tmpline);
}
else
@@ -198,7 +205,7 @@
$lastlogs = "";
while ($row = sql_fetch_array($result))
{
$lastlogs .= '<a href=\'viewlogs.php?cacheid=' . urlencode($caches_record['cache_id']) . '#' . htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8') . '\'>' . icon_log_type($row['icon_small'], '') . '</a>&nbsp;';
$lastlogs .= '<a href=\'viewlogs.php?cacheid=' . urlencode($caches_record['cache_id']) . '#log' . htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8') . '\'>' . icon_log_type($row['icon_small'], '') . '</a>&nbsp;';
}
$tmpline = mb_ereg_replace('{lastlogs}', $lastlogs, $tmpline);
@@ -334,6 +341,9 @@
else
tpl_set_var('distanceunit', $distance_unit);
tpl_set_var('displaylastlogs', $options['sort'] == 'bymylastlog' ? 'none' : 'inline');
tpl_set_var('displayownlogs', $options['sort'] == 'bymylastlog' ? 'inline' : 'none');
if ($sqldebug == true)
sqldbg_end();
else
@@ -83,11 +83,13 @@
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
if ($options['sort'] == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
if ($options['sort'] == 'bymylastlog')
$sAddJoin .= ' AND `cache_logs`.`user_id`=' . sql_escape($usr === false? 0 : $usr['userid']);
$sGroupBy = ' GROUP BY `caches`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
@@ -103,7 +105,7 @@
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -73,11 +73,13 @@
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
if ($options['sort'] == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
if ($options['sort'] == 'bymylastlog')
$sAddJoin .= ' AND `cache_logs`.`user_id`=' . sql_escape($usr === false? 0 : $usr['userid']);
$sGroupBy = ' GROUP BY `caches`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
@@ -93,7 +95,7 @@
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -58,11 +58,13 @@
$sAddJoin = '';
$sAddGroupBy = '';
$sAddField = '';
if ($options['sort'] == 'bylastlog')
if ($options['sort'] == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
if ($options['sort'] == 'bymylastlog')
$sAddJoin .= ' AND `cache_logs`.`user_id`=' . sql_escape($usr === false? 0 : $usr['userid']);
$sGroupBy = ' GROUP BY `caches`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`, `caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`, `caches`.`user_id` `user_id`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
@@ -78,7 +80,7 @@
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -62,11 +62,13 @@
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
if ($options['sort'] == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
if ($options['sort'] == 'bymylastlog')
$sAddJoin .= ' AND `cache_logs`.`user_id`=' . sql_escape($usr === false? 0 : $usr['userid']);
$sGroupBy = ' GROUP BY `caches`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`,
IF(IFNULL(`stat_caches`.`toprating`,0)>3, 4, IFNULL(`stat_caches`.`toprating`, 0)) `ratingvalue`' .
@@ -82,7 +84,7 @@
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -95,11 +95,13 @@
$sAddGroupBy = '';
$sAddField = '';
$sGroupBy = '';
if ($options['sort'] == 'bylastlog')
if ($options['sort'] == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sAddField = ', MAX(`cache_logs`.`date`) AS `lastLog`';
$sAddJoin = ' LEFT JOIN `cache_logs` ON `caches`.`cache_id`=`cache_logs`.`cache_id`';
$sGroupBy = ' GROUP BY `cache_logs`.`cache_id`';
if ($options['sort'] == 'bymylastlog')
$sAddJoin .= ' AND `cache_logs`.`user_id`=' . sql_escape($usr === false? 0 : $usr['userid']);
$sGroupBy = ' GROUP BY `caches`.`cache_id`';
}
$sql .= '`caches`.`cache_id` `cache_id`, `caches`.`status` `status`, `caches`.`type` `type`,
`caches`.`size` `size`, `caches`.`longitude` `longitude`, `caches`.`latitude` `latitude`,
@@ -117,7 +119,7 @@
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $options['sort'] == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -90,7 +90,7 @@
if ($options['orderRatingFirst'])
$sql .= '`ratingvalue` DESC, ';
if ($sortby == 'bylastlog')
if ($sortby == 'bylastlog' || $sortby == 'bymylastlog')
{
$sql .= '`lastLog` DESC, ';
$sortby = 'bydistance';
@@ -1061,6 +1061,9 @@ function outputSearchForm($options)
tpl_set_var('formmethod', 'get');
// checkboxen
tpl_set_var('disable_nologin', $usr === false ? 'disabled' : '');
tpl_set_var('grey_nologin', $usr === false ? 'style="color:grey"' : '');
$homecoords = ($login->userid>0 && sql_value_slave("SELECT `latitude`+`longitude` FROM user WHERE `user_id`='&1'", $login->userid) <> 0);
if (!$homecoords && isset($options['sort']) && $options['sort'] == 'bydistance')
$options['sort'] = 'byname';
@@ -1090,6 +1093,12 @@ function outputSearchForm($options)
$bBylastlogChecked = ($usr['userid'] != 0);
tpl_set_var('bylastlog_checked', ($bBylastlogChecked == true) ? ' checked="checked"' : '');
if (isset($options['sort']))
$bBymylastlogChecked = ($options['sort'] == 'bymylastlog');
else
$bBymylastlogChecked = ($usr['userid'] != 0);
tpl_set_var('bymylastlog_checked', ($bBymylastlogChecked == true) ? ' checked="checked"' : '');
tpl_set_var('hidopt_sort', $options['sort']);
tpl_set_var('orderRatingFirst_checked', ($options['orderRatingFirst'] == true) ? ' checked="checked"' : '');
@@ -21,7 +21,7 @@
</div>
{* Ocprop: (find|us|own)erid=([0-9]+) *}
<p style="line-height: 1.6em;">[<a href="search.php?showresult=1&amp;expert=0&amp;output=HTML&amp ;sort=byname&amp;finderid={$login.userid}&amp;searchbyfinder=&amp;f_inactive=0&amp;logtype=1,7">{t}Show all{/t}</a>] &ndash; <b>{t}Your latest log entries:{/t}</b></p>
<p style="line-height: 1.6em;">[<a href="search.php?showresult=1&amp;expert=0&amp;output=HTML&amp;sort=bymylastlog&amp;finderid={$login.userid}&amp;searchbyfinder=&amp;f_inactive=0&amp;logtype=1,7">{t}Show all{/t}</a>] &ndash; <b>{t}Your latest log entries:{/t}</b></p>
<table class="table">
{foreach from=$logs item=logItem}

0 comments on commit d27d9c3

Please sign in to comment.
You can’t perform that action at this time.