From: Leberwurscht Date: Tue, 17 Apr 2012 20:17:06 +0000 (+0200) Subject: jappixmini: display number of addresses/contacts in user settings X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6846c0658b4f20e27c062f9e11f86a98f681a3cd;p=friendica-addons.git jappixmini: display number of addresses/contacts in user settings --- diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 4c3ebcc4..d09427e7 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -257,6 +257,16 @@ function jappixmini_settings(&$a, &$s) { $info_text = htmlentities($info_text); $info_text = str_replace("\n", "
", $info_text); + // count contacts + $r = q("SELECT COUNT(1) as `cnt` FROM `pconfig` WHERE `uid`=%d AND `cat`='jappixmini' AND `k` LIKE 'id:%%'", local_user()); + if (count($r)) $contact_cnt = $r[0]["cnt"]; + else $contact_cnt = 0; + + // count jabber addresses + $r = q("SELECT COUNT(1) as `cnt` FROM `pconfig` WHERE `uid`=%d AND `cat`='jappixmini' AND `k` LIKE 'id:%%' AND `v` LIKE '%%@%%'", local_user()); + if (count($r)) $address_cnt = $r[0]["cnt"]; + else $address_cnt = 0; + if (!$activate) { // load scripts if not yet activated so that password can be saved $a->page['htmlhead'] .= ''."\r\n"; @@ -304,6 +314,7 @@ function jappixmini_settings(&$a, &$s) { $s .= ' '; $s .= '
'; if ($info_text) $s .= '
Configuration help:

'.$info_text.'

'; + $s .= '
Status:

Addon knows '.$address_cnt.' Jabber addresses of '.$contact_cnt.' Friendica contacts (takes some time, usually 10 minutes, to update).

'; $s .= ''; $s .= ' '; $s .= ''; @@ -390,7 +401,7 @@ function jappixmini_settings_post(&$a,&$b) { info( 'Jappix Mini settings saved.' ); if ($purge) { - q("DELETE FROM `pconfig` WHERE `uid`=$uid AND `cat`='jappixmini' and `k` LIKE 'id%%'"); + q("DELETE FROM `pconfig` WHERE `uid`=$uid AND `cat`='jappixmini' AND `k` LIKE 'id:%%'"); info( 'List of addresses purged.' ); } } @@ -438,7 +449,7 @@ function jappixmini_script(&$a,&$s) { // get a list of jabber accounts of the contacts $contacts = Array(); $uid = local_user(); - $rows = q("SELECT * FROM `pconfig` WHERE `uid`=$uid AND `cat`='jappixmini' and `k` LIKE 'id%%'"); + $rows = q("SELECT * FROM `pconfig` WHERE `uid`=$uid AND `cat`='jappixmini' AND `k` LIKE 'id:%%'"); foreach ($rows as $row) { $key = $row['k']; $pos = strpos($key, ":");