예제 #1
0
<?php

try {
    require_once "Sprinkles.php";
    $sprink = new Sprinkles();
    $topic_id = request_param('id');
    if (!$topic_id) {
        die("Internal error: expected id parameter.");
    }
    $items = $sprink->topic($topic_id);
    if (!$items) {
        die("Internal error: Empty topic {$topic_id}.");
    }
    $topic_head = array_shift($items['replies']);
    $smarty->assign('topic_head', $topic_head);
    $smarty->assign('topic_id', $topic_id);
    $smarty->assign('body_css_id', 'share-topic');
    $smarty->assign('current_url', 'share-topic.php?id=' . $topic_id);
    $sprink->add_std_hash_elems($smarty);
    $smarty->display('share-topic.t');
    finish_request('share-topic');
} catch (Exception $e) {
    error_log("Exception thrown while preparing page: " . $e->getMessage());
    $smarty->display('error.t');
}
예제 #2
0
try {
    require_once "Sprinkles.php";
    $sprink = new Sprinkles();
    $topic_id = request_param('id');
    if (!$topic_id) {
        $topic_id = request_param('topic_id');
    }
    if (!$topic_id) {
        $sfn_id = request_param('sfn_id');
        $topic_id = $sprink->api_url("topics/" . $sfn_id);
    }
    if (!$topic_id) {
        die("Internal error: expected id parameter.");
    }
    $topic = $sprink->topic($topic_id);
    $topic_head = array_shift($topic['replies']);
    $reply_count = count($topic['replies']);
    $topic['replies'] = thread_items($topic['replies'], $topic_head['id']);
    $toplevel_reply_count = count($topic['replies']);
    $topic['replies'] = flatten_threads($topic['replies']);
    $sprink->resolve_author($topic_head);
    $sprink->resolve_authors($topic['replies']);
    $related_topics = $sprink->topics(array('related' => $topic_id));
    list($company_related_topics, $noncompany_related_topics) = $sprink->company_partition($related_topics['topics']);
    $noncompany_related_topics = take($related_topics_count, $noncompany_related_topics);
    resolve_companies($noncompany_related_topics);
    list($company_promoted, $star_promoted) = filter_promoted($topic['replies']);
    $smarty->assign('topic_head', $topic_head);
    $smarty->assign('replies', $topic['replies']);
    $smarty->assign('related_topics', $noncompany_related_topics);
예제 #3
0
<?php

try {
    require_once 'Sprinkles.php';
    $sprink = new Sprinkles();
    $id = request_param('id');
    $topic = $sprink->topic($id);
    $topic = $topic['replies'][0];
    $from = request_param('from_email');
    $from = preg_replace('/\\n.*$/', ' ', $from);
    # Sanitizes $from; it'll go verbatim in the SMTP headers
    $user_fn = request_param('sender_name');
    if (!$user_fn) {
        $user = $sprink->current_user();
        $user_fn = $user['fn'];
    }
    $personal_message = request_param('personal_message');
    $message = $user_fn . " thinks you might be interested in this discussion from Get Satisfaction:\n\n" . "\"" . $topic['title'] . "\n\n" . $topic['content'] . "\"\n\n" . $topic['author']['fn'] . " asked this on " . $topic['published_formatted'] . (!$personal_message ? '' : "\n\n" . $user_fn . " says: \n\n" . $personal_message);
    $subject = "'" . $topic['title'] . "' on Get Satisfaction!";
    $to = request_param('to_email');
    # TBD: handle more than one address
    if (preg_match('/,/', $to)) {
        die("Sharing with more than one recipient is not yet implemented. :-(");
    }
    # FIXME: not graceful.
    $result = mail($to, $subject, $message, "From: {$from}");
    if ($result) {
        redirect('topic.php?id=' . $id . '&shared_with=' . urlencode($to));
    } else {
        redirect('topic.php?id=' . $id . '&share_failed=true');
    }