MDL-11510 added missing fields in new gradebook backup
[moodle-pu.git] / tag / index.php
blob921caf8e1f890328cbd43e3aca5c6b579610adfc
1 <?php // $Id$
3 require_once('../config.php');
4 require_once('lib.php');
5 require_once('pagelib.php');
6 require_once($CFG->dirroot.'/lib/weblib.php');
7 require_once($CFG->dirroot.'/blog/lib.php');
9 require_login();
11 if (empty($CFG->usetags)) {
12 error(get_string('tagsaredisabled', 'tag'));
15 $tagid = optional_param('id', 0, PARAM_INT); // tag id
16 $edit = optional_param('edit', -1, PARAM_BOOL);
17 $userpage = optional_param('userpage', 0, PARAM_INT); // which page to show
18 $perpage = optional_param('perpage', 24, PARAM_INT);
20 $tag = tag_by_id($tagid);
22 if (!$tag) {
23 redirect($CFG->wwwroot.'/tag/search.php');
26 //create a new page_tag object, defined in pagelib.php
27 $PAGE = page_create_object(PAGE_TAG_INDEX, $tag->id);
28 $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
29 $PAGE->tag_object = $tag;
31 if (($edit != -1) and $PAGE->user_allowed_editing()) {
32 $USER->editing = $edit;
36 $PAGE->print_header();
39 echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
40 echo '<tr valign="top">';
42 //----------------- left column -----------------
44 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
46 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
47 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
48 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
49 echo '</td>';
54 //----------------- middle column -----------------
56 echo '<td valign="top" id="middle-column">';
58 $tagname = tag_display_name($tag);
60 $systemcontext = get_context_instance(CONTEXT_SYSTEM);
61 if ($tag->flag > 0 && has_capability('moodle/tag:manage', $systemcontext)) {
62 $tagname = '<span class="flagged-tag">' . $tagname . '</span>';
65 print_heading($tagname, '', 2, 'headingblock header tag-heading');
67 print_tag_management_box($tag);
69 print_tag_description_box($tag);
72 $usercount = count_items_tagged_with($tag->id,'user');
74 if ($usercount > 0) {
76 //user table box
77 print_box_start('generalbox', 'tag-user-table');
79 $heading = get_string('userstaggedwith', 'tag', $tagname) . ': ' . $usercount;
80 print_heading($heading, '', 3);
82 $baseurl = $CFG->wwwroot.'/tag/index.php?id=' . $tag->id;
84 print_paging_bar($usercount, $userpage, $perpage, $baseurl.'&amp;', 'userpage');
86 print_tagged_users_table($tag, $userpage * $perpage, $perpage);
88 print_box_end();
95 // Print last 10 blogs
97 // I was not able to use get_items_tagged_with() because it automatically
98 // tries to join on 'blog' table, since the itemtype is 'blog'. However blogs
99 // uses the post table so this would not really work. - Yu 29/8/07
100 if ($blogs = blog_fetch_entries('', 10, 0, 'site', '', $tag->id)) {
102 print_box_start('generalbox', 'tag-blogs');
104 print_heading(get_string('relatedblogs', 'tag'), '', 3);
106 echo '<ul id="tagblogentries">';
107 foreach ($blogs as $blog) {
108 if ($blog->publishstate == 'draft') {
109 $class = 'class="dimmed"';
110 } else {
111 $class = '';
113 echo '<li '.$class.'>';
114 echo '<a '.$class.' href="'.$CFG->wwwroot.'/blog/index.php?postid='.$blog->id.'">';
115 echo format_string($blog->subject);
116 echo '</a>';
117 echo ' - ';
118 echo '<a '.$class.' href="'.$CFG->wwwroot.'/user/view.php?id='.$blog->userid.'">';
119 echo fullname($blog);
120 echo '</a>';
121 echo ', '. userdate($blog->lastmodified);
122 echo '</li>';
124 echo '</ul>';
126 echo '<p class="moreblogs"><a href="'.$CFG->wwwroot.'/blog/index.php?filtertype=site&filterselect=0&tagid='.$tag->id.'">'.get_string('seeallblogs', 'tag').'</a>...</p>';
128 print_box_end();
132 echo '</td>';
135 //----------------- right column -----------------
137 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
139 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
140 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
141 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
142 echo '</td>';
145 /// Finish the page
146 echo '</tr></table>';
150 $PAGE->print_footer();