<?php

global $CFG;
// $parameter = the ID number of the user
// Convert $parameter to an integer, see if it exists
$parameter = (int) $parameter;
$feed_offset = optional_param('feed_offset', 0, PARAM_INT);
$numposts = count_records_sql('SELECT count(fp.ident) FROM ' . $CFG->prefix . 'feed_subscriptions fs
                               JOIN ' . $CFG->prefix . 'feed_posts fp ON fp.feed = fs.feed_id
                               WHERE fs.user_id = ?', array($parameter));
if ($posts = get_records_sql('SELECT fp.*,f.name,f.siteurl,f.tagline,f.url AS feedurl FROM ' . $CFG->prefix . 'feed_subscriptions fs
                              JOIN ' . $CFG->prefix . 'feed_posts fp ON fp.feed = fs.feed_id
                              JOIN ' . $CFG->prefix . 'feeds f ON f.ident = fs.feed_id 
                              WHERE fs.user_id = ? ORDER BY fp.added DESC ' . sql_paging_limit($feed_offset, 25), array($parameter))) {
    foreach ($posts as $post) {
        $run_result .= run("rss:view:post", $post);
    }
}
$profile_name = htmlspecialchars(optional_param('profile_name'), ENT_COMPAT, 'utf-8');
if ($numposts - ($feed_offset + 25) > 0) {
    $display_feed_offset = $feed_offset + 25;
    $back = __gettext("Back");
    $run_result .= <<<END
        
        <a href="{$CFG->wwwroot}{$profile_name}/newsclient/all/skip={$display_feed_offset}">&lt;&lt; {$back}</a>
        
END;
}
if ($feed_offset > 0) {
    $display_feed_offset = $feed_offset - 25;
    if ($display_feed_offset < 0) {
예제 #2
0
/**
 * Get a number of records as an ADODB RecordSet.
 *
 * If given, $select is used as the SELECT parameter in the SQL query,
 * otherwise all records from the table are returned.
 * 
 * Other arguments and the return type as for @see function get_recordset. 
 *
 * @uses $CFG
 * @param string $table the table to query.
 * @param string $select A fragment of SQL to be used in a where clause in the SQL call.
 * @param array $values If using placeholder ?s in $select, pass values here.
 * @param string $sort an order to sort the results in (optional, a valid SQL ORDER BY parameter).
 * @param string $fields a comma separated list of fields to return (optional, by default all fields are returned).
 * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
 * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
 * @return mixed an ADODB RecordSet object, or false if an error occured.
 */
function get_recordset_select($table, $select = '', $values = null, $sort = '', $fields = '*', $limitfrom = '', $limitnum = '')
{
    global $CFG;
    if ($select) {
        $select = ' WHERE ' . $select;
    }
    if ($limitfrom !== '') {
        $limit = sql_paging_limit($limitfrom, $limitnum);
    } else {
        $limit = '';
    }
    if ($sort) {
        $sort = ' ORDER BY ' . $sort;
    }
    return get_recordset_sql('SELECT ' . $fields . ' FROM ' . $CFG->prefix . $table . $select . $sort . ' ' . $limit, $values);
}
function dcmetadata_search_metadata($searchterms, $courseid, $searchcourseid, $page = 0, $recordsperpage = 50, &$totalcountdc, $extrasql = '')
{
    /// Returns a list of los metadatadc found using an array of search terms
    /// eg   word  +word -word
    ///
    global $CFG, $USER;
    //	require_once('meta_searchlib.php');
    /*
        if (!isteacher($courseid)) {
            $notteacherforum = "AND f.type <> 'teacher'";
            $forummodule = get_record("modules", "name", "forum");
            $onlyvisible = "AND d.forum = f.id AND f.id = cm.instance AND cm.visible = 1 AND cm.module = $forummodule->id";
            $onlyvisibletable = ", {$CFG->prefix}course_modules cm, {$CFG->prefix}forum f";
            if (!empty($sepgroups)) {
                $separategroups = SEPARATEGROUPS;
                $selectgroup = " AND ( NOT (cm.groupmode='$separategroups'".
                                          " OR (c.groupmode='$separategroups' AND c.groupmodeforce='1') )";//.
                $selectgroup .= " OR d.groupid = '-1'"; //search inside discussions for all groups too
                foreach ($sepgroups as $sepgroup){
                    $selectgroup .= " OR d.groupid = '$sepgroup->id'";
                }
                $selectgroup .= ")";
    
                                   //  " OR d.groupid = '$groupid')";
                $selectcourse = " AND d.course = '$courseid' AND c.id='$courseid'";
                $coursetable = ", {$CFG->prefix}course c";
            } else {
                $selectgroup = '';
                $selectcourse = " AND d.course = '$courseid'";
                $coursetable = '';
            }
        } else { */
    //$notteacherforum = "";
    //$selectgroup = '';
    //$onlyvisible = "";
    //$onlyvisibletable = "";
    //$coursetable = '';
    //if ($courseid == SITEID && isadmin()) {
    if ($searchcourseid == '9999') {
        $mycourses = get_my_courses($USER->id);
        foreach ($mycourses as $mycourse) {
            $mcstring = $mcstring . " d.course = '{$mycourse->id}' OR";
        }
        $mcstringfinal = meta_cut_final($mcstring);
        $selectcourse = " AND" . $mcstringfinal;
    } elseif ($searchcourseid == '0') {
        $selectcourse = '';
    } elseif (!$searchcourseid == '9999' | !$searchcourseid == '0' | !empty($searchcourseid)) {
        $selectcourse = " AND d.course = '{$searchcourseid}'";
    } else {
        if ($courseid == SITEID) {
            $selectcourse = '';
        } else {
            $selectcourse = " AND d.course = '{$courseid}'";
        }
    }
    $timelimit = '';
    //    if (!empty($CFG->forum_enabletimedposts) && (!((isadmin() and !empty($CFG->admineditalways)) || isteacher($courseid)))) {
    //if ((!((isadmin() and !empty($CFG->admineditalways)) || isteacher($courseid)))) {
    $now = time();
    //        $timelimit = " AND (d.userid = $USER->id OR ((d.timestart = 0 OR d.timestart <= $now) AND (d.timeend = 0 OR d.timeend > $now)))";
    $timelimit = " AND (d.userid = {$USER->id} OR ((d.timemodified = 0 OR d.timemodified <= {$now}) AND (d.timemodified = 0 OR d.timemodified > {$now})))";
    //     $timelimit = " AND ((d.timemodified <= $now) OR (d.timemodified > $now)))";
    //    }
    $limit = sql_paging_limit($page, $recordsperpage);
    /// Some differences in syntax for PostgreSQL
    if ($CFG->dbtype == "postgres7") {
        $LIKE = "ILIKE";
        // case-insensitive
        $NOTLIKE = "NOT ILIKE";
        // case-insensitive
        $REGEXP = "~*";
        $NOTREGEXP = "!~*";
    } else {
        $LIKE = "LIKE";
        $NOTLIKE = "NOT LIKE";
        $REGEXP = "REGEXP";
        $NOTREGEXP = "NOT REGEXP";
    }
    $metasearch = "";
    $searchstring = "";
    // Need to concat these back together for parser to work.
    foreach ($searchterms as $searchterm) {
        if ($searchstring != "") {
            $searchstring .= " ";
        }
        $searchstring .= $searchterm;
    }
    // We need to allow quoted strings for the search. The quotes *should* be stripped
    // by the parser, but this should be examined carefully for security implications.
    $searchstring = str_replace("\\\"", "\"", $searchstring);
    $parser = new search_parser();
    $lexer = new search_lexer($parser);
    if ($lexer->parse($searchstring)) {
        $parsearray = $parser->get_parsed_array();
        //search_generate_sql($parsetree, $datafield, $metafield, $mainidfield, $useridfield,$userfirstnamefield, $userlastnamefield, $timefield, $instancefield)
        //$messagesearch = search_generate_SQL($parsearray,'p.message','p.subject','p.userid','u.id','u.firstname','u.lastname','p.modified', 'd.forum');
        $metasearch = metasearch_generate_SQL($parsearray, 'd.title', 'd.alternative', 'd.type', 'd.format', 'd.audience', 'd.instructionalMethod', 'd.subject', 'd.description', 'd.abstract', 'd.tableOfContents', 'd.bibliographicCitation', 'd.coverage', 'd.creator', 'd.publisher', 'd.contributor', 'd.userid', 'd.timemodified', '');
    }
    //'cm.modnameid','d.timemodified','d.course');
    /*
        $selectsql = "{$CFG->prefix}forum_posts p,
                      {$CFG->prefix}forum_discussions d,
                      {$CFG->prefix}user u $onlyvisibletable $coursetable
                 WHERE ($messagesearch)
                   AND p.userid = u.id
                   AND p.discussion = d.id $selectcourse $notteacherforum $onlyvisible $selectgroup $timelimit $extrasql";
    
        $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
    
        return get_records_sql("SELECT p.*,d.forum, u.firstname,u.lastname,u.email,u.picture FROM
                                $selectsql ORDER BY p.modified DESC $limit");
    */
    $selectsql = "{$CFG->prefix}metadatadc d\r\n             WHERE ({$metasearch})\r\n               \t\t{$selectcourse} {$extrasql}";
    //AND cm.course = d.course AND d.resource = cm.modnameid $selectcourse $extrasql";				  {$CFG->prefix}course_module cm
    $totalcountdc = count_records_sql("SELECT COUNT(*) FROM {$selectsql}");
    return get_records_sql("SELECT d.* FROM\r\n                            {$selectsql} ORDER BY d.course, d.timemodified DESC {$limit}");
}
예제 #4
0
            </form>
        
END;
if (empty($search_sql)) {
    $formatted_filter = $db->qstr($filter);
    if (empty($filter)) {
        $search_sql = "SELECT u.ident, u.username, u.name, u.icon, u.user_type, COUNT(m.ident) AS members FROM `" . $CFG->prefix . "users` u JOIN " . $CFG->prefix . "friends m ON m.friend = u.ident WHERE " . $usertypefilter . " GROUP BY u.ident ORDER BY members DESC, name DESC";
        $count_sql = "SELECT COUNT(DISTINCT u.ident) AS numberofusers, COUNT(m.ident) AS members FROM `" . $CFG->prefix . "users` u JOIN " . $CFG->prefix . "friends m ON m.friend = u.ident WHERE " . $usertypefilter . "";
    } else {
        if (empty($searchtype)) {
            $search_sql = "SELECT u.ident, u.username, u.name, u.icon, u.user_type, COUNT(m.ident) AS members FROM " . $CFG->prefix . "tags t JOIN " . $CFG->prefix . "users u ON u.ident = t.owner JOIN " . $CFG->prefix . "friends m ON m.friend = u.ident WHERE ({$access_string}) AND t.tag = {$formatted_filter} AND " . $usertypefilter . " GROUP BY u.ident ORDER BY members DESC, name DESC";
            $count_sql = "SELECT COUNT(DISTINCT u.ident) AS numberofusers, COUNT(m.ident) AS members FROM " . $CFG->prefix . "tags t JOIN " . $CFG->prefix . "users u ON u.ident = t.owner JOIN " . $CFG->prefix . "friends m ON m.friend = u.ident WHERE ({$access_string}) AND t.tag = {$formatted_filter} AND " . $usertypefilter . "";
        }
    }
}
$search_sql .= sql_paging_limit($offset, $CFG->browser_search_results);
if ($results = get_records_sql($search_sql)) {
    if ($displayicons) {
        $icontoggle = "<a href=\"index.php?display={$display}&amp;searchtype={$searchtype}&amp;filter={$filter}&amp;displayicons=0\">Hide icons</a>";
    } else {
        $icontoggle = "<a href=\"index.php?display={$display}&amp;searchtype={$searchtype}&amp;filter={$filter}&amp;displayicons=1\">Show icons</a>";
    }
    $name = __gettext("Name");
    $description = __gettext("Description");
    $connections = __gettext("Connections");
    $posts = __gettext("Posts");
    $type = __gettext("Type");
    $body .= <<<END
            
            <table id="search_table" cellpadding="0" cellspacing="0">
                <tr>
<?php

global $CFG;
// $parameter = the ID number of the feed
// Convert $parameter to an integer, see if it exists
$parameter = (int) $parameter;
// If the feed offset hasn't been set, it's 0
$feed_offset = optional_param('feed_offset', 0, PARAM_INT);
$numposts = count_records_sql('SELECT COUNT(fp.ident) FROM ' . $CFG->prefix . 'feed_posts fp
                               JOIN ' . $CFG->prefix . 'feeds f ON f.ident = fp.feed
                               WHERE f.ident = ?', array($parameter));
if ($posts = get_records_sql('SELECT fp.*,f.name,f.siteurl,f.tagline FROM ' . $CFG->prefix . 'feed_posts fp
                              JOIN ' . $CFG->prefix . 'feeds f ON f.ident = fp.feed
                              WHERE f.ident = ? ORDER BY fp.added DESC, fp.ident ASC ' . sql_paging_limit($feed_offset, '25'), array($parameter))) {
    foreach ($posts as $post) {
        $run_result .= run("rss:view:post", $post);
    }
}
if ($numposts - ($feed_offset + 25) > 0) {
    $display_feed_offset = $feed_offset + 25;
    $back = __gettext("Back");
    $run_result .= <<<END
        
                <a href="{$CFG->wwwroot}_rss/individual.php?feed={$parameter}&amp;feed_offset={$display_feed_offset}">&lt;&lt; {$back}</a>
                
END;
}
if ($feed_offset > 0) {
    $display_feed_offset = $feed_offset - 25;
    if ($display_feed_offset < 0) {
        $display_feed_offset = 0;
 function get_images_listing($catid, $sort = 'name', $dir = 'ASC', $page = 0, $fields = '*')
 {
     global $CFG;
     $limit = sql_paging_limit($page, $this->module->imagesperpage);
     $select = 'galleryid = ' . $this->module->id . ' AND ';
     $select .= 'categoryid = ' . intval($catid);
     if ($sort) {
         if ($sort == 'date') {
             $sort = 'timemodified';
         }
         $sort = ' ORDER BY ' . $sort . ' ' . $dir;
     }
     $fields = 'id, galleryid, categoryid, userid, name, size, ' . 'mime, width, height, path, description';
     return get_records_sql("SELECT {$fields}\n                                FROM\n                                  {$CFG->prefix}imagegallery_images\n                                WHERE {$select} {$sort} {$limit}");
 }
예제 #7
0
function widget_for_user_paginated($user_id, $location = NULL, $location_id = NULL, $column = NULL, $offset = 0, $count = 0)
{
    $widgets = get_records_sql(widget_for_user_sql($user_id, $location, $location_id, $column) . sql_paging_limit($offset, $count));
    // Return them
    return $widgets;
}
예제 #8
0
        if ($messagestemp[$i]) {
            $messages[] = $messagestemp[$i];
        }
    }
} else {
    if ($message) {
        //actualizar a leido
        $updatemessage = new object();
        $updatemessage->id = $message->id;
        $updatemessage->leido = 1;
        update_record('mail_messages', $updatemessage);
        $listtousers = mail_get_list_to_users($course->id, $message->id);
    } else {
        if ($id) {
            //si no se ha puesto ningun $m y tampoco $f, pero si $id, se muestran los mensajes eliminados
            $limit = sql_paging_limit($page, $perpage);
            $numtotalmessages = mail_get_messages_delete($mail->id, $USER->id);
            if (!($messages_all = get_records_sql("SELECT * FROM {$CFG->prefix}mail_messages WHERE mailid={$mail->id} and userid={$USER->id} and borrado=1"))) {
                $messages_all = array();
                $messages = array();
            }
            foreach ($messages_all as $message_all) {
                $messagetemp = new object();
                $messagetemp->id = $message_all->id;
                $messagetemp->mailid = $message_all->mailid;
                $messagetemp->userid = $message_all->userid;
                $messagetemp->mark = mail_print_mark_message_sort($message_all->leido, $message_all->responded);
                $messagetemp->fromid = $message_all->fromid;
                $messagetemp->fromtext = mail_print_name_user_message_sort($message_all->fromid);
                $messagetemp->totext = mail_get_list_to_users_sort($message_all->id);
                $messagetemp->folderid = $message_all->folderid;
function metadatadc_search_metadatadc($searchterms, $courseid, $page = 0, $recordsperpage = 50, &$totalcount, $sepgroups = 0, $extrasql = '')
{
    /// Returns a list of posts found using an array of search terms
    /// eg   word  +word -word
    ///
    global $CFG, $USER;
    require_once $CFG->libdir . '/searchlib.php';
    /*    if (!isteacher($courseid)) {
            $notteacherforum = "AND f.type <> 'teacher'";
            $forummodule = get_record("modules", "name", "forum");
            $onlyvisible = "AND d.forum = f.id AND f.id = cm.instance AND cm.visible = 1 AND cm.module = $forummodule->id";
            $onlyvisibletable = ", {$CFG->prefix}course_modules cm, {$CFG->prefix}forum f";
            if (!empty($sepgroups)) {
                $separategroups = SEPARATEGROUPS;
                $selectgroup = " AND ( NOT (cm.groupmode='$separategroups'".
                                          " OR (c.groupmode='$separategroups' AND c.groupmodeforce='1') )";//.
                $selectgroup .= " OR d.groupid = '-1'"; //search inside discussions for all groups too
                foreach ($sepgroups as $sepgroup){
                    $selectgroup .= " OR d.groupid = '$sepgroup->id'";
                }
                $selectgroup .= ")";
    
                                   //  " OR d.groupid = '$groupid')";
                $selectcourse = " AND d.course = '$courseid' AND c.id='$courseid'";
                $coursetable = ", {$CFG->prefix}course c";
            } else {
                $selectgroup = '';
                $selectcourse = " AND d.course = '$courseid'";
                $coursetable = '';
            }
        } else {
            $notteacherforum = "";
            $selectgroup = '';
            $onlyvisible = "";
            $onlyvisibletable = "";
            $coursetable = '';
            if ($courseid == SITEID && isadmin()) {
                $selectcourse = '';
            } else {
                $selectcourse = " AND d.course = '$courseid'";
            }
        }
    
        $timelimit = '';
        if (!empty($CFG->forum_enabletimedposts) && (!((isadmin() and !empty($CFG->admineditalways)) || isteacher($courseid)))) {
            $now = time();
            $timelimit = " AND (d.userid = $USER->id OR ((d.timestart = 0 OR d.timestart <= $now) AND (d.timeend = 0 OR d.timeend > $now)))";
        }
    */
    $limit = sql_paging_limit($page, $recordsperpage);
    /// Some differences in syntax for PostgreSQL
    if ($CFG->dbtype == "postgres7") {
        $LIKE = "ILIKE";
        // case-insensitive
        $NOTLIKE = "NOT ILIKE";
        // case-insensitive
        $REGEXP = "~*";
        $NOTREGEXP = "!~*";
    } else {
        $LIKE = "LIKE";
        $NOTLIKE = "NOT LIKE";
        $REGEXP = "REGEXP";
        $NOTREGEXP = "NOT REGEXP";
    }
    $messagesearch = "";
    $searchstring = "";
    // Need to concat these back together for parser to work.
    foreach ($searchterms as $searchterm) {
        if ($searchstring != "") {
            $searchstring .= " ";
        }
        $searchstring .= $searchterm;
    }
    // We need to allow quoted strings for the search. The quotes *should* be stripped
    // by the parser, but this should be examined carefully for security implications.
    $searchstring = str_replace("\\\"", "\"", $searchstring);
    $parser = new search_parser();
    $lexer = new search_lexer($parser);
    if ($lexer->parse($searchstring)) {
        $parsearray = $parser->get_parsed_array();
        $messagesearch = search_generate_SQL($parsearray, 'p.message', 'p.subject', 'p.userid', 'u.id', 'u.firstname', 'u.lastname', 'p.modified', 'd.metadatadc');
    }
    $selectsql = "{$CFG->prefix}metadatadc d,\r\n                  {$CFG->prefix}user u {$onlyvisibletable} {$coursetable}\r\n             WHERE ({$messagesearch})\r\n               AND p.userid = u.id\r\n               AND p.discussion = d.id {$selectcourse} {$notteacherforum} {$onlyvisible} {$selectgroup} {$timelimit} {$extrasql}";
    $totalcount = count_records_sql("SELECT COUNT(*) FROM {$selectsql}");
    return get_records_sql("SELECT p.*,d.forum, u.firstname,u.lastname,u.email,u.picture FROM\r\n                            {$selectsql} ORDER BY p.modified DESC {$limit}");
}