From c00f0d4b282f2242b9c2e154a5381029cf0dc812 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Dec 2013 13:26:40 -0800 Subject: a couple more comanche conversions --- mod/allfriends.php | 60 ------------------------------------------------------ mod/message.php | 23 --------------------- mod/settings.php | 4 ++-- 3 files changed, 2 insertions(+), 85 deletions(-) delete mode 100644 mod/allfriends.php (limited to 'mod') diff --git a/mod/allfriends.php b/mod/allfriends.php deleted file mode 100644 index bb4df30be..000000000 --- a/mod/allfriends.php +++ /dev/null @@ -1,60 +0,0 @@ - 1) - $cid = intval(argv(1)); - if(! $cid) - return; - - $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", - intval($cid), - intval(local_user()) - ); - - $a->page['aside'] .= '
' - . '
' . $c[0]['name'] . '
' - . '
' - . '' . $c[0]['name'] . '
' - . '
'; - - - if(! count($c)) - return; - - $o .= '

' . sprintf( t('Friends of %s'), $c[0]['name']) . '

'; - - - $r = all_friends(local_user(),$cid); - - if(! count($r)) { - $o .= t('No friends to display.'); - return $o; - } - - $tpl = get_markup_template('common_friends.tpl'); - - foreach($r as $rr) { - - $o .= replace_macros($tpl,array( - '$url' => $rr['url'], - '$name' => $rr['name'], - '$photo' => $rr['photo'], - '$tags' => '' - )); - } - - $o .= cleardiv(); -// $o .= paginate($a); - return $o; -} diff --git a/mod/message.php b/mod/message.php index b5420e5b3..6a33f1db7 100644 --- a/mod/message.php +++ b/mod/message.php @@ -7,29 +7,6 @@ require_once("include/bbcode.php"); require_once('include/Contact.php'); -function message_aside(&$a) { - - if (! local_user()) - return; - - $a->set_widget('msgaside',replace_macros(get_markup_template('message_side.tpl'), array( - '$tabs'=> array(), - - '$check'=>array( - 'label' => t('Check Mail'), - 'url' => $a->get_baseurl(true) . '/message', - 'sel' => (argv(1) == ''), - ), - '$new'=>array( - 'label' => t('New Message'), - 'url' => $a->get_baseurl(true) . '/message/new', - 'sel'=> (argv(1) == 'new'), - ) - - ))); - -} - function message_post(&$a) { if(! local_user()) diff --git a/mod/settings.php b/mod/settings.php index 4d95f75b3..c2a540063 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -32,7 +32,7 @@ if (! local_user()) $a->argc = 2; $a->argv[] = 'channel'; } - +/* $channel = $a->get_channel(); $abook_self_id = 0; @@ -132,7 +132,7 @@ if (! local_user()) '$class' => 'settings-widget', '$items' => $tabs, )); - +*/ } -- cgit v1.2.3 From d14e2db6b436b3190db0c506cf5f907bd1a7fcc9 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Dec 2013 17:03:37 -0800 Subject: make home.html fullpage mode - make directory search work for non-logged in, but leave off suggest and invite --- mod/directory.php | 10 ++++------ mod/home.php | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'mod') diff --git a/mod/directory.php b/mod/directory.php index 616035339..92fb36ea7 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -11,15 +11,13 @@ function directory_init(&$a) { function directory_aside(&$a) { - if(local_user()) { - require_once('include/contact_widgets.php'); - $a->set_widget('find_people',findpeople_widget()); - } - if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { return; } - + + require_once('include/contact_widgets.php'); + $a->set_widget('find_people',findpeople_widget()); + $a->set_widget('safe_search',dir_safe_mode()); $a->set_widget('dir_sort_order',dir_sort_links()); diff --git a/mod/home.php b/mod/home.php index edcaa938d..3f862b596 100644 --- a/mod/home.php +++ b/mod/home.php @@ -1,6 +1,6 @@ Date: Sat, 14 Dec 2013 17:06:50 -0800 Subject: missed this --- mod/home.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'mod') diff --git a/mod/home.php b/mod/home.php index 3f862b596..2b8e83c30 100644 --- a/mod/home.php +++ b/mod/home.php @@ -1,6 +1,6 @@ ' . ((x($a->config,'sitename')) ? sprintf( t("Welcome to %s") ,$a->config['sitename']) : "" ) . ''; - if(file_exists('home.html')) - $o .= file_get_contents('home.html'); -} + if(file_exists('home.html')) { + $o .= file_get_contents('home.html'); + $a->page['template'] = 'full'; + } + } if (!$a->config['system']['no_login_on_homepage']) $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); @@ -85,4 +87,4 @@ require_once('include/conversation.php'); return $o; } - +} -- cgit v1.2.3 From 0272ab4cd9a6428396489d88c7a1a89be76e5810 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Dec 2013 14:36:43 -0800 Subject: Provide a fallback channel to probe for magic-auth when we have no prior communications with a site. This will be a system channel if one exists, otherwise any channel will do. We'll try to use the first valid channel on the site because that was probably created when the site was installed and is the closest thing to a system channel we've got. --- mod/magic.php | 37 ++++++++++++++++++++++--------------- mod/zfinger.php | 32 +++++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 20 deletions(-) (limited to 'mod') diff --git a/mod/magic.php b/mod/magic.php index 03d09e70d..aead559a7 100644 --- a/mod/magic.php +++ b/mod/magic.php @@ -33,21 +33,28 @@ function magic_init(&$a) { if(! $x) { - // Somebody new? Finger them if they've never been seen here before - - if($addr) { - $ret = zot_finger($addr,null); - if($ret['success']) { - $j = json_decode($ret['body'],true); - if($j) - import_xchan($j); - - // Now try again - - $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1", - dbesc($basepath) - ); - } + /* + * We have no records for, or prior communications with this hub. + * If an address was supplied, let's finger them to create a hub record. + * Otherwise we'll use the special address '[system]' which will return + * either a system channel or the first available normal channel. We don't + * really care about what channel is returned - we need the hub information + * from that response so that we can create signed auth packets destined + * for that hub. + * + */ + + $ret = zot_finger((($addr) ? $addr : '[system]@' . $parsed['host']),null); + if($ret['success']) { + $j = json_decode($ret['body'],true); + if($j) + import_xchan($j); + + // Now try again + + $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1", + dbesc($basepath) + ); } } diff --git a/mod/zfinger.php b/mod/zfinger.php index 0827f3424..aad8e224d 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -52,11 +52,33 @@ function zfinger_init(&$a) { ); } elseif(strlen($zaddr)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash - where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1", - dbesc($zaddr), - dbesc($zaddr) - ); + if(strpos($zaddr,'[system]') === false) { /* normal address lookup */ + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1", + dbesc($zaddr), + dbesc($zaddr) + ); + } + + else { + + /** + * The special address '[system]' will return a system channel if one has been defined, + * Or the first valid channel we find if there are no system channels. + * + * This is used by magic-auth if we have no prior communications with this site - and + * returns an identity on this site which we can use to create a valid hub record so that + * we can exchange signed messages. The precise identity is irrelevant. It's the hub + * information that we really need at the other end - and this will return it. + * + */ + + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + where (( channel_pageflags & %d ) or not ( channel_pageflags & %d )) order by channel_id limit 1", + intval(PAGE_SYSTEM), + intval(PAGE_REMOVED) + ); + } } else { $ret['message'] = 'Invalid request'; -- cgit v1.2.3 From 731ab80ac2ea78f595730ecb8f4d62d7b468d084 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Dec 2013 15:37:51 -0800 Subject: set system.projecthome to 1 if you want the project page for a home page. There was a bit of re-org of mod/home, which might alter the behaviour for some existing sites. Basically we're not showing a login box at all if you've got home.html - there should be a login link in th nav bar. If you haven't defined anything at all we'll fall back to the old behaviour but still allow the home contents to be set via plugin. --- mod/home.php | 92 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 43 deletions(-) (limited to 'mod') diff --git a/mod/home.php b/mod/home.php index 2b8e83c30..05626dcb5 100644 --- a/mod/home.php +++ b/mod/home.php @@ -1,6 +1,9 @@ profile = array('profile_uid' => $u[0]['channel_id']); + $o .= prepare_page($r[0]); + return $o; } - $r = q("select item.* from item left join item_id on item.id = item_id.iid - where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and - item_restrict = %d limit 1", - intval($u[0]['channel_id']), - dbesc($page_id), - intval(ITEM_WEBPAGE) - ); - - if(! $r) { - notice( t('Item not found.') . EOL); - return; + if(get_config('system','projecthome')) { + $o .= file_get_contents('assets/home.html'); + $a->page['template'] = 'full'; + return $o; } - xchan_query($r); - $r = fetch_post_tags($r,true); - $a->profile = array('profile_uid' => $u[0]['channel_id']); - $o .= prepare_page($r[0]); + if(file_exists('home.html')) { + $o .= file_get_contents('home.html'); + } + else { -} + // If there's no site channel or home contents configured, fallback to the old behaviour -// If there's no site channel specified, fallback to the old behaviour - else { $o .= '

' . ((x($a->config,'sitename')) ? sprintf( t("Welcome to %s") ,$a->config['sitename']) : "" ) . '

'; - if(file_exists('home.html')) { - $o .= file_get_contents('home.html'); - $a->page['template'] = 'full'; - } + $sitename = get_config('system','sitename'); + if($sitename) + $o .= '

' . sprintf( t("Welcome to %s") ,$sitename) . '

'; + if (! $a->config['system']['no_login_on_homepage']) + $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); } - - if (!$a->config['system']['no_login_on_homepage']) - $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); - - call_hooks("home_content",$o); - return $o; -} + call_hooks('home_content',$o); + return $o; } -- cgit v1.2.3 From 5a3a72604bf0e1c7ec04fbdbdee7a08c2a340c5a Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Dec 2013 20:59:52 -0800 Subject: some re-work of mod_sources --- mod/sources.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mod') diff --git a/mod/sources.php b/mod/sources.php index 125184d47..87bab60df 100644 --- a/mod/sources.php +++ b/mod/sources.php @@ -9,11 +9,25 @@ function sources_post(&$a) { $source = intval($_REQUEST['source']); $xchan = $_REQUEST['xchan']; + $abook = intval($_REQUEST['abook']); $words = $_REQUEST['words']; $frequency = $_REQUEST['frequency']; $channel = $a->get_channel(); + if($abook) { + $r = q("select abook_xchan from abook where abook_id = %d and abook_channel = %d limit 1", + intval($abook), + intval(local_user()) + ); + if($r) + $xchan = $r[0]['abook_xchan']; + } + + if(! $xchan) { + notice ( t('Failed to create source. No channel selected.') . EOL); + return; + } if(! $source) { $r = q("insert into source ( src_channel_id, src_channel_xchan, src_xchan, src_patt ) @@ -92,6 +106,12 @@ function sources_content(&$a) { intval(argv(1)), intval(local_user()) ); + if($r) { + $x = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($r[0]['src_xchan']), + intval(local_user()) + ); + } if(! $r) { notice( t('Source not found.') . EOL); return ''; @@ -106,6 +126,7 @@ function sources_content(&$a) { '$desc' => t('Import all or selected content from the following channel into this channel and distribute it according to your channel settings.'), '$words' => array( 'words', t('Only import content with these words (one per line)'),$r[0]['src_patt'],t('Leave blank to import all public content')), '$xchan' => $r[0]['src_xchan'], + '$abook' => $x[0]['abook_id'], '$name' => array( 'name', t('Channel Name'), $r[0]['xchan_name'], ''), '$submit' => t('Submit') )); -- cgit v1.2.3 From a7a775a718ef92c9bd623849baab1e386071d70b Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Dec 2013 00:25:08 -0800 Subject: install redbasic during setup so that at least one theme is registered. Otherwise none of the display settings seem to work very well. --- mod/setup.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/setup.php b/mod/setup.php index 0198f1f09..245508683 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -577,6 +577,8 @@ function load_database($db) { function what_next() { $a = get_app(); + // install the standard theme + set_config('system','allowed_themes','redbasic'); $baseurl = $a->get_baseurl(); return t('

What next

') -- cgit v1.2.3