コード例 #1
0
ファイル: comment.php プロジェクト: webhacking/Textcube
function getRecentComments($blogid, $count = false, $isGuestbook = false, $guestShip = false)
{
    $context = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $comments = array();
    $pool->init("Comments");
    if (!(doesHaveOwnership() && !$guestShip)) {
        $pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
    }
    $pool->setAlias("Comments", "r");
    $pool->setAlias("Entries", "e");
    $joint = array(array("r.blogid", "eq", "e.blogid"), array("r.entry", "eq", "e.id"), array("e.draft", "eq", 0));
    if (doesHaveOwnership() && !$guestShip) {
        if (!$isGuestbook && !Acl::check("group.editors")) {
            array_push($joint, array("e.userid", "eq", getUserId()));
        }
        $pool->join("Entries", "inner", $joint);
        $pool->setQualifier("r.blogid", "eq", $blogid);
    } else {
        $pool->setAlias("Categories", "c");
        $pool->join("Entries", "inner", $joint);
        $pool->join("Categories", "left outer", array(array("e.blogid", "eq", "c.blogid"), array("e.category", "eq", "c.id")));
        $pool->setQualifier("r.blogid", "eq", $blogid);
        $pool->setQualifier("e.draft", "eq", 0);
        $pool->setQualifier("e.visibility", ">=", 2);
    }
    if ($isGuestbook != false) {
        $pool->setQualifier("r.entry", "eq", 0);
    } else {
        $pool->setQualifier("r.entry", ">", 0);
    }
    $pool->setQualifier("r.isfiltered", "eq", 0);
    $pool->setOrder("r.written", "desc");
    $pool->setLimit($count != false ? $count : $context->getProperty('skin.commentsOnRecent'));
    if ($result = $pool->getAll("r.*, e.title, e.slogan", array("usedbcache" => true, "dbprefix" => 'comment'))) {
        foreach ($result as $comment) {
            if ($comment['secret'] == 1 && !doesHaveOwnership()) {
                if (!doesHaveOpenIDPriv($comment)) {
                    $comment['name'] = _text('비밀방문자');
                    $comment['homepage'] = '';
                    $comment['comment'] = _text('관리자만 볼 수 있는 댓글입니다.');
                }
            }
            array_push($comments, $comment);
        }
    }
    return $comments;
}
コード例 #2
0
function getRecentRemoteResponses($blogid, $count = false, $guestShip = false, $type = null)
{
    $pool = DBModel::getInstance();
    $context = Model_Context::getInstance();
    $pool->init("RemoteResponses");
    $pool->setAlias("RemoteResponses", "t");
    $pool->setAlias("Entries", "e");
    if (!is_null($type)) {
        $pool->setQualifier("t.responsetype", "eq", $type, true);
    }
    $pool->setQualifier("t.blogid", "eq", $blogid);
    $pool->setQualifier("t.isfiltered", "eq", 0);
    if (doesHaveOwnership() && !$guestShip) {
        $pool->join("Entries", "left", array(array("t.entry", "eq", "e.id"), array("t.blogid", "eq", "e.blogid"), array("e.draft", "eq", 0)));
    } else {
        $pool->join("Entries", "left", array(array("t.entry", "eq", "e.id"), array("t.blogid", "eq", "e.blogid")));
        $pool->setQualifier("e.draft", "eq", 0);
        $pool->setQualifier("e.visibility", ">=", 2);
        $pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
    }
    $pool->setOrder("t.written", "desc");
    $pool->setLimit($count != false ? $count : $context->getProperty('skin.trackbacksOnRecent'));
    if ($result = $pool->getAll('*', array("useDBcache" => true, "cachePrefix" => 'remoteResponse'))) {
        return $result;
    } else {
        return array();
    }
}
コード例 #3
0
ファイル: archive.php プロジェクト: Avantians/Textcube
function getCalendar($blogid, $period)
{
    global $database;
    $skinSetting = Setting::getSkinSettings($blogid);
    $pool = DBModel::getInstance();
    $pool->init("Entries");
    $pool->setAlias("Entries", "e");
    $pool->setQualifier("e.blogid", "eq", $blogid);
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setQualifier("e.category", ">=", 0);
    if (!doesHaveOwnership()) {
        $pool->setQualifier("e.visibility", ">", 0);
        $pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
    }
    $calendar = array('days' => array());
    if ($period === true || !checkPeriod($period)) {
        $period = Timestamp::getYearMonth();
    }
    $calendar['period'] = $period;
    $calendar['year'] = substr($period, 0, 4);
    $calendar['month'] = substr($period, 4, 2);
    switch (POD::dbms()) {
        case 'Cubrid':
            $pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYY')", "eq", $calendar['year'], true);
            $pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'MM')", "eq", $calendar['month'], true);
            $result = $pool->getAll("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'DD')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
        case 'SQLite3':
            $pool->setQualifier("strftime('%Y',e.published,'unixepoch')", "eq", $calendar['year'], true);
            $pool->setQualifier("strftime('%m',e.published,'unixepoch')", "eq", $calendar['month'], true);
            $result = $pool->getAll("strftime('%d',e.published,'unixepoch')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
        case 'MySQL':
        case 'MySQLi':
        case 'PostgreSQL':
        default:
            $pool->setQualifier("YEAR(FROM_UNIXTIME(e.published))", "eq", $calendar['year'], true);
            $pool->setQualifier("MONTH(FROM_UNIXTIME(e.published))", "eq", $calendar['month'], true);
            $result = $pool->getAll("DAYOFMONTH(FROM_UNIXTIME(e.published))", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
    }
    if ($result) {
        foreach ($result as $dayArray) {
            list($day) = $dayArray;
            array_push($calendar['days'], $day);
        }
    }
    $calendar['days'] = array_flip($calendar['days']);
    return $calendar;
}
コード例 #4
0
ファイル: entry.php プロジェクト: ni5am/Textcube
function getRecentEntries($blogid)
{
    $ctx = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $pool->init("Entries");
    $pool->setAlias("Entries", "e");
    $pool->setQualifier("e.blogid", "eq", $blogid);
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setQualifier("e.category", "beq", 0);
    if (!doesHaveOwnership()) {
        $pool->setQualifier("e.visibility", ">", 0);
        $pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
    }
    $pool->setOrder("e.published", "DESC");
    $pool->setLimit($ctx->getProperty('skin.entriesOnRecent'));
    $result = $pool->getAll("e.id, e.userid, e.title, e.slogan, e.comments, e.published");
    if ($result) {
        return $result;
    } else {
        return array();
    }
}