예제 #1
0
파일: rsslib.php 프로젝트: nmicha/moodle
/**
 * Generates the SQL query used to get the Post details from the forum table of the database
 *
 * @param stdClass $forum     the forum object
 * @param stdClass $cm        Course Module object
 * @param int      $newsince  check for items since this epoch timestamp
 * @return string the SQL query to be used to get the Post details from the forum table of the database
 */
function forum_rss_feed_posts_sql($forum, $cm, $newsince = 0)
{
    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
    //get group enforcement SQL
    $groupmode = groups_get_activity_groupmode($cm);
    $currentgroup = groups_get_activity_group($cm);
    $groupselect = forum_rss_get_group_sql($cm, $groupmode, $currentgroup, $modcontext);
    if ($groupmode && $currentgroup) {
        $params['groupid'] = $currentgroup;
    }
    //do we only want new posts?
    if ($newsince) {
        $newsince = " AND p.modified > '{$newsince}'";
    } else {
        $newsince = '';
    }
    $sql = "SELECT p.id AS postid,\n                 d.id AS discussionid,\n                 d.name AS discussionname,\n                 u.id AS userid,\n                 u.firstname AS userfirstname,\n                 u.lastname AS userlastname,\n                 p.subject AS postsubject,\n                 p.message AS postmessage,\n                 p.created AS postcreated,\n                 p.messageformat AS postformat,\n                 p.messagetrust AS posttrust\n            FROM {forum_discussions} d,\n               {forum_posts} p,\n               {user} u\n            WHERE d.forum = {$forum->id} AND\n                p.discussion = d.id AND\n                u.id = p.userid {$newsince}\n                {$groupselect}\n            ORDER BY p.created desc";
    return $sql;
}
예제 #2
0
파일: rsslib.php 프로젝트: verbazend/AWFA
/**
 * Generates the SQL query used to get the Post details from the forum table of the database
 *
 * @param stdClass $forum     the forum object
 * @param stdClass $cm        Course Module object
 * @param int      $newsince  check for items since this epoch timestamp
 * @return string the SQL query to be used to get the Post details from the forum table of the database
 */
function forum_rss_feed_posts_sql($forum, $cm, $newsince=0) {
    $modcontext = context_module::instance($cm->id);

    // Get group enforcement SQL.
    $groupmode = groups_get_activity_groupmode($cm);
    $currentgroup = groups_get_activity_group($cm);
    $params = array();

    list($groupselect, $groupparams) = forum_rss_get_group_sql($cm, $groupmode, $currentgroup, $modcontext);

    // Add the groupparams to the params array.
    $params = array_merge($params, $groupparams);

    // Do we only want new posts?
    if ($newsince) {
        $params['newsince'] = $newsince;
        $newsince = " AND p.modified > :newsince";
    } else {
        $newsince = '';
    }

    $sql = "SELECT p.id AS postid,
                 d.id AS discussionid,
                 d.name AS discussionname,
                 d.groupid,
                 d.timestart,
                 d.timeend,
                 u.id AS userid,
                 u.firstname AS userfirstname,
                 u.lastname AS userlastname,
                 p.subject AS postsubject,
                 p.message AS postmessage,
                 p.created AS postcreated,
                 p.messageformat AS postformat,
                 p.messagetrust AS posttrust,
                 p.parent as postparent
            FROM {forum_discussions} d,
               {forum_posts} p,
               {user} u
            WHERE d.forum = {$forum->id} AND
                p.discussion = d.id AND
                u.id = p.userid $newsince
                $groupselect
            ORDER BY p.created desc";

    return array($sql, $params);
}
예제 #3
0
파일: rsslib.php 프로젝트: covex-nn/moodle
/**
 * Generates the SQL query used to get the Post details from the forum table of the database
 *
 * @param stdClass $forum     the forum object
 * @param stdClass $cm        Course Module object
 * @param int      $newsince  check for items since this epoch timestamp
 * @return string the SQL query to be used to get the Post details from the forum table of the database
 */
function forum_rss_feed_posts_sql($forum, $cm, $newsince = 0)
{
    $modcontext = context_module::instance($cm->id);
    // Get group enforcement SQL.
    $groupmode = groups_get_activity_groupmode($cm);
    $currentgroup = groups_get_activity_group($cm);
    $params = array();
    list($groupselect, $groupparams) = forum_rss_get_group_sql($cm, $groupmode, $currentgroup, $modcontext);
    // Add the groupparams to the params array.
    $params = array_merge($params, $groupparams);
    // Do we only want new posts?
    if ($newsince) {
        $params['newsince'] = $newsince;
        $newsince = " AND p.modified > :newsince";
    } else {
        $newsince = '';
    }
    $usernamefields = get_all_user_name_fields(true, 'u');
    $sql = "SELECT p.id AS postid,\n                 d.id AS discussionid,\n                 d.name AS discussionname,\n                 u.id AS userid,\n                 {$usernamefields},\n                 p.subject AS postsubject,\n                 p.message AS postmessage,\n                 p.created AS postcreated,\n                 p.messageformat AS postformat,\n                 p.messagetrust AS posttrust\n            FROM {forum_discussions} d,\n               {forum_posts} p,\n               {user} u\n            WHERE d.forum = {$forum->id} AND\n                p.discussion = d.id AND\n                u.id = p.userid {$newsince}\n                {$groupselect}\n            ORDER BY p.created desc";
    return array($sql, $params);
}