Skip to content

Commit 3892af0

Browse files
authored
Merge pull request #459 from Nicola1971/extras-check
#458 OutdatedExtrasCheck plugin
2 parents aefd6b4 + 9d01ae5 commit 3892af0

3 files changed

Lines changed: 167 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
// ---------------------------------------------------------------
3+
// :: OutdatedExtrasCheck
4+
// ----------------------------------------------------------------
5+
//
6+
//
7+
//
8+
// ----------------------------------------------------------------
9+
// :: Copyright & Licencing
10+
// ----------------------------------------------------------------
11+
//
12+
// GNU General Public License (GPL - http://www.gnu.org/copyleft/gpl.html)
13+
//
14+
15+
$_oec_lang['title'] = 'Extras compatibility check';
16+
$_oec_lang['isoutdated'] = 'is <b>outdated</b> and no more compatible with';
17+
$_oec_lang['please_update'] = 'Please update';
18+
$_oec_lang["to_latest"] = 'to the latest version';
19+
$_oec_lang['min _required'] = 'min required';
20+
$_oec_lang['from'] = 'from';
21+
$_oec_lang['extras_module'] = 'Extras Module';
22+
$_oec_lang['or_move_to'] = 'or move to';
23+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
// ---------------------------------------------------------------
3+
// :: OutdatedExtrasCheck
4+
// ----------------------------------------------------------------
5+
//
6+
//
7+
//
8+
// ----------------------------------------------------------------
9+
// :: Copyright & Licencing
10+
// ----------------------------------------------------------------
11+
//
12+
// GNU General Public License (GPL - http://www.gnu.org/copyleft/gpl.html)
13+
//
14+
15+
$_oec_lang['title'] = 'Controllo Compatibilità Extras';
16+
$_oec_lang['isoutdated'] = 'è <b>obsoleto</b> e non compatibile con';
17+
$_oec_lang['please_update'] = 'Aggiorna';
18+
$_oec_lang["to_latest"] = 'all\'ultima versione';
19+
$_oec_lang['min _required'] = 'minima richiesta ';
20+
$_oec_lang['from'] = 'dal';
21+
$_oec_lang['extras_module'] = 'Modulo Extras';
22+
$_oec_lang['or_move_to'] = 'o passa a';
23+
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/**
2+
* OutdatedExtrasCheck
3+
*
4+
* Check for Outdated critical extras not compatible with EVO 1.4.0
5+
*
6+
* @category plugin
7+
* @version 1.4.0
8+
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
9+
* @package evo
10+
* @author Author: Nicola Lambathakis
11+
* @internal @events OnManagerWelcomeHome
12+
* @internal @properties &wdgVisibility=Show widget for:;menu;All,AdminOnly,AdminExcluded,ThisRoleOnly,ThisUserOnly;All &ThisRole=Run only for this role:;string;;;(role id) &ThisUser=Run only for this user:;string;;;(username) &DittoVersion=Min Ditto version:;string;2.1.3 &MtvVersion=Min multiTV version:;string;2.0.12
13+
* @internal @modx_category Manager and Admin
14+
* @internal @installset base
15+
* @internal @disabled 0
16+
*/
17+
18+
// get manager role check
19+
$internalKey = $modx->getLoginUserID();
20+
$sid = $modx->sid;
21+
$role = $_SESSION['mgrRole'];
22+
$user = $_SESSION['mgrShortname'];
23+
// show widget only to Admin role 1
24+
if(($role!=1) AND ($wdgVisibility == 'AdminOnly')) {}
25+
// show widget to all manager users excluded Admin role 1
26+
else if(($role==1) AND ($wdgVisibility == 'AdminExcluded')) {}
27+
// show widget only to "this" role id
28+
else if(($role!=$ThisRole) AND ($wdgVisibility == 'ThisRoleOnly')) {}
29+
// show widget only to "this" username
30+
else if(($user!=$ThisUser) AND ($wdgVisibility == 'ThisUserOnly')) {}
31+
else {
32+
// get plugin id and setting button
33+
$result = $modx->db->select('id', $this->getFullTableName("site_plugins"), "name='{$modx->event->activePlugin}' AND disabled=0");
34+
$pluginid = $modx->db->getValue($result);
35+
if($modx->hasPermission('edit_plugin')) {
36+
$button_pl_config = '<a data-toggle="tooltip" href="javascript:;" title="' . $_lang["settings_config"] . '" class="text-muted pull-right" onclick="parent.modx.popup({url:\''. MODX_MANAGER_URL.'?a=102&id='.$pluginid.'&tab=1\',title1:\'' . $_lang["settings_config"] . '\',icon:\'fa-cog\',iframe:\'iframe\',selector2:\'#tabConfig\',position:\'center center\',width:\'80%\',height:\'80%\',hide:0,hover:0,overlay:1,overlayclose:1})" ><i class="fa fa-cog fa-spin-hover" style="color:#FFFFFF;"></i> </a>';
37+
}
38+
$modx->setPlaceholder('button_pl_config', $button_pl_config);
39+
//plugin lang
40+
$_oec_lang = array();
41+
$plugin_path = $modx->config['base_path'] . "assets/plugins/extrascheck/";
42+
include($plugin_path . 'lang/english.php');
43+
if (file_exists($plugin_path . 'lang/' . $modx->config['manager_language'] . '.php')) {
44+
include($plugin_path . 'lang/' . $modx->config['manager_language'] . '.php');
45+
}
46+
//run the plugin
47+
// get globals
48+
global $modx,$_lang;
49+
//function to extract snippet version from description <strong></strong> tags
50+
if (!function_exists('getver')) {
51+
function getver($string, $tag)
52+
{
53+
$content ="/<$tag>(.*?)<\/$tag>/";
54+
preg_match($content, $string, $text);
55+
return $text[1];
56+
}
57+
}
58+
$e = &$modx->Event;
59+
$EVOversion = $modx->config['settings_version'];
60+
$output = '';
61+
//get extras module id for the link
62+
$modtable = $modx->getFullTableName('site_modules');
63+
$getExtra = $modx->db->select( "id, name", $modtable, "name='Extras'" );
64+
while( $row = $modx->db->getRow( $getExtra ) ) {
65+
$ExtrasID = $row['id'];
66+
}
67+
//get site snippets table
68+
$table = $modx->getFullTableName('site_snippets');
69+
//check ditto
70+
//get min version from config
71+
$minDittoVersion = $DittoVersion;
72+
//search the snippet by name
73+
$CheckDitto = $modx->db->select( "id, name, description", $table, "name='Ditto'" );
74+
if($CheckDitto != ''){
75+
while( $row = $modx->db->getRow( $CheckDitto ) ) {
76+
//extract snippet version from description <strong></strong> tags
77+
$curr_ditto_version = getver($row['description'],"strong");
78+
//check snippet version and return an alert if outdated
79+
if ($curr_ditto_version < $minDittoVersion){
80+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_ditto_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minDittoVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> '.$_oec_lang['or_move_to'].' <b>DocLister</b></div>';
81+
}
82+
}
83+
}
84+
//end check ditto
85+
86+
//check Multitv
87+
//get min version from config
88+
$minMtvVersion = $MtvVersion;
89+
//search the snippet by name
90+
$CheckMtv = $modx->db->select( "id, name, description", $table, "name='multiTV'" );
91+
if($CheckMtv != ''){
92+
while( $row = $modx->db->getRow( $CheckMtv ) ) {
93+
//extract snippet version from description <strong></strong> tags
94+
$curr_mtv_version = getver($row['description'],"strong");
95+
//check snippet version and return an alert if outdated
96+
if ($curr_mtv_version < $minMtvVersion){
97+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_mtv_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minMtvVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a></div>';
98+
}
99+
}
100+
}
101+
//end check Multitv
102+
if($output != ''){
103+
if($e->name == 'OnManagerWelcomeHome') {
104+
$out = $output;
105+
$wdgTitle = 'EVO '.$EVOversion.' - '.$_oec_lang['title'].'';
106+
$widgets['xtraCheck'] = array(
107+
'menuindex' =>'0',
108+
'id' => 'xtraCheck'.$pluginid.'',
109+
'cols' => 'col-md-12',
110+
'headAttr' => 'style="background-color:#B60205; color:#FFFFFF;"',
111+
'bodyAttr' => 'style="background-color:#FFFFFF; color:#24292E;"',
112+
'icon' => 'fa-warning',
113+
'title' => ''.$wdgTitle.' '.$button_pl_config.'',
114+
'body' => '<div class="card-body">'.$out.'</div>',
115+
'hide' => '0'
116+
);
117+
$e->output(serialize($widgets));
118+
return;
119+
}
120+
}
121+
}

0 commit comments

Comments
 (0)