The Hubzilla
 All Classes Namespaces Files Functions Variables Pages
channel.php File Reference

Channel related functions. More...

Functions

 identity_check_service_class ($account_id)
 Called when creating a new channel. More...
 
 validate_channelname ($name)
 Determine if the channel name is allowed when creating a new channel. More...
 
 create_sys_channel ()
 Create a system channel - which has no account attached. More...
 
 get_sys_channel ()
 Returns the sys channel. More...
 
 is_sys_channel ($channel_id)
 Checks if $channel_id is sys channel. More...
 
 channel_total ()
 Return the total number of channels on this site. More...
 
 create_identity ($arr)
 Create a new channel. More...
 
 change_channel_keys ($channel)
 
 channel_change_address ($channel, $new_address)
 
 set_default_login_identity ($account_id, $channel_id, $force=true)
 Set default channel to be used on login. More...
 
 get_default_export_sections ()
 Return an array with default list of sections to export. More...
 
 identity_basic_export ($channel_id, $sections=null)
 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. More...
 
 identity_export_year ($channel_id, $year, $month=0)
 Export items for a year, or a month of a year. More...
 
 channel_export_items ($channel_id, $start, $finish)
 Export items within an arbitrary date range. More...
 
 profile_load ($nickname, $profile= '')
 Loads a profile into the App structure. More...
 
 profile_edit_menu ($uid)
 
 profile_sidebar ($profile, $block=0, $show_connect=true, $zcard=false)
 Formats a profile for display in the sidebar. More...
 
 gender_icon ($gender)
 
 advanced_profile ()
 
 get_my_url ()
 
 get_my_address ()
 
 zid_init ()
 Add visitor's zid to our xchan and attempt authentication. More...
 
 zat_init ()
 If somebody arrives at our site using a zat, authenticate them. More...
 
 get_theme_uid ()
 Used from within PCSS themes to set theme parameters. More...
 
 get_default_profile_photo ($size=300)
 Retrieves the path of the default_profile_photo for this system with the specified size. More...
 
 is_foreigner ($s)
 Test whether a given identity is NOT a member of the Hubzilla. More...
 
 is_member ($s)
 Test whether a given identity is a member of the Hubzilla. More...
 
 get_online_status ($nick)
 Get chatpresence status for nick. More...
 
 remote_online_status ($webbie)
 
 identity_selector ()
 Return the parsed identity selector HTML template. More...
 
 is_public_profile ()
 
 get_profile_fields_basic ($filter=0)
 
 get_profile_fields_advanced ($filter=0)
 
 notifications_off ($channel_id)
 Clear notifyflags for a channel. More...
 
 notifications_on ($channel_id, $value)
 
 get_channel_default_perms ($uid)
 
 profiles_build_sync ($channel_id, $send=true)
 
 auto_channel_create ($account_id)
 
 get_cover_photo ($channel_id, $format= 'bbcode', $res=PHOTO_RES_COVER_1200)
 
 get_zcard ($channel, $observer_hash= '', $args=array())
 Return parsed HTML zcard template. More...
 
 get_zcard_embed ($channel, $observer_hash= '', $args=array())
 Return parsed HTML embed zcard template. More...
 
 channelx_by_nick ($nick)
 Get a channel array from a channel nickname. More...
 
 channelx_by_hash ($hash)
 Get a channel array by a channel_hash. More...
 
 channelx_by_n ($id)
 Get a channel array by a channel ID. More...
 
 channel_reddress ($channel)
 
 channel_manual_conv_update ($channel_id)
 Get manual channel conversation update config. More...
 
 remote_login ()
 Return parsed HTML remote_login template. More...
 
 channel_store_lowlevel ($arr)
 
 profile_store_lowlevel ($arr)
 
 account_remove ($account_id, $local=true, $unset_session=true)
 
 channel_remove ($channel_id, $local=true, $unset_session=false)
 Removes a channel. More...
 
 channel_remove_final ($channel_id)
 
 channel_codeallowed ($channel_id)
 This checks if a channel is allowed to publish executable code. More...
 
 anon_identity_init ($reqvars)
 
 pchan_to_chan ($pchan)
 Create a channel array from proxy channel (pchan). More...
 

