Example #1
0
 * Post a reply to discussion topic
 *
 * @override mod/groups/actions/discussion/reply/save.php
 */
gatekeeper();
elgg_load_library('elgg:threads');
// Get input
$text = get_input('group_topic_post');
$entity_guid = (int) get_input('entity_guid');
$reply = (bool) get_input('reply', false);
// reply cannot be empty
if (empty($text)) {
    register_error(elgg_echo('grouppost:nopost'));
    forward(REFERER);
}
$topic = threads_top($entity_guid);
if (!$topic) {
    register_error(elgg_echo('grouppost:nopost'));
    forward(REFERER);
}
$user = elgg_get_logged_in_user_entity();
$group = $topic->getContainerEntity();
if (!$group->canWriteToContainer($user)) {
    register_error(elgg_echo('groups:notmember'));
    forward(REFERER);
}
// if editing a reply, make sure it's valid
if (!$reply) {
    $entity = get_entity($entity_guid);
    if (!$entity || !$entity->canEdit()) {
        register_error(elgg_echo('groups:notowner'));
Example #2
0
function threads_reply($parent_guid, $text, $title = "", $params = null)
{
    $topic = threads_top($parent_guid);
    $topic_guid = $topic->guid;
    // add the reply to the forum topic
    $reply = new ElggObject();
    $reply->subtype = 'topicreply';
    $reply->title = $title ? $title : "Re:" . $topic->title;
    $reply->description = $text;
    $reply->access_id = $topic->access_id;
    $reply->container_guid = $topic->container_guid;
    // save parameters
    if ($params) {
        foreach ($params as $key => $value) {
            $reply->{$key} = $value;
        }
    }
    if ($reply->save()) {
        $reply->addRelationship($parent_guid, 'parent');
        $reply->addRelationship($topic_guid, 'top');
        return $reply->save();
    } else {
        return false;
    }
}
Example #3
0
<?php

/*
 * Embeds an edit link for the annotation
 */
elgg_load_library("elgg:threads");
$entity = elgg_extract('entity', $vars);
$topic = threads_top($entity->guid);
$owner = get_entity($entity->owner_guid);
if (!$entity || !$owner) {
    return true;
}
$icon = elgg_view_entity_icon($owner, 'tiny');
$owner_link = "<a href=\"{$owner->getURL()}\">{$owner->name}</a>";
$menu = elgg_view_menu('reply', array('entity' => $entity, 'sort_by' => 'priority', 'class' => 'elgg-menu-entity elgg-menu-hz'));
$text = elgg_view("output/longtext", array("value" => $entity->description));
$friendlytime = elgg_view_friendly_time($entity->time_created);
$replies = elgg_view('discussion/replies', array('entity' => $entity));
$body = <<<HTML
<div class="mbn">
\t{$menu}
\t{$owner_link}
\t<span class="elgg-subtext">
\t\t{$friendlytime}
\t</span>
\t{$text}
</div>
HTML;
echo elgg_view_image_block($icon, $body);
if (get_input('guid') == $entity->guid && get_input('box')) {
    $box = false;