Skip to content

Commit 7a88728

Browse files
authored
Allow a plugin to update phplist (#946)
* Allow a plugin to update the phplist code * When a new release is available link to a plugin if available in preference to the updater
1 parent b999690 commit 7a88728

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* A plugin should implement this interface if it wants to be responsible for updating phpList.
4+
* It should implement an admin page with the name "update".
5+
*/
6+
interface Updater
7+
{
8+
}

public_html/lists/admin/index.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -523,24 +523,25 @@ function mb_strtolower($string)
523523
echo Info($GLOBALS['I18N']->get('Running in testmode, no emails will be sent. Check your config file.'));
524524
}
525525

526-
# if (!DEVVERSION) { ## why not, quite useful to see
527-
if (ALLOW_UPDATER) {
526+
if (ALLOW_UPDATER || $updaterplugin) {
528527
$updaterdir = __DIR__ . '/../updater';
529528

530529
include 'updateLib.php';
531530
$updateNotif = checkForUpdate();
532-
$moreInfo = ' <ul><li><a href="https://www.phplist.com/download?utm_source=pl' . VERSION . '&amp;utm_medium=updatedownload&amp;utm_campaign=phpList" title="' . s('Download the new version') . '" target="_blank">' . s('Download the new version') . '</a></li>';
533531

534-
if (file_exists($updaterdir)) {
535-
$moreInfo .= '<li>'.s('or use the %sphpList Updater%s','<a href="?page=update" title="' . s('automatic updater') . '">','</a>');
536-
}
537-
$moreInfo .= '</ul>';
532+
if ($updateNotif !== '' && $_GET['page'] !== 'update') {
533+
$moreInfo = ' <ul><li><a href="https://www.phplist.com/download?utm_source=pl' . VERSION . '&amp;utm_medium=updatedownload&amp;utm_campaign=phpList" title="' . s('Download the new version') . '" target="_blank">' . s('Download the new version') . '</a></li>';
538534

539-
if ($updateNotif !== '') {
535+
if ($updaterplugin) {
536+
$class = get_class($updaterplugin);
537+
$moreInfo .= '<li>'.s('or use the %sphpList Updater%s', sprintf('<a href="?page=update&amp;pi=%s" title="', $class) . s('automatic updater') . '">','</a>');
538+
} elseif (file_exists($updaterdir)) {
539+
$moreInfo .= '<li>'.s('or use the %sphpList Updater%s','<a href="?page=update" title="' . s('automatic updater') . '">','</a>');
540+
}
541+
$moreInfo .= '</ul>';
540542
Info($updateNotif . '' . $moreInfo);
541543
}
542544
}
543-
# }
544545

545546
if (version_compare(PHP_VERSION, '5.3.3', '<') && WARN_ABOUT_PHP_SETTINGS) {
546547
Error(s('Your PHP version is out of date. phpList requires PHP version 5.3.3 or higher.'));

public_html/lists/admin/pluginlib.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
require_once dirname(__FILE__).'/EmailSender.php';
55
include_once dirname(__FILE__).'/defaultplugin.php';
66
require_once dirname(__FILE__).'/AnalyticsQuery.php';
7+
require_once dirname(__FILE__).'/Updater.php';
78

89
$GLOBALS['plugins'] = array();
910
$GLOBALS['editorplugin'] = false;
1011
$GLOBALS['authenticationplugin'] = false;
1112
$GLOBALS['emailsenderplugin'] = false;
1213
$GLOBALS['analyticsqueryplugin'] = false;
14+
$GLOBALS['updaterplugin'] = false;
1315

1416
$pluginRootDirs = array();
1517
if (PLUGIN_ROOTDIRS != '') {
@@ -123,6 +125,10 @@
123125
$default_config['analytic_tracker']['values'] += array('plugin' => $analyticsqueryplugin->name);
124126
}
125127

128+
if (!$GLOBALS['updaterplugin'] && $pluginInstance instanceof Updater) {
129+
$GLOBALS['updaterplugin'] = $pluginInstance;
130+
}
131+
126132
if (!empty($pluginInstance->DBstruct)) {
127133
foreach ($pluginInstance->DBstruct as $tablename => $tablecolumns) {
128134
$GLOBALS['tables'][$className.'_'.$tablename] = $GLOBALS['table_prefix'].$className.'_'.$tablename;

0 commit comments

Comments
 (0)