/** * Get a wall post message suitable for notifications and status updates * @param ElggObject $object * @param bool $include_address Include URL address in the message body * @return string */ function format_wall_message($object, $include_address = false) { $status = $object->description; $status = Extractor::render($status); $message = array(0 => $status); $tagged_friends = get_tagged_friends($object, 'links'); if ($tagged_friends) { $message[2] = '<span class="wall-tagged-friends">' . elgg_echo('wall:with', array(implode(', ', $tagged_friends))) . '</span>'; } $location = $object->getLocation(); if ($location) { $location = elgg_view('output/wall/location', array('value' => $location)); $message[3] = '<span class="wall-tagged-location">' . elgg_echo('wall:at', array($location)) . '</span>'; } $attachments = get_attachments($object, 'links'); if ($attachments) { $attachments_str = count($attachments) == 1 ? elgg_echo('wall:attached:single') : elgg_echo('wall:attached', array(count($attachments))); $message[4] = '<span class="wall-tagged-attachments">' . $attachments_str . '</span>'; } if (!$status || $include_address) { $address = $object->address; if ($address && strpos($status, $address) === false) { $message[1] = elgg_view('output/url', array('href' => $address, 'class' => 'wall-attached-url')); } } ksort($message); $output = implode(' ', $message); return elgg_trigger_plugin_hook('message:format', 'wall', array('entity' => $object), $output); }
$user_guids = array_unique($user_guids); sort($user_guids); $acl_hash = sha1(implode(':', $user_guids)); $dbprefix = elgg_get_config('dbprefix'); $query = "SELECT * FROM {$dbprefix}access_collections WHERE name = '{$acl_hash}'"; $collection = get_data_row($query); $acl_id = $collection->id; if (!$acl_id) { $site = elgg_get_site_entity(); $acl_id = create_access_collection($acl_hash, $site->guid); update_access_collection($acl_id, $user_guids); } $wall_post->access_id = $acl_id; $wall_post->save(); } $extractor = Extractor::extract($status); if (count($extractor->hashtags)) { $wall_post->tags = $extractor->hashtags; } if (count($extractor->usernames)) { foreach ($extractor->usernames as $username) { $user = get_user_by_username($username); if (elgg_instanceof($user) && !in_array($user->guid, $friend_guids)) { $friend_guids[] = $user->guid; } } } // Add 'tagged_in' relationships // If the access level for the post is not set to private, also create a river item with the access level specified in their settings by the tagged user if (count($friend_guids)) { foreach ($friend_guids as $friend_guid) {