set frequency of poll per contact, other misc fixes (photo now has contact-id)
This commit is contained in:
parent
a4a46d82df
commit
3fd4b4264e
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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']);
|
||||
// }
|
||||
// }
|
||||
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 ",
|
||||
|
||||
if(intval($contact_id))
|
||||
q("DELETE FROM `item` WHERE `contact-id` = %d LIMIT 1",
|
||||
intval($contact_id)
|
||||
);
|
||||
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') ),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
<a href="contacts/$contact_id/drop" id="contact-edit-drop-link" onclick="return confirmDelete();" ><img src="images/b_drophide.gif" alt="Delete contact" title="Delete contact" onmouseover="imgbright(this);" onmouseout="imgdull(this);" /></a>
|
||||
</div>
|
||||
<div id="contact-edit-nav-end"></div>
|
||||
<div id="contact-edit-poll-wrapper">
|
||||
<div id="contact-edit-last-update-text">Last updated: <span id="contact-edit-last-updated">$last_update</span</div>
|
||||
<div id="contact-edit-poll-text">Update public posts: </div>
|
||||
$poll_interval
|
||||
</div>
|
||||
</div>
|
||||
<div id="contact-edit-end" ></div>
|
||||
|
||||
|
|
|
@ -26,12 +26,12 @@ function contact_reputation($current) {
|
|||
$o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
|
||||
|
||||
$rep = array(
|
||||
0 => "Unknown | Not categorised",
|
||||
1 => "Block immediately",
|
||||
2 => "Shady, spammer, self-marketer",
|
||||
3 => "Known to me, but no opinion",
|
||||
4 => "OK, probably harmless",
|
||||
5 => "Reputable, has my trust"
|
||||
0 => t('Unknown | Not categorised'),
|
||||
1 => t('Block immediately'),
|
||||
2 => t('Shady, spammer, self-marketer'),
|
||||
3 => t('Known to me, but no opinion'),
|
||||
4 => t('OK, probably harmless'),
|
||||
5 => t('Reputable, has my trust')
|
||||
);
|
||||
|
||||
foreach($rep as $k => $v) {
|
||||
|
@ -43,4 +43,24 @@ function contact_reputation($current) {
|
|||
}
|
||||
|
||||
|
||||
function contact_poll_interval($current) {
|
||||
|
||||
$o = '';
|
||||
$o .= '<select id="contact-poll-interval" name="poll" />' . "\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 .= "<option value=\"$k\" $selected >$v</option>\r\n";
|
||||
}
|
||||
$o .= "</select>\r\n";
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user