Esempio n. 1
0
<?php

/**
 * Choose the best answer action
 */
// Get input
$answer_id = (int) get_input('answer_id');
// Let's see if we can get an entity with the specified GUID
$answer = get_entity($answer_id);
$question = answers_get_question_for_answer($answer);
if ($question && $answer) {
    if ($question->getSubtype() == "question" && $question->canEdit()) {
        $question->chosen_answer = $answer->getGUID();
        $user_guid = elgg_get_logged_in_user_guid();
        system_message(elgg_echo("answers:answer:chosen"));
        //add to river
        add_to_river('river/object/question/choose', 'update', $user_guid, $answer->getGUID());
        // @ManUtopiK prefer 'update' to correspond to elgg standard.
    } else {
        register_error(elgg_echo('answers:answer:notchosen'));
    }
} else {
    register_error(elgg_echo("answers:notfound"));
}
forward($question->getURL());
Esempio n. 2
0
function answers_notify_message($hook, $type, $result, $params)
{
    $entity = $params['entity'];
    if (elgg_instanceof($entity, 'object')) {
        $subtype = $entity->getSubtype();
        if ($subtype == 'question' || $subtype == 'answer') {
            $descr = $entity->description;
            $owner = $entity->getOwnerEntity();
            $ret = array();
            if ($subtype == 'answer') {
                $question = answers_get_question_for_answer($entity);
                $subject = elgg_echo('answers:notify:answer:subject', array($owner->name, $question->title));
            } else {
                $subject = elgg_echo('answers:notify:question:subject', array($owner->name, $entity->title));
            }
            $link = elgg_echo('answers:notify:body', array(elgg_echo("answers:{$subtype}"), $entity->getURL()));
            return $subject . "\n\n" . $descr . "\n\n\n" . $link;
        }
    }
    return null;
}
Esempio n. 3
0
$icon = $entity->getVolatileData('search_icon');
if (!$icon) {
    // display the entity's owner by default if available.
    // @todo allow an option to switch to displaying the entity's icon instead.
    $type = $entity->getType();
    if ($type == 'user' || $type == 'group') {
        $icon = elgg_view_entity_icon($entity, 'tiny');
    } elseif ($owner = $entity->getOwnerEntity()) {
        $icon = elgg_view_entity_icon($owner, 'tiny');
    } else {
        // display a generic icon if no owner, though there will probably be
        // other problems if the owner can't be found.
        $icon = elgg_view_entity_icon($entity, 'tiny');
    }
}
$question = answers_get_question_for_answer($entity);
$title = $question->title;
$description = $entity->getVolatileData('search_matched_description');
$extra_info = $entity->getVolatileData('search_matched_extra');
$url = $entity->getVolatileData('search_url');
if (!$url) {
    $url = $entity->getURL();
}
$title = "<a href=\"{$url}\">{$title}</a>";
$time = $entity->getVolatileData('search_time');
if (!$time) {
    $tc = $entity->time_created;
    $tu = $entity->time_updated;
    $time = elgg_view_friendly_time($tu > $tc ? $tu : $tc);
}
$body = "<p class=\"mbn\">{$title}</p>{$description}";