minor code optimisation
This commit is contained in:
parent
0f5ae5cac8
commit
fc7d9c235c
@ -174,8 +174,7 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
|
|||||||
if(! is_array($authors))
|
if(! is_array($authors))
|
||||||
$authors = array($authors);
|
$authors = array($authors);
|
||||||
|
|
||||||
stringify_array_elms($authors,true);
|
$sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
|
||||||
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($owner) {
|
if($owner) {
|
||||||
@ -227,8 +226,7 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0
|
|||||||
if(! is_array($authors))
|
if(! is_array($authors))
|
||||||
$authors = array($authors);
|
$authors = array($authors);
|
||||||
|
|
||||||
stringify_array_elms($authors,true);
|
$sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
|
||||||
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($owner) {
|
if($owner) {
|
||||||
@ -280,8 +278,7 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
|
|||||||
if(! is_array($authors))
|
if(! is_array($authors))
|
||||||
$authors = array($authors);
|
$authors = array($authors);
|
||||||
|
|
||||||
stringify_array_elms($authors,true);
|
$sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
|
||||||
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($owner) {
|
if($owner) {
|
||||||
@ -351,8 +348,7 @@ function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) {
|
|||||||
if($safemode) {
|
if($safemode) {
|
||||||
$unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]);
|
$unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]);
|
||||||
if($unsafetags) {
|
if($unsafetags) {
|
||||||
stringify_array_elms($unsafetags,true);
|
$sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") ";
|
||||||
$sql_extra .= " and not term.term in ( " . implode(",",$unsafetags) . ") ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,9 +617,8 @@ function get_things($profile_hash,$uid) {
|
|||||||
if(! in_array($rr['obj_obj'],$profile_hashes))
|
if(! in_array($rr['obj_obj'],$profile_hashes))
|
||||||
$profile_hashes[] = $rr['obj_obj'];
|
$profile_hashes[] = $rr['obj_obj'];
|
||||||
}
|
}
|
||||||
stringify_array_elms($profile_hashes);
|
|
||||||
if(! $profile_hash) {
|
if(! $profile_hash) {
|
||||||
$exp = explode(',',$profile_hashes);
|
$exp = stringify_array($profile_hashes,true);
|
||||||
$p = q("select profile_guid as hash, profile_name as name from profile where profile_guid in ( $exp ) ");
|
$p = q("select profile_guid as hash, profile_name as name from profile where profile_guid in ( $exp ) ");
|
||||||
if($p) {
|
if($p) {
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
|
@ -2324,6 +2324,23 @@ function stringify_array_elms(&$arr, $escape = false) {
|
|||||||
$arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'";
|
$arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Similar to stringify_array_elms but returns a string. If $escape is true, dbesc() each element before adding quotes.
|
||||||
|
*
|
||||||
|
* @param array $arr
|
||||||
|
* @param boolean $escape (optional) default false
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function stringify_array($arr, $escape = false) {
|
||||||
|
if($arr) {
|
||||||
|
stringify_array_elms($arr);
|
||||||
|
return(implode(',',$arr));
|
||||||
|
}
|
||||||
|
return EMPTY_STR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Indents a flat JSON string to make it more human-readable.
|
* @brief Indents a flat JSON string to make it more human-readable.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user