$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('profile/icon', array('entity' => $entity, 'size' => 'small')); } elseif ($owner = $entity->getOwnerEntity()) { $icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'small')); } 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('graphics/icon', array('entity' => $entity, 'size' => 'small')); } } $question = 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 = friendly_time($tu > $tc ? $tu : $tc); } ?>
<?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 = get_question_for_answer($answer); if ($question && $answer) { if ($question->getSubtype() == "question" && $question->canEdit()) { $question->chosen_answer = $answer->getGUID(); system_message(elgg_echo("answers:answer:chosen")); //add to river add_to_river('river/object/question/choose', 'choose', $question->getGUID(), $answer->getGUID()); //add_to_river('river/object/question/choose', 'choose', $_SESSION['user']->guid, $question->getGUID()); } else { error_log("couldn't edit: " . $question->getSubtype() . ", " . $question->canEdit() . ", " . $answer->getGUID()); } } else { register_error(elgg_echo("answers:notfound")); } forward($question->getURL());
function answers_notify_comment($object, $comment_text, $commenter) { global $CONFIG; // find interested users // - question owner // - if commenting on answer, answer owner // - should these be added, too? // - other answers owners // - other commenters // - followers of the commenter // - group members (if group question) $commenter_guid = $commenter->guid; $interested_users = array(); $question = $object; $answer = null; $subtype = $object->getSubtype(); if ($subtype == 'answer') { $answer = $object; $question = get_question_for_answer($answer); } if ($question->owner_guid != $commenter_guid) { $interested_users[] = $question->owner_guid; } if ($answer && $answer->owner_guid != $commenter_guid) { $interested_users[] = $answer->owner_guid; } $interested_users = array_unique($interested_users); $email_subject = sprintf(elgg_echo('answers:' . $subtype . ':comment:email:subject'), $question->title); $email_body = sprintf(elgg_echo('answers:' . $subtype . ':comment:email:body'), $commenter->name, $question->title, $comment_text, $object->getURL(), $commenter->getURL()); foreach ($interested_users as $user_guid) { $user = get_user($user_guid); notify_user($user_guid, $commenter_guid, $email_subject, $email_body); } }