Pārlūkot izejas kodu

Add a page to list redirects to the own mailbox

ohartl 9 gadi atpakaļ
vecāks
revīzija
4dc50750c9

+ 4 - 0
include/php/pages/private/start.php

@@ -6,4 +6,8 @@
 
 <div class="buttons buttons-horizontal button-large">
 	<a class="button" href="<?php echo url('private/changepass'); ?>">Change your password</a>
+</div>
+
+<div class="buttons buttons-horizontal button-large">
+	<a class="button" href="<?php echo url('private/yourredirects'); ?>">Redirects to your mailbox</a>
 </div>

+ 52 - 0
include/php/pages/private/yourredirects.php

@@ -0,0 +1,52 @@
+<?php
+
+$ownEmail = Auth::getUser()->getEmail();
+
+$redirects = AbstractRedirect::findMultiWhere(
+	array(DBC_ALIASES_DESTINATION, 'LIKE', '%'.$ownEmail.'%')
+);
+
+function anonymizeEmails($emails, $ownEmail){
+	if(is_string($emails) || count($emails) === 1){
+		return $ownEmail;
+	}
+
+	return array($ownEmail, '&hellip;');
+}
+?>
+
+	<h1>Redirects to your mailbox</h1>
+
+	<div class="buttons">
+		<a class="button" href="<?php echo url('private'); ?>">&#10092; Back to personal dashboard</a>
+	</div>
+
+<?php output_messages(); ?>
+
+<?php if($redirects->count() > 0): ?>
+	<table class="table">
+		<thead>
+		<tr>
+			<th>Source</th>
+			<th>Destination</th>
+		<tr>
+		</thead>
+		<tbody>
+		<?php foreach($redirects as $redirect): /** @var AbstractRedirect $redirect */ ?>
+			<tr>
+				<td><?php echo formatEmails($redirect->getSource(), str_replace(PHP_EOL, '<br>', FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
+				<td><?php echo formatEmails(anonymizeEmails($redirect->getDestination(), $ownEmail), str_replace(PHP_EOL, '<br>', FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
+			</tr>
+		<?php endforeach; ?>
+		</tbody>
+		<tfoot>
+		<tr>
+			<th><?php echo ($redirects->count() > 1) ? $redirects->count().' Redirects' : '1 Redirect'; ?></th>
+		</tr>
+		</tfoot>
+	</table>
+<?php else: ?>
+	<div class="notification notification-warning">
+		There are currently no redirects to your mailbox.
+	</div>
+<?php endif; ?>

+ 1 - 0
include/php/routes.inc.php

@@ -18,6 +18,7 @@ Router::addGet('/logout', function(){
  */
 Router::addGet('/private', 'include/php/pages/private/start.php', User::ROLE_USER);
 Router::addMixed('/private/changepass', 'include/php/pages/private/changepass.php', User::ROLE_USER);
+Router::addGet('/private/yourredirects', 'include/php/pages/private/yourredirects.php', User::ROLE_USER);
 
 
 /**