Skip to content

Commit

Permalink
v1.7.4 (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
bfren authored Sep 8, 2023
2 parents 5ffd8e4 + 6602b3b commit 1aeb180
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 45 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.3
1.7.4
2 changes: 1 addition & 1 deletion docker/overlay/tmp/PHP_BUILD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2.9-r0
8.2.10-r0
2 changes: 1 addition & 1 deletion src/classes/config/config-cache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ class Config_Cache
*/
public function __construct(array $config)
{
$this->duration_in_seconds = Arr::get($config, "duration_in_seconds", 3600);
$this->duration_in_seconds = Arr::get_integer($config, "duration_in_seconds", 3600);
}
}
2 changes: 1 addition & 1 deletion src/classes/config/config-events.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(array $config)
{
$this->cancelled_flag = Arr::get($config, "cancelled_flag", "[Cancelled]");
$this->default_location = Arr::get($config, "default_location", "Church");
$this->length_in_minutes = Arr::get($config, "length_in_minutes", 60);
$this->length_in_minutes = Arr::get_integer($config, "length_in_minutes", 60);
$this->pending_flag = Arr::get($config, "pending_flag", "[tbc]");
$this->timezone = new DateTimeZone(Arr::get($config, "timezone", "Europe/London"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/classes/config/config-login.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(array $config)
{
$this->admin = Arr::get($config, "admin", "");
$this->api = Arr::get($config, "api", "");
$this->max_attempts = Arr::get($config, "max_attempts", 5);
$this->max_attempts = Arr::get_integer($config, "max_attempts", 5);
$this->pass = Arr::get($config, "pass", "");
}
}
4 changes: 2 additions & 2 deletions src/classes/config/config-refresh.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class Config_Refresh
*/
public function __construct(array $config)
{
$this->days_before = Arr::get($config, "days_before", 7);
$this->days_after = Arr::get($config, "days_after", 2);
$this->days_before = Arr::get_integer($config, "days_before", 7);
$this->days_after = Arr::get_integer($config, "days_after", 2);
$this->footer_page_1_left = Arr::get($config, "footer_page_1_left", "");
$this->footer_page_1_right = Arr::get($config, "footer_page_1_right", "");
$this->footer_page_2_left = Arr::get($config, "footer_page_2_left", "");
Expand Down
2 changes: 1 addition & 1 deletion src/classes/config/config-rota.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Config_Rota
public function __construct(array $config)
{
$this->bible_version = Arr::get($config, "bible_version", "NIVUK");
$this->default_days = Arr::get($config, "default_days", 28);
$this->default_days = Arr::get_integer($config, "default_days", 28);
$this->default_length = new DateInterval(Arr::get($config, "default_length", "PT60M"));

$ministries = array();
Expand Down
10 changes: 3 additions & 7 deletions src/classes/prayer/prayer-calendar.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function get_people(?array $hashes = null): array
* Get the people on a particular day from the prayer calendar.
*
* @param DateTimeImmutable $dt Date.
* @return Person[] Array of people.
* @return array Array of people.
*/
public static function get_day(DateTimeImmutable $dt, int $return_as = self::RETURN_FULL_NAME): array
{
Expand All @@ -66,12 +66,8 @@ public static function get_day(DateTimeImmutable $dt, int $return_as = self::RET
// if we are at the end of the month return the configured additional people
$day = (int)$dt->format("j");
if (in_array($day, array(29, 30, 31))) {
if ($return_as == self::RETURN_FULL_NAME) {
$day = sprintf("day_%s", $day);
return C::$prayer->$day;
} else {
return array();
}
$day = sprintf("day_%s", $day);
return C::$prayer->$day;
}

// get the people hashes for the day
Expand Down
7 changes: 5 additions & 2 deletions src/pages/parts/header/nav-part.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Feeds\Request\Request;
use Feeds\Response\View;

use function PHPSTORM_META\map;

App::check();

/** @var View $this */
Expand All @@ -17,15 +19,16 @@
$links = array(
"Home" => "/",
"Rota" => "/rota",
"Prayer Calendar" => "/prayer",
"Refresh" => "/refresh",
"Log Out" => "/auth/logout"
);
if (Request::$session->is_admin) {
$links = array_merge(
array_slice($links, 0, 1),
array("Upload" => "/upload"),
array_slice($links, 1)
array_slice($links, 1, 1),
array("Prayer Calendar" => "/prayer"),
array_slice($links, 2)
);
}
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/pages/prayer/index-model.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public function __construct(
public readonly ?Result $result,
public readonly array $months,
public readonly string $next_month
)
{

) {
}
}
35 changes: 16 additions & 19 deletions src/pages/prayer/index-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Feeds\App;
use Feeds\Pages\Parts\Header\Header_Model;
use Feeds\Request\Request;
use Feeds\Response\View;

App::check();
Expand Down Expand Up @@ -32,30 +31,28 @@
?>
<li>
<a href="/refresh/print/?<?php _e(http_build_query($view_query)); ?>" target="_blank"><?php _e($month); ?></a>
<?php if (Request::$session->is_admin) : ?>
<a class="badge rounded-pill text-bg-warning fw-bold" href="/prayer/edit/?<?php _e(http_build_query($edit_query)); ?>">edit</a>
<a class="badge rounded-pill text-bg-danger fw-bold check-first" href="/prayer/delete/?<?php _e(http_build_query($delete_query)); ?>">delete</a>
<?php endif; ?>
<a class="badge rounded-pill text-bg-warning fw-bold" href="/prayer/edit/?<?php _e(http_build_query($edit_query)); ?>">edit</a>
<a class="badge rounded-pill text-bg-danger fw-bold check-first" href="/prayer/delete/?<?php _e(http_build_query($delete_query)); ?>">delete</a>
</li>
<?php endforeach; ?>
</ul>
<?php else : ?>
<p>Nothing to see here - please try again later!</p>
<?php endif; ?>

<?php if (Request::$session->is_admin) : ?>
<h2>Create</h2>
<p>Please enter the month to create a calendar for, and click 'Create'.</p>
<form class="row row-cols-lg-auto g-3 mb-3 align-items-center needs-validation" method="GET" action="/prayer/edit/" novalidate>
<div class="col-12 position-relative">
<label class="visually-hidden" for="for">Month</label>
<input type="text" class="form-control" id="for" name="for" placeholder="Month e.g. '<?php _e($model->next_month); ?>'" required />
<div class="invalid-tooltip">Please enter the month to create a prayer calendar for.</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Create</button>
</div>
</form>
<?php endif;
<h2>Create</h2>
<p>Please enter the month to create a calendar for, and click 'Create'.</p>
<form class="row row-cols-lg-auto g-3 mb-3 align-items-center needs-validation" method="GET" action="/prayer/edit/" novalidate>
<div class="col-12 position-relative">
<label class="visually-hidden" for="for">Month</label>
<input type="text" class="form-control" id="for" name="for" placeholder="Month e.g. '<?php _e($model->next_month); ?>'" required />
<div class="invalid-tooltip">Please enter the month to create a prayer calendar for.</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Create</button>
</div>
</form>

<?php

$this->footer();
2 changes: 0 additions & 2 deletions src/pages/prayer/prayer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function index_get(): View
*
* @return Action
*/
#[Require_Admin]
public function edit_get(): Action
{
// define variables
Expand Down Expand Up @@ -95,7 +94,6 @@ public function edit_get(): Action
*
* @return View
*/
#[Require_Admin]
public function delete_get(): View
{
// get file and delete
Expand Down
3 changes: 1 addition & 2 deletions src/pages/refresh/day-model.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Feeds\App;
use Feeds\Bible\Bible_Plan;
use Feeds\Lectionary\Lectionary;
use Feeds\Prayer\Prayer_Calendar;

App::check();

Expand All @@ -15,7 +14,7 @@ class Day_Model
/**
* Create Day model.
*
* @param DateTimeImmutable $day Formatted string to display the month being displayed.
* @param DateTimeImmutable $day The day being displayed.
* @param Bible_Plan $bible_plan Bible Plan (to save loading each time).
* @param Lectionary $lectionary Lectionary (to save loading each time).
*/
Expand Down
2 changes: 1 addition & 1 deletion src/pages/refresh/day-part.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<?php else : ?>
<?php if (isset($people)) : ?>
<div class="people">
<?php _h(join(", ", array_map(function ($name) { return str_replace(" ", "&nbsp;", $name); }, $people))); ?>
<?php _h(join(", ", array_map(fn (string $name) => str_replace(" ", "&nbsp;", $name), $people))); ?>
</div>
<?php endif; ?>
<?php if (isset($readings)) : ?>
Expand Down
2 changes: 1 addition & 1 deletion src/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Router::map_page(P\Ajax\Ajax::class);
Router::map_page(P\Auth\Auth::class, requires_auth: false);
Router::map_page(P\Events\Events::class, requires_auth: false);
Router::map_page(P\Prayer\Prayer::class);
Router::map_page(P\Prayer\Prayer::class, requires_admin: true);
Router::map_page(P\Preload\Preload::class, requires_auth: false);
Router::map_page(P\Refresh\Refresh::class);
Router::map_page(P\Rota\Rota::class);
Expand Down

0 comments on commit 1aeb180

Please sign in to comment.