Detailed Description

Channel related functions.

Function Documentation

account_remove (   $account_id,
  $local = true,
  $unset_session = true 
)

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.

Parameters
int$account_id
boolean$local(optional) default true
boolean$unset_session(optional) default true
Returns
boolean|array

Referenced by Zotlabs\Module\Admin\Accounts\get(), Zotlabs\Module\Removeaccount\post(), and Zotlabs\Module\Admin\Accounts\post().

advanced_profile ( )
anon_identity_init (   $reqvars)
Hooks:
anon_identity_init
  • array request_vars
  • string xchan - return value
  • string|int success - Must be a number, so xchan return value gets used

Referenced by Zotlabs\Module\Item\post().

auto_channel_create (   $account_id)
change_channel_keys (   $channel)
channel_change_address (   $channel,
  $new_address 
)
channel_codeallowed (   $channel_id)

This checks if a channel is allowed to publish executable code.

It is up to the caller to determine if the observer or local_channel is in fact the resource owner whose channel_id is being checked.

Parameters
int$channel_id
Returns
boolean

Referenced by import_items(), import_webpage_element(), Zotlabs\Module\Attach\init(), mimetype_select(), and Zotlabs\Module\Getfile\post().

channel_export_items (   $channel_id,
  $start,
  $finish 
)

Export items within an arbitrary date range.

Date/time is in UTC.

Parameters
int$channel_idThe channel ID
string$start
string$finish
Returns
array
channel_manual_conv_update (   $channel_id)

Get manual channel conversation update config.

Check the channel config manual_conversation_update, if not set fall back to global system config, defaults to 1 if nothing set.

Parameters
int$channel_id
Returns
int

Referenced by Zotlabs\Module\Pubstream\get(), Zotlabs\Module\Search\get(), Zotlabs\Module\Display\get(), Zotlabs\Module\Network\get(), Zotlabs\Module\Hq\get(), Zotlabs\Module\Channel\get(), and Zotlabs\Module\Settings\Display\get().

channel_remove (   $channel_id,
  $local = true,
  $unset_session = false 
)

Removes a channel.

Parameters
int$channel_id
boolean$localdefault true
boolean$unset_sessiondefault false
Hooks:
channel_remove Called when removing a channel.
  • array with entry from channel tabel for $channel_id

Referenced by account_remove(), Zotlabs\Module\Admin\Channels\get(), Zotlabs\Module\Removeme\post(), and Zotlabs\Module\Admin\Channels\post().

channel_remove_final (   $channel_id)
channel_store_lowlevel (   $arr)

Referenced by create_identity().

channel_total ( )

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

Referenced by zot_site_info().

channelx_by_hash (   $hash)

Get a channel array by a channel_hash.

Parameters
string$hash
Returns
array|boolean false if channel ID not found, otherwise the channel array

Referenced by api_login(), Zotlabs\Module\Zfinger\init(), Zotlabs\Module\Cdav\init(), Zotlabs\Module\Dav\init(), Zotlabs\Module\Getfile\post(), Zotlabs\Module\Cdav\post(), Zotlabs\Daemon\Ratenotif\run(), and Zotlabs\Daemon\Onepoll\run().

create_identity (   $arr)

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.

Parameters
array$arrassociative array with:
  • string name full name of channel
  • string nickname "email/url-compliant" nickname
  • int 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
Hooks:
create_channel_photo
  • array account
  • array channel
  • string photo_url - Return value
Hooks:
create_identity Called when creating a channel.
  • int - The UID of the created identity

Referenced by auto_channel_create(), create_sys_channel(), and Zotlabs\Module\New_channel\post().

create_sys_channel ( )

Create a system channel - which has no account attached.

Referenced by check_config(), and Zotlabs\Module\Setup\what_next().

gender_icon (   $gender)

Referenced by profile_sidebar().

get_channel_default_perms (   $uid)
get_cover_photo (   $channel_id,
  $format = 'bbcode',
  $res = PHOTO_RES_COVER_1200 
)
get_default_export_sections ( )

