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- }
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 &EformVersion=Min eForm version:;string;1.4.9 &AjaxSearchVersion=Min AjaxSearch version:;string;1.11.0 &MtvVersion=Min multiTV version:;string;2.0.12 &badthemes=Outdated Manager Themes:;string;MODxRE2_DropdownMenu,MODxRE2,MODxRE,MODxCarbon,MODxFLAT,wMOD,ScienceStyle
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+ //check outdated files
68+ //ajax index
69+ $indexajax = "../index-ajax.php";
70+ if (file_exists($indexajax)){
71+ $output .= ' <div class="widget-wrapper alert alert-danger"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>index-ajax.php</b> ' .$_oec_lang [' not_used' ].' <b>Evolution ' .$EVOversion .' </b>. ' .$_oec_lang [' if_dont_use' ].' , ' .$_oec_lang [' please_delete' ].' .</div>' ;
72+ }
73+ //check outdated default manager themes
74+ $oldthemes = explode(",","$badthemes");
75+ foreach ($oldthemes as $oldtheme){
76+ if (file_exists(' media/style/' .$oldtheme )){
77+ $output .= ' <div class="widget-wrapper alert alert-danger"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' .$oldtheme .' </b> ' .$_lang [" manager_theme" ].' , ' .$_oec_lang [' isoutdated' ].' <b>Evolution ' .$EVOversion .' </b>. ' .$_oec_lang [' please_delete' ].' ' .$_oec_lang [' from_folder' ].' ' . MODX_MANAGER_PATH . ' media/style/.</div>' ;
78+ }
79+ }
80+ //get site snippets table
81+ $table = $modx->getFullTableName('site_snippets');
82+ //check ditto
83+ //get min version from config
84+ $minDittoVersion = $DittoVersion;
85+ //search the snippet by name
86+ $CheckDitto = $modx->db->select( "id, name, description", $table, "name='Ditto'" );
87+ if($CheckDitto != ''){
88+ while( $row = $modx -> db -> getRow ( $CheckDitto ) ) {
89+ //extract snippet version from description < strong>< /strong> tags
90+ $curr_ditto_version = getver($row [' description' ]," strong" );
91+ //check snippet version and return an alert if outdated
92+ if ($curr_ditto_version < $minDittoVersion ){
93+ $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>' ;
94+ }
95+ }
96+ }
97+ //end check ditto
98+
99+ //check eform
100+ //get min version from config
101+ $minEformVersion = $EformVersion;
102+ //search the snippet by name
103+ $CheckEform = $modx->db->select( "id, name, description", $table, "name='eForm'" );
104+ if($CheckEform != ''){
105+ while( $row = $modx -> db -> getRow ( $CheckEform ) ) {
106+ //extract snippet version from description < strong>< /strong> tags
107+ $curr_Eform_version = getver($row [' description' ]," strong" );
108+ //check snippet version and return an alert if outdated
109+ if ($curr_Eform_version < $minEformVersion ){
110+ $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_Eform_version . ' ) ' .$_oec_lang [' isoutdated' ].' <b>Evolution ' .$EVOversion .' </b>. ' .$_oec_lang [' please_update' ].' <b>' . $row [' name' ] . ' </b> ' .$_oec_lang [" to_latest" ].' (' .$_oec_lang [' min _required' ].' ' .$minEformVersion .' ) ' .$_oec_lang [' from' ].' <a target="main" href="index.php?a=112&id=' .$ExtrasID .' ">' .$_oec_lang [' extras_module' ].' </a> ' .$_oec_lang [' or_move_to' ].' <b>FormLister</b></div>' ;
111+ }
112+ }
113+ }
114+ //end check eform
115+
116+ //check AjaxSearch
117+ //get min version from config
118+ $minAjaxSearchVersion = $AjaxSearchVersion;
119+ //search the snippet by name
120+ $CheckAjaxSearch = $modx->db->select( "id, name, description", $table, "name='AjaxSearch'" );
121+ if($CheckAjaxSearch != ''){
122+ while( $row = $modx -> db -> getRow ( $CheckAjaxSearch ) ) {
123+ //extract snippet version from description < strong>< /strong> tags
124+ $curr_AjaxSearch_version = getver($row [' description' ]," strong" );
125+ //check snippet version and return an alert if outdated
126+ if ($curr_AjaxSearch_version < $minAjaxSearchVersion ){
127+ $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_AjaxSearch_version . ' ) ' .$_oec_lang [' isoutdated' ].' <b>Evolution ' .$EVOversion .' </b>. ' .$_oec_lang [' please_update' ].' <b>' . $row [' name' ] . ' </b> ' .$_oec_lang [" to_latest" ].' (' .$_oec_lang [' min _required' ].' ' .$minAjaxSearchVersion .' ) ' .$_oec_lang [' from' ].' <a target="main" href="index.php?a=112&id=' .$ExtrasID .' ">' .$_oec_lang [' extras_module' ].' </a>.</div>' ;
128+ }
129+ }
130+ }
131+ //end check AjaxSearch
132+
133+ //check Multitv
134+ //get min version from config
135+ $minMtvVersion = $MtvVersion;
136+ //search the snippet by name
137+ $CheckMtv = $modx->db->select( "id, name, description", $table, "name='multiTV'" );
138+ if($CheckMtv != ''){
139+ while( $row = $modx -> db -> getRow ( $CheckMtv ) ) {
140+ //extract snippet version from description < strong>< /strong> tags
141+ $curr_mtv_version = getver($row [' description' ]," strong" );
142+ //check snippet version and return an alert if outdated
143+ if ($curr_mtv_version < $minMtvVersion ){
144+ $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>' ;
145+ }
146+ }
147+ }
148+ //end check Multitv
149+
150+ if($output != ''){
151+ if ($e -> name == ' OnManagerWelcomeHome' ) {
152+ $out = $output ;
153+ $wdgTitle = ' EVO ' .$EVOversion .' - ' .$_oec_lang [' title' ].' ' ;
154+ $widgets [' xtraCheck' ] = array(
155+ ' menuindex' => ' 0' ,
156+ ' id' => ' xtraCheck' .$pluginid .' ' ,
157+ ' cols' => ' col-md-12' ,
158+ ' headAttr' => ' style="background-color:#B60205; color:#FFFFFF;"' ,
159+ ' bodyAttr' => ' style="background-color:#FFFFFF; color:#24292E;"' ,
160+ ' icon' => ' fa-warning' ,
161+ ' title' => ' ' .$wdgTitle .' ' .$button_pl_config .' ' ,
162+ ' body' => ' <div class="card-body">' .$out .' </div>' ,
163+ ' hide' => ' 0'
164+ );
165+ $e -> output (serialize($widgets ));
166+ return;
167+ }
168+ }
121169}
0 commit comments