Exemple #1
0
function journo_collectData($journo, $quick_n_nasty = false)
{
    $data = $journo;
    if ($data['fake'] == 't') {
        $data['fake'] = True;
    }
    $data['quick_n_nasty'] = $quick_n_nasty;
    if (!$quick_n_nasty) {
        $slowdata = journo_calculateSlowData($journo);
        $data = $data + $slowdata;
    }
    $data['rssurl'] = journoRSS($journo);
    $data['bios'] = journo_fetchBios($journo['id']);
    $data['picture'] = journo_getThumbnail($journo['id']);
    /* contact details */
    $guessed = null;
    $known = fetchJournoEmail($journo);
    if (!is_null($known)) {
        /* if there is an email address, but it is blank, don't display _anything_ */
        if ($known['email'] == '') {
            $known = null;
        }
    } else {
        if (!$quick_n_nasty) {
            $guessed = journo_guessContactDetails($journo, $data['guessed_main_org']);
        }
    }
    $data['address'] = db_getOne("SELECT address FROM journo_address WHERE journo_id=?", $journo['id']);
    $data['phone_number'] = db_getOne("SELECT phone_number FROM journo_phone WHERE journo_id=?", $journo['id']);
    $data['known_email'] = $known;
    $data['guessed'] = $guessed;
    $data['twitter_id'] = journo_fetchTwitterID($journo['id']);
    if ($data['twitter_id']) {
        $data['twitter_url'] = 'http://twitter.com/' . urlencode($data['twitter_id']);
    } else {
        $data['twitter_url'] = NULL;
    }
    /* assorted bio things */
    $data['employers'] = journo_collectEmployment($journo['id']);
    $data['education'] = journo_collectEducation($journo['id']);
    $data['awards'] = journo_collectAwards($journo['id']);
    $data['books'] = db_getAll("SELECT * FROM journo_books WHERE journo_id=? ORDER BY year_published DESC", $journo['id']);
    /* admired journos */
    $sql = <<<EOT
SELECT a.admired_name AS prettyname, j.ref, j.oneliner
    FROM (journo_admired a LEFT JOIN journo j ON j.id=a.admired_id)
    WHERE a.journo_id=?
EOT;
    $data['admired'] = db_getAll($sql, $journo['id']);
    /* journos who admire this one */
    $sql = <<<EOT
SELECT j.prettyname, j.ref, j.oneliner
    FROM (journo_admired a LEFT JOIN journo j ON j.id=a.journo_id)
    WHERE a.admired_id=?
EOT;
    $data['admired_by'] = db_getAll($sql, $journo['id']);
    $data['num_alerts'] = (int) db_getOne("SELECT count(*) FROM alert WHERE journo_id=?", $journo['id']);
    $data['num_views_week'] = (int) db_getOne("SELECT num_views_week FROM journo_pageviews WHERE journo_id=?", $journo['id']);
    $data['articles'] = journo_collectArticles($journo);
    $data['more_articles'] = true;
    /*links*/
    $sql = "SELECT id, url, description, kind " . "FROM journo_weblink " . "WHERE journo_id=? " . "AND approved ORDER BY rank DESC";
    $links = db_getAll($sql, $journo['id']);
    foreach ($links as &$l) {
        $l['description'] = journo_describeWeblink($journo, $l);
    }
    unset($l);
    $links = array_merge($links, journo_getBioLinks($journo));
    $data['links'] = $links;
    /* similar journos */
    $sql = <<<EOT
SELECT j.prettyname, j.ref, j.oneliner
    FROM (journo_similar s INNER JOIN journo j ON j.id=s.other_id)
    WHERE s.journo_id=?
    ORDER BY s.score DESC
    LIMIT 10
EOT;
    $data['similar_journos'] = db_getAll($sql, $journo['id']);
    return $data;
}
Exemple #2
0
    if (db_getOne("SELECT id FROM person_permission WHERE person_id=? AND ((journo_id=? AND permission='edit') OR permission='admin')", $P->id(), $journo['id'])) {
        $can_edit_page = TRUE;
    }
}
// if journo is not active, only allow viewing if logged-in user can edit page
if ($journo['status'] == 'i') {
    // activate journo if they've met the requirements
    if (journo_checkActivation($journo['id'])) {
        $journo['status'] = 'a';
    }
}
if ($journo['status'] != 'a' && !$can_edit_page) {
    spew_404($ref);
    exit(1);
}
$pageparams = array('rss' => array('Recent Articles' => journoRSS($journo)), 'head_extra_fn' => 'extra_head', 'pingbacks' => TRUE);
if (get_http_var('allarticles') == 'yes') {
    $title = "All articles by " . $journo['prettyname'];
    page_header($title, $pageparams);
    ?>
<div class="main">
<?php 
    journo_emitAllArticles($journo);
    ?>
</div>
<?php 
    page_footer();
    exit;
}
// UGH!
if ($journo['status'] == 'a') {