MDL-10234
[moodle-linuxchix.git] / blog / tags.html
blob73c7a3f0bb87808ab1187709ca88c3de48bb994e
1 <?php
2 $otags = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'official\' ORDER by text ASC');
3 $ptags1 = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'personal\' AND userid = '.$USER->id.' ORDER by text ASC');
4 $ptags2 = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'personal\' AND userid <> '.$USER->id.' ORDER by text ASC');
6 print_heading(get_string('tagmanagement'));
7 ?>
9 <table>
10 <tr>
11 <td width="50%" align="left"><label for="otags"><?php print_string('otags','blog');?></label></td>
12 <td width="50%" align="left"><label for="ptags"><?php print_string('ptags','blog');?></label></td>
13 </tr>
15 <tr>
16 <td>
17 <form action="tags.php" method="post">
18 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
19 <?php
20 if (has_capability('moodle/blog:manageofficialtags', $sitecontext)) {
22 <select name="tags[]" id="otags" multiple="multiple" size="8">
23 <?php
24 if ($otags) {
25 foreach ($otags as $otag) {
26 echo '<option value="'.$otag->id.'">'.$otag->text.'</option>';
30 </select>
31 <input type="hidden" name="action" value="delete" />
32 <br />
33 <input type="submit" value="<?php print_string('delete');?>" />
34 <?php }
35 else {
36 if ($otags) {
37 foreach ($otags as $otag) {
38 echo '<br />'.$otag->text;
43 </form>
44 </td>
46 <td>
47 <form action="tags.php" method="post">
48 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
49 <select name="tags[]" multiple="multiple" id="ptags" size="8">
50 <?php
52 $ptags = array();
54 // Not sure if this sowring is needed anymore
55 if (!empty($ptags1)) { // user's own tag exists
56 if (!empty($ptags2)) { // user's own tags, and other users tags exist, we merge
57 $ptags = array_merge($ptags1, $ptags2);
58 } else { // user's own tags exist, no other personal tags, just use that
59 $ptags = $ptags1;
61 } else if (!empty($ptags2)) {
62 $ptags = $ptags2;
65 if (!empty($ptags)) {
66 foreach ($ptags as $ptag) {
67 echo '<option value="'.$ptag->id.'">'.$ptag->text.'</option>';
71 </select>
72 <input type="hidden" name="action" value="delete" />
73 <br />
74 <input type="submit" value="<?php print_string('delete');?>" />
75 </form>
76 </td>
77 </tr>
79 <tr>
80 <td>
81 <?php if (has_capability('moodle/blog:manageofficialtags', $sitecontext)) { ?>
82 <form action="tags.php" method="post">
83 <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
84 <label for="newotag"><?php print_string('addotags','blog');?></label>:<br/>
85 <input type="text" name="otag" id="newotag" />
86 <input type="submit" value="<?php print_string('add');?>" />
87 <input type="hidden" name="action" value="addofficial" />
88 </form>
89 <?php }?>
90 </td>
92 <td>
93 </td>
94 </tr>
96 </table>
98 <p align="center">
99 <a href="#" onclick="window.close()"><?php print_string('closewindow');?></a>
100 </p>