Return an array with default list of sections to export.

Returns
array with default section names to export
Hooks:
get_default_export_sections Called to get the default list of functional data groups to export in identity_basic_export().
  • array sections - return value

Referenced by api_export_basic(), identity_basic_export(), and Zotlabs\Module\Uexport\init().

get_default_profile_photo (   $size = 300)

Retrieves the path of the default_profile_photo for this system with the specified size.

Parameters
int$size(optional) default 300 one of (300, 80, 48)
Returns
string with path to profile photo

Referenced by anon_identity_init(), Zotlabs\Lib\Apps\app_render(), Zotlabs\Lib\Apps\app_store(), Zotlabs\Lib\Apps\app_update(), atoken_xchan(), consume_feed(), feed_get_reshare(), Zotlabs\Module\Chatsvc\get(), import_xchan_photo(), Zotlabs\Module\Photo\init(), Zotlabs\Module\Ping\init(), Zotlabs\Lib\Apps\parse_app_description(), reflect_comment_store(), and xchan_store().

get_my_address ( )
get_my_url ( )

Referenced by nav(), and zid().

get_online_status (   $nick)

Get chatpresence status for nick.

Parameters
string$nick
Returns
array An associative array with
  • bool result

Referenced by Zotlabs\Module\Online\init(), and profile_load().

get_theme_uid ( )

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.

Returns
int
get_zcard (   $channel,
  $observer_hash = '',
  $args = array() 
)

Return parsed HTML zcard template.

Parameters
array$channel
string$observer_hash(optional)
array$args(optional)
Returns
string parsed HTML from zcard template

Referenced by Zotlabs\Widget\Zcard\widget().

get_zcard_embed (   $channel,
  $observer_hash = '',
  $args = array() 
)

Return parsed HTML embed zcard template.

Parameters
array$channel
string$observer_hash(optional)
array$args(optional)
Returns
string parsed HTML from zcard_embed template

Referenced by Zotlabs\Module\Oep\oep_profile_reply().

identity_basic_export (   $channel_id,
  $sections = null 
)

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.

Parameters
int$channel_idChannel_id to export
array$sections(optional) Which sections to include in the export, default see get_default_export_sections()
Returns
array See function for details
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.

Hooks:
identity_basic_export Called when exporting a channel's basic information for backup or transfer.
  • number channel_id - The channel ID
  • array sections
  • array data - The data will get returned

Referenced by api_export_basic(), and Zotlabs\Module\Uexport\init().

identity_check_service_class (   $account_id)

Called when creating a new channel.

Checks the account's service class and number of current channels to determine whether creating a new channel is within the current service class constraints.

Parameters
int$account_idAccount_id used for this request
Returns
associative array with:
  • boolean success boolean true if creating a new channel is allowed for this account
  • string message (optional) if success is false, optional error text
  • int total_identities

Referenced by create_identity().

identity_export_year (   $channel_id,
  $year,
  $month = 0 
)

Export items for a year, or a month of a year.

Parameters
int$channel_idThe channel ID
number$yearYYYY
number$month(optional) 0-12, default 0 complete year
Returns
array An associative array
  • array relocate - (optional)
  • array item - array with items encoded_item()

Referenced by Zotlabs\Module\Uexport\init().

identity_selector ( )

Return the parsed identity selector HTML template.

Returns
string with parsed HTML channel_id_selet template
is_foreigner (   $s)

Test whether a given identity is NOT a member of the Hubzilla.

Parameters
string$sxchan_hash of the identity in question
Returns
boolean true or false

Referenced by is_member(), scopes_sql(), and theme_attachments().

is_member (   $s)

Test whether a given identity is a member of the Hubzilla.

Parameters
string$sxchan_hash of the identity in question
Returns
boolean true or false
is_sys_channel (   $channel_id)

Checks if $channel_id is sys channel.

Parameters
int$channel_id
Returns
boolean

Referenced by event_store_item(), Zotlabs\Module\Page\init(), profile_sidebar(), and zot_feed().

notifications_off (   $channel_id)

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.

Parameters
int$channel_idThe 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();

