Example #1
0
/**
 *  This function is in lib and not in BlogInfo because entries being searched
 *   might be found in any number of blogs rather than just one.
 *
 *   $@param ...
 */
function blog_print_html_formatted_entries($postid, $filtertype, $filterselect, $tagid, $tag)
{
    global $CFG, $USER, $OUTPUT;
    $blogpage = optional_param('blogpage', 0, PARAM_INT);
    $bloglimit = optional_param('limit', get_user_preferences('blogpagesize', 10), PARAM_INT);
    $start = $blogpage * $bloglimit;
    $sitecontext = get_context_instance(CONTEXT_SYSTEM);
    $morelink = '<br />&nbsp;&nbsp;';
    $totalentries = get_viewable_entry_count($postid, $bloglimit, $start, $filtertype, $filterselect, $tagid, $tag, $sort = 'created DESC');
    $blogEntries = blog_fetch_entries($postid, $bloglimit, $start, $filtertype, $filterselect, $tagid, $tag, $sort = 'created DESC', true);
    $pagingbar = moodle_paging_bar::make($totalentries, $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect));
    $pagingbar->pagevar = 'blogpage';
    echo $OUTPUT->paging_bar($pagingbar);
    if ($CFG->enablerssfeeds) {
        blog_rss_print_link($filtertype, $filterselect, $tag);
    }
    if (has_capability('moodle/blog:create', $sitecontext)) {
        //the user's blog is enabled and they are viewing their own blog
        $addlink = '<div class="addbloglink">';
        $addlink .= '<a href="' . $CFG->wwwroot . '/blog/edit.php?action=add' . '">' . get_string('addnewentry', 'blog') . '</a>';
        $addlink .= '</div>';
        echo $addlink;
    }
    if ($blogEntries) {
        $count = 0;
        foreach ($blogEntries as $blogEntry) {
            blog_print_entry($blogEntry, 'list', $filtertype, $filterselect);
            //print this entry.
            $count++;
        }
        $pagingbar = moodle_paging_bar::make($totalentries, $blogpage, $bloglimit, get_baseurl($filtertype, $filterselect));
        $pagingbar->pagevar = 'blogpage';
        echo $OUTPUT->paging_bar($pagingbar);
        if (!$count) {
            print '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />';
        }
        print $morelink . '<br />' . "\n";
        return;
    }
    $output = '<br /><div style="text-align:center">' . get_string('noentriesyet', 'blog') . '</div><br />';
    print $output;
}
Example #2
0
    }
}
/// Print out all the courses
$courses = get_courses_page($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible,c.guest,c.password', $totalcount, $page * $perpage, $perpage);
$numcourses = count($courses);
if (!$courses) {
    if (empty($subcategorieswereshown)) {
        echo $OUTPUT->heading(get_string("nocoursesyet"));
    }
} else {
    if ($numcourses <= COURSE_MAX_SUMMARIES_PER_PAGE and !$page and !$editingon) {
        echo $OUTPUT->box_start('courseboxes');
        print_courses($category);
        echo $OUTPUT->box_end();
    } else {
        echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "category.php?id={$category->id}&perpage={$perpage}"));
        $strcourses = get_string('courses');
        $strselect = get_string('select');
        $stredit = get_string('edit');
        $strdelete = get_string('delete');
        $strbackup = get_string('backup');
        $strrestore = get_string('restore');
        $strmoveup = get_string('moveup');
        $strmovedown = get_string('movedown');
        $strupdate = get_string('update');
        $strhide = get_string('hide');
        $strshow = get_string('show');
        $strsummary = get_string('summary');
        $strsettings = get_string('settings');
        $strassignteachers = get_string('assignteachers');
        $strallowguests = get_string('allowguests');
Example #3
0
     echo '</form>';
 } else {
     if (!empty($list['path'])) {
         foreach ($list['path'] as $p) {
             echo '<form method="post" style="display:inline">';
             echo '<input type="hidden" name="p" value="' . $p['path'] . '"';
             echo '<input type="hidden" name="action" value="list"';
             echo '<input type="submit" value="' . $p['name'] . '" />';
             echo '</form>';
             echo '<strong> / </strong>';
         }
     }
     if (!empty($list['page'])) {
         // TODO: need a better solution
         $pagingurl = new moodle_url("{$CFG->httpswwwroot}/repository/filepicker.php?action=list&itemid={$itemid}&ctx_id={$ctx_id}&repo_id={$repo_id}");
         echo $OUTPUT->paging_bar(moodle_paging_bar::make($list['total'], $list['page'] - 1, $list['perpage'], $pagingurl));
     }
     echo '<table>';
     foreach ($list['list'] as $item) {
         echo '<tr>';
         echo '<td><img src="' . $item['thumbnail'] . '" />';
         echo '</td><td>';
         if (!empty($item['url'])) {
             echo '<a href="' . $item['url'] . '" target="_blank">' . $item['title'] . '</a>';
         } else {
             echo $item['title'];
         }
         echo '</td>';
         echo '<td>';
         if (!isset($item['children'])) {
             echo '<form method="post">';
Example #4
0
            echo '<li ' . $class . '>';
            echo '<a ' . $class . ' href="' . $CFG->wwwroot . '/blog/index.php?postid=' . $blog->id . '">';
            echo format_string($blog->subject);
            echo '</a>';
            echo ' - ';
            echo '<a ' . $class . ' href="' . $CFG->wwwroot . '/user/view.php?id=' . $blog->userid . '">';
            echo fullname($blog);
            echo '</a>';
            echo ', ' . userdate($blog->lastmodified);
            echo '</li>';
        }
        echo '</ul>';
        echo '<p class="moreblogs"><a href="' . $CFG->wwwroot . '/blog/index.php?filtertype=site&amp;filterselect=0&amp;tagid=' . $tag->id . '">' . get_string('seeallblogs', 'tag', $tagname) . '</a></p>';
        echo $OUTPUT->box_end();
    }
}
$usercount = tag_record_count('user', $tag->id);
if ($usercount > 0) {
    //user table box
    echo $OUTPUT->box_start('generalbox', 'tag-user-table');
    $heading = get_string('users') . ' ' . get_string('taggedwith', 'tag', $tagname) . ': ' . $usercount;
    echo "<a name='user'></a>";
    echo $OUTPUT->heading($heading, 3);
    $baseurl = new moodle_url($CFG->wwwroot . '/tag/index.php', array('id' => $tag->id));
    $pagingbar = moodle_paging_bar::make($totalcount, $page, $perpage, $baseurl);
    $pagingbar->pagevar = 'userpage';
    echo $OUTPUT->paging_bar($pagingbar);
    tag_print_tagged_users_table($tag, $userpage * $perpage, $perpage);
    echo $OUTPUT->box_end();
}
echo $OUTPUT->footer();
Example #5
0
            //send the advanced flag through the URL so it is remembered while paging.
            $baseurl .= 'advanced=' . $advanced . '&amp;';
            if (!empty($search)) {
                $baseurl .= 'filter=1&amp;';
            }
            //pass variable to allow determining whether or not we are paging through results.
            $baseurl .= 'paging=' . $paging . '&amp;';
            echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
            if (empty($data->listtemplate)) {
                echo $OUTPUT->notification(get_string('nolisttemplate', 'data'));
                data_generate_default_template($data, 'listtemplate', 0, false, false);
            }
            echo $data->listtemplateheader;
            data_print_template('listtemplate', $records, $data, $search, $page);
            echo $data->listtemplatefooter;
            echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
        }
    }
}
$search = trim($search);
if (empty($records)) {
    $records = array();
}
//Advanced search form doesn't make sense for single (redirects list view)
if (($maxcount || $mode == 'asearch') && $mode != 'single') {
    data_print_preference_form($data, $perpage, $search, $sort, $order, $search_array, $advanced, $mode);
}
/// Mark as viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
echo $OUTPUT->footer();
Example #6
0
 /**
  * Print comments
  * @param int $page 
  */
 function print_comments($page = 0)
 {
     global $CFG, $OUTPUT, $DB;
     $this->perpage = 10;
     $count = $DB->count_records_sql('SELECT COUNT(*) FROM {comments} c');
     $comments = $this->get_comments($page);
     $table = new html_table();
     $table->head = array('<input type="checkbox" id="comment_select_all"/>', 'author', 'content', 'action');
     $table->align = array('left', 'left', 'left', 'left');
     $table->width = "95%";
     $table->data = array();
     foreach ($comments as $c) {
         $this->_setup_plugin($c);
         if (!empty($this->plugintype)) {
             $url = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'url', array($c));
         }
         $checkbox = '<input type="checkbox" name="comments" value="' . $c->id . '" />';
         $action = '';
         $action .= "<a href='{$CFG->wwwroot}/comment/index.php?action=delete&amp;sesskey=" . sesskey() . "&amp;commentid={$c->id}'>" . get_string('delete') . '</a>';
         $action .= "<br />";
         if (!empty($url)) {
             $action .= "<a target='_blank' href='{$url}'>" . get_string('commentincontext') . '</a>';
         }
         $table->data[] = array($checkbox, $c->username, $c->content, $action);
     }
     echo $OUTPUT->table($table);
     echo $OUTPUT->paging_bar(moodle_paging_bar::make($count, $page, $this->perpage, $CFG->wwwroot . '/comment/index.php'));
 }
