Skip to content
Permalink
Browse files

personal cache list fixes and improvements; updates #168

- fixed "add to list" function in cache listings
- added "visible for all users in cache listings" option
- minor changes
  • Loading branch information...
following5 committed Jul 1, 2015
1 parent 08ad240 commit 3110708a863540d426fc7fe8dbc2b98733ea02e6
@@ -32,11 +32,11 @@
if ($listid == 0)
{
$cachelist = new cachelist(ID_NEW, $login->userid);
if (!$cachelist->setName($newlist_name))
$tpl->assign('name_error', true);
$name_error = $cachelist->setNameAndVisibility($newlist_name, $newlist_public ? 2 : 0);
if ($name_error)
$tpl->assign('name_error', $name_error);
else
{
$cachelist->setPublic($newlist_public);
if ($cachelist->save())
{
$cachelist->addCacheByID($cacheid);
@@ -2628,7 +2628,7 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2192', 'There a
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2193', 'My cache lists', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2194', 'Do you really want to delete the list \\\'%1\\\'?', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2195', 'Create new list', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2196', 'Public lists are displayed in your <a href=\"viewprofile.php?userid=%1\">public user profile</a>, on the <a href=\"cachelists.php\">lists overwiew page</a> and in the cache listings.', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2196', 'Public lists are displayed in your <a href=\"viewprofile.php?userid=%1\">public user profile</a>, on the <a href=\"cachelists.php\">lists overwiew page</a> and (if enabled) in the cache listings.', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2197', 'Space-separated list of OC waypoints.', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2198', 'You may also add caches via \"Add to list\" button in cache listings.', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2199', 'This is optional, caches may be added to the list later.', '2015-06-17 10:09:14');
@@ -2654,7 +2654,11 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2218', 'Another
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2219', 'minimum length for public lists is 10 characters', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2220', 'You are still watching this geocache via one or more cache lists.', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2221', 'Create new cachelist', '2015-06-17 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2222', 'visible for all users in cache listings', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2223', 'semi-public', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2224', 'listing display', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2225', 'without Geokrets', '2013-11-03 10:09:14');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2226', 'hidden[cachelist]', '2013-11-03 10:09:14');

-- Table sys_trans_ref
SET NAMES 'utf8';
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2193', 'DE', 'Meine Cachelisten', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2194', 'DE', 'Möchtest du die Liste \\\'%1\\\' wirklich löschen?', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2195', 'DE', 'Neue Liste anlegen', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2196', 'DE', 'Öffentliche Listen werden in deinem <a href=\"viewprofile.php?userid=%1\">öffentlichen Profil</a>, auf der <a href=\"cachelists.php\">Listen-Sammelseite</a> und in den Cachelistings angezeigt.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2196', 'DE', 'Öffentliche Listen werden in deinem <a href=\"viewprofile.php?userid=%1\">öffentlichen Profil</a>, auf der <a href=\"cachelists.php\">Listen-Sammelseite</a> und (falls eingeschaltet) in den Cachelistings angezeigt.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2197', 'DE', 'Mit Leerzeichen getrennte Liste von OC-Wegpunkten.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2198', 'DE', 'Wahlweise kannst du auch Caches mit dem „Merken“-Knopf im Listing hinzufügen.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2199', 'DE', 'Diese Angabe ist optional; Caches können auch später zur Liste hinzugefügt werden.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2219', 'DE', 'Mindestlänge für öffentliche Listen ist 10 Zeichen', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2220', 'DE', 'Du beobachtest diesen Geocache weiterhin über eine oder mehrere Cachelisten.', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2221', 'DE', 'Neue Cacheliste anlegen', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2222', 'DE', 'für Alle in Cachelistings sichtbar', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2223', 'DE', 'halböffentlich', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2224', 'DE', 'Listinganzeige', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2225', 'DE', 'ohne Geokrets', '2013-11-03 10:09:14');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2226', 'DE', 'ausgeblendet', '2013-11-03 10:09:14');

INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs', '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 ('2151', 'EN', 'Also listed as', '2011-05-23 22:19:23');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2162', 'EN', 'Your log entries', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2175', 'EN', 'Disclose my e-mail address by default when sending e-mails to other users.', '2015-05-25 19:50:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2226', 'EN', 'hidden', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'ES', 'Reordenar ID', '2010-12-09 00:17:55');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'ES', 'La base de datos no se pudo conectar.', '2010-12-09 00:17:55');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'ES', 'En pruebas - por favor, no entre.', '2010-12-09 00:17:55');
@@ -70,13 +70,14 @@ function getName()
return $this->reCachelist->getValue('name');
}
function isPublic()
// 0 = private, 1 = private & friends (not impl.), 2 = public, 3 = public + listing display
function getVisibility()
{
return $this->reCachelist->getValue('is_public');
}
// !! This method returns an error state instead of a success flag; false means "no error".
function setNameAndPublic($name, $public)
function setNameAndVisibility($name, $visibility)
{
$name = trim($name);
if ($name == '')
@@ -88,11 +89,14 @@ function setNameAndPublic($name, $public)
false, $this->getUserId(), $this->getId(), $name))
// $this->getId() is 0 when creating a new list -> condition has no effect
return ERROR_DUPLICATE_LISTNAME;
else if ($public && strlen($name) < 10)
else if ($visibility >= 2 && strlen($name) < 10)
return ERROR_BAD_LISTNAME;
}
return !$this->reCachelist->setValue('name', trim($name)) ||
!$this->reCachelist->setValue('is_public', $public ? 1 : 0);
$error = !$this->reCachelist->setValue('name', trim($name));
if ($visibility == 0 || $visibility == 2 || $visibility == 3)
$error |= !$this->reCachelist->setValue('is_public', $visibility);
return $error;
}
// return description in HTML format
@@ -241,7 +245,7 @@ function watch($watch)
{
if ($watch)
{
if ($this->isPublic() || $this->getUserId() == $login->userid)
if ($this->getVisibility() >= 2 || $this->getUserId() == $login->userid)
sql("
INSERT IGNORE INTO `cache_list_watches` (`cache_list_id`, `user_id`)
VALUES ('&1','&2')",
@@ -288,7 +292,7 @@ static function getPublicListCount($namelike='', $userlike='')
FROM `cache_lists`
LEFT JOIN `stat_cache_lists` ON `stat_cache_lists`.`cache_list_id`=`cache_lists`.`id`
LEFT JOIN `user` ON `user`.`user_id`=`cache_lists`.`user_id`
WHERE `is_public` AND `entries`>0"
WHERE `is_public`>=2 AND `entries`>0"
. ($namelike ? " AND `name` LIKE '%" . sql_escape($namelike) ."%'" : '')
. ($userlike ? " AND `username` LIKE '%" . sql_escape($userlike) . "%'" : ''),
0);
@@ -297,7 +301,7 @@ static function getPublicListCount($namelike='', $userlike='')
static function getPublicLists($startat=0, $maxitems=PHP_INT_MAX, $namelike='', $userlike='')
{
return cachelist::getLists(
"`is_public` AND `entries`>0"
"`is_public`>=2 AND `entries`>0"
. ($namelike ? " AND `name` LIKE '%" . sql_escape($namelike) ."%'" : '')
. ($userlike ? " AND `username` LIKE '%" . sql_escape($userlike) . "%'" : ''),
0,
@@ -307,7 +311,7 @@ static function getPublicLists($startat=0, $maxitems=PHP_INT_MAX, $namelike='',
static function getPublicListsOf($userid)
{
return cachelist::getLists("`is_public` AND `entries`>0 AND `cache_lists`.`user_id`='" . sql_escape($userid) . "'");
return cachelist::getLists("`is_public`>=2 AND `entries`>0 AND `cache_lists`.`user_id`='" . sql_escape($userid) . "'");
}
// If $all is false, only own lists and public lists of the cache owner will be returned.
@@ -320,11 +324,8 @@ static function getListsByCacheId($cacheid, $all)
FROM `caches`
WHERE `cache_id`='" . sql_escape($cacheid) . "'",
0);
if (!$all)
{
$my_watches = sql_fetch_column(
sql("SELECT `cache_list_id` FROM `cache_list_watches` WHERE `user_id`='&1'", $login->userid));
}
$my_watches = sql_fetch_column(
sql("SELECT `cache_list_id` FROM `cache_list_watches` WHERE `user_id`='&1'", $login->userid));
return cachelist::getLists("
`id` IN
@@ -333,12 +334,10 @@ static function getListsByCacheId($cacheid, $all)
WHERE `cache_id`='" . sql_escape($cacheid) . "')
AND
(
`cache_lists`.`user_id`='" . sql_escape($login->userid) . "' OR
(`is_public`" .
($all ? "" : "AND
(`cache_lists`.`user_id`='" . sql_escape($cache_owner_id) . "' OR
`id` IN ('" . implode("','", array_map('sql_escape', $my_watches)) . "'))") . "
)
`cache_lists`.`user_id`='" . sql_escape($login->userid) . "' " .
($all ? "OR `is_public`= 3 " : "") .
"OR (`is_public`> 0 AND
`cache_lists`.`id` IN ('" . implode("','", array_map('sql_escape', $my_watches)) . "'))
)",
"`cache_lists`.`user_id`<>'" . sql_escape($cache_owner_id) . "'");
}
@@ -359,18 +358,18 @@ private function getLists($condition, $prio=0, $startat=0, $maxitems=PHP_INT_MAX
$rs = sql("
SELECT `cache_lists`.`id`, `cache_lists`.`user_id`, `user`.`username`,
`cache_lists`.`name`, `cache_lists`.`is_public`,
`cache_lists`.`name`, `cache_lists`.`is_public` `visibility`,
`cache_lists`.`description`, `cache_lists`.`desc_htmledit`,
`cache_lists`.`user_id`='&1' `own_list`,
`stat_cache_lists`.`entries`, `stat_cache_lists`.`watchers`,
`w`.`user_id` IS NOT NULL `watched_by_me`,
$prio AS `prio`
$prio `prio`
FROM `cache_lists`
LEFT JOIN `stat_cache_lists` ON `stat_cache_lists`.`cache_list_id`=`cache_lists`.`id`
LEFT JOIN `user` ON `user`.`user_id`=`cache_lists`.`user_id`
LEFT JOIN `cache_list_watches` `w` ON `w`.`cache_list_id`=`cache_lists`.`id` AND `w`.`user_id`='&1'
WHERE $condition
ORDER BY `prio`, `name`
ORDER BY `prio`,`cache_lists`.`name`
LIMIT &2,&3",
$login->userid, $startat, $maxitems);
return sql_fetch_assoc_table($rs);
@@ -16,7 +16,7 @@
$tpl->redirect('login.php?target=' . urlencode($tpl->target));
$list_name = isset($_REQUEST['list_name']) ? trim($_REQUEST['list_name']) : '';
$list_public = isset($_REQUEST['list_public']) ? $_REQUEST['list_public'] + 0 : 0;
$list_visibility = isset($_REQUEST['list_visibility']) ? $_REQUEST['list_visibility'] + 0 : 0;
$list_caches = isset($_REQUEST['list_caches']) ? strtoupper(trim($_REQUEST['list_caches'])) : '';
$watch = isset($_REQUEST['watch']);
$desctext = isset($_REQUEST['desctext']) ? $_REQUEST['desctext'] : '';
@@ -33,7 +33,7 @@
$tpl->assign('newlist_mode', true);
$tpl->assign('show_editor', false);
$list_name = '';
$list_public = false;
$list_visibility = 0;
$watch = false;
$desctext = '';
// keep descMode of previous operation
@@ -44,7 +44,7 @@
if (isset($_REQUEST['create']))
{
$list = new cachelist(ID_NEW, $login->userid);
$name_error = $list->setNameAndPublic($list_name, $list_public);
$name_error = $list->setNameAndVisibility($list_name, $list_visibility);
if ($name_error)
$tpl->assign('newlist_mode', true);
else
@@ -71,7 +71,7 @@
{
$edit_list = true;
$list_name = $list->getName();
$list_public = $list->isPublic();
$list_visibility = $list->getVisibility();
$watch = $list->isWatchedByMe();
$desctext = $list->getDescription();
$descMode = $list->getDescHtmledit() ? 3 : 2;
@@ -106,7 +106,7 @@
$list = new cachelist($_REQUEST['listid'] + 0);
if ($list->exist() && $list->getUserId() == $login->userid)
{
$name_error = $list->setNameAndPublic($list_name, $list_public);
$name_error = $list->setNameAndVisibility($list_name, $list_visibility);
if ($name_error)
$edit_list = true;
$list->setDescription($desctext, $descMode == 3);
@@ -134,7 +134,7 @@
}
// redirect to list search output after editing a list from the search output page
if ($fromsearch && !$switchDescMode && isset($_REQUEST['listid']))
if ($fromsearch && !$switchDescMode && !$name_error && isset($_REQUEST['listid']))
{
$tpl->redirect('cachelist.php?id=' . ($_REQUEST['listid'] + 0));
}
@@ -163,7 +163,7 @@
$tpl->assign('name_error', $name_error);
$tpl->assign('list_name', $list_name);
$tpl->assign('list_public', $list_public);
$tpl->assign('list_visibility', $list_visibility);
$tpl->assign('watch', $watch);
$tpl->assign('desctext', $desctext);
$tpl->assign('descMode', $descMode);
@@ -260,7 +260,7 @@ div.tplhelp

.nav4 li.hilite a { background-color:#ffb9b5 !important; }

.nav4 li {float: left; list-style: none; margin: 0px; padding: 2px 0 5px 0; }
.nav4 li {float: left; list-style: none; margin: 0px; padding: 2px 0 3px 0; }
.nav4 li.title {display: none; margin: 0px 0px 0px 0px; padding: 3px 5px 2px 5px; background-color: rgb(156,186,214); color: rgb(255,255,255); text-transform: uppercase; font-weight: bold; font-size: 120%;}
.nav4 li.group a {background-color: rgb(219,230,241);display: block; min-height: 1.7em; height: auto !important; height: 1.7em; line-height: 1.7em; margin: 0px; margin-right: 3px; padding: 0px 7px 0px 20px; border-left: solid 7px rgb(219,230,241); color: rgb(75,75,75); font-weight: bold; font-size: 100%;}
.nav4 li.group_active a {border-left: solid 7px rgb(156,186,214); background-color: rgb(156,186,214);}
@@ -983,7 +983,7 @@
SELECT `cache_id` FROM `cache_list_items`
LEFT JOIN `cache_lists` ON `cache_lists`.`id`=`cache_list_items`.`cache_list_id`
WHERE `cache_list_id`=" . sql_escape($options['listid']) . "
AND (`is_public` OR `cache_lists`.`user_id`=" . sql_escape($login->userid) . ")";
AND (`is_public`>=2 OR `cache_lists`.`user_id`=" . sql_escape($login->userid) . ")";
sql_slave($cachesFilter);
sql_slave('ALTER TABLE &result_caches ADD PRIMARY KEY ( `cache_id` )');
@@ -21,29 +21,29 @@
</p>

<p style="margin-left:16px">
<input type="radio" id="newlist" name="listid" value="0" {if $default_list==0}checked="checked"{/if} />
<input type="radio" class="radio" id="newlist" name="listid" value="0" {if $default_list==0}checked="checked"{/if} />
<input type="text" name="newlist_name" maxlength="80" class="input400" value="{if $newlist_name !== false}{$newlist_name}{else}{t}New cache list{/t}{/if}" onfocus="if (this.value == '{t}New cache list{/t}') this.value=''; newlist.checked=1;" onblur="if (this.value == '') this.value = '{t}New cache list{/t}';" />
{if $name_error}<span class="errormsg">{t}Invalid name{/t}</span>{/if}
&nbsp;
<input type="checkbox" id="newlist_public" name="newlist_public" value="1" {if $newlist_public}checked="checked"{/if} /> <label for="newlist_public">{t}public list{/t}</label>
<input type="checkbox" class="checkbox" id="newlist_public" name="newlist_public" value="1" {if $newlist_public}checked="checked"{/if} /> <label for="newlist_public">{t}public list{/t}</label>
&nbsp;
<input type="checkbox" id="newlist_watch" name="newlist_watch" value="1" {if $newlist_watch}checked="checked"{/if} /> <label for="newlist_watch">{t}watch{/t}</label>
<input type="checkbox" class="checkbox" id="newlist_watch" name="newlist_watch" value="1" {if $newlist_watch}checked="checked"{/if} /> <label for="newlist_watch">{t}watch{/t}</label>
{if $name_error}<br /><div style="margin-left:42px"><p class="errormsg">{if $name_error==ERROR_DUPLICATE_LISTNAME}{t}Another of your cache lists already has this name.{/t}{else}{if $name_error==ERROR_BAD_LISTNAME}{t}Invalid name{/t}{if $newlist_public}; {t}minimum length for public lists is 10 characters{/t}{/if}{/if}{/if}</p></div>{/if}
</p>

<p style="margin-left:16px">
<span class="radiolist">
{foreach from=$cachelists item=cachelist}
<input type="radio" id="list{$cachelist.id}" name="listid" value="{$cachelist.id}" {if $default_list==$cachelist.id}checked="checked"{/if} />
<input type="radio" class="radio" id="list{$cachelist.id}" name="listid" value="{$cachelist.id}" {if $default_list==$cachelist.id}checked="checked"{/if} />
<label for="list{$cachelist.id}">{$cachelist.name|escape}
&nbsp;<span class="greytext">({if $cachelist.is_public}{t}public{/t}{else}{t}private{/t}{/if})</span></label>
&nbsp;<span class="greytext">({if $cachelist.visibility<2}{t}private{/t}{else}{t}public{/t}{if $cachelist.visibility==3} + {t}listing display{/t}{/if}{/if})</span></label>
<br />
{/foreach}
</span>
</p>

<p>
<br />
{t}You can maintain your personal cache lists in your <a href="mylists.php">user profile</a>.{/t} {t 1=$login.userid}Public lists are displayed in your <a href="viewprofile.php?userid=%1">public user profile</a>, on the <a href="cachelists.php">lists overwiew page</a> and in the cache listings.{/t}<br />
{t}You can maintain your personal cache lists in your <a href="mylists.php">user profile</a>.{/t} {t 1=$login.userid}Public lists are displayed in your <a href="viewprofile.php?userid=%1">public user profile</a>, on the <a href="cachelists.php">lists overwiew page</a> and (if enabled) in the cache listings.{/t}<br />
<br />
</p>

Oops, something went wrong.

0 comments on commit 3110708

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