aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php2
-rw-r--r--include/socgraph.php28
-rw-r--r--install/database.sql4
-rw-r--r--install/update.php10
-rw-r--r--mod/poco.php11
5 files changed, 52 insertions, 3 deletions
diff --git a/boot.php b/boot.php
index 381f1eea0..c37bd57b9 100755
--- a/boot.php
+++ b/boot.php
@@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1100 );
+define ( 'DB_UPDATE_VERSION', 1101 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/include/socgraph.php b/include/socgraph.php
index 0e91eba60..2bd0290cc 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -64,6 +64,34 @@ function poco_load($xchan = '',$url = null) {
logger('poco_load: ' . print_r($j,true),LOGGER_DATA);
+ if($xchan) {
+ if(array_key_exists('chatrooms',$j) && is_array($j['chatrooms'])) {
+ foreach($j['chatrooms'] as $room) {
+ $r = q("select * from xchat where xchat_url = '%s' and xchat_xchan = '%s' limit 1",
+ dbesc($room['url'])
+ );
+ if($r) {
+ q("update xchat set xchat_edited = '%s' where xchat_id = %d limit 1",
+ dbesc(datetime_convert()),
+ intval($r[0]['xchat_id'])
+ );
+ }
+ else {
+ $x = q("insert into xchat ( xchat_url, xchat_desc, xchat_xchan, xchat_edited )
+ values ( '%s', '%s', '%s', '%s' ) ",
+ dbesc(escape_tags($room['url'])),
+ dbesc(escape_tags($room['desc'])),
+ dbesc($xchan),
+ dbesc(datetime_convert())
+ );
+ }
+ }
+ }
+ q("delete from xchat where xchat_edited < UTC_TIMESTAMP() - INTERVAL 7 DAY and xchat_xchan = '%s' ",
+ dbesc($xchan)
+ );
+ }
+
if(! ((x($j,'entry')) && (is_array($j['entry'])))) {
logger('poco_load: no entries');
return;
diff --git a/install/database.sql b/install/database.sql
index 5d00afb03..2c8bc50c7 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -1032,10 +1032,12 @@ CREATE TABLE IF NOT EXISTS `xchat` (
`xchat_url` char(255) NOT NULL DEFAULT '',
`xchat_desc` char(255) NOT NULL DEFAULT '',
`xchat_xchan` char(255) NOT NULL DEFAULT '',
+ `xchat_edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'
PRIMARY KEY (`xchat_id`),
KEY `xchat_url` (`xchat_url`),
KEY `xchat_desc` (`xchat_desc`),
- KEY `xchat_xchan` (`xchat_xchan`)
+ KEY `xchat_xchan` (`xchat_xchan`),
+ KEY `xchat_edited` (`xchat_edited`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `xconfig` (
diff --git a/install/update.php b/install/update.php
index 8612e7354..9c9b6129a 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1100 );
+define( 'UPDATE_VERSION' , 1101 );
/**
*
@@ -1136,3 +1136,11 @@ function update_r1099() {
return UPDATE_FAILED;
}
+function update_r1100() {
+ $r = q("ALTER TABLE `xchat` ADD `xchat_edited` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+ADD INDEX ( `xchat_edited` ) ");
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}
+ \ No newline at end of file
diff --git a/mod/poco.php b/mod/poco.php
index a5808b7db..9295f13de 100644
--- a/mod/poco.php
+++ b/mod/poco.php
@@ -76,6 +76,9 @@ function poco_init(&$a) {
$sql_extra ",
intval($channel_id)
);
+ $c = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " ) and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d",
+ intval($channel_id)
+ );
}
if($r)
$totalResults = intval($r[0]['total']);
@@ -115,6 +118,14 @@ function poco_init(&$a) {
$ret['startIndex'] = (string) $startIndex;
$ret['itemsPerPage'] = (string) $itemsPerPage;
$ret['totalResults'] = (string) $totalResults;
+
+ if($c) {
+ $ret['chatrooms'] = array();
+ foreach($c as $d) {
+ $ret['chatrooms'][] = array('url' => $d['mitem_link'], 'desc' => $d['mitem_desc']);
+ }
+ }
+
$ret['entry'] = array();