aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php4
-rw-r--r--database.sql1
-rw-r--r--include/items.php6
-rw-r--r--mod/item.php11
-rw-r--r--mod/network.php112
-rw-r--r--update.php19
6 files changed, 66 insertions, 87 deletions
diff --git a/boot.php b/boot.php
index 6e78b21f6..226bc3d01 100644
--- a/boot.php
+++ b/boot.php
@@ -7,9 +7,9 @@ require_once('include/text.php');
require_once("include/pgettext.php");
-define ( 'FRIENDIKA_VERSION', '2.2.1107' );
+define ( 'FRIENDIKA_VERSION', '2.3.1108' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
-define ( 'DB_UPDATE_VERSION', 1087 );
+define ( 'DB_UPDATE_VERSION', 1088 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/database.sql b/database.sql
index ff339929e..444b05faa 100644
--- a/database.sql
+++ b/database.sql
@@ -174,6 +174,7 @@ CREATE TABLE IF NOT EXISTS `item` (
`thr-parent` char(255) NOT NULL,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`owner-name` char(255) NOT NULL,
diff --git a/include/items.php b/include/items.php
index 735adc717..b433381a7 100644
--- a/include/items.php
+++ b/include/items.php
@@ -717,6 +717,7 @@ function item_store($arr,$force_parent = false) {
$arr['owner-avatar'] = ((x($arr,'owner-avatar')) ? notags(trim($arr['owner-avatar'])) : '');
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
+ $arr['commented'] = datetime_convert();
$arr['received'] = datetime_convert();
$arr['changed'] = datetime_convert();
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
@@ -865,9 +866,10 @@ function item_store($arr,$force_parent = false) {
intval($current_post)
);
- // update the timestamp on the parent
+ // update the commented timestamp on the parent
- q("UPDATE `item` set `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($parent_id)
);
diff --git a/mod/item.php b/mod/item.php
index 38f4c2040..cad72122b 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -501,6 +501,7 @@ function item_post(&$a) {
$datarray['author-avatar'] = $author['thumb'];
$datarray['created'] = datetime_convert();
$datarray['edited'] = datetime_convert();
+ $datarray['commented'] = datetime_convert();
$datarray['received'] = datetime_convert();
$datarray['changed'] = datetime_convert();
$datarray['uri'] = $uri;
@@ -561,9 +562,9 @@ function item_post(&$a) {
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
- `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
+ `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
`tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark` )
- VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d )",
+ VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d )",
dbesc($datarray['guid']),
intval($datarray['uid']),
dbesc($datarray['type']),
@@ -578,6 +579,7 @@ function item_post(&$a) {
dbesc($datarray['author-avatar']),
dbesc($datarray['created']),
dbesc($datarray['edited']),
+ dbesc($datarray['commented']),
dbesc($datarray['received']),
dbesc($datarray['changed']),
dbesc($datarray['uri']),
@@ -803,9 +805,10 @@ function item_post(&$a) {
// NOTREACHED
}
- // update the timestamp on the parent
+ // update the commented timestamp on the parent
- q("UPDATE `item` set `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($parent)
);
diff --git a/mod/network.php b/mod/network.php
index 438b3417d..5faeee453 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -315,44 +315,27 @@ function network_content(&$a, $update = 0) {
else {
// Normal conversation view
- // Show conversation by activity date
- if($order === 'post') {
- $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` = `item`.`id`
- $sql_extra
- ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
- intval(local_user()),
- intval($a->pager['start']),
- intval($a->pager['itemspage'])
- );
- }
- else {
- // $order === 'comment'
- // First fetch a known number of parent items
-
- $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- , (SELECT `_com`.`parent`,max(`_com`.`created`) as `created`
- FROM `item` AS `_com`
- WHERE `_com`.`uid`=%d AND
- (`_com`.`parent`!=`_com`.`id` OR `_com`.`id` NOT IN (SELECT `__com`.`parent` FROM `item` as `__com` WHERE `__com`.`parent`!=`__com`.`id`))
- GROUP BY `_com`.`parent` ORDER BY `created` DESC) AS `com`
- WHERE `item`.`id`=`com`.`parent` AND
- `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- $sql_extra
- ORDER BY `com`.`created` DESC LIMIT %d ,%d ",
- intval(local_user()),
- intval(local_user()),
- intval($a->pager['start']),
- intval($a->pager['itemspage'])
- );
- }
+ if($order === 'post')
+ $ordering = "`created`";
+ else
+ $ordering = "`commented`";
+
+ // Fetch a page full of parent items for this page
+
+ $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
+ FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`parent` = `item`.`id`
+ $sql_extra
+ ORDER BY `item`.$ordering DESC LIMIT %d ,%d ",
+ intval(local_user()),
+ intval($a->pager['start']),
+ intval($a->pager['itemspage'])
+ );
+
// Then fetch all the children of the parents that are on this page
$parents_arr = array();
@@ -363,48 +346,21 @@ function network_content(&$a, $update = 0) {
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
- if($order === 'post') {
- // parent created order
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )
- $sql_extra
- ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC ",
- intval(local_user()),
- dbesc($parents_str)
- );
- }
- else {
- // $order === 'comment'
-
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, `contact`,
- (SELECT `_com`.`parent`,max(`_com`.`created`) as `created`
- FROM `item` AS `_com`
- WHERE `_com`.`uid`=%d AND
- (`_com`.`parent`!=`_com`.`id` OR `_com`.`id` NOT IN (SELECT `__com`.`parent` FROM `item` as `__com` WHERE `__com`.`parent`!=`__com`.`id`))
- GROUP BY `_com`.`parent` ORDER BY `created` DESC) AS `com`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` = `com`.`parent` AND `item`.`parent` IN ( %s )
- $sql_extra
- ORDER BY `com`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC ",
- intval(local_user()),
- intval(local_user()),
- dbesc($parents_str)
- );
- }
- }
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
+ `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ FROM `item`, (SELECT `p`.`id`,`p`.`created`,`p`.`commented` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact`
+ WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ AND `contact`.`id` = `item`.`contact-id`
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )
+ $sql_extra
+ ORDER BY `parentitem`.$ordering DESC, `item`.`gravity` ASC, `item`.`created` ASC ",
+ intval(local_user()),
+ dbesc($parents_str)
+ );
+ }
}
// Set this so that the conversation function can find out contact info for our wall-wall items
diff --git a/update.php b/update.php
index f94e78d72..82ae05872 100644
--- a/update.php
+++ b/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1087 );
+define( 'UPDATE_VERSION' , 1088 );
/**
*
@@ -726,3 +726,20 @@ function update_1086() {
q("ALTER TABLE `item` ADD `bookmark` tinyint(1) NOT NULL DEFAULT '0' AFTER `starred` ");
}
+function update_1087() {
+ q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
+
+ $r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
+ intval($rr['id'])
+ );
+ if(count($x))
+ q("UPDATE `item` SET `commented` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc($x[0]['cdate']),
+ intval($rr['id'])
+ );
+ }
+ }
+}