diff --git a/database.sql b/database.sql index cfe0df9d2..6b8b1281b 100644 --- a/database.sql +++ b/database.sql @@ -204,6 +204,7 @@ CREATE TABLE IF NOT EXISTS `mail` ( CREATE TABLE IF NOT EXISTS `photo` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, + `contact-id` int(10) unsigned NOT NULL, `resource-id` char(255) NOT NULL, `created` datetime NOT NULL, `edited` datetime NOT NULL, diff --git a/include/poller.php b/include/poller.php index dad50ab9a..e0b4d79b2 100644 --- a/include/poller.php +++ b/include/poller.php @@ -17,7 +17,7 @@ require_once('include/items.php'); if($argc < 2) exit; - +dbg(3); $a->set_baseurl($argv[1]); $contacts = q("SELECT * FROM `contact` WHERE `dfrn-id` != '' AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()"); @@ -27,6 +27,39 @@ if($argc < 2) foreach($contacts as $contact) { + if($contact['priority']) { + + $update = false; + $t = $contact['last-update']; + + switch ($contact['priority']) { + case 5: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 month")) + $update = true; + break; + case 4: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 week")) + $update = true; + break; + case 3: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 day")) + $update = true; + break; + case 2: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 12 hour")) + $update = true; + break; + case 1: + default: + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 hour")) + $update = true; + break; + } + if(! $update) + continue; + } + + $importer_uid = $contact['uid']; $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", @@ -44,7 +77,8 @@ if($argc < 2) $url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update ; $xml = fetch_url($url); - +echo "URL: " . $url; +echo "XML: " . $xml; if(! $xml) continue; @@ -61,12 +95,19 @@ if($argc < 2) openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); $xml = post_url($contact['poll'],$postvars); - if(! strlen($xml)) - continue; echo "XML response:" . $xml . "\r\n"; echo "Length:" . strlen($xml) . "\r\n"; + if(! strlen($xml)) { + // an empty response may mean there's nothing new - record the fact that we checked + $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($contact['id']) + ); + continue; + } + $feed = new SimplePie(); $feed->set_raw_data($xml); $feed->enable_order_by_date(false); diff --git a/mod/contacts.php b/mod/contacts.php index 1e3cb8f06..c1b3781bf 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -40,15 +40,20 @@ function contacts_post(&$a) { return; } } + $priority = intval($_POST['priority']); + if($priority > 5 || $priority < 0) + $priority = 0; + $rating = intval($_POST['reputation']); if($rating > 5 || $rating < 0) $rating = 0; $reason = notags(trim($_POST['reason'])); - $r = q("UPDATE `contact` SET `profile-id` = %d, `rating` = %d, `reason` = '%s' + $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `rating` = %d, `reason` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($profile_id), + intval($priority), intval($rating), dbesc($reason), intval($contact_id), @@ -91,12 +96,6 @@ function contacts_content(&$a) { } -// $photo = str_replace('-4.jpg', '' , $r[0]['photo']); -// $photos = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d", -// dbesc($photo), -// intval($_SESSION['uid']) -// ); - if($cmd == 'block') { $blocked = (($orig_record[0]['blocked']) ? 0 : 1); $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -130,19 +129,18 @@ function contacts_content(&$a) { if($cmd == 'drop') { $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), - intval($_SESSION['uid'])); + intval($_SESSION['uid']) + ); -// if(count($photos)) { -// foreach($photos as $p) { -// q("DELETE FROM `photos` WHERE `id` = %d LIMIT 1", -// $p['id']); -// } -// } - - if(intval($contact_id)) - q("DELETE FROM `item` WHERE `contact-id` = %d LIMIT 1", - intval($contact_id) - ); + q("DELETE FROM `item` WHERE `contact-id` = %d AND `uid` = %d ", + intval($contact_id), + intval($_SESSION['uid']) + ); + q("DELETE FROM `photo` WHERE `contact-id` = %d AND `uid` = %d ", + + intval($contact_id), + intval($_SESSION['uid']) + ); notice("Contact has been removed." . EOL ); goaway($a->get_baseurl() . '/contacts'); @@ -186,6 +184,10 @@ function contacts_content(&$a) { } $o .= replace_macros($tpl,array( + '$poll_interval' => contact_poll_interval($r[0]['priority']), + '$last_update' => (($r[0]['last-update'] == '0000-00-00 00:00:00') + ? t('Never') + : datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, G:i A')), '$profile_select' => contact_profile_assign($r[0]['profile-id']), '$contact_id' => $r[0]['id'], '$block_text' => (($r[0]['blocked']) ? t('Unblock this contact') : t('Block this contact') ), diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index ca6afca8b..0298e76a5 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -91,10 +91,11 @@ function dfrn_confirm_post(&$a) { $hash = hash('md5',uniqid(mt_rand(),true)); - $r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, + $r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `height`, `width`, `data`, `scale` ) - VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )", + VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 4 )", intval($local_uid), + intval($dfrn_record), dbesc($hash), datetime_convert(), datetime_convert(), @@ -107,10 +108,11 @@ function dfrn_confirm_post(&$a) { $photo_failure = true; $img->scaleImage(80); - $r = q("INSERT INTO `photo` ( `uid`, `resource-id`, `created`, `edited`, `filename`, + $r = q("INSERT INTO `photo` ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `height`, `width`, `data`, `scale` ) - VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )", + VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', 5 )", intval($local_uid), + intval($dfrn_record), dbesc($hash), datetime_convert(), datetime_convert(), diff --git a/view/contact_edit.tpl b/view/contact_edit.tpl index 6f1dbbc7c..a049c232f 100644 --- a/view/contact_edit.tpl +++ b/view/contact_edit.tpl @@ -23,6 +23,11 @@ Delete contact
+
+
Last updated: $last_update +
Update public posts:
+ $poll_interval +
diff --git a/view/contact_selectors.php b/view/contact_selectors.php index a6cafe4ee..7c7abfc7c 100644 --- a/view/contact_selectors.php +++ b/view/contact_selectors.php @@ -26,12 +26,12 @@ function contact_reputation($current) { $o .= "' . "\r\n"; + + $rep = array( + 0 => t('Frequently'), + 1 => t('Hourly'), + 2 => t('Twice daily'), + 3 => t('Daily'), + 4 => t('Weekly'), + 5 => t('Monthly') + ); + + foreach($rep as $k => $v) { + $selected = (($k == $current) ? " selected=\"selected\" " : ""); + $o .= "\r\n"; + } + $o .= "\r\n"; + return $o; +} diff --git a/view/style.css b/view/style.css index 0d3b6b29d..c7b46a830 100644 --- a/view/style.css +++ b/view/style.css @@ -16,7 +16,7 @@ body { background: #FEFEFE; color: #444444; font-family: "Lucida Grande", Tahoma, sans-serif; - letter-spacing: 1px; +/* letter-spacing: 1px; */ /* font-family: verdana, sans-serif; */ font-size: 90%; margin-left: 10px; @@ -880,6 +880,14 @@ input#dfrn-url { margin-left: 30px; } +#contact-edit-poll-wrapper { + margin-left: 50px; + margin-top: 30px; +} +#contact-edit-poll-text { + margin-bottom: 10px; +} + #contact-edit-photo-wrapper { margin-bottom: 20px; }