diff --git a/classes/newsletter.php b/classes/newsletter.php index d5f020d..a72b9e3 100644 --- a/classes/newsletter.php +++ b/classes/newsletter.php @@ -208,7 +208,7 @@ public function get_instance(): object { /** * Get subscription id of user if $userid = 0 id of current user is returned * - * @param int userid + * @param int $userid * @return int|boolean subscriptionid | false if no subscription is found */ public function get_subid(int $userid = 0) { @@ -274,19 +274,6 @@ public function get_config(): object { return $this->config; } - /** - * get all subscribed users for a newsletter instance - * - * @return array of objects with subscription id as key - */ - public function get_subscriptions(): array { - global $DB; - return $DB->get_records( - 'newsletter_subscriptions', - array('id' => $this->get_instance()->id) - ); - } - /** * Reset user data * @@ -1137,7 +1124,7 @@ private function view_manage_subscriptions(array $params) { * @return int * @throws \dml_exception */ - public static function get_delivered_issues($userid) { + public static function get_delivered_issues($userid): int { global $DB; $delivered = $DB->count_records('newsletter_deliveries', array('userid' => $userid)); return $delivered; @@ -1288,6 +1275,10 @@ private function prepare_issue_list($heading, $groupby) { $dateformat = get_string("week") . " %W/%Y"; $datefromto = "%d. %B %Y"; break; + default: + $from = strtotime("first day of this month", $firstissue->publishon); + $to = strtotime("next month", $from); + $dateformat = "%B %Y"; } $sectionlist = new \newsletter_section_list($heading); @@ -1335,7 +1326,7 @@ private function prepare_issue_list($heading, $groupby) { if (!($issue->publishon > time() && !$editissue)) { // Do not display issues that // are not yet published. $currentissuelist->add_issue_summary( - new \newsletter_issue_summary($issue, $editissue, $deleteissue) + new \newsletter_issue_summary($issue, $editissue, $deleteissue, $duplicateissue) ); } } // End if issue in timeslot. diff --git a/renderable.php b/renderable.php index f1dd24a..cc3bf7e 100755 --- a/renderable.php +++ b/renderable.php @@ -123,12 +123,14 @@ public function __construct(stdClass $issue) { } } +/** + * + */ class newsletter_issue_summary extends newsletter_issue { public $editissue; public $deleteissue; public $duplicateissue; - public function __construct(stdClass $issue, $editissue = false, $deleteissue = false, $duplicateissue = false) { parent::__construct($issue); $this->editissue = $editissue; @@ -138,9 +140,9 @@ public function __construct(stdClass $issue, $editissue = false, $deleteissue = } class newsletter_subscription_list implements renderable { - public $cmid; - public $subscriptions; - public $columns; + public int $cmid; + public array $subscriptions; + public array $columns; public function __construct($cmid, array $subscriptions, array $columns) { $this->cmid = $cmid; $this->subscriptions = $subscriptions; @@ -166,8 +168,8 @@ public function add_issue_summary(newsletter_issue_summary $issue) { class newsletter_section_list implements renderable { - public $heading = ''; - public $sections = array(); + public string $heading = ''; + public array $sections = array(); /** * Constructor diff --git a/renderer.php b/renderer.php index 5c5d40d..fa42619 100755 --- a/renderer.php +++ b/renderer.php @@ -201,11 +201,6 @@ public function render_newsletter_issue_summary(newsletter_issue_summary $issue) $output .= $this->render( new newsletter_progressbar($issue->numnotyetdelivered, $issue->numdelivered)); } - - if ($issue->duplicateissue) { - $output .= $this->render( - new newsletter_progressbar($issue->numnotyetdelivered, $issue->numdelivered)); - } } else { $output .= $this->render(new newsletter_publish_countdown($now, $issue->publishon)); } @@ -364,8 +359,8 @@ public function render_newsletter_progressbar(newsletter_progressbar $progressba } $output .= html_writer::start_tag('div', array('class' => 'progress')); - $output .= html_writer::div($completed, '', - array('class' => 'progress-bar', 'role' => 'progressbar', + $output .= html_writer::div($completed, 'progress-bar', + array('role' => 'progressbar', 'aria-valuenow' => $value, 'aria-valuemin' => '0', 'aria-valuemax' => '100', 'style' => 'width:' . $value . '%')); $output .= html_writer::end_tag('div');