mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-16 20:05:14 +02:00
Database stuff. New table "thread". Changing "left join" to "inner join", removing "limit 1" at update and delete.
This commit is contained in:
parent
2b5345323f
commit
6b8585d48d
33 changed files with 487 additions and 444 deletions
|
@ -842,13 +842,14 @@
|
|||
|
||||
$lastwall = q("SELECT `item`.*
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`contact-id` = %d
|
||||
WHERE `item`.`uid` = %d AND `item`.`contact-id` = %d
|
||||
AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s')))
|
||||
AND `contact`.`id`=`item`.`contact-id`
|
||||
AND `type`!='activity'
|
||||
AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
|
||||
ORDER BY `created` DESC
|
||||
LIMIT 1",
|
||||
intval(api_user()),
|
||||
intval($user_info['cid']),
|
||||
dbesc($user_info['url']),
|
||||
dbesc(normalise_link($user_info['url'])),
|
||||
|
@ -1041,8 +1042,8 @@
|
|||
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
|
||||
`user`.`nickname`, `user`.`hidewall`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
||||
|
|
|
@ -18,6 +18,7 @@ class dba {
|
|||
|
||||
private $debug = 0;
|
||||
private $db;
|
||||
private $result;
|
||||
public $mysqli = true;
|
||||
public $connected = false;
|
||||
public $error = false;
|
||||
|
@ -75,7 +76,7 @@ class dba {
|
|||
return $this->db;
|
||||
}
|
||||
|
||||
public function q($sql) {
|
||||
public function q($sql, $onlyquery = false) {
|
||||
global $a;
|
||||
|
||||
if((! $this->db) || (! $this->connected))
|
||||
|
@ -154,6 +155,11 @@ class dba {
|
|||
if(($result === true) || ($result === false))
|
||||
return $result;
|
||||
|
||||
if ($onlyquery) {
|
||||
$this->result = $result;
|
||||
return true;
|
||||
}
|
||||
|
||||
$r = array();
|
||||
if($this->mysqli) {
|
||||
if($result->num_rows) {
|
||||
|
@ -177,6 +183,30 @@ class dba {
|
|||
return($r);
|
||||
}
|
||||
|
||||
public function qfetch() {
|
||||
$x = false;
|
||||
|
||||
if ($this->result)
|
||||
if($this->mysqli) {
|
||||
if($this->result->num_rows)
|
||||
$x = $this->result->fetch_array(MYSQLI_ASSOC);
|
||||
} else {
|
||||
if(mysql_num_rows($this->result))
|
||||
$x = mysql_fetch_array($this->result, MYSQL_ASSOC);
|
||||
}
|
||||
|
||||
return($x);
|
||||
}
|
||||
|
||||
public function qclose() {
|
||||
if ($this->result)
|
||||
if($this->mysqli) {
|
||||
$this->result->free_result();
|
||||
} else {
|
||||
mysql_free_result($this->result);
|
||||
}
|
||||
}
|
||||
|
||||
public function dbg($dbg) {
|
||||
$this->debug = $dbg;
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ function delivery_run(&$argv, &$argc){
|
|||
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
|
||||
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
|
||||
`user`.`page-flags`, `user`.`prvnets`
|
||||
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
@ -319,7 +319,7 @@ function delivery_run(&$argv, &$argc){
|
|||
`contact`.`name` as `senderName`,
|
||||
`user`.*
|
||||
FROM `contact`
|
||||
LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
|
||||
$sql_extra
|
||||
|
|
|
@ -578,7 +578,7 @@ function diaspora_request($importer,$xml) {
|
|||
// That makes us friends.
|
||||
|
||||
if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
|
||||
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
|
||||
intval(CONTACT_IS_FRIEND),
|
||||
intval($contact['id']),
|
||||
intval($importer['uid'])
|
||||
|
@ -733,7 +733,7 @@ function diaspora_request($importer,$xml) {
|
|||
`avatar-date` = '%s',
|
||||
`blocked` = 0,
|
||||
`pending` = 0
|
||||
WHERE `id` = %d LIMIT 1
|
||||
WHERE `id` = %d
|
||||
",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
|
@ -759,7 +759,7 @@ function diaspora_post_allow($importer,$contact) {
|
|||
// That makes us friends.
|
||||
// Normally this should have handled by getting a request - but this could get lost
|
||||
if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
|
||||
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
|
||||
intval(CONTACT_IS_FRIEND),
|
||||
intval($contact['id']),
|
||||
intval($importer['uid'])
|
||||
|
@ -895,7 +895,7 @@ function diaspora_post($importer,$xml,$msg) {
|
|||
$message_id = item_store($datarray);
|
||||
|
||||
//if($message_id) {
|
||||
// q("update item set plink = '%s' where id = %d limit 1",
|
||||
// q("update item set plink = '%s' where id = %d",
|
||||
// dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
|
||||
// intval($message_id)
|
||||
// );
|
||||
|
@ -1071,7 +1071,7 @@ function diaspora_reshare($importer,$xml,$msg) {
|
|||
$message_id = item_store($datarray);
|
||||
|
||||
//if($message_id) {
|
||||
// q("update item set plink = '%s' where id = %d limit 1",
|
||||
// q("update item set plink = '%s' where id = %d",
|
||||
// dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
|
||||
// intval($message_id)
|
||||
// );
|
||||
|
@ -1170,7 +1170,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
|
|||
$message_id = item_store($datarray);
|
||||
|
||||
//if($message_id) {
|
||||
// q("update item set plink = '%s' where id = %d limit 1",
|
||||
// q("update item set plink = '%s' where id = %d",
|
||||
// dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
|
||||
// intval($message_id)
|
||||
// );
|
||||
|
@ -1350,7 +1350,7 @@ function diaspora_comment($importer,$xml,$msg) {
|
|||
$message_id = item_store($datarray);
|
||||
|
||||
if($message_id) {
|
||||
q("update item set plink = '%s' where id = %d limit 1",
|
||||
q("update item set plink = '%s' where id = %d",
|
||||
dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
|
||||
intval($message_id)
|
||||
);
|
||||
|
@ -1559,15 +1559,15 @@ function diaspora_conversation($importer,$xml,$msg) {
|
|||
dbesc($message_id),
|
||||
dbesc($parent_uri),
|
||||
dbesc($msg_created_at)
|
||||
);
|
||||
);
|
||||
|
||||
q("update conv set updated = '%s' where id = %d limit 1",
|
||||
q("update conv set updated = '%s' where id = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($conversation['id'])
|
||||
);
|
||||
);
|
||||
|
||||
require_once('include/enotify.php');
|
||||
notification(array(
|
||||
notification(array(
|
||||
'type' => NOTIFY_MAIL,
|
||||
'notify_flags' => $importer['notify-flags'],
|
||||
'language' => $importer['language'],
|
||||
|
@ -1672,13 +1672,13 @@ function diaspora_message($importer,$xml,$msg) {
|
|||
dbesc($message_id),
|
||||
dbesc($parent_uri),
|
||||
dbesc($msg_created_at)
|
||||
);
|
||||
);
|
||||
|
||||
q("update conv set updated = '%s' where id = %d limit 1",
|
||||
q("update conv set updated = '%s' where id = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($conversation['id'])
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1740,7 +1740,7 @@ function diaspora_photo($importer,$xml,$msg,$attempt=1) {
|
|||
array($remote_photo_name, 'scaled_full_' . $remote_photo_name));
|
||||
|
||||
if(strpos($parent_item['body'],$link_text) === false) {
|
||||
$r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d limit 1",
|
||||
$r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d",
|
||||
dbesc($link_text . $parent_item['body']),
|
||||
intval($parent_item['id']),
|
||||
intval($parent_item['uid'])
|
||||
|
@ -1800,12 +1800,12 @@ function diaspora_like($importer,$xml,$msg) {
|
|||
if($positive === 'true') {
|
||||
logger('diaspora_like: duplicate like: ' . $guid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Note: I don't think "Like" objects with positive = "false" are ever actually used
|
||||
// It looks like "RelayableRetractions" are used for "unlike" instead
|
||||
if($positive === 'false') {
|
||||
logger('diaspora_like: received a like with positive set to "false"...ignoring');
|
||||
/* q("UPDATE `item` SET `deleted` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
/* q("UPDATE `item` SET `deleted` = 1 WHERE `id` = %d AND `uid` = %d",
|
||||
intval($r[0]['id']),
|
||||
intval($importer['uid'])
|
||||
);*/
|
||||
|
@ -1942,7 +1942,7 @@ EOT;
|
|||
|
||||
|
||||
if($message_id) {
|
||||
q("update item set plink = '%s' where id = %d limit 1",
|
||||
q("update item set plink = '%s' where id = %d",
|
||||
dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
|
||||
intval($message_id)
|
||||
);
|
||||
|
@ -1989,8 +1989,8 @@ function diaspora_retraction($importer,$xml) {
|
|||
);
|
||||
if(count($r)) {
|
||||
if(link_compare($r[0]['author-link'],$contact['url'])) {
|
||||
q("update item set `deleted` = 1, `changed` = '%s' where `id` = %d limit 1",
|
||||
dbesc(datetime_convert()),
|
||||
q("update item set `deleted` = 1, `changed` = '%s' where `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
|
@ -2060,12 +2060,12 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
|
|||
);
|
||||
if(count($r)) {
|
||||
if(link_compare($r[0]['author-link'],$contact['url'])) {
|
||||
q("update item set `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' where `id` = %d limit 1",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
q("update item set `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' where `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
|
||||
|
||||
// Now check if the retraction needs to be relayed by us
|
||||
//
|
||||
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
|
||||
|
@ -2161,7 +2161,7 @@ function diaspora_profile($importer,$xml,$msg) {
|
|||
// TODO: update name on item['author-name'] if the name changed. See consume_feed()
|
||||
// Not doing this currently because D* protocol is scheduled for revision soon.
|
||||
|
||||
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc($name),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($images[0]),
|
||||
|
@ -2331,7 +2331,7 @@ function diaspora_send_images($item,$owner,$contact,$images,$public_batch = fals
|
|||
if(! count($r))
|
||||
continue;
|
||||
$public = (($r[0]['allow_cid'] || $r[0]['allow_gid'] || $r[0]['deny_cid'] || $r[0]['deny_gid']) ? 'false' : 'true' );
|
||||
$msg = replace_macros($tpl,array(
|
||||
$msg = replace_macros($tpl,array(
|
||||
'$path' => xmlify($image['path']),
|
||||
'$filename' => xmlify($image['file']),
|
||||
'$msg_guid' => xmlify($image['guid']),
|
||||
|
|
|
@ -262,7 +262,7 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
'$ostat_follow' => ''
|
||||
));
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
$r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
|
|
@ -157,7 +157,7 @@ function group_get_members($gid) {
|
|||
$ret = array();
|
||||
if(intval($gid)) {
|
||||
$r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
|
||||
WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ",
|
||||
intval($gid),
|
||||
intval(local_user())
|
||||
|
@ -172,7 +172,7 @@ function group_public_members($gid) {
|
|||
$ret = 0;
|
||||
if(intval($gid)) {
|
||||
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
|
||||
WHERE `gid` = %d AND `group_member`.`uid` = %d
|
||||
AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ",
|
||||
intval($gid),
|
||||
|
@ -299,7 +299,7 @@ function expand_groups($a,$check_dead = false) {
|
|||
|
||||
function member_of($c) {
|
||||
|
||||
$r = q("SELECT `group`.`name`, `group`.`id` FROM `group` LEFT JOIN `group_member` ON `group_member`.`gid` = `group`.`id` WHERE `group_member`.`contact-id` = %d AND `group`.`deleted` = 0 ORDER BY `group`.`name` ASC ",
|
||||
$r = q("SELECT `group`.`name`, `group`.`id` FROM `group` INNER JOIN `group_member` ON `group_member`.`gid` = `group`.`id` WHERE `group_member`.`contact-id` = %d AND `group`.`deleted` = 0 ORDER BY `group`.`name` ASC ",
|
||||
intval($c)
|
||||
);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ require_once('include/tags.php');
|
|||
require_once('include/text.php');
|
||||
require_once('include/email.php');
|
||||
require_once('include/ostatus_conversation.php');
|
||||
require_once('include/threads.php');
|
||||
|
||||
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
|
||||
|
||||
|
@ -36,7 +37,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
|
|||
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`
|
||||
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1",
|
||||
dbesc($owner_nick)
|
||||
);
|
||||
|
@ -122,15 +123,15 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
|
|||
|
||||
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
|
||||
|
||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
`contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
|
||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
`contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
|
||||
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
|
||||
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`,
|
||||
`sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
|
||||
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0
|
||||
AND `item`.`wall` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
|
||||
$sql_extra
|
||||
|
@ -915,7 +916,7 @@ function encode_rel_links($links) {
|
|||
|
||||
function item_store($arr,$force_parent = false) {
|
||||
|
||||
// If a Diaspora signature structure was passed in, pull it out of the
|
||||
// If a Diaspora signature structure was passed in, pull it out of the
|
||||
// item array and set it aside for later storage.
|
||||
|
||||
$dsprsig = null;
|
||||
|
@ -947,7 +948,7 @@ function item_store($arr,$force_parent = false) {
|
|||
|
||||
// Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin.
|
||||
|
||||
if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
|
||||
if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
|
||||
$arr['body'] = strip_tags($arr['body']);
|
||||
|
||||
|
||||
|
@ -1058,7 +1059,7 @@ function item_store($arr,$force_parent = false) {
|
|||
|
||||
if($r[0]['uri'] != $r[0]['parent-uri']) {
|
||||
$arr['parent-uri'] = $r[0]['parent-uri'];
|
||||
$z = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d
|
||||
$z = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `parent-uri` = '%s' AND `uid` = %d
|
||||
ORDER BY `id` ASC LIMIT 1",
|
||||
dbesc($r[0]['parent-uri']),
|
||||
dbesc($r[0]['parent-uri']),
|
||||
|
@ -1077,18 +1078,32 @@ function item_store($arr,$force_parent = false) {
|
|||
$arr['wall'] = $r[0]['wall'];
|
||||
|
||||
// if the parent is private, force privacy for the entire conversation
|
||||
// This differs from the above settings as it subtly allows comments from
|
||||
// email correspondents to be private even if the overall thread is not.
|
||||
// This differs from the above settings as it subtly allows comments from
|
||||
// email correspondents to be private even if the overall thread is not.
|
||||
|
||||
if($r[0]['private'])
|
||||
$arr['private'] = $r[0]['private'];
|
||||
|
||||
// Edge case. We host a public forum that was originally posted to privately.
|
||||
// The original author commented, but as this is a comment, the permissions
|
||||
// weren't fixed up so it will still show the comment as private unless we fix it here.
|
||||
// weren't fixed up so it will still show the comment as private unless we fix it here.
|
||||
|
||||
if((intval($r[0]['forum_mode']) == 1) && (! $r[0]['private']))
|
||||
$arr['private'] = 0;
|
||||
|
||||
|
||||
// If its a post from myself then tag the thread as "mention"
|
||||
logger("item_store: Checking if parent ".$parent_id." has to be tagged as mention for user ".$arr['uid'], LOGGER_DEBUG);
|
||||
$u = q("select * from user where uid = %d limit 1", intval($arr['uid']));
|
||||
if(count($u)) {
|
||||
$a = get_app();
|
||||
$self = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
|
||||
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
|
||||
if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) {
|
||||
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
|
||||
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
@ -1150,6 +1165,7 @@ function item_store($arr,$force_parent = false) {
|
|||
|
||||
// Only check for notifications on start posts
|
||||
if ($arr['parent-uri'] === $arr['uri']) {
|
||||
add_thread($r[0]['id']);
|
||||
logger('item_store: Check notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
|
||||
|
||||
// Send a notification for every new post?
|
||||
|
@ -1246,6 +1262,7 @@ function item_store($arr,$force_parent = false) {
|
|||
dbesc(datetime_convert()),
|
||||
intval($parent_id)
|
||||
);
|
||||
update_thread($parent_id);
|
||||
|
||||
if($dsprsig) {
|
||||
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
|
||||
|
@ -1318,7 +1335,7 @@ function get_item_contact($item,$contacts) {
|
|||
*/
|
||||
function tag_deliver($uid,$item_id) {
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
@ -1448,6 +1465,7 @@ function tag_deliver($uid,$item_id) {
|
|||
dbesc($u[0]['deny_gid']),
|
||||
intval($item_id)
|
||||
);
|
||||
update_thread($item_id);
|
||||
|
||||
proc_run('php','include/notifier.php','tgroup',$item_id);
|
||||
|
||||
|
@ -1965,7 +1983,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
$when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s');
|
||||
}
|
||||
if($deleted && is_array($contact)) {
|
||||
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id`
|
||||
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` INNER JOIN `contact` on `item`.`contact-id` = `contact`.`id`
|
||||
WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
|
||||
dbesc($uri),
|
||||
intval($importer['uid']),
|
||||
|
@ -2023,10 +2041,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
intval($importer['uid'])
|
||||
);
|
||||
create_tags_from_itemuri($item['uri'], $importer['uid']);
|
||||
update_thread_uri($item['uri'], $importer['uid']);
|
||||
}
|
||||
else {
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
||||
`body` = '', `title` = ''
|
||||
`body` = '', `title` = ''
|
||||
WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($when),
|
||||
dbesc(datetime_convert()),
|
||||
|
@ -2122,6 +2141,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
intval($importer['uid'])
|
||||
);
|
||||
$datarray['last-child'] = 1;
|
||||
update_thread_uri($parent_uri, $importer['uid']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2148,6 +2168,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
intval($importer['uid'])
|
||||
);
|
||||
create_tags_from_itemuri($item_id, $importer['uid']);
|
||||
update_thread_uri($item_id, $importer['uid']);
|
||||
}
|
||||
|
||||
// update last-child if it changes
|
||||
|
@ -2165,6 +2186,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
dbesc($item_id),
|
||||
intval($importer['uid'])
|
||||
);
|
||||
update_thread_uri($item_id, $importer['uid']);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -2291,7 +2313,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
// Update content if 'updated' changes
|
||||
|
||||
if(count($r)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
|
||||
// do not accept (ignore) an earlier edit than one we currently have.
|
||||
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
|
||||
|
@ -2306,6 +2328,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
intval($importer['uid'])
|
||||
);
|
||||
create_tags_from_itemuri($item_id, $importer['uid']);
|
||||
update_thread_uri($item_id, $importer['uid']);
|
||||
}
|
||||
|
||||
// update last-child if it changes
|
||||
|
@ -2318,6 +2341,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
dbesc($item_id),
|
||||
intval($importer['uid'])
|
||||
);
|
||||
update_thread_uri($item_id, $importer['uid']);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -2556,65 +2580,65 @@ function local_delivery($importer,$data) {
|
|||
/*$newloc['pubkey'] = notags(unxmlify($base['pubkey'][0]['data']));
|
||||
$newloc['prvkey'] = notags(unxmlify($base['prvkey'][0]['data']));*/
|
||||
|
||||
logger("items:relocate contact ".print_r($newloc, true).print_r($importer, true), LOGGER_DEBUG);
|
||||
logger("items:relocate contact ".print_r($newloc, true).print_r($importer, true), LOGGER_DEBUG);
|
||||
|
||||
// update contact
|
||||
$r = q("SELECT photo, url FROM contact WHERE id=%d AND uid=%d;",
|
||||
intval($importer['id']),
|
||||
intval($importer['importer_uid']));
|
||||
// update contact
|
||||
$r = q("SELECT photo, url FROM contact WHERE id=%d AND uid=%d;",
|
||||
intval($importer['id']),
|
||||
intval($importer['importer_uid']));
|
||||
if ($r === false)
|
||||
return 1;
|
||||
$old = $r[0];
|
||||
$old = $r[0];
|
||||
|
||||
$x = q("UPDATE contact SET
|
||||
name = '%s',
|
||||
photo = '%s',
|
||||
thumb = '%s',
|
||||
micro = '%s',
|
||||
url = '%s',
|
||||
request = '%s',
|
||||
confirm = '%s',
|
||||
notify = '%s',
|
||||
poll = '%s',
|
||||
`site-pubkey` = '%s'
|
||||
WHERE id=%d AND uid=%d;",
|
||||
dbesc($newloc['name']),
|
||||
dbesc($newloc['photo']),
|
||||
dbesc($newloc['thumb']),
|
||||
dbesc($newloc['micro']),
|
||||
dbesc($newloc['url']),
|
||||
dbesc($newloc['request']),
|
||||
dbesc($newloc['confirm']),
|
||||
dbesc($newloc['notify']),
|
||||
dbesc($newloc['poll']),
|
||||
dbesc($newloc['sitepubkey']),
|
||||
intval($importer['id']),
|
||||
$x = q("UPDATE contact SET
|
||||
name = '%s',
|
||||
photo = '%s',
|
||||
thumb = '%s',
|
||||
micro = '%s',
|
||||
url = '%s',
|
||||
request = '%s',
|
||||
confirm = '%s',
|
||||
notify = '%s',
|
||||
poll = '%s',
|
||||
`site-pubkey` = '%s'
|
||||
WHERE id=%d AND uid=%d;",
|
||||
dbesc($newloc['name']),
|
||||
dbesc($newloc['photo']),
|
||||
dbesc($newloc['thumb']),
|
||||
dbesc($newloc['micro']),
|
||||
dbesc($newloc['url']),
|
||||
dbesc($newloc['request']),
|
||||
dbesc($newloc['confirm']),
|
||||
dbesc($newloc['notify']),
|
||||
dbesc($newloc['poll']),
|
||||
dbesc($newloc['sitepubkey']),
|
||||
intval($importer['id']),
|
||||
intval($importer['importer_uid']));
|
||||
|
||||
if ($x === false)
|
||||
if ($x === false)
|
||||
return 1;
|
||||
// update items
|
||||
$fields = array(
|
||||
'owner-link' => array($old['url'], $newloc['url']),
|
||||
'author-link' => array($old['url'], $newloc['url']),
|
||||
'owner-avatar' => array($old['photo'], $newloc['photo']),
|
||||
'author-avatar' => array($old['photo'], $newloc['photo']),
|
||||
);
|
||||
foreach ($fields as $n=>$f){
|
||||
$x = q("UPDATE item SET `%s`='%s' WHERE `%s`='%s' AND uid=%d",
|
||||
$n, dbesc($f[1]),
|
||||
$n, dbesc($f[0]),
|
||||
intval($importer['importer_uid']));
|
||||
if ($x === false)
|
||||
return 1;
|
||||
}
|
||||
// update items
|
||||
$fields = array(
|
||||
'owner-link' => array($old['url'], $newloc['url']),
|
||||
'author-link' => array($old['url'], $newloc['url']),
|
||||
'owner-avatar' => array($old['photo'], $newloc['photo']),
|
||||
'author-avatar' => array($old['photo'], $newloc['photo']),
|
||||
);
|
||||
foreach ($fields as $n=>$f){
|
||||
$x = q("UPDATE `item` SET `%s`='%s' WHERE `%s`='%s' AND uid=%d",
|
||||
$n, dbesc($f[1]),
|
||||
$n, dbesc($f[0]),
|
||||
intval($importer['importer_uid']));
|
||||
if ($x === false)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// merge with current record, current contents have priority
|
||||
// update record, set url-updated
|
||||
// update profile photos
|
||||
// schedule a scan?
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2832,7 +2856,7 @@ function local_delivery($importer,$data) {
|
|||
// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
|
||||
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
|
||||
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
|
||||
AND `item`.`uid` = %d
|
||||
$sql_extra
|
||||
|
@ -2862,7 +2886,7 @@ function local_delivery($importer,$data) {
|
|||
}
|
||||
}
|
||||
|
||||
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id`
|
||||
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` INNER JOIN contact on `item`.`contact-id` = `contact`.`id`
|
||||
WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
|
||||
dbesc($uri),
|
||||
intval($importer['importer_uid']),
|
||||
|
@ -2924,6 +2948,7 @@ function local_delivery($importer,$data) {
|
|||
intval($importer['importer_uid'])
|
||||
);
|
||||
create_tags_from_itemuri($item['uri'], $importer['importer_uid']);
|
||||
update_thread_uri($item['uri'], $importer['importer_uid']);
|
||||
}
|
||||
else {
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
||||
|
@ -2935,6 +2960,7 @@ function local_delivery($importer,$data) {
|
|||
intval($importer['importer_uid'])
|
||||
);
|
||||
create_tags_from_itemuri($uri, $importer['importer_uid']);
|
||||
update_thread_uri($uri, $importer['importer_uid']);
|
||||
if($item['last-child']) {
|
||||
// ensure that last-child is set in case the comment that had it just got wiped.
|
||||
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
|
||||
|
@ -3003,7 +3029,7 @@ function local_delivery($importer,$data) {
|
|||
// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
|
||||
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
|
||||
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
|
||||
AND `item`.`uid` = %d
|
||||
$sql_extra
|
||||
|
@ -3346,7 +3372,7 @@ function local_delivery($importer,$data) {
|
|||
continue;
|
||||
|
||||
require_once('include/enotify.php');
|
||||
|
||||
|
||||
$conv_parent = $conv['parent'];
|
||||
|
||||
notification(array(
|
||||
|
@ -3430,6 +3456,7 @@ function local_delivery($importer,$data) {
|
|||
intval($importer['importer_uid'])
|
||||
);
|
||||
create_tags_from_itemuri($item_id, $importer['importer_uid']);
|
||||
update_thread_uri($item_id, $importer['importer_uid']);
|
||||
}
|
||||
|
||||
// update last-child if it changes
|
||||
|
@ -4154,6 +4181,7 @@ function drop_item($id,$interactive = true) {
|
|||
intval($item['id'])
|
||||
);
|
||||
create_tags_from_item($item['id']);
|
||||
delete_thread($item['id']);
|
||||
|
||||
// clean up categories and tags so they don't end up as orphans
|
||||
|
||||
|
@ -4248,6 +4276,7 @@ function drop_item($id,$interactive = true) {
|
|||
intval($item['uid'])
|
||||
);
|
||||
create_tags_from_item($item['parent-uri'], $item['uid']);
|
||||
delete_thread_uri($item['parent-uri'], $item['uid']);
|
||||
// ignore the result
|
||||
}
|
||||
else {
|
||||
|
@ -4294,8 +4323,8 @@ function drop_item($id,$interactive = true) {
|
|||
|
||||
|
||||
function first_post_date($uid,$wall = false) {
|
||||
$r = q("select id, created from item
|
||||
where uid = %d and wall = %d and deleted = 0 and visible = 1 AND moderated = 0
|
||||
$r = q("select id, created from item
|
||||
where uid = %d and wall = %d and deleted = 0 and visible = 1 AND moderated = 0
|
||||
and id = parent
|
||||
order by created asc limit 1",
|
||||
intval($uid),
|
||||
|
|
|
@ -207,7 +207,7 @@ function notifier_run(&$argv, &$argc){
|
|||
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
|
||||
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
|
||||
`user`.`page-flags`, `user`.`prvnets`
|
||||
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
@ -643,7 +643,7 @@ function notifier_run(&$argv, &$argc){
|
|||
`contact`.`name` as `senderName`,
|
||||
`user`.*
|
||||
FROM `contact`
|
||||
LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`archive` = 0
|
||||
AND `contact`.`pending` = 0
|
||||
AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
|
||||
|
|
|
@ -112,7 +112,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
$importer_uid = $contact['uid'];
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
||||
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
||||
intval($importer_uid)
|
||||
);
|
||||
if(! count($r))
|
||||
|
|
|
@ -174,7 +174,7 @@ function poller_run(&$argv, &$argc){
|
|||
: ''
|
||||
);
|
||||
|
||||
$contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
$contacts = q("SELECT `contact`.`id` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
|
||||
AND NOT `network` IN ( '%s', '%s', '%s' )
|
||||
$sql_extra
|
||||
|
|
|
@ -25,7 +25,7 @@ function profile_change() {
|
|||
return;
|
||||
|
||||
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile`
|
||||
LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
||||
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
||||
WHERE `user`.`uid` = %d AND `profile`.`is-default` = 1 LIMIT 1",
|
||||
intval(local_user())
|
||||
);
|
||||
|
|
|
@ -111,7 +111,7 @@ function queue_run(&$argv, &$argc){
|
|||
}
|
||||
|
||||
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
|
||||
LEFT JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
||||
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
||||
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
|
||||
if($r) {
|
||||
foreach($r as $rr) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
function update_queue_time($id) {
|
||||
logger('queue: requeue item ' . $id);
|
||||
q("UPDATE `queue` SET `last` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `queue` SET `last` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($id)
|
||||
);
|
||||
|
@ -10,7 +10,7 @@ function update_queue_time($id) {
|
|||
|
||||
function remove_queue_item($id) {
|
||||
logger('queue: remove queue item ' . $id);
|
||||
q("DELETE FROM `queue` WHERE `id` = %d LIMIT 1",
|
||||
q("DELETE FROM `queue` WHERE `id` = %d",
|
||||
intval($id)
|
||||
);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
|
|||
if($batch_queue < 1)
|
||||
$batch_queue = 1000;
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `queue` left join `contact` ON `queue`.`cid` = `contact`.`id`
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
|
||||
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
|
||||
intval($cid)
|
||||
);
|
||||
|
|
|
@ -56,7 +56,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
|
|||
$a->identities = array();
|
||||
|
||||
$r = q("select `user`.`uid`, `user`.`username`, `user`.`nickname`
|
||||
from manage left join user on manage.mid = user.uid where `user`.`account_removed` = 0
|
||||
from manage INNER JOIN user on manage.mid = user.uid where `user`.`account_removed` = 0
|
||||
and `manage`.`uid` = %d",
|
||||
intval($master_record['uid'])
|
||||
);
|
||||
|
@ -139,7 +139,7 @@ function can_write_wall(&$a,$owner) {
|
|||
return false;
|
||||
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid`
|
||||
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1",
|
||||
intval($owner),
|
||||
|
@ -255,11 +255,11 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
|
|||
* default permissions - anonymous user
|
||||
*/
|
||||
|
||||
$sql = " AND allow_cid = ''
|
||||
AND allow_gid = ''
|
||||
AND deny_cid = ''
|
||||
AND deny_gid = ''
|
||||
AND private = 0
|
||||
$sql = " AND `item`.allow_cid = ''
|
||||
AND `item`.allow_gid = ''
|
||||
AND `item`.deny_cid = ''
|
||||
AND `item`.deny_gid = ''
|
||||
AND `item`.private = 0
|
||||
";
|
||||
|
||||
/**
|
||||
|
@ -291,7 +291,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
|
|||
}
|
||||
}
|
||||
if($remote_verified) {
|
||||
|
||||
|
||||
$gs = '<<>>'; // should be impossible to match
|
||||
|
||||
if(is_array($groups) && count($groups)) {
|
||||
|
@ -310,9 +310,9 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
|
|||
dbesc($gs),
|
||||
dbesc($gs)
|
||||
*/
|
||||
" AND ( private = 0 OR ( private in (1,2) AND wall = 1
|
||||
AND ( NOT (deny_cid REGEXP '<%d>' OR deny_gid REGEXP '%s')
|
||||
AND ( allow_cid REGEXP '<%d>' OR allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = '')))))
|
||||
" AND ( `item`.private = 0 OR ( `item`.private in (1,2) AND wall = 1
|
||||
AND ( NOT (`item`.deny_cid REGEXP '<%d>' OR `item`.deny_gid REGEXP '%s')
|
||||
AND ( `item`.allow_cid REGEXP '<%d>' OR `item`.allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = '')))))
|
||||
",
|
||||
intval($remote_user),
|
||||
dbesc($gs),
|
||||
|
|
|
@ -170,7 +170,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
function count_common_friends($uid,$cid) {
|
||||
|
||||
$r = q("SELECT count(*) as `total`
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
where `glink`.`cid` = %d and `glink`.`uid` = %d
|
||||
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ",
|
||||
intval($cid),
|
||||
|
@ -195,7 +195,7 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) {
|
|||
$sql_extra = " order by `gcontact`.`name` asc ";
|
||||
|
||||
$r = q("SELECT `gcontact`.*
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
where `glink`.`cid` = %d and `glink`.`uid` = %d
|
||||
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d )
|
||||
$sql_extra limit %d, %d",
|
||||
|
@ -215,7 +215,7 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) {
|
|||
function count_common_friends_zcid($uid,$zcid) {
|
||||
|
||||
$r = q("SELECT count(*) as `total`
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
where `glink`.`zcid` = %d
|
||||
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ",
|
||||
intval($zcid),
|
||||
|
@ -236,7 +236,7 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
|
|||
$sql_extra = " order by `gcontact`.`name` asc ";
|
||||
|
||||
$r = q("SELECT `gcontact`.*
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
where `glink`.`zcid` = %d
|
||||
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
|
||||
$sql_extra limit %d, %d",
|
||||
|
@ -254,7 +254,7 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
|
|||
function count_all_friends($uid,$cid) {
|
||||
|
||||
$r = q("SELECT count(*) as `total`
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
where `glink`.`cid` = %d and `glink`.`uid` = %d ",
|
||||
intval($cid),
|
||||
intval($uid)
|
||||
|
@ -270,7 +270,7 @@ function count_all_friends($uid,$cid) {
|
|||
function all_friends($uid,$cid,$start = 0, $limit = 80) {
|
||||
|
||||
$r = q("SELECT `gcontact`.*
|
||||
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
|
||||
where `glink`.`cid` = %d and `glink`.`uid` = %d
|
||||
order by `gcontact`.`name` asc LIMIT %d, %d ",
|
||||
intval($cid),
|
||||
|
@ -290,7 +290,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
|||
return array();
|
||||
|
||||
$r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
|
||||
left join glink on glink.gcid = gcontact.id
|
||||
INNER JOIN glink on glink.gcid = gcontact.id
|
||||
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
|
||||
and not gcontact.name in ( select name from contact where uid = %d )
|
||||
and not gcontact.id in ( select gcid from gcign where uid = %d )
|
||||
|
@ -307,7 +307,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
|
|||
return $r;
|
||||
|
||||
$r2 = q("SELECT gcontact.* from gcontact
|
||||
left join glink on glink.gcid = gcontact.id
|
||||
INNER JOIN glink on glink.gcid = gcontact.id
|
||||
where glink.uid = 0 and glink.cid = 0 and glink.zcid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d )
|
||||
and not gcontact.name in ( select name from contact where uid = %d )
|
||||
and not gcontact.id in ( select gcid from gcign where uid = %d )
|
||||
|
|
|
@ -1,20 +1,4 @@
|
|||
<?php
|
||||
/*
|
||||
require_once("boot.php");
|
||||
if(@is_null($a)) {
|
||||
$a = new App;
|
||||
}
|
||||
|
||||
if(is_null($db)) {
|
||||
@include(".htconfig.php");
|
||||
require_once("dba.php");
|
||||
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
||||
unset($db_host, $db_user, $db_pass, $db_data);
|
||||
};
|
||||
|
||||
$a->set_baseurl("https://pirati.ca");
|
||||
*/
|
||||
|
||||
function create_tags_from_item($itemid) {
|
||||
global $a;
|
||||
|
||||
|
@ -25,7 +9,7 @@ function create_tags_from_item($itemid) {
|
|||
|
||||
$searchpath = $a->get_baseurl()."/search?tag=";
|
||||
|
||||
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `title`, `body`, `tag` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
|
||||
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
|
||||
|
||||
if (!$messages)
|
||||
return;
|
||||
|
@ -102,8 +86,11 @@ function create_tags_from_item($itemid) {
|
|||
if ((substr($tag, 0, 1) == '@') AND (strpos($link, $profile_base_friendica) OR strpos($link, $profile_base_diaspora))) {
|
||||
$users = q("SELECT `uid` FROM `contact` WHERE self AND (`url` = '%s' OR `nurl` = '%s')", $link, $link);
|
||||
foreach ($users AS $user) {
|
||||
if ($user["uid"] == $message["uid"])
|
||||
if ($user["uid"] == $message["uid"]) {
|
||||
q("UPDATE `item` SET `mention` = 1 WHERE `id` = %d", intval($itemid));
|
||||
|
||||
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($message["parent"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,11 +112,4 @@ function update_items() {
|
|||
foreach ($messages as $message)
|
||||
create_tags_from_item($message["id"]);
|
||||
}
|
||||
|
||||
//print_r($tags);
|
||||
//print_r($hashtags);
|
||||
//print_r($mentions);
|
||||
//update_items();
|
||||
//create_tags_from_item(265194);
|
||||
//create_tags_from_itemuri("infoagent@diasp.org:cce94abd104c06e8", 2);
|
||||
?>
|
||||
|
|
|
@ -233,7 +233,7 @@ function create_user($arr) {
|
|||
);
|
||||
if((count($r) > 1) && $newuid) {
|
||||
$result['message'] .= t('Nickname is already registered. Please choose another.') . EOL;
|
||||
q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
q("DELETE FROM `user` WHERE `uid` = %d",
|
||||
intval($newuid)
|
||||
);
|
||||
return $result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue