Skip to content

Commit

Permalink
display your own MP's keywords alerts even if no speaks alert
Browse files Browse the repository at this point in the history
Even if you haven't signed up for a "everything they say" alert from
your MP show any "when they mention" alerts under the speaks sign up
prompt. Splits the alert list into a separate template to make this
easier.
  • Loading branch information
struan committed Oct 31, 2024
1 parent 132e3e6 commit eb8b4f1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
</form>
</div>
<?php if ($current_mp) { ?>
<h3 class="alert-page-subsection--heading"><?= gettext('Your MP') ?></h3>
<ul class="alerts-manage__list">
<li>
<?= sprintf(gettext('You are not subscribed to an alert for your current MP, %s'), $current_mp->full_name()) ?>.
Expand All @@ -169,58 +170,17 @@
</form>
</li>
</ul>
<?php } else { ?>
<?php if (count($own_member_alerts) > 0) { ?>
<p>
<?= gettext('You are subscribed to the following alerts about your MP.') ?>
</p>
<?php include '_own_mp_alerts.php' ?>
<?php } ?>
<?php } elseif (count($own_member_alerts) > 0) { ?>
<div class="alert-page-subsection">
<h3 class="alert-page-subsection--heading"><?= gettext('Your MP') ?><?= $own_member_alerts[0]['spokenby'][0] ?></h3>

<?php foreach ($own_member_alerts as $alert) { ?>
<p class="alert-page-subsection--subtitle"><?= _htmlspecialchars($alert['criteria']) ?></p>
<div class="alert-page-alert-controls">
<form action="<?= $actionurl ?>" method="POST">
<input type="hidden" name="t" value="<?= _htmlspecialchars($alert['token']) ?>">
<?php if ($alert['status'] == 'unconfirmed') { ?>
<button type="submit" class="button small" name="action" value="Confirm">
<span><?= gettext('Confirm alert') ?></span>
<i aria-hidden="true" class="fi-save"></i>
</button>
<?php } elseif ($alert['status'] == 'suspended') { ?>
<button type="submit" class="button small" name="action" value="Resume">
<span><?= gettext('Resume alert') ?></span>
<i aria-hidden="true" class="fi-play"></i>
</button>
<?php } else { ?>
<button typ="submit" class="button small" value="Suspend">
<span><?= gettext('Suspend alert') ?></span>
<i aria-hidden="true" class="fi-pause"></i>
</button>
<button typ="submit" class="button small" value="Delete">
<span><?= gettext('Delete alert') ?></span>
<i aria-hidden="true" class="fi-trash"></i>
</button>
</form>
<form action="<?= $actionurl ?>" method="POST">
<input type="hidden" name="step" value="define">
<input type="hidden" name="shown_related" value="1">
<input type="hidden" name="t" value="<?= _htmlspecialchars($alert['token']) ?>">
<button type="submit" class="button small" value="Edit">
<span><?= gettext('Edit alert') ?></span>
<i aria-hidden="true" class="fi-page-edit"></i>
</button>
</form>
<?php } ?>
</div>
<?php } ?>

<?php if (!in_array(implode('', $own_member_alerts[0]['spokenby']), $all_keywords)) { ?>
<p class="alert-page-subsection--subtitle">Alert when <?= _htmlspecialchars(implode(', ', $alert['spokenby'])) ?> is <strong>mentioned</strong></p>
<form action="<?= $actionurl ?>" method="post">
<input type="hidden" name="keyword" value="<?= _htmlentities(implode('', $alert['spokenby'])) ?>">
<button type="submit" class="button small" name="action" value="Subscribe">
<?= gettext('Create new alert') ?>
<i aria-hidden="true" role="img" class="fi-megaphone"></i>
</button>
</form>
<?php } ?>
<?php include '_own_mp_alerts.php' ?>
</div>
<?php } ?>

Expand Down Expand Up @@ -248,7 +208,7 @@
<span><?= gettext('Suspend alert') ?></span>
<i aria-hidden="true" class="fi-pause"></i>
</button>
<button type="submit" class="button small" name="action" value="Delete">
<button type="submit" class="button small red" name="action" value="Delete">
<span><?= gettext('Delete alert') ?></span>
<i aria-hidden="true" class="fi-trash"></i>
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

<?php foreach ($own_member_alerts as $alert) { ?>
<p class="alert-page-subsection--subtitle"><?= _htmlspecialchars($alert['criteria']) ?></p>
<div class="alert-page-alert-controls">
<form action="<?= $actionurl ?>" method="POST">
<input type="hidden" name="t" value="<?= _htmlspecialchars($alert['token']) ?>">
<?php if ($alert['status'] == 'unconfirmed') { ?>
<button type="submit" class="button small" name="action" value="Confirm">
<span><?= gettext('Confirm alert') ?></span>
<i aria-hidden="true" class="fi-save"></i>
</button>
<?php } elseif ($alert['status'] == 'suspended') { ?>
<button type="submit" class="button small" name="action" value="Resume">
<span><?= gettext('Resume alert') ?></span>
<i aria-hidden="true" class="fi-play"></i>
</button>
<?php } else { ?>
<button type="submit" class="button small" name="action" value="Suspend">
<span><?= gettext('Suspend alert') ?></span>
<i aria-hidden="true" class="fi-pause"></i>
</button>
<button type="submit" class="button small red" name="action" value="Delete">
<span><?= gettext('Delete alert') ?></span>
<i aria-hidden="true" class="fi-trash"></i>
</button>
</form>
<form action="<?= $actionurl ?>" method="POST">
<input type="hidden" name="step" value="define">
<input type="hidden" name="shown_related" value="1">
<input type="hidden" name="t" value="<?= _htmlspecialchars($alert['token']) ?>">
<button type="submit" class="button small" value="Edit">
<span><?= gettext('Edit alert') ?></span>
<i aria-hidden="true" class="fi-page-edit"></i>
</button>
</form>
<?php } ?>
</div>
<?php } ?>

<?php if (!in_array(implode('', $own_member_alerts[0]['spokenby']), $all_keywords)) { ?>
<p class="alert-page-subsection--subtitle">Alert when <?= _htmlspecialchars(implode('', $own_member_alerts[0]['spokenby'])) ?> is <strong>mentioned</strong></p>
<form action="<?= $actionurl ?>" method="post">
<input type="hidden" name="keyword" value="<?= _htmlentities(implode('', $own_member_alerts[0]['spokenby'])) ?>">
<button type="submit" class="button small" name="action" value="Subscribe">
<?= gettext('Create new alert') ?>
<i aria-hidden="true" role="img" class="fi-megaphone"></i>
</button>
</form>
<?php } ?>

0 comments on commit eb8b4f1

Please sign in to comment.