Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Commit

Permalink
feat(releases): upgrade for Elgg 3
Browse files Browse the repository at this point in the history
  • Loading branch information
hypeJunction committed Mar 19, 2018
1 parent 526589d commit f83668b
Show file tree
Hide file tree
Showing 61 changed files with 1,944 additions and 1,637 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# hypeNotifications for Elgg

![Elgg 2.2](https://img.shields.io/badge/Elgg-2.2-orange.svg?style=flat-square)
![Elgg 3.0](https://img.shields.io/badge/Elgg-3.0-orange.svg?style=flat-square)

![Popup](https://raw.github.com/hypeJunction/hypeNotifications/master/screenshots/popup.png "Popup")
![Digest](https://raw.github.com/hypeJunction/hypeNotifications/master/screenshots/digest.png "Email Digest")
Expand All @@ -11,7 +11,7 @@
* Email digest: users can specify at which interval they receive notifications for each type
* A tool to update preferred notification methods for all site users
* Leverages `Zend_Mail` (email library used in core) to send out HTML emails
* Allows to configure email transports (Sendmail, SMTP, File Transport)
* Allows to configure email transports (Sendmail, SMTP, File Transport, SendGrid, Mailgun, SparkPost)
* Allows to send file attachments
* Inlines CSS styles for improved email client experience
* Simpler testing experience: catch all email address, email/domain whitelist
Expand Down
2 changes: 1 addition & 1 deletion actions/admin/notifications/test_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
}

$result = elgg_send_email($site->email, $recipient, $subject, $body, array(
$result = elgg_send_email(null, $recipient, $subject, $body, array(
'attachments' => $attachments,
), 'email');

Expand Down
50 changes: 50 additions & 0 deletions actions/hypeNotifications/settings/save.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Saves global plugin settings.
*
* This action can be overriden for a specific plugin by creating the
* <plugin_id>/settings/save action in that plugin.
*
* @uses array $_REQUEST['params'] A set of key/value pairs to save to the ElggPlugin entity
* @uses int $_REQUEST['plugin_id'] The ID of the plugin
*/

$params = get_input('params');
$plugin_id = get_input('plugin_id');
$plugin = elgg_get_plugin_from_id($plugin_id);

if (!$plugin) {
return elgg_error_response(elgg_echo('plugins:settings:save:fail', [$plugin_id]));
}

$plugin_name = $plugin->getDisplayName();

$result = false;

$config = [
'transport',
'smtp_host_name',
'smtp_host',
'smtp_port',
'smtp_connection',
'smtp_username',
'smtp_password',
'smtp_ssl',
'sparkpost_apikey',
'sendgrid_apikey',
'mailgun_apikey',
'mailgun_domain',
];

foreach ($params as $k => $v) {
if (in_array($k, $config)) {
elgg_save_config("email.$k", $v);
} else {
$result = $plugin->setSetting($k, $v);
if (!$result) {
return elgg_error_response(elgg_echo('plugins:settings:save:fail', [$plugin_name]));
}
}
}

return elgg_ok_response('', elgg_echo('plugins:settings:save:ok', [$plugin_name]));
88 changes: 0 additions & 88 deletions actions/upgrade/notifications/notifier.php

This file was deleted.

41 changes: 41 additions & 0 deletions classes/hypeJunction/Notifications/AddHtmlEmailPart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace hypeJunction\Notifications;

use Elgg\Hook;
use Zend\Mail\Message;
use Zend\Mime\Mime;
use Zend\Mime\Part;

class AddHtmlEmailPart {

/**
* Add HTML email part
*
* @param Hook $hook Hook
* @return Message
*/
public function __invoke(Hook $hook) {

$message = $hook->getValue();
/* @var $message Message */

if (elgg_get_plugin_setting('enable_html_emails', 'hypeNotifications')) {

$html_body = elgg_view('notifications/wrapper/html', [
'email' => $hook->getParam('email'),
]);

if ($html_body) {
$html_part = new Part($html_body);
$html_part->setCharset('UTF-8');
$html_part->setType(Mime::TYPE_HTML);

$message->getBody()->addPart($html_part);
}
}

return $message;

}
}
14 changes: 9 additions & 5 deletions classes/hypeJunction/Notifications/DigestNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ public function __construct(stdClass $row = null) {
public function save() {
$id = $this->id;

$svc = DigestService::getInstance();
$table = elgg()->{'db.digest'};
/* @var $table DigestTable */

if (!$id) {
$this->set('time_created', time());
return $svc->getTable()->insert($this);
return $table->insert($this);
} else {
return $svc->getTable()->update($this);
return $table->update($this);
}
}

Expand Down Expand Up @@ -124,8 +126,10 @@ public function setTimeScheduled($timestamp = null) {
* {@inheritdoc}
*/
public function delete() {
$svc = DigestService::getInstance();
return $svc->getTable()->delete($this->id);
$table = elgg()->{'db.digest'};
/* @var $table DigestTable */

return $table->delete($this->id);
}

/**
Expand Down
Loading

0 comments on commit f83668b

Please sign in to comment.