| The Red Matrix

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Pages
Functions
items.php File Reference

## Functions
| collect_recipients ($item, &$private_envelope)
| filter_insecure ($channel_id, $arr)
| comments_are_now_closed ($item)
| can_comment_on_post ($observer_xchan, $item)
| add_source_route ($iid, $hash)
| red_zrl_callback ($matches)
| red_escape_zrl_callback ($matches)
| red_escape_codeblock ($m)
| red_unescape_codeblock ($m)
| red_zrlify_img_callback ($matches)
| post_activity_item ($arr)
| get_public_feed ($channel, $params)
| get_feed_for ($channel, $observer_hash, $params)
| construct_verb ($item)
| construct_activity_object ($item)
| construct_activity_target ($item)
| limit_body_size ($body)
| title_is_body ($title, $body)
| get_item_elements ($x)
| import_author_xchan ($x)
| import_author_diaspora ($x)
| import_author_rss ($x)
| import_author_unknown ($x)
| encode_item ($item, $mirror=false)
| map_scope ($scope, $strip=false)
| translate_scope ($scope)
| encode_item_xchan ($xchan)
| encode_item_terms ($terms)
| termtype ($t)
| decode_tags ($t)
| activity_sanitise ($arr)
| array_sanitise ($arr)
| encode_item_flags ($item)
| encode_mail ($item)
| get_mail_elements ($x)
| get_profile_elements ($x)
| get_atom_elements ($feed, $item, &$author)
| encode_rel_links ($links)
| item_store ($arr, $allow_exec=false)
| item_store_update ($arr, $allow_exec=false)
| store_diaspora_comment_sig ($datarray, $channel, $parent_item, $post_id, $walltowall=false)
| send_status_notifications ($post_id, $item)
| get_item_contact ($item, $contacts)
| tag_deliver ($uid, $item_id)
| tgroup_check ($uid, $item)
| start_delivery_chain ($channel, $item, $item_id, $parent)
| check_item_source ($uid, $item)
| mail_store ($arr)
| consume_feed ($xml, $importer, &$contact, $pass=0)
| update_feed_item ($uid, $datarray)
| handle_feed ($uid, $abook_id, $url)
| atom_author ($tag, $name, $uri, $h, $w, $type, $photo)
| atom_entry ($item, $type, $author, $owner, $comment=false, $cid=0)
| fix_private_photos ($s, $uid, $item=null, $cid=0)
| has_permissions ($obj)
| compare_permissions ($obj1, $obj2)
| enumerate_permissions ($obj)
| item_getfeedtags ($item)
| item_getfeedattach ($item)
| item_expire ($uid, $days)
| retain_item ($id)
| drop_items ($items)
| drop_item ($id, $interactive=true, $stage=DROPITEM_NORMAL)
| delete_item_lowlevel ($item, $stage=DROPITEM_NORMAL)
| first_post_date ($uid, $wall=false)
| list_post_dates ($uid, $wall, $mindate)
| posted_dates ($uid, $wall)
| fetch_post_tags ($items, $link=false)
| zot_feed ($uid, $observer_xchan, $arr)
| items_fetch ($arr, $channel=null, $observer_hash=null, $client_mode=CLIENT_MODE_NORMAL, $module= 'network')
| update_remote_id ($channel, $post_id, $webpage, $pagetitle, $namespace, $remote_id, $mid)
| item_add_cid ($xchan_hash, $mid, $uid)
| item_remove_cid ($xchan_hash, $mid, $uid)

## Function Documentation

activity_sanitise | ( |  | $arr | ) |

Referenced by get_item_elements(), get_mail_elements(), item_store(), and item_store_update().

add_source_route | ( |  | $iid,
|  |  | $hash
| ) |  |

add_source_route($iid,$hash) Adds $hash to the item source route specified by $iid

Parameters

  integer | $iid | item['id'] of target item
  string | $hash | xchan_hash of the channel that sent the item Modifies item pointed to by $iid

$item['route'] contains a comma-separated list of xchans that sent the current message, somewhat analogous to the * Received: header line in email. We can use this to perform loop detection and to avoid sending a particular item to any "upstream" sender (they already have a copy because they sent it to us).

Referenced by process_delivery().

array_sanitise | ( |  | $arr | ) |

Referenced by get_profile_elements().

atom_author | ( |  | $tag,
|  |  | $name,
|  |  | $uri,
|  |  | $h,
|  |  | $w,
|  |  | $type,
|  |  | $photo
| ) |  |

