added spaces + some curly braces + some usage of dbm::is_result()
Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
parent
bebff8ebbb
commit
03571f6e74
11 changed files with 309 additions and 268 deletions
|
@ -121,8 +121,9 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
||||||
$sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude']));
|
$sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude']));
|
||||||
|
|
||||||
if (is_array($x['networks']) && count($x['networks'])) {
|
if (is_array($x['networks']) && count($x['networks'])) {
|
||||||
for($y = 0; $y < count($x['networks']) ; $y ++)
|
for ($y = 0; $y < count($x['networks']) ; $y ++) {
|
||||||
$x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'";
|
$x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'";
|
||||||
|
}
|
||||||
$str_nets = implode(',',$x['networks']);
|
$str_nets = implode(',',$x['networks']);
|
||||||
$sql_extra .= " AND `network` IN ( $str_nets ) ";
|
$sql_extra .= " AND `network` IN ( $str_nets ) ";
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,17 +219,20 @@ function bb_find_open_close($s, $open, $close, $occurance = 1) {
|
||||||
|
|
||||||
$start_pos = -1;
|
$start_pos = -1;
|
||||||
for ($i = 1; $i <= $occurance; $i++) {
|
for ($i = 1; $i <= $occurance; $i++) {
|
||||||
if( $start_pos !== false)
|
if ( $start_pos !== false) {
|
||||||
$start_pos = strpos($s, $open, $start_pos + 1);
|
$start_pos = strpos($s, $open, $start_pos + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( $start_pos === false)
|
if ( $start_pos === false) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$end_pos = strpos($s, $close, $start_pos);
|
$end_pos = strpos($s, $close, $start_pos);
|
||||||
|
|
||||||
if( $end_pos === false)
|
if ( $end_pos === false) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$res = array( 'start' => $start_pos, 'end' => $end_pos );
|
$res = array( 'start' => $start_pos, 'end' => $end_pos );
|
||||||
|
|
||||||
|
@ -243,30 +246,43 @@ function get_bb_tag_pos($s, $name, $occurance = 1) {
|
||||||
|
|
||||||
$start_open = -1;
|
$start_open = -1;
|
||||||
for ($i = 1; $i <= $occurance; $i++) {
|
for ($i = 1; $i <= $occurance; $i++) {
|
||||||
if( $start_open !== false)
|
if ( $start_open !== false) {
|
||||||
$start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags
|
$start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( $start_open === false)
|
if ( $start_open === false) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$start_equal = strpos($s, '=', $start_open);
|
$start_equal = strpos($s, '=', $start_open);
|
||||||
$start_close = strpos($s, ']', $start_open);
|
$start_close = strpos($s, ']', $start_open);
|
||||||
|
|
||||||
if( $start_close === false)
|
if ( $start_close === false) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$start_close++;
|
$start_close++;
|
||||||
|
|
||||||
$end_open = strpos($s, '[/' . $name . ']', $start_close);
|
$end_open = strpos($s, '[/' . $name . ']', $start_close);
|
||||||
|
|
||||||
if( $end_open === false)
|
if ( $end_open === false) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$res = array( 'start' => array('open' => $start_open, 'close' => $start_close),
|
$res = array(
|
||||||
'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
|
'start' => array(
|
||||||
if( $start_equal !== false)
|
'open' => $start_open,
|
||||||
|
'close' => $start_close
|
||||||
|
),
|
||||||
|
'end' => array(
|
||||||
|
'open' => $end_open,
|
||||||
|
'close' => $end_open + strlen('[/' . $name . ']')
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if ( $start_equal !== false) {
|
||||||
$res['start']['equal'] = $start_equal + 1;
|
$res['start']['equal'] = $start_equal + 1;
|
||||||
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,9 +215,9 @@ function common_friends_visitor_widget($profile_uid) {
|
||||||
dbesc(normalise_link(get_my_url())),
|
dbesc(normalise_link(get_my_url())),
|
||||||
intval($profile_uid)
|
intval($profile_uid)
|
||||||
);
|
);
|
||||||
if (dbm::is_result($r))
|
if (dbm::is_result($r)) {
|
||||||
$cid = $r[0]['id'];
|
$cid = $r[0]['id'];
|
||||||
else {
|
} else {
|
||||||
$r = q("select id from gcontact where nurl = '%s' limit 1",
|
$r = q("select id from gcontact where nurl = '%s' limit 1",
|
||||||
dbesc(normalise_link(get_my_url()))
|
dbesc(normalise_link(get_my_url()))
|
||||||
);
|
);
|
||||||
|
@ -227,22 +227,26 @@ function common_friends_visitor_widget($profile_uid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($cid == 0 && $zcid == 0)
|
if ($cid == 0 && $zcid == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
require_once('include/socgraph.php');
|
require_once('include/socgraph.php');
|
||||||
|
|
||||||
if($cid)
|
if ($cid) {
|
||||||
$t = count_common_friends($profile_uid,$cid);
|
$t = count_common_friends($profile_uid,$cid);
|
||||||
else
|
} else {
|
||||||
$t = count_common_friends_zcid($profile_uid,$zcid);
|
$t = count_common_friends_zcid($profile_uid,$zcid);
|
||||||
if(! $t)
|
}
|
||||||
|
if (! $t) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if($cid)
|
if ($cid) {
|
||||||
$r = common_friends($profile_uid,$cid,0,5,true);
|
$r = common_friends($profile_uid,$cid,0,5,true);
|
||||||
else
|
} else {
|
||||||
$r = common_friends_zcid($profile_uid,$zcid,0,5,true);
|
$r = common_friends_zcid($profile_uid,$zcid,0,5,true);
|
||||||
|
}
|
||||||
|
|
||||||
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
||||||
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
|
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
|
||||||
|
|
|
@ -484,9 +484,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
||||||
$str_blocked = get_pconfig(local_user(),'system','blocked');
|
$str_blocked = get_pconfig(local_user(),'system','blocked');
|
||||||
if ($str_blocked) {
|
if ($str_blocked) {
|
||||||
$arr_blocked = explode(',',$str_blocked);
|
$arr_blocked = explode(',',$str_blocked);
|
||||||
for($x = 0; $x < count($arr_blocked); $x ++)
|
for ($x = 0; $x < count($arr_blocked); $x ++) {
|
||||||
$arr_blocked[$x] = trim($arr_blocked[$x]);
|
$arr_blocked[$x] = trim($arr_blocked[$x]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1337,15 +1338,17 @@ function sort_item_children($items) {
|
||||||
function add_children_to_list($children, &$arr) {
|
function add_children_to_list($children, &$arr) {
|
||||||
foreach ($children as $y) {
|
foreach ($children as $y) {
|
||||||
$arr[] = $y;
|
$arr[] = $y;
|
||||||
if(count($y['children']))
|
if (count($y['children'])) {
|
||||||
add_children_to_list($y['children'], $arr);
|
add_children_to_list($y['children'], $arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function conv_sort($arr,$order) {
|
function conv_sort($arr,$order) {
|
||||||
|
|
||||||
if((!(is_array($arr) && count($arr))))
|
if ((!(is_array($arr) && count($arr)))) {
|
||||||
return array();
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$parents = array();
|
$parents = array();
|
||||||
$children = array();
|
$children = array();
|
||||||
|
@ -1353,24 +1356,31 @@ function conv_sort($arr,$order) {
|
||||||
|
|
||||||
// This is a preparation for having two different items with the same uri in one thread
|
// This is a preparation for having two different items with the same uri in one thread
|
||||||
// This will otherwise lead to an endless loop.
|
// This will otherwise lead to an endless loop.
|
||||||
foreach($arr as $x)
|
foreach ($arr as $x) {
|
||||||
if (!isset($newarr[$x['uri']]))
|
if (!isset($newarr[$x['uri']])) {
|
||||||
$newarr[$x['uri']] = $x;
|
$newarr[$x['uri']] = $x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$arr = $newarr;
|
$arr = $newarr;
|
||||||
|
|
||||||
foreach($arr as $x)
|
foreach ($arr as $x) {
|
||||||
if($x['id'] == $x['parent'])
|
if ($x['id'] == $x['parent']) {
|
||||||
$parents[] = $x;
|
$parents[] = $x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(stristr($order,'created'))
|
if (stristr($order,'created')) {
|
||||||
usort($parents,'sort_thr_created');
|
usort($parents,'sort_thr_created');
|
||||||
elseif(stristr($order,'commented'))
|
} elseif (stristr($order,'commented')) {
|
||||||
usort($parents,'sort_thr_commented');
|
usort($parents,'sort_thr_commented');
|
||||||
|
}
|
||||||
|
|
||||||
if(count($parents))
|
if (count($parents)) {
|
||||||
foreach($parents as $i=>$_x)
|
foreach ($parents as $i=>$_x) {
|
||||||
$parents[$i]['children'] = get_item_children($arr, $_x);
|
$parents[$i]['children'] = get_item_children($arr, $_x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*foreach ($arr as $x) {
|
/*foreach ($arr as $x) {
|
||||||
if ($x['id'] != $x['parent']) {
|
if ($x['id'] != $x['parent']) {
|
||||||
|
@ -1394,12 +1404,13 @@ function conv_sort($arr,$order) {
|
||||||
if (count($parents)) {
|
if (count($parents)) {
|
||||||
foreach ($parents as $x) {
|
foreach ($parents as $x) {
|
||||||
$ret[] = $x;
|
$ret[] = $x;
|
||||||
if(count($x['children']))
|
if (count($x['children'])) {
|
||||||
add_children_to_list($x['children'], $ret);
|
add_children_to_list($x['children'], $ret);
|
||||||
/*foreach ($x['children'] as $y)
|
/*foreach ($x['children'] as $y)
|
||||||
$ret[] = $y;*/
|
$ret[] = $y;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -1418,9 +1429,11 @@ function sort_thr_commented($a,$b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_thread_parent_index($arr,$x) {
|
function find_thread_parent_index($arr,$x) {
|
||||||
foreach($arr as $k => $v)
|
foreach ($arr as $k => $v) {
|
||||||
if($v['id'] == $x['parent'])
|
if ($v['id'] == $x['parent']) {
|
||||||
return $k;
|
return $k;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1443,8 +1456,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
|
||||||
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
|
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
|
||||||
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
|
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
|
||||||
. (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>');
|
. (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$ret[$v]['list_part'] = '';
|
$ret[$v]['list_part'] = '';
|
||||||
}
|
}
|
||||||
$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
|
$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
|
||||||
|
@ -1453,9 +1465,10 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($ret as $key) {
|
foreach ($ret as $key) {
|
||||||
if ($key['count'] == true)
|
if ($key['count'] == true) {
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$ret['count'] = $count;
|
$ret['count'] = $count;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
|
@ -18,6 +18,7 @@ function cron_run(&$argv, &$argc){
|
||||||
if (! $poll_interval) {
|
if (! $poll_interval) {
|
||||||
$poll_interval = 10;
|
$poll_interval = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($last) {
|
if ($last) {
|
||||||
$next = $last + ($poll_interval * 60);
|
$next = $last + ($poll_interval * 60);
|
||||||
if ($next > time()) {
|
if ($next > time()) {
|
||||||
|
@ -242,6 +243,10 @@ function cron_poll_contacts($argc, $argv) {
|
||||||
} else {
|
} else {
|
||||||
proc_run(PRIORITY_LOW, 'include/onepoll.php', intval($contact['id']));
|
proc_run(PRIORITY_LOW, 'include/onepoll.php', intval($contact['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($interval) {
|
||||||
|
time_sleep_until(microtime(true) + (float) $interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,21 @@ function cronhooks_run(&$argv, &$argc){
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
|
|
||||||
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||||
foreach ($a->hooks["cron"] as $hook)
|
foreach ($a->hooks["cron"] as $hook) {
|
||||||
if ($hook[1] == $argv[1]) {
|
if ($hook[1] == $argv[1]) {
|
||||||
logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
|
logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
|
||||||
call_single_hook($a, $name, $hook, $data);
|
call_single_hook($a, $name, $hook, $data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$last = get_config('system', 'last_cronhook');
|
$last = get_config('system', 'last_cronhook');
|
||||||
|
|
||||||
$poll_interval = intval(get_config('system','cronhook_interval'));
|
$poll_interval = intval(get_config('system','cronhook_interval'));
|
||||||
if(! $poll_interval)
|
if (! $poll_interval) {
|
||||||
$poll_interval = 9;
|
$poll_interval = 9;
|
||||||
|
}
|
||||||
|
|
||||||
if ($last) {
|
if ($last) {
|
||||||
$next = $last + ($poll_interval * 60);
|
$next = $last + ($poll_interval * 60);
|
||||||
|
|
Loading…
Reference in a new issue