Example #7
0
        } else {
            $columndir = 'ASC';
        }
    } else {
        $columndir = $dir == 'ASC' ? 'DESC' : 'ASC';
        if ($column == 'lastaccess') {
            $columnicon = $dir == 'ASC' ? 'up' : 'down';
        } else {
            $columnicon = $dir == 'ASC' ? 'down' : 'up';
        }
        $columnicon = " <img src=\"" . $OUTPUT->old_icon_url('t/' . $columnicon) . "\" alt=\"\" />";
    }
    $hcolumns[$column] = "<a href=\"index.php?sort={$column}&amp;dir={$columndir}&amp;page={$page}&amp;perpage={$perpage}\">" . $strcolumn . "</a>{$columnicon}";
}
$baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
echo $OUTPUT->paging_bar(moodle_paging_bar::make($changescount, $page, $perpage, $baseurl));
$override = new object();
$override->firstname = 'firstname';
$override->lastname = 'lastname';
$fullnamelanguage = get_string('fullnamedisplay', '', $override);
if ($CFG->fullnamedisplay == 'firstname lastname' or $CFG->fullnamedisplay == 'firstname' or $CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname') {
    $fullnamedisplay = $hcolumns['firstname'] . ' / ' . $hcolumns['lastname'];
} else {
    // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname')
    $fullnamedisplay = $hcolumns['lastname'] . ' / ' . $hcolumns['firstname'];
}
$table = new html_table();
$table->head = array($hcolumns['timemodified'], $fullnamedisplay, $hcolumns['plugin'], $hcolumns['name'], $hcolumns['value'], $hcolumns['oldvalue']);
$table->align = array('left', 'left', 'left', 'left', 'left', 'left');
$table->size = array('30%', '10%', '10%', '10%', '20%', '20%');
$table->width = '95%';
Example #8
0
/**
 * Prints the discussion view screen for a forum.
 *
 * @global object
 * @global object
 * @param object $course The current course object.
 * @param object $forum Forum to be printed.
 * @param int $maxdiscussions .
 * @param string $displayformat The display format to use (optional).
 * @param string $sort Sort arguments for database query (optional).
 * @param int $groupmode Group mode of the forum (optional).
 * @param void $unused (originally current group)
 * @param int $page Page mode, page to display (optional).
 * @param int $perpage The maximum number of discussions per page(optional)
 *
 */