Referenced by atom_entry().

atom_entry | ( |  | $item,
|  |  | $type,
|  |  | $author,
|  |  | $owner,
|  |  | $comment = `false`,
|  |  | $cid = `0`
| ) |  |

Referenced by get_feed_for().

can_comment_on_post | ( |  | $observer_xchan,
|  |  | $item
| ) |  |

can_comment_on_post($observer_xchan,$item);

This function examines the comment_policy attached to an item and decides if the current observer has sufficient privileges to comment. This will normally be called on a remote site where perm_is_allowed() will not be suitable because the post owner does not have a local channel_id. Generally we should look at the item - in particular the author['book_flags'] and see if ABOOK_FLAG_SELF is set. If it is, you should be able to use perm_is_allowed( ... 'post_comments'), and if it isn't you need to call can_comment_on_post() We also check the comments_closed date/time on the item if this is set.

Referenced by Conversation\add_thread(), and item_post().

check_item_source | ( |  | $uid,
|  |  | $item
| ) |  |

check_item_source($uid,$item)

Parameters

  $uid |
  $item | Checks to see if this item owner is referenced as a source for this channel and if the post matches the rules for inclusion in this channel. Returns true if we should create a second delivery chain and false if none of the rules apply, or if the item is private.

Referenced by tag_deliver().

collect_recipients | ( |  | $item,
|  | & | $private_envelope
| ) |  |

Referenced by notifier_run().

comments_are_now_closed | ( |  | $item | ) |

Referenced by Conversation\add_thread(), can_comment_on_post(), and item_store().

compare_permissions | ( |  | $obj1,
|  |  | $obj2
| ) |  |

Referenced by fix_private_photos().

construct_activity_object | ( |  | $item | ) |

Referenced by atom_entry().

construct_activity_target | ( |  | $item | ) |

Referenced by atom_entry().

construct_verb | ( |  | $item | ) |

Referenced by atom_entry().

consume_feed | ( |  | $xml,
|  |  | $importer,
|  | & | $contact,
|  |  | $pass = `0`
| ) |  |

consume_feed - process atom feed and update anything/everything we might need to update

