From de006771c7fe92a889d759c2c75c1473c420ad47 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 22 May 2016 16:54:30 -0700 Subject: renamed include files identity.php (channel.php) and Contact.php (connections.php) --- Zotlabs/Daemon/Cron_weekly.php | 1 - Zotlabs/Daemon/Externals.php | 2 +- Zotlabs/Daemon/Notifier.php | 3 +- Zotlabs/Daemon/Onepoll.php | 2 +- Zotlabs/Daemon/Ratenotif.php | 1 - Zotlabs/Lib/ThreadStream.php | 2 +- Zotlabs/Module/Admin.php | 4 - Zotlabs/Module/Blocks.php | 2 +- Zotlabs/Module/Cal.php | 2 - Zotlabs/Module/Chanview.php | 2 - Zotlabs/Module/Connect.php | 2 +- Zotlabs/Module/Connections.php | 2 +- Zotlabs/Module/Connedit.php | 3 +- Zotlabs/Module/Cover_photo.php | 2 +- Zotlabs/Module/Display.php | 4 +- Zotlabs/Module/Editblock.php | 2 +- Zotlabs/Module/Editlayout.php | 2 +- Zotlabs/Module/Editwebpage.php | 2 +- Zotlabs/Module/Getfile.php | 1 - Zotlabs/Module/Import.php | 4 +- Zotlabs/Module/Item.php | 2 +- Zotlabs/Module/Layouts.php | 2 +- Zotlabs/Module/Mail.php | 7 +- Zotlabs/Module/Menu.php | 2 +- Zotlabs/Module/Message.php | 2 - Zotlabs/Module/Network.php | 2 +- Zotlabs/Module/New_channel.php | 2 +- Zotlabs/Module/Oep.php | 4 +- Zotlabs/Module/Photos.php | 2 +- Zotlabs/Module/Profile_photo.php | 2 +- Zotlabs/Module/Profiles.php | 4 +- Zotlabs/Module/Profperm.php | 2 +- Zotlabs/Module/Pubstream.php | 2 +- Zotlabs/Module/Randprof.php | 1 - Zotlabs/Module/Register.php | 2 +- Zotlabs/Module/Removeaccount.php | 11 +- Zotlabs/Module/Removeme.php | 5 +- Zotlabs/Module/Search.php | 2 +- Zotlabs/Module/Settings.php | 2 +- Zotlabs/Module/Setup.php | 2 +- Zotlabs/Module/Uexport.php | 2 +- Zotlabs/Module/Viewconnections.php | 4 +- Zotlabs/Module/Wall_attach.php | 2 +- Zotlabs/Module/Wall_upload.php | 2 +- Zotlabs/Module/Webpages.php | 2 +- Zotlabs/Zot/Finger.php | 4 +- boot.php | 6 +- doc/hooks.html | 2 +- include/Contact.php | 636 ------------ include/account.php | 2 +- include/api.php | 2 +- include/apps.php | 2 +- include/channel.php | 1947 +++++++++++++++++++++++++++++++++++ include/connections.php | 636 ++++++++++++ include/contact_widgets.php | 8 - include/conversation.php | 3 +- include/feedutils.php | 1 - include/identity.php | 1949 ------------------------------------ include/items.php | 2 +- include/text.php | 6 +- include/widgets.php | 5 +- include/zot.php | 6 +- util/hmessages.po | 134 +-- util/messages.po | 126 +-- 64 files changed, 2774 insertions(+), 2820 deletions(-) delete mode 100644 include/Contact.php create mode 100644 include/channel.php create mode 100644 include/connections.php delete mode 100644 include/identity.php diff --git a/Zotlabs/Daemon/Cron_weekly.php b/Zotlabs/Daemon/Cron_weekly.php index dc781ad73..1d8420947 100644 --- a/Zotlabs/Daemon/Cron_weekly.php +++ b/Zotlabs/Daemon/Cron_weekly.php @@ -21,7 +21,6 @@ class Cron_weekly { require_once('include/hubloc.php'); prune_hub_reinstalls(); - require_once('include/Contact.php'); mark_orphan_hubsxchans(); diff --git a/Zotlabs/Daemon/Externals.php b/Zotlabs/Daemon/Externals.php index 167b0524f..24cfe64ec 100644 --- a/Zotlabs/Daemon/Externals.php +++ b/Zotlabs/Daemon/Externals.php @@ -3,7 +3,7 @@ namespace Zotlabs\Daemon; require_once('include/zot.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); class Externals { diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 65690f8ce..590be31ee 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -72,8 +72,7 @@ require_once('include/queue_fn.php'); require_once('include/datetime.php'); require_once('include/items.php'); require_once('include/bbcode.php'); -require_once('include/identity.php'); -require_once('include/Contact.php'); +require_once('include/channel.php'); class Notifier { diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index 2610ad151..036a4991b 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -4,7 +4,7 @@ namespace Zotlabs\Daemon; require_once('include/zot.php'); require_once('include/socgraph.php'); -require_once('include/Contact.php'); + class Onepoll { diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php index a404273e2..1cba5e26d 100644 --- a/Zotlabs/Daemon/Ratenotif.php +++ b/Zotlabs/Daemon/Ratenotif.php @@ -12,7 +12,6 @@ class Ratenotif { require_once("datetime.php"); require_once('include/items.php'); - require_once('include/Contact.php'); if($argc < 3) return; diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 2bcf167e9..a6d4f8517 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -165,7 +165,7 @@ class ThreadStream { $item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data)); } } - require_once('include/identity.php'); + require_once('include/channel.php'); $item->set_conversation($this); $this->threads[] = $item; diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index cd6e45e9f..172b109c8 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -902,7 +902,6 @@ class Admin extends \Zotlabs\Web\Controller { } // account delete button was submitted if (x($_POST, 'page_users_delete')) { - require_once('include/Contact.php'); foreach ($users as $uid){ account_remove($uid, true, false); } @@ -951,7 +950,6 @@ class Admin extends \Zotlabs\Web\Controller { switch (argv(2)){ case 'delete': // delete user - require_once('include/Contact.php'); account_remove($uid,true,false); notice( sprintf(t("Account '%s' deleted"), $account[0]['account_email']) . EOL); @@ -1096,7 +1094,6 @@ class Admin extends \Zotlabs\Web\Controller { notice( sprintf( tt("%s channel code allowed/disallowed", "%s channels code allowed/disallowed", count($channels)), count($channels)) ); } if (x($_POST,'page_channels_delete')){ - require_once("include/Contact.php"); foreach($channels as $uid){ channel_remove($uid,true); } @@ -1128,7 +1125,6 @@ class Admin extends \Zotlabs\Web\Controller { case "delete":{ check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels', 't'); // delete channel - require_once("include/Contact.php"); channel_remove($uid,true); notice( sprintf(t("Channel '%s' deleted"), $channel[0]['channel_name']) . EOL); diff --git a/Zotlabs/Module/Blocks.php b/Zotlabs/Module/Blocks.php index ed702befb..32650a090 100644 --- a/Zotlabs/Module/Blocks.php +++ b/Zotlabs/Module/Blocks.php @@ -1,7 +1,7 @@ disabled())) { $r = null; - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $sysid = $sys['channel_id']; @@ -233,7 +233,7 @@ class Display extends \Zotlabs\Web\Controller { elseif($update && !$load) { $r = null; - require_once('include/identity.php'); + require_once('include/channel.php'); $sys = get_sys_channel(); $sysid = $sys['channel_id']; diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index a79962033..fb86557f2 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -1,7 +1,7 @@ 1) { $channel = \App::get_channel(); - require_once('include/identity.php'); + require_once('include/channel.php'); if(argc() > 1 && intval(argv(1)) > 1900) { $year = intval(argv(1)); diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index a9445cdeb..d58c431e5 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -2,8 +2,6 @@ namespace Zotlabs\Module; require_once('include/selectors.php'); -require_once('include/Contact.php'); - class Viewconnections extends \Zotlabs\Web\Controller { @@ -16,7 +14,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { profile_load($a,argv(1)); } - function get() { + function get() { if((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) { notice( t('Public access denied.') . EOL); diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index 5bdecfa75..9a1019ddb 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/attach.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/photos.php'); diff --git a/Zotlabs/Module/Wall_upload.php b/Zotlabs/Module/Wall_upload.php index fff3ed03a..3868cb14e 100644 --- a/Zotlabs/Module/Wall_upload.php +++ b/Zotlabs/Module/Wall_upload.php @@ -2,7 +2,7 @@ namespace Zotlabs\Module; require_once('include/photo/photo_driver.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); require_once('include/photos.php'); diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index d8adb55b2..bb8d454c8 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -1,7 +1,7 @@ true) or array('success' => false); */ static public function run($webbie, $channel = null, $autofallback = true) { @@ -108,7 +108,7 @@ class Finger { $x = json_decode($result['body'],true); if($x) { - $signed_token = $x['signed_token']; + $signed_token = ((is_array($x) && array_key_exists('signed_token',$x)) ? $x['signed_token'] : null); if($signed_token) { $valid = rsa_verify(self::$token,base64url_decode($signed_token),$x['key']); if(! $valid) { diff --git a/boot.php b/boot.php index e7e962b8e..25551346b 100755 --- a/boot.php +++ b/boot.php @@ -39,14 +39,14 @@ require_once('include/permissions.php'); require_once('library/Mobile_Detect/Mobile_Detect.php'); require_once('include/features.php'); require_once('include/taxonomy.php'); -require_once('include/identity.php'); -require_once('include/Contact.php'); +require_once('include/channel.php'); +require_once('include/connections.php'); require_once('include/account.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'STD_VERSION', '1.7.1' ); -define ( 'ZOT_REVISION', 1 ); +define ( 'ZOT_REVISION', 1.1 ); define ( 'DB_UPDATE_VERSION', 1168 ); diff --git a/doc/hooks.html b/doc/hooks.html index c05de58ef..f4a5a7630 100644 --- a/doc/hooks.html +++ b/doc/hooks.html @@ -1 +1 @@ -

Hooks

FunctionSource FileArg
$a->module . _mod_aftercontentindex.php$arr
$a->module . _mod_contentindex.php$arr
$a->module . _mod_initindex.php$placeholder
$a->module . _mod_postindex.php$_POST
$a->module . _post_ . $selnameinclude/acl_selectors.php$o
$a->module . _post_ . $selnameinclude/acl_selectors.php$o
$a->module . _post_ . $selnameinclude/acl_selectors.php$o
$a->module . _pre_ . $selnameinclude/acl_selectors.php$arr
$a->module . _pre_ . $selnameinclude/acl_selectors.php$arr
$a->module . _pre_ . $selnameinclude/acl_selectors.php$arr
$nameinclude/plugin.php&$data = null
about_hookmod/siteinfo.php$o
accept_followmod/connedit.php$arr
account_downgradeinclude/account.php$ret
account_downgradeinclude/account.php$ret
account_settingsmod/settings.php$account_settings
activity_receivedinclude/zot.php$parr
affinity_labelsinclude/widgets.php$labels
affinity_labelsmod/connedit.php$labels
api_perm_is_allowedinclude/permissions.php$arr
app_menuindex.php$arr
atom_authorinclude/items.php$o
atom_entryinclude/items.php$o
atom_feedinclude/items.php$atom
atom_feed_endinclude/items.php$atom
attach_upload_fileinclude/attach.php$f
authenticateinclude/auth.php$addon_auth
avatar_lookupinclude/network.php$avatar
bb2diasporainclude/bb2diaspora.php$Text
bbcodeinclude/bbcode.php$Text
channel_removeinclude/Contact.php$r[0]
chat_messageinclude/chat.php$arr
chat_postmod/chatsvc.php$arr
check_account_emailinclude/account.php$arr
check_account_inviteinclude/account.php$arr
check_account_passwordinclude/account.php$arr
connect_premiummod/connect.php$arr
connector_settingsmod/settings.php$settings_connectors
construct_pageboot.php$arr
contact_block_endinclude/text.php$arr
contact_editmod/connedit.php$arr
contact_edit_postmod/connedit.php$_POST
contact_select_optionsinclude/acl_selectors.php$x
conversation_startinclude/conversation.php$cb
create_identityinclude/identity.php$newuid
croninclude/cronhooks.php$d
cron_dailyinclude/poller.phpdatetime_convert()
cron_weeklyinclude/poller.phpdatetime_convert()
directory_itemmod/directory.php$arr
discover_by_webbieinclude/network.php$arr
display_iteminclude/ItemObject.php$arr
display_iteminclude/conversation.php$arr
display_settingsmod/settings.php$o
display_settings_postmod/settings.php$_POST
donate_contributorsextend/addon/matrix/donate/donate.php$contributors
donate_pluginextend/addon/matrix/donate/donate.php$o
donate_sponsorsextend/addon/matrix/donate/donate.php$sponsors
dreport_is_storableinclude/zot.php$dr
drop_iteminclude/items.php$arr
enotifyinclude/enotify.php$h
enotify_mailinclude/enotify.php$datarray
enotify_storeinclude/enotify.php$datarray
event_createdinclude/event.php$event[id]
event_updatedinclude/event.php$event[id]
externals_url_selectinclude/externals.php$arr
feature_enabledinclude/features.php$arr
feature_settingsmod/settings.php$settings_addons
feature_settings_postmod/settings.php$_POST
followinclude/follow.php$arr
followinclude/follow.php$arr
follow_allowinclude/follow.php$x
gender_selectorinclude/profile_selectors.php$select
gender_selector_mininclude/profile_selectors.php$select
generate_mapinclude/text.php$arr
generate_named_mapinclude/text.php$arr
get_all_api_permsinclude/permissions.php$arr
get_all_permsinclude/permissions.php$arr
get_featuresinclude/features.php$arr
get_role_permsinclude/permissions.php$ret
get_widgetsboot.php$arr
get_widgetsboot.php$arr
global_permissionsinclude/permissions.php$ret
home_contentmod/home.php$o
home_initmod/home.php$ret
hostxrdmod/hostxrd.php$arr
html2bbcodeinclude/html2bbcode.php$message
identity_basic_exportinclude/identity.php$addon
import_author_xchaninclude/items.php$arr
import_channelmod/import.php$addon
import_directory_profileinclude/zot.php$d
import_xchaninclude/zot.php$arr
item_photo_menuinclude/conversation.php$args
item_storeinclude/items.php$d
item_storeinclude/items.php$arr
item_store_updateinclude/items.php$d
item_translateinclude/items.php$translate
item_translateinclude/items.php$translate
jot_networksinclude/acl_selectors.php$jotnets
jot_networksinclude/conversation.php$jotnets
jot_networksmod/editblock.php$jotnets
jot_networksmod/editpost.php$jotnets
jot_networksmod/editwebpage.php$jotnets
jot_networksmod/editlayout.php$jotnets
jot_toolinclude/conversation.php$jotplugins
jot_toolmod/editblock.php$jotplugins
jot_toolmod/editpost.php$jotplugins
jot_toolmod/editwebpage.php$jotplugins
jot_toolmod/editlayout.php$jotplugins
load_pdlboot.php$arr
local_dir_updateinclude/dir_fns.php$arr
logged_ininclude/oauth.php$a->user
logged_ininclude/api.php$a->user
logged_ininclude/security.php$a->account
logged_ininclude/security.php$user_record
logging_outinclude/auth.php$args
login_hookboot.php$o
magic_authmod/magic.php$arr
magic_auth_openid_successmod/openid.php$arr
magic_auth_openid_successmod/openid.php$arr
magic_auth_successmod/post.php$arr
main_sliderinclude/widgets.php$arr
marital_selectorinclude/profile_selectors.php$select
marital_selector_mininclude/profile_selectors.php$select
module_loadedindex.php$x
mood_verbsinclude/text.php$arr
navinclude/nav.php$x
network_content_initmod/network.php$arr
network_pingmod/ping.php$arr
network_tabsinclude/conversation.php$arr
network_to_nameinclude/contact_selectors.php$nets
notifier_endinclude/notifier.php$target_item
notifier_hubinclude/notifier.php$narr
notifier_normalinclude/deliver_hooks.php$r[0]
obj_verbsinclude/taxonomy.php$arr
oembed_probeinclude/oembed.php$x
page_content_topindex.php$a->page[content]
page_endindex.php$a->page[content]
page_headerinclude/nav.php$a->page[nav]
parse_atominclude/items.php$arr
parse_linkmod/linkinfo.php$arr
pdl_selectorinclude/comanche.php$arr
perm_is_allowedinclude/permissions.php$arr
permissions_createinclude/notifier.php$perm_update
permissions_updateinclude/notifier.php$perm_update
personal_xrdmod/xrd.php$arr
photo_post_endinclude/photos.php$ret
photo_post_endinclude/photos.php$ret
photo_upload_begininclude/attach.php$arr
photo_upload_begininclude/photos.php$args
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_fileinclude/attach.php$f
photo_upload_fileinclude/photos.php$f
photo_upload_formmod/photos.php$ret
poke_verbsinclude/text.php$arr
post_localinclude/zot.php$arr
post_localinclude/items.php$arr
post_localmod/item.php$datarray
post_local_endinclude/items.php$arr
post_local_endinclude/attach.php$arr
post_local_endinclude/attach.php$arr
post_local_endextend/addon/matrix/randpost/randpost.php$x
post_local_endextend/addon/matrix/randpost/randpost.php$x
post_local_endmod/mood.php$arr
post_local_endmod/like.php$arr
post_local_endmod/item.php$datarray
post_local_endmod/subthread.php$arr
post_local_startmod/item.php$_REQUEST
post_mailinclude/items.php$arr
post_mail_endinclude/items.php$arr
post_remoteinclude/items.php$arr
post_remote_endinclude/items.php$arr
post_remote_updateinclude/items.php$arr
post_remote_update_endinclude/items.php$arr
prepare_bodyinclude/text.php$prep_arr
prepare_body_finalinclude/text.php$prep_arr
prepare_body_initinclude/text.php$item
probe_well_knowninclude/probe.php$ret
proc_runboot.php$arr
process_channel_sync_deliveryinclude/zot.php$addon
profile_advancedmod/profile.php$o
profile_editmod/profiles.php$arr
profile_photo_content_endmod/profile_photo.php$o
profile_postmod/profiles.php$_POST
profile_sidebarinclude/identity.php$arr
profile_sidebar_enterinclude/identity.php$profile
profile_tabsinclude/conversation.php$arr
register_accountinclude/account.php$result
render_locationinclude/conversation.php$locate
replace_macrosinclude/text.php$arr
reverse_magic_authmod/rmagic.php$arr
settings_accountmod/settings.php$_POST
settings_formmod/settings.php$o
settings_postmod/settings.php$_POST
sexpref_selectorinclude/profile_selectors.php$select
sexpref_selector_mininclude/profile_selectors.php$select
smilieinclude/text.php$params
smilieextend/addon/matrix/smileybutton/smileybutton.php$params
taggedinclude/items.php$arr
validate_channelnameinclude/identity.php$arr
webfingermod/wfinger.php$arr
well_knownmod/_well_known.php$arr
zidinclude/identity.php$arr
zid_initinclude/identity.php$arr
zot_fingerinclude/zot.php$ret

Generated Tue Nov 03 21:19:02 PST 2015

\ No newline at end of file +

Hooks

FunctionSource FileArg
$a->module . _mod_aftercontentindex.php$arr
$a->module . _mod_contentindex.php$arr
$a->module . _mod_initindex.php$placeholder
$a->module . _mod_postindex.php$_POST
$a->module . _post_ . $selnameinclude/acl_selectors.php$o
$a->module . _post_ . $selnameinclude/acl_selectors.php$o
$a->module . _post_ . $selnameinclude/acl_selectors.php$o
$a->module . _pre_ . $selnameinclude/acl_selectors.php$arr
$a->module . _pre_ . $selnameinclude/acl_selectors.php$arr
$a->module . _pre_ . $selnameinclude/acl_selectors.php$arr
$nameinclude/plugin.php&$data = null
about_hookmod/siteinfo.php$o
accept_followmod/connedit.php$arr
account_downgradeinclude/account.php$ret
account_downgradeinclude/account.php$ret
account_settingsmod/settings.php$account_settings
activity_receivedinclude/zot.php$parr
affinity_labelsinclude/widgets.php$labels
affinity_labelsmod/connedit.php$labels
api_perm_is_allowedinclude/permissions.php$arr
app_menuindex.php$arr
atom_authorinclude/items.php$o
atom_entryinclude/items.php$o
atom_feedinclude/items.php$atom
atom_feed_endinclude/items.php$atom
attach_upload_fileinclude/attach.php$f
authenticateinclude/auth.php$addon_auth
avatar_lookupinclude/network.php$avatar
bb2diasporainclude/bb2diaspora.php$Text
bbcodeinclude/bbcode.php$Text
channel_removeinclude/Contact.php$r[0]
chat_messageinclude/chat.php$arr
chat_postmod/chatsvc.php$arr
check_account_emailinclude/account.php$arr
check_account_inviteinclude/account.php$arr
check_account_passwordinclude/account.php$arr
connect_premiummod/connect.php$arr
connector_settingsmod/settings.php$settings_connectors
construct_pageboot.php$arr
contact_block_endinclude/text.php$arr
contact_editmod/connedit.php$arr
contact_edit_postmod/connedit.php$_POST
contact_select_optionsinclude/acl_selectors.php$x
conversation_startinclude/conversation.php$cb
create_identityinclude/channel.php$newuid
croninclude/cronhooks.php$d
cron_dailyinclude/poller.phpdatetime_convert()
cron_weeklyinclude/poller.phpdatetime_convert()
directory_itemmod/directory.php$arr
discover_by_webbieinclude/network.php$arr
display_iteminclude/ItemObject.php$arr
display_iteminclude/conversation.php$arr
display_settingsmod/settings.php$o
display_settings_postmod/settings.php$_POST
donate_contributorsextend/addon/matrix/donate/donate.php$contributors
donate_pluginextend/addon/matrix/donate/donate.php$o
donate_sponsorsextend/addon/matrix/donate/donate.php$sponsors
dreport_is_storableinclude/zot.php$dr
drop_iteminclude/items.php$arr
enotifyinclude/enotify.php$h
enotify_mailinclude/enotify.php$datarray
enotify_storeinclude/enotify.php$datarray
event_createdinclude/event.php$event[id]
event_updatedinclude/event.php$event[id]
externals_url_selectinclude/externals.php$arr
feature_enabledinclude/features.php$arr
feature_settingsmod/settings.php$settings_addons
feature_settings_postmod/settings.php$_POST
followinclude/follow.php$arr
followinclude/follow.php$arr
follow_allowinclude/follow.php$x
gender_selectorinclude/profile_selectors.php$select
gender_selector_mininclude/profile_selectors.php$select
generate_mapinclude/text.php$arr
generate_named_mapinclude/text.php$arr
get_all_api_permsinclude/permissions.php$arr
get_all_permsinclude/permissions.php$arr
get_featuresinclude/features.php$arr
get_role_permsinclude/permissions.php$ret
get_widgetsboot.php$arr
get_widgetsboot.php$arr
global_permissionsinclude/permissions.php$ret
home_contentmod/home.php$o
home_initmod/home.php$ret
hostxrdmod/hostxrd.php$arr
html2bbcodeinclude/html2bbcode.php$message
identity_basic_exportinclude/channel.php$addon
import_author_xchaninclude/items.php$arr
import_channelmod/import.php$addon
import_directory_profileinclude/zot.php$d
import_xchaninclude/zot.php$arr
item_photo_menuinclude/conversation.php$args
item_storeinclude/items.php$d
item_storeinclude/items.php$arr
item_store_updateinclude/items.php$d
item_translateinclude/items.php$translate
item_translateinclude/items.php$translate
jot_networksinclude/acl_selectors.php$jotnets
jot_networksinclude/conversation.php$jotnets
jot_networksmod/editblock.php$jotnets
jot_networksmod/editpost.php$jotnets
jot_networksmod/editwebpage.php$jotnets
jot_networksmod/editlayout.php$jotnets
jot_toolinclude/conversation.php$jotplugins
jot_toolmod/editblock.php$jotplugins
jot_toolmod/editpost.php$jotplugins
jot_toolmod/editwebpage.php$jotplugins
jot_toolmod/editlayout.php$jotplugins
load_pdlboot.php$arr
local_dir_updateinclude/dir_fns.php$arr
logged_ininclude/oauth.php$a->user
logged_ininclude/api.php$a->user
logged_ininclude/security.php$a->account
logged_ininclude/security.php$user_record
logging_outinclude/auth.php$args
login_hookboot.php$o
magic_authmod/magic.php$arr
magic_auth_openid_successmod/openid.php$arr
magic_auth_openid_successmod/openid.php$arr
magic_auth_successmod/post.php$arr
main_sliderinclude/widgets.php$arr
marital_selectorinclude/profile_selectors.php$select
marital_selector_mininclude/profile_selectors.php$select
module_loadedindex.php$x
mood_verbsinclude/text.php$arr
navinclude/nav.php$x
network_content_initmod/network.php$arr
network_pingmod/ping.php$arr
network_tabsinclude/conversation.php$arr
network_to_nameinclude/contact_selectors.php$nets
notifier_endinclude/notifier.php$target_item
notifier_hubinclude/notifier.php$narr
notifier_normalinclude/deliver_hooks.php$r[0]
obj_verbsinclude/taxonomy.php$arr
oembed_probeinclude/oembed.php$x
page_content_topindex.php$a->page[content]
page_endindex.php$a->page[content]
page_headerinclude/nav.php$a->page[nav]
parse_atominclude/items.php$arr
parse_linkmod/linkinfo.php$arr
pdl_selectorinclude/comanche.php$arr
perm_is_allowedinclude/permissions.php$arr
permissions_createinclude/notifier.php$perm_update
permissions_updateinclude/notifier.php$perm_update
personal_xrdmod/xrd.php$arr
photo_post_endinclude/photos.php$ret
photo_post_endinclude/photos.php$ret
photo_upload_begininclude/attach.php$arr
photo_upload_begininclude/photos.php$args
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/attach.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_endinclude/photos.php$ret
photo_upload_fileinclude/attach.php$f
photo_upload_fileinclude/photos.php$f
photo_upload_formmod/photos.php$ret
poke_verbsinclude/text.php$arr
post_localinclude/zot.php$arr
post_localinclude/items.php$arr
post_localmod/item.php$datarray
post_local_endinclude/items.php$arr
post_local_endinclude/attach.php$arr
post_local_endinclude/attach.php$arr
post_local_endextend/addon/matrix/randpost/randpost.php$x
post_local_endextend/addon/matrix/randpost/randpost.php$x
post_local_endmod/mood.php$arr
post_local_endmod/like.php$arr
post_local_endmod/item.php$datarray
post_local_endmod/subthread.php$arr
post_local_startmod/item.php$_REQUEST
post_mailinclude/items.php$arr
post_mail_endinclude/items.php$arr
post_remoteinclude/items.php$arr
post_remote_endinclude/items.php$arr
post_remote_updateinclude/items.php$arr
post_remote_update_endinclude/items.php$arr
prepare_bodyinclude/text.php$prep_arr
prepare_body_finalinclude/text.php$prep_arr
prepare_body_initinclude/text.php$item
probe_well_knowninclude/probe.php$ret
proc_runboot.php$arr
process_channel_sync_deliveryinclude/zot.php$addon
profile_advancedmod/profile.php$o
profile_editmod/profiles.php$arr
profile_photo_content_endmod/profile_photo.php$o
profile_postmod/profiles.php$_POST
profile_sidebarinclude/channel.php$arr
profile_sidebar_enterinclude/channel.php$profile
profile_tabsinclude/conversation.php$arr
register_accountinclude/account.php$result
render_locationinclude/conversation.php$locate
replace_macrosinclude/text.php$arr
reverse_magic_authmod/rmagic.php$arr
settings_accountmod/settings.php$_POST
settings_formmod/settings.php$o
settings_postmod/settings.php$_POST
sexpref_selectorinclude/profile_selectors.php$select
sexpref_selector_mininclude/profile_selectors.php$select
smilieinclude/text.php$params
smilieextend/addon/matrix/smileybutton/smileybutton.php$params
taggedinclude/items.php$arr
validate_channelnameinclude/channel.php$arr
webfingermod/wfinger.php$arr
well_knownmod/_well_known.php$arr
zidinclude/channel.php$arr
zid_initinclude/channel.php$arr
zot_fingerinclude/zot.php$ret

Generated Tue Nov 03 21:19:02 PST 2015

\ No newline at end of file diff --git a/include/Contact.php b/include/Contact.php deleted file mode 100644 index e50670a89..000000000 --- a/include/Contact.php +++ /dev/null @@ -1,636 +0,0 @@ - $xchan['xchan_name'], - '$photo' => ((is_array(App::$profile) && array_key_exists('photo',App::$profile)) ? App::$profile['photo'] : $xchan['xchan_photo_l']), - '$follow' => $xchan['xchan_addr'], - '$link' => zid($xchan['xchan_url']), - '$connect' => $connect, - '$newwin' => (($mode === 'chanview') ? t('New window') : ''), - '$newtit' => t('Open the selected location in a different window or browser tab'), - '$url' => $url, - )); -} - -function abook_toggle_flag($abook,$flag) { - - $field = ''; - - switch($flag) { - case ABOOK_FLAG_BLOCKED: - $field = 'abook_blocked'; - break; - case ABOOK_FLAG_IGNORED: - $field = 'abook_ignored'; - break; - case ABOOK_FLAG_HIDDEN: - $field = 'abook_hidden'; - break; - case ABOOK_FLAG_ARCHIVED: - $field = 'abook_archived'; - break; - case ABOOK_FLAG_PENDING: - $field = 'abook_pending'; - break; - case ABOOK_FLAG_UNCONNECTED: - $field = 'abook_unconnected'; - break; - case ABOOK_FLAG_SELF: - $field = 'abook_self'; - break; - case ABOOK_FLAG_FEED: - $field = 'abook_feed'; - break; - default: - break; - } - if(! $field) - return; - - $r = q("UPDATE abook set $field = (1 - $field) where abook_id = %d and abook_channel = %d", - intval($abook['abook_id']), - intval($abook['abook_channel']) - ); - - - // if unsetting the archive bit, update the timestamps so we'll try to connect for an additional 30 days. - - if(($flag === ABOOK_FLAG_ARCHIVED) && (intval($abook['abook_archived']))) { - $r = q("update abook set abook_connected = '%s', abook_updated = '%s' - where abook_id = %d and abook_channel = %d", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($abook['abook_id']), - intval($abook['abook_channel']) - ); - } - - return $r; - -} - - -// Included here for completeness, but this is a very dangerous operation. -// It is the caller's responsibility to confirm the requestor's intent and -// authorisation to do this. - -function user_remove($uid) { - -} - -function account_remove($account_id,$local = true,$unset_session=true) { - - logger('account_remove: ' . $account_id); - - if(! intval($account_id)) { - logger('account_remove: no account.'); - return false; - } - - // Don't let anybody nuke the only admin account. - - $r = q("select account_id from account where (account_roles & %d)>0", - intval(ACCOUNT_ROLE_ADMIN) - ); - - if($r !== false && count($r) == 1 && $r[0]['account_id'] == $account_id) { - logger("Unable to remove the only remaining admin account"); - return false; - } - - $r = q("select * from account where account_id = %d limit 1", - intval($account_id) - ); - $account_email=$r[0]['account_email']; - - if(! $r) { - logger('account_remove: No account with id: ' . $account_id); - return false; - } - - $x = q("select channel_id from channel where channel_account_id = %d", - intval($account_id) - ); - if($x) { - foreach($x as $xx) { - channel_remove($xx['channel_id'],$local,false); - } - } - - $r = q("delete from account where account_id = %d", - intval($account_id) - ); - - - if ($unset_session) { - unset($_SESSION['authenticated']); - unset($_SESSION['uid']); - notice( sprintf(t("User '%s' deleted"),$account_email) . EOL); - goaway(z_root()); - } - return $r; - -} -// recursively delete a directory -function rrmdir($path) -{ - if (is_dir($path) === true) - { - $files = array_diff(scandir($path), array('.', '..')); - - foreach ($files as $file) - { - rrmdir(realpath($path) . '/' . $file); - } - - return rmdir($path); - } - - else if (is_file($path) === true) - { - return unlink($path); - } - - return false; -} - -function channel_remove($channel_id, $local = true, $unset_session=false) { - - if(! $channel_id) - return; - $a = get_app(); - logger('Removing channel: ' . $channel_id); - logger('channel_remove: local only: ' . intval($local)); - - $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id)); - if(! $r) { - logger('channel_remove: channel not found: ' . $channel_id); - return; - } - - $channel = $r[0]; - - call_hooks('channel_remove',$r[0]); - - if(! $local) { - - $r = q("update channel set channel_deleted = '%s', channel_removed = 1, channel_r_stream = 0, channel_r_profile = 0, - channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0, - channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0, - channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0, channel_a_republish = 0 - where channel_id = %d", - dbesc(datetime_convert()), - intval($channel_id) - ); - - logger('deleting hublocs',LOGGER_DEBUG); - - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", - dbesc($channel['channel_hash']) - ); - - - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", - dbesc($channel['channel_hash']) - ); - - Zotlabs\Daemon\Master::Summon(array('Notifier','purge_all',$channel_id)); - } - - q("DELETE FROM `groups` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `event` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `item` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `item_id` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `mail` WHERE `channel_id` = %d", intval($channel_id)); - q("DELETE FROM `notify` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `photo` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `attach` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `profile` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `spam` WHERE `uid` = %d", intval($channel_id)); - - // @FIXME At this stage we need to remove the file resources located under /store/$nickname - - - q("delete from abook where abook_xchan = '%s' and abook_self = 1 ", - dbesc($channel['channel_hash']) - ); - - $r = q("update channel set channel_deleted = '%s', channel_removed = 1 where channel_id = %d", - dbesc(datetime_convert()), - intval($channel_id) - ); - - // if this was the default channel, set another one as default - if(App::$account['account_default_channel'] == $channel_id) { - $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", - intval(App::$account['account_id']), - intval(PAGE_REMOVED)); - if ($r) { - $rr = q("update account set account_default_channel = %d where account_id = %d", - intval($r[0]['channel_id']), - intval(App::$account['account_id'])); - logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']); - } - else { - $rr = q("update account set account_default_channel = 0 where account_id = %d", - intval(App::$account['account_id']) - ); - } - } - - logger('deleting hublocs',LOGGER_DEBUG); - - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", - dbesc($channel['channel_hash']), - dbesc(z_root()) - ); - - // Do we have any valid hublocs remaining? - - $hublocs = 0; - - $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", - dbesc($channel['channel_hash']) - ); - if($r) - $hublocs = count($r); - - if(! $hublocs) { - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s' ", - dbesc($channel['channel_hash']) - ); - } - - //remove from file system - $r = q("select channel_address from channel where channel_id = %d limit 1", - intval($channel_id) - ); - if($r) - $channel_address = $r[0]['channel_address'] ; - if ($channel_address !== '') { - $f = 'store/' . $channel_address.'/'; - logger ('delete '. $f); - if(is_dir($f)) - @rrmdir($f); - } - - Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id)); - - if($channel_id == local_channel() && $unset_session) { - App::$session->nuke(); - goaway(z_root()); - } - -} - -/** - * mark any hubs "offline" that haven't been heard from in more than 30 days - * Allow them to redeem themselves if they come back later. - * Then go through all those that are newly marked and see if any other hubs - * are attached to the controlling xchan that are still alive. - * If not, they're dead (although they could come back some day). - */ - - -function mark_orphan_hubsxchans() { - - $dirmode = intval(get_config('system','directory_mode')); - if($dirmode == DIRECTORY_MODE_NORMAL) - return; - - $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0 - and hubloc_network = 'zot' and hubloc_connected < %s - interval %s", - db_utcnow(), db_quoteinterval('36 day') - ); - -// $realm = get_directory_realm(); -// if($realm == DIRECTORY_REALM) { -// $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') order by rand()", -// dbesc($realm) -// ); -// } -// else { -// $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' order by rand()", -// dbesc($realm) -// ); -// } - - - $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0"); - - if($r) { - foreach($r as $rr) { - - // see if any other hublocs are still alive for this channel - - $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0", - dbesc($rr['hubloc_hash']) - ); - if($x) { - - // yes - if the xchan was marked as an orphan, undo it - - $y = q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'", - dbesc($rr['hubloc_hash']) - ); - - } - else { - - // nope - mark the xchan as an orphan - - $y = q("update xchan set xchan_orphan = 1 where xchan_hash = '%s'", - dbesc($rr['hubloc_hash']) - ); - } - - // mark that we've checked this entry so we don't need to do it again - - $y = q("update hubloc set hubloc_orphancheck = 1 where hubloc_id = %d", - dbesc($rr['hubloc_id']) - ); - } - } - -} - - - - -function remove_all_xchan_resources($xchan, $channel_id = 0) { - - if(intval($channel_id)) { - - - - } - else { - - $dirmode = intval(get_config('system','directory_mode')); - - - $r = q("delete from photo where xchan = '%s'", - dbesc($xchan) - ); - $r = q("select resource_id, resource_type, uid, id from item where ( author_xchan = '%s' or owner_xchan = '%s' ) ", - dbesc($xchan), - dbesc($xchan) - ); - if($r) { - foreach($r as $rr) { - drop_item($rr,false); - } - } - $r = q("delete from event where event_xchan = '%s'", - dbesc($xchan) - ); - $r = q("delete from group_member where xchan = '%s'", - dbesc($xchan) - ); - $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' )", - dbesc($xchan), - dbesc($xchan) - ); - $r = q("delete from xlink where ( xlink_xchan = '%s' or xlink_link = '%s' )", - dbesc($xchan), - dbesc($xchan) - ); - - $r = q("delete from abook where abook_xchan = '%s'", - dbesc($xchan) - ); - - - if($dirmode === false || $dirmode == DIRECTORY_MODE_NORMAL) { - - $r = q("delete from xchan where xchan_hash = '%s'", - dbesc($xchan) - ); - $r = q("delete from hubloc where hubloc_hash = '%s'", - dbesc($xchan) - ); - - } - else { - - // directory servers need to keep the record around for sync purposes - mark it deleted - - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", - dbesc($xchan) - ); - - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", - dbesc($xchan) - ); - } - } -} - - -function contact_remove($channel_id, $abook_id) { - - if((! $channel_id) || (! $abook_id)) - return false; - - logger('removing contact ' . $abook_id . ' for channel ' . $channel_id,LOGGER_DEBUG); - - $archive = get_pconfig($channel_id, 'system','archive_removed_contacts'); - if($archive) { - q("update abook set abook_archived = 1 where abook_id = %d and abook_channel = %d", - intval($abook_id), - intval($channel_id) - ); - return true; - } - - $r = q("select * from abook where abook_id = %d and abook_channel = %d limit 1", - intval($abook_id), - intval($channel_id) - ); - - if(! $r) - return false; - - $abook = $r[0]; - - if(intval($abook['abook_self'])) - return false; - - - $r = q("select * from item where author_xchan = '%s' and uid = %d", - dbesc($abook['abook_xchan']), - intval($channel_id) - ); - if($r) { - foreach($r as $rr) { - drop_item($rr['id'],false); - } - } - - q("delete from abook where abook_id = %d and abook_channel = %d", - intval($abook['abook_id']), - intval($channel_id) - ); - - $r = q("delete from event where event_xchan = '%s' and uid = %d", - dbesc($abook['abook_xchan']), - intval($channel_id) - ); - - $r = q("delete from group_member where xchan = '%s' and uid = %d", - dbesc($abook['abook_xchan']), - intval($channel_id) - ); - - $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and channel_id = %d ", - dbesc($abook['abook_xchan']), - dbesc($abook['abook_xchan']), - intval($channel_id) - ); - - return true; -} - - - -function random_profile() { - $randfunc = db_getfunc('rand'); - - $checkrandom = get_config('randprofile','check'); // False by default - $retryrandom = intval(get_config('randprofile','retry')); - if($retryrandom == 0) $retryrandom = 5; - - for($i = 0; $i < $retryrandom; $i++) { - - $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1", - db_utcnow(), db_quoteinterval('30 day') - ); - - if(!$r) return ''; // Couldn't get a random channel - - if($checkrandom) { - $x = z_fetch_url($r[0]['xchan_url']); - if($x['success']) - return $r[0]['xchan_url']; - else - logger('Random channel turned out to be bad.'); - } - else { - return $r[0]['xchan_url']; - } - - } - return ''; -} - diff --git a/include/account.php b/include/account.php index 5998609d4..e367e002d 100644 --- a/include/account.php +++ b/include/account.php @@ -11,7 +11,7 @@ require_once('include/text.php'); require_once('include/language.php'); require_once('include/datetime.php'); require_once('include/crypto.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); function check_account_email($email) { diff --git a/include/api.php b/include/api.php index 4a462d1e8..ba36cc01a 100644 --- a/include/api.php +++ b/include/api.php @@ -514,7 +514,7 @@ require_once('include/api_auth.php'); return false; } - require_once('include/identity.php'); + require_once('include/channel.php'); json_return_and_die(identity_basic_export(api_user(),(($_REQUEST['posts']) ? intval($_REQUEST['posts']) : 0 ))); } diff --git a/include/apps.php b/include/apps.php index 7439be6d4..e300bc50d 100644 --- a/include/apps.php +++ b/include/apps.php @@ -6,7 +6,7 @@ */ require_once('include/plugin.php'); -require_once('include/identity.php'); +require_once('include/channel.php'); function get_system_apps($translate = true) { diff --git a/include/channel.php b/include/channel.php new file mode 100644 index 000000000..050c4824b --- /dev/null +++ b/include/channel.php @@ -0,0 +1,1947 @@ + false, 'message' => ''); + + $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0 ", + intval($account_id) + ); + if(! ($r && count($r))) { + $ret['total_identities'] = 0; + $ret['message'] = t('Unable to obtain identity information from database'); + return $ret; + } + + $ret['total_identities'] = intval($r[0]['total']); + + if (! account_service_class_allows($account_id, 'total_identities', $r[0]['total'])) { + $ret['message'] .= upgrade_message(); + return $ret; + } + + $ret['success'] = true; + + return $ret; +} + + +/** + * @brief Determine if the channel name is allowed when creating a new channel. + * + * This action is pluggable. + * We're currently only checking for an empty name or one that exceeds our + * storage limit (255 chars). 255 chars is probably going to create a mess on + * some pages. + * Plugins can set additional policies such as full name requirements, character + * sets, multi-byte length, etc. + * + * @param string $name + * + * @returns nil return if name is valid, or string describing the error state. + */ +function validate_channelname($name) { + + if (! $name) + return t('Empty name'); + + if (strlen($name) > 255) + return t('Name too long'); + + $arr = array('name' => $name); + call_hooks('validate_channelname', $arr); + + if (x($arr, 'message')) + return $arr['message']; +} + + +/** + * @brief Create a system channel - which has no account attached. + * + */ +function create_sys_channel() { + if (get_sys_channel()) + return; + + // Ensure that there is a host keypair. + + if ((! get_config('system', 'pubkey')) && (! get_config('system', 'prvkey'))) { + require_once('include/crypto.php'); + $hostkey = new_keypair(4096); + set_config('system', 'pubkey', $hostkey['pubkey']); + set_config('system', 'prvkey', $hostkey['prvkey']); + } + + create_identity(array( + 'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required + 'nickname' => 'sys', + 'name' => 'System', + 'pageflags' => 0, + 'publish' => 0, + 'system' => 1 + )); +} + + +/** + * @brief Returns the sys channel. + * + * @return array|boolean + */ +function get_sys_channel() { + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_system = 1 limit 1"); + + if ($r) + return $r[0]; + + return false; +} + + +/** + * @brief Checks if $channel_id is sys channel. + * + * @param int $channel_id + * @return boolean + */ +function is_sys_channel($channel_id) { + $r = q("select channel_system from channel where channel_id = %d and channel_system = 1 limit 1", + intval($channel_id) + ); + + if($r) + return true; + + return false; +} + + +/** + * @brief Return the total number of channels on this site. + * + * No filtering is performed except to check PAGE_REMOVED. + * + * @returns int|booleean + * on error returns boolean false + */ +function channel_total() { + $r = q("select channel_id from channel where channel_removed = 0"); + + if (is_array($r)) + return count($r); + + return false; +} + + +/** + * @brief Create a new channel. + * + * Also creates the related xchan, hubloc, profile, and "self" abook records, + * and an empty "Friends" group/collection for the new channel. + * + * @param array $arr assoziative array with: + * * \e string \b name full name of channel + * * \e string \b nickname "email/url-compliant" nickname + * * \e int \b account_id to attach with this channel + * * [other identity fields as desired] + * + * @returns array + * 'success' => boolean true or false + * 'message' => optional error text if success is false + * 'channel' => if successful the created channel array + */ +function create_identity($arr) { + + $ret = array('success' => false); + + if(! $arr['account_id']) { + $ret['message'] = t('No account identifier'); + return $ret; + } + $ret = identity_check_service_class($arr['account_id']); + if (!$ret['success']) { + return $ret; + } + // save this for auto_friending + $total_identities = $ret['total_identities']; + + $nick = mb_strtolower(trim($arr['nickname'])); + if(! $nick) { + $ret['message'] = t('Nickname is required.'); + return $ret; + } + + $name = escape_tags($arr['name']); + $pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL); + $system = ((x($arr,'system')) ? intval($arr['system']) : 0); + $name_error = validate_channelname($arr['name']); + if($name_error) { + $ret['message'] = $name_error; + return $ret; + } + + if($nick === 'sys' && (! $system)) { + $ret['message'] = t('Reserved nickname. Please choose another.'); + return $ret; + } + + if(check_webbie(array($nick)) !== $nick) { + $ret['message'] = t('Nickname has unsupported characters or is already being used on this site.'); + return $ret; + } + + $guid = zot_new_uid($nick); + $key = new_keypair(4096); + + $sig = base64url_encode(rsa_sign($guid,$key['prvkey'])); + $hash = make_xchan_hash($guid,$sig); + + // Force a few things on the short term until we can provide a theme or app with choice + + $publish = 1; + + if(array_key_exists('publish', $arr)) + $publish = intval($arr['publish']); + + $primary = true; + + if(array_key_exists('primary', $arr)) + $primary = intval($arr['primary']); + + $role_permissions = null; + $global_perms = get_perms(); + + if(array_key_exists('permissions_role',$arr) && $arr['permissions_role']) { + $role_permissions = get_role_perms($arr['permissions_role']); + + if($role_permissions) { + foreach($role_permissions as $p => $v) { + if(strpos($p,'channel_') !== false) { + $perms_keys .= ', ' . $p; + $perms_vals .= ', ' . intval($v); + } + if($p === 'directory_publish') + $publish = intval($v); + } + } + } + else { + $defperms = site_default_perms(); + foreach($defperms as $p => $v) { + $perms_keys .= ', ' . $global_perms[$p][0]; + $perms_vals .= ', ' . intval($v); + } + } + + $expire = 0; + + $r = q("insert into channel ( channel_account_id, channel_primary, + channel_name, channel_address, channel_guid, channel_guid_sig, + channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_system, channel_expire_days, channel_timezone $perms_keys ) + values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' $perms_vals ) ", + + intval($arr['account_id']), + intval($primary), + dbesc($name), + dbesc($nick), + dbesc($guid), + dbesc($sig), + dbesc($hash), + dbesc($key['prvkey']), + dbesc($key['pubkey']), + intval($pageflags), + intval($system), + intval($expire), + dbesc(App::$timezone) + ); + + $r = q("select * from channel where channel_account_id = %d + and channel_guid = '%s' limit 1", + intval($arr['account_id']), + dbesc($guid) + ); + + if(! $r) { + $ret['message'] = t('Unable to retrieve created identity'); + return $ret; + } + + $ret['channel'] = $r[0]; + + if(intval($arr['account_id'])) + set_default_login_identity($arr['account_id'],$ret['channel']['channel_id'],false); + + // Create a verified hub location pointing to this site. + + $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary, + hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_network ) + values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )", + dbesc($guid), + dbesc($sig), + dbesc($hash), + dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()), + intval($primary), + dbesc(z_root()), + dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))), + dbesc(App::get_hostname()), + dbesc(z_root() . '/post'), + dbesc(get_config('system','pubkey')), + dbesc('zot') + ); + if(! $r) + logger('create_identity: Unable to store hub location'); + + $newuid = $ret['channel']['channel_id']; + + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_system ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", + dbesc($hash), + dbesc($guid), + dbesc($sig), + dbesc($key['pubkey']), + dbesc(z_root() . "/photo/profile/l/{$newuid}"), + dbesc(z_root() . "/photo/profile/m/{$newuid}"), + dbesc(z_root() . "/photo/profile/s/{$newuid}"), + dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()), + dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']), + dbesc(z_root() . '/follow?f=&url=%s'), + dbesc(z_root() . '/poco/' . $ret['channel']['channel_address']), + dbesc($ret['channel']['channel_name']), + dbesc('zot'), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($system) + ); + + // Not checking return value. + // It's ok for this to fail if it's an imported channel, and therefore the hash is a duplicate + + $r = q("INSERT INTO profile ( aid, uid, profile_guid, profile_name, is_default, publish, name, photo, thumb) + VALUES ( %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s') ", + intval($ret['channel']['channel_account_id']), + intval($newuid), + dbesc(random_string()), + t('Default Profile'), + 1, + $publish, + dbesc($ret['channel']['channel_name']), + dbesc(z_root() . "/photo/profile/l/{$newuid}"), + dbesc(z_root() . "/photo/profile/m/{$newuid}") + ); + + if($role_permissions) { + $myperms = ((array_key_exists('perms_accept',$role_permissions)) ? intval($role_permissions['perms_accept']) : 0); + } + else + $myperms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK + |PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT + |PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE; + + $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_self, abook_my_perms ) + values ( %d, %d, '%s', %d, '%s', '%s', %d, %d ) ", + intval($ret['channel']['channel_account_id']), + intval($newuid), + dbesc($hash), + intval(0), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval(1), + intval($myperms) + ); + + if(intval($ret['channel']['channel_account_id'])) { + + // Save our permissions role so we can perhaps call it up and modify it later. + + if($role_permissions) { + set_pconfig($newuid,'system','permissions_role',$arr['permissions_role']); + if(array_key_exists('online',$role_permissions)) + set_pconfig($newuid,'system','hide_presence',1-intval($role_permissions['online'])); + if(array_key_exists('perms_auto',$role_permissions)) + set_pconfig($newuid,'system','autoperms',(($role_permissions['perms_auto']) ? $role_permissions['perms_accept'] : 0)); + } + + // Create a group with yourself as a member. This allows somebody to use it + // right away as a default group for new contacts. + + require_once('include/group.php'); + group_add($newuid, t('Friends')); + group_add_member($newuid,t('Friends'),$ret['channel']['channel_hash']); + + // if our role_permissions indicate that we're using a default collection ACL, add it. + + if(is_array($role_permissions) && $role_permissions['default_collection']) { + $r = q("select hash from groups where uid = %d and name = '%s' limit 1", + intval($newuid), + dbesc( t('Friends') ) + ); + if($r) { + q("update channel set channel_default_group = '%s', channel_allow_gid = '%s' where channel_id = %d", + dbesc($r[0]['hash']), + dbesc('<' . $r[0]['hash'] . '>'), + intval($newuid) + ); + } + } + + if(! $system) { + set_pconfig($ret['channel']['channel_id'],'system','photo_path', '%Y-%m'); + set_pconfig($ret['channel']['channel_id'],'system','attach_path','%Y-%m'); + } + + // UNO: channel defaults, incl addons (addons specific pconfig will only work after the relevant addon is enabled by the admin). It's located here, so members can modify these defaults after the channel is created. + if(UNO) { + //diaspora protocol addon + set_pconfig($ret['channel']['channel_id'],'system','diaspora_allowed', '1'); + set_pconfig($ret['channel']['channel_id'],'system','diaspora_public_comments', '1'); + set_pconfig($ret['channel']['channel_id'],'system','prevent_tag_hijacking', '0'); + } + + // auto-follow any of the hub's pre-configured channel choices. + // Only do this if it's the first channel for this account; + // otherwise it could get annoying. Don't make this list too big + // or it will impact registration time. + + $accts = get_config('system','auto_follow'); + if(($accts) && (! $total_identities)) { + require_once('include/follow.php'); + if(! is_array($accts)) + $accts = array($accts); + foreach($accts as $acct) { + if(trim($acct)) + new_contact($newuid,trim($acct),$ret['channel'],false); + } + } + + call_hooks('create_identity', $newuid); + + Zotlabs\Daemon\Master::Summon(array('Directory', $ret['channel']['channel_id'])); + } + + $ret['success'] = true; + return $ret; +} + +/** + * @brief Set default channel to be used on login. + * + * @param int $account_id + * login account + * @param int $channel_id + * channel id to set as default for this account + * @param boolean $force + * if true, set this default unconditionally + * if $force is false only do this if there is no existing default + */ +function set_default_login_identity($account_id, $channel_id, $force = true) { + $r = q("select account_default_channel from account where account_id = %d limit 1", + intval($account_id) + ); + if ($r) { + if ((intval($r[0]['account_default_channel']) == 0) || ($force)) { + $r = q("update account set account_default_channel = %d where account_id = %d", + intval($channel_id), + intval($account_id) + ); + } + } +} + +/** + * @brief Create an array representing the important channel information + * which would be necessary to create a nomadic identity clone. This includes + * most channel resources and connection information with the exception of content. + * + * @param int $channel_id + * Channel_id to export + * @param boolean $items + * Include channel posts (wall items), default false + * + * @returns array + * See function for details + */ +function identity_basic_export($channel_id, $items = false) { + + /* + * Red basic channel export + */ + + $ret = array(); + + // use constants here as otherwise we will have no idea if we can import from a site + // with a non-standard platform and version. + $ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => STD_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => Zotlabs\Lib\System::get_server_role()); + + $r = q("select * from channel where channel_id = %d limit 1", + intval($channel_id) + ); + if($r) + $ret['channel'] = $r[0]; + + $r = q("select * from profile where uid = %d", + intval($channel_id) + ); + if($r) + $ret['profile'] = $r; + + $xchans = array(); + $r = q("select * from abook where abook_channel = %d ", + intval($channel_id) + ); + if($r) { + $ret['abook'] = $r; + + for($x = 0; $x < count($ret['abook']); $x ++) { + $xchans[] = $ret['abook'][$x]['abook_chan']; + $abconfig = load_abconfig($ret['channel']['channel_hash'],$ret['abook'][$x]['abook_xchan']); + if($abconfig) + $ret['abook'][$x]['abconfig'] = $abconfig; + } + stringify_array_elms($xchans); + } + + if($xchans) { + $r = q("select * from xchan where xchan_hash in ( " . implode(',',$xchans) . " ) "); + if($r) + $ret['xchan'] = $r; + + $r = q("select * from hubloc where hubloc_hash in ( " . implode(',',$xchans) . " ) "); + if($r) + $ret['hubloc'] = $r; + } + + $r = q("select * from `groups` where uid = %d ", + intval($channel_id) + ); + + if($r) + $ret['group'] = $r; + + $r = q("select * from group_member where uid = %d ", + intval($channel_id) + ); + if($r) + $ret['group_member'] = $r; + + $r = q("select * from pconfig where uid = %d", + intval($channel_id) + ); + if($r) + $ret['config'] = $r; + + $r = q("select type, data, os_storage from photo where scale = 4 and photo_usage = %d and uid = %d limit 1", + intval(PHOTO_PROFILE), + intval($channel_id) + ); + + if($r) { + $ret['photo'] = array('type' => $r[0]['type'], 'data' => (($r[0]['os_storage']) ? base64url_encode(file_get_contents($r[0]['data'])) : base64url_encode($r[0]['data']))); + } + + // All other term types will be included in items, if requested. + + $r = q("select * from term where type in (%d,%d) and uid = %d", + intval(TERM_SAVEDSEARCH), + intval(TERM_THING), + intval($channel_id) + ); + if($r) + $ret['term'] = $r; + + + // add psuedo-column obj_baseurl to aid in relocations + + $r = q("select obj.*, '%s' as obj_baseurl from obj where obj_channel = %d", + dbesc(z_root()), + intval($channel_id) + ); + + if($r) + $ret['obj'] = $r; + + $r = q("select * from app where app_channel = %d and app_system = 0", + intval($channel_id) + ); + if($r) { + for($x = 0; $x < count($r); $x ++) { + $r[$x]['term'] = q("select * from term where otype = %d and oid = %d", + intval(TERM_OBJ_APP), + intval($r[$x]['id']) + ); + } + $ret['app'] = $r; + } + + $r = q("select * from chatroom where cr_uid = %d", + intval($channel_id) + ); + if($r) + $ret['chatroom'] = $r; + + + $r = q("select * from event where uid = %d", + intval($channel_id) + ); + if($r) + $ret['event'] = $r; + + $r = q("select * from item where resource_type = 'event' and uid = %d", + intval($channel_id) + ); + if($r) { + $ret['event_item'] = array(); + xchan_query($r); + $r = fetch_post_tags($r,true); + foreach($r as $rr) + $ret['event_item'][] = encode_item($rr,true); + } + + $x = menu_list($channel_id); + if($x) { + $ret['menu'] = array(); + for($y = 0; $y < count($x); $y ++) { + $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); + if($m) + $ret['menu'][] = menu_element($m); + } + } + + $x = menu_list($channel_id); + if($x) { + $ret['menu'] = array(); + for($y = 0; $y < count($x); $y ++) { + $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); + if($m) + $ret['menu'][] = menu_element($m); + } + } + + $addon = array('channel_id' => $channel_id,'data' => $ret); + call_hooks('identity_basic_export',$addon); + $ret = $addon['data']; + + + if(! $items) + return $ret; + + $r = q("select * from likes where channel_id = %d", + intval($channel_id) + ); + + if($r) + $ret['likes'] = $r; + + + $r = q("select * from conv where uid = %d", + intval($channel_id) + ); + if($r) { + for($x = 0; $x < count($r); $x ++) { + $r[$x]['subject'] = base64url_decode(str_rot47($r[$x]['subject'])); + } + $ret['conv'] = $r; + } + + + $r = q("select * from mail where mail.uid = %d", + intval($channel_id) + ); + if($r) { + $m = array(); + foreach($r as $rr) { + xchan_mail_query($rr); + $m[] = mail_encode($rr,true); + } + $ret['mail'] = $m; + } + + $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d", + intval($channel_id) + ); + + if($r) + $ret['item_id'] = $r; + + //$key = get_config('system','prvkey'); + + /** @warning this may run into memory limits on smaller systems */ + + + /** export three months of posts. If you want to export and import all posts you have to start with + * the first year and export/import them in ascending order. + * + * Don't export linked resource items. we'll have to pull those out separately. + */ + + $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d and created > %s - INTERVAL %s and resource_type = '' order by created", + intval($channel_id), + db_utcnow(), + db_quoteinterval('3 MONTH') + ); + if($r) { + $ret['item'] = array(); + xchan_query($r); + $r = fetch_post_tags($r,true); + foreach($r as $rr) + $ret['item'][] = encode_item($rr,true); + } + + return $ret; +} + + +function identity_export_year($channel_id,$year,$month = 0) { + + if(! $year) + return array(); + + if($month && $month <= 12) { + $target_month = sprintf('%02d',$month); + $target_month_plus = sprintf('%02d',$month+1); + } + else + $target_month = '01'; + + $ret = array(); + + $mindate = datetime_convert('UTC','UTC',$year . '-' . $target_month . '-01 00:00:00'); + if($month && $month < 12) + $maxdate = datetime_convert('UTC','UTC',$year . '-' . $target_month_plus . '-01 00:00:00'); + else + $maxdate = datetime_convert('UTC','UTC',$year+1 . '-01-01 00:00:00'); + + $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created", + intval(ITEM_TYPE_POST), + intval($channel_id), + dbesc($mindate), + dbesc($maxdate) + ); + + if($r) { + $ret['item'] = array(); + xchan_query($r); + $r = fetch_post_tags($r,true); + foreach($r as $rr) + $ret['item'][] = encode_item($rr,true); + } + + $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d + and item.created >= '%s' and item.created < '%s' order by created ", + intval($channel_id), + dbesc($mindate), + dbesc($maxdate) + ); + + if($r) + $ret['item_id'] = $r; + + + return $ret; +} + + +/** + * @brief Loads a profile into the App structure. + * + * The function requires a writeable copy of the main App structure, and the + * nickname of a valid channel. + * + * Permissions of the current observer are checked. If a restricted profile is available + * to the current observer, that will be loaded instead of the channel default profile. + * + * The channel owner can set $profile to a valid profile_guid to preview that profile. + * + * The channel default theme is also selected for use, unless over-riden elsewhere. + * + * @param[in,out] App &$a + * @param string $nickname + * @param string $profile + */ +function profile_load(&$a, $nickname, $profile = '') { + +// logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : '')); + + $user = q("select channel_id from channel where channel_address = '%s' and channel_removed = 0 limit 1", + dbesc($nickname) + ); + + if(! $user) { + logger('profile error: ' . App::$query_string, LOGGER_DEBUG); + notice( t('Requested channel is not available.') . EOL ); + App::$error = 404; + return; + } + + // get the current observer + $observer = App::get_observer(); + + $can_view_profile = true; + + // Can the observer see our profile? + require_once('include/permissions.php'); + if(! perm_is_allowed($user[0]['channel_id'],$observer['xchan_hash'],'view_profile')) { + $can_view_profile = false; + } + + if(! $profile) { + $r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' and abook_channel = '%d' limit 1", + dbesc($observer['xchan_hash']), + intval($user[0]['channel_id']) + ); + if($r) + $profile = $r[0]['abook_profile']; + } + $p = null; + + if($profile) { + $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile + LEFT JOIN channel ON profile.uid = channel.channel_id + WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1", + dbesc($nickname), + dbesc($profile) + ); + } + + if(! $p) { + $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile + LEFT JOIN channel ON profile.uid = channel.channel_id + WHERE channel.channel_address = '%s' and channel_removed = 0 + AND profile.is_default = 1 LIMIT 1", + dbesc($nickname) + ); + } + + if(! $p) { + logger('profile error: ' . App::$query_string, LOGGER_DEBUG); + notice( t('Requested profile is not available.') . EOL ); + App::$error = 404; + return; + } + + $q = q("select * from profext where hash = '%s' and channel_id = %d", + dbesc($p[0]['profile_guid']), + intval($p[0]['profile_uid']) + ); + if($q) { + + $extra_fields = array(); + + require_once('include/channel.php'); + $profile_fields_basic = get_profile_fields_basic(); + $profile_fields_advanced = get_profile_fields_advanced(); + + $advanced = ((feature_enabled(local_channel(),'advanced_profiles')) ? true : false); + if($advanced) + $fields = $profile_fields_advanced; + else + $fields = $profile_fields_basic; + + foreach($q as $qq) { + foreach($fields as $k => $f) { + if($k == $qq['k']) { + $p[0][$k] = $qq['v']; + $extra_fields[] = $k; + break; + } + } + } + } + + $p[0]['extra_fields'] = $extra_fields; + + $z = q("select xchan_photo_date, xchan_addr from xchan where xchan_hash = '%s' limit 1", + dbesc($p[0]['channel_hash']) + ); + if($z) { + $p[0]['picdate'] = $z[0]['xchan_photo_date']; + $p[0]['reddress'] = str_replace('@','@',$z[0]['xchan_addr']); + } + + // fetch user tags if this isn't the default profile + + if(! $p[0]['is_default']) { + $x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1", + intval($p[0]['profile_uid']) + ); + if($x && $can_view_profile) + $p[0]['keywords'] = $x[0]['keywords']; + } + + if($p[0]['keywords']) { + $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$p[0]['keywords']); + if(strlen($keywords) && $can_view_profile) + App::$page['htmlhead'] .= '' . "\r\n" ; + } + + App::$profile = $p[0]; + App::$profile_uid = $p[0]['profile_uid']; + App::$page['title'] = App::$profile['channel_name'] . " - " . App::$profile['channel_address'] . "@" . App::get_hostname(); + + App::$profile['permission_to_view'] = $can_view_profile; + + if($can_view_profile) { + $online = get_online_status($nickname); + App::$profile['online_status'] = $online['result']; + } + + if(local_channel()) { + App::$profile['channel_mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme'); + $_SESSION['mobile_theme'] = App::$profile['channel_mobile_theme']; + } + + /* + * load/reload current theme info + */ + + $_SESSION['theme'] = $p[0]['channel_theme']; + +} + +function profile_edit_menu($uid) { + + $ret = array(); + + $is_owner = (($uid == local_channel()) ? true : false); + + // show edit profile to profile owner + if($is_owner) { + $ret['menu'] = array( + 'chg_photo' => t('Change profile photo'), + 'entries' => array(), + ); + + $multi_profiles = feature_enabled(local_channel(), 'multi_profiles'); + if($multi_profiles) { + $ret['multi'] = 1; + $ret['edit'] = array(z_root(). '/profiles', t('Edit Profiles'), '', t('Edit')); + $ret['menu']['cr_new'] = t('Create New Profile'); + } + else { + $ret['edit'] = array(z_root() . '/profiles/' . $uid, t('Edit Profile'), '', t('Edit')); + } + + $r = q("SELECT * FROM profile WHERE uid = %d", + local_channel() + ); + + if($r) { + foreach($r as $rr) { + if(!($multi_profiles || $rr['is_default'])) + continue; + $ret['menu']['entries'][] = array( + 'photo' => $rr['thumb'], + 'id' => $rr['id'], + 'alt' => t('Profile Image'), + 'profile_name' => $rr['profile_name'], + 'isdefault' => $rr['is_default'], + 'visible_to_everybody' => t('Visible to everybody'), + 'edit_visibility' => t('Edit visibility'), + ); + } + } + } + + return $ret; + +} + +/** + * @brief Formats a profile for display in the sidebar. + * + * It is very difficult to templatise the HTML completely + * because of all the conditional logic. + * + * @param array $profile + * @param int $block + * @param boolean $show_connect + * + * @return HTML string suitable for sidebar inclusion + * Exceptions: Returns empty string if passed $profile is wrong type or not populated + */ +function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false) { + + $observer = App::get_observer(); + + $o = ''; + $location = false; + $pdesc = true; + $reddress = true; + + if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) { + $block = true; + } + + if((! is_array($profile)) && (! count($profile))) + return $o; + + head_set_icon($profile['thumb']); + + if(is_sys_channel($profile['uid'])) + $show_connect = false; + + $profile['picdate'] = urlencode($profile['picdate']); + + call_hooks('profile_sidebar_enter', $profile); + + if($show_connect) { + + // This will return an empty string if we're already connected. + + $connect_url = rconnect_url($profile['uid'],get_observer_hash()); + $connect = (($connect_url) ? t('Connect') : ''); + if($connect_url) + $connect_url = sprintf($connect_url,urlencode($profile['channel_address'] . '@' . App::get_hostname())); + + // premium channel - over-ride + + if($profile['channel_pageflags'] & PAGE_PREMIUM) + $connect_url = z_root() . '/connect/' . $profile['channel_address']; + } + + if((x($profile,'address') == 1) + || (x($profile,'locality') == 1) + || (x($profile,'region') == 1) + || (x($profile,'postal_code') == 1) + || (x($profile,'country_name') == 1)) + $location = t('Location:'); + + $profile['homepage'] = linkify($profile['homepage'],true); + + $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False); + $marital = ((x($profile,'marital') == 1) ? t('Status:') : False); + $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False); + $profile['online'] = (($profile['online_status'] === 'online') ? t('Online Now') : False); + +// logger('online: ' . $profile['online']); + + + if(($profile['hidewall'] && (! local_channel()) && (! remote_channel())) || $block ) { + $location = $reddress = $pdesc = $gender = $marital = $homepage = False; + } + + $firstname = ((strpos($profile['channel_name'],' ')) + ? trim(substr($profile['channel_name'],0,strpos($profile['channel_name'],' '))) : $profile['channel_name']); + $lastname = (($firstname === $profile['channel_name']) ? '' : trim(substr($profile['channel_name'],strlen($firstname)))); + + $diaspora = array( + 'podloc' => z_root(), + 'searchable' => (($block) ? 'false' : 'true'), + 'nickname' => $profile['channel_address'], + 'fullname' => $profile['channel_name'], + 'firstname' => $firstname, + 'lastname' => $lastname, + 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', + 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', + 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg', + ); + + $contact_block = contact_block(); + + $channel_menu = false; + $menu = get_pconfig($profile['uid'],'system','channel_menu'); + if($menu && ! $block) { + require_once('include/menu.php'); + $m = menu_fetch($menu,$profile['uid'],$observer['xchan_hash']); + if($m) + $channel_menu = menu_render($m); + } + $menublock = get_pconfig($profile['uid'],'system','channel_menublock'); + if ($menublock && (! $block)) { + $comanche = new Zotlabs\Render\Comanche(); + $channel_menu .= $comanche->block($menublock); + } + + if($zcard) + $tpl = get_markup_template('profile_vcard_short.tpl'); + else + $tpl = get_markup_template('profile_vcard.tpl'); + + require_once('include/widgets.php'); + + if(! feature_enabled($profile['uid'],'hide_rating')) + $z = widget_rating(array('target' => $profile['channel_hash'])); + + $o .= replace_macros($tpl, array( + '$zcard' => $zcard, + '$profile' => $profile, + '$connect' => $connect, + '$connect_url' => $connect_url, + '$location' => $location, + '$gender' => $gender, + '$pdesc' => $pdesc, + '$marital' => $marital, + '$homepage' => $homepage, + '$chanmenu' => $channel_menu, + '$diaspora' => $diaspora, + '$reddress' => $reddress, + '$rating' => $z, + '$contact_block' => $contact_block, + '$editmenu' => profile_edit_menu($profile['uid']) + )); + + $arr = array('profile' => &$profile, 'entry' => &$o); + + call_hooks('profile_sidebar', $arr); + + return $o; +} + + +/** + * @FIXME or remove + */ + function get_birthdays() { + + $o = ''; + + if(! local_channel()) + return $o; + + $bd_format = t('g A l F d') ; // 8 AM Friday January 18 + $bd_short = t('F d'); + + $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` + LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid` + WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s' + ORDER BY `start` ASC ", + intval(local_channel()), + dbesc(datetime_convert('UTC','UTC','now + 6 days')), + dbesc(datetime_convert('UTC','UTC','now')) + ); + + if($r && count($r)) { + $total = 0; + $now = strtotime('now'); + $cids = array(); + + $istoday = false; + foreach($r as $rr) { + if(strlen($rr['name'])) + $total ++; + if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) + $istoday = true; + } + $classtoday = $istoday ? ' birthday-today ' : ''; + if($total) { + foreach($r as &$rr) { + if(! strlen($rr['name'])) + continue; + + // avoid duplicates + + if(in_array($rr['cid'],$cids)) + continue; + $cids[] = $rr['cid']; + + $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); + $sparkle = ''; + $url = $rr['url']; + if($rr['network'] === NETWORK_DFRN) { + $sparkle = " sparkle"; + $url = z_root() . '/redir/' . $rr['cid']; + } + + $rr['link'] = $url; + $rr['title'] = $rr['name']; + $rr['date'] = day_translate(datetime_convert('UTC', App::$timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : ''); + $rr['startime'] = Null; + $rr['today'] = $today; + } + } + } + $tpl = get_markup_template("birthdays_reminder.tpl"); + return replace_macros($tpl, array( + '$baseurl' => z_root(), + '$classtoday' => $classtoday, + '$count' => $total, + '$event_reminders' => t('Birthday Reminders'), + '$event_title' => t('Birthdays this week:'), + '$events' => $r, + '$lbr' => '{', // raw brackets mess up if/endif macro processing + '$rbr' => '}' + )); + } + + +/** + * @FIXME + */ + function get_events() { + + require_once('include/bbcode.php'); + + if(! local_channel()) + return $o; + + $bd_format = t('g A l F d') ; // 8 AM Friday January 18 + $bd_short = t('F d'); + + $r = q("SELECT `event`.* FROM `event` + WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` > '%s' + ORDER BY `start` ASC ", + intval(local_channel()), + dbesc(datetime_convert('UTC','UTC','now + 6 days')), + dbesc(datetime_convert('UTC','UTC','now - 1 days')) + ); + + if($r && count($r)) { + $now = strtotime('now'); + $istoday = false; + foreach($r as $rr) { + if(strlen($rr['name'])) + $total ++; + + $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start'],'Y-m-d'); + if($strt === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) + $istoday = true; + } + $classtoday = (($istoday) ? 'event-today' : ''); + + foreach($r as &$rr) { + if($rr['adjust']) + $md = datetime_convert('UTC',App::$timezone,$rr['start'],'Y/m'); + else + $md = datetime_convert('UTC','UTC',$rr['start'],'Y/m'); + $md .= "/#link-".$rr['id']; + + $title = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... '; + if(! $title) + $title = t('[No description]'); + + $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start']); + $today = ((substr($strt,0,10) === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) ? true : false); + + $rr['link'] = $md; + $rr['title'] = $title; + $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? App::$timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); + $rr['startime'] = $strt; + $rr['today'] = $today; + } + } + + $tpl = get_markup_template("events_reminder.tpl"); + return replace_macros($tpl, array( + '$baseurl' => z_root(), + '$classtoday' => $classtoday, + '$count' => count($r), + '$event_reminders' => t('Event Reminders'), + '$event_title' => t('Events this week:'), + '$events' => $r, + )); + } + + +function advanced_profile(&$a) { + require_once('include/text.php'); + if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile')) + return ''; + + if(App::$profile['name']) { + + $profile_fields_basic = get_profile_fields_basic(); + $profile_fields_advanced = get_profile_fields_advanced(); + + $advanced = ((feature_enabled(App::$profile['profile_uid'],'advanced_profiles')) ? true : false); + if($advanced) + $fields = $profile_fields_advanced; + else + $fields = $profile_fields_basic; + + $clean_fields = array(); + if($fields) { + foreach($fields as $k => $v) { + $clean_fields[] = trim($k); + } + } + + + + $tpl = get_markup_template('profile_advanced.tpl'); + + $profile = array(); + + $profile['fullname'] = array( t('Full Name:'), App::$profile['name'] ) ; + + if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] ); + + $ob_hash = get_observer_hash(); + if($ob_hash && perm_is_allowed(App::$profile['profile_uid'],$ob_hash,'post_like')) { + $profile['canlike'] = true; + $profile['likethis'] = t('Like this channel'); + $profile['profile_guid'] = App::$profile['profile_guid']; + } + + $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'", + intval(App::$profile['profile_uid']), + dbesc(ACTIVITY_OBJ_PROFILE), + dbesc(ACTIVITY_LIKE) + ); + $profile['likers'] = array(); + $profile['like_count'] = count($likers); + $profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun'); + if($likers) { + foreach($likers as $l) + $profile['likers'][] = array('name' => $l['xchan_name'],'photo' => zid($l['xchan_photo_s']), 'url' => zid($l['xchan_url'])); + } + + if((App::$profile['dob']) && (App::$profile['dob'] != '0000-00-00')) { + + $val = ''; + + if((substr(App::$profile['dob'],5,2) === '00') || (substr(App::$profile['dob'],8,2) === '00')) + $val = substr(App::$profile['dob'],0,4); + + $year_bd_format = t('j F, Y'); + $short_bd_format = t('j F'); + + if(! $val) { + $val = ((intval(App::$profile['dob'])) + ? day_translate(datetime_convert('UTC','UTC',App::$profile['dob'] . ' 00:00 +00:00',$year_bd_format)) + : day_translate(datetime_convert('UTC','UTC','2001-' . substr(App::$profile['dob'],5) . ' 00:00 +00:00',$short_bd_format))); + } + $profile['birthday'] = array( t('Birthday:'), $val); + } + + if($age = age(App::$profile['dob'],App::$profile['timezone'],'')) + $profile['age'] = array( t('Age:'), $age ); + + if(App::$profile['marital']) + $profile['marital'] = array( t('Status:'), App::$profile['marital']); + + if(App::$profile['with']) + $profile['marital']['with'] = bbcode(App::$profile['with']); + + if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) { + $profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s')); + } + + if(App::$profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), App::$profile['sexual'] ); + + if(App::$profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify(App::$profile['homepage']) ); + + if(App::$profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify(App::$profile['hometown']) ); + + if(App::$profile['keywords']) $profile['keywords'] = array( t('Tags:'), App::$profile['keywords']); + + if(App::$profile['politic']) $profile['politic'] = array( t('Political Views:'), App::$profile['politic']); + + if(App::$profile['religion']) $profile['religion'] = array( t('Religion:'), App::$profile['religion']); + + if($txt = prepare_text(App::$profile['about'])) $profile['about'] = array( t('About:'), $txt ); + + if($txt = prepare_text(App::$profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt); + + if($txt = prepare_text(App::$profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt); + + if($txt = prepare_text(App::$profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt); + + if($txt = prepare_text(App::$profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); + + if($txt = prepare_text(App::$profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt); + + if($txt = prepare_text(App::$profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt); + + if($txt = prepare_text(App::$profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt); + + if($txt = prepare_text(App::$profile['tv'])) $profile['tv'] = array( t('Television:'), $txt); + + if($txt = prepare_text(App::$profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt); + + if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt); + + if($txt = prepare_text(App::$profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); + + if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); + + if(App::$profile['extra_fields']) { + foreach(App::$profile['extra_fields'] as $f) { + $x = q("select * from profdef where field_name = '%s' limit 1", + dbesc($f) + ); + if($x && $txt = prepare_text(App::$profile[$f])) + $profile[$f] = array( $x[0]['field_desc'] . ':',$txt); + } + $profile['extra_fields'] = App::$profile['extra_fields']; + } + + $things = get_things(App::$profile['profile_guid'],App::$profile['profile_uid']); + +// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA); + + return replace_macros($tpl, array( + '$title' => t('Profile'), + '$canlike' => (($profile['canlike'])? true : false), + '$likethis' => t('Like this thing'), + '$profile' => $profile, + '$fields' => $clean_fields, + '$editmenu' => profile_edit_menu(App::$profile['profile_uid']), + '$things' => $things + )); + } + + return ''; +} + + +function get_my_url() { + if(x($_SESSION, 'zrl_override')) + return $_SESSION['zrl_override']; + if(x($_SESSION, 'my_url')) + return $_SESSION['my_url']; + + return false; +} + +function get_my_address() { + if(x($_SESSION, 'zid_override')) + return $_SESSION['zid_override']; + if(x($_SESSION, 'my_address')) + return $_SESSION['my_address']; + + return false; +} + +/** + * @brief + * + * If somebody arrives at our site using a zid, add their xchan to our DB if we don't have it already. + * And if they aren't already authenticated here, attempt reverse magic auth. + * + * @param App &$a + * + * @hooks 'zid_init' + * string 'zid' - their zid + * string 'url' - the destination url + */ +function zid_init(&$a) { + $tmp_str = get_my_address(); + if(validate_email($tmp_str)) { + Zotlabs\Daemon\Master::Summon(array('Gprobe',bin2hex($tmp_str))); + $arr = array('zid' => $tmp_str, 'url' => App::$cmd); + call_hooks('zid_init',$arr); + if(! local_channel()) { + $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc limit 1", + dbesc($tmp_str) + ); + if($r && remote_channel() && remote_channel() === $r[0]['hubloc_hash']) + return; + logger('zid_init: not authenticated. Invoking reverse magic-auth for ' . $tmp_str); + // try to avoid recursion - but send them home to do a proper magic auth + $query = App::$query_string; + $query = str_replace(array('?zid=','&zid='),array('?rzid=','&rzid='),$query); + $dest = '/' . urlencode($query); + if($r && ($r[0]['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) { + goaway($r[0]['hubloc_url'] . '/magic' . '?f=&rev=1&dest=' . z_root() . $dest); + } + else + logger('zid_init: no hubloc found.'); + } + } +} + +/** + * @brief Adds a zid parameter to a url. + * + * @param string $s + * The url to accept the zid + * @param boolean $address + * $address to use instead of session environment + * @return string + * + * @hooks 'zid' + * string url - url to accept zid + * string zid - urlencoded zid + * string result - the return string we calculated, change it if you want to return something else + */ +function zid($s,$address = '') { + if (! strlen($s) || strpos($s,'zid=')) + return $s; + + $has_params = ((strpos($s,'?')) ? true : false); + $num_slashes = substr_count($s, '/'); + if (! $has_params) + $has_params = ((strpos($s, '&')) ? true : false); + + $achar = strpos($s,'?') ? '&' : '?'; + + $mine = get_my_url(); + $myaddr = (($address) ? $address : get_my_address()); + + /** @FIXME checking against our own channel url is no longer reliable. We may have a lot + * of urls attached to out channel. Should probably match against our site, since we + * will not need to remote authenticate on our own site anyway. + */ + + if ($mine && $myaddr && (! link_compare($mine,$s))) + $zurl = $s . (($num_slashes >= 3) ? '' : '/') . $achar . 'zid=' . urlencode($myaddr); + else + $zurl = $s; + + $arr = array('url' => $s, 'zid' => urlencode($myaddr), 'result' => $zurl); + call_hooks('zid', $arr); + + return $arr['result']; +} + +// Used from within PCSS themes to set theme parameters. If there's a +// puid request variable, that is the "page owner" and normally their theme +// settings take precedence; unless a local user sets the "always_my_theme" +// system pconfig, which means they don't want to see anybody else's theme +// settings except their own while on this site. + +function get_theme_uid() { + $uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0); + if(local_channel()) { + if((get_pconfig(local_channel(),'system','always_my_theme')) || (! $uid)) + return local_channel(); + } + if(! $uid) { + $x = get_sys_channel(); + if($x) + return $x['channel_id']; + } + + return $uid; +} + +/** +* @brief Retrieves the path of the default_profile_photo for this system +* with the specified size. +* +* @param int $size +* one of (300, 80, 48) +* @returns string +*/ +function get_default_profile_photo($size = 300) { + $scheme = get_config('system','default_profile_photo'); + if(! $scheme) + $scheme = 'rainbow_man'; + + return 'images/default_profile_photos/' . $scheme . '/' . $size . '.png'; +} + +/** + * @brief Test whether a given identity is NOT a member of the Hubzilla. + * + * @param string $s; + * xchan_hash of the identity in question + * @returns boolean true or false + */ +function is_foreigner($s) { + return((strpbrk($s, '.:@')) ? true : false); +} + +/** + * @brief Test whether a given identity is a member of the Hubzilla. + * + * @param string $s; + * xchan_hash of the identity in question + * @returns boolean true or false + */ +function is_member($s) { + return((is_foreigner($s)) ? false : true); +} + +function get_online_status($nick) { + + $ret = array('result' => false); + + if(get_config('system','block_public') && ! local_channel() && ! remote_channel()) + return $ret; + + $r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1", + dbesc(argv(1)) + ); + if($r) { + $hide = get_pconfig($r[0]['channel_id'],'system','hide_online_status'); + if($hide) + return $ret; + $x = q("select cp_status from chatpresence where cp_xchan = '%s' and cp_room = 0 limit 1", + dbesc($r[0]['channel_hash']) + ); + if($x) + $ret['result'] = $x[0]['cp_status']; + } + + return $ret; +} + + +function remote_online_status($webbie) { + + $result = false; + $r = q("select * from hubloc where hubloc_addr = '%s' limit 1", + dbesc($webbie) + ); + if(! $r) + return $result; + + $url = $r[0]['hubloc_url'] . '/online/' . substr($webbie,0,strpos($webbie,'@')); + + $x = z_fetch_url($url); + if($x['success']) { + $j = json_decode($x['body'],true); + if($j) + $result = (($j['result']) ? $j['result'] : false); + } + + return $result; +} + + +function get_channel_by_nick($nick) { + $r = q("select * from channel where channel_address = '%s' limit 1", + dbesc($nick) + ); + return(($r) ? $r[0] : false); + +} + +/** + * @brief + * + * @return string + */ +function identity_selector() { + if (local_channel()) { + $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", + intval(get_account_id()) + ); + if (count($r) > 1) { + //$account = App::get_account(); + $o = replace_macros(get_markup_template('channel_id_select.tpl'), array( + '$channels' => $r, + '$selected' => local_channel() + )); + return $o; + } + } + + return ''; +} + + +function is_public_profile() { + if(! local_channel()) + return false; + if(intval(get_config('system','block_public'))) + return false; + $channel = App::get_channel(); + if($channel && $channel['channel_r_profile'] == PERMS_PUBLIC) + return true; + + return false; +} + +function get_profile_fields_basic($filter = 0) { + + $profile_fields_basic = (($filter == 0) ? get_config('system','profile_fields_basic') : null); + if(! $profile_fields_basic) + $profile_fields_basic = array('name','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact'); + + $x = array(); + if($profile_fields_basic) + foreach($profile_fields_basic as $f) + $x[$f] = 1; + + return $x; +} + + +function get_profile_fields_advanced($filter = 0) { + $basic = get_profile_fields_basic($filter); + $profile_fields_advanced = (($filter == 0) ? get_config('system','profile_fields_advanced') : null); + if(! $profile_fields_advanced) + $profile_fields_advanced = array('with','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education'); + + $x = array(); + if($basic) + foreach($basic as $f => $v) + $x[$f] = $v; + + if($profile_fields_advanced) + foreach($profile_fields_advanced as $f) + $x[$f] = 1; + + return $x; +} + +/** + * @brief Clear notifyflags for a channel. + * + * Most likely during bulk import of content or other activity that is likely + * to generate huge amounts of undesired notifications. + * + * @param int $channel_id + * The channel to disable notifications for + * @returns int + * Current notification flag value. Send this to notifications_on() to restore the channel settings when finished + * with the activity requiring notifications_off(); + */ +function notifications_off($channel_id) { + $r = q("select channel_notifyflags from channel where channel_id = %d limit 1", + intval($channel_id) + ); + q("update channel set channel_notifyflags = 0 where channel_id = %d", + intval($channel_id) + ); + + return intval($r[0]['channel_notifyflags']); +} + + +function notifications_on($channel_id,$value) { + $x = q("update channel set channel_notifyflags = %d where channel_id = %d", + intval($value), + intval($channel_id) + ); + return $x; +} + + +function get_channel_default_perms($uid) { + + $r = q("select abook_my_perms from abook where abook_channel = %d and abook_self = 1 limit 1", + intval($uid) + ); + if($r) + return $r[0]['abook_my_perms']; + + return 0; +} + + +function profiles_build_sync($channel_id) { + + $r = q("select * from profile where uid = %d", + intval($channel_id) + ); + if($r) { + build_sync_packet($channel_id,array('profile' => $r)); + } +} + + +function auto_channel_create($account_id) { + + if(! $account_id) + return false; + + $arr = array(); + $arr['account_id'] = $account_id; + $arr['name'] = get_aconfig($account_id,'register','channel_name'); + $arr['nickname'] = legal_webbie(get_aconfig($account_id,'register','channel_address')); + $arr['permissions_role'] = get_aconfig($account_id,'register','permissions_role'); + + del_aconfig($account_id,'register','channel_name'); + del_aconfig($account_id,'register','channel_address'); + del_aconfig($account_id,'register','permissions_role'); + + if((! $arr['name']) || (! $arr['nickname'])) { + $x = q("select * from account where account_id = %d limit 1", + intval($account_id) + ); + if($x) { + if(! $arr['name']) + $arr['name'] = substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@')); + if(! $arr['nickname']) + $arr['nickname'] = legal_webbie(substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@'))); + } + } + if(! $arr['permissions_role']) + $arr['permissions_role'] = 'social'; + + if(validate_channelname($arr['name'])) + return false; + if($arr['nickname'] === 'sys') + $arr['nickname'] = $arr['nickname'] . mt_rand(1000,9999); + + $arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999))); + + return create_identity($arr); + +} + +function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) { + + $r = q("select height, width, resource_id, type from photo where uid = %d and scale = %d and photo_usage = %d", + intval($channel_id), + intval($res), + intval(PHOTO_COVER) + ); + if(! $r) + return false; + + $output = false; + + $url = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $res ; + + switch($format) { + case 'bbcode': + $output = '[zrl=' . $r[0]['width'] . 'x' . $r[0]['height'] . ']' . $url . '[/zrl]'; + break; + case 'html': + $output = '' . t('cover photo') . ''; + break; + case 'array': + default: + $output = array( + 'width' => $r[0]['width'], + 'height' => $r[0]['type'], + 'type' => $r[0]['type'], + 'url' => $url + ); + break; + } + + return $output; + +} + +function get_zcard($channel,$observer_hash = '',$args = array()) { + + logger('get_zcard'); + + $maxwidth = (($args['width']) ? intval($args['width']) : 0); + $maxheight = (($args['height']) ? intval($args['height']) : 0); + + + if(($maxwidth > 1200) || ($maxwidth < 1)) + $maxwidth = 1200; + + if($maxwidth <= 425) { + $width = 425; + $size = 'hz_small'; + $cover_size = PHOTO_RES_COVER_425; + $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); + } + elseif($maxwidth <= 900) { + $width = 900; + $size = 'hz_medium'; + $cover_size = PHOTO_RES_COVER_850; + $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); + } + elseif($maxwidth <= 1200) { + $width = 1200; + $size = 'hz_large'; + $cover_size = PHOTO_RES_COVER_1200; + $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); + } + +// $scale = (float) $maxwidth / $width; +// $translate = intval(($scale / 1.0) * 100); + + + $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname(); + $zcard = array('chan' => $channel); + + $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", + intval($channel['channel_id']), + intval($cover_size), + intval(PHOTO_COVER) + ); + + if($r) { + $cover = $r[0]; + $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale']; + } + else { + $cover = $pphoto; + } + + $o .= replace_macros(get_markup_template('zcard.tpl'),array( + '$maxwidth' => $maxwidth, + '$scale' => $scale, + '$translate' => $translate, + '$size' => $size, + '$cover' => $cover, + '$pphoto' => $pphoto, + '$zcard' => $zcard + )); + + return $o; + +} + + +function get_zcard_embed($channel,$observer_hash = '',$args = array()) { + + logger('get_zcard_embed'); + + $maxwidth = (($args['width']) ? intval($args['width']) : 0); + $maxheight = (($args['height']) ? intval($args['height']) : 0); + + + if(($maxwidth > 1200) || ($maxwidth < 1)) + $maxwidth = 1200; + + if($maxwidth <= 425) { + $width = 425; + $size = 'hz_small'; + $cover_size = PHOTO_RES_COVER_425; + $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); + } + elseif($maxwidth <= 900) { + $width = 900; + $size = 'hz_medium'; + $cover_size = PHOTO_RES_COVER_850; + $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); + } + elseif($maxwidth <= 1200) { + $width = 1200; + $size = 'hz_large'; + $cover_size = PHOTO_RES_COVER_1200; + $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); + } + + $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname(); + $zcard = array('chan' => $channel); + + $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", + intval($channel['channel_id']), + intval($cover_size), + intval(PHOTO_COVER) + ); + + if($r) { + $cover = $r[0]; + $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale']; + } + else { + $cover = $pphoto; + } + + $o .= replace_macros(get_markup_template('zcard_embed.tpl'),array( + '$maxwidth' => $maxwidth, + '$scale' => $scale, + '$translate' => $translate, + '$size' => $size, + '$cover' => $cover, + '$pphoto' => $pphoto, + '$zcard' => $zcard + )); + + return $o; + +} diff --git a/include/connections.php b/include/connections.php new file mode 100644 index 000000000..c55ffd817 --- /dev/null +++ b/include/connections.php @@ -0,0 +1,636 @@ + $xchan['xchan_name'], + '$photo' => ((is_array(App::$profile) && array_key_exists('photo',App::$profile)) ? App::$profile['photo'] : $xchan['xchan_photo_l']), + '$follow' => $xchan['xchan_addr'], + '$link' => zid($xchan['xchan_url']), + '$connect' => $connect, + '$newwin' => (($mode === 'chanview') ? t('New window') : ''), + '$newtit' => t('Open the selected location in a different window or browser tab'), + '$url' => $url, + )); +} + +function abook_toggle_flag($abook,$flag) { + + $field = ''; + + switch($flag) { + case ABOOK_FLAG_BLOCKED: + $field = 'abook_blocked'; + break; + case ABOOK_FLAG_IGNORED: + $field = 'abook_ignored'; + break; + case ABOOK_FLAG_HIDDEN: + $field = 'abook_hidden'; + break; + case ABOOK_FLAG_ARCHIVED: + $field = 'abook_archived'; + break; + case ABOOK_FLAG_PENDING: + $field = 'abook_pending'; + break; + case ABOOK_FLAG_UNCONNECTED: + $field = 'abook_unconnected'; + break; + case ABOOK_FLAG_SELF: + $field = 'abook_self'; + break; + case ABOOK_FLAG_FEED: + $field = 'abook_feed'; + break; + default: + break; + } + if(! $field) + return; + + $r = q("UPDATE abook set $field = (1 - $field) where abook_id = %d and abook_channel = %d", + intval($abook['abook_id']), + intval($abook['abook_channel']) + ); + + + // if unsetting the archive bit, update the timestamps so we'll try to connect for an additional 30 days. + + if(($flag === ABOOK_FLAG_ARCHIVED) && (intval($abook['abook_archived']))) { + $r = q("update abook set abook_connected = '%s', abook_updated = '%s' + where abook_id = %d and abook_channel = %d", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($abook['abook_id']), + intval($abook['abook_channel']) + ); + } + + return $r; + +} + + +// Included here for completeness, but this is a very dangerous operation. +// It is the caller's responsibility to confirm the requestor's intent and +// authorisation to do this. + +function user_remove($uid) { + +} + +function account_remove($account_id,$local = true,$unset_session=true) { + + logger('account_remove: ' . $account_id); + + if(! intval($account_id)) { + logger('account_remove: no account.'); + return false; + } + + // Don't let anybody nuke the only admin account. + + $r = q("select account_id from account where (account_roles & %d) > 0", + intval(ACCOUNT_ROLE_ADMIN) + ); + + if($r !== false && count($r) == 1 && $r[0]['account_id'] == $account_id) { + logger("Unable to remove the only remaining admin account"); + return false; + } + + $r = q("select * from account where account_id = %d limit 1", + intval($account_id) + ); + $account_email=$r[0]['account_email']; + + if(! $r) { + logger('account_remove: No account with id: ' . $account_id); + return false; + } + + $x = q("select channel_id from channel where channel_account_id = %d", + intval($account_id) + ); + if($x) { + foreach($x as $xx) { + channel_remove($xx['channel_id'],$local,false); + } + } + + $r = q("delete from account where account_id = %d", + intval($account_id) + ); + + + if ($unset_session) { + unset($_SESSION['authenticated']); + unset($_SESSION['uid']); + notice( sprintf(t("User '%s' deleted"),$account_email) . EOL); + goaway(z_root()); + } + return $r; + +} +// recursively delete a directory +function rrmdir($path) +{ + if (is_dir($path) === true) + { + $files = array_diff(scandir($path), array('.', '..')); + + foreach ($files as $file) + { + rrmdir(realpath($path) . '/' . $file); + } + + return rmdir($path); + } + + else if (is_file($path) === true) + { + return unlink($path); + } + + return false; +} + +function channel_remove($channel_id, $local = true, $unset_session=false) { + + if(! $channel_id) + return; + $a = get_app(); + logger('Removing channel: ' . $channel_id); + logger('channel_remove: local only: ' . intval($local)); + + $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id)); + if(! $r) { + logger('channel_remove: channel not found: ' . $channel_id); + return; + } + + $channel = $r[0]; + + call_hooks('channel_remove',$r[0]); + + if(! $local) { + + $r = q("update channel set channel_deleted = '%s', channel_removed = 1, channel_r_stream = 0, channel_r_profile = 0, + channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0, + channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0, + channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0, channel_a_republish = 0 + where channel_id = %d", + dbesc(datetime_convert()), + intval($channel_id) + ); + + logger('deleting hublocs',LOGGER_DEBUG); + + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", + dbesc($channel['channel_hash']) + ); + + + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", + dbesc($channel['channel_hash']) + ); + + Zotlabs\Daemon\Master::Summon(array('Notifier','purge_all',$channel_id)); + } + + q("DELETE FROM `groups` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `event` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `item` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `item_id` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `mail` WHERE `channel_id` = %d", intval($channel_id)); + q("DELETE FROM `notify` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `photo` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `attach` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `profile` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `spam` WHERE `uid` = %d", intval($channel_id)); + + // @FIXME At this stage we need to remove the file resources located under /store/$nickname + + + q("delete from abook where abook_xchan = '%s' and abook_self = 1 ", + dbesc($channel['channel_hash']) + ); + + $r = q("update channel set channel_deleted = '%s', channel_removed = 1 where channel_id = %d", + dbesc(datetime_convert()), + intval($channel_id) + ); + + // if this was the default channel, set another one as default + if(App::$account['account_default_channel'] == $channel_id) { + $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 limit 1", + intval(App::$account['account_id']), + intval(PAGE_REMOVED)); + if ($r) { + $rr = q("update account set account_default_channel = %d where account_id = %d", + intval($r[0]['channel_id']), + intval(App::$account['account_id'])); + logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']); + } + else { + $rr = q("update account set account_default_channel = 0 where account_id = %d", + intval(App::$account['account_id']) + ); + } + } + + logger('deleting hublocs',LOGGER_DEBUG); + + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", + dbesc($channel['channel_hash']), + dbesc(z_root()) + ); + + // Do we have any valid hublocs remaining? + + $hublocs = 0; + + $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", + dbesc($channel['channel_hash']) + ); + if($r) + $hublocs = count($r); + + if(! $hublocs) { + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s' ", + dbesc($channel['channel_hash']) + ); + } + + //remove from file system + $r = q("select channel_address from channel where channel_id = %d limit 1", + intval($channel_id) + ); + if($r) + $channel_address = $r[0]['channel_address'] ; + if ($channel_address !== '') { + $f = 'store/' . $channel_address.'/'; + logger ('delete '. $f); + if(is_dir($f)) + @rrmdir($f); + } + + Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id)); + + if($channel_id == local_channel() && $unset_session) { + App::$session->nuke(); + goaway(z_root()); + } + +} + +/** + * mark any hubs "offline" that haven't been heard from in more than 30 days + * Allow them to redeem themselves if they come back later. + * Then go through all those that are newly marked and see if any other hubs + * are attached to the controlling xchan that are still alive. + * If not, they're dead (although they could come back some day). + */ + + +function mark_orphan_hubsxchans() { + + $dirmode = intval(get_config('system','directory_mode')); + if($dirmode == DIRECTORY_MODE_NORMAL) + return; + + $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0 + and hubloc_network = 'zot' and hubloc_connected < %s - interval %s", + db_utcnow(), db_quoteinterval('36 day') + ); + +// $realm = get_directory_realm(); +// if($realm == DIRECTORY_REALM) { +// $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') order by rand()", +// dbesc($realm) +// ); +// } +// else { +// $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' order by rand()", +// dbesc($realm) +// ); +// } + + + $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0"); + + if($r) { + foreach($r as $rr) { + + // see if any other hublocs are still alive for this channel + + $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0", + dbesc($rr['hubloc_hash']) + ); + if($x) { + + // yes - if the xchan was marked as an orphan, undo it + + $y = q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'", + dbesc($rr['hubloc_hash']) + ); + + } + else { + + // nope - mark the xchan as an orphan + + $y = q("update xchan set xchan_orphan = 1 where xchan_hash = '%s'", + dbesc($rr['hubloc_hash']) + ); + } + + // mark that we've checked this entry so we don't need to do it again + + $y = q("update hubloc set hubloc_orphancheck = 1 where hubloc_id = %d", + dbesc($rr['hubloc_id']) + ); + } + } + +} + + + + +function remove_all_xchan_resources($xchan, $channel_id = 0) { + + if(intval($channel_id)) { + + + + } + else { + + $dirmode = intval(get_config('system','directory_mode')); + + + $r = q("delete from photo where xchan = '%s'", + dbesc($xchan) + ); + $r = q("select resource_id, resource_type, uid, id from item where ( author_xchan = '%s' or owner_xchan = '%s' ) ", + dbesc($xchan), + dbesc($xchan) + ); + if($r) { + foreach($r as $rr) { + drop_item($rr,false); + } + } + $r = q("delete from event where event_xchan = '%s'", + dbesc($xchan) + ); + $r = q("delete from group_member where xchan = '%s'", + dbesc($xchan) + ); + $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' )", + dbesc($xchan), + dbesc($xchan) + ); + $r = q("delete from xlink where ( xlink_xchan = '%s' or xlink_link = '%s' )", + dbesc($xchan), + dbesc($xchan) + ); + + $r = q("delete from abook where abook_xchan = '%s'", + dbesc($xchan) + ); + + + if($dirmode === false || $dirmode == DIRECTORY_MODE_NORMAL) { + + $r = q("delete from xchan where xchan_hash = '%s'", + dbesc($xchan) + ); + $r = q("delete from hubloc where hubloc_hash = '%s'", + dbesc($xchan) + ); + + } + else { + + // directory servers need to keep the record around for sync purposes - mark it deleted + + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", + dbesc($xchan) + ); + + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", + dbesc($xchan) + ); + } + } +} + + +function contact_remove($channel_id, $abook_id) { + + if((! $channel_id) || (! $abook_id)) + return false; + + logger('removing contact ' . $abook_id . ' for channel ' . $channel_id,LOGGER_DEBUG); + + $archive = get_pconfig($channel_id, 'system','archive_removed_contacts'); + if($archive) { + q("update abook set abook_archived = 1 where abook_id = %d and abook_channel = %d", + intval($abook_id), + intval($channel_id) + ); + return true; + } + + $r = q("select * from abook where abook_id = %d and abook_channel = %d limit 1", + intval($abook_id), + intval($channel_id) + ); + + if(! $r) + return false; + + $abook = $r[0]; + + if(intval($abook['abook_self'])) + return false; + + + $r = q("select * from item where author_xchan = '%s' and uid = %d", + dbesc($abook['abook_xchan']), + intval($channel_id) + ); + if($r) { + foreach($r as $rr) { + drop_item($rr['id'],false); + } + } + + q("delete from abook where abook_id = %d and abook_channel = %d", + intval($abook['abook_id']), + intval($channel_id) + ); + + $r = q("delete from event where event_xchan = '%s' and uid = %d", + dbesc($abook['abook_xchan']), + intval($channel_id) + ); + + $r = q("delete from group_member where xchan = '%s' and uid = %d", + dbesc($abook['abook_xchan']), + intval($channel_id) + ); + + $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and channel_id = %d ", + dbesc($abook['abook_xchan']), + dbesc($abook['abook_xchan']), + intval($channel_id) + ); + + return true; +} + + + +function random_profile() { + $randfunc = db_getfunc('rand'); + + $checkrandom = get_config('randprofile','check'); // False by default + $retryrandom = intval(get_config('randprofile','retry')); + if($retryrandom == 0) $retryrandom = 5; + + for($i = 0; $i < $retryrandom; $i++) { + + $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1", + db_utcnow(), db_quoteinterval('30 day') + ); + + if(!$r) return ''; // Couldn't get a random channel + + if($checkrandom) { + $x = z_fetch_url($r[0]['xchan_url']); + if($x['success']) + return $r[0]['xchan_url']; + else + logger('Random channel turned out to be bad.'); + } + else { + return $r[0]['xchan_url']; + } + + } + return ''; +} + diff --git a/include/contact_widgets.php b/include/contact_widgets.php index e62d57aa2..14d26e257 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -3,9 +3,6 @@ function findpeople_widget() { - require_once('include/Contact.php'); - - $a = get_app(); if(get_config('system','invitation_only')) { $x = get_pconfig(local_channel(),'system','invites_remaining'); @@ -37,7 +34,6 @@ function findpeople_widget() { function fileas_widget($baseurl,$selected = '') { - $a = get_app(); if(! local_channel()) return ''; @@ -65,8 +61,6 @@ function fileas_widget($baseurl,$selected = '') { } function categories_widget($baseurl,$selected = '') { - - $a = get_app(); if(! feature_enabled(App::$profile['profile_uid'],'categories')) return ''; @@ -108,8 +102,6 @@ function categories_widget($baseurl,$selected = '') { function common_friends_visitor_widget($profile_uid) { - $a = get_app(); - if(local_channel() == $profile_uid) return; diff --git a/include/conversation.php b/include/conversation.php index fca07a91d..ca73a7a07 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1107,7 +1107,6 @@ function status_editor($a, $x, $popup = false) { $o = ''; - require_once('include/Contact.php'); $c = channelx_by_n($x['profile_uid']); if($c && $c['channel_moved']) return $o; @@ -1160,7 +1159,7 @@ function status_editor($a, $x, $popup = false) { $layoutselect = ''; if(array_key_exists('channel_select',$x) && $x['channel_select']) { - require_once('include/identity.php'); + require_once('include/channel.php'); $id_select = identity_selector(); } else diff --git a/include/feedutils.php b/include/feedutils.php index 700198ff8..f370c540a 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1087,7 +1087,6 @@ function update_feed_item($uid,$datarray) { function handle_feed($uid,$abook_id,$url) { - require_once('include/Contact.php'); $channel = channelx_by_n($uid); if(! $channel) return; diff --git a/include/identity.php b/include/identity.php deleted file mode 100644 index 4ef1105ea..000000000 --- a/include/identity.php +++ /dev/null @@ -1,1949 +0,0 @@ - false, 'message' => ''); - - $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0 ", - intval($account_id) - ); - if(! ($r && count($r))) { - $ret['total_identities'] = 0; - $ret['message'] = t('Unable to obtain identity information from database'); - return $ret; - } - - $ret['total_identities'] = intval($r[0]['total']); - - if (! account_service_class_allows($account_id, 'total_identities', $r[0]['total'])) { - $ret['message'] .= upgrade_message(); - return $ret; - } - - $ret['success'] = true; - - return $ret; -} - - -/** - * @brief Determine if the channel name is allowed when creating a new channel. - * - * This action is pluggable. - * We're currently only checking for an empty name or one that exceeds our - * storage limit (255 chars). 255 chars is probably going to create a mess on - * some pages. - * Plugins can set additional policies such as full name requirements, character - * sets, multi-byte length, etc. - * - * @param string $name - * - * @returns nil return if name is valid, or string describing the error state. - */ -function validate_channelname($name) { - - if (! $name) - return t('Empty name'); - - if (strlen($name) > 255) - return t('Name too long'); - - $arr = array('name' => $name); - call_hooks('validate_channelname', $arr); - - if (x($arr, 'message')) - return $arr['message']; -} - - -/** - * @brief Create a system channel - which has no account attached. - * - */ -function create_sys_channel() { - if (get_sys_channel()) - return; - - // Ensure that there is a host keypair. - - if ((! get_config('system', 'pubkey')) && (! get_config('system', 'prvkey'))) { - require_once('include/crypto.php'); - $hostkey = new_keypair(4096); - set_config('system', 'pubkey', $hostkey['pubkey']); - set_config('system', 'prvkey', $hostkey['prvkey']); - } - - create_identity(array( - 'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required - 'nickname' => 'sys', - 'name' => 'System', - 'pageflags' => 0, - 'publish' => 0, - 'system' => 1 - )); -} - - -/** - * @brief Returns the sys channel. - * - * @return array|boolean - */ -function get_sys_channel() { - $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_system = 1 limit 1"); - - if ($r) - return $r[0]; - - return false; -} - - -/** - * @brief Checks if $channel_id is sys channel. - * - * @param int $channel_id - * @return boolean - */ -function is_sys_channel($channel_id) { - $r = q("select channel_system from channel where channel_id = %d and channel_system = 1 limit 1", - intval($channel_id) - ); - - if($r) - return true; - - return false; -} - - -/** - * @brief Return the total number of channels on this site. - * - * No filtering is performed except to check PAGE_REMOVED. - * - * @returns int|booleean - * on error returns boolean false - */ -function channel_total() { - $r = q("select channel_id from channel where channel_removed = 0"); - - if (is_array($r)) - return count($r); - - return false; -} - - -/** - * @brief Create a new channel. - * - * Also creates the related xchan, hubloc, profile, and "self" abook records, - * and an empty "Friends" group/collection for the new channel. - * - * @param array $arr assoziative array with: - * * \e string \b name full name of channel - * * \e string \b nickname "email/url-compliant" nickname - * * \e int \b account_id to attach with this channel - * * [other identity fields as desired] - * - * @returns array - * 'success' => boolean true or false - * 'message' => optional error text if success is false - * 'channel' => if successful the created channel array - */ -function create_identity($arr) { - - $ret = array('success' => false); - - if(! $arr['account_id']) { - $ret['message'] = t('No account identifier'); - return $ret; - } - $ret = identity_check_service_class($arr['account_id']); - if (!$ret['success']) { - return $ret; - } - // save this for auto_friending - $total_identities = $ret['total_identities']; - - $nick = mb_strtolower(trim($arr['nickname'])); - if(! $nick) { - $ret['message'] = t('Nickname is required.'); - return $ret; - } - - $name = escape_tags($arr['name']); - $pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL); - $system = ((x($arr,'system')) ? intval($arr['system']) : 0); - $name_error = validate_channelname($arr['name']); - if($name_error) { - $ret['message'] = $name_error; - return $ret; - } - - if($nick === 'sys' && (! $system)) { - $ret['message'] = t('Reserved nickname. Please choose another.'); - return $ret; - } - - if(check_webbie(array($nick)) !== $nick) { - $ret['message'] = t('Nickname has unsupported characters or is already being used on this site.'); - return $ret; - } - - $guid = zot_new_uid($nick); - $key = new_keypair(4096); - - $sig = base64url_encode(rsa_sign($guid,$key['prvkey'])); - $hash = make_xchan_hash($guid,$sig); - - // Force a few things on the short term until we can provide a theme or app with choice - - $publish = 1; - - if(array_key_exists('publish', $arr)) - $publish = intval($arr['publish']); - - $primary = true; - - if(array_key_exists('primary', $arr)) - $primary = intval($arr['primary']); - - $role_permissions = null; - $global_perms = get_perms(); - - if(array_key_exists('permissions_role',$arr) && $arr['permissions_role']) { - $role_permissions = get_role_perms($arr['permissions_role']); - - if($role_permissions) { - foreach($role_permissions as $p => $v) { - if(strpos($p,'channel_') !== false) { - $perms_keys .= ', ' . $p; - $perms_vals .= ', ' . intval($v); - } - if($p === 'directory_publish') - $publish = intval($v); - } - } - } - else { - $defperms = site_default_perms(); - foreach($defperms as $p => $v) { - $perms_keys .= ', ' . $global_perms[$p][0]; - $perms_vals .= ', ' . intval($v); - } - } - - $expire = 0; - - $r = q("insert into channel ( channel_account_id, channel_primary, - channel_name, channel_address, channel_guid, channel_guid_sig, - channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_system, channel_expire_days, channel_timezone $perms_keys ) - values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' $perms_vals ) ", - - intval($arr['account_id']), - intval($primary), - dbesc($name), - dbesc($nick), - dbesc($guid), - dbesc($sig), - dbesc($hash), - dbesc($key['prvkey']), - dbesc($key['pubkey']), - intval($pageflags), - intval($system), - intval($expire), - dbesc(App::$timezone) - ); - - $r = q("select * from channel where channel_account_id = %d - and channel_guid = '%s' limit 1", - intval($arr['account_id']), - dbesc($guid) - ); - - if(! $r) { - $ret['message'] = t('Unable to retrieve created identity'); - return $ret; - } - - $ret['channel'] = $r[0]; - - if(intval($arr['account_id'])) - set_default_login_identity($arr['account_id'],$ret['channel']['channel_id'],false); - - // Create a verified hub location pointing to this site. - - $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary, - hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_network ) - values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )", - dbesc($guid), - dbesc($sig), - dbesc($hash), - dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()), - intval($primary), - dbesc(z_root()), - dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))), - dbesc(App::get_hostname()), - dbesc(z_root() . '/post'), - dbesc(get_config('system','pubkey')), - dbesc('zot') - ); - if(! $r) - logger('create_identity: Unable to store hub location'); - - $newuid = $ret['channel']['channel_id']; - - $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_system ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", - dbesc($hash), - dbesc($guid), - dbesc($sig), - dbesc($key['pubkey']), - dbesc(z_root() . "/photo/profile/l/{$newuid}"), - dbesc(z_root() . "/photo/profile/m/{$newuid}"), - dbesc(z_root() . "/photo/profile/s/{$newuid}"), - dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()), - dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']), - dbesc(z_root() . '/follow?f=&url=%s'), - dbesc(z_root() . '/poco/' . $ret['channel']['channel_address']), - dbesc($ret['channel']['channel_name']), - dbesc('zot'), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($system) - ); - - // Not checking return value. - // It's ok for this to fail if it's an imported channel, and therefore the hash is a duplicate - - $r = q("INSERT INTO profile ( aid, uid, profile_guid, profile_name, is_default, publish, name, photo, thumb) - VALUES ( %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s') ", - intval($ret['channel']['channel_account_id']), - intval($newuid), - dbesc(random_string()), - t('Default Profile'), - 1, - $publish, - dbesc($ret['channel']['channel_name']), - dbesc(z_root() . "/photo/profile/l/{$newuid}"), - dbesc(z_root() . "/photo/profile/m/{$newuid}") - ); - - if($role_permissions) { - $myperms = ((array_key_exists('perms_accept',$role_permissions)) ? intval($role_permissions['perms_accept']) : 0); - } - else - $myperms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK - |PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT - |PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE; - - $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_self, abook_my_perms ) - values ( %d, %d, '%s', %d, '%s', '%s', %d, %d ) ", - intval($ret['channel']['channel_account_id']), - intval($newuid), - dbesc($hash), - intval(0), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval(1), - intval($myperms) - ); - - if(intval($ret['channel']['channel_account_id'])) { - - // Save our permissions role so we can perhaps call it up and modify it later. - - if($role_permissions) { - set_pconfig($newuid,'system','permissions_role',$arr['permissions_role']); - if(array_key_exists('online',$role_permissions)) - set_pconfig($newuid,'system','hide_presence',1-intval($role_permissions['online'])); - if(array_key_exists('perms_auto',$role_permissions)) - set_pconfig($newuid,'system','autoperms',(($role_permissions['perms_auto']) ? $role_permissions['perms_accept'] : 0)); - } - - // Create a group with yourself as a member. This allows somebody to use it - // right away as a default group for new contacts. - - require_once('include/group.php'); - group_add($newuid, t('Friends')); - group_add_member($newuid,t('Friends'),$ret['channel']['channel_hash']); - - // if our role_permissions indicate that we're using a default collection ACL, add it. - - if(is_array($role_permissions) && $role_permissions['default_collection']) { - $r = q("select hash from groups where uid = %d and name = '%s' limit 1", - intval($newuid), - dbesc( t('Friends') ) - ); - if($r) { - q("update channel set channel_default_group = '%s', channel_allow_gid = '%s' where channel_id = %d", - dbesc($r[0]['hash']), - dbesc('<' . $r[0]['hash'] . '>'), - intval($newuid) - ); - } - } - - if(! $system) { - set_pconfig($ret['channel']['channel_id'],'system','photo_path', '%Y-%m'); - set_pconfig($ret['channel']['channel_id'],'system','attach_path','%Y-%m'); - } - - // UNO: channel defaults, incl addons (addons specific pconfig will only work after the relevant addon is enabled by the admin). It's located here, so members can modify these defaults after the channel is created. - if(UNO) { - //diaspora protocol addon - set_pconfig($ret['channel']['channel_id'],'system','diaspora_allowed', '1'); - set_pconfig($ret['channel']['channel_id'],'system','diaspora_public_comments', '1'); - set_pconfig($ret['channel']['channel_id'],'system','prevent_tag_hijacking', '0'); - } - - // auto-follow any of the hub's pre-configured channel choices. - // Only do this if it's the first channel for this account; - // otherwise it could get annoying. Don't make this list too big - // or it will impact registration time. - - $accts = get_config('system','auto_follow'); - if(($accts) && (! $total_identities)) { - require_once('include/follow.php'); - if(! is_array($accts)) - $accts = array($accts); - foreach($accts as $acct) { - if(trim($acct)) - new_contact($newuid,trim($acct),$ret['channel'],false); - } - } - - call_hooks('create_identity', $newuid); - - Zotlabs\Daemon\Master::Summon(array('Directory', $ret['channel']['channel_id'])); - } - - $ret['success'] = true; - return $ret; -} - -/** - * @brief Set default channel to be used on login. - * - * @param int $account_id - * login account - * @param int $channel_id - * channel id to set as default for this account - * @param boolean $force - * if true, set this default unconditionally - * if $force is false only do this if there is no existing default - */ -function set_default_login_identity($account_id, $channel_id, $force = true) { - $r = q("select account_default_channel from account where account_id = %d limit 1", - intval($account_id) - ); - if ($r) { - if ((intval($r[0]['account_default_channel']) == 0) || ($force)) { - $r = q("update account set account_default_channel = %d where account_id = %d", - intval($channel_id), - intval($account_id) - ); - } - } -} - -/** - * @brief Create an array representing the important channel information - * which would be necessary to create a nomadic identity clone. This includes - * most channel resources and connection information with the exception of content. - * - * @param int $channel_id - * Channel_id to export - * @param boolean $items - * Include channel posts (wall items), default false - * - * @returns array - * See function for details - */ -function identity_basic_export($channel_id, $items = false) { - - /* - * Red basic channel export - */ - - $ret = array(); - - // use constants here as otherwise we will have no idea if we can import from a site - // with a non-standard platform and version. - $ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => STD_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => Zotlabs\Lib\System::get_server_role()); - - $r = q("select * from channel where channel_id = %d limit 1", - intval($channel_id) - ); - if($r) - $ret['channel'] = $r[0]; - - $r = q("select * from profile where uid = %d", - intval($channel_id) - ); - if($r) - $ret['profile'] = $r; - - $xchans = array(); - $r = q("select * from abook where abook_channel = %d ", - intval($channel_id) - ); - if($r) { - $ret['abook'] = $r; - - for($x = 0; $x < count($ret['abook']); $x ++) { - $xchans[] = $ret['abook'][$x]['abook_chan']; - $abconfig = load_abconfig($ret['channel']['channel_hash'],$ret['abook'][$x]['abook_xchan']); - if($abconfig) - $ret['abook'][$x]['abconfig'] = $abconfig; - } - stringify_array_elms($xchans); - } - - if($xchans) { - $r = q("select * from xchan where xchan_hash in ( " . implode(',',$xchans) . " ) "); - if($r) - $ret['xchan'] = $r; - - $r = q("select * from hubloc where hubloc_hash in ( " . implode(',',$xchans) . " ) "); - if($r) - $ret['hubloc'] = $r; - } - - $r = q("select * from `groups` where uid = %d ", - intval($channel_id) - ); - - if($r) - $ret['group'] = $r; - - $r = q("select * from group_member where uid = %d ", - intval($channel_id) - ); - if($r) - $ret['group_member'] = $r; - - $r = q("select * from pconfig where uid = %d", - intval($channel_id) - ); - if($r) - $ret['config'] = $r; - - $r = q("select type, data, os_storage from photo where scale = 4 and photo_usage = %d and uid = %d limit 1", - intval(PHOTO_PROFILE), - intval($channel_id) - ); - - if($r) { - $ret['photo'] = array('type' => $r[0]['type'], 'data' => (($r[0]['os_storage']) ? base64url_encode(file_get_contents($r[0]['data'])) : base64url_encode($r[0]['data']))); - } - - // All other term types will be included in items, if requested. - - $r = q("select * from term where type in (%d,%d) and uid = %d", - intval(TERM_SAVEDSEARCH), - intval(TERM_THING), - intval($channel_id) - ); - if($r) - $ret['term'] = $r; - - - // add psuedo-column obj_baseurl to aid in relocations - - $r = q("select obj.*, '%s' as obj_baseurl from obj where obj_channel = %d", - dbesc(z_root()), - intval($channel_id) - ); - - if($r) - $ret['obj'] = $r; - - $r = q("select * from app where app_channel = %d and app_system = 0", - intval($channel_id) - ); - if($r) { - for($x = 0; $x < count($r); $x ++) { - $r[$x]['term'] = q("select * from term where otype = %d and oid = %d", - intval(TERM_OBJ_APP), - intval($r[$x]['id']) - ); - } - $ret['app'] = $r; - } - - $r = q("select * from chatroom where cr_uid = %d", - intval($channel_id) - ); - if($r) - $ret['chatroom'] = $r; - - - $r = q("select * from event where uid = %d", - intval($channel_id) - ); - if($r) - $ret['event'] = $r; - - $r = q("select * from item where resource_type = 'event' and uid = %d", - intval($channel_id) - ); - if($r) { - $ret['event_item'] = array(); - xchan_query($r); - $r = fetch_post_tags($r,true); - foreach($r as $rr) - $ret['event_item'][] = encode_item($rr,true); - } - - $x = menu_list($channel_id); - if($x) { - $ret['menu'] = array(); - for($y = 0; $y < count($x); $y ++) { - $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); - if($m) - $ret['menu'][] = menu_element($m); - } - } - - $x = menu_list($channel_id); - if($x) { - $ret['menu'] = array(); - for($y = 0; $y < count($x); $y ++) { - $m = menu_fetch($x[$y]['menu_name'],$channel_id,$ret['channel']['channel_hash']); - if($m) - $ret['menu'][] = menu_element($m); - } - } - - $addon = array('channel_id' => $channel_id,'data' => $ret); - call_hooks('identity_basic_export',$addon); - $ret = $addon['data']; - - - if(! $items) - return $ret; - - $r = q("select * from likes where channel_id = %d", - intval($channel_id) - ); - - if($r) - $ret['likes'] = $r; - - - $r = q("select * from conv where uid = %d", - intval($channel_id) - ); - if($r) { - for($x = 0; $x < count($r); $x ++) { - $r[$x]['subject'] = base64url_decode(str_rot47($r[$x]['subject'])); - } - $ret['conv'] = $r; - } - - - $r = q("select * from mail where mail.uid = %d", - intval($channel_id) - ); - if($r) { - $m = array(); - foreach($r as $rr) { - xchan_mail_query($rr); - $m[] = mail_encode($rr,true); - } - $ret['mail'] = $m; - } - - $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d", - intval($channel_id) - ); - - if($r) - $ret['item_id'] = $r; - - //$key = get_config('system','prvkey'); - - /** @warning this may run into memory limits on smaller systems */ - - - /** export three months of posts. If you want to export and import all posts you have to start with - * the first year and export/import them in ascending order. - * - * Don't export linked resource items. we'll have to pull those out separately. - */ - - $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d and created > %s - INTERVAL %s and resource_type = '' order by created", - intval($channel_id), - db_utcnow(), - db_quoteinterval('3 MONTH') - ); - if($r) { - $ret['item'] = array(); - xchan_query($r); - $r = fetch_post_tags($r,true); - foreach($r as $rr) - $ret['item'][] = encode_item($rr,true); - } - - return $ret; -} - - -function identity_export_year($channel_id,$year,$month = 0) { - - if(! $year) - return array(); - - if($month && $month <= 12) { - $target_month = sprintf('%02d',$month); - $target_month_plus = sprintf('%02d',$month+1); - } - else - $target_month = '01'; - - $ret = array(); - - $mindate = datetime_convert('UTC','UTC',$year . '-' . $target_month . '-01 00:00:00'); - if($month && $month < 12) - $maxdate = datetime_convert('UTC','UTC',$year . '-' . $target_month_plus . '-01 00:00:00'); - else - $maxdate = datetime_convert('UTC','UTC',$year+1 . '-01-01 00:00:00'); - - $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created", - intval(ITEM_TYPE_POST), - intval($channel_id), - dbesc($mindate), - dbesc($maxdate) - ); - - if($r) { - $ret['item'] = array(); - xchan_query($r); - $r = fetch_post_tags($r,true); - foreach($r as $rr) - $ret['item'][] = encode_item($rr,true); - } - - $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d - and item.created >= '%s' and item.created < '%s' order by created ", - intval($channel_id), - dbesc($mindate), - dbesc($maxdate) - ); - - if($r) - $ret['item_id'] = $r; - - - return $ret; -} - - -/** - * @brief Loads a profile into the App structure. - * - * The function requires a writeable copy of the main App structure, and the - * nickname of a valid channel. - * - * Permissions of the current observer are checked. If a restricted profile is available - * to the current observer, that will be loaded instead of the channel default profile. - * - * The channel owner can set $profile to a valid profile_guid to preview that profile. - * - * The channel default theme is also selected for use, unless over-riden elsewhere. - * - * @param[in,out] App &$a - * @param string $nickname - * @param string $profile - */ -function profile_load(&$a, $nickname, $profile = '') { - -// logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : '')); - - $user = q("select channel_id from channel where channel_address = '%s' and channel_removed = 0 limit 1", - dbesc($nickname) - ); - - if(! $user) { - logger('profile error: ' . App::$query_string, LOGGER_DEBUG); - notice( t('Requested channel is not available.') . EOL ); - App::$error = 404; - return; - } - - // get the current observer - $observer = App::get_observer(); - - $can_view_profile = true; - - // Can the observer see our profile? - require_once('include/permissions.php'); - if(! perm_is_allowed($user[0]['channel_id'],$observer['xchan_hash'],'view_profile')) { - $can_view_profile = false; - } - - if(! $profile) { - $r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' and abook_channel = '%d' limit 1", - dbesc($observer['xchan_hash']), - intval($user[0]['channel_id']) - ); - if($r) - $profile = $r[0]['abook_profile']; - } - $p = null; - - if($profile) { - $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile - LEFT JOIN channel ON profile.uid = channel.channel_id - WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1", - dbesc($nickname), - dbesc($profile) - ); - } - - if(! $p) { - $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile - LEFT JOIN channel ON profile.uid = channel.channel_id - WHERE channel.channel_address = '%s' and channel_removed = 0 - AND profile.is_default = 1 LIMIT 1", - dbesc($nickname) - ); - } - - if(! $p) { - logger('profile error: ' . App::$query_string, LOGGER_DEBUG); - notice( t('Requested profile is not available.') . EOL ); - App::$error = 404; - return; - } - - $q = q("select * from profext where hash = '%s' and channel_id = %d", - dbesc($p[0]['profile_guid']), - intval($p[0]['profile_uid']) - ); - if($q) { - - $extra_fields = array(); - - require_once('include/identity.php'); - $profile_fields_basic = get_profile_fields_basic(); - $profile_fields_advanced = get_profile_fields_advanced(); - - $advanced = ((feature_enabled(local_channel(),'advanced_profiles')) ? true : false); - if($advanced) - $fields = $profile_fields_advanced; - else - $fields = $profile_fields_basic; - - foreach($q as $qq) { - foreach($fields as $k => $f) { - if($k == $qq['k']) { - $p[0][$k] = $qq['v']; - $extra_fields[] = $k; - break; - } - } - } - } - - $p[0]['extra_fields'] = $extra_fields; - - $z = q("select xchan_photo_date, xchan_addr from xchan where xchan_hash = '%s' limit 1", - dbesc($p[0]['channel_hash']) - ); - if($z) { - $p[0]['picdate'] = $z[0]['xchan_photo_date']; - $p[0]['reddress'] = str_replace('@','@',$z[0]['xchan_addr']); - } - - // fetch user tags if this isn't the default profile - - if(! $p[0]['is_default']) { - $x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1", - intval($p[0]['profile_uid']) - ); - if($x && $can_view_profile) - $p[0]['keywords'] = $x[0]['keywords']; - } - - if($p[0]['keywords']) { - $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$p[0]['keywords']); - if(strlen($keywords) && $can_view_profile) - App::$page['htmlhead'] .= '' . "\r\n" ; - } - - App::$profile = $p[0]; - App::$profile_uid = $p[0]['profile_uid']; - App::$page['title'] = App::$profile['channel_name'] . " - " . App::$profile['channel_address'] . "@" . App::get_hostname(); - - App::$profile['permission_to_view'] = $can_view_profile; - - if($can_view_profile) { - $online = get_online_status($nickname); - App::$profile['online_status'] = $online['result']; - } - - if(local_channel()) { - App::$profile['channel_mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme'); - $_SESSION['mobile_theme'] = App::$profile['channel_mobile_theme']; - } - - /* - * load/reload current theme info - */ - - $_SESSION['theme'] = $p[0]['channel_theme']; - -} - -function profile_edit_menu($uid) { - - $ret = array(); - - $is_owner = (($uid == local_channel()) ? true : false); - - // show edit profile to profile owner - if($is_owner) { - $ret['menu'] = array( - 'chg_photo' => t('Change profile photo'), - 'entries' => array(), - ); - - $multi_profiles = feature_enabled(local_channel(), 'multi_profiles'); - if($multi_profiles) { - $ret['multi'] = 1; - $ret['edit'] = array(z_root(). '/profiles', t('Edit Profiles'), '', t('Edit')); - $ret['menu']['cr_new'] = t('Create New Profile'); - } - else { - $ret['edit'] = array(z_root() . '/profiles/' . $uid, t('Edit Profile'), '', t('Edit')); - } - - $r = q("SELECT * FROM profile WHERE uid = %d", - local_channel() - ); - - if($r) { - foreach($r as $rr) { - if(!($multi_profiles || $rr['is_default'])) - continue; - $ret['menu']['entries'][] = array( - 'photo' => $rr['thumb'], - 'id' => $rr['id'], - 'alt' => t('Profile Image'), - 'profile_name' => $rr['profile_name'], - 'isdefault' => $rr['is_default'], - 'visible_to_everybody' => t('Visible to everybody'), - 'edit_visibility' => t('Edit visibility'), - ); - } - } - } - - return $ret; - -} - -/** - * @brief Formats a profile for display in the sidebar. - * - * It is very difficult to templatise the HTML completely - * because of all the conditional logic. - * - * @param array $profile - * @param int $block - * @param boolean $show_connect - * - * @return HTML string suitable for sidebar inclusion - * Exceptions: Returns empty string if passed $profile is wrong type or not populated - */ -function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false) { - - $observer = App::get_observer(); - - $o = ''; - $location = false; - $pdesc = true; - $reddress = true; - - if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) { - $block = true; - } - - if((! is_array($profile)) && (! count($profile))) - return $o; - - head_set_icon($profile['thumb']); - - if(is_sys_channel($profile['uid'])) - $show_connect = false; - - $profile['picdate'] = urlencode($profile['picdate']); - - call_hooks('profile_sidebar_enter', $profile); - - require_once('include/Contact.php'); - - if($show_connect) { - - // This will return an empty string if we're already connected. - - $connect_url = rconnect_url($profile['uid'],get_observer_hash()); - $connect = (($connect_url) ? t('Connect') : ''); - if($connect_url) - $connect_url = sprintf($connect_url,urlencode($profile['channel_address'] . '@' . App::get_hostname())); - - // premium channel - over-ride - - if($profile['channel_pageflags'] & PAGE_PREMIUM) - $connect_url = z_root() . '/connect/' . $profile['channel_address']; - } - - if((x($profile,'address') == 1) - || (x($profile,'locality') == 1) - || (x($profile,'region') == 1) - || (x($profile,'postal_code') == 1) - || (x($profile,'country_name') == 1)) - $location = t('Location:'); - - $profile['homepage'] = linkify($profile['homepage'],true); - - $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False); - $marital = ((x($profile,'marital') == 1) ? t('Status:') : False); - $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False); - $profile['online'] = (($profile['online_status'] === 'online') ? t('Online Now') : False); - -// logger('online: ' . $profile['online']); - - - if(($profile['hidewall'] && (! local_channel()) && (! remote_channel())) || $block ) { - $location = $reddress = $pdesc = $gender = $marital = $homepage = False; - } - - $firstname = ((strpos($profile['channel_name'],' ')) - ? trim(substr($profile['channel_name'],0,strpos($profile['channel_name'],' '))) : $profile['channel_name']); - $lastname = (($firstname === $profile['channel_name']) ? '' : trim(substr($profile['channel_name'],strlen($firstname)))); - - $diaspora = array( - 'podloc' => z_root(), - 'searchable' => (($block) ? 'false' : 'true'), - 'nickname' => $profile['channel_address'], - 'fullname' => $profile['channel_name'], - 'firstname' => $firstname, - 'lastname' => $lastname, - 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', - 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', - 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg', - ); - - $contact_block = contact_block(); - - $channel_menu = false; - $menu = get_pconfig($profile['uid'],'system','channel_menu'); - if($menu && ! $block) { - require_once('include/menu.php'); - $m = menu_fetch($menu,$profile['uid'],$observer['xchan_hash']); - if($m) - $channel_menu = menu_render($m); - } - $menublock = get_pconfig($profile['uid'],'system','channel_menublock'); - if ($menublock && (! $block)) { - $comanche = new Zotlabs\Render\Comanche(); - $channel_menu .= $comanche->block($menublock); - } - - if($zcard) - $tpl = get_markup_template('profile_vcard_short.tpl'); - else - $tpl = get_markup_template('profile_vcard.tpl'); - - require_once('include/widgets.php'); - - if(! feature_enabled($profile['uid'],'hide_rating')) - $z = widget_rating(array('target' => $profile['channel_hash'])); - - $o .= replace_macros($tpl, array( - '$zcard' => $zcard, - '$profile' => $profile, - '$connect' => $connect, - '$connect_url' => $connect_url, - '$location' => $location, - '$gender' => $gender, - '$pdesc' => $pdesc, - '$marital' => $marital, - '$homepage' => $homepage, - '$chanmenu' => $channel_menu, - '$diaspora' => $diaspora, - '$reddress' => $reddress, - '$rating' => $z, - '$contact_block' => $contact_block, - '$editmenu' => profile_edit_menu($profile['uid']) - )); - - $arr = array('profile' => &$profile, 'entry' => &$o); - - call_hooks('profile_sidebar', $arr); - - return $o; -} - - -/** - * @FIXME or remove - */ - function get_birthdays() { - - $o = ''; - - if(! local_channel()) - return $o; - - $bd_format = t('g A l F d') ; // 8 AM Friday January 18 - $bd_short = t('F d'); - - $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` - LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid` - WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s' - ORDER BY `start` ASC ", - intval(local_channel()), - dbesc(datetime_convert('UTC','UTC','now + 6 days')), - dbesc(datetime_convert('UTC','UTC','now')) - ); - - if($r && count($r)) { - $total = 0; - $now = strtotime('now'); - $cids = array(); - - $istoday = false; - foreach($r as $rr) { - if(strlen($rr['name'])) - $total ++; - if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) - $istoday = true; - } - $classtoday = $istoday ? ' birthday-today ' : ''; - if($total) { - foreach($r as &$rr) { - if(! strlen($rr['name'])) - continue; - - // avoid duplicates - - if(in_array($rr['cid'],$cids)) - continue; - $cids[] = $rr['cid']; - - $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); - $sparkle = ''; - $url = $rr['url']; - if($rr['network'] === NETWORK_DFRN) { - $sparkle = " sparkle"; - $url = z_root() . '/redir/' . $rr['cid']; - } - - $rr['link'] = $url; - $rr['title'] = $rr['name']; - $rr['date'] = day_translate(datetime_convert('UTC', App::$timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : ''); - $rr['startime'] = Null; - $rr['today'] = $today; - } - } - } - $tpl = get_markup_template("birthdays_reminder.tpl"); - return replace_macros($tpl, array( - '$baseurl' => z_root(), - '$classtoday' => $classtoday, - '$count' => $total, - '$event_reminders' => t('Birthday Reminders'), - '$event_title' => t('Birthdays this week:'), - '$events' => $r, - '$lbr' => '{', // raw brackets mess up if/endif macro processing - '$rbr' => '}' - )); - } - - -/** - * @FIXME - */ - function get_events() { - - require_once('include/bbcode.php'); - - if(! local_channel()) - return $o; - - $bd_format = t('g A l F d') ; // 8 AM Friday January 18 - $bd_short = t('F d'); - - $r = q("SELECT `event`.* FROM `event` - WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` > '%s' - ORDER BY `start` ASC ", - intval(local_channel()), - dbesc(datetime_convert('UTC','UTC','now + 6 days')), - dbesc(datetime_convert('UTC','UTC','now - 1 days')) - ); - - if($r && count($r)) { - $now = strtotime('now'); - $istoday = false; - foreach($r as $rr) { - if(strlen($rr['name'])) - $total ++; - - $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start'],'Y-m-d'); - if($strt === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) - $istoday = true; - } - $classtoday = (($istoday) ? 'event-today' : ''); - - foreach($r as &$rr) { - if($rr['adjust']) - $md = datetime_convert('UTC',App::$timezone,$rr['start'],'Y/m'); - else - $md = datetime_convert('UTC','UTC',$rr['start'],'Y/m'); - $md .= "/#link-".$rr['id']; - - $title = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... '; - if(! $title) - $title = t('[No description]'); - - $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start']); - $today = ((substr($strt,0,10) === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) ? true : false); - - $rr['link'] = $md; - $rr['title'] = $title; - $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? App::$timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); - $rr['startime'] = $strt; - $rr['today'] = $today; - } - } - - $tpl = get_markup_template("events_reminder.tpl"); - return replace_macros($tpl, array( - '$baseurl' => z_root(), - '$classtoday' => $classtoday, - '$count' => count($r), - '$event_reminders' => t('Event Reminders'), - '$event_title' => t('Events this week:'), - '$events' => $r, - )); - } - - -function advanced_profile(&$a) { - require_once('include/text.php'); - if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile')) - return ''; - - if(App::$profile['name']) { - - $profile_fields_basic = get_profile_fields_basic(); - $profile_fields_advanced = get_profile_fields_advanced(); - - $advanced = ((feature_enabled(App::$profile['profile_uid'],'advanced_profiles')) ? true : false); - if($advanced) - $fields = $profile_fields_advanced; - else - $fields = $profile_fields_basic; - - $clean_fields = array(); - if($fields) { - foreach($fields as $k => $v) { - $clean_fields[] = trim($k); - } - } - - - - $tpl = get_markup_template('profile_advanced.tpl'); - - $profile = array(); - - $profile['fullname'] = array( t('Full Name:'), App::$profile['name'] ) ; - - if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] ); - - $ob_hash = get_observer_hash(); - if($ob_hash && perm_is_allowed(App::$profile['profile_uid'],$ob_hash,'post_like')) { - $profile['canlike'] = true; - $profile['likethis'] = t('Like this channel'); - $profile['profile_guid'] = App::$profile['profile_guid']; - } - - $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'", - intval(App::$profile['profile_uid']), - dbesc(ACTIVITY_OBJ_PROFILE), - dbesc(ACTIVITY_LIKE) - ); - $profile['likers'] = array(); - $profile['like_count'] = count($likers); - $profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun'); - if($likers) { - foreach($likers as $l) - $profile['likers'][] = array('name' => $l['xchan_name'],'photo' => zid($l['xchan_photo_s']), 'url' => zid($l['xchan_url'])); - } - - if((App::$profile['dob']) && (App::$profile['dob'] != '0000-00-00')) { - - $val = ''; - - if((substr(App::$profile['dob'],5,2) === '00') || (substr(App::$profile['dob'],8,2) === '00')) - $val = substr(App::$profile['dob'],0,4); - - $year_bd_format = t('j F, Y'); - $short_bd_format = t('j F'); - - if(! $val) { - $val = ((intval(App::$profile['dob'])) - ? day_translate(datetime_convert('UTC','UTC',App::$profile['dob'] . ' 00:00 +00:00',$year_bd_format)) - : day_translate(datetime_convert('UTC','UTC','2001-' . substr(App::$profile['dob'],5) . ' 00:00 +00:00',$short_bd_format))); - } - $profile['birthday'] = array( t('Birthday:'), $val); - } - - if($age = age(App::$profile['dob'],App::$profile['timezone'],'')) - $profile['age'] = array( t('Age:'), $age ); - - if(App::$profile['marital']) - $profile['marital'] = array( t('Status:'), App::$profile['marital']); - - if(App::$profile['with']) - $profile['marital']['with'] = bbcode(App::$profile['with']); - - if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) { - $profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s')); - } - - if(App::$profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), App::$profile['sexual'] ); - - if(App::$profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify(App::$profile['homepage']) ); - - if(App::$profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify(App::$profile['hometown']) ); - - if(App::$profile['keywords']) $profile['keywords'] = array( t('Tags:'), App::$profile['keywords']); - - if(App::$profile['politic']) $profile['politic'] = array( t('Political Views:'), App::$profile['politic']); - - if(App::$profile['religion']) $profile['religion'] = array( t('Religion:'), App::$profile['religion']); - - if($txt = prepare_text(App::$profile['about'])) $profile['about'] = array( t('About:'), $txt ); - - if($txt = prepare_text(App::$profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt); - - if($txt = prepare_text(App::$profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt); - - if($txt = prepare_text(App::$profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt); - - if($txt = prepare_text(App::$profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); - - if($txt = prepare_text(App::$profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt); - - if($txt = prepare_text(App::$profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt); - - if($txt = prepare_text(App::$profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt); - - if($txt = prepare_text(App::$profile['tv'])) $profile['tv'] = array( t('Television:'), $txt); - - if($txt = prepare_text(App::$profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt); - - if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt); - - if($txt = prepare_text(App::$profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); - - if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); - - if(App::$profile['extra_fields']) { - foreach(App::$profile['extra_fields'] as $f) { - $x = q("select * from profdef where field_name = '%s' limit 1", - dbesc($f) - ); - if($x && $txt = prepare_text(App::$profile[$f])) - $profile[$f] = array( $x[0]['field_desc'] . ':',$txt); - } - $profile['extra_fields'] = App::$profile['extra_fields']; - } - - $things = get_things(App::$profile['profile_guid'],App::$profile['profile_uid']); - -// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA); - - return replace_macros($tpl, array( - '$title' => t('Profile'), - '$canlike' => (($profile['canlike'])? true : false), - '$likethis' => t('Like this thing'), - '$profile' => $profile, - '$fields' => $clean_fields, - '$editmenu' => profile_edit_menu(App::$profile['profile_uid']), - '$things' => $things - )); - } - - return ''; -} - - -function get_my_url() { - if(x($_SESSION, 'zrl_override')) - return $_SESSION['zrl_override']; - if(x($_SESSION, 'my_url')) - return $_SESSION['my_url']; - - return false; -} - -function get_my_address() { - if(x($_SESSION, 'zid_override')) - return $_SESSION['zid_override']; - if(x($_SESSION, 'my_address')) - return $_SESSION['my_address']; - - return false; -} - -/** - * @brief - * - * If somebody arrives at our site using a zid, add their xchan to our DB if we don't have it already. - * And if they aren't already authenticated here, attempt reverse magic auth. - * - * @param App &$a - * - * @hooks 'zid_init' - * string 'zid' - their zid - * string 'url' - the destination url - */ -function zid_init(&$a) { - $tmp_str = get_my_address(); - if(validate_email($tmp_str)) { - Zotlabs\Daemon\Master::Summon(array('Gprobe',bin2hex($tmp_str))); - $arr = array('zid' => $tmp_str, 'url' => App::$cmd); - call_hooks('zid_init',$arr); - if(! local_channel()) { - $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc limit 1", - dbesc($tmp_str) - ); - if($r && remote_channel() && remote_channel() === $r[0]['hubloc_hash']) - return; - logger('zid_init: not authenticated. Invoking reverse magic-auth for ' . $tmp_str); - // try to avoid recursion - but send them home to do a proper magic auth - $query = App::$query_string; - $query = str_replace(array('?zid=','&zid='),array('?rzid=','&rzid='),$query); - $dest = '/' . urlencode($query); - if($r && ($r[0]['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) { - goaway($r[0]['hubloc_url'] . '/magic' . '?f=&rev=1&dest=' . z_root() . $dest); - } - else - logger('zid_init: no hubloc found.'); - } - } -} - -/** - * @brief Adds a zid parameter to a url. - * - * @param string $s - * The url to accept the zid - * @param boolean $address - * $address to use instead of session environment - * @return string - * - * @hooks 'zid' - * string url - url to accept zid - * string zid - urlencoded zid - * string result - the return string we calculated, change it if you want to return something else - */ -function zid($s,$address = '') { - if (! strlen($s) || strpos($s,'zid=')) - return $s; - - $has_params = ((strpos($s,'?')) ? true : false); - $num_slashes = substr_count($s, '/'); - if (! $has_params) - $has_params = ((strpos($s, '&')) ? true : false); - - $achar = strpos($s,'?') ? '&' : '?'; - - $mine = get_my_url(); - $myaddr = (($address) ? $address : get_my_address()); - - /** @FIXME checking against our own channel url is no longer reliable. We may have a lot - * of urls attached to out channel. Should probably match against our site, since we - * will not need to remote authenticate on our own site anyway. - */ - - if ($mine && $myaddr && (! link_compare($mine,$s))) - $zurl = $s . (($num_slashes >= 3) ? '' : '/') . $achar . 'zid=' . urlencode($myaddr); - else - $zurl = $s; - - $arr = array('url' => $s, 'zid' => urlencode($myaddr), 'result' => $zurl); - call_hooks('zid', $arr); - - return $arr['result']; -} - -// Used from within PCSS themes to set theme parameters. If there's a -// puid request variable, that is the "page owner" and normally their theme -// settings take precedence; unless a local user sets the "always_my_theme" -// system pconfig, which means they don't want to see anybody else's theme -// settings except their own while on this site. - -function get_theme_uid() { - $uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0); - if(local_channel()) { - if((get_pconfig(local_channel(),'system','always_my_theme')) || (! $uid)) - return local_channel(); - } - if(! $uid) { - $x = get_sys_channel(); - if($x) - return $x['channel_id']; - } - - return $uid; -} - -/** -* @brief Retrieves the path of the default_profile_photo for this system -* with the specified size. -* -* @param int $size -* one of (300, 80, 48) -* @returns string -*/ -function get_default_profile_photo($size = 300) { - $scheme = get_config('system','default_profile_photo'); - if(! $scheme) - $scheme = 'rainbow_man'; - - return 'images/default_profile_photos/' . $scheme . '/' . $size . '.png'; -} - -/** - * @brief Test whether a given identity is NOT a member of the Hubzilla. - * - * @param string $s; - * xchan_hash of the identity in question - * @returns boolean true or false - */ -function is_foreigner($s) { - return((strpbrk($s, '.:@')) ? true : false); -} - -/** - * @brief Test whether a given identity is a member of the Hubzilla. - * - * @param string $s; - * xchan_hash of the identity in question - * @returns boolean true or false - */ -function is_member($s) { - return((is_foreigner($s)) ? false : true); -} - -function get_online_status($nick) { - - $ret = array('result' => false); - - if(get_config('system','block_public') && ! local_channel() && ! remote_channel()) - return $ret; - - $r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1", - dbesc(argv(1)) - ); - if($r) { - $hide = get_pconfig($r[0]['channel_id'],'system','hide_online_status'); - if($hide) - return $ret; - $x = q("select cp_status from chatpresence where cp_xchan = '%s' and cp_room = 0 limit 1", - dbesc($r[0]['channel_hash']) - ); - if($x) - $ret['result'] = $x[0]['cp_status']; - } - - return $ret; -} - - -function remote_online_status($webbie) { - - $result = false; - $r = q("select * from hubloc where hubloc_addr = '%s' limit 1", - dbesc($webbie) - ); - if(! $r) - return $result; - - $url = $r[0]['hubloc_url'] . '/online/' . substr($webbie,0,strpos($webbie,'@')); - - $x = z_fetch_url($url); - if($x['success']) { - $j = json_decode($x['body'],true); - if($j) - $result = (($j['result']) ? $j['result'] : false); - } - - return $result; -} - - -function get_channel_by_nick($nick) { - $r = q("select * from channel where channel_address = '%s' limit 1", - dbesc($nick) - ); - return(($r) ? $r[0] : false); - -} - -/** - * @brief - * - * @return string - */ -function identity_selector() { - if (local_channel()) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", - intval(get_account_id()) - ); - if (count($r) > 1) { - //$account = App::get_account(); - $o = replace_macros(get_markup_template('channel_id_select.tpl'), array( - '$channels' => $r, - '$selected' => local_channel() - )); - return $o; - } - } - - return ''; -} - - -function is_public_profile() { - if(! local_channel()) - return false; - if(intval(get_config('system','block_public'))) - return false; - $channel = App::get_channel(); - if($channel && $channel['channel_r_profile'] == PERMS_PUBLIC) - return true; - - return false; -} - -function get_profile_fields_basic($filter = 0) { - - $profile_fields_basic = (($filter == 0) ? get_config('system','profile_fields_basic') : null); - if(! $profile_fields_basic) - $profile_fields_basic = array('name','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact'); - - $x = array(); - if($profile_fields_basic) - foreach($profile_fields_basic as $f) - $x[$f] = 1; - - return $x; -} - - -function get_profile_fields_advanced($filter = 0) { - $basic = get_profile_fields_basic($filter); - $profile_fields_advanced = (($filter == 0) ? get_config('system','profile_fields_advanced') : null); - if(! $profile_fields_advanced) - $profile_fields_advanced = array('with','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education'); - - $x = array(); - if($basic) - foreach($basic as $f => $v) - $x[$f] = $v; - - if($profile_fields_advanced) - foreach($profile_fields_advanced as $f) - $x[$f] = 1; - - return $x; -} - -/** - * @brief Clear notifyflags for a channel. - * - * Most likely during bulk import of content or other activity that is likely - * to generate huge amounts of undesired notifications. - * - * @param int $channel_id - * The channel to disable notifications for - * @returns int - * Current notification flag value. Send this to notifications_on() to restore the channel settings when finished - * with the activity requiring notifications_off(); - */ -function notifications_off($channel_id) { - $r = q("select channel_notifyflags from channel where channel_id = %d limit 1", - intval($channel_id) - ); - q("update channel set channel_notifyflags = 0 where channel_id = %d", - intval($channel_id) - ); - - return intval($r[0]['channel_notifyflags']); -} - - -function notifications_on($channel_id,$value) { - $x = q("update channel set channel_notifyflags = %d where channel_id = %d", - intval($value), - intval($channel_id) - ); - return $x; -} - - -function get_channel_default_perms($uid) { - - $r = q("select abook_my_perms from abook where abook_channel = %d and abook_self = 1 limit 1", - intval($uid) - ); - if($r) - return $r[0]['abook_my_perms']; - - return 0; -} - - -function profiles_build_sync($channel_id) { - - $r = q("select * from profile where uid = %d", - intval($channel_id) - ); - if($r) { - build_sync_packet($channel_id,array('profile' => $r)); - } -} - - -function auto_channel_create($account_id) { - - if(! $account_id) - return false; - - $arr = array(); - $arr['account_id'] = $account_id; - $arr['name'] = get_aconfig($account_id,'register','channel_name'); - $arr['nickname'] = legal_webbie(get_aconfig($account_id,'register','channel_address')); - $arr['permissions_role'] = get_aconfig($account_id,'register','permissions_role'); - - del_aconfig($account_id,'register','channel_name'); - del_aconfig($account_id,'register','channel_address'); - del_aconfig($account_id,'register','permissions_role'); - - if((! $arr['name']) || (! $arr['nickname'])) { - $x = q("select * from account where account_id = %d limit 1", - intval($account_id) - ); - if($x) { - if(! $arr['name']) - $arr['name'] = substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@')); - if(! $arr['nickname']) - $arr['nickname'] = legal_webbie(substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@'))); - } - } - if(! $arr['permissions_role']) - $arr['permissions_role'] = 'social'; - - if(validate_channelname($arr['name'])) - return false; - if($arr['nickname'] === 'sys') - $arr['nickname'] = $arr['nickname'] . mt_rand(1000,9999); - - $arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999))); - - return create_identity($arr); - -} - -function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) { - - $r = q("select height, width, resource_id, type from photo where uid = %d and scale = %d and photo_usage = %d", - intval($channel_id), - intval($res), - intval(PHOTO_COVER) - ); - if(! $r) - return false; - - $output = false; - - $url = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $res ; - - switch($format) { - case 'bbcode': - $output = '[zrl=' . $r[0]['width'] . 'x' . $r[0]['height'] . ']' . $url . '[/zrl]'; - break; - case 'html': - $output = '' . t('cover photo') . ''; - break; - case 'array': - default: - $output = array( - 'width' => $r[0]['width'], - 'height' => $r[0]['type'], - 'type' => $r[0]['type'], - 'url' => $url - ); - break; - } - - return $output; - -} - -function get_zcard($channel,$observer_hash = '',$args = array()) { - - logger('get_zcard'); - - $maxwidth = (($args['width']) ? intval($args['width']) : 0); - $maxheight = (($args['height']) ? intval($args['height']) : 0); - - - if(($maxwidth > 1200) || ($maxwidth < 1)) - $maxwidth = 1200; - - if($maxwidth <= 425) { - $width = 425; - $size = 'hz_small'; - $cover_size = PHOTO_RES_COVER_425; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); - } - elseif($maxwidth <= 900) { - $width = 900; - $size = 'hz_medium'; - $cover_size = PHOTO_RES_COVER_850; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); - } - elseif($maxwidth <= 1200) { - $width = 1200; - $size = 'hz_large'; - $cover_size = PHOTO_RES_COVER_1200; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); - } - -// $scale = (float) $maxwidth / $width; -// $translate = intval(($scale / 1.0) * 100); - - - $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname(); - $zcard = array('chan' => $channel); - - $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", - intval($channel['channel_id']), - intval($cover_size), - intval(PHOTO_COVER) - ); - - if($r) { - $cover = $r[0]; - $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale']; - } - else { - $cover = $pphoto; - } - - $o .= replace_macros(get_markup_template('zcard.tpl'),array( - '$maxwidth' => $maxwidth, - '$scale' => $scale, - '$translate' => $translate, - '$size' => $size, - '$cover' => $cover, - '$pphoto' => $pphoto, - '$zcard' => $zcard - )); - - return $o; - -} - - -function get_zcard_embed($channel,$observer_hash = '',$args = array()) { - - logger('get_zcard_embed'); - - $maxwidth = (($args['width']) ? intval($args['width']) : 0); - $maxheight = (($args['height']) ? intval($args['height']) : 0); - - - if(($maxwidth > 1200) || ($maxwidth < 1)) - $maxwidth = 1200; - - if($maxwidth <= 425) { - $width = 425; - $size = 'hz_small'; - $cover_size = PHOTO_RES_COVER_425; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); - } - elseif($maxwidth <= 900) { - $width = 900; - $size = 'hz_medium'; - $cover_size = PHOTO_RES_COVER_850; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); - } - elseif($maxwidth <= 1200) { - $width = 1200; - $size = 'hz_large'; - $cover_size = PHOTO_RES_COVER_1200; - $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); - } - - $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname(); - $zcard = array('chan' => $channel); - - $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", - intval($channel['channel_id']), - intval($cover_size), - intval(PHOTO_COVER) - ); - - if($r) { - $cover = $r[0]; - $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale']; - } - else { - $cover = $pphoto; - } - - $o .= replace_macros(get_markup_template('zcard_embed.tpl'),array( - '$maxwidth' => $maxwidth, - '$scale' => $scale, - '$translate' => $translate, - '$size' => $size, - '$cover' => $cover, - '$pphoto' => $pphoto, - '$zcard' => $zcard - )); - - return $o; - -} diff --git a/include/items.php b/include/items.php index a25be72b3..de0941c3c 100755 --- a/include/items.php +++ b/include/items.php @@ -77,7 +77,7 @@ function collect_recipients($item, &$private_envelope) { // by the directives in $item['public_policy']. $private_envelope = false; - require_once('include/identity.php'); + require_once('include/channel.php'); //$sys = get_sys_channel(); if(array_key_exists('public_policy',$item) && $item['public_policy'] !== 'self') { diff --git a/include/text.php b/include/text.php index df6dac056..91aeae989 100644 --- a/include/text.php +++ b/include/text.php @@ -1319,7 +1319,7 @@ function theme_attachments(&$item) { $title = t('Size') . ' ' . (($r['length']) ? userReadableSize($r['length']) : t('unknown')); - require_once('include/identity.php'); + require_once('include/channel.php'); if(is_foreigner($item['author_xchan'])) $url = $r['href']; else @@ -1486,7 +1486,7 @@ function format_event($jobject) { } function prepare_body(&$item,$attach = false) { - require_once('include/identity.php'); + require_once('include/channel.php'); call_hooks('prepare_body_init', $item); @@ -2261,7 +2261,7 @@ function design_tools() { $sys = false; if(App::$is_sys && is_site_admin()) { - require_once('include/identity.php'); + require_once('include/channel.php'); $channel = get_sys_channel(); $sys = true; } diff --git a/include/widgets.php b/include/widgets.php index 2641a718e..a158633ad 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -8,7 +8,7 @@ require_once('include/dir_fns.php'); require_once('include/contact_widgets.php'); require_once('include/attach.php'); -require_once('include/Contact.php'); + function widget_profile($args) { @@ -806,7 +806,6 @@ function widget_photo_albums($arr) { function widget_vcard($arr) { - require_once ('include/Contact.php'); return vcard_from_xchan('', App::get_observer()); } @@ -1052,7 +1051,7 @@ function widget_photo($arr) { function widget_cover_photo($arr) { - require_once('include/identity.php'); + require_once('include/channel.php'); $o = ''; if(App::$module == 'channel' && $_REQUEST['mid']) diff --git a/include/zot.php b/include/zot.php index f5fb87e12..4b780db2a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1332,7 +1332,7 @@ function zot_import($arr, $sender_url) { */ function public_recips($msg) { - require_once('include/identity.php'); + require_once('include/channel.php'); $check_mentions = false; $include_sys = false; @@ -3222,7 +3222,6 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $clean = array(); if($abook['abook_xchan'] && $abook['entry_deleted']) { logger('process_channel_sync_delivery: removing abook entry for ' . $abook['abook_xchan']); - require_once('include/Contact.php'); $r = q("select abook_id, abook_feed from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1", dbesc($abook['abook_xchan']), @@ -3926,7 +3925,7 @@ function zotinfo($arr) { $ret['site']['accounts'] = account_total(); - require_once('include/identity.php'); + require_once('include/channel.php'); $ret['site']['channels'] = channel_total(); @@ -4421,7 +4420,6 @@ function zot_reply_purge($sender,$recipients) { $arr = $sender; $sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); - require_once('include/Contact.php'); remove_all_xchan_resources($sender_hash); $ret['success'] = true; diff --git a/util/hmessages.po b/util/hmessages.po index abc4d1a9f..c863c6a67 100644 --- a/util/hmessages.po +++ b/util/hmessages.po @@ -111,8 +111,8 @@ msgstr "" #: ../../Zotlabs/Module/Editwebpage.php:146 #: ../../Zotlabs/Module/Layouts.php:190 ../../Zotlabs/Module/Menu.php:112 #: ../../Zotlabs/Module/Settings.php:652 ../../Zotlabs/Module/Thing.php:260 -#: ../../Zotlabs/Module/Webpages.php:187 ../../include/identity.php:937 -#: ../../include/identity.php:941 ../../include/ItemObject.php:100 +#: ../../Zotlabs/Module/Webpages.php:187 ../../include/channel.php:937 +#: ../../include/channel.php:941 ../../include/ItemObject.php:100 #: ../../include/menu.php:108 ../../include/page_widgets.php:8 #: ../../include/page_widgets.php:36 ../../include/apps.php:291 msgid "Edit" @@ -247,7 +247,7 @@ msgstr "" #: ../../Zotlabs/Module/Editwebpage.php:33 #: ../../Zotlabs/Module/Filestorage.php:60 ../../Zotlabs/Module/Hcard.php:12 #: ../../Zotlabs/Module/Layouts.php:31 ../../Zotlabs/Module/Profile.php:20 -#: ../../Zotlabs/Module/Webpages.php:34 ../../include/identity.php:837 +#: ../../Zotlabs/Module/Webpages.php:34 ../../include/channel.php:837 msgid "Requested profile is not available." msgstr "" @@ -2030,8 +2030,8 @@ msgstr "" #: ../../Zotlabs/Module/Settings.php:346 ../../Zotlabs/Module/Settings.php:347 #: ../../Zotlabs/Module/Settings.php:350 ../../Zotlabs/Module/Settings.php:361 #: ../../include/profile_selectors.php:80 ../../include/widgets.php:495 -#: ../../include/identity.php:389 ../../include/identity.php:390 -#: ../../include/identity.php:397 +#: ../../include/channel.php:389 ../../include/channel.php:390 +#: ../../include/channel.php:397 msgid "Friends" msgstr "" @@ -2236,7 +2236,7 @@ msgstr "" msgid "%1$s updated their %2$s" msgstr "" -#: ../../Zotlabs/Module/Cover_photo.php:240 ../../include/identity.php:1807 +#: ../../Zotlabs/Module/Cover_photo.php:240 ../../include/channel.php:1807 msgid "cover photo" msgstr "" @@ -2318,12 +2318,12 @@ msgstr "" msgid "Homepage: " msgstr "" -#: ../../Zotlabs/Module/Directory.php:306 ../../include/identity.php:1329 +#: ../../Zotlabs/Module/Directory.php:306 ../../include/channel.php:1329 msgid "Age:" msgstr "" #: ../../Zotlabs/Module/Directory.php:311 ../../include/event.php:52 -#: ../../include/identity.php:1029 ../../include/text.php:1481 +#: ../../include/channel.php:1029 ../../include/text.php:1481 #: ../../include/bb2diaspora.php:509 msgid "Location:" msgstr "" @@ -2332,18 +2332,18 @@ msgstr "" msgid "Description:" msgstr "" -#: ../../Zotlabs/Module/Directory.php:322 ../../include/identity.php:1345 +#: ../../Zotlabs/Module/Directory.php:322 ../../include/channel.php:1345 msgid "Hometown:" msgstr "" -#: ../../Zotlabs/Module/Directory.php:324 ../../include/identity.php:1353 +#: ../../Zotlabs/Module/Directory.php:324 ../../include/channel.php:1353 msgid "About:" msgstr "" #: ../../Zotlabs/Module/Directory.php:325 ../../Zotlabs/Module/Match.php:68 #: ../../Zotlabs/Module/Suggest.php:56 ../../include/Contact.php:101 #: ../../include/widgets.php:147 ../../include/widgets.php:184 -#: ../../include/identity.php:1014 ../../include/conversation.php:961 +#: ../../include/channel.php:1014 ../../include/conversation.php:961 msgid "Connect" msgstr "" @@ -4182,7 +4182,7 @@ msgstr "" msgid "View all" msgstr "" -#: ../../Zotlabs/Module/Photos.php:1130 ../../include/identity.php:1304 +#: ../../Zotlabs/Module/Photos.php:1130 ../../include/channel.php:1304 #: ../../include/ItemObject.php:179 ../../include/conversation.php:1748 #: ../../include/taxonomy.php:403 msgctxt "noun" @@ -4243,13 +4243,13 @@ msgstr "" msgid "added your channel" msgstr "" -#: ../../Zotlabs/Module/Ping.php:322 ../../include/identity.php:1123 -#: ../../include/identity.php:1199 +#: ../../Zotlabs/Module/Ping.php:322 ../../include/channel.php:1123 +#: ../../include/channel.php:1199 msgid "g A l F d" msgstr "" -#: ../../Zotlabs/Module/Ping.php:345 ../../include/identity.php:1169 -#: ../../include/identity.php:1239 +#: ../../Zotlabs/Module/Ping.php:345 ../../include/channel.php:1169 +#: ../../include/channel.php:1239 msgid "[today]" msgstr "" @@ -4387,7 +4387,7 @@ msgid "View this profile" msgstr "" #: ../../Zotlabs/Module/Profiles.php:693 ../../Zotlabs/Module/Profiles.php:775 -#: ../../include/identity.php:959 +#: ../../include/channel.php:959 msgid "Edit visibility" msgstr "" @@ -4399,7 +4399,7 @@ msgstr "" msgid "Change cover photo" msgstr "" -#: ../../Zotlabs/Module/Profiles.php:696 ../../include/identity.php:930 +#: ../../Zotlabs/Module/Profiles.php:696 ../../include/channel.php:930 msgid "Change profile photo" msgstr "" @@ -4560,11 +4560,11 @@ msgstr "" msgid "My other channels" msgstr "" -#: ../../Zotlabs/Module/Profiles.php:771 ../../include/identity.php:955 +#: ../../Zotlabs/Module/Profiles.php:771 ../../include/channel.php:955 msgid "Profile Image" msgstr "" -#: ../../Zotlabs/Module/Profiles.php:781 ../../include/identity.php:937 +#: ../../Zotlabs/Module/Profiles.php:781 ../../include/channel.php:937 #: ../../include/nav.php:88 msgid "Edit Profiles" msgstr "" @@ -4577,7 +4577,7 @@ msgstr "" msgid "Profile Visibility Editor" msgstr "" -#: ../../Zotlabs/Module/Profperm.php:117 ../../include/identity.php:1395 +#: ../../Zotlabs/Module/Profperm.php:117 ../../include/channel.php:1395 msgid "Profile" msgstr "" @@ -5190,7 +5190,7 @@ msgstr "" msgid "Basic Settings" msgstr "" -#: ../../Zotlabs/Module/Settings.php:1040 ../../include/identity.php:1286 +#: ../../Zotlabs/Module/Settings.php:1040 ../../include/channel.php:1286 msgid "Full Name:" msgstr "" @@ -6952,185 +6952,185 @@ msgstr "" msgid "Room is full" msgstr "" -#: ../../include/identity.php:32 +#: ../../include/channel.php:32 msgid "Unable to obtain identity information from database" msgstr "" -#: ../../include/identity.php:66 +#: ../../include/channel.php:66 msgid "Empty name" msgstr "" -#: ../../include/identity.php:69 +#: ../../include/channel.php:69 msgid "Name too long" msgstr "" -#: ../../include/identity.php:180 +#: ../../include/channel.php:180 msgid "No account identifier" msgstr "" -#: ../../include/identity.php:192 +#: ../../include/channel.php:192 msgid "Nickname is required." msgstr "" -#: ../../include/identity.php:206 +#: ../../include/channel.php:206 msgid "Reserved nickname. Please choose another." msgstr "" -#: ../../include/identity.php:211 +#: ../../include/channel.php:211 msgid "" "Nickname has unsupported characters or is already being used on this site." msgstr "" -#: ../../include/identity.php:287 +#: ../../include/channel.php:287 msgid "Unable to retrieve created identity" msgstr "" -#: ../../include/identity.php:345 +#: ../../include/channel.php:345 msgid "Default Profile" msgstr "" -#: ../../include/identity.php:791 +#: ../../include/channel.php:791 msgid "Requested channel is not available." msgstr "" -#: ../../include/identity.php:938 +#: ../../include/channel.php:938 msgid "Create New Profile" msgstr "" -#: ../../include/identity.php:941 ../../include/nav.php:90 +#: ../../include/channel.php:941 ../../include/nav.php:90 msgid "Edit Profile" msgstr "" -#: ../../include/identity.php:958 +#: ../../include/channel.php:958 msgid "Visible to everybody" msgstr "" -#: ../../include/identity.php:1033 ../../include/identity.php:1288 +#: ../../include/channel.php:1033 ../../include/channel.php:1288 msgid "Gender:" msgstr "" -#: ../../include/identity.php:1034 ../../include/identity.php:1332 +#: ../../include/channel.php:1034 ../../include/channel.php:1332 msgid "Status:" msgstr "" -#: ../../include/identity.php:1035 ../../include/identity.php:1343 +#: ../../include/channel.php:1035 ../../include/channel.php:1343 msgid "Homepage:" msgstr "" -#: ../../include/identity.php:1036 +#: ../../include/channel.php:1036 msgid "Online Now" msgstr "" -#: ../../include/identity.php:1124 ../../include/identity.php:1200 +#: ../../include/channel.php:1124 ../../include/channel.php:1200 msgid "F d" msgstr "" -#: ../../include/identity.php:1180 +#: ../../include/channel.php:1180 msgid "Birthday Reminders" msgstr "" -#: ../../include/identity.php:1181 +#: ../../include/channel.php:1181 msgid "Birthdays this week:" msgstr "" -#: ../../include/identity.php:1232 +#: ../../include/channel.php:1232 msgid "[No description]" msgstr "" -#: ../../include/identity.php:1250 +#: ../../include/channel.php:1250 msgid "Event Reminders" msgstr "" -#: ../../include/identity.php:1251 +#: ../../include/channel.php:1251 msgid "Events this week:" msgstr "" -#: ../../include/identity.php:1293 +#: ../../include/channel.php:1293 msgid "Like this channel" msgstr "" -#: ../../include/identity.php:1317 +#: ../../include/channel.php:1317 msgid "j F, Y" msgstr "" -#: ../../include/identity.php:1318 +#: ../../include/channel.php:1318 msgid "j F" msgstr "" -#: ../../include/identity.php:1325 +#: ../../include/channel.php:1325 msgid "Birthday:" msgstr "" -#: ../../include/identity.php:1338 +#: ../../include/channel.php:1338 #, php-format msgid "for %1$d %2$s" msgstr "" -#: ../../include/identity.php:1341 +#: ../../include/channel.php:1341 msgid "Sexual Preference:" msgstr "" -#: ../../include/identity.php:1347 +#: ../../include/channel.php:1347 msgid "Tags:" msgstr "" -#: ../../include/identity.php:1349 +#: ../../include/channel.php:1349 msgid "Political Views:" msgstr "" -#: ../../include/identity.php:1351 +#: ../../include/channel.php:1351 msgid "Religion:" msgstr "" -#: ../../include/identity.php:1355 +#: ../../include/channel.php:1355 msgid "Hobbies/Interests:" msgstr "" -#: ../../include/identity.php:1357 +#: ../../include/channel.php:1357 msgid "Likes:" msgstr "" -#: ../../include/identity.php:1359 +#: ../../include/channel.php:1359 msgid "Dislikes:" msgstr "" -#: ../../include/identity.php:1361 +#: ../../include/channel.php:1361 msgid "Contact information and Social Networks:" msgstr "" -#: ../../include/identity.php:1363 +#: ../../include/channel.php:1363 msgid "My other channels:" msgstr "" -#: ../../include/identity.php:1365 +#: ../../include/channel.php:1365 msgid "Musical interests:" msgstr "" -#: ../../include/identity.php:1367 +#: ../../include/channel.php:1367 msgid "Books, literature:" msgstr "" -#: ../../include/identity.php:1369 +#: ../../include/channel.php:1369 msgid "Television:" msgstr "" -#: ../../include/identity.php:1371 +#: ../../include/channel.php:1371 msgid "Film/dance/culture/entertainment:" msgstr "" -#: ../../include/identity.php:1373 +#: ../../include/channel.php:1373 msgid "Love/Romance:" msgstr "" -#: ../../include/identity.php:1375 +#: ../../include/channel.php:1375 msgid "Work/employment:" msgstr "" -#: ../../include/identity.php:1377 +#: ../../include/channel.php:1377 msgid "School/education:" msgstr "" -#: ../../include/identity.php:1397 +#: ../../include/channel.php:1397 msgid "Like this thing" msgstr "" diff --git a/util/messages.po b/util/messages.po index f3c9782f3..dd847e9e0 100644 --- a/util/messages.po +++ b/util/messages.po @@ -1023,7 +1023,7 @@ msgstr "" #: ../../include/widgets.php:136 ../../include/widgets.php:175 #: ../../include/Contact.php:107 ../../include/conversation.php:956 -#: ../../include/identity.php:956 ../../mod/directory.php:316 +#: ../../include/channel.php:956 ../../mod/directory.php:316 #: ../../mod/match.php:64 ../../mod/suggest.php:52 msgid "Connect" msgstr "" @@ -1088,8 +1088,8 @@ msgstr "" msgid "Family" msgstr "" -#: ../../include/widgets.php:431 ../../include/identity.php:394 -#: ../../include/identity.php:395 ../../include/identity.php:402 +#: ../../include/widgets.php:431 ../../include/channel.php:394 +#: ../../include/channel.php:395 ../../include/channel.php:402 #: ../../include/profile_selectors.php:80 ../../mod/settings.php:345 #: ../../mod/settings.php:349 ../../mod/settings.php:350 #: ../../mod/settings.php:353 ../../mod/settings.php:364 @@ -1206,7 +1206,7 @@ msgid "Finishes:" msgstr "" #: ../../include/event.php:50 ../../include/bb2diaspora.php:481 -#: ../../include/identity.php:1007 ../../mod/directory.php:302 +#: ../../include/channel.php:1007 ../../mod/directory.php:302 #: ../../mod/events.php:684 msgid "Location:" msgstr "" @@ -1523,7 +1523,7 @@ msgid "View all" msgstr "" #: ../../include/ItemObject.php:179 ../../include/taxonomy.php:396 -#: ../../include/conversation.php:1712 ../../include/identity.php:1266 +#: ../../include/conversation.php:1712 ../../include/channel.php:1266 #: ../../mod/photos.php:1019 msgctxt "noun" msgid "Like" @@ -1775,7 +1775,7 @@ msgstr "" msgid "Manage/Edit profiles" msgstr "" -#: ../../include/nav.php:95 ../../include/identity.php:979 +#: ../../include/nav.php:95 ../../include/channel.php:979 msgid "Edit Profile" msgstr "" @@ -3279,48 +3279,48 @@ msgstr "" msgid "database storage failed." msgstr "" -#: ../../include/identity.php:33 +#: ../../include/channel.php:33 msgid "Unable to obtain identity information from database" msgstr "" -#: ../../include/identity.php:67 +#: ../../include/channel.php:67 msgid "Empty name" msgstr "" -#: ../../include/identity.php:70 +#: ../../include/channel.php:70 msgid "Name too long" msgstr "" -#: ../../include/identity.php:186 +#: ../../include/channel.php:186 msgid "No account identifier" msgstr "" -#: ../../include/identity.php:198 +#: ../../include/channel.php:198 msgid "Nickname is required." msgstr "" -#: ../../include/identity.php:212 +#: ../../include/channel.php:212 msgid "Reserved nickname. Please choose another." msgstr "" -#: ../../include/identity.php:217 ../../include/dimport.php:34 +#: ../../include/channel.php:217 ../../include/dimport.php:34 msgid "" "Nickname has unsupported characters or is already being used on this site." msgstr "" -#: ../../include/identity.php:292 +#: ../../include/channel.php:292 msgid "Unable to retrieve created identity" msgstr "" -#: ../../include/identity.php:350 +#: ../../include/channel.php:350 msgid "Default Profile" msgstr "" -#: ../../include/identity.php:759 +#: ../../include/channel.php:759 msgid "Requested channel is not available." msgstr "" -#: ../../include/identity.php:806 ../../mod/profile.php:16 +#: ../../include/channel.php:806 ../../mod/profile.php:16 #: ../../mod/achievements.php:11 ../../mod/webpages.php:29 #: ../../mod/connect.php:13 ../../mod/hcard.php:8 ../../mod/blocks.php:29 #: ../../mod/editlayout.php:27 ../../mod/editwebpage.php:28 @@ -3329,193 +3329,193 @@ msgstr "" msgid "Requested profile is not available." msgstr "" -#: ../../include/identity.php:969 ../../mod/profiles.php:774 +#: ../../include/channel.php:969 ../../mod/profiles.php:774 msgid "Change profile photo" msgstr "" -#: ../../include/identity.php:975 +#: ../../include/channel.php:975 msgid "Profiles" msgstr "" -#: ../../include/identity.php:975 +#: ../../include/channel.php:975 msgid "Manage/edit profiles" msgstr "" -#: ../../include/identity.php:976 ../../mod/profiles.php:775 +#: ../../include/channel.php:976 ../../mod/profiles.php:775 msgid "Create New Profile" msgstr "" -#: ../../include/identity.php:991 ../../mod/profiles.php:786 +#: ../../include/channel.php:991 ../../mod/profiles.php:786 msgid "Profile Image" msgstr "" -#: ../../include/identity.php:994 +#: ../../include/channel.php:994 msgid "visible to everybody" msgstr "" -#: ../../include/identity.php:995 ../../mod/profiles.php:669 +#: ../../include/channel.php:995 ../../mod/profiles.php:669 #: ../../mod/profiles.php:790 msgid "Edit visibility" msgstr "" -#: ../../include/identity.php:1011 ../../include/identity.php:1250 +#: ../../include/channel.php:1011 ../../include/channel.php:1250 msgid "Gender:" msgstr "" -#: ../../include/identity.php:1012 ../../include/identity.php:1294 +#: ../../include/channel.php:1012 ../../include/channel.php:1294 msgid "Status:" msgstr "" -#: ../../include/identity.php:1013 ../../include/identity.php:1305 +#: ../../include/channel.php:1013 ../../include/channel.php:1305 msgid "Homepage:" msgstr "" -#: ../../include/identity.php:1014 +#: ../../include/channel.php:1014 msgid "Online Now" msgstr "" -#: ../../include/identity.php:1097 ../../include/identity.php:1175 +#: ../../include/channel.php:1097 ../../include/channel.php:1175 #: ../../mod/ping.php:324 msgid "g A l F d" msgstr "" -#: ../../include/identity.php:1098 ../../include/identity.php:1176 +#: ../../include/channel.php:1098 ../../include/channel.php:1176 msgid "F d" msgstr "" -#: ../../include/identity.php:1143 ../../include/identity.php:1215 +#: ../../include/channel.php:1143 ../../include/channel.php:1215 #: ../../mod/ping.php:346 msgid "[today]" msgstr "" -#: ../../include/identity.php:1154 +#: ../../include/channel.php:1154 msgid "Birthday Reminders" msgstr "" -#: ../../include/identity.php:1155 +#: ../../include/channel.php:1155 msgid "Birthdays this week:" msgstr "" -#: ../../include/identity.php:1208 +#: ../../include/channel.php:1208 msgid "[No description]" msgstr "" -#: ../../include/identity.php:1226 +#: ../../include/channel.php:1226 msgid "Event Reminders" msgstr "" -#: ../../include/identity.php:1227 +#: ../../include/channel.php:1227 msgid "Events this week:" msgstr "" -#: ../../include/identity.php:1240 ../../include/identity.php:1357 +#: ../../include/channel.php:1240 ../../include/channel.php:1357 #: ../../include/apps.php:138 ../../mod/profperm.php:112 msgid "Profile" msgstr "" -#: ../../include/identity.php:1248 ../../mod/settings.php:1056 +#: ../../include/channel.php:1248 ../../mod/settings.php:1056 msgid "Full Name:" msgstr "" -#: ../../include/identity.php:1255 +#: ../../include/channel.php:1255 msgid "Like this channel" msgstr "" -#: ../../include/identity.php:1279 +#: ../../include/channel.php:1279 msgid "j F, Y" msgstr "" -#: ../../include/identity.php:1280 +#: ../../include/channel.php:1280 msgid "j F" msgstr "" -#: ../../include/identity.php:1287 +#: ../../include/channel.php:1287 msgid "Birthday:" msgstr "" -#: ../../include/identity.php:1291 ../../mod/directory.php:297 +#: ../../include/channel.php:1291 ../../mod/directory.php:297 msgid "Age:" msgstr "" -#: ../../include/identity.php:1300 +#: ../../include/channel.php:1300 #, php-format msgid "for %1$d %2$s" msgstr "" -#: ../../include/identity.php:1303 ../../mod/profiles.php:691 +#: ../../include/channel.php:1303 ../../mod/profiles.php:691 msgid "Sexual Preference:" msgstr "" -#: ../../include/identity.php:1307 ../../mod/directory.php:313 +#: ../../include/channel.php:1307 ../../mod/directory.php:313 #: ../../mod/profiles.php:693 msgid "Hometown:" msgstr "" -#: ../../include/identity.php:1309 +#: ../../include/channel.php:1309 msgid "Tags:" msgstr "" -#: ../../include/identity.php:1311 ../../mod/profiles.php:694 +#: ../../include/channel.php:1311 ../../mod/profiles.php:694 msgid "Political Views:" msgstr "" -#: ../../include/identity.php:1313 +#: ../../include/channel.php:1313 msgid "Religion:" msgstr "" -#: ../../include/identity.php:1315 ../../mod/directory.php:315 +#: ../../include/channel.php:1315 ../../mod/directory.php:315 msgid "About:" msgstr "" -#: ../../include/identity.php:1317 +#: ../../include/channel.php:1317 msgid "Hobbies/Interests:" msgstr "" -#: ../../include/identity.php:1319 ../../mod/profiles.php:697 +#: ../../include/channel.php:1319 ../../mod/profiles.php:697 msgid "Likes:" msgstr "" -#: ../../include/identity.php:1321 ../../mod/profiles.php:698 +#: ../../include/channel.php:1321 ../../mod/profiles.php:698 msgid "Dislikes:" msgstr "" -#: ../../include/identity.php:1323 +#: ../../include/channel.php:1323 msgid "Contact information and Social Networks:" msgstr "" -#: ../../include/identity.php:1325 +#: ../../include/channel.php:1325 msgid "My other channels:" msgstr "" -#: ../../include/identity.php:1327 +#: ../../include/channel.php:1327 msgid "Musical interests:" msgstr "" -#: ../../include/identity.php:1329 +#: ../../include/channel.php:1329 msgid "Books, literature:" msgstr "" -#: ../../include/identity.php:1331 +#: ../../include/channel.php:1331 msgid "Television:" msgstr "" -#: ../../include/identity.php:1333 +#: ../../include/channel.php:1333 msgid "Film/dance/culture/entertainment:" msgstr "" -#: ../../include/identity.php:1335 +#: ../../include/channel.php:1335 msgid "Love/Romance:" msgstr "" -#: ../../include/identity.php:1337 +#: ../../include/channel.php:1337 msgid "Work/employment:" msgstr "" -#: ../../include/identity.php:1339 +#: ../../include/channel.php:1339 msgid "School/education:" msgstr "" -#: ../../include/identity.php:1359 +#: ../../include/channel.php:1359 msgid "Like this thing" msgstr "" -- cgit v1.2.3