コード例 #1
0
function topic($company_sfnid, $topic_id)
{
    $url = $topic_id;
    $feed_raw = get_url($url, false);
    if (!$feed_raw) {
        throw new Exception("Failed to load topic feed at {$url}.");
    }
    try {
        $topic_feed = new XML_Feed_Parser($feed_raw);
        if (!$topic_feed) {
            throw new Exception("Invalid feed at {$url}");
        }
    } catch (XML_Feed_Parser_Exception $e) {
        invalidate_http_cache($url);
        throw new Exception("Invalid feed at {$url}");
    }
    # Add stuff to the raw feed data using fix_atom_entry
    $items = array();
    foreach ($topic_feed as $entry) {
        $item = fix_atom_entry($entry, 'reply');
        array_push($items, $item);
    }
    # Collect information about the participants in this topic
    $authors = array();
    $employees = array();
    foreach ($items as $item) {
        $authors[$item['author']['uri']]++;
        list($role, $role_name) = get_person_role($company_sfnid, $item['author']['uri']);
        if ($role) {
            $employees[$item['author']['uri']] = $item['author'];
            $employees[$item['author']['uri']]['role'] = $role;
        }
    }
    $official_reps = array();
    foreach ($employees as $emp) {
        $emp_data = get_person($emp['uri']);
        $emp = superimpose($emp, $emp_data);
        if ($emp['role'] == 'company_rep' || $emp['role'] == 'company_admin') {
            array_push($official_reps, $emp);
        }
    }
    $particip = array('people' => count($authors), 'employees' => count($employees), 'official_reps' => $official_reps, 'count_official_reps' => count($official_reps));
    return array('replies' => $items, 'particip' => $particip, 'tags' => $tags);
}
コード例 #2
0
ファイル: Sprinkles.php プロジェクト: nullstyle/helpcenter
 function get_person_role($person_url)
 {
     return get_person_role($this->company_sfnid, $person_url);
 }