Permalink
Browse files

Keuze tussen AutoMarkAsRead & oude gedrag

  • Loading branch information...
1 parent d5468cc commit 5433521499229b87abe37900d78e51f301dd51a3 nightspirit81 committed Apr 27, 2011
Showing with 26 additions and 3 deletions.
  1. +5 −2 lib/SpotDb.php
  2. +10 −0 lib/SpotUserSystem.php
  3. +2 −1 lib/SpotsOverview.php
  4. +5 −0 lib/dbstruct/SpotStruct_abs.php
  5. +1 −0 lib/page/SpotPage_markallasread.php
  6. +3 −0 settings.php
View
@@ -191,6 +191,7 @@ function getUser($userid) {
u.deleted AS deleted,
u.lastlogin AS lastlogin,
u.lastvisit AS lastvisit,
+ u.lastseen AS lastseen,
s.publickey AS publickey,
s.otherprefs AS prefs
FROM users AS u
@@ -231,13 +232,15 @@ function setUser($user) {
mail = '%s',
lastlogin = %d,
lastvisit = %d,
+ lastseen = %d,
deleted = '%s'
WHERE id = '%s'",
Array($user['firstname'],
$user['lastname'],
$user['mail'],
(int) $user['lastlogin'],
(int) $user['lastvisit'],
+ (int) $user['lastseen'],
$user['deleted'],
(int) $user['userid']));
@@ -281,8 +284,8 @@ function getUserPrivateRsaKey($userId) {
* Voeg een user toe
*/
function addUser($user) {
- $this->_conn->exec("INSERT INTO users(username, firstname, lastname, passhash, mail, lastlogin, lastvisit, deleted)
- VALUES('%s', '%s', '%s', '%s', '%s', 0, 0, 'false')",
+ $this->_conn->exec("INSERT INTO users(username, firstname, lastname, passhash, mail, lastlogin, lastvisit, lastseen, deleted)
+ VALUES('%s', '%s', '%s', '%s', '%s', 0, 0, 0, 'false')",
Array($user['username'],
$user['firstname'],
$user['lastname'],
@@ -142,6 +142,16 @@ function resetLastVisit($user) {
} # resetLastVisit
/*
+ * Reset the seenstamp timestamp
+ */
+ function resetSeenStamp($user) {
+ $user['lastseen'] = $this->_db->getMaxMessageTime();
+ $this->_db->setUser($user);
+
+ return $user;
+ } # resetSeenStamp
+
+ /*
* Clear the seen list
*/
function clearSeenList($user) {
@@ -450,7 +450,8 @@ function filterToQuery($search, $currentSession) {
# New spots
if (isset($search['filterValues']['New'])) {
- $newSpotsSearchTmp[] = '(s.stamp > ' . (int) $this->_db->safe($currentSession['user']['lastvisit']) . ')';
+ $newerThan = ($this->_settings->get('auto_markasread')) ? $currentSession['user']['lastvisit'] : $currentSession['user']['lastseen'];
+ $newSpotsSearchTmp[] = '(s.stamp > ' . (int) $this->_db->safe($newerThan) . ')';
$newSpotsSearchTmp[] = '(c.stamp IS NULL)';
$newSpotsSearch = join(' AND ', $newSpotsSearchTmp);
} # if
@@ -306,6 +306,7 @@ function updateSchema() {
$this->addColumn('mail', 'users', "VARCHAR(128) DEFAULT '' NOT NULL");
$this->addColumn('lastlogin', 'users', "INTEGER DEFAULT 0 NOT NULl");
$this->addColumn('lastvisit', 'users', "INTEGER DEFAULT 0 NOT NULL");
+ $this->addColumn('lastseen', 'users', "INTEGER DEFAULT 0 NOT NULL");
$this->addColumn('deleted', 'users', "BOOLEAN DEFAULT 0 NOT NULL");
$this->addIndex("idx_users_1", "UNIQUE", "users", "username");
@@ -405,6 +406,10 @@ function updateSchema() {
$this->addIndex("idx_seenlist_1", "UNIQUE", "seenlist", "messageid,ouruserid");
}
+ if ($this->_spotdb->getSchemaVer() < 0.18) {
+ $this->addColumn('lastseen', 'users', "INTEGER DEFAULT 0 NOT NULL");
+ }
+
# voeg het database schema versie nummer toe
$this->_spotdb->updateSetting('schemaversion', SPOTDB_SCHEMA_VERSION, false);
} # updateSchema
@@ -6,6 +6,7 @@ function render() {
$spotUserSystem = new SpotUserSystem($this->_db, $this->_settings);
$spotUserSystem->clearSeenList($this->_currentSession['user']);
$spotUserSystem->resetLastVisit($this->_currentSession['user']);
+ $spotUserSystem->resetSeenStamp($this->_currentSession['user']);
echo "<xml><return>ok</return></xml>";
} # render()
View
@@ -195,6 +195,9 @@
# Doet niets als count_newspots op false staat
$settings['keep_seenlist'] = true;
+# Moeten spots automatisch na elke visit als gelezen worden gemarkeerd?
+$settings['auto_markasread'] = true;
+
# toon het aantal comments op een spot in het overzicht? Kan vertragend werken, uitzetten op trage systemen!
$settings['count_comments'] = true;

0 comments on commit 5433521

Please sign in to comment.