From: Michael Vogel Date: Sun, 11 Mar 2012 18:24:05 +0000 (+0100) Subject: Pages: New plugin that displays a list of community pages on the sidebar. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0f3f8deee3b1cc9a1ec18a4184903aa95fe819f2;p=friendica-addons.git Pages: New plugin that displays a list of community pages on the sidebar. --- diff --git a/pages/README b/pages/README new file mode 100755 index 00000000..6ec314b7 --- /dev/null +++ b/pages/README @@ -0,0 +1,3 @@ +Pages + +Shows lists of community pages diff --git a/pages/pages.php b/pages/pages.php new file mode 100755 index 00000000..9e90cc24 --- /dev/null +++ b/pages/pages.php @@ -0,0 +1,86 @@ + + * + */ + +function pages_install() { + register_hook('page_end', 'addon/pages/pages.php', 'pages_page_end'); +} + +function pages_uninstall() { + unregister_hook('page_end', 'addon/pages/pages.php', 'pages_page_end'); +} + +function pages_iscommunity($url, &$pagelist) { + // check every week for the status - should be enough + if ($pagelist[$url]["checked"]') != 0); + + $pagelist[$url] = array("community" => $iscommunity, "checked" => time()); + } else // Fetch from cache + $iscommunity = $pagelist[$url]["community"]; + return($iscommunity); +} + +function pages_getpages($uid) { + + // Fetch cached pagelist from configuration + $pagelist = get_pconfig($uid,'pages','pagelist'); + + if (sizeof($pagelist) == 0) + $pagelist = array(); + + $contacts = q("SELECT `id`, `url`, `Name` FROM `contact` + WHERE `network`= 'dfrn' AND `uid` = %d", + intval($uid)); + + $pages = array(); + + // Look if the profile is a community page + foreach($contacts as $contact) { + if (pages_iscommunity($contact["url"], $pagelist)) + $pages[] = array("url"=>$contact["url"], "Name"=>$contact["Name"], "id"=>$contact["id"]); + } + + // Write back cached pagelist + set_pconfig($uid,'pages','pagelist', $pagelist); + return($pages); +} + +function pages_page_end($a,&$b) { + // Only move on if if it's the "network" module and there is a logged on user + if (($a->module != "network") OR ($a->user['uid'] == 0)) + return; + + $pages = '
+
+

'.t("Community").'

+
"; + if (sizeof($contacts) > 0) + $a->page['aside'] = $pages.$a->page['aside']; +} +?> diff --git a/pages/test.php b/pages/test.php new file mode 100644 index 00000000..4490c4a1 --- /dev/null +++ b/pages/test.php @@ -0,0 +1,28 @@ +"Blubb"); +$test[] = array("test"=>"Blubb"); + +print_r($test); +$serial = serialize($test); + +print_r(unserialize($serial)); +die(); + +$url = "https://pirati.ca/profile/test1"; + +$ch = curl_init(); + +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_HEADER, 0); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); +curl_setopt($ch, CURLOPT_TIMEOUT, 2); + +$page = curl_exec($ch); + +curl_close($ch); + +if (strpos($page, '')) + echo "Ping"; + +?>