X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=jappixmini%2Fjappixmini.php;h=370d2c7b7e6a1d550db0fb7656a2488f10298e98;hb=8fa3f2415a3f3906f5fdadd1601ec6830ecce3c9;hp=69c58e94c8930dede7471d822a07d754cb2ff365;hpb=7b71fec6222988a89423ee4584c87927f1a6e149;p=friendica-addons.git diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 69c58e94..370d2c7b 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -122,6 +122,22 @@ function jappixmini_plugin_admin(&$a, &$o) { $o .= ''; $o .= '
'; + // bosh address + $bosh_address = get_config("jappixmini", "bosh_address"); + $o .= '


'; + $o .= '

'; + + // default server address + $default_server = get_config("jappixmini", "default_server"); + $o .= '


'; + $o .= '

'; + + // default user name to friendica nickname + $default_user = intval(get_config("jappixmini", "default_user")); + $default_user = intval($default_user) ? ' checked="checked"' : ''; + $o .= ''; + $o .= '
'; + // info text field $info_text = get_config("jappixmini", "infotext"); $o .= '


'; @@ -137,8 +153,14 @@ function jappixmini_plugin_admin_post(&$a) { if ($submit) { $info_text = $_REQUEST['jappixmini-infotext']; $bosh_proxy = intval($_REQUEST['jappixmini-proxy']); + $default_user = intval($_REQUEST['jappixmini-defaultuser']); + $bosh_address = $_REQUEST['jappixmini-address']; + $default_server = $_REQUEST['jappixmini-server']; set_config("jappixmini", "infotext", $info_text); set_config("jappixmini", "bosh_proxy", $bosh_proxy); + set_config("jappixmini", "bosh_address", $bosh_address); + set_config("jappixmini", "default_server", $default_server); + set_config("jappixmini", "default_user", $default_user); } } @@ -224,6 +246,11 @@ function jappixmini_settings(&$a, &$s) { $dontinsertchat = get_pconfig(local_user(),'jappixmini','dontinsertchat'); $insertchat = !(intval($dontinsertchat) ? ' checked="checked"' : ''); + $defaultbosh = get_config("jappixmini", "bosh_address"); + + if ($defaultbosh != "") + set_pconfig(local_user(),'jappixmini','bosh', $defaultbosh); + $username = get_pconfig(local_user(),'jappixmini','username'); $username = htmlentities($username); $server = get_pconfig(local_user(),'jappixmini','server'); @@ -239,6 +266,12 @@ function jappixmini_settings(&$a, &$s) { $encrypt_checked = $encrypt ? ' checked="checked"' : ''; $encrypt_disabled = $encrypt ? '' : ' disabled="disabled"'; + if ($server == "") + $server = get_config("jappixmini", "default_server"); + + if (($username == "") && get_config("jappixmini", "default_user")) + $username = $a->user["nickname"]; + $info_text = get_config("jappixmini", "infotext"); $info_text = htmlentities($info_text); $info_text = str_replace("\n", "
", $info_text); @@ -261,10 +294,14 @@ function jappixmini_settings(&$a, &$s) { $a->page['htmlhead'] .= ''."\r\n"; } - $s .= '

'; + $s .= ''; + $s .= '

'.t('Jappix Mini').'

'; + $s .= '
'; + $s .= ''; @@ -400,9 +439,12 @@ function jappixmini_script(&$a,&$s) { if(! local_user()) return; + if ($_GET["mode"] == "minimal") + return; + $activate = get_pconfig(local_user(),'jappixmini','activate'); $dontinsertchat = get_pconfig(local_user(), 'jappixmini','dontinsertchat'); - if (!$activate or $dontinsertchat) return; + if (!$activate || $dontinsertchat) return; $a->page['htmlhead'] .= ''."\r\n"; $a->page['htmlhead'] .= ''."\r\n"; @@ -446,7 +488,8 @@ function jappixmini_script(&$a,&$s) { dbesc($dfrn_id), dbesc($dfrn_id) ); - $name = $r[0]["name"]; + if (count($r)) + $name = $r[0]["name"]; $value = $row['v']; $pos = strpos($value, ":"); @@ -462,11 +505,16 @@ function jappixmini_script(&$a,&$s) { // get nickname $r = q("SELECT `username` FROM `user` WHERE `uid`=$uid"); $nickname = json_encode($r[0]["username"]); + $groupchats = get_config('jappixmini','groupchats'); + //if $groupchats has no value jappix_addon_start will produce a syntax error + if(empty($groupchats)){ + $groupchats = "{}"; + } // add javascript to start Jappix Mini $a->page['htmlhead'] .= ""; @@ -502,7 +550,8 @@ function jappixmini_cron(&$a, $d) { $uid = $row["uid"]; // for each user, go through list of contacts - $contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`)))", intval($uid)); + $contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`))) AND `network` = '%s'", + intval($uid), dbesc(NETWORK_DFRN)); foreach ($contacts as $contact_row) { $request = $contact_row["request"]; if (!$request) continue;