Merge pull request #817 from annando/master
SQL: Query for showing group posts is improved, order by comment date now is working again
This commit is contained in:
commit
3964d86020
5 changed files with 15 additions and 98 deletions
|
@ -1068,19 +1068,6 @@
|
||||||
$myurl = str_replace('www.','',$myurl);
|
$myurl = str_replace('www.','',$myurl);
|
||||||
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
||||||
|
|
||||||
/* if (get_config('system','use_fulltext_engine'))
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
|
|
||||||
dbesc(protect_sprintf($myurl)),
|
|
||||||
dbesc(protect_sprintf($myurl)),
|
|
||||||
dbesc(protect_sprintf($diasp_url))
|
|
||||||
);
|
|
||||||
else
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
|
|
||||||
dbesc(protect_sprintf('%' . $myurl)),
|
|
||||||
dbesc(protect_sprintf('%' . $myurl . ']%')),
|
|
||||||
dbesc(protect_sprintf('%' . $diasp_url . ']%'))
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
||||||
dbesc(protect_sprintf($myurl)),
|
dbesc(protect_sprintf($myurl)),
|
||||||
dbesc(protect_sprintf($myurl))
|
dbesc(protect_sprintf($myurl))
|
||||||
|
|
|
@ -423,7 +423,6 @@ function onepoll_run(&$argv, &$argc){
|
||||||
|
|
||||||
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
|
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
|
||||||
if(!x($datarray,'parent-uri') and $reply) {
|
if(!x($datarray,'parent-uri') and $reply) {
|
||||||
//$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
|
|
||||||
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
|
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
|
||||||
dbesc(protect_sprintf($datarray['title'])),
|
dbesc(protect_sprintf($datarray['title'])),
|
||||||
intval($importer_uid));
|
intval($importer_uid));
|
||||||
|
|
|
@ -173,23 +173,6 @@ function content_content(&$a, $update = 0) {
|
||||||
if (get_config('system','only_tag_search'))
|
if (get_config('system','only_tag_search'))
|
||||||
$tag = true;
|
$tag = true;
|
||||||
|
|
||||||
/*if (get_config('system','use_fulltext_engine')) {
|
|
||||||
if(strpos($search,'#') === 0)
|
|
||||||
$sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('%s' in boolean mode)) ",
|
|
||||||
dbesc(protect_sprintf($search))
|
|
||||||
);
|
|
||||||
else
|
|
||||||
$sql_extra .= sprintf(" AND (MATCH(`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode)) ",
|
|
||||||
dbesc(protect_sprintf($search)),
|
|
||||||
dbesc(protect_sprintf($search))
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
|
|
||||||
dbesc(protect_sprintf('%' . $search . '%')),
|
|
||||||
dbesc(protect_sprintf('%]' . $search . '[%'))
|
|
||||||
);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if($tag) {
|
if($tag) {
|
||||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
||||||
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||||
|
@ -216,18 +199,6 @@ function content_content(&$a, $update = 0) {
|
||||||
$myurl = substr($myurl,strpos($myurl,'://')+3);
|
$myurl = substr($myurl,strpos($myurl,'://')+3);
|
||||||
$myurl = str_replace('www.','',$myurl);
|
$myurl = str_replace('www.','',$myurl);
|
||||||
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
||||||
/*if (get_config('system','use_fulltext_engine'))
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from $sql_table where (MATCH(`author-link`, `tag`) AGAINST ('%s' in boolean mode) or MATCH(tag) AGAINST ('%s' in boolean mode))) ",
|
|
||||||
dbesc(protect_sprintf($myurl)),
|
|
||||||
dbesc(protect_sprintf($myurl)),
|
|
||||||
dbesc(protect_sprintf($diasp_url))
|
|
||||||
);
|
|
||||||
else
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from $sql_table where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
|
|
||||||
dbesc(protect_sprintf('%' . $myurl)),
|
|
||||||
dbesc(protect_sprintf('%' . $myurl . ']%')),
|
|
||||||
dbesc(protect_sprintf('%' . $diasp_url . ']%'))
|
|
||||||
);*/
|
|
||||||
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
||||||
dbesc(protect_sprintf($myurl)),
|
dbesc(protect_sprintf($myurl)),
|
||||||
|
|
|
@ -599,7 +599,9 @@ function network_content(&$a, $update = 0) {
|
||||||
info( t('Group is empty'));
|
info( t('Group is empty'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
|
$sql_table = "`item` INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND (`contact-id` IN ($contact_str) OR `allow_gid` like '".protect_sprintf('%<'.intval($group).'>%')."') and deleted = 0 ORDER BY `created` DESC) AS `temp1` ON item.parent = `temp1`.parent ";
|
||||||
|
$sql_extra = "";
|
||||||
|
//$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
|
||||||
$o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
|
$o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
|
||||||
}
|
}
|
||||||
elseif($cid) {
|
elseif($cid) {
|
||||||
|
@ -641,7 +643,8 @@ function network_content(&$a, $update = 0) {
|
||||||
|
|
||||||
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
||||||
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
||||||
$sql_order = "`item`.`received`";
|
//$sql_order = "`item`.`received`";
|
||||||
|
$sql_order = "";
|
||||||
|
|
||||||
if ($sql_table == "")
|
if ($sql_table == "")
|
||||||
$sql_table = "`item`";
|
$sql_table = "`item`";
|
||||||
|
@ -657,23 +660,6 @@ function network_content(&$a, $update = 0) {
|
||||||
if (get_config('system','only_tag_search'))
|
if (get_config('system','only_tag_search'))
|
||||||
$tag = true;
|
$tag = true;
|
||||||
|
|
||||||
/*if (get_config('system','use_fulltext_engine')) {
|
|
||||||
if(strpos($search,'#') === 0)
|
|
||||||
$sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
|
|
||||||
dbesc(protect_sprintf($search))
|
|
||||||
);
|
|
||||||
else
|
|
||||||
$sql_extra .= sprintf(" AND (MATCH(`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode)) ",
|
|
||||||
dbesc(protect_sprintf($search)),
|
|
||||||
dbesc(protect_sprintf($search))
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
|
|
||||||
dbesc(protect_sprintf('%' . $search . '%')),
|
|
||||||
dbesc(protect_sprintf('%]' . $search . '[%'))
|
|
||||||
);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if($tag) {
|
if($tag) {
|
||||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
||||||
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||||
|
@ -705,20 +691,6 @@ function network_content(&$a, $update = 0) {
|
||||||
$myurl = substr($myurl,strpos($myurl,'://')+3);
|
$myurl = substr($myurl,strpos($myurl,'://')+3);
|
||||||
$myurl = str_replace('www.','',$myurl);
|
$myurl = str_replace('www.','',$myurl);
|
||||||
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
||||||
/*if (get_config('system','use_fulltext_engine'))
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
|
|
||||||
//$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (`author-link` IN ('https://%s', 'http://%s') OR MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
|
|
||||||
//$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
|
||||||
dbesc(protect_sprintf($myurl)),
|
|
||||||
dbesc(protect_sprintf($myurl)),
|
|
||||||
dbesc(protect_sprintf($diasp_url))
|
|
||||||
);
|
|
||||||
else
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
|
|
||||||
dbesc(protect_sprintf('%' . $myurl)),
|
|
||||||
dbesc(protect_sprintf('%' . $myurl . ']%')),
|
|
||||||
dbesc(protect_sprintf('%' . $diasp_url . ']%'))
|
|
||||||
);*/
|
|
||||||
|
|
||||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
|
||||||
dbesc(protect_sprintf($myurl)),
|
dbesc(protect_sprintf($myurl)),
|
||||||
|
@ -781,7 +753,7 @@ function network_content(&$a, $update = 0) {
|
||||||
$simple_update
|
$simple_update
|
||||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||||
$sql_extra $sql_nets
|
$sql_extra $sql_nets
|
||||||
ORDER BY $sql_order DESC $pager_sql ",
|
ORDER BY `item`.`received` DESC $pager_sql ",
|
||||||
intval($_SESSION['uid'])
|
intval($_SESSION['uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -127,18 +127,6 @@ function search_content(&$a) {
|
||||||
if (get_config('system','only_tag_search'))
|
if (get_config('system','only_tag_search'))
|
||||||
$tag = true;
|
$tag = true;
|
||||||
|
|
||||||
/*if (get_config('system','use_fulltext_engine')) {
|
|
||||||
if($tag)
|
|
||||||
$sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search)));
|
|
||||||
else
|
|
||||||
$sql_extra = sprintf(" AND MATCH (`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) ", dbesc(protect_sprintf($search)));
|
|
||||||
} else {
|
|
||||||
if($tag)
|
|
||||||
$sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . protect_sprintf(preg_quote($search)) . '\\['));
|
|
||||||
else
|
|
||||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if($tag) {
|
if($tag) {
|
||||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d",
|
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d",
|
||||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
|
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
|
||||||
|
|
Loading…
Reference in a new issue