mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
Closes #5106 - system notification consolidation.
This commit is contained in:
@@ -135,16 +135,20 @@ class admin_start
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if(!e107::getDb()->isTable('admin_log')) // Upgrade from v1.x to v2.x required.
|
||||
{
|
||||
$this->upgradeRequiredFirst = true;
|
||||
}
|
||||
|
||||
// eHelper::clearSystemNotification(); // clear the notifications.
|
||||
|
||||
// Files that can cause comflicts and problems.
|
||||
$fileInspector = e107::getFileInspector();
|
||||
$this->deprecated = $fileInspector::getCachedDeprecatedFiles();
|
||||
|
||||
$this->checkCoreVersion();
|
||||
$this->checkDependencies();
|
||||
|
||||
if(!empty($_POST['delete-deprecated']))
|
||||
{
|
||||
@@ -205,7 +209,8 @@ class admin_start
|
||||
$this->checkDeveloperMode();
|
||||
|
||||
|
||||
if($this->refresh == true)
|
||||
|
||||
if($this->refresh)
|
||||
{
|
||||
e107::getRedirect()->go(e_REQUEST_SELF);
|
||||
}
|
||||
@@ -213,7 +218,9 @@ class admin_start
|
||||
// delete half-completed user accounts. (previously called in header.php )
|
||||
e107::getUserSession()->deleteExpired();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function checkPaths()
|
||||
{
|
||||
@@ -232,9 +239,13 @@ class admin_start
|
||||
else
|
||||
{
|
||||
$message = e107::getParser()->lanVars(ADLAN_187,$dr,true);
|
||||
$mes->addWarning($message);
|
||||
eHelper::addSystemNotification('check_paths_'.sha1($dr), $message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eHelper::clearSystemNotification('check_paths_'.sha1($dr));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -284,7 +295,7 @@ class admin_start
|
||||
// auto db update
|
||||
if ('0' != ADMINPERMS)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->upgradeRequiredFirst)
|
||||
@@ -488,13 +499,13 @@ TMPO;
|
||||
if(deftrue('e_MEDIA') && is_dir(e_MEDIA) && !is_writable(e_MEDIA))
|
||||
{
|
||||
$message = str_replace("[x]", e_MEDIA, ADLAN_193);
|
||||
$mes->addWarning($message);
|
||||
$mes->addWarning($message);
|
||||
}
|
||||
|
||||
if(deftrue('e_SYSTEM') && is_dir(e_SYSTEM) && !is_writable(e_SYSTEM))
|
||||
{
|
||||
$message = str_replace("[x]", e_SYSTEM, ADLAN_193);
|
||||
$mes->addWarning($message);
|
||||
$mes->addWarning($message);
|
||||
}
|
||||
|
||||
$files = e107::getFile()->scandir(e_IMAGE."avatars",'jpg,gif,png,jpeg');
|
||||
@@ -526,7 +537,8 @@ TMPO;
|
||||
{
|
||||
if($this->upgradeRequiredFirst)
|
||||
{
|
||||
return null;
|
||||
eHelper::clearSystemNotification('checkIncompatiblePlugins');
|
||||
return;
|
||||
}
|
||||
|
||||
$mes = e107::getMessage();
|
||||
@@ -543,15 +555,21 @@ TMPO;
|
||||
|
||||
if(!empty($installedPlugs[$folder]) && ($version == $installedPlugs[$folder] || $version === '*'))
|
||||
{
|
||||
$inCompatText .= "<li><a title='".LAN_UNINSTALL."' href='".e_ADMIN."plugin.php?mode=installed&action=uninstall&path=".$folder."'>".$folder." v".$installedPlugs[$folder]."</a></li>";
|
||||
$url = e_ADMIN."plugin.php?searchquery=$folder&filter_options=&mode=installed&action=list&etrigger_filter=etrigger_filter";
|
||||
$inCompatText .= "<li><a title='".LAN_VIEW."' href='".$url."'>".$folder." v".$installedPlugs[$folder]."</a></li>";
|
||||
}
|
||||
}
|
||||
|
||||
if($inCompatText)
|
||||
{
|
||||
$text = "<ul>".$inCompatText."</ul>";
|
||||
$mes->addWarning(ADLAN_189." <br /><br />".$text);
|
||||
}
|
||||
eHelper::addSystemNotification('checkIncompatiblePlugins', ADLAN_189." <br /><br />".$text);
|
||||
// $mes->addWarning(ADLAN_189." <br /><br />".$text);
|
||||
}
|
||||
else
|
||||
{
|
||||
eHelper::clearSystemNotification('checkIncompatiblePlugins');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -560,7 +578,7 @@ TMPO;
|
||||
{
|
||||
if($this->upgradeRequiredFirst)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
$us = e107::getUserSession();
|
||||
@@ -570,8 +588,12 @@ TMPO;
|
||||
{
|
||||
$message = LAN_PASSWORD_WARNING;
|
||||
$srch = array('[',']');
|
||||
$repl = array("<a class='alert-link' href='".e_ADMIN."prefs.php#nav-core-prefs-security'>","</a>");
|
||||
$mes->addWarning(str_replace($srch,$repl,$message));
|
||||
$repl = array("<a class='text-info' href='".e_ADMIN."prefs.php#nav-core-prefs-security'>","</a>");
|
||||
eHelper::addSystemNotification('checkPasswordEncryption', str_replace($srch,$repl,$message));
|
||||
}
|
||||
else
|
||||
{
|
||||
eHelper::clearSystemNotification('checkPasswordEncryption');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -583,7 +605,11 @@ TMPO;
|
||||
|
||||
if($pref['developer'] && (strpos(e_SELF,'localhost') === false) && (strpos(e_SELF,'127.0.0.1') === false))
|
||||
{
|
||||
e107::getMessage()->addWarning($tp->toHTML(LAN_DEVELOPERMODE_CHECK, true));
|
||||
eHelper::addSystemNotification('checkDeveloperMode', $tp->toHTML(LAN_DEVELOPERMODE_CHECK, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
eHelper::clearSystemNotification('checkDeveloperMode');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,7 +617,27 @@ TMPO;
|
||||
|
||||
private function checkDependencies()
|
||||
{
|
||||
if(PHP_MAJOR_VERSION < 8)
|
||||
{
|
||||
$lanFallback = 'Your website is currently running an [outdated version of PHP], which may pose a security risk. If your plugins will allow it, we recommend upgrading to [x] to ensure that your website is secure and up-to-date.';
|
||||
$lan = defset('LAN_PHP_OUTDATED', $lanFallback);
|
||||
$url = e_ADMIN.'phpinfo.php';
|
||||
|
||||
$lan = e107::getParser()->lanVars($lan, 'PHP 8.2');
|
||||
|
||||
$srch = array('[',']');
|
||||
$repl = [
|
||||
"<a class='text-info' href='$url'>",
|
||||
"</a>"
|
||||
];
|
||||
|
||||
$lan = str_replace($srch, $repl, $lan);
|
||||
eHelper::addSystemNotification('checkDependencies', $lan);
|
||||
}
|
||||
else
|
||||
{
|
||||
eHelper::clearSystemNotification('checkDependencies');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -674,9 +720,13 @@ TMPO;
|
||||
{
|
||||
if(rename(e_BASE."e107.htaccess", e_BASE.".htaccess")===false)
|
||||
{
|
||||
e107::getMessage()->addWarning("Please rename your <b>e107.htaccess</b> file to <b>.htaccess</b>");
|
||||
eHelper::addSystemNotification('checkHtaccess', "Please rename your <b>e107.htaccess</b> file to <b>.htaccess</b>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eHelper::clearSystemNotification('checkDependencies');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1699,7 +1699,55 @@ Inverse 10 <span class="badge badge-inverse">10</span>
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function sc_admin_notifications()
|
||||
{
|
||||
// $content = @file_get_contents(e_SYSTEM."adminNotifications.json");
|
||||
if(!$array = eHelper::getSystemNotification())
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/*return '<ul class="admin-notifications nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle " title="" role="button" data-toggle="dropdown" data-bs-toggle="dropdown" href="#" aria-expanded="true">
|
||||
<i class="fas fa-bell fa-fw"></i></a>
|
||||
</li>
|
||||
</ul>';*/
|
||||
|
||||
$count = count($array);
|
||||
$lanNotify = defset('LAN_SYSTEM_NOTIFICATIONS_X', '[x] System Notifications');
|
||||
$lan = e107::getParser()->lanVars($lanNotify, $count);
|
||||
|
||||
|
||||
$text = '<ul id="admin-notifications" class=" nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle " title="'.$lan.'" role="button" data-toggle="dropdown" data-bs-toggle="dropdown" href="#" aria-expanded="true">
|
||||
<i class="fas fa-beat fa-bell fa-fw text-warning"></i>';
|
||||
|
||||
$text .= ($count > 1) ? '<sup class="text-warning">'.$count.'</sup>' : '';
|
||||
$text .= '</a>
|
||||
<ul class="dropdown-menu" role="menu">';
|
||||
|
||||
foreach($array as $row)
|
||||
{
|
||||
$text .= '<li class="dropdown-item-text">'.$row['message'].'</li>';
|
||||
}
|
||||
|
||||
$text .= '
|
||||
</ul>
|
||||
</li>
|
||||
</ul>';
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks for a new version of e107 that could be available for download.
|
||||
* @return string|null
|
||||
*/
|
||||
public function sc_admin_update()
|
||||
{
|
||||
if (!ADMIN) { return null; }
|
||||
@@ -1708,6 +1756,7 @@ Inverse 10 <span class="badge badge-inverse">10</span>
|
||||
|
||||
if(empty($pref['check_updates']))
|
||||
{
|
||||
eHelper::clearSystemNotification('sc_admin_update');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1733,13 +1782,18 @@ Inverse 10 <span class="badge badge-inverse">10</span>
|
||||
}
|
||||
|
||||
$data = e107::unserialize($cached);
|
||||
$message = e107::getParser()->lanVars(LAN_NEWVERSION,$data['version']);
|
||||
|
||||
eHelper::addSystemNotification('sc_admin_update', "<a class='text-info' href='".$data['url']."' target='_blank'>$message</a>");
|
||||
|
||||
if($data === false || isset($data['status']))
|
||||
{
|
||||
eHelper::clearSystemNotification('sc_admin_update');
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Don't check for updates if running locally (comment out the next line to allow check - but
|
||||
// remember it can cause delays/errors if its not possible to access the Internet
|
||||
if(e_DEBUG !== true)
|
||||
@@ -1748,13 +1802,15 @@ Inverse 10 <span class="badge badge-inverse">10</span>
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return '<ul class="core-update-available nav navbar-nav navbar-left">
|
||||
<li class="dropdown open">
|
||||
<a class="dropdown-toggle " title="Core Update Available" role="button" data-toggle="dropdown" data-bs-toggle="dropdown" href="#" aria-expanded="true">
|
||||
<i class="fa fa-cloud-download text-success"></i>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li class="nav-header navbar-header dropdown-header">'.e107::getParser()->lanVars(LAN_NEWVERSION,$data['version']).'</li>
|
||||
<li class="nav-header navbar-header dropdown-header">'.$message.'</li>
|
||||
<li><a href="'.$data['url'].'" rel="external"><i class="fa fa-download" ></i> '.LAN_DOWNLOAD.'</a></li>
|
||||
<li><a href="'.$data['infourl'].'" rel="external"><i class="fa fa-file-text-o "></i> Release Notes</a></li>
|
||||
</ul>
|
||||
@@ -2085,11 +2141,24 @@ Inverse 10 <span class="badge badge-inverse">10</span>
|
||||
}
|
||||
|
||||
// $template = $$tmpl;
|
||||
if(e107::getSession()->get('core-update-status')===true)
|
||||
{
|
||||
$lan = defset('LAN_DATABASE_UPDATE', "An update is available for your database. We recommend [running this update] as soon as possible to ensure that your database is secure and up-to-date.");
|
||||
$srch = array('[',']');
|
||||
$repl = [
|
||||
"<a class='text-info' href='".e_ADMIN_ABS."e107_update.php'>",
|
||||
"</a>"
|
||||
];
|
||||
eHelper::addSystemNotification('core_update', str_replace($srch, $repl, $lan));
|
||||
}
|
||||
else
|
||||
{
|
||||
eHelper::clearSystemNotification('core_update');
|
||||
}
|
||||
// $upStatus = (e107::getSession()->get('core-update-status') === true) ? '<span title="' .ADLAN_120. '" class="text-info"><i class="fa fa-database"></i></span>' : '<!-- -->';
|
||||
|
||||
|
||||
$upStatus = (e107::getSession()->get('core-update-status') === true) ? '<span title="' .ADLAN_120. '" class="text-info"><i class="fa fa-database"></i></span>' : '<!-- -->';
|
||||
|
||||
return varset($template['start']). '<li><a id="e-admin-core-update" tabindex="0" href="'.e_ADMIN_ABS.'e107_update.php" class="e-popover text-primary" role="button" data-container="body" data-toggle="popover" data-bs-toggle="popover" data-placement="right" data-trigger="bottom" data-content="'.$tp->toAttribute(ADLAN_120).'">'.$upStatus.'</a></li>' .varset($template['end']);
|
||||
return;
|
||||
// return varset($template['start']). '<li><a id="e-admin-core-update" tabindex="0" href="'.e_ADMIN_ABS.'e107_update.php" class="e-popover text-primary" role="button" data-container="body" data-toggle="popover" data-bs-toggle="popover" data-placement="right" data-trigger="bottom" data-content="'.$tp->toAttribute(ADLAN_120).'">'.$upStatus.'</a></li>' .varset($template['end']);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -206,6 +206,7 @@ $ADMIN_TEMPLATE['header'] = '
|
||||
{ADMIN_MULTISITE}
|
||||
{ADMIN_PM}
|
||||
{ADMIN_DEBUG}
|
||||
{ADMIN_NOTIFICATIONS}
|
||||
{ADMIN_UPDATE}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -4864,6 +4864,8 @@ class eHelper
|
||||
protected static $_idRegEx = '#[^\w\-]#';
|
||||
protected static $_styleRegEx = '#[^\w\s\-\.;:!]#';
|
||||
|
||||
protected static $_systemNotify = 'systemNotifications';
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* @return array|string|string[]|null
|
||||
@@ -4873,6 +4875,39 @@ class eHelper
|
||||
return preg_replace(self::$_classRegEx, '', $string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getSystemNotification()
|
||||
{
|
||||
return (array) e107::getSession()->get(self::$_systemNotify);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param string $message
|
||||
* @return array|e_core_session|null
|
||||
*/
|
||||
public static function addSystemNotification($id, $message)
|
||||
{
|
||||
return e107::getSession()->set(self::$_systemNotify.'/'.$id.'/message', $message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return array|e_core_session|null
|
||||
*/
|
||||
public static function clearSystemNotification($id = '')
|
||||
{
|
||||
$key = !empty($id) ? self::$_systemNotify.'/'.$id : self::$_systemNotify;
|
||||
|
||||
return e107::getSession()->clear($key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* @return array|string|string[]|null
|
||||
|
@@ -383,7 +383,7 @@ define("LAN_NOPERMISSION", "no permissions");
|
||||
define("LAN_NO_ADMIN_PERMISSION", "You do not have administrator permissions for [x]");
|
||||
|
||||
define("LAN_CREDITS","Credits");
|
||||
define("LAN_NEWVERSION","e107 v[x] Available");
|
||||
define("LAN_NEWVERSION","e107 v[x] is available for download.");
|
||||
|
||||
define("LAN_CHECKALL", "Check All");
|
||||
define("LAN_UNCHECKALL", "Uncheck All");
|
||||
@@ -597,4 +597,8 @@ define("LAN_UI_FILTER_THIS_YEAR", "This Year");
|
||||
|
||||
define("LAN_SEARCH_ENGINES_X_LIMIT", "Read by search engines. Maximum [x] characters.");
|
||||
define("LAN_META_TITLE", "Meta Title");
|
||||
define("LAN_META_DESCRIPTION", "Meta Description");
|
||||
define("LAN_META_DESCRIPTION", "Meta Description");
|
||||
|
||||
define("LAN_SYSTEM_NOTIFICATIONS_X", "[x] System Notification(s)");
|
||||
define("LAN_PHP_OUTDATED", "Your website is currently running an [outdated version of PHP], which may pose a security risk. If your plugins will allow it, we recommend upgrading to [x] to ensure that your website is secure and up-to-date.");
|
||||
define("LAN_DATABASE_UPDATE", "An update is available for your database. We recommend [running this update] as soon as possible to ensure that your database is secure and up-to-date.");
|
@@ -470,6 +470,14 @@ img.image-selector { margin-bottom:0; }
|
||||
.dropdown-menu i,
|
||||
.dropdown-menu img { padding: 0 0; margin-right: 10px; }
|
||||
|
||||
.dropdown-menu li.dropdown-item-text { padding:15px}
|
||||
.dropdown-menu li.dropdown-item-text:hover { background: rgba(255,255,255,0.05) }
|
||||
.dropdown-menu li.dropdown-item-text { border-bottom:1px solid rgba(255,255,255,0.3)}
|
||||
.dropdown-menu > li.dropdown-item-text > a { display: inline !important; padding:0; white-space:normal }
|
||||
.dropdown-menu > li.dropdown-item-text > a:focus,
|
||||
.dropdown-menu > li.dropdown-item-text > a:hover { background: none; color: white !important }
|
||||
#admin-notifications ul.dropdown-menu { width:400px; max-height:calc(100vh - 300px); overflow-y:scroll }
|
||||
|
||||
ul.navbar-nav li ul.dropdown-menu > li a img,
|
||||
ul.navbar-nav li ul.dropdown-menu > li a i,
|
||||
ul#e-latest img,
|
||||
|
@@ -1475,7 +1475,7 @@ td.visible-print,th.visible-print{display:table-cell!important}
|
||||
.text-success,.text-success:hover{color:#51a351}
|
||||
.text-danger,.text-danger:hover{color:#F86965}
|
||||
.text-warning,.text-warning:hover{color:#f89406}
|
||||
.text-info,.text-info:hover{color:#5bc0de}
|
||||
.text-info,.text-info:hover{color:#8BC0ED !important}
|
||||
.table a{text-decoration:underline}
|
||||
.table .danger,.table .info,.table .success,.table .warning{color:#fff}
|
||||
.table-bordered tbody tr.danger td,.table-bordered tbody tr.danger:hover td,.table-bordered tbody tr.success td,.table-bordered tbody tr.success:hover td,.table-bordered tbody tr.warning td,.table-bordered tbody tr.warning:hover td{border-color:#0a0a0a}
|
||||
|
Reference in New Issue
Block a user