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']));
|
||||
|
||||
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]) . "'";
|
||||
}
|
||||
$str_nets = implode(',',$x['networks']);
|
||||
$sql_extra .= " AND `network` IN ( $str_nets ) ";
|
||||
}
|
||||
|
|
|
@ -219,17 +219,20 @@ function bb_find_open_close($s, $open, $close, $occurance = 1) {
|
|||
|
||||
$start_pos = -1;
|
||||
for ($i = 1; $i <= $occurance; $i++) {
|
||||
if( $start_pos !== false)
|
||||
if ( $start_pos !== false) {
|
||||
$start_pos = strpos($s, $open, $start_pos + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if( $start_pos === false)
|
||||
if ( $start_pos === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$end_pos = strpos($s, $close, $start_pos);
|
||||
|
||||
if( $end_pos === false)
|
||||
if ( $end_pos === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = array( 'start' => $start_pos, 'end' => $end_pos );
|
||||
|
||||
|
@ -243,30 +246,43 @@ function get_bb_tag_pos($s, $name, $occurance = 1) {
|
|||
|
||||
$start_open = -1;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if( $start_open === false)
|
||||
if ( $start_open === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start_equal = strpos($s, '=', $start_open);
|
||||
$start_close = strpos($s, ']', $start_open);
|
||||
|
||||
if( $start_close === false)
|
||||
if ( $start_close === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start_close++;
|
||||
|
||||
$end_open = strpos($s, '[/' . $name . ']', $start_close);
|
||||
|
||||
if( $end_open === false)
|
||||
if ( $end_open === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = array( 'start' => array('open' => $start_open, 'close' => $start_close),
|
||||
'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
|
||||
if( $start_equal !== false)
|
||||
$res = array(
|
||||
'start' => array(
|
||||
'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;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
|
|
@ -215,9 +215,9 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
dbesc(normalise_link(get_my_url())),
|
||||
intval($profile_uid)
|
||||
);
|
||||
if (dbm::is_result($r))
|
||||
if (dbm::is_result($r)) {
|
||||
$cid = $r[0]['id'];
|
||||
else {
|
||||
} else {
|
||||
$r = q("select id from gcontact where nurl = '%s' limit 1",
|
||||
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;
|
||||
}
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
if($cid)
|
||||
if ($cid) {
|
||||
$t = count_common_friends($profile_uid,$cid);
|
||||
else
|
||||
} else {
|
||||
$t = count_common_friends_zcid($profile_uid,$zcid);
|
||||
if(! $t)
|
||||
}
|
||||
if (! $t) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($cid)
|
||||
if ($cid) {
|
||||
$r = common_friends($profile_uid,$cid,0,5,true);
|
||||
else
|
||||
} else {
|
||||
$r = common_friends_zcid($profile_uid,$zcid,0,5,true);
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
||||
'$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');
|
||||
if ($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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1337,15 +1338,17 @@ function sort_item_children($items) {
|
|||
function add_children_to_list($children, &$arr) {
|
||||
foreach ($children as $y) {
|
||||
$arr[] = $y;
|
||||
if(count($y['children']))
|
||||
if (count($y['children'])) {
|
||||
add_children_to_list($y['children'], $arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function conv_sort($arr,$order) {
|
||||
|
||||
if((!(is_array($arr) && count($arr))))
|
||||
if ((!(is_array($arr) && count($arr)))) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$parents = 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 will otherwise lead to an endless loop.
|
||||
foreach($arr as $x)
|
||||
if (!isset($newarr[$x['uri']]))
|
||||
foreach ($arr as $x) {
|
||||
if (!isset($newarr[$x['uri']])) {
|
||||
$newarr[$x['uri']] = $x;
|
||||
}
|
||||
}
|
||||
|
||||
$arr = $newarr;
|
||||
|
||||
foreach($arr as $x)
|
||||
if($x['id'] == $x['parent'])
|
||||
foreach ($arr as $x) {
|
||||
if ($x['id'] == $x['parent']) {
|
||||
$parents[] = $x;
|
||||
}
|
||||
}
|
||||
|
||||
if(stristr($order,'created'))
|
||||
if (stristr($order,'created')) {
|
||||
usort($parents,'sort_thr_created');
|
||||
elseif(stristr($order,'commented'))
|
||||
} elseif (stristr($order,'commented')) {
|
||||
usort($parents,'sort_thr_commented');
|
||||
}
|
||||
|
||||
if(count($parents))
|
||||
foreach($parents as $i=>$_x)
|
||||
if (count($parents)) {
|
||||
foreach ($parents as $i=>$_x) {
|
||||
$parents[$i]['children'] = get_item_children($arr, $_x);
|
||||
}
|
||||
}
|
||||
|
||||
/*foreach ($arr as $x) {
|
||||
if ($x['id'] != $x['parent']) {
|
||||
|
@ -1394,12 +1404,13 @@ function conv_sort($arr,$order) {
|
|||
if (count($parents)) {
|
||||
foreach ($parents as $x) {
|
||||
$ret[] = $x;
|
||||
if(count($x['children']))
|
||||
if (count($x['children'])) {
|
||||
add_children_to_list($x['children'], $ret);
|
||||
/*foreach ($x['children'] as $y)
|
||||
$ret[] = $y;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -1418,9 +1429,11 @@ function sort_thr_commented($a,$b) {
|
|||
}
|
||||
|
||||
function find_thread_parent_index($arr,$x) {
|
||||
foreach($arr as $k => $v)
|
||||
if($v['id'] == $x['parent'])
|
||||
foreach ($arr as $k => $v) {
|
||||
if ($v['id'] == $x['parent']) {
|
||||
return $k;
|
||||
}
|
||||
}
|
||||
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);
|
||||
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>');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$ret[$v]['list_part'] = '';
|
||||
}
|
||||
$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;
|
||||
foreach ($ret as $key) {
|
||||
if ($key['count'] == true)
|
||||
if ($key['count'] == true) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$ret['count'] = $count;
|
||||
|
||||
return $ret;
|
||||
|
|
|
@ -18,6 +18,7 @@ function cron_run(&$argv, &$argc){
|
|||
if (! $poll_interval) {
|
||||
$poll_interval = 10;
|
||||
}
|
||||
|
||||
if ($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if ($next > time()) {
|
||||
|
@ -242,6 +243,10 @@ function cron_poll_contacts($argc, $argv) {
|
|||
} else {
|
||||
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');
|
||||
|
||||
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]) {
|
||||
logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
|
||||
call_single_hook($a, $name, $hook, $data);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$last = get_config('system', 'last_cronhook');
|
||||
|
||||
$poll_interval = intval(get_config('system','cronhook_interval'));
|
||||
if(! $poll_interval)
|
||||
if (! $poll_interval) {
|
||||
$poll_interval = 9;
|
||||
}
|
||||
|
||||
if ($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
|
|
Loading…
Reference in a new issue