function forum_print_latest_discussions($course, $forum, $maxdiscussions = -1, $displayformat = 'plain', $sort = '', $currentgroup = -1, $groupmode = -1, $page = -1, $perpage = 100, $cm = NULL)
{
    global $CFG, $USER, $OUTPUT;
    if (!$cm) {
        if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course))) {
            print_error('invalidcoursemodule');
        }
    }
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (empty($sort)) {
        $sort = "d.timemodified DESC";
    }
    $olddiscussionlink = false;
    // Sort out some defaults
    if ($perpage <= 0) {
        $perpage = 0;
        $page = -1;
    }
    if ($maxdiscussions == 0) {
        // all discussions - backwards compatibility
        $page = -1;
        $perpage = 0;
        if ($displayformat == 'plain') {
            $displayformat = 'header';
            // Abbreviate display by default
        }
    } else {
        if ($maxdiscussions > 0) {
            $page = -1;
            $perpage = $maxdiscussions;
        }
    }
    $fullpost = false;
    if ($displayformat == 'plain') {
        $fullpost = true;
    }
    // Decide if current user is allowed to see ALL the current discussions or not
    // First check the group stuff
    if ($currentgroup == -1 or $groupmode == -1) {
        $groupmode = groups_get_activity_groupmode($cm, $course);
        $currentgroup = groups_get_activity_group($cm);
    }
    // If the user can post discussions, then this is a good place to put the
    // button for it. We do not show the button if we are showing site news
    // and the current user is a guest.
    if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context) || ($forum->type != 'news' and (isguestuser() or !isloggedin() or has_capability('moodle/legacy:guest', $context, NULL, false)))) {
        echo '<div class="singlebutton forumaddnew">';
        echo "<form id=\"newdiscussionform\" method=\"get\" action=\"{$CFG->wwwroot}/mod/forum/post.php\">";
        echo '<div>';
        echo "<input type=\"hidden\" name=\"forum\" value=\"{$forum->id}\" />";
        echo '<input type="submit" value="';
        echo $forum->type == 'news' ? get_string('addanewtopic', 'forum') : ($forum->type == 'qanda' ? get_string('addanewquestion', 'forum') : get_string('addanewdiscussion', 'forum'));
        echo '" />';
        echo '</div>';
        echo '</form>';
        echo "</div>\n";
    } else {
        if (isguestuser() or !isloggedin() or $forum->type == 'news') {
            // no button and no info
        } else {
            if ($groupmode and has_capability('mod/forum:startdiscussion', $context)) {
                // inform users why they can not post new discussion
                if ($currentgroup) {
                    echo $OUTPUT->notification(get_string('cannotadddiscussion', 'forum'));
                } else {
                    echo $OUTPUT->notification(get_string('cannotadddiscussionall', 'forum'));
                }
            }
        }
    }
    // Get all the recent discussions we're allowed to see
    $getuserlastmodified = $displayformat == 'header';
    if (!($discussions = forum_get_discussions($cm, $sort, $fullpost, null, $maxdiscussions, $getuserlastmodified, $page, $perpage))) {
        echo '<div class="forumnodiscuss">';
        if ($forum->type == 'news') {
            echo '(' . get_string('nonews', 'forum') . ')';
        } else {
            if ($forum->type == 'qanda') {
                echo '(' . get_string('noquestions', 'forum') . ')';
            } else {
                echo '(' . get_string('nodiscussions', 'forum') . ')';
            }
        }
        echo "</div>\n";
        return;
    }
    // If we want paging
    if ($page != -1) {
        ///Get the number of discussions found
        $numdiscussions = forum_get_discussions_count($cm);
        ///Show the paging bar
        echo $OUTPUT->paging_bar(moodle_paging_bar::make($numdiscussions, $page, $perpage, "view.php?f={$forum->id}"));
        if ($numdiscussions > 1000) {
            // saves some memory on sites with very large forums
            $replies = forum_count_discussion_replies($forum->id, $sort, $maxdiscussions, $page, $perpage);
        } else {
            $replies = forum_count_discussion_replies($forum->id);
        }
    } else {
        $replies = forum_count_discussion_replies($forum->id);
        if ($maxdiscussions > 0 and $maxdiscussions <= count($discussions)) {
            $olddiscussionlink = true;
        }
    }
    $canviewparticipants = has_capability('moodle/course:viewparticipants', $context);
    $strdatestring = get_string('strftimerecentfull');
    // Check if the forum is tracked.
    if ($cantrack = forum_tp_can_track_forums($forum)) {
        $forumtracked = forum_tp_is_tracked($forum);
    } else {
        $forumtracked = false;
    }
    if ($forumtracked) {
        $unreads = forum_get_discussions_unread($cm);
    } else {
        $unreads = array();
    }
    if ($displayformat == 'header') {
        echo '<table cellspacing="0" class="forumheaderlist">';
        echo '<thead>';
        echo '<tr>';
        echo '<th class="header topic" scope="col">' . get_string('discussion', 'forum') . '</th>';
        echo '<th class="header author" colspan="2" scope="col">' . get_string('startedby', 'forum') . '</th>';
        if ($groupmode > 0) {
            echo '<th class="header group" scope="col">' . get_string('group') . '</th>';
        }
        if (has_capability('mod/forum:viewdiscussion', $context)) {
            echo '<th class="header replies" scope="col">' . get_string('replies', 'forum') . '</th>';
            // If the forum can be tracked, display the unread column.
            if ($cantrack) {
                echo '<th class="header replies" scope="col">' . get_string('unread', 'forum');
                if ($forumtracked) {
                    echo '&nbsp;<a title="' . get_string('markallread', 'forum') . '" href="' . $CFG->wwwroot . '/mod/forum/markposts.php?f=' . $forum->id . '&amp;mark=read&amp;returnpage=view.php">' . '<img src="' . $OUTPUT->old_icon_url('t/clear') . '" class="iconsmall" alt="' . get_string('markallread', 'forum') . '" /></a>';
                }
                echo '</th>';
            }
        }
        echo '<th class="header lastpost" scope="col">' . get_string('lastpost', 'forum') . '</th>';
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';
    }
    foreach ($discussions as $discussion) {
        if (!empty($replies[$discussion->discussion])) {
            $discussion->replies = $replies[$discussion->discussion]->replies;
            $discussion->lastpostid = $replies[$discussion->discussion]->lastpostid;
        } else {
            $discussion->replies = 0;
        }
        // SPECIAL CASE: The front page can display a news item post to non-logged in users.
        // All posts are read in this case.
        if (!$forumtracked) {
            $discussion->unread = '-';
        } else {
            if (empty($USER)) {
                $discussion->unread = 0;
            } else {
                if (empty($unreads[$discussion->discussion])) {
                    $discussion->unread = 0;
                } else {
                    $discussion->unread = $unreads[$discussion->discussion];
                }
            }
        }
        if (!empty($USER->id)) {
            $ownpost = $discussion->userid == $USER->id;
        } else {
            $ownpost = false;
        }
        // Use discussion name instead of subject of first post
        $discussion->subject = $discussion->name;
        switch ($displayformat) {
            case 'header':
                if ($groupmode > 0) {
                    if (isset($groups[$discussion->groupid])) {
                        $group = $groups[$discussion->groupid];
                    } else {
                        $group = $groups[$discussion->groupid] = groups_get_group($discussion->groupid);
                    }
                } else {
                    $group = -1;
                }
                forum_print_discussion_header($discussion, $forum, $group, $strdatestring, $cantrack, $forumtracked, $canviewparticipants, $context);
                break;
            default:
                $link = false;
                if ($discussion->replies) {
                    $link = true;
                } else {
                    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
                    $link = forum_user_can_post($forum, $discussion, $USER, $cm, $course, $modcontext);
                }
                $discussion->forum = $forum->id;
                forum_print_post($discussion, $discussion, $forum, $cm, $course, $ownpost, 0, $link, false);
                break;
        }
    }
    if ($displayformat == "header") {
        echo '</tbody>';
        echo '</table>';
    }
    if ($olddiscussionlink) {
        if ($forum->type == 'news') {
            $strolder = get_string('oldertopics', 'forum');
        } else {
            $strolder = get_string('olderdiscussions', 'forum');
        }
        echo '<div class="forumolddiscuss">';
        echo '<a href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '&amp;showall=1">';
        echo $strolder . '</a> ...</div>';
    }
    if ($page != -1) {
        ///Show the paging bar
        echo $OUTPUT->paging_bar(moodle_paging_bar::make($numdiscussions, $page, $perpage, "view.php?f={$forum->id}"));
    }
}
Example #9
0
/**
 * Print a list navigation bar
 * Display page numbers, and a link for displaying all entries
 * @param integer $totalcount - number of entry to display
 * @param integer $page - page number
 * @param integer $perpage - number of entry per page
 * @param string $encodedsearch
 * @param string $modulelink - module name
 */
