remove lots of duplicated code in diabook config handling
This commit is contained in:
parent
1b43ef9205
commit
2d614b6700
1 changed files with 152 additions and 258 deletions
|
@ -9,6 +9,19 @@
|
|||
|
||||
$a = get_app();
|
||||
|
||||
function get_diabook_config($key, $default = false) {
|
||||
if (local_user()) {
|
||||
$result = get_pconfig(local_user(), "diabook", $key);
|
||||
if ($result !== false)
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = get_config("diabook", $key);
|
||||
if ($result !== false)
|
||||
return $result;
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
function diabook_init(&$a) {
|
||||
|
||||
|
@ -24,65 +37,16 @@ load_config("diabook");
|
|||
load_pconfig(local_user(), "diabook");
|
||||
|
||||
//get statuses of boxes at right-hand-column
|
||||
$close_pages = false;
|
||||
$site_close_pages = get_config("diabook", "close_pages" );
|
||||
if (local_user()) {$close_pages = get_pconfig(local_user(), "diabook", "close_pages");}
|
||||
if ($close_pages===false) $close_pages=$site_close_pages;
|
||||
if ($close_pages===false) $close_pages="1";
|
||||
|
||||
$close_profiles = false;
|
||||
$site_close_profiles = get_config("diabook", "close_profiles" );
|
||||
if (local_user()) {$close_profiles = get_pconfig(local_user(), "diabook", "close_profiles");}
|
||||
if ($close_profiles===false) $close_profiles=$site_close_profiles;
|
||||
if ($close_profiles===false) $close_profiles="0";
|
||||
|
||||
$close_helpers = false;
|
||||
$site_close_helpers = get_config("diabook", "close_helpers" );
|
||||
if (local_user()) {$close_helpers = get_pconfig(local_user(), "diabook", "close_helpers");}
|
||||
if ($close_helpers===false) $close_helpers=$site_close_helpers;
|
||||
if ($close_helpers===false) $close_helpers="0";
|
||||
|
||||
$close_services = false;
|
||||
$site_close_services = get_config("diabook", "close_services" );
|
||||
if (local_user()) {$close_services = get_pconfig(local_user(), "diabook", "close_services");}
|
||||
if ($close_services===false) $close_services=$site_close_services;
|
||||
if ($close_services===false) $close_services="0";
|
||||
|
||||
$close_friends = false;
|
||||
$site_close_friends = get_config("diabook", "close_friends" );
|
||||
if (local_user()) {$close_friends = get_pconfig(local_user(), "diabook", "close_friends");}
|
||||
if ($close_friends===false) $close_friends=$site_close_friends;
|
||||
if ($close_friends===false) $close_friends="0";
|
||||
|
||||
$close_lastusers = false;
|
||||
$site_close_lastusers = get_config("diabook", "close_lastusers" );
|
||||
if (local_user()) {$close_lastusers = get_pconfig(local_user(), "diabook", "close_lastusers");}
|
||||
if ($close_lastusers===false) $close_lastusers=$site_close_lastusers;
|
||||
if ($close_lastusers===false) $close_lastusers="0";
|
||||
|
||||
$close_lastphotos = false;
|
||||
$site_close_lastphotos = get_config("diabook", "close_lastphotos" );
|
||||
if (local_user()) {$close_lastphotos = get_pconfig(local_user(), "diabook", "close_lastphotos");}
|
||||
if ($close_lastphotos===false) $close_lastphotos=$site_close_lastphotos;
|
||||
if ($close_lastphotos===false) $close_lastphotos="0";
|
||||
|
||||
$close_lastlikes = false;
|
||||
$site_close_lastlikes = get_config("diabook", "close_lastlikes" );
|
||||
if (local_user()) {$close_lastlikes = get_pconfig(local_user(), "diabook", "close_lastlikes");}
|
||||
if ($close_lastlikes===false) $close_lastlikes=$site_close_lastlikes;
|
||||
if ($close_lastlikes===false) $close_lastlikes="0";
|
||||
|
||||
$close_twitter = false;
|
||||
$site_close_twitter = get_config("diabook", "close_twitter" );
|
||||
if (local_user()) {$close_twitter = get_pconfig(local_user(), "diabook", "close_twitter");}
|
||||
if ($close_twitter===false) $close_twitter=$site_close_twitter;
|
||||
if ($close_twitter===false) $close_twitter="1";
|
||||
|
||||
$close_mapquery = false;
|
||||
$site_close_mapquery = get_config("diabook", "close_mapquery" );
|
||||
if (local_user()) {$close_mapquery = get_pconfig(local_user(), "diabook", "close_mapquery");}
|
||||
if ($close_mapquery===false) $close_mapquery=$site_close_mapquery;
|
||||
if ($close_mapquery===false) $close_mapquery="1";
|
||||
$close_pages = get_diabook_config( "close_pages", 1 );
|
||||
$close_profiles = get_diabook_config( "close_profiles", 0 );
|
||||
$close_helpers = get_diabook_config( "close_helpers", 0 );
|
||||
$close_services = get_diabook_config( "close_services", 0 );
|
||||
$close_friends = get_diabook_config( "close_friends", 0 );
|
||||
$close_lastusers = get_diabook_config( "close_lastusers", 0 );
|
||||
$close_lastphotos = get_diabook_config( "close_lastphotos", 0 );
|
||||
$close_lastlikes = get_diabook_config( "close_lastlikes", 0 );
|
||||
$close_twitter = get_diabook_config( "close_twitter", 1 );
|
||||
$close_mapquery = get_diabook_config( "close_mapquery", 1 );
|
||||
|
||||
//get resolution (wide/normal)
|
||||
$resolution=false;
|
||||
|
@ -96,11 +60,7 @@ if ($resolution=="wide") {
|
|||
$a->page['htmlhead'] .= '<meta name="viewport" content="width=980" />';
|
||||
}
|
||||
//get colour-scheme
|
||||
$color = false;
|
||||
$site_color = get_config("diabook", "color" );
|
||||
if (local_user()) {$color = get_pconfig(local_user(), "diabook", "color");}
|
||||
if ($color===false) $color=$site_color;
|
||||
if ($color===false) $color="diabook";
|
||||
$color = get_diabook_config( "color", "diabook" );
|
||||
|
||||
if ($color=="diabook") $color_path = "/";
|
||||
if ($color=="aerith") $color_path = "/diabook-aerith/";
|
||||
|
@ -223,21 +183,9 @@ if ($color=="dark") $color_path = "/diabook-dark/";
|
|||
|
||||
//check if mapquerybox is active and print
|
||||
if($close_mapquery != "1") {
|
||||
$ELZoom=false;
|
||||
$ELPosX=false;
|
||||
$ELPosy=false;
|
||||
$site_ELZoom = get_config("diabook", "ELZoom" );
|
||||
$site_ELPosX = get_config("diabook", "ELPosX" );
|
||||
$site_ELPosY = get_config("diabook", "ELPosY" );
|
||||
$ELZoom = get_pconfig(local_user(), "diabook", "ELZoom");
|
||||
$ELPosX = get_pconfig(local_user(), "diabook", "ELPosX");
|
||||
$ELPosY = get_pconfig(local_user(), "diabook", "ELPosY");
|
||||
if ($ELZoom===false) $ELZoom=$site_ELZoom;
|
||||
if ($ELPosX===false) $ELPosX=$site_ELPosX;
|
||||
if ($ELPosY===false) $ELPosY=$site_ELPosY;
|
||||
if ($ELZoom===false) $ELZoom="0";
|
||||
if ($ELPosX===false) $ELPosX="0";
|
||||
if ($ELPosY===false) $ELPosY="0";
|
||||
$ELZoom = get_diabook_config( "ELZoom", 0 );
|
||||
$ELPosX = get_diabook_config( "ELPosX", 0);
|
||||
$ELPosY = get_diabook_config( "ELPosY", 0);
|
||||
$a->page['htmlhead'] .= '
|
||||
<script>
|
||||
|
||||
|
@ -288,11 +236,7 @@ if ($color=="dark") $color_path = "/diabook-dark/";
|
|||
}
|
||||
//check if twitterbox is active and print
|
||||
if($close_twitter != "1") {
|
||||
$TSearchTerm=false;
|
||||
$site_TSearchTerm = get_config("diabook", "TSearchTerm" );
|
||||
$TSearchTerm = get_pconfig(local_user(), "diabook", "TSearchTerm");
|
||||
if ($TSearchTerm===false) $TSearchTerm=$site_TSearchTerm;
|
||||
if ($TSearchTerm===false) $TSearchTerm="friendica";
|
||||
$TSearchTerm = get_diabook_config( "TSearchTerm", "friendica" );
|
||||
$a->page['htmlhead'] .= '
|
||||
<script>
|
||||
$(function() {
|
||||
|
@ -424,66 +368,16 @@ if ($color=="dark") $color_path = "/diabook-dark/";
|
|||
function diabook_community_info() {
|
||||
$a = get_app();
|
||||
|
||||
$close_pages = false;
|
||||
$site_close_pages = get_config("diabook", "close_pages" );
|
||||
if (local_user()) {$close_pages = get_pconfig(local_user(), "diabook", "close_pages");}
|
||||
if ($close_pages===false) $close_pages=$site_close_pages;
|
||||
if ($close_pages===false) $close_pages="1";
|
||||
|
||||
$close_profiles = false;
|
||||
$site_close_profiles = get_config("diabook", "close_profiles" );
|
||||
if (local_user()) {$close_profiles = get_pconfig(local_user(), "diabook", "close_profiles");}
|
||||
if ($close_profiles===false) $close_profiles=$site_close_profiles;
|
||||
if ($close_profiles===false) $close_profiles="0";
|
||||
|
||||
$close_helpers = false;
|
||||
$site_close_helpers = get_config("diabook", "close_helpers" );
|
||||
if (local_user()) {$close_helpers = get_pconfig(local_user(), "diabook", "close_helpers");}
|
||||
if ($close_helpers===false) $close_helpers=$site_close_helpers;
|
||||
if ($close_helpers===false) $close_helpers="0";
|
||||
|
||||
$close_services = false;
|
||||
$site_close_services = get_config("diabook", "close_services" );
|
||||
if (local_user()) {$close_services = get_pconfig(local_user(), "diabook", "close_services");}
|
||||
if ($close_services===false) $close_services=$site_close_services;
|
||||
if ($close_services===false) $close_services="0";
|
||||
|
||||
$close_friends = false;
|
||||
$site_close_friends = get_config("diabook", "close_friends" );
|
||||
if (local_user()) {$close_friends = get_pconfig(local_user(), "diabook", "close_friends");}
|
||||
if ($close_friends===false) $close_friends=$site_close_friends;
|
||||
if ($close_friends===false) $close_friends="0";
|
||||
|
||||
$close_lastusers = false;
|
||||
$site_close_lastusers = get_config("diabook", "close_lastusers" );
|
||||
if (local_user()) {$close_lastusers = get_pconfig(local_user(), "diabook", "close_lastusers");}
|
||||
if ($close_lastusers===false) $close_lastusers=$site_close_lastusers;
|
||||
if ($close_lastusers===false) $close_lastusers="0";
|
||||
|
||||
$close_lastphotos = false;
|
||||
$site_close_lastphotos = get_config("diabook", "close_lastphotos" );
|
||||
if (local_user()) {$close_lastphotos = get_pconfig(local_user(), "diabook", "close_lastphotos");}
|
||||
if ($close_lastphotos===false) $close_lastphotos=$site_close_lastphotos;
|
||||
if ($close_lastphotos===false) $close_lastphotos="0";
|
||||
|
||||
$close_lastlikes = false;
|
||||
$site_close_lastlikes = get_config("diabook", "close_lastlikes" );
|
||||
if (local_user()) {$close_lastlikes = get_pconfig(local_user(), "diabook", "close_lastlikes");}
|
||||
if ($close_lastlikes===false) $close_lastlikes=$site_close_lastlikes;
|
||||
if ($close_lastlikes===false) $close_lastlikes="0";
|
||||
|
||||
$close_twitter = false;
|
||||
$site_close_twitter = get_config("diabook", "close_twitter" );
|
||||
if (local_user()) {$close_twitter = get_pconfig(local_user(), "diabook", "close_twitter");}
|
||||
if ($close_twitter===false) $close_twitter=$site_close_twitter;
|
||||
if ($close_twitter===false) $close_twitter="1";
|
||||
|
||||
$close_mapquery = false;
|
||||
$site_close_mapquery = get_config("diabook", "close_mapquery" );
|
||||
if (local_user()) {$close_mapquery = get_pconfig(local_user(), "diabook", "close_mapquery");}
|
||||
if ($close_mapquery===false) $close_mapquery=$site_close_mapquery;
|
||||
if ($close_mapquery===false) $close_mapquery="1";
|
||||
|
||||
$close_pages = get_diabook_config( "close_pages", 1 );
|
||||
$close_profiles = get_diabook_config( "close_profiles", 0 );
|
||||
$close_helpers = get_diabook_config( "close_helpers", 0 );
|
||||
$close_services = get_diabook_config( "close_services", 0 );
|
||||
$close_friends = get_diabook_config( "close_friends", 0 );
|
||||
$close_lastusers = get_diabook_config( "close_lastusers", 0 );
|
||||
$close_lastphotos = get_diabook_config( "close_lastphotos", 0 );
|
||||
$close_lastlikes = get_diabook_config( "close_lastlikes", 0 );
|
||||
$close_twitter = get_diabook_config( "close_twitter", 1 );
|
||||
$close_mapquery = get_diabook_config( "close_mapquery", 1 );
|
||||
|
||||
// comunity_profiles
|
||||
if($close_profiles != "1") {
|
||||
|
|
Loading…
Reference in a new issue