Referenced by Zotlabs\Module\Import\import_account().

notifications_on (   $channel_id,
  $value 
)
pchan_to_chan (   $pchan)

Create a channel array from proxy channel (pchan).

Parameters
array$pchanThe proxy channel
Returns
array channel array

Referenced by Zotlabs\Module\Wfinger\init().

profile_edit_menu (   $uid)
profile_load (   $nickname,
  $profile = '' 
)

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.

Parameters
string$nickname
string$profile

Referenced by Zotlabs\Module\Achievements\get(), Zotlabs\Module\Hcard\init(), Zotlabs\Module\Viewconnections\init(), Zotlabs\Module\Common\init(), Zotlabs\Module\Block\init(), Zotlabs\Module\Layouts\init(), Zotlabs\Module\Page\init(), Zotlabs\Module\Profiles\init(), Zotlabs\Module\Profperm\init(), Zotlabs\Module\Editblock\init(), Zotlabs\Module\Editlayout\init(), Zotlabs\Module\Blocks\init(), Zotlabs\Module\Editwebpage\init(), Zotlabs\Module\Articles\init(), Zotlabs\Module\Cards\init(), Zotlabs\Module\Webpages\init(), Zotlabs\Module\Chat\init(), Zotlabs\Module\Cal\init(), Zotlabs\Module\Connect\init(), Zotlabs\Module\Profile\init(), Zotlabs\Module\Photos\init(), Zotlabs\Module\Wiki\init(), Zotlabs\Module\Channel\init(), Zotlabs\Module\Dav\init(), Zotlabs\Module\Cover_photo\init(), Zotlabs\Module\Snap\init(), Zotlabs\Module\Cloud\init(), Zotlabs\Module\Profile_photo\init(), and Zotlabs\Module\Profiles\post().

profile_sidebar (   $profile,
  $block = 0,
  $show_connect = true,
  $zcard = false 
)

Formats a profile for display in the sidebar.

It is very difficult to templatise the HTML completely because of all the conditional logic.

Parameters
array$profile
int$block
boolean$show_connect(optional) default true
mixed$zcard(optional) default false
Returns
HTML string suitable for sidebar inclusion Exceptions: Returns empty string if passed $profile is wrong type or not populated
Hooks:
profile_sidebar_enter Called before generating the 'channel sidebar' or mini-profile.
Hooks:
profile_sidebar Called when generating the 'channel sidebar' or mini-profile.
  • array profile
  • string entry - The parsed HTML template

Referenced by Zotlabs\Widget\Fullprofile\widget(), Zotlabs\Widget\Shortprofile\widget(), and Zotlabs\Widget\Profile\widget().

profile_store_lowlevel (   $arr)
profiles_build_sync (   $channel_id,
  $send = true 
)
remote_login ( )

Return parsed HTML remote_login template.

Returns
string with parsed HTML from remote_login template

Referenced by nav().

remote_online_status (   $webbie)
Parameters
string$webbie
Returns
array|boolean|string
set_default_login_identity (   $account_id,
  $channel_id,
  $force = true 
)

Set default channel to be used on login.

Parameters
int$account_idlogin account
int$channel_idchannel id to set as default for this account
boolean$force(optional) default true
  • if true, set this default unconditionally
  • if $force is false only do this if there is no existing default

Referenced by create_identity(), and import_channel().

validate_channelname (   $name)

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 (191 chars). 191 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.

Parameters
string$name
Returns
string describing the error state, or nil return if name is valid
Hooks:
validate_channelname Used to validate the names used by a channel.
  • string name
  • string message - return error message

Referenced by auto_channel_create(), create_identity(), Zotlabs\Module\Settings\Channel\post(), and Zotlabs\Module\Profiles\post().

zat_init ( )

If somebody arrives at our site using a zat, authenticate them.

Referenced by Zotlabs\Web\WebServer\run().

zid_init ( )

Add visitor's zid to our xchan and attempt authentication.

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.

Hooks:
zid_init
  • string zid - their zid
  • string url - the destination url

Referenced by Zotlabs\Web\WebServer\run().