Exemplo n.º 1
0
Arquivo: start.php Projeto: elgg/elgg
/**
 * Prepare a notification message about a new wire post
 *
 * @param string                          $hook         Hook name
 * @param string                          $type         Hook type
 * @param Elgg\Notifications\Notification $notification The notification to prepare
 * @param array                           $params       Hook parameters
 * @return Elgg\Notifications\Notification
 */
function thewire_prepare_notification($hook, $type, $notification, $params)
{
    $entity = $params['event']->getObject();
    $owner = $params['event']->getActor();
    $recipient = $params['recipient'];
    $language = $params['language'];
    $method = $params['method'];
    $descr = $entity->description;
    $subject = elgg_echo('thewire:notify:subject', array($owner->name), $language);
    if ($entity->reply) {
        $parent = thewire_get_parent($entity->guid);
        if ($parent) {
            $parent_owner = $parent->getOwnerEntity();
            $body = elgg_echo('thewire:notify:reply', array($owner->name, $parent_owner->name), $language);
        }
    } else {
        $body = elgg_echo('thewire:notify:post', array($owner->name), $language);
    }
    $body .= "\n\n" . $descr . "\n\n";
    $body .= elgg_echo('thewire:notify:footer', array($entity->getURL()), $language);
    $notification->subject = $subject;
    $notification->body = $body;
    $notification->summary = elgg_echo('thewire:notify:summary', array($descr), $language);
    return $notification;
}
Exemplo n.º 2
0
/**
 * Get Thread
 *
 * @param int $thread_id Thread GUID
 *
 * @return SuccessResult|ErrorResult
 */
function ws_pack_get_thread($thread_id = false)
{
    $result = false;
    $user = elgg_get_logged_in_user_entity();
    $api_application = ws_pack_get_current_api_application();
    if (!empty($user) && !empty($api_application)) {
        $threads = elgg_get_entities_from_metadata(array("metadata_name" => "wire_thread", "metadata_value" => $thread_id, "type" => "object", "subtype" => "thewire", "limit" => 20));
        // returns guid of wire post
        if ($threads === false) {
            // error
        } else {
            $wires = array();
            $wires["entities"] = ws_pack_export_entities($threads);
            $guids_thread = array();
            foreach ($wires["entities"] as $k => $wt) {
                $wire_guid_th = $wt["guid"];
                if (!in_array($wire_guid_th, $guids_thread)) {
                    $guids_thread[] = $wire_guid_th;
                    $owner_thread = get_entity($wt["owner_guid"]);
                    $wt["owner"] = ws_pack_export_entity($owner_thread);
                    $parent = thewire_get_parent($wire_guid_th);
                    $wt["parent"] = ws_pack_export_entity($parent);
                    if ($parent !== false) {
                        $parent_owner = get_entity($wt["parent"]["owner_guid"]);
                        $wt["parent_owner"] = ws_pack_export_entity($parent_owner);
                    }
                    $wires["entities"][$k] = $wt;
                } else {
                    unset($wires["entities"][$k]);
                }
            }
            $result = new SuccessResult($wires);
        }
        if ($result === false) {
            $result = new ErrorResult(elgg_echo("ws_pack:error:notfound"));
        }
    }
    return $result;
}
Exemplo n.º 3
0
<?php

/**
 * Serve up html for a post's parent
 */
$guid = (int) get_input('guid');
$title = elgg_echo('thewire:previous');
$parent = thewire_get_parent($guid);
if ($parent) {
    $body = elgg_view_entity($parent);
}
$body = elgg_view_layout('content', array('filter' => false, 'content' => $body, 'title' => $title));
echo elgg_view_page($title, $body);