Add public notes

This commit is contained in:
Daniel Winzen
2021-02-12 18:58:09 +01:00
parent e51fba28c7
commit f0f812badc
14 changed files with 74 additions and 8 deletions

View File

@ -128,14 +128,19 @@ function route(){
send_notes(0);
}elseif($_POST['do']==='staff' && $U['status']>=5){
send_notes(1);
}elseif($_POST['do']==='public' && $U['status']>=3){
send_notes(3);
}
if($U['status']<3 || !get_setting('personalnotes')){
if($U['status']<3 || (!get_setting('personalnotes') && !get_setting('publicnotes'))){
send_access_denied();
}
send_notes(2);
}elseif($_REQUEST['action']==='help'){
check_session();
send_help();
}elseif($_REQUEST['action']==='viewpublicnotes'){
check_session();
view_publicnotes();
}elseif($_REQUEST['action']==='inbox'){
check_session();
if(isset($_POST['do'])){
@ -230,7 +235,7 @@ function route_setup(){
if(!valid_admin()){
send_alogin();
}
$C['bool_settings']=['suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'incognito', 'sendmail', 'modfallback', 'disablepm', 'eninbox', 'enablegreeting', 'sortupdown', 'hidechatters', 'personalnotes', 'filtermodkick'];
$C['bool_settings']=['suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'incognito', 'sendmail', 'modfallback', 'disablepm', 'eninbox', 'enablegreeting', 'sortupdown', 'hidechatters', 'personalnotes', 'publicnotes', 'filtermodkick'];
$C['colour_settings']=['colbg', 'coltxt'];
$C['msg_settings']=['msgenter', 'msgexit', 'msgmemreg', 'msgsureg', 'msgkick', 'msgmultikick', 'msgallkick', 'msgclean', 'msgsendall', 'msgsendmem', 'msgsendmod', 'msgsendadm', 'msgsendprv', 'msgattache'];
$C['number_settings']=['memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'numnotes', 'maxuploadsize', 'enfileupload'];
@ -783,6 +788,8 @@ function restore_backup(array $C){
$note['type']=0;
}elseif($note['type']==='staff'){
$note['type']=1;
}elseif($note['type']==='public'){
$note['type']=3;
}
if(MSGENCRYPTED){
try {
@ -1579,15 +1586,21 @@ function send_notes(int $type){
global $I, $U, $db;
print_start('notes');
$personalnotes=(bool) get_setting('personalnotes');
if($U['status']>=5 && ($personalnotes || $U['status']>6)){
$publicnotes=(bool) get_setting('publicnotes');
if($U['status']>=3 && ($personalnotes || $publicnotes)){
echo '<table><tr>';
if($U['status']>6){
echo '<td>'.form_target('view', 'notes', 'admin').submit($I['admnotes']).'</form></td>';
}
if($U['status']>=5){
echo '<td>'.form_target('view', 'notes', 'staff').submit($I['staffnotes']).'</form></td>';
}
if($personalnotes){
echo '<td>'.form_target('view', 'notes').submit($I['personalnotes']).'</form></td>';
}
if($publicnotes){
echo '<td>'.form_target('view', 'notes', 'public').submit($I['publicnotes']).'</form></td>';
}
echo '</tr></table>';
}
if($type===1){
@ -1596,9 +1609,12 @@ function send_notes(int $type){
}elseif($type===0){
echo "<h2>$I[adminnotes]</h2><p>";
$hiddendo=hidden('do', 'admin');
}else{
}elseif($type===2){
echo "<h2>$I[personalnotes]</h2><p>";
$hiddendo='';
}elseif($type===3){
echo "<h2>$I[publicnotes]</h2><p>";
$hiddendo=hidden('do', 'public');
}
if(isset($_POST['text'])){
if(MSGENCRYPTED){
@ -1614,7 +1630,7 @@ function send_notes(int $type){
echo "<b>$I[notessaved]</b> ";
}
$dateformat=get_setting('dateformat');
if($type!==2){
if(($type!==2) && ($type !==3)){
$stmt=$db->prepare('SELECT COUNT(*) FROM ' . PREFIX . 'notes WHERE type=?;');
$stmt->execute([$type]);
}else{
@ -1627,7 +1643,7 @@ function send_notes(int $type){
}else{
$revision=0;
}
if($type!==2){
if(($type!==2) && ($type !==3)){
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . "notes WHERE type=? ORDER BY id DESC LIMIT 1 OFFSET $revision;");
$stmt->execute([$type]);
}else{
@ -1898,6 +1914,25 @@ function send_help(){
print_end();
}
function view_publicnotes(){
global $I, $db;
$dateformat=get_setting('dateformat');
print_start('publicnotes');
echo "<h2>$I[publicnotes]</h2><p>";
// SQL adapted from AdamMc331 https://stackoverflow.com/questions/27991484/using-max-within-inner-join-sql
$query=$db->query('SELECT pubs.* FROM notes pubs JOIN (SELECT lastedited,editedby,text,MAX(id) AS latest FROM notes WHERE type=3 GROUP BY editedby) t ON t.editedby = pubs.editedby AND t.latest = pubs.id;');
while($result=$query->fetch(PDO::FETCH_OBJ)){
if ($result->text <> "") {
print '<hr/>';
printf($I['lastedited'], htmlspecialchars($result->editedby), date($dateformat, $result->lastedited));
print '<br/>';
print '<textarea cols="80" rows="9" readonly="true">'.$result->text.'</textarea>';
print '<br/>';
}
}
print_end();
}
function send_profile(string $arg=''){
global $I, $L, $U, $db, $language;
print_start('profile');
@ -2048,6 +2083,7 @@ function send_controls(){
global $I, $U;
print_start('controls');
$personalnotes=(bool) get_setting('personalnotes');
$publicnotes=(bool) get_setting('publicnotes');
echo '<table><tr>';
echo '<td>'.form_target('post', 'post').submit($I['reloadpb']).'</form></td>';
echo '<td>'.form_target('view', 'view').submit($I['reloadmsgs']).'</form></td>';
@ -2058,8 +2094,11 @@ function send_controls(){
echo '<td>'.form_target('view', 'notes', 'staff').submit($I['notes']).'</form></td>';
}
}
if($publicnotes){
echo '<td>'.form_target('view', 'viewpublicnotes').submit($I['viewpublicnotes']).'</form></td>';
}
if($U['status']>=3){
if($personalnotes){
if($personalnotes || $publicnotes){
echo '<td>'.form_target('view', 'notes').submit($I['notes']).'</form></td>';
}
echo '<td>'.form_target('_blank', 'login').submit($I['clone']).'</form></td>';
@ -3589,7 +3628,7 @@ function cron(){
}
// delete old notes
$limit=get_setting('numnotes');
$db->exec('DELETE FROM ' . PREFIX . 'notes WHERE type!=2 AND id NOT IN (SELECT * FROM ( (SELECT id FROM ' . PREFIX . "notes WHERE type=0 ORDER BY id DESC LIMIT $limit) UNION (SELECT id FROM " . PREFIX . "notes WHERE type=1 ORDER BY id DESC LIMIT $limit) ) AS t);");
$db->exec('DELETE FROM ' . PREFIX . 'notes WHERE type!=2 AND type!=3 AND id NOT IN (SELECT * FROM ( (SELECT id FROM ' . PREFIX . "notes WHERE type=0 ORDER BY id DESC LIMIT $limit) UNION (SELECT id FROM " . PREFIX . "notes WHERE type=1 ORDER BY id DESC LIMIT $limit) ) AS t);");
$result=$db->query('SELECT editedby, COUNT(*) AS cnt FROM ' . PREFIX . "notes WHERE type=2 GROUP BY editedby HAVING cnt>$limit;");
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'notes WHERE type=2 AND editedby=? AND id NOT IN (SELECT * FROM (SELECT id FROM ' . PREFIX . "notes WHERE type=2 AND editedby=? ORDER BY id DESC LIMIT $limit) AS t);");
while($tmp=$result->fetch(PDO::FETCH_NUM)){
@ -3764,6 +3803,7 @@ function init_chat(){
['maxuploadsize', '1024'],
['nextcron', '0'],
['personalnotes', '1'],
['publicnotes', '1'],
['filtermodkick', '0'],
['metadescription', $I['defaultmetadescription']],
];

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Запази промените',
'reloadpb' => 'Презареди пощенската кутия',
'reloadmsgs' => 'Презареди съобщенията',
'viewpublicnotes' => 'Чета́ обще́ствен Бележки',
'chgprofile' => 'Профил',
'adminbtn' => 'Администрация',
'admnotes' => 'Администраторски бележки',
@ -366,5 +367,6 @@ $T=[
'cssupdate' => 'Забележка: CSS-ът по подразбиране е вече вграден в кода и може да бъде премахнат от CSS настройките',
'manualrefresh' => 'Необходимо ръчно опресняване',
'personalnotes' => 'Лични бележки',
'publicnotes' => 'Обще́ствен Бележки',
'filtermodkick' => 'Прилагай филтъра за изгонване и за модераторите',
];

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Uložit',
'reloadpb' => 'Znovu načíst poštovní schránku',
'reloadmsgs' => 'Znovu načíst zprávy',
'viewpublicnotes' => 'Zobrazit poznámky publikovaný',
'chgprofile' => 'Profil',
'adminbtn' => 'Admin',
'admnotes' => 'Admin poznámky',
@ -366,5 +367,6 @@ $T=[
'cssupdate' => 'Poznámka: Výchozí CSS je nyní napevno a může být odstraněn z nastavení CSS',
'manualrefresh' => 'Nutná ruční aktualizace ',
'personalnotes' => 'Osobní poznámky',
'publicnotes' => 'Poznámky publikovaný',
'filtermodkick' => 'Použít vyhazovací filtr na moderátory',
];

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Änderungen speichern',
'reloadpb' => 'Postbox neu laden',
'reloadmsgs' => 'Nachrichten neu laden',
'viewpublicnotes' => 'Öffentliche Notizen anzeigen',
'chgprofile' => 'Profil',
'adminbtn' => 'Admin',
'admnotes' => 'Adminnotizen',
@ -367,6 +368,7 @@ $T=[
'cssupdate' => 'Hinweis: Standard CSS ist jetzt hardcoded und kann aus der CSS Einstellung entfernt werden',
'manualrefresh' => 'Manuelles Neuladen erforderlich',
'personalnotes' => 'Persönliche Notizen',
'publicnotes' => 'Öffentliche Notizen',
'filtermodkick' => 'Kickfilter auf Moderatoren anwenden',
'forgotlogin' => 'Zugangsdaten vergessen?',
'resetinstruction' => 'Bitte bearbeiten Sie das Skript und fügen Sie folgendes am Ende der Datei hinzu (und ändern Sie das Passwort "changeme"). Danach aktualisieren Sie die Seite bitte: define(\'RESET_SUPERADMIN_PASSWORD\', \'changeme\');',

View File

@ -164,6 +164,7 @@ $I=[
'savechanges' => 'Save changes',
'reloadpb' => 'Reload Post Box',
'reloadmsgs' => 'Reload Messages',
'viewpublicnotes' => 'View public notes',
'chgprofile' => 'Profile',
'adminbtn' => 'Admin',
'admnotes' => 'Admin Notes',
@ -367,6 +368,7 @@ $I=[
'cssupdate' => 'Note: Default CSS is now hardcoded and can be removed from the CSS setting',
'manualrefresh' => 'Manual refresh required',
'personalnotes' => 'Personal notes',
'publicnotes' => 'Public notes',
'filtermodkick' => 'Apply kick filter on moderators',
'forgotlogin' => 'Forgot login?',
'resetinstruction' => 'Please modify the script and put the following at the bottom of it (change the password). Then refresh this page: define(\'RESET_SUPERADMIN_PASSWORD\', \'changeme\');',

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Guardar cambios',
'reloadpb' => 'Recargar caja de publicación',
'reloadmsgs' => 'Recargar mensajes',
'viewpublicnotes' => 'Ver notas públicas',
'chgprofile' => 'Perfil',
'adminbtn' => 'Admin',
'admnotes' => 'Notas de administrador',
@ -366,5 +367,6 @@ $T=[
'cssupdate' => 'Note: Css predeterminado está ahora hardcoded y puede ser removido de la configuración CSS',
'manualrefresh' => 'Recarga manual requerida',
'personalnotes' => 'Notas personales',
'publicnotes' => 'Notas públicas',
'filtermodkick' => 'Aplicar Kick filter en moderadores o administradores',
];

View File

@ -160,6 +160,8 @@ $T=[
'savechanges' => 'Sauvegarder les modifications',
'reloadpb' => 'Recharger la boite de texte',
'reloadmsgs' => 'Recharger les messages',
'viewpublicnotes' => 'Voir notes publiques',
'publicnotes' => 'Notes publiques',
'chgprofile' => 'Profile',
'adminbtn' => 'Administrateur',
'admnotes' => 'Notes de l\'administrateur',

View File

@ -160,6 +160,8 @@ $T=[
'savechanges' => 'Simpan perubahan',
'reloadpb' => 'Muat-ulang kotak pos',
'reloadmsgs' => 'Muat-ulang pesan',
'viewpublicnotes' => 'Baca catatan terbuka',
'publicnotes' => 'Catatan terbuka',
'chgprofile' => 'Profil',
'adminbtn' => 'Admin',
'admnotes' => 'Catatan Admin',

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Salavre cambiamenti',
'reloadpb' => 'Ricarica Chat',
'reloadmsgs' => 'Aggiorna/Indietro',
'viewpublicnotes' => 'Leggere appunti pubbliche',
'chgprofile' => 'Profilo',
'adminbtn' => 'Amministratore',
'admnotes' => 'Note del amministratore',
@ -366,5 +367,6 @@ $T=[
'cssupdate' => 'Note: Default CSS is now hardcoded and can be removed from the CSS setting',
'manualrefresh' => 'Bisogna aggiornare pagina manualmente',
'personalnotes' => 'Appunti personali',
'publicnotes' => 'Appunti pubbliche',
'filtermodkick' => 'Utlizzare filtro di esclusione per moderatori',
];

View File

@ -164,6 +164,7 @@ $I=[
'savechanges' => 'Salvar alterações',
'reloadpb' => 'Reload Post Box',
'reloadmsgs' => 'Reload Messages',
'viewpublicnotes' => 'Ler notas públicas',
'chgprofile' => 'Perfil',
'adminbtn' => 'Admin',
'admnotes' => 'Admin Notes',
@ -367,6 +368,7 @@ $I=[
'cssupdate' => 'Nota: CSS padrão agora está codificado e pode ser removido da configuração CSS',
'manualrefresh' => 'Reload manual necessário',
'personalnotes' => 'Notas pessoais',
'publicnotes' => 'Notas públicas',
'filtermodkick' => 'Aplicar kick filter nos moderadores',
'forgotlogin' => 'Esqueceu o login?',
'resetinstruction' => 'Please modify the script and put the following at the bottom of it (change the password). Then refresh this page: define(\'RESET_SUPERADMIN_PASSWORD\', \'changeme\');',

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Сохранить изменения',
'reloadpb' => 'Перезагрузить почтовый ящик',
'reloadmsgs' => 'Обновить',
'viewpublicnotes' => 'Читать профили пользователей',
'chgprofile' => 'Профиль',
'adminbtn' => 'Администратор',
'admnotes' => 'Примечания администратора',
@ -366,6 +367,7 @@ $T=[
'cssupdate' => 'Заметка: по установлению CSS он тяжелый и можна убрать его в CSS настройках',
'manualrefresh' => 'Требуется обновить страницу вручную',
'personalnotes' => 'Личные заметки',
'publicnotes' => ' Профиля пользователяь',
'filtermodkick' => 'Применить фильтр исключения для модераторов',
];

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Değişiklikleri kaydet',
'reloadpb' => 'Posta Kutusunu Yenile',
'reloadmsgs' => 'İletileri yenile',
'viewpublicnotes' => 'Oku kamu profilim',
'chgprofile' => 'Profil',
'adminbtn' => 'Yönetici',
'admnotes' => 'Yönetici Notları',
@ -367,6 +368,7 @@ $T=[
'cssupdate' => 'Not: Default CSS is now hardcoded and can be removed from the CSS setting',
'manualrefresh' => 'Manuel yenileme gerekli',
'personalnotes' => 'Kişisel notlar',
'publicnotes' => 'Kamu profiller',
'filtermodkick' => 'Moderatörler için atma filtresini etkinleştir',
];

View File

@ -164,6 +164,7 @@ $T=[
'savechanges' => 'Зберігти иізмінення',
'reloadpb' => 'Перезагрузити почтовий ящік',
'reloadmsgs' => 'Обновити',
'viewpublicnotes' => 'Читати зауваження публічний',
'chgprofile' => 'Профіль',
'adminbtn' => 'Администратор',
'admnotes' => 'Зауваження администратора',
@ -366,6 +367,7 @@ $T=[
'cssupdate' => 'Note: Default CSS is now hardcoded and can be removed from the CSS setting',
'manualrefresh' => 'Потрібно обновити сторінку вручну',
'personalnotes' => 'Лічні замітки',
'publicnotes' => 'Зауваження публічний',
'filtermodkick' => 'Примінити фільтр исключення для модераторів',
];

View File

@ -143,6 +143,8 @@ $T=[
'savechanges' => '保存更改',
'reloadpb' => '刷新缓存',
'reloadmsgs' => '刷新一下消息',
'viewpublicnotes' => '阅读用户配置文件',
'publicnotes' => '用户配置文件',
'chgprofile' => '个人资料',
'adminbtn' => '管理',
'admnotes' => '管理员公告',