From: Paul J R Date: Sat, 22 Sep 2012 21:41:56 +0000 (+1000) Subject: added a gravatar enable/disable bit X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=b26baaa1fd812e3c01646323119ca2b97ccdbd1d;p=gwvp-mini.git added a gravatar enable/disable bit --- diff --git a/gwvpmini/gwvpmini_admin.php b/gwvpmini/gwvpmini_admin.php index 6b721c3..b4f9db6 100644 --- a/gwvpmini/gwvpmini_admin.php +++ b/gwvpmini/gwvpmini_admin.php @@ -7,6 +7,18 @@ if(gwvpmini_isLoggedIn()) if(gwvpmini_isUserAdmin()) { } +$reg = gwvpmini_getConfigVal("gravatarenabled"); + +$use_gravatar = false; +if($reg == null) { + gwvpmini_setConfigVal("gravatarenabled", "1"); +} else if($reg == 1) { + $use_gravatar = true; +} else { + $use_gravatar = false; +} + +global $use_gravatar; function gwvpmini_AdminCallMe() { @@ -48,6 +60,9 @@ function gwvpmini_AdminCallMe() if($qspl[1] == "switchenablerepo") { return "gwvpmini_SwitchEnableRepo"; } + if($qspl[1] == "changegravs") { + return "gwvpmini_SwitchGravatars"; + } } else { error_log("i got here, where next?"); return "gwvpmini_AdminMainPage"; @@ -81,7 +96,7 @@ function gwvpmini_AdminMainPage() function gwvpmini_AdminMainPageBody() { global $BASE_URL; - global $can_register, $reg_reqs_confirm, $confirm_from_address; + global $can_register, $reg_reqs_confirm, $confirm_from_address, $use_gravatar; if($can_register) { $register = "Registration Enabled (Disable)"; @@ -94,10 +109,17 @@ function gwvpmini_AdminMainPageBody() } else { $regconfirm = "Registration Doesnt Require Confirmation (Enable)"; } + + if($use_gravatar) { + $usegrav = "Gravatars are enabled (Disable)"; + } else { + $usegrav = "Gravatars are disabled (Enable)"; + } + $totalusers = gwvpmini_GetNUsers(); echo ""; diff --git a/gwvpmini/gwvpmini_search.php b/gwvpmini/gwvpmini_search.php index 870dc0b..40fae3f 100644 --- a/gwvpmini/gwvpmini_search.php +++ b/gwvpmini/gwvpmini_search.php @@ -76,13 +76,12 @@ function gwvpmini_SearchMainPageBody() echo "
"; echo "

Users - $totalusers

"; - echo "$register
$regconfirm
"; + echo "$register
$regconfirm
$usegrav
"; echo "
"; echo "Address emails are sent from
"; echo "
"; @@ -471,4 +493,22 @@ function gwvpmini_SwitchEnableRepo() header("Location: $BASE_URL/admin"); } + +function gwvpmini_SwitchGravatars() +{ + global $BASE_URL, $use_gravatar; + + if($newst == 1) $stat = "disabled"; + else $stat = "enabled"; + + if($use_gravatar) { + gwvpmini_setConfigVal("gravatarenabled", "0"); + } else { + gwvpmini_setConfigVal("gravatarenabled", "1"); + } + + gwvpmini_SendMessage("info", "Gravatars $stat"); + + header("Location: $BASE_URL/admin"); +} ?> \ No newline at end of file diff --git a/gwvpmini/gwvpmini_gitrepo.php b/gwvpmini/gwvpmini_gitrepo.php index d8e0d32..b24e4bd 100644 --- a/gwvpmini/gwvpmini_gitrepo.php +++ b/gwvpmini/gwvpmini_gitrepo.php @@ -110,7 +110,7 @@ function gwvpmini_RepoMainPageBody() $owner = gwvpmini_getUser(null, null, $repo["owner"]); $repname = "$name"; - $repown = get_gravatar($owner["email"], 30, 'mm', 'g', true)."
".$owner["username"].""; + $repown = gwvpmini_HtmlGravatar($owner["email"], 30, "
")."".$owner["username"].""; echo "
$repname$repown$desc$lastlog
"; - // get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { + if($reps != false) { echo ""; foreach($reps as $rep) { $ownerinfo = gwvpmini_getUser(null, null, $rep["owner"]); - $userdets = get_gravatar($ownerinfo["email"], 40, 'mm', 'g', true); - $userdets .= "
".$ownerinfo["username"].""; + $userdets = gwvpmini_HtmlGravatar($ownerinfo["email"], 40, "
")."".$ownerinfo["username"].""; $repodets = "".$rep["name"]."
".$rep["desc"]; echo ""; @@ -97,8 +96,7 @@ function gwvpmini_SearchMainPageBody() echo "
$userdets$repodets
"; $ownedrepos = "BLAHBLAH"; foreach($ppls as $ppl) { - $userdets = get_gravatar($ppl["email"], 40, 'mm', 'g', true); - $userdets .= "
".$ppl["username"].""; + $userdets = gwvpmini_HtmlGravatar($ppl["email"], 40, "
")."".$ppl["username"].""; $repos = gwvpmini_GetOwnedRepos($ppl["username"]); if($repos == false) $ownedrepos = "No Repos"; else { diff --git a/gwvpmini/gwvpmini_view.php b/gwvpmini/gwvpmini_view.php index 126f5e4..d9721a7 100644 --- a/gwvpmini/gwvpmini_view.php +++ b/gwvpmini/gwvpmini_view.php @@ -111,7 +111,7 @@ function gwvpmini_RepoViewPageBody() if($owner_view) $owner_extra = " (YOU)"; else $owner_extra = ""; - echo "

".get_gravatar($owner["email"], 30, 'mm', 'g', true)."$repo_view_call - $owner_name$owner_extra

"; + echo "

".gwvpmini_HtmlGravatar($owner["email"], 30)."$repo_view_call - $owner_name$owner_extra

"; if(!$owner_view) echo "$desc
"; if($owner_view) { @@ -150,7 +150,7 @@ function gwvpmini_RepoViewPageBody() foreach($bperms_f as $key=>$val) { if($val == 1) { $dets = gwvpmini_getUser(null, null, $key); - echo get_gravatar($dets["email"], 18, 'mm', 'g', true)." ".$dets["username"]."
"; + echo gwvpmini_HtmlGravatar($dets["email"], 18, " ")." ".$dets["username"]."
"; $nl = 1; } } @@ -167,7 +167,7 @@ function gwvpmini_RepoViewPageBody() foreach($bperms_f as $key=>$val) { if($val == 2) { $dets = gwvpmini_getUser(null, null, $key); - echo get_gravatar($dets["email"], 18, 'mm', 'g', true)." ".$dets["username"]."
"; + echo gwvpmini_HtmlGravatar($dets["email"], 18, " ")." ".$dets["username"]."
"; $nl = 1; } } @@ -215,7 +215,7 @@ function gwvpmini_RepoViewPageBody() $flon = "$flin3 (external)"; } } - echo ""; + echo ""; } echo "
".get_gravatar($flin2, 18, 'mm', 'g', true)."$flon$flin1$flin4
".gwvpmini_HtmlGravatar($flin2, 18)."$flon$flin1$flin4
"; } else { diff --git a/gwvpmini/gwvpmini_web.php b/gwvpmini/gwvpmini_web.php index 97afbaa..6d45c4a 100644 --- a/gwvpmini/gwvpmini_web.php +++ b/gwvpmini/gwvpmini_web.php @@ -264,7 +264,17 @@ function gwvpmini_fourZeroFour() * @param array $atts Optional, additional key/value attributes to include in the IMG tag * @return String containing either just a URL or a complete image tag * @source http://gravatar.com/site/implement/images/php/ - */ + */ +function gwvpmini_HtmlGravatar($email, $size, $htmlappend="") +{ + + global $use_gravatar; + + + if($use_gravatar == false) return ""; + return get_gravatar( $email, $size, 'mm', 'g', true)."$htmlappend"; +} + function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { $url = 'http://en.gravatar.com/avatar/'; $url .= md5( strtolower( trim( $email ) ) );