diff --git a/communityhome/communityhome.php b/communityhome/communityhome.php index ba2af6de..cbcf86a0 100755 --- a/communityhome/communityhome.php +++ b/communityhome/communityhome.php @@ -23,17 +23,24 @@ function communityhome_uninstall() { function communityhome_home(&$a, &$o){ // custom css $a->page['htmlhead'] .= ''; - - $aside = array( - '$tab_1' => t('Login'), - '$tab_2' => t('OpenID'), - '$noOid' => get_config('system','no_openid'), - ); - - // login form - $aside['$login_title'] = t('Login'); - $aside['$login_form'] = login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); - + + if (!get_config('communityhome','hidelogin')){ + $aside = array( + '$tab_1' => t('Login'), + '$tab_2' => t('OpenID'), + '$noOid' => get_config('system','no_openid'), + ); + + // login form + $aside['$login_title'] = t('Login'); + $aside['$login_form'] = login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); + } else + $aside = array( + //'$tab_1' => t('Login'), + //'$tab_2' => t('OpenID'), + //'$noOid' => get_config('system','no_openid'), + ); + // last 12 users if (get_config('communityhome','showlastusers')===true){ $aside['$lastusers_title'] = t('Latest users'); diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 5bd82ed8..e28b3658 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -327,7 +327,8 @@ function fromgplus_fetch($a, $uid) { else $location = ""; - fromgplus_post($a, $uid, $item->provider->title, $post, $location); + fromgplus_post($a, $uid, "Google+", $post, $location); + //fromgplus_post($a, $uid, $item->provider->title, $post, $location); break; @@ -360,7 +361,8 @@ function fromgplus_fetch($a, $uid) { else $location = ""; - fromgplus_post($a, $uid, $item->provider->title, $post, $location); + fromgplus_post($a, $uid, "Google+", $post, $location); + //fromgplus_post($a, $uid, $item->provider->title, $post, $location); break; } } diff --git a/gpluspost/gpluspost.php b/gpluspost/gpluspost.php new file mode 100644 index 00000000..22fccdef --- /dev/null +++ b/gpluspost/gpluspost.php @@ -0,0 +1,316 @@ + + */ + +function gpluspost_install() { + register_hook('post_local', 'addon/gpluspost/gpluspost.php', 'gpluspost_post_local'); + register_hook('notifier_normal', 'addon/gpluspost/gpluspost.php', 'gpluspost_send'); + register_hook('jot_networks', 'addon/gpluspost/gpluspost.php', 'gpluspost_jot_nets'); + register_hook('connector_settings', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings'); + register_hook('connector_settings_post', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings_post'); +} + + +function gpluspost_uninstall() { + unregister_hook('post_local', 'addon/gpluspost/gpluspost.php', 'gpluspost_post_local'); + unregister_hook('notifier_normal', 'addon/gpluspost/gpluspost.php', 'gpluspost_send'); + unregister_hook('jot_networks', 'addon/gpluspost/gpluspost.php', 'gpluspost_jot_nets'); + unregister_hook('connector_settings', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings'); + unregister_hook('connector_settings_post', 'addon/gpluspost/gpluspost.php', 'gpluspost_settings_post'); +} + +function gpluspost_jot_nets(&$a,&$b) { + if(! local_user()) + return; + + $post = get_pconfig(local_user(),'gpluspost','post'); + if(intval($post) == 1) { + $defpost = get_pconfig(local_user(),'gpluspost','post_by_default'); + $selected = ((intval($defpost) == 1) ? ' checked="checked" ' : ''); + $b .= '
".$match[2].""; + //$text = "\n\t".$match[2].":\t"; + $text = $author.": ".$match[2]; + + return($text); +} + +function gpluspost_feeditem($pid, $uid) { + global $a; + + require_once('include/bbcode.php'); + require_once("include/html2plain.php"); + + $max_char = 140; + + $items = q("SELECT `uri`, `plink`, `author-link`, `author-name`, `created`, `edited`, `id`, `title`, `body` from `item` WHERE id=%d", intval($pid)); + foreach ($items AS $item) { + + // Looking for the first image + $image = ''; + if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$item['body'],$matches)) + $image = $matches[3]; + + if ($image == '') + if(preg_match("/\[img\](.*?)\[\/img\]/is",$item['body'],$matches)) + $image = $matches[1]; + + $multipleimages = (strpos($item['body'], "[img") != strrpos($item['body'], "[img")); + + // When saved into the database the content is sent through htmlspecialchars + // That means that we have to decode all image-urls + $image = htmlspecialchars_decode($image); + + $link = ''; + // look for bookmark-bbcode and handle it with priority + if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$item['body'],$matches)) + $link = $matches[1]; + + $multiplelinks = (strpos($item['body'], "[bookmark") != strrpos($item['body'], "[bookmark")); + + $body = $item['body']; + $body = preg_replace_callback("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]/ism","gpluspost_ShareAttributes", $body); + + $html = bbcode($body, false, false); + $msg = trim(html2plain($html, 0, true)); + + // If there is no bookmark element then take the first link + if ($link == '') { + $links = collecturls($html); + if (sizeof($links) > 0) { + reset($links); + $link = current($links); + } + $multiplelinks = (sizeof($links) > 1); + } + + $msglink = ""; + if ($multiplelinks) + $msglink = $item["plink"]; + else if ($link != "") + $msglink = $link; + else if ($multipleimages) + $msglink = $item["plink"]; + else if ($image != "") + $msglink = $image; + + if ($msglink == "") + $msglink = $item["plink"]; + + if ($image != $msglink) + $html = trim(str_replace($msglink, "", $html)); + + // Fetching the title - or the first line + if ($item["title"] != "") + $title = $item["title"]; + else { + $lines = explode("\n", $msg); + $title = $lines[0]; + } + + if ($uid == 0) + $title = $item["author-name"].": ".$title; + + $title = str_replace("&", "&", $title); + //$html = str_replace("&", "&", $html); + + echo "\t".'