aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2011-12-12 20:13:12 -0800
committerfriendica <info@friendica.com>2011-12-12 20:13:12 -0800
commited725df5f1c1ea2484c689283e93f8f825591384 (patch)
tree289183e66da097acfeaeb0c7bfe9099a87a5a86a /mod
parent50c4b9a7803c08d6e41fc64ca3ffeb66c7f450ba (diff)
parentee4975f1cd9f205e2300f3e22e51079c5e26f155 (diff)
downloadvolse-hubzilla-ed725df5f1c1ea2484c689283e93f8f825591384.tar.gz
volse-hubzilla-ed725df5f1c1ea2484c689283e93f8f825591384.tar.bz2
volse-hubzilla-ed725df5f1c1ea2484c689283e93f8f825591384.zip
Merge branch 'master' into notify
Diffstat (limited to 'mod')
-rw-r--r--mod/dfrn_request.php32
-rw-r--r--mod/network.php96
-rw-r--r--mod/profile.php80
-rw-r--r--mod/settings.php14
4 files changed, 149 insertions, 73 deletions
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index 9755895ce..d7c918490 100644
--- a/mod/dfrn_request.php
+++ b/mod/dfrn_request.php
@@ -252,12 +252,41 @@ function dfrn_request_post(&$a) {
*
* Cleanup old introductions that remain blocked.
* Also remove the contact record, but only if there is no existing relationship
+ * Do not remove email contacts as these may be awaiting email verification
+ */
+
+ $r = q("SELECT `intro`.*, `intro`.`id` AS `iid`, `contact`.`id` AS `cid`, `contact`.`rel`
+ FROM `intro` LEFT JOIN `contact` on `intro`.`contact-id` = `contact`.`id`
+ WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
+ AND `contact`.`network` != '%s'
+ AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ",
+ dbesc(NETWORK_MAIL)
+ );
+ if(count($r)) {
+ foreach($r as $rr) {
+ if(! $rr['rel']) {
+ q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
+ intval($rr['cid'])
+ );
+ }
+ q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1",
+ intval($rr['iid'])
+ );
+ }
+ }
+
+ /**
*
+ * Cleanup any old email intros - which will have a greater lifetime
*/
$r = q("SELECT `intro`.*, `intro`.`id` AS `iid`, `contact`.`id` AS `cid`, `contact`.`rel`
FROM `intro` LEFT JOIN `contact` on `intro`.`contact-id` = `contact`.`id`
- WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ");
+ WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
+ AND `contact`.`network` = '%s'
+ AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ",
+ dbesc(NETWORK_MAIL)
+ );
if(count($r)) {
foreach($r as $rr) {
if(! $rr['rel']) {
@@ -271,6 +300,7 @@ function dfrn_request_post(&$a) {
}
}
+
$url = trim($_POST['dfrn_url']);
if(! strlen($url)) {
notice( t("Invalid locator") . EOL );
diff --git a/mod/network.php b/mod/network.php
index 3df8a2105..e9e761c3f 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -266,16 +266,6 @@ function network_content(&$a, $update = 0) {
}
- // We aren't going to try and figure out at the item, group, and page
- // level which items you've seen and which you haven't. If you're looking
- // at the top level network page just mark everything seen.
-
- if((! $group) && (! $cid) && (! $star)) {
- $r = q("UPDATE `item` SET `unseen` = 0
- WHERE `unseen` = 1 AND `uid` = %d",
- intval($_SESSION['uid'])
- );
- }
// We don't have to deal with ACL's on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if
@@ -382,21 +372,30 @@ function network_content(&$a, $update = 0) {
}
+ if($update) {
- $r = q("SELECT COUNT(*) AS `total`
- 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
- $sql_extra2
- $sql_extra ",
- intval($_SESSION['uid'])
- );
+ // only setup pagination on initial page view
+ $pager_sql = '';
- if(count($r)) {
- $a->set_pager_total($r[0]['total']);
- $a->set_pager_itemspage(40);
+ }
+ else {
+ $r = q("SELECT COUNT(*) AS `total`
+ 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
+ $sql_extra2
+ $sql_extra ",
+ intval($_SESSION['uid'])
+ );
+
+ if(count($r)) {
+ $a->set_pager_total($r[0]['total']);
+ $a->set_pager_itemspage(40);
+ }
+ $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
}
+ $simple_update = (($update) ? " and `item`.`unseen` = 1 " : '');
if($nouveau) {
@@ -408,13 +407,12 @@ function network_content(&$a, $update = 0) {
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ $simple_update
AND `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra
- ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
- intval($_SESSION['uid']),
- intval($a->pager['start']),
- intval($a->pager['itemspage'])
+ ORDER BY `item`.`received` DESC $pager_sql ",
+ intval($_SESSION['uid'])
);
}
@@ -430,17 +428,27 @@ function network_content(&$a, $update = 0) {
// 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'])
- );
+ if($update) {
+ $r = q("SELECT distinct(`parent`) 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 `item`.`parent` in ( select parent from item where unseen = 1 )
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ $sql_extra ",
+ intval(local_user())
+ );
+ }
+ else {
+ $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 $pager_sql ",
+ intval(local_user())
+ );
+ }
// Then fetch all the children of the parents that are on this page
@@ -452,7 +460,7 @@ function network_content(&$a, $update = 0) {
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ $items = 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`
@@ -469,12 +477,24 @@ function network_content(&$a, $update = 0) {
}
}
+
+ // We aren't going to try and figure out at the item, group, and page
+ // level which items you've seen and which you haven't. If you're looking
+ // at the top level network page just mark everything seen.
+
+ if((! $group) && (! $cid) && (! $star)) {
+ $r = q("UPDATE `item` SET `unseen` = 0
+ WHERE `unseen` = 1 AND `uid` = %d",
+ intval(local_user())
+ );
+ }
+
// Set this so that the conversation function can find out contact info for our wall-wall items
$a->page_contact = $a->contact;
$mode = (($nouveau) ? 'network-new' : 'network');
- $o .= conversation($a,$r,$mode,$update);
+ $o .= conversation($a,$items,$mode,$update);
if(! $update) {
$o .= paginate($a);
diff --git a/mod/profile.php b/mod/profile.php
index 47312fdb6..a619703c6 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -154,12 +154,6 @@ function profile_content(&$a, $update = 0) {
}
- if($is_owner) {
- $r = q("UPDATE `item` SET `unseen` = 0
- WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
- intval(local_user())
- );
- }
/**
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
@@ -168,33 +162,49 @@ function profile_content(&$a, $update = 0) {
$sql_extra = permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
- $r = q("SELECT COUNT(*) AS `total`
- 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`.`id` = `item`.`parent` AND `item`.`wall` = 1
- $sql_extra ",
- intval($a->profile['profile_uid'])
+ if($update) {
- );
+ $r = q("SELECT distinct(parent) 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 `item`.`parent` in (select parent from item where unseen = 1 )
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`wall` = 1
+ $sql_extra
+ ORDER BY `item`.`created` DESC",
+ intval($a->profile['profile_uid'])
+ );
- if(count($r)) {
- $a->set_pager_total($r[0]['total']);
- $a->set_pager_itemspage(40);
}
+ else {
+
+ $r = q("SELECT COUNT(*) AS `total`
+ 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`.`id` = `item`.`parent` AND `item`.`wall` = 1
+ $sql_extra ",
+ intval($a->profile['profile_uid'])
+ );
- $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`.`id` = `item`.`parent` AND `item`.`wall` = 1
- $sql_extra
- ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
- intval($a->profile['profile_uid']),
- intval($a->pager['start']),
- intval($a->pager['itemspage'])
+ if(count($r)) {
+ $a->set_pager_total($r[0]['total']);
+ $a->set_pager_itemspage(40);
+ }
+
+ $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
- );
+ $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`.`id` = `item`.`parent` AND `item`.`wall` = 1
+ $sql_extra
+ ORDER BY `item`.`created` DESC $pager_sql ",
+ intval($a->profile['profile_uid'])
+
+ );
+ }
$parents_arr = array();
$parents_str = '';
@@ -204,7 +214,7 @@ function profile_content(&$a, $update = 0) {
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`,
`contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
@@ -232,10 +242,18 @@ function profile_content(&$a, $update = 0) {
$o .= '<div id="live-profile"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . $a->profile['profile_uid']
- . "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ }
+
+
+ if($is_owner) {
+ $r = q("UPDATE `item` SET `unseen` = 0
+ WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
+ intval(local_user())
+ );
}
- $o .= conversation($a,$r,'profile',$update);
+ $o .= conversation($a,$items,'profile',$update);
if(! $update) {
$o .= paginate($a);
diff --git a/mod/settings.php b/mod/settings.php
index 3f5e0f2ed..ad22ba1a6 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -223,7 +223,12 @@ function settings_post(&$a) {
$expire_notes = ((x($_POST,'expire_notes')) ? intval($_POST['expire_notes']) : 0);
$expire_starred = ((x($_POST,'expire_starred')) ? intval($_POST['expire_starred']) : 0);
$expire_photos = ((x($_POST,'expire_photos'))? intval($_POST['expire_photos']) : 0);
-
+
+ $browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0);
+ $browser_update = $browser_update * 1000;
+ if($browser_update < 10000)
+ $browser_update = 40000;
+
$allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
$publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
@@ -313,6 +318,7 @@ function settings_post(&$a) {
set_pconfig(local_user(),'expire','photos', $expire_photos);
set_pconfig(local_user(),'system','suggestme', $suggestme);
+ set_pconfig(local_user(),'system','update_interval', $browser_update);
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d WHERE `uid` = %d LIMIT 1",
dbesc($username),
@@ -618,6 +624,9 @@ function settings_content(&$a) {
$suggestme = get_pconfig(local_user(), 'system','suggestme');
$suggestme = (($suggestme===false)?0:$suggestme); // default if not set: 0
+
+ $browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
+ $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
if(! strlen($a->user['timezone']))
$timezone = date_default_timezone_get();
@@ -770,8 +779,7 @@ function settings_content(&$a) {
'$defloc' => array('defloc', t('Default Post Location:'), $defloc, ''),
'$allowloc' => array('allow_location', t('Use Browser Location:'), ($a->user['allow_location'] == 1), ''),
'$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes),
-
-
+ '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')),
'$h_prv' => t('Security and Privacy Settings'),