function print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink)
{
    global $OUTPUT;
    $pagingbar = moodle_paging_bar::make($totalcount, $page, $perpage, "search.php?search={$encodedsearch}" . $modulelink . "&perpage={$perpage}");
    $pagingbar->nocurr = $perpage == 99999;
    echo $OUTPUT->paging_bar($pagingbar);
    //display
    if ($perpage != 99999 && $totalcount > $perpage) {
        echo "<center><p>";
        echo "<a href=\"search.php?search={$encodedsearch}" . $modulelink . "&amp;perpage=99999\">" . get_string("showall", "", $totalcount) . "</a>";
        echo "</p></center>";
    }
}
Example #10
0
        unset($e);
        // this could potentially be quite big, so free it.
    }
    echo $OUTPUT->heading(get_string('queuesummary', 'portfolio'));
    echo $OUTPUT->table($table);
}
$logcount = $DB->count_records('portfolio_log', array('userid' => $USER->id));
if ($logcount > 0) {
    $table = new html_table();
    $table->head = array(get_string('plugin', 'portfolio'), get_string('displayarea', 'portfolio'), get_string('transfertime', 'portfolio'));
    $logs = $DB->get_records('portfolio_log', array('userid' => $USER->id), 'time DESC', '*', $page * $perpage, $perpage);
    foreach ($logs as $log) {
        require_once $CFG->dirroot . $log->caller_file;
        $class = $log->caller_class;
        $pluginname = '';
        try {
            $plugin = portfolio_instance($log->portfolio);
            $pluginname = $plugin->get('name');
        } catch (portfolio_exception $e) {
            // may have been deleted
            $pluginname = get_string('unknownplugin', 'portfolio');
        }
        $table->data[] = array($pluginname, call_user_func(array($class, 'display_name')), userdate($log->time));
    }
    echo $OUTPUT->heading(get_string('logsummary', 'portfolio'));
    $pagingbar = moodle_paging_bar::make($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?');
    echo $OUTPUT->paging_bar($pagingbar);
    echo $OUTPUT->table($table);
    echo $OUTPUT->paging_bar($pagingbar);
}
echo $OUTPUT->footer();
Example #11
0
function print_mnet_log($hostid, $course, $user = 0, $date = 0, $order = "l.time ASC", $page = 0, $perpage = 100, $url = "", $modname = "", $modid = 0, $modaction = "", $groupid = 0)
{
    global $CFG, $DB, $OUTPUT;
    if (!($logs = build_mnet_logs_array($hostid, $course, $user, $date, $order, $page * $perpage, $perpage, $modname, $modid, $modaction, $groupid))) {
        echo $OUTPUT->notification("No logs found!");
        echo $OUTPUT->footer();
        exit;
    }
    if ($course->id == SITEID) {
        $courses[0] = '';
        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.visible')) {
            foreach ($ccc as $cc) {
                $courses[$cc->id] = $cc->shortname;
            }
        }
    }
    $totalcount = $logs['totalcount'];
    $count = 0;
    $ldcache = array();
    $tt = getdate(time());
    $today = mktime(0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
    $strftimedatetime = get_string("strftimedatetime");
    echo "<div class=\"info\">\n";
    print_string("displayingrecords", "", $totalcount);
    echo "</div>\n";
    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "{$url}&perpage={$perpage}"));
    echo "<table class=\"logtable\" cellpadding=\"3\" cellspacing=\"0\">\n";
    echo "<tr>";
    if ($course->id == SITEID) {
        echo "<th class=\"c0 header\">" . get_string('course') . "</th>\n";
    }
    echo "<th class=\"c1 header\">" . get_string('time') . "</th>\n";
    echo "<th class=\"c2 header\">" . get_string('ip_address') . "</th>\n";
    echo "<th class=\"c3 header\">" . get_string('fullnamecourse') . "</th>\n";
    echo "<th class=\"c4 header\">" . get_string('action') . "</th>\n";
    echo "<th class=\"c5 header\">" . get_string('info') . "</th>\n";
    echo "</tr>\n";
    if (empty($logs['logs'])) {
        echo "</table>\n";
        return;
    }
    $row = 1;
    foreach ($logs['logs'] as $log) {
        $log->info = $log->coursename;
        $row = ($row + 1) % 2;
        if (isset($ldcache[$log->module][$log->action])) {
            $ld = $ldcache[$log->module][$log->action];
        } else {
            $ld = $DB->get_record('log_display', array('module' => $log->module, 'action' => $log->action));
            $ldcache[$log->module][$log->action] = $ld;
        }
        if (0 && $ld && !empty($log->info)) {
            // ugly hack to make sure fullname is shown correctly
            if ($ld->mtable == 'user' and $ld->field == $DB->sql_concat('firstname', "' '", 'lastname')) {
                $log->info = fullname($DB->get_record($ld->mtable, array('id' => $log->info)), true);
            } else {
                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id' => $log->info));
            }
        }
        //Filter log->info
        $log->info = format_string($log->info);
        echo '<tr class="r' . $row . '">';
        if ($course->id == SITEID) {
            echo "<td class=\"r{$row} c0\" >\n";
            echo "    <a href=\"{$CFG->wwwroot}/course/view.php?id={$log->course}\">" . $courses[$log->course] . "</a>\n";
            echo "</td>\n";
        }
        echo "<td class=\"r{$row} c1\" align=\"right\">" . userdate($log->time, '%a') . ' ' . userdate($log->time, $strftimedatetime) . "</td>\n";
        echo "<td class=\"r{$row} c2\" >\n";
        $link = html_link::make("/iplookup/index.php?ip={$log->ip}&user={$log->userid}", $log->ip);
        $link->add_action(new popup_action('click', $link->url, 'iplookup', array('height' => 400, 'width' => 700)));
        echo $OUTPUT->link($link);
        echo "</td>\n";
        $fullname = fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
        echo "<td class=\"r{$row} c3\" >\n";
        echo "    <a href=\"{$CFG->wwwroot}/user/view.php?id={$log->userid}\">{$fullname}</a>\n";
        echo "</td>\n";
        echo "<td class=\"r{$row} c4\">\n";
        echo $log->action . ': ' . $log->module;
        echo "</td>\n";
        echo "<td class=\"r{$row} c5\">{$log->info}</td>\n";
        echo "</tr>\n";
    }
    echo "</table>\n";
    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "{$url}&perpage={$perpage}"));
}
Example #12
0
/**
 * Prints the tag search results
 *
 * @param string $query text that tag names will be matched against
 * @param int $page current page
 * @param int $perpage nr of users displayed per page
 * @param $return if true return html string
 */
