From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:08:29 +0200 Subject: 2024-02-19 upstream --- admin/survey/classes/class.Notifications.php | 310 ++++++++++++++++++--------- 1 file changed, 210 insertions(+), 100 deletions(-) (limited to 'admin/survey/classes/class.Notifications.php') diff --git a/admin/survey/classes/class.Notifications.php b/admin/survey/classes/class.Notifications.php index 1a88247..3604125 100644 --- a/admin/survey/classes/class.Notifications.php +++ b/admin/survey/classes/class.Notifications.php @@ -18,46 +18,77 @@ class Notifications { public function display($tab=0){ global $admin_type, $global_user_id, $lang; - + // Prikazemo poslana sporocila if((isset($_GET['t']) && $_GET['t']=='sent') || $tab == 1){ - + + echo '
'; + // Izpis vseh poslanih sporocil if($admin_type == 0){ - echo '
'; + echo '
'; + + echo '
'; + echo '
'; + echo '

'.$lang['srv_notifications_sent'].'

'; + echo '
'; + $this->displaySentMessages(); echo '
'; // obrazec za posiljanje sporocil + echo '
'; + + echo '
'; + echo '
'; + echo '

'.$lang['srv_inv_message_draft_new'].'

'; + echo '
'; + $this->sendMessageForm(); + echo '
'; + } else - echo $lang['srv_notifications_admin_alert']; + echo $lang['srv_notifications_admin_alert']; + + echo '
'; } // Prikazemo prejeta sporocila else{ + + echo '
'; + echo '
'; + echo '

'.$lang['srv_notifications_recieved'].'

'; + echo '
'; + + echo '
'; + + echo '
'; echo '
'; $this->displayRecievedMessages(); echo '
'; + echo '
'; + echo '
'; echo ''; + echo '
'; + + + echo '
'; + } - - echo '
'; } private function displayRecievedMessages($active=0){ global $admin_type, $global_user_id, $lang; - echo ''.$lang['srv_notifications_recieved'].':'; - // Napolnimo array prejetih sporocil $recievedMessages = array(); - $sql = sisplet_query("SELECT n.id AS id, n.recipient AS recipient, n.viewed AS viewed, m.id AS message_id, m.date AS date, m.title AS title, m.text AS text + $sql = sisplet_query("SELECT n.id AS id, n.recipient AS recipient, n.viewed AS viewed, m.id AS message_id, m.send_time AS send_time, m.title AS title, m.text AS text FROM srv_notifications n, srv_notifications_messages m WHERE n.recipient='".$global_user_id."' AND n.message_id=m.id - ORDER BY m.date DESC"); + ORDER BY m.send_time DESC"); while($row = mysqli_fetch_array($sql)){ $recievedMessages[$row['id']] = $row; } @@ -67,16 +98,25 @@ class Notifications { if(count($recievedMessages) > 0){ foreach($recievedMessages as $message){ - echo ''; - echo '
  • '; - - echo ''.$message['title'].' ('.$message['date'].')'; + echo '
  • '; + + echo ''; + + echo '
    '; //sem noter pride še oznaka, če je obvestilo ali sporočilo + echo '
    '; + echo $message['title']; + echo '
    '; + echo '
    '; + echo date('Y-m-d H:i:s', strtotime($message['send_time'])); + echo '
    '; + echo '
    '; - $text = strip_tags((strlen($message['text']) > 70) ? substr($message['text'], 0, 70).'...' : $message['text']); - echo '
    '.$text; + $text = strip_tags($message['text']); + echo '
    '; + echo $text; + echo '
    '; echo '
  • '; - echo '
    '; } } @@ -85,43 +125,54 @@ class Notifications { private function displaySentMessages(){ global $admin_type, $global_user_id, $lang; - - echo ''.$lang['srv_notifications_sent'].':'; - + // Napolnimo array poslanih sporocil $sentMessages = array(); - $sql = sisplet_query("SELECT * FROM srv_notifications_messages WHERE author='".$global_user_id."' ORDER BY date DESC"); + $sql = sisplet_query("SELECT * FROM srv_notifications_messages WHERE author='".$global_user_id."' ORDER BY send_time DESC"); while($row = mysqli_fetch_array($sql)){ $sentMessages[$row['id']] = $row; } - - echo ''; + else //Ni poslanih sporočil + echo '

    '.$lang['srv_notifications_sent_none'].'.

    '; } // Obrazec za posiljanje sporocila @@ -129,28 +180,59 @@ class Notifications { global $admin_type, $global_user_id, $lang; echo '
    '; - echo ''.$lang['srv_notifications_send_reciever'].': '; - - // Checkboxa za posiljenje vsem uporabnikoom (slo in ang) - echo '
    '; - echo '

    '; - - echo ''.$lang['srv_notifications_send_title'].':

    '; - echo ''.$lang['srv_notifications_send_text'].':
    '; + + //Prejemniki + echo '
    '; + echo ''.$lang['srv_notifications_send_reciever2'].':'; + + echo '
    '; + echo ''; + echo ''; + echo '
    '; + echo '
    '; + echo ''; + echo ''; + echo '
    '; + echo '
    '; + echo ''; + echo ''; + echo ''; + echo '
    '; + + echo '
    '; + + // Naslov sporocila + echo '
    '; + echo $lang['srv_notifications_send_title'].':'; + echo ''; + echo '
    '; + + // Besedilo sporocila (editor) + echo $lang['srv_notifications_send_text'].':'; + echo '
    '; + echo ''; + echo '
    '; // Avtomatsko prikaži obvestilo po prijavi - echo '

    '; - - echo ''; - echo ''.$lang['srv_notifications_send'].''; - echo ''; - + echo '
    '; + echo ''; + echo ''; + echo '
    '; + + //Error notes if($note != ''){ - echo '

    '; - echo ''.$note.''; + echo '

    '.$note.'

    '; } + + // Gumb pošlji + echo '
    '; + echo ''; + echo '
    '; echo '
    '; + + // Inicializiramo editor + echo ''; } @@ -245,7 +327,7 @@ class Notifications { if($recipient_all_slo == 1 || $recipient_all_ang == 1){ // Dodamo novo sporocilo v bazo - $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, date, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')"); + $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, send_time, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')"); $message_id = mysqli_insert_id($GLOBALS['connect_db']); $note = ''; @@ -261,7 +343,7 @@ class Notifications { $sql = sisplet_query("INSERT INTO srv_notifications (message_id, recipient, viewed) VALUES ('".$message_id."', '".$rowU['id']."', '0')"); if(!$sql) - $note .= mysqli_error($GLOBALS['connect_db']).'
    '; + $note .= ''.mysqli_error($GLOBALS['connect_db']).''; } } // Posiljamo na specificen mail @@ -272,30 +354,46 @@ class Notifications { $rowU = mysqli_fetch_array($sqlU); // Dodamo novo sporocilo v bazo - $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, date, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')"); + $sql = sisplet_query("INSERT INTO srv_notifications_messages (author, send_time, title, text, force_show) VALUES ('".$global_user_id."', NOW(), '".$title."', '".$notification."', '".$force_show."')"); $message_id = mysqli_insert_id($GLOBALS['connect_db']); // Dodamo novo sporocilo v bazo $sql = sisplet_query("INSERT INTO srv_notifications (message_id, recipient, viewed) VALUES ('".$message_id."', '".$rowU['id']."', '0')"); if(!$sql) - $note = mysqli_error($GLOBALS['connect_db']); + $note = ''.mysqli_error($GLOBALS['connect_db']).''; else - $note = 'Sporočilo je bilo uspešno poslano uporabniku '.$recipient.' ('.$rowU['name'].' '.$rowU['surname'].').'; + $note = ''.$lang['srv_notifications_sent_success'].' '.$recipient.' ('.$rowU['name'].' '.$rowU['surname'].').'; } else{ - $note = 'Vnešeni email ('.$recipient.') ne pripada nobenemu uporabniku!'; + $note = ''.$lang['srv_notifications_sent_nouser1'].$recipient.$lang['srv_notifications_sent_nouser1'].''; } } + echo '
    '; + // Refresh vseh poslanih sporocil - echo '
    '; + echo '
    '; + + echo '
    '; + echo '
    '; + echo '

    '.$lang['srv_notifications_sent'].'

    '; + echo '
    '; + $this->displaySentMessages(); echo '
    '; // Refresh obrazca za posiljanje sporocil + echo '
    '; + + echo '
    '; + echo '
    '; + echo '

    '.$lang['srv_inv_message_draft_new'].'

    '; + echo '
    '; + $this->sendMessageForm($note); - - echo '
    '; + echo '
    '; + + echo '
    '; } public function ajax_resolveMessages(){ @@ -320,57 +418,80 @@ class Notifications { $sql = sisplet_query("UPDATE srv_notifications SET viewed='1' WHERE id='$id'"); // Dobimo sporocilo - $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.date AS date + $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.send_time AS send_time FROM srv_notifications n, srv_notifications_messages m WHERE n.id='$id' AND m.id=n.message_id"); $row = mysqli_fetch_array($sql); // Refresh vseh prejetih sporocil + echo '
    '; + echo '
    '; + echo '

    '.$lang['srv_notifications_recieved'].'

    '; + echo '
    '; + + echo '
    '; + + echo '
    '; echo '
    '; $this->displayRecievedMessages($active=$id); echo '
    '; - + echo '
    '; + // Prikaz izbranega sporocila + echo '
    '; echo '
    '; - echo ''.$row['title'].' ('.$row['date'].')'; - echo '

    '.nl2br($row['text']).'

    '; + + echo '
    '; + echo $row['title']; + echo '
    '; + + echo '
    '; + echo '('.date('Y-m-d H:i:s', strtotime($row['send_time'])).')'; + echo '
    '; + + // Stara sporocila so brez editorja + $text = (strtotime($row['send_time']) < strtotime('2021-08-26')) ? nl2br($row['text']) : $row['text']; + echo '
    '; + echo $text; + echo '
    '; + echo '
    '; echo '
    '; + + echo '
    '; //div.notifications_content } - public function ajax_viewUnreadMessages(){ + public function ajax_viewUnreadMessages($active=0){ global $lang, $global_user_id; - echo '

    '.$lang['srv_notifications_unread'].'

    '; + echo '

    '.$lang['srv_notifications_unread'].'

    '; - echo '
      '; + echo '
      '; // Loop cez vsa neprebrana sporocila - $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.date AS date, n.viewed AS viewed + $sql = sisplet_query("SELECT n.id AS id, m.title AS title, m.text AS text, m.send_time AS send_time, n.viewed AS viewed FROM srv_notifications n, srv_notifications_messages m - WHERE n.recipient='".$global_user_id."' AND n.viewed='0' AND m.id=n.message_id - ORDER BY m.date DESC"); + WHERE n.recipient='".$global_user_id."' AND n.viewed='0' AND m.id=n.message_id + ORDER BY m.send_time DESC"); while($row = mysqli_fetch_array($sql)){ - echo '
    • '; + echo '
      '; - echo ''.$row['title'].' ('.$row['date'].')'; + echo ''.$row['title'].' ('.date('Y-m-d H:i:s', strtotime($row['send_time'])).')'; - echo '
      '.nl2br($row['text']); + // Stara sporocila so brez editorja + $text = (strtotime($row['send_time']) < strtotime('2021-08-26')) ? nl2br($row['text']) : $row['text']; + echo '
      '.$text; - echo '
    • '; + echo '
      '; } - echo '
    '; + echo '
    '; // Gumb za zapiranje - echo '
    '; - echo ''; + echo '
    '; + echo ' '; echo '
    '; @@ -379,28 +500,25 @@ class Notifications { } public function ajax_viewGDPRMessage(){ - global $lang, $global_user_id, $aai_instalacija; - - echo '

    '.$lang['srv_notifications_unread'].'

    '; + global $lang, $global_user_id; - echo '
      '; - echo '
    • '; + echo '

      '.$lang['srv_notifications_unread'].'

      '; - if(isset($aai_instalacija) && $aai_instalacija == true){ + /* if(isAAI()){ echo ''.$lang['srv_gdpr_notification_title_aai'].''; } else{ echo ''.$lang['srv_gdpr_notification_title'].''; } - echo '

      '; + echo '

      '; */ echo $lang['srv_gdpr_notification_text1']; echo '

      '; echo $lang['srv_gdpr_notification_question']; - echo '
      '; + echo '

      '; echo '
      '; //echo ' '.$lang['srv_invitation_nonActivated_more'].''; echo '
      '; @@ -409,21 +527,13 @@ class Notifications { echo '
      '; - echo $lang['srv_gdpr_notification_pogoji']; - - echo '
    • '; - echo '
    '; + echo $lang['srv_gdpr_notification_unsubscribe']; // Gumb za zapiranje - //echo '
    '; - echo ''; + echo ''; } public function ajax_saveGDPRAgree(){ -- cgit v1.2.3