$xml = the (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds.

$importer = the contact_record (joined to user_record) of the local user who owns this relationship. It is this person's stuff that is going to be updated. $contact = the person who is sending us stuff. If not set, we MAY be processing a "follow" activity from an external network and MAY create an appropriate contact record. Otherwise, we MUST have a contact record. $hub = should we find a hub declation in the feed, pass it back to our calling process, who might (or might not) try and subscribe to it. $datedir sorts in reverse order $pass - by default ($pass = 0) we cannot guarantee that a parent item has been imported prior to its children being seen in the stream unless we are certain of how the feed is arranged/ordered. With $pass = 1, we only pull parent items out of the stream. With $pass = 2, we only pull children (comments/likes).

So running this twice, first with pass 1 and then with pass 2 will do the right thing regardless of feed ordering. This won't be adequate in a fully-threaded model where comments can have sub-threads. That would require some massive sorting to get all the feed items into a mostly linear ordering, and might still require recursion.

Referenced by handle_feed(), and pubsub_post().

decode_tags | ( |  | $t | ) |

Referenced by get_item_elements().

delete_item_lowlevel | ( |  | $item,
|  |  | $stage = `DROPITEM_NORMAL`
| ) |  |

Referenced by drop_item().

drop_item | ( |  | $id,
|  |  | $interactive = `true`,
|  |  | $stage = `DROPITEM_NORMAL`
| ) |  |

Referenced by api_statuses_destroy(), consume_feed(), contact_remove(), delete_imported_item(), diaspora_retraction(), diaspora_signed_retraction(), drop_items(), expire_run(), item_content(), item_expire(), like_content(), photos_post(), poller_run(), and remove_all_xchan_resources().

drop_items | ( |  | $items | ) |

Referenced by item_post().

encode_item | ( |  | $item,
|  |  | $mirror = `false`
| ) |  |

Referenced by identity_basic_export(), notifier_run(), and zot_feed().

encode_item_flags | ( |  | $item | ) |

Referenced by encode_item().

encode_item_terms | ( |  | $terms | ) |

Referenced by encode_item().

encode_item_xchan | ( |  | $xchan | ) |

Referenced by encode_item(), and encode_mail().

encode_mail | ( |  | $item | ) |

Referenced by notifier_run().

encode_rel_links | ( |  | $links | ) |

Referenced by get_atom_elements().

enumerate_permissions | ( |  | $obj | ) |

Referenced by compare_permissions(), and fix_private_photos().

fetch_post_tags | ( |  | $items,
|  |  | $link = `false`
| ) |  |

Referenced by block_content(), bookmarks_init(), channel_content(), display_content(), editpost_content(), event_store_item(), events_content(), home_content(), identity_basic_export(), item_expire(), items_fetch(), network_content(), notifier_run(), page_content(), photos_post(), search_content(), tag_deliver(), tagrm_content(), tagrm_post(), widget_item(), and zot_feed().

filter_insecure | ( |  | $channel_id,
|  |  | $arr
| ) |  |

If channel is configured to filter insecure members of privacy groups (those whose networks leak privacy via email notifications or other criteria) remove them from any privacy groups (collections) that were included in a post. They can still be addressed individually. Networks may need to be added or removed from this list as circumstances change.

Update: this may need to be the default, which will force people to opt-in to sending stuff privately to insecure platforms.

Referenced by collect_recipients().

first_post_date | ( |  | $uid,
|  |  | $wall = `false`
| ) |  |

Referenced by list_post_dates(), and posted_dates().

fix_private_photos | ( |  | $s,
|  |  | $uid,
|  |  | $item = `null`,
|  |  | $cid = `0`
| ) |  |

Referenced by atom_entry().

get_atom_elements | ( |  | $feed,
|  |  | $item,
|  | & | $author
| ) |  |

If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it.

Referenced by consume_feed().

get_feed_for | ( |  | $channel,
|  |  | $observer_hash,
|  |  | $params
| ) |  |

Referenced by get_public_feed().

get_item_contact | ( |  | $item,
|  |  | $contacts
| ) |  |

get_item_elements | ( |  | $x | ) |

Referenced by externals_run(), import_post(), onepoll_run(), and zot_import().

get_mail_elements | ( |  | $x | ) |

Referenced by zot_import().

get_profile_elements | ( |  | $x | ) |

Referenced by zot_import().

get_public_feed | ( |  | $channel,
|  |  | $params
| ) |  |

get_public_feed($channel,$params) generate an Atom feed

Referenced by feed_init().

handle_feed | ( |  | $uid,
|  |  | $abook_id,
|  |  | $url
| ) |  |

Referenced by onepoll_run().

has_permissions | ( |  | $obj | ) |

Referenced by fix_private_photos().

import_author_diaspora | ( |  | $x | ) |

Referenced by import_author_xchan(), and poco_load().

import_author_rss | ( |  | $x | ) |

Referenced by import_author_xchan().

import_author_unknown | ( |  | $x | ) |

Referenced by consume_feed(), and import_author_xchan().

import_author_xchan | ( |  | $x | ) |

Referenced by get_item_elements(), get_mail_elements(), and get_profile_elements().

item_add_cid | ( |  | $xchan_hash,
|  |  | $mid,
|  |  | $uid
| ) |  |

change access control for item with message_id $mid and channel_id $uid

item_expire | ( |  | $uid,
|  |  | $days
| ) |  |

Referenced by expire_run().

item_getfeedattach | ( |  | $item | ) |

item_getfeedtags | ( |  | $item | ) |

item_remove_cid | ( |  | $xchan_hash,
|  |  | $mid,
|  |  | $uid
| ) |  |

item_store | ( |  | $arr,
|  |  | $allow_exec = `false`
| ) |  |

Referenced by consume_feed(), diaspora_asphoto(), diaspora_comment(), diaspora_like(), diaspora_post(), diaspora_reshare(), event_store_item(), impel_init(), import_post(), item_post(), like_content(), mood_init(), photo_upload(), photos_create_item(), post_activity_item(), process_delivery(), profile_activity(), refimport_content(), reflect_comment_store(), and subthread_content().

item_store_update | ( |  | $arr,
|  |  | $allow_exec = `false`
| ) |  |

Referenced by impel_init(), import_post(), item_post(), photos_post(), refimport_content(), reflect_comment_store(), tagrm_content(), tagrm_post(), and update_imported_item().

items_fetch | ( |  | $arr,
|  |  | $channel = `null`,
|  |  | $observer_hash = `null`,
|  |  | $client_mode = `CLIENT_MODE_NORMAL`,
|  |  | $module = `'network'`
| ) |  |

Referenced by api_statuses_user_timeline(), and get_feed_for().

limit_body_size | ( |  | $body | ) |

Referenced by get_atom_elements().

list_post_dates | ( |  | $uid,
|  |  | $wall,
|  |  | $mindate
| ) |  |

modified posted_dates() {below} to arrange the list in years, which we'll eventually use to make a menu of years with collapsible sub-menus for the months instead of the current flat list of all representative dates.

Referenced by widget_archive().

mail_store | ( |  | $arr | ) |

Referenced by process_mail_delivery().

map_scope | ( |  | $scope,
|  |  | $strip = `false`
| ) |  |

Referenced by encode_item(), item_post(), post_activity_item(), profiles_content(), and start_delivery_chain().

post_activity_item | ( |  | $arr | ) |

post_activity_item($arr)

    post an activity

Parameters

  array | $arr | In its simplest form one needs only to set $arr['body'] to post a note to the logged in channel's wall. Much more complex activities can be created. Permissions are checked. No filtering, tag expansion or other processing is performed.

Returns
  array 'success' => true or false 'activity' => the resulting activity if successful

Referenced by api_channel_stream(), connedit_post(), poke_init(), tagger_content(), and thing_init().

posted_dates | ( |  | $uid,
|  |  | $wall
| ) |  |

red_escape_codeblock | ( |  | $m | ) |

red_escape_zrl_callback | ( |  | $matches | ) |

red_unescape_codeblock | ( |  | $m | ) |

red_zrl_callback | ( |  | $matches | ) |

red_zrl_callback preg_match function when fixing 'naked' links in mod item.php Check if we've got a hubloc for the site and use a zrl if we do, a url if we don't. Remove any existing zid= param which may have been pasted by mistake - and will have the author's credentials. zid's are dynamic and can't really be passed around like that.

red_zrlify_img_callback | ( |  | $matches | ) |

retain_item | ( |  | $id | ) |

Referenced by item_expire().

send_status_notifications | ( |  | $post_id,
|  |  | $item
| ) |  |

Referenced by diaspora_comment(), item_store(), and item_store_update().

start_delivery_chain | ( |  | $channel,
|  |  | $item,
|  |  | $item_id,
|  |  | $parent
| ) |  |

Sourced and tag-delivered posts are re-targetted for delivery to the connections of the channel receiving the post. This starts the second delivery chain, by resetting permissions and ensuring that ITEM_UPLINK is set on the parent post, and storing the current owner_xchan as the source_xchan. We'll become the new owner. If called without $parent, this is the parent post.

Referenced by tag_deliver().

store_diaspora_comment_sig | ( |  | $datarray,
|  |  | $channel,
|  |  | $parent_item,
|  |  | $post_id,
|  |  | $walltowall = `false`
| ) |  |

Referenced by item_post().

tag_deliver | ( |  | $uid,
|  |  | $item_id
| ) |  |

Fetch stuff we need - a channel and an item

Seems like a good place to plug in a poke notification.

Do community tagging

A "union" is a message which our channel has sourced from another channel. This sets up a second delivery chain just like forum tags do. Find out if this is a source-able post.

Now we've got those out of the way. Let's see if this is a post that's tagged for re-delivery

Kill two birds with one stone. As long as we're here, send a mention notification.

Referenced by delete_imported_item(), item_content(), item_store(), and item_store_update().

termtype | ( |  | $t | ) |

Referenced by encode_item_terms().

tgroup_check | ( |  | $uid,
|  |  | $item
| ) |  |

tgroup_check($uid,$item)

This function is called pre-deliver to see if a post matches the criteria to be tag delivered. We don't actually do anything except check that it matches the criteria. This is so that the channel with tag_delivery enabled can receive the post even if they turn off permissions for the sender to send their stream. tag_deliver() can't be called until the post is actually stored. By then it would be too late to reject it.

Referenced by process_delivery().

title_is_body | ( |  | $title,
|  |  | $body
| ) |  |

Referenced by get_atom_elements().

translate_scope | ( |  | $scope | ) |

Referenced by lockview_content(), and profiles_content().

update_feed_item | ( |  | $uid,
|  |  | $datarray
| ) |  |

Referenced by consume_feed().

update_remote_id | ( |  | $channel,
|  |  | $post_id,
|  |  | $webpage,
|  |  | $pagetitle,
|  |  | $namespace,
|  |  | $remote_id,
|  |  | $mid
| ) |  |

Referenced by impel_init(), and item_post().

zot_feed | ( |  | $uid,
|  |  | $observer_xchan,
|  |  | $arr
| ) |  |

Referenced by zot_process_message_request(), and zotfeed_init().