function tag_print_search_results($query, $page, $perpage, $return = false)
{
    global $CFG, $USER, $OUTPUT;
    $query = array_shift(tag_normalize($query, TAG_CASE_ORIGINAL));
    $count = sizeof(tag_find_tags($query, false));
    $tags = array();
    if ($found_tags = tag_find_tags($query, true, $page * $perpage, $perpage)) {
        $tags = array_values($found_tags);
    }
    $baseurl = $CFG->wwwroot . '/tag/search.php?query=' . rawurlencode($query);
    $output = '';
    // link "Add $query to my interests"
    $addtaglink = '';
    if (!tag_record_tagged_with('user', $USER->id, $query)) {
        $addtaglink = '<a href="' . $CFG->wwwroot . '/tag/user.php?action=addinterest&amp;sesskey=' . sesskey() . '&amp;tag=' . rawurlencode($query) . '">';
        $addtaglink .= get_string('addtagtomyinterests', 'tag', htmlspecialchars($query)) . '</a>';
    }
    if (!empty($tags)) {
        // there are results to display!!
        $output .= $OUTPUT->heading(get_string('searchresultsfor', 'tag', htmlspecialchars($query)) . " : {$count}", 3, 'main');
        //print a link "Add $query to my interests"
        if (!empty($addtaglink)) {
            $output .= $OUTPUT->box($addtaglink, 'box', 'tag-management-box');
        }
        $nr_of_lis_per_ul = 6;
        $nr_of_uls = ceil(sizeof($tags) / $nr_of_lis_per_ul);
        $output .= '<ul id="tag-search-results">';
        for ($i = 0; $i < $nr_of_uls; $i++) {
            $output .= '<li>';
            foreach (array_slice($tags, $i * $nr_of_lis_per_ul, $nr_of_lis_per_ul) as $tag) {
                $tag_link = ' <a href="' . $CFG->wwwroot . '/tag/index.php?id=' . $tag->id . '">' . tag_display_name($tag) . '</a>';
                $output .= '&#8226;' . $tag_link . '<br/>';
            }
            $output .= '</li>';
        }
        $output .= '</ul>';
        $output .= '<div>&nbsp;</div>';
        // <-- small layout hack in order to look good in Firefox
        $output .= $OUTPUT->paging_bar(moodle_paging_bar::make($count, $page, $perpage, $baseurl));
    } else {
        //no results were found!!
        $output .= $OUTPUT->heading(get_string('noresultsfor', 'tag', htmlspecialchars($query)), 3, 'main');
        //print a link "Add $query to my interests"
        if (!empty($addtaglink)) {
            $output .= $OUTPUT->box($addtaglink, 'box', 'tag-management-box');
        }
    }
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Example #13
0
     // Bar of last initials
     echo '<div class="initialbar lastinitial">' . get_string('lastname') . ' : ';
     if (!empty($lastinitial)) {
         echo '<a href="' . $baseurl->out() . '&amp;silast=">' . $strall . '</a>';
     } else {
         echo '<strong>' . $strall . '</strong>';
     }
     foreach ($alpha as $letter) {
         if ($letter == $lastinitial) {
             echo ' <strong>' . $letter . '</strong>';
         } else {
             echo ' <a href="' . $baseurl->out() . '&amp;silast=' . $letter . '">' . $letter . '</a>';
         }
     }
     echo '</div>';
     $pagingbar = moodle_paging_bar::make($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl);
     $pagingbar->pagevar = 'spage';
     echo $OUTPUT->paging_bar($pagingbar);
 }
 if ($matchcount > 0) {
     $usersprinted = array();
     foreach ($userlist as $user) {
         if (in_array($user->id, $usersprinted)) {
             /// Prevent duplicates by r.hidden - MDL-13935
             continue;
         }
         $usersprinted[] = $user->id;
         /// Add new user to the array of users printed
         $user = make_context_subobj($user);
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
         if (isset($user->context->id)) {
Example #14
0
 public function get_pagination($page = 0)
 {
     global $DB, $CFG, $OUTPUT;
     if (!($count = $DB->count_records_sql("SELECT COUNT(*) from {comments} c, {user} u WHERE u.id=c.userid AND c.contextid=? AND c.commentarea=? AND c.itemid=?", array($this->contextid, $this->commentarea, $this->itemid)))) {
     }
     $pages = (int) ceil($count / $CFG->commentsperpage);
     if ($pages == 1 || $pages == 0) {
         return '';
     }
     if (!empty(self::$nonjs)) {
         // used in non-js interface
         return $OUTPUT->paging_bar(moodle_paging_bar::make($count, $page, $CFG->commentsperpage, $this->link));
     } else {
         // return ajax paging bar
         $str = '';
         $str .= '<div class="comment-paging">';
         for ($p = 0; $p < $pages; $p++) {
             $extra = '';
             if ($p == $page) {
                 $extra = ' style="border:1px solid grey" ';
             }
             $str .= '<a class="pageno" href="###"' . $extra . ' onclick="get_comments(\'' . $this->cid . '\', \'' . $this->commentarea . '\', \'' . $this->itemid . '\', \'' . $p . '\')">' . ($p + 1) . '</a> ';
         }
         $str .= '</div>';
     }
     return $str;
 }
Example #15
0
/**
 * Prints a single paging bar to provide access to other pages  (usually in a search)
 *
 * @deprecated since Moodle 2.0
 *
 * @param int $totalcount Thetotal number of entries available to be paged through
 * @param int $page The page you are currently viewing
 * @param int $perpage The number of entries that should be shown per page
 * @param mixed $baseurl If this  is a string then it is the url which will be appended with $pagevar, an equals sign and the page number.
 *                          If this is a moodle_url object then the pagevar param will be replaced by the page no, for each page.
 * @param string $pagevar This is the variable name that you use for the page number in your code (ie. 'tablepage', 'blogpage', etc)
 * @param bool $nocurr do not display the current page as a link
 * @param bool $return whether to return an output string or echo now
 * @return bool|string depending on $result
 */
function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar = 'page', $nocurr = false, $return = false)
{
    global $OUTPUT;
    debugging('print_paging_bar() has been deprecated. Please change your code to use $OUTPUT->paging_bar($pagingbar).');
    $pagingbar = moodle_paging_bar::make($totalcount, $page, $perpage, $baseurl);
    $pagingbar->pagevar = $pagevar;
    $pagingbar->nocurr = $nocurr;
    $output = $OUTPUT->paging_bar($pagingbar);
    if ($return) {
        return $output;
    }
    echo $output;
    return true;
}
Example #16
0
if ($USER->gradeediting[$course->id] and !$report->get_pref('enableajax')) {
    echo '<form action="index.php" method="post">';
    echo '<div>';
    echo '<input type="hidden" value="' . $courseid . '" name="id" />';
    echo '<input type="hidden" value="' . sesskey() . '" name="sesskey" />';
    echo '<input type="hidden" value="grader" name="report"/>';
}
echo $reporthtml;
// print submit button
if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading')) && !$report->get_pref('enableajax')) {
    echo '<div class="submit"><input type="submit" value="' . get_string('update') . '" /></div>';
    echo '</div></form>';
}
// prints paging bar at bottom for large pages
if (!empty($studentsperpage) && $studentsperpage >= 20) {
    echo $OUTPUT->paging_bar(moodle_paging_bar::make($numusers, $report->page, $studentsperpage, $report->pbarurl));
}
echo '<div id="hiddentooltiproot">tooltip panel</div>';
// Print AJAX code
if ($report->get_pref('enableajax')) {
    require_once 'ajax.php';
}
// Print YUI tooltip code
?>
<script type="text/javascript">
//<![CDATA[

YAHOO.namespace("graderreport");

function init() {
    // Adjust height of header c0
Example #17
0
 /**
  * Prints the table of questions in a category with interactions
  *
  * @param object $course   The course object
  * @param int $categoryid  The id of the question category to be displayed
  * @param int $cm      The course module record if we are in the context of a particular module, 0 otherwise
  * @param int $recurse     This is 1 if subcategories should be included, 0 otherwise
  * @param int $page        The number of the page to be displayed
  * @param int $perpage     Number of questions to show per page
  * @param boolean $showhidden   True if also hidden questions should be displayed
  * @param boolean $showquestiontext whether the text of each question should be shown in the list
  */
 protected function display_question_list($contexts, $pageurl, $categoryandcontext, $cm = null, $recurse = 1, $page = 0, $perpage = 100, $showhidden = false, $sortorder = 'typename', $sortorderdecoded = 'qtype, name ASC', $showquestiontext = false, $addcontexts = array())
 {
     global $CFG, $DB, $OUTPUT;
     $category = $this->get_current_category($categoryandcontext);
     $cmoptions = new stdClass();
     $cmoptions->hasattempts = !empty($this->quizhasattempts);
     $strselectall = get_string("selectall", "quiz");
     $strselectnone = get_string("selectnone", "quiz");
     $strdelete = get_string("delete");
     list($categoryid, $contextid) = explode(',', $categoryandcontext);
     $catcontext = get_context_instance_by_id($contextid);
     $canadd = has_capability('moodle/question:add', $catcontext);
     $caneditall = has_capability('moodle/question:editall', $catcontext);
     $canuseall = has_capability('moodle/question:useall', $catcontext);
     $canmoveall = has_capability('moodle/question:moveall', $catcontext);
     $this->create_new_question_form($category, $canadd);
     $this->build_query_sql($category, $recurse, $showhidden);
     $totalnumber = $this->get_question_count();
     if ($totalnumber == 0) {
         return;
     }
     $questions = $this->load_page_questions($page, $perpage);
     echo '<div class="categorypagingbarcontainer">';
     $pagingbar = moodle_paging_bar::make($totalnumber, $page, $perpage, $pageurl);
     $pagingbar->pagevar = 'qpage';
     echo $OUTPUT->paging_bar($pagingbar);
     echo '</div>';
     echo '<form method="post" action="edit.php">';
     echo '<fieldset class="invisiblefieldset" style="display: block;">';
     echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
     echo $pageurl->hidden_params_out();
     echo '<div class="categoryquestionscontainer">';
     $this->start_table();
     $rowcount = 0;
     foreach ($questions as $question) {
         $this->print_table_row($question, $rowcount);
         $rowcount += 1;
     }
     $this->end_table();
     echo "</div>\n";
     echo '<div class="categorypagingbarcontainer pagingbottom">';
     echo $OUTPUT->paging_bar($pagingbar);
     if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) {
         if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) {
             $showall = '<a href="edit.php?' . $pageurl->get_query_string(array('qperpage' => 1000)) . '">' . get_string('showall', 'moodle', $totalnumber) . '</a>';
         } else {
             $showall = '<a href="edit.php?' . $pageurl->get_query_string(array('qperpage' => DEFAULT_QUESTIONS_PER_PAGE)) . '">' . get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE) . '</a>';
         }
         if ($paging) {
             $paging = substr($paging, 0, strrpos($paging, '</div>'));
             $paging .= "<br />{$showall}</div>";
         } else {
             $paging = "<div class='paging'>{$showall}</div>";
         }
         echo $paging;
     }
     echo '</div>';
     echo '<div class="modulespecificbuttonscontainer">';
     if ($caneditall || $canmoveall || $canuseall) {
         echo '<strong>&nbsp;' . get_string('withselected', 'quiz') . ':</strong><br />';
         if (function_exists('module_specific_buttons')) {
             echo module_specific_buttons($this->cm->id, $cmoptions);
         }
         // print delete and move selected question
         if ($caneditall) {
             echo '<input type="submit" name="deleteselected" value="' . $strdelete . "\" />\n";
         }
         if ($canmoveall && count($addcontexts)) {
             echo '<input type="submit" name="move" value="' . get_string('moveto', 'quiz') . "\" />\n";
             question_category_select_menu($addcontexts, false, 0, "{$category->id},{$category->contextid}");
         }
         if (function_exists('module_specific_controls') && $canuseall) {
             $modulespecific = module_specific_controls($totalnumber, $recurse, $category, $this->cm->id, $cmoptions);
             if (!empty($modulespecific)) {
                 echo "<hr />{$modulespecific}";
             }
         }
     }
     echo "</div>\n";
     echo '</fieldset>';
     echo "</form>\n";
 }