forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtags.html
executable file
·101 lines (91 loc) · 3.88 KB
/
tags.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
print_heading(get_string('tagmanagement'));
?>
<table>
<tr>
<td width="50%"><?php print_string('otags','blog');?></td>
<td width="50%"><?php print_string('ptags','blog');?></td>
</tr>
<tr>
<td>
<form action="tags.php" method="POST">
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
<?php if (isadmin()){ ?>
<select name="tags[]" multiple="multiple" size="8">
<?php
$otags = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'official\' ORDER by text ASC');
foreach ($otags as $otag) {
echo '<option value="'.$otag->id.'">'.$otag->text.'</option>';
}
?>
</select>
<input type="hidden" name="mode" value="delete" />
<br />
<input type="submit" value="<?php print_string('delete');?>" />
<?php }
else {
if ($otags = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'official\' ORDER by text ASC')) {
foreach ($otags as $otag) {
echo '<br />'.$otag->text;
}
}
}
?>
</form>
</td>
<td>
<form action="tags.php" method="POST">
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
<select name="tags[]" multiple="multiple" size="8">
<?php
$ptags1 = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'personal\' AND userid = '.$USER->id.' ORDER by text ASC');
$ptags2 = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'personal\' AND userid <> '.$USER->id.' ORDER by text ASC');
$ptags = array();
if (!empty($ptags1)) { // user's own tag exists
if (!empty($ptags2)) { // user's own tags, and other users tags exist, we merge
$ptags = array_merge($ptags1, $ptags2);
} else { // user's own tags exist, no other personal tags, just use that
$ptags = $ptags1;
}
} else if (!empty($ptags2)) {
$ptags = $ptags2;
}
if (!empty($ptags)) {
foreach ($ptags as $ptag) {
echo '<option value="'.$ptag->id.'">'.$ptag->text.'</option>';
}
}
?>
</select>
<input type="hidden" name="mode" value="delete" />
<br />
<input type="submit" value="<?php print_string('delete');?>" />
</form>
</td>
</tr>
<tr>
<td>
<?php if (isadmin()) { ?>
<form action="tags.php" method="POST">
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
<?php print_string('addotags','blog');?>:<br/>
<input type="text" name="otag" />
<input type="submit" value="<?php print_string('add');?>" />
<input type="hidden" name="mode" value="addofficial" />
</form>
<?php }?>
</td>
<td>
<form action="tags.php" method="POST">
<input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
<?php print_string('addptags','blog');?><br/>
<input type="text" name="ptag" />
<input type="submit" value="<?php print_string('add');?>" />
<input type="hidden" name="mode" value="addpersonal" />
</form>
</td>
</tr>
</table>
<p align="center">
<a href="#" onclick="window.close()"><?php print_string('closewindow');?></a>
</p>