"global" flag for terms that indicate if the term is present in the global posts.
This commit is contained in:
parent
e2965c9ec5
commit
2260415ca9
|
@ -1193,6 +1193,7 @@ function db_definition() {
|
||||||
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
"guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
|
||||||
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
"created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||||
"received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
"received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
|
||||||
|
"global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
|
||||||
"aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
||||||
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
|
||||||
),
|
),
|
||||||
|
@ -1203,6 +1204,7 @@ function db_definition() {
|
||||||
"type_term" => array("type","term"),
|
"type_term" => array("type","term"),
|
||||||
"uid_otype_type_term_created" => array("uid","otype","type","term","created"),
|
"uid_otype_type_term_created" => array("uid","otype","type","term","created"),
|
||||||
"otype_type_term_tid" => array("otype","type","term","tid"),
|
"otype_type_term_tid" => array("otype","type","term","tid"),
|
||||||
|
"guid" => array("guid"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["thread"] = array(
|
$database["thread"] = array(
|
||||||
|
|
|
@ -69,10 +69,22 @@ function create_tags_from_item($itemid) {
|
||||||
$term = $tag;
|
$term = $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`, `url`, `guid`, `created`, `received`)
|
if ($message["uid"] == 0) {
|
||||||
VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s')",
|
$global = true;
|
||||||
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval($type),
|
|
||||||
dbesc($term), dbesc($link), dbesc($message["guid"]), dbesc($message["created"]), dbesc($message["received"]));
|
q("UPDATE `term` SET `global` = 1 WHERE `otype` = %d AND `guid` = '%s'",
|
||||||
|
intval(TERM_OBJ_POST), dbesc($message["guid"]));
|
||||||
|
} else {
|
||||||
|
$isglobal = q("SELECT `global` FROM `term` WHERE `uid` = 0 AND `otype` = %d AND `guid` = '%s'",
|
||||||
|
intval(TERM_OBJ_POST), dbesc($message["guid"]));
|
||||||
|
|
||||||
|
$global = (count($isglobal) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`, `url`, `guid`, `created`, `received`, `global`)
|
||||||
|
VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d)",
|
||||||
|
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval($type), dbesc($term),
|
||||||
|
dbesc($link), dbesc($message["guid"]), dbesc($message["created"]), dbesc($message["received"]), intval($global));
|
||||||
|
|
||||||
// Search for mentions
|
// Search for mentions
|
||||||
if ((substr($tag, 0, 1) == '@') AND (strpos($link, $profile_base_friendica) OR strpos($link, $profile_base_diaspora))) {
|
if ((substr($tag, 0, 1) == '@') AND (strpos($link, $profile_base_friendica) OR strpos($link, $profile_base_diaspora))) {
|
||||||
|
@ -100,13 +112,27 @@ function create_tags_from_itemuri($itemuri, $uid) {
|
||||||
function update_items() {
|
function update_items() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$messages = $db->q("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''", true);
|
// $messages = $db->q("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''", true);
|
||||||
|
$messages = $db->q("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1", true);
|
||||||
|
|
||||||
logger("fetched messages: ".count($messages));
|
logger("fetched messages: ".count($messages));
|
||||||
while ($message = $db->qfetch()) {
|
while ($message = $db->qfetch()) {
|
||||||
q("UPDATE `term` SET `guid` = '%s', `created` = '%s', `received` = '%s' WHERE `otype` = %d AND `oid` = %d",
|
|
||||||
|
if ($message["uid"] == 0) {
|
||||||
|
$global = true;
|
||||||
|
|
||||||
|
q("UPDATE `term` SET `global` = 1 WHERE `otype` = %d AND `guid` = '%s'",
|
||||||
|
intval(TERM_OBJ_POST), dbesc($message["guid"]));
|
||||||
|
} else {
|
||||||
|
$isglobal = q("SELECT `global` FROM `term` WHERE `uid` = 0 AND `otype` = %d AND `guid` = '%s'",
|
||||||
|
intval(TERM_OBJ_POST), dbesc($message["guid"]));
|
||||||
|
|
||||||
|
$global = (count($isglobal) > 0);
|
||||||
|
}
|
||||||
|
echo $message["created"]." - ".$message["guid"]."\n";
|
||||||
|
q("UPDATE `term` SET `guid` = '%s', `created` = '%s', `received` = '%s', `global` = %d WHERE `otype` = %d AND `oid` = %d",
|
||||||
dbesc($message["guid"]), dbesc($message["created"]), dbesc($message["received"]),
|
dbesc($message["guid"]), dbesc($message["created"]), dbesc($message["received"]),
|
||||||
intval(TERM_OBJ_POST), intval($message["oid"]));
|
intval($global), intval(TERM_OBJ_POST), intval($message["oid"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->qclose();
|
$db->qclose();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user