Esempio n. 1
0
}
$filename = md5(sprintf('%s-%s-%d-%d', $feed_type, $orderby, $proj->id, $max_items) . $conf['general']['cookiesalt']);
$cachefile = sprintf('%s/%s', FS_CACHE_DIR, $filename);
// Get the time when a task has been changed last
$db->setLimit($max_items);
$sql = $db->query("SELECT  t.date_opened, t.date_closed, t.last_edited_time\n                     FROM  {tasks}    t\n                    WHERE  {$closed} AND {$sql_project}\n                 ORDER BY  {$orderby} DESC");
$most_recent = 0;
while ($row = $sql->fetchRow()) {
    $most_recent = max($most_recent, $row['date_opened'], $row['date_closed'], $row['last_edited_time']);
}
$content = $db->x->GetOne("SELECT  content\n                             FROM  {cache} t\n                            WHERE  type = ? AND topic = ? AND {$sql_project}\n                                   AND max_items = ?  AND last_updated >= ?", null, array($feed_type, $topic . $user->id, $max_items, $most_recent));
if ($content) {
    echo $content;
    exit;
}
/* build a new feed if cache didn't work */
$db->setLimit($max_items);
$task_details = $db->x->getAll("SELECT  t.task_id, t.item_summary, t.detailed_desc, t.date_opened, t.date_closed,\n                                 t.last_edited_time, t.opened_by, u.real_name, u.email_address, u.show_contact, t.*, p.project_prefix\n                           FROM  {tasks}    t\n                     INNER JOIN  {users}    u ON t.opened_by = u.user_id\n                     INNER JOIN  {projects} p ON t.project_id = p.project_id\n                          WHERE  {$closed} AND {$sql_project}\n                       ORDER BY  {$orderby} DESC");
$task_details = array_filter($task_details, array($user, 'can_view_task'));
$feed_description = $proj->prefs['feed_description'] ? $proj->prefs['feed_description'] : $fs->prefs['page_title'] . $proj->prefs['project_title'] . ': ' . $title;
$feed_image = false;
if ($proj->prefs['feed_img_url'] && !strncmp($proj->prefs['feed_img_url'], 'http://', 7)) {
    $feed_image = $proj->prefs['feed_img_url'];
}
$page->uses('most_recent', 'feed_description', 'feed_image', 'task_details');
$content = $page->fetch('feed.' . $feed_type . '.tpl');
// cache feed
$fields = array('content' => array('value' => $content), 'type' => array('value' => $feed_type, 'key' => true), 'topic' => array('value' => $topic . $user->id, 'key' => true), 'project_id' => array('value' => $proj->id, 'key' => true), 'max_items' => array('value' => $max_items, 'key' => true), 'last_updated' => array('value' => time()));
$db->Replace('{cache}', $fields);
header('Content-Type: application/xml; charset=utf-8');
echo $content;
Esempio n. 2
0
function tpl_double_select($name, $options, $selected = null, $labelIsValue = false, $updown = true)
{
    static $_id = 0;
    static $tpl = null;
    if (!$tpl) {
        // poor man's cache
        $tpl = new FSTpl();
    }
    settype($selected, 'array');
    settype($options, 'array');
    $tpl->assign('id', '_task_id_' . $_id++);
    $tpl->assign('name', $name);
    $tpl->assign('selected', $selected);
    $tpl->assign('updown', $updown);
    $html = $tpl->fetch('common.dualselect.tpl');
    $selectedones = array();
    $opt1 = '';
    foreach ($options as $value => $label) {
        if (is_array($label) && count($label) >= 2) {
            $value = $label[0];
            $label = $label[1];
        }
        if ($labelIsValue) {
            $value = $label;
        }
        if (in_array($value, $selected)) {
            $selectedones[$value] = $label;
            continue;
        }
        $label = htmlspecialchars($label, ENT_QUOTES, 'utf-8');
        $value = htmlspecialchars($value, ENT_QUOTES, 'utf-8');
        $opt1 .= sprintf('<option title="%2$s" value="%1$s">%2$s</option>', $value, $label);
    }
    $opt2 = '';
    foreach ($selected as $value) {
        if (!isset($selectedones[$value])) {
            continue;
        }
        $label = htmlspecialchars($selectedones[$value], ENT_QUOTES, 'utf-8');
        $value = htmlspecialchars($value, ENT_QUOTES, 'utf-8');
        $opt2 .= sprintf('<option title="%2$s" value="%1$s">%2$s</option>', $value, $label);
    }
    return sprintf($html, $opt1